summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--attocc.c16
-rw-r--r--makefile2
2 files changed, 11 insertions, 7 deletions
diff --git a/attocc.c b/attocc.c
index 1389f9d..bb6b248 100644
--- a/attocc.c
+++ b/attocc.c
@@ -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') {
diff --git a/makefile b/makefile
index cd8b45b..0364204 100644
--- a/makefile
+++ b/makefile
@@ -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 $@ $<