Computers, how do they even?

This commit is contained in:
Kyle Isom 2020-02-15 01:17:09 +02:00
parent e999245c8e
commit ba6c249454
3 changed files with 74 additions and 59 deletions

View File

@ -1,57 +0,0 @@
VERSION := 0.9.2
CC ?= gcc
TARGET := ke
OBJS := main.o
LIBS := -lefence
PREFIX ?= /usr/local
MANDIR ?= /usr/local/man
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g
CFLAGS += -DKE_VERSION="\"$(TARGET) version $(VERSION)\""
CFLAGS += -D_DEFAULT_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE
all: $(TARGET)
clean:
-rm -f .?*.* *.core *.o *.html tags $(TARGET) $(OBJS)
-rm -rf security
-rm -rf $(TARGET)-$(VERSION)
-rm -f $(TARGET)-$(VERSION).tgz
$(TARGET): $(OBJS)
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS)
install: $(TARGET)
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
install -m 0755 -d $(MANDIR)/man1
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
uninstall:
-rm -f $(PREFIX)/bin/$(TARGET)
-rm -f $(MANDIR)/man1/$(TARGET).1
lint:
-mkdir security
-rats -w 3 $(TARGET).[ch] > security/rats.out
-lint -fhrs $(TARGET).c > security/lint.out
-splint +posixlib $(TARGET).[ch] > security/splint.out
dist: clean
-mkdir $(TARGET)-$(VERSION)
-cp * $(TARGET)-$(VERSION)
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
distclean: clean
-rm -f Makefile
htmldoc:
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
tags:
ctags *.[ch]
.c.o:
$(CC) -c ${CFLAGS} $?
.PHONY: clean all install lint uninstall dist distclean htmldoc tags

73
ke/config.sh Executable file
View File

@ -0,0 +1,73 @@
#!/bin/sh
TARGET="$(cat Makefile.in | grep 'TARGET :=' | awk -F' ' '{ print $3; }')"
echo "configuring ${TARGET}"
which sed 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]
then
echo "cannot find sed!" 1>&2
fi
OPSYS=$(uname -s)
echo "Configuring for ${OPSYS}..."
if [ "x${OPSYS}" = "xLinux" ]
then
OS_CFLAGS="-D_DEFAULT_SOURCE -D_XOPEN_SOURCE"
OS_LIBS="-lbsd"
if [ "x${CC}" = "xclang" ]; then
OS_CFLAGS="${OS_CFLAGS} -fsanitize=memory"
fi
if [ -e "/usr/lib/libefence.a" ]
then
OS_LIBS="${OS_LIBS} -lefence"
fi
else
OS_CFLAGS=""
OS_LIBS=""
fi
if [ -z "${OS_CFLAGS}" ]
then
echo "${OPSYS} requires no extra build flags."
else
echo "${OPSYS} requires build flags ${OS_CFLAGS}"
fi
if [ -z "${OS_LIBS}" ]
then
echo "${OPSYS} requires no extra linkages."
else
echo "${OPSYS} requires linking with ${OS_LIBS}."
fi
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
if [ "${PREFIX}" = "/usr" ]
then
MANDIR="$(PREFIX)/share/man"
elif [ "${PREFIX}" = "/usr/local" ]
then
if [ "${OPSYS}" = "Darwin" ]
then
MANDIR="${PREFIX}/share/man"
else
MANDIR="${PREFIX}/man"
fi
else
MANDIR="${PREFIX}/man"
fi
echo "prefix: ${PREFIX}"
echo "mandir: ${MANDIR}"
echo "writing new Makefile"
cat Makefile.in | sed -e "s|OS_CFLAGS|${OS_CFLAGS}|" | \
sed -e "s|OS_LIBS|${OS_LIBS}|" | \
sed -e "s|\$PREFIX|${PREFIX}|" | \
sed -e "s|\$MANDIR|${MANDIR}|" > Makefile
echo "done."

View File

@ -427,7 +427,7 @@ row_delete_ch(struct erow *row, int at)
if (at < 0 || at >= row->size) {
return;
}
memmove(&row->line[at], &row->line[at+1], row->size+1);
memmove(&row->line[at], &row->line[at+1], row->size-at);
row->size--;
erow_update(row);
editor.dirty++;
@ -660,7 +660,6 @@ get_keypress()
if (seq[2] == '~') {
switch (seq[1]) {
case '1': return HOME_KEY;
case '2': return /* INS_KEY */ c;
case '3': return DEL_KEY;
case '4': return END_KEY;
case '5': return PG_UP;