-- Got dynamic-buffer version to pass acceptance test.

This commit is contained in:
dfs
1998-02-09 00:25:45 +00:00
parent ce88211f50
commit f4e09f9e96
2 changed files with 24 additions and 21 deletions

View File

@@ -10,7 +10,7 @@
/***************************************************************/ /***************************************************************/
#include "config.h" #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 <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
@@ -213,26 +213,29 @@ char **in;
case '&': case '&':
case '|': case '|':
case '=': if (**in == c) { case '=':
if (DBufPutc(buf, c) != OK) { if (**in == c) {
DBufFree(buf); if (DBufPutc(buf, c) != OK) {
return E_NO_MEM; DBufFree(buf);
return E_NO_MEM;
}
(*in)++;
} }
(*in)++; return OK;
}
return OK;
case '!': case '!':
case '>': case '>':
case '<': if (**in == '=') { case '<':
if (DBufPutc(buf, c) != OK) { if (**in == '=') {
DBufFree(buf); if (DBufPutc(buf, '=') != OK) {
return E_NO_MEM; DBufFree(buf);
return E_NO_MEM;
}
(*in)++;
} }
(*in)++; return OK;
} }
return OK;
}
/* Handle the parsing of quoted strings */ /* Handle the parsing of quoted strings */
if (c == '\"') { if (c == '\"') {
@@ -283,7 +286,7 @@ char **in;
/* Peek ahead - is it '('? Then we have a function call */ /* Peek ahead - is it '('? Then we have a function call */
if (**in == '(') { if (**in == '(') {
if (DBufPutc(buf, **in++) != OK) { if (DBufPutc(buf, '(') != OK) {
DBufFree(buf); DBufFree(buf);
return E_NO_MEM; return E_NO_MEM;
} }
@@ -365,7 +368,7 @@ Var *locals;
DBufFree(&ExprBuf); DBufFree(&ExprBuf);
return E_MISS_RIGHT_PAREN; return E_MISS_RIGHT_PAREN;
} }
return OK; if (r) return r;
} else if (*DBufValue(&ExprBuf) == '+') { } else if (*DBufValue(&ExprBuf) == '+') {
continue; /* Ignore unary + */ continue; /* Ignore unary + */
} }
@@ -387,8 +390,8 @@ Var *locals;
free(ufname); free(ufname);
} }
if (r) return r; if (r) return r;
(void) ParseExprToken(&ExprBuf, s); /* Guaranteed to be right paren. */ r = ParseExprToken(&ExprBuf, s); /* Guaranteed to be right paren. */
DBufFree(&ExprBuf); if (r) return r;
} else { /* Function has some arguments */ } else { /* Function has some arguments */
while(1) { while(1) {
args++; args++;

View File

@@ -12,7 +12,7 @@
/***************************************************************/ /***************************************************************/
#include "config.h" #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 <stdio.h> #include <stdio.h>
@@ -169,7 +169,7 @@ static int ReadLineFromFile()
DBufFree(&LineBuffer); DBufFree(&LineBuffer);
return E_IO_ERR; return E_IO_ERR;
} }
if (feof(fp) || !DBufLen(&buf)) { if (feof(fp)) {
DBufFree(&buf); DBufFree(&buf);
FCLOSE(fp); FCLOSE(fp);
} }