diff options
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | startmode.c | 34 | ||||
-rw-r--r-- | test/Makefile | 6 |
3 files changed, 15 insertions, 39 deletions
@@ -1,24 +1,28 @@ -CC=cc +CC=gcc CFLAGS=-Wfatal-errors -Wall -Werror -Wextra -g -O2 -static CFLAGS_TESTBIN=-Wfatal-errors -Wall -Werror -Wextra -g -fsanitize=address TARGET=7ed TESTTARGET=7ed-TESTING INSTALL_DIRECTORY=/usr/local/bin - +MAKEFLAGS += -s all: 7ed 7ed: + echo "CC 7ed.c functions.c startmode.c editmode.c ---> $(TARGET)" $(CC) $(CFLAGS) 7ed.c functions.c startmode.c editmode.c -o $(TARGET) - @echo "$(TARGET) is done. Run 'make install' as root to install it" + echo "$(TARGET) is done. Run 'make install' as root to install it" clean: + echo "rm -f $(TARGET)" rm -f $(TARGET) + echo "rm -f test/$(TESTTARGET)" rm -f test/$(TESTTARGET) tests: + echo "CC 7ed.c functions.c startmode.c editmode.c ---> test/$(TESTTARGET)" $(CC) $(CFLAGS_TESTBIN) 7ed.c functions.c startmode.c editmode.c -o test/$(TESTTARGET) install: - @cp $(TARGET) $(INSTALL_DIRECTORY) - @echo "$(TARGET) was installed to $(INSTALL_DIRECTORY)" + cp $(TARGET) $(INSTALL_DIRECTORY) + echo "$(TARGET) was installed to $(INSTALL_DIRECTORY)" diff --git a/startmode.c b/startmode.c index 9e0daf1..8f75069 100644 --- a/startmode.c +++ b/startmode.c @@ -146,39 +146,9 @@ int startmode(char filename[]) { break; case 'n': case 'N': { - // The "focus" that the newline will be inserted afterwards - uint64_t new_line_pos_temp = 0; // temp - char buf[1024]; - int success; - - do { - fprintf(stdout, "Create a new line after: "); - if (!fgets(buf, 1024, stdin)) { // take input from user - fprintf(stderr, "Too many characters\n"); - break; - } - char *endptr; - - new_line_pos_temp = strtol(buf, &endptr, 10); - errno = 0; - if (errno == ERANGE) { - fprintf(stderr, "Sorry, this number is too small or too large.\n"); - success = 0; - } - else if (endptr == buf) { - // no character was read - success = 0; - } - else if (*endptr && *endptr != '\n') { - success = 0; - } - - else { - success = 1; - } + + new_line(filename, focus); // create new line after the current focus - } while (!success); - new_line(filename, new_line_pos_temp); break; } case 'X': case 'x': diff --git a/test/Makefile b/test/Makefile index 75145a3..a97614b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,8 +1,10 @@ +MAKEFLAGS += -s + all: 7ed-TESTING 7ed-TESTING: cd .. && make tests - @echo "Done." + echo "Done." clean: cd .. && make clean - @echo "Cleaned." + echo "Cleaned." |