From f4e09f9e9627a510f456d948e9d50a00be9aad93 Mon Sep 17 00:00:00 2001 From: dfs Date: Mon, 9 Feb 1998 00:25:45 +0000 Subject: [PATCH] -- Got dynamic-buffer version to pass acceptance test. --- src/expr.c | 41 ++++++++++++++++++++++------------------- src/files.c | 4 ++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/expr.c b/src/expr.c index 894c60b4..8c7cb2f7 100644 --- a/src/expr.c +++ b/src/expr.c @@ -10,7 +10,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: expr.c,v 1.3 1998-02-07 05:35:58 dfs Exp $"; +static char const RCSID[] = "$Id: expr.c,v 1.4 1998-02-09 00:25:45 dfs Exp $"; #include #include @@ -213,26 +213,29 @@ char **in; case '&': case '|': - case '=': if (**in == c) { - if (DBufPutc(buf, c) != OK) { - DBufFree(buf); - return E_NO_MEM; + case '=': + if (**in == c) { + if (DBufPutc(buf, c) != OK) { + DBufFree(buf); + return E_NO_MEM; + } + (*in)++; } - (*in)++; - } - return OK; + return OK; case '!': case '>': - case '<': if (**in == '=') { - if (DBufPutc(buf, c) != OK) { - DBufFree(buf); - return E_NO_MEM; + case '<': + if (**in == '=') { + if (DBufPutc(buf, '=') != OK) { + DBufFree(buf); + return E_NO_MEM; + } + (*in)++; } - (*in)++; + return OK; } - return OK; - } + /* Handle the parsing of quoted strings */ if (c == '\"') { @@ -283,7 +286,7 @@ char **in; /* Peek ahead - is it '('? Then we have a function call */ if (**in == '(') { - if (DBufPutc(buf, **in++) != OK) { + if (DBufPutc(buf, '(') != OK) { DBufFree(buf); return E_NO_MEM; } @@ -365,7 +368,7 @@ Var *locals; DBufFree(&ExprBuf); return E_MISS_RIGHT_PAREN; } - return OK; + if (r) return r; } else if (*DBufValue(&ExprBuf) == '+') { continue; /* Ignore unary + */ } @@ -387,8 +390,8 @@ Var *locals; free(ufname); } if (r) return r; - (void) ParseExprToken(&ExprBuf, s); /* Guaranteed to be right paren. */ - DBufFree(&ExprBuf); + r = ParseExprToken(&ExprBuf, s); /* Guaranteed to be right paren. */ + if (r) return r; } else { /* Function has some arguments */ while(1) { args++; diff --git a/src/files.c b/src/files.c index f6132aab..7ccc44ac 100644 --- a/src/files.c +++ b/src/files.c @@ -12,7 +12,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: files.c,v 1.4 1998-02-07 05:35:58 dfs Exp $"; +static char const RCSID[] = "$Id: files.c,v 1.5 1998-02-09 00:25:46 dfs Exp $"; #include @@ -169,7 +169,7 @@ static int ReadLineFromFile() DBufFree(&LineBuffer); return E_IO_ERR; } - if (feof(fp) || !DBufLen(&buf)) { + if (feof(fp)) { DBufFree(&buf); FCLOSE(fp); }