diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-22 20:57:50 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-22 20:57:50 +0100 |
commit | bd76057e8c5ac7f97455f1708a8bb4d0dbb1841b (patch) | |
tree | 8e904df009ca6a326f87d9f94fdf7fe902e1c8ef | |
parent | Move C and Scheme code into subdirs. (diff) | |
download | calp-bd76057e8c5ac7f97455f1708a8bb4d0dbb1841b.tar.gz calp-bd76057e8c5ac7f97455f1708a8bb4d0dbb1841b.tar.xz |
Fix errors shown by scan-build.
-rw-r--r-- | src/parse.c | 11 | ||||
-rw-r--r-- | src/strbuf.c | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/parse.c b/src/parse.c index 0e37350d..565e1d6c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -309,7 +309,6 @@ FREE_F(parse_ctx) { int handle_escape (parse_ctx* ctx) { char esc = fgetc(ctx->f); - char target; /* * Escape character '\' and escaped token sepparated by a newline @@ -330,19 +329,19 @@ int handle_escape (parse_ctx* ctx) { /* Escaped new_line */ if (esc == 'n' || esc == 'N') { - target = '\n'; + esc = '\n'; - /* "Standard" escaped character */ + /* "Standard" escaped character */ } else if (esc == ';' || esc == ',' || esc == '\\') { - target = esc; + /* esc already contains character, do nothing */ - /* Invalid escaped character */ + /* Invalid escaped character */ } else { ERR_P(ctx, "Non escapable character '%c' (%i)", esc, esc); } /* save escapade character as a normal character */ - strbuf_append(&ctx->str, target); + strbuf_append(&ctx->str, esc); ++ctx->column; ++ctx->pcolumn; diff --git a/src/strbuf.c b/src/strbuf.c index 0e56468b..c7e3f2b5 100644 --- a/src/strbuf.c +++ b/src/strbuf.c @@ -86,10 +86,10 @@ int strbuf_cmp(strbuf* a, strbuf* b) { b == NULL || b->alloc == 0) { ERR("a or b not alloced"); - // return -1; + return -1; + } else { + return strncmp(a->mem, b->mem, a->len); } - - return strncmp(a->mem, b->mem, a->len); } int strbuf_c(strbuf* a, const char* b) { |