diff options
-rw-r--r-- | attocc.c | 16 | ||||
-rw-r--r-- | makefile | 2 |
2 files changed, 11 insertions, 7 deletions
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ #include <fcntl.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -26,6 +27,8 @@ #define DEBUG #endif +#define TRAP kill(getpid(), SIGTRAP); + const int NUM_KEYWORDS = 32; static char *KEYWORDS[] = { "auto", "break", "case", "char", "const", "continue", @@ -273,17 +276,19 @@ void *memcpy(void *dest, const void *src, unsigned long size) { // not to specification but this program only needs to check equality int strncmp(const char *a, const char *b, unsigned long len) { - while (len--) - if (*a++ != *b++) - return 1; + while (len--) { + if (*a != *b) + return *a - *b; + a++; + b++; + } return 0; } - unsigned long strlen(const char *s) { int len = 0; while (*s++) len++; - return len - 1; + return len; } char *strdup(const char *s) { int len = strlen(s); @@ -316,7 +321,6 @@ struct token *tokenize(char *source) { struct token *tokens = NULL; while (*p) { unsigned long remaining = end - p; - printf("%li\n", p - source); //* whitespace if (p[0] == ' ' || p[0] == '\t' || p[0] == '\n') { @@ -11,7 +11,7 @@ attocc: attocc.c cc -DDEBUG -O3 -o $@ $< attocc-debug: attocc.c - cc -DDEBUG -Wall -Wextra -Wpedantic -o $@ $< + cc -DDEBUG -Wall -Wextra -Wpedantic -Og -g -o $@ $< attocc-small: attocc.c cc -DDEBUG -Wl,--gc-sections -flto -ffunction-sections -fdata-sections -fPIC -s -Os -o $@ $< |