Permalink
Browse files

static keyword on non-global functions, a bunch of gcc warning flags,…

… .gitignore file, and some comment changes.
  • Loading branch information...
petermichaux committed Jul 25, 2011
1 parent 6c6a718 commit cdc8f0ad22fb4cbf252a680c7fdd630c223502f1
Showing with 28 additions and 16 deletions.
  1. +2 −0 .gitignore
  2. +17 −6 Makefile
  3. +1 −2 README
  4. +7 −7 read.c
  5. +1 −1 repl.c
View
@@ -0,0 +1,2 @@
+*.o
+scm
View
@@ -1,23 +1,34 @@
+CC = gcc
+
+FLAGS = -ansi -pedantic-errors -Wall -Wextra \
+ -Wmissing-include-dirs \
+ -Wswitch-default -Wswitch-enum -Wundef \
+ -Wdeclaration-after-statement -Wcast-qual \
+ -Wcast-align -Wstrict-prototypes \
+ -Wmissing-prototypes -Wmissing-declarations \
+ -Wmissing-field-initializers -Wunreachable-code \
+ -Wvariadic-macros -Werror
+
.PHONY: clean cleaner
scm: scm.h util.o model.o read.o eval.o print.o repl.c
- cc -Wall -ansi -o scm util.o model.o read.o eval.o \
+ $(CC) $(FLAGS) -o scm util.o model.o read.o eval.o \
print.o repl.c
util.o: scm.h util.c
- cc -Wall -ansi -c util.c
+ $(CC) $(FLAGS) -c util.c
model.o: scm.h model.c
- cc -Wall -ansi -c model.c
+ $(CC) $(FLAGS) -c model.c
read.o: scm.h read.c
- cc -Wall -ansi -c read.c
+ $(CC) $(FLAGS) -c read.c
eval.o: scm.h eval.c
- cc -Wall -ansi -c eval.c
+ $(CC) $(FLAGS) -c eval.c
print.o: scm.h print.c
- cc -Wall -ansi -c print.c
+ $(CC) $(FLAGS) -c print.c
clean:
rm -f *.o
View
3 README
@@ -7,8 +7,7 @@ that mortals can accomplish the task.
Thanks to Abdulaziz Ghuloum for his paper "An Incremental
Approach to Compiler Construction". The pedagogy of his
-paper which inspired the incremental development of
-Royal Scheme.
+paper inspired the incremental development of Royal Scheme.
Thanks to Alex Shinn for making his Chibi-Scheme
implementation open source. Chibi-Scheme has inspired
View
14 read.c
@@ -2,18 +2,18 @@
#include <ctype.h>
#include "scm.h"
-int scm_is_delimiter(int c) {
+static int scm_is_delimiter(int c) {
return c == '\t' || c == '\n' ||
c == '\r' || c == ' ' ||
c == ')' || c == ';' ||
c == EOF;
}
-int scm_digit_value(int c) {
+static int scm_digit_value(int c) {
return c - '0';
}
-scm_object scm_read_number(FILE *in) {
+static scm_object scm_read_number(FILE *in) {
char is_negative = 0;
int c;
scm_int num = 0, tmp;
@@ -30,10 +30,10 @@ scm_object scm_read_number(FILE *in) {
while (isdigit(c)) {
tmp = num * 10 + scm_digit_value(c);
/* The next line assumes that if adding c in the
- * line causes tmp to overflow, the overflow will
- * mean tmp is less than num. This will be true
- * if the base of the number being read is small
- * in comparison to the size of tmp.
+ * line above causes tmp to overflow, the overflow
+ * will mean tmp is less than num. This will be
+ * true if the base of the number being read is
+ * small in comparison to the size of tmp.
*/
if ((tmp < num) || (tmp > scm_fixnum_max)) {
scm_fatal("scm_read_number: number too large");
View
2 repl.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include "scm.h"
-void repl(void) {
+static void repl(void) {
int p;
scm_object object;

0 comments on commit cdc8f0a

Please sign in to comment.