diff options
Diffstat (limited to 'attocc.c')
-rw-r--r-- | attocc.c | 16 |
1 files changed, 10 insertions, 6 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') { |