aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules2
-rw-r--r--Makefile9
-rw-r--r--include/stem.h6
-rw-r--r--src/builtins.c4
-rw-r--r--src/main.c2
-rw-r--r--src/stem.c2
7 files changed, 15 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index b9c9055..992f404 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ tmp/
/latex/**
stem
compile_commands.json
+compile_flags.txt
diff --git a/.gitmodules b/.gitmodules
index cf2ae3c..0752188 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,4 +3,4 @@
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "stemlib"]
path = stemlib
- url = git@github.com:ret2pop/stemlib
+ url = https://github.com/ret2pop/stemlib.git
diff --git a/Makefile b/Makefile
index 242e93f..9ee2833 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ TARGET := stem
SRCEXT := c
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
-CFLAGS :=
+CFLAGS := -MMD -MP
LIB := -L lib -lm
INC := -I include
@@ -13,11 +13,14 @@ $(TARGET): $(OBJECTS)
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) -O3
-$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
+$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) Makefile
@echo " Building..."
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< -save-temps -O3
+compile_flags.txt: Makefile
+ printf "%s\n" $(CFLAGS) $(INC) >$@
+
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)
@@ -33,3 +36,5 @@ doc:
site:
doxygen
rsync -uvrP --delete-after "html/" root@nullring.xyz:/var/www/stemdoc
+
+-include $(OBJECTS:.o=.d)
diff --git a/include/stem.h b/include/stem.h
index f4aff54..c467286 100644
--- a/include/stem.h
+++ b/include/stem.h
@@ -48,14 +48,14 @@ struct VALUE_STRUCT {
/*! @brief Parser implementation directly parses without lexer */
/*! the parser data structure parses a string of valid stem code and
- * returns a value until it reaches EOF or end of string. */
+ * returns a value until it reaches end of string. */
typedef struct PARSER_STRUCT {
/*! @brief The string that contains valid stem code. */
char *source;
/*! @brief Index of current character */
int i;
/*! @brief The current character */
- char c;
+ int c;
} parser_t;
/*! @brief This structure is to be used in singly linked lists that hold
@@ -181,7 +181,7 @@ value_t *parse_word(parser_t *p);
/*! Error in parsing strings can occur if wrong escape code. */
void parser_error(parser_t *p);
-/*! Gets the next value_t from the string, returns NULL if EOF. */
+/*! Gets the next value_t from the string, returns NULL if end of string. */
value_t *parser_get_next(parser_t *p);
/*! Allocates memory for new node struct. */
diff --git a/src/builtins.c b/src/builtins.c
index caf18c2..d6049f3 100644
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -540,7 +540,7 @@ void stemfread(value_t *v) {
eval_error("EMPTY STACK");
return;
}
- char *val = "";
+ char *val = NULL;
size_t len = 0;
FILE *fp = fopen(v1->str_word->value, "rb");
if (!fp) {
@@ -1341,7 +1341,7 @@ void include(value_t *v) {
eval_error("EMPTY STACK");
return;
}
- char *val = "";
+ char *val = NULL;
size_t len = 0;
string_t *strval = init_string("/usr/local/share/stem/stemlib/");
string_concat(strval, v1->str_word);
diff --git a/src/main.c b/src/main.c
index de0abe7..2a6ed6b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,7 +49,7 @@ void sigint_handler(int signum) {
int main(int argc, char **argv) {
value_t *v;
size_t len = 0;
- char *buf = "";
+ char *buf = NULL;
/* Parsing arguments */
if (argc < 2) {
diff --git a/src/stem.c b/src/stem.c
index 651d624..f623ae7 100644
--- a/src/stem.c
+++ b/src/stem.c
@@ -331,8 +331,6 @@ value_t *parser_get_next(parser_t *p) {
return parse_quote(p);
case '\0':
return NULL;
- case EOF:
- return NULL;
default:
return parse_word(p);
}