diff options
author | Preston Pan <135050157+ret2pop@users.noreply.github.com> | 2024-05-02 20:47:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 20:47:58 -0700 |
commit | 104437bf7533798087e77b07756cd6b5dcc45bcd (patch) | |
tree | d60076e1beee31c81e1f8a604f46b4fa0270d83b | |
parent | 4738c0ffe90fc5e46a2a31b061b76d49317b6b1e (diff) | |
parent | 3f6e346cfb9cce3e24c27c400e345eccc34697d9 (diff) |
A few fixes and improvements
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .gitmodules | 2 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | include/stem.h | 6 | ||||
-rw-r--r-- | src/builtins.c | 4 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/stem.c | 2 |
7 files changed, 15 insertions, 11 deletions
@@ -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 @@ -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); @@ -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) { @@ -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); } |