aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-11 01:38:44 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-11 01:38:44 -0700
commit2baadd9ba00a84b3daa5c7028e7129223fbd5b1d (patch)
treeadfc8af77a7edd866f28e0853aa6d7460b7abb86
parent05ad83f8f08a342042e4cd05abbee733833c40a7 (diff)
Tightening up the makefile flags and vim modelines
-rw-r--r--Makefile8
-rw-r--r--bpeg.c2
-rw-r--r--compiler.c10
-rw-r--r--compiler.h1
-rw-r--r--grammar.c2
-rw-r--r--grammar.h1
-rw-r--r--types.h1
-rw-r--r--utils.c1
-rw-r--r--utils.h1
-rw-r--r--vm.c3
-rw-r--r--vm.h1
11 files changed, 22 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 986ecdc..a6ce457 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
PREFIX=/usr/local
-CFLAGS=-Wall -Wextra -pedantic -Wmissing-prototypes -Wstrict-prototypes
+CFLAGS=-std=c99 -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L
+CWARN=-Wall -Wpedantic -Wextra -Wno-unknown-pragmas -Wno-missing-field-initializers\
+ -Wno-padded -Wsign-conversion -Wno-missing-noreturn -Wno-cast-qual -Wtype-limits
LDFLAGS=
G ?=
O ?= -O3
@@ -10,10 +12,10 @@ OBJFILES=$(CFILES:.c=.o)
all: bpeg
.c.o:
- cc -c $(CFLAGS) $(G) $(O) -o $@ $<
+ cc -c $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $<
bpeg: $(OBJFILES) bpeg.c
- cc $(CFLAGS) $(G) $(O) -o $@ $^
+ cc $(CFLAGS) $(CWARN) $(G) $(O) -o $@ $^
clean:
rm -f bpeg $(OBJFILES)
diff --git a/bpeg.c b/bpeg.c
index 23fa6fc..01073a0 100644
--- a/bpeg.c
+++ b/bpeg.c
@@ -144,4 +144,4 @@ int main(int argc, char *argv[])
return 0;
}
-//vim: ts=4
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/compiler.c b/compiler.c
index 88919cf..067101b 100644
--- a/compiler.c
+++ b/compiler.c
@@ -157,7 +157,7 @@ vm_op_t *bpeg_simplepattern(const char *str)
len = unescape_string(literal, literal, len);
op->op = VM_STRING;
- op->len = len;
+ op->len = (ssize_t)len;
op->args.s = literal;
check(matchchar(&str, endquote), "Missing closing quote");
@@ -372,8 +372,8 @@ vm_op_t *bpeg_simplepattern(const char *str)
const char *refname = str;
str = after_name(str);
op->op = VM_REF;
- op->len = (size_t)(str - refname);
- op->args.s = strndup(refname, op->len);
+ op->len = (ssize_t)(str - refname);
+ op->args.s = strndup(refname, (size_t)op->len);
break;
} else {
free(op);
@@ -410,7 +410,7 @@ vm_op_t *bpeg_stringpattern(const char *str)
size_t len = (size_t)(str - literal);
literal = strndup(literal, len);
len = unescape_string(literal, literal, len);
- strop->len = len;
+ strop->len = (ssize_t)len;
strop->args.s = literal;
strop->end = str;
@@ -459,3 +459,5 @@ vm_op_t *bpeg_pattern(const char *str)
if (op != NULL) op = expand_choices(op);
return op;
}
+
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/compiler.h b/compiler.h
index 916d8fe..855b05d 100644
--- a/compiler.h
+++ b/compiler.h
@@ -14,3 +14,4 @@ vm_op_t *bpeg_replacement(vm_op_t *pat, const char *replacement);
vm_op_t *bpeg_pattern(const char *str);
#endif
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/grammar.c b/grammar.c
index c04587b..6001211 100644
--- a/grammar.c
+++ b/grammar.c
@@ -91,3 +91,5 @@ void print_grammar(grammar_t *g)
{
if (g->pattern) print_pattern(g->pattern);
}
+
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/grammar.h b/grammar.h
index 90cc3f2..e477cc6 100644
--- a/grammar.h
+++ b/grammar.h
@@ -16,3 +16,4 @@ void print_grammar(grammar_t *g);
#endif
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/types.h b/types.h
index ef62cdc..27e9388 100644
--- a/types.h
+++ b/types.h
@@ -87,3 +87,4 @@ typedef struct {
} grammar_t;
#endif
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/utils.c b/utils.c
index 4fdec79..d70d3fc 100644
--- a/utils.c
+++ b/utils.c
@@ -169,3 +169,4 @@ char *readfile(int fd)
return buf;
}
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/utils.h b/utils.h
index c2dd04a..c537853 100644
--- a/utils.h
+++ b/utils.h
@@ -25,3 +25,4 @@ int matchchar(const char **str, char c);
size_t unescape_string(char *dest, const char *src, size_t bufsize);
#endif
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/vm.c b/vm.c
index 50b136a..565f94d 100644
--- a/vm.c
+++ b/vm.c
@@ -41,7 +41,7 @@ match_t *match(grammar_t *g, const char *str, vm_op_t *op)
return m;
}
case VM_STRING: {
- if (strncmp(str, op->args.s, op->len) != 0)
+ if (strncmp(str, op->args.s, (size_t)op->len) != 0)
return NULL;
match_t *m = calloc(sizeof(match_t), 1);
m->op = op;
@@ -447,3 +447,4 @@ void print_match(match_t *m, const char *color, int verbose)
}
}
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1
diff --git a/vm.h b/vm.h
index 965a040..9225461 100644
--- a/vm.h
+++ b/vm.h
@@ -16,3 +16,4 @@ void print_pattern(vm_op_t *op);
void print_match(match_t *m, const char *color, int verbose);
#endif
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1