Merge branch 'master' into assign-expr
This commit is contained in:
commit
1d836ff681
10
b.c
10
b.c
|
@ -823,7 +823,15 @@ int relex(void) /* lexical analyzer for reparse */
|
||||||
if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
|
if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
|
||||||
prestr[2 + cc->cc_namelen] == ']') {
|
prestr[2 + cc->cc_namelen] == ']') {
|
||||||
prestr += cc->cc_namelen + 3;
|
prestr += cc->cc_namelen + 3;
|
||||||
for (i = 0; i < NCHARS; i++) {
|
/*
|
||||||
|
* BUG: We begin at 1, instead of 0, since we
|
||||||
|
* would otherwise prematurely terminate the
|
||||||
|
* string for classes like [[:cntrl:]]. This
|
||||||
|
* means that we can't match the NUL character,
|
||||||
|
* not without first adapting the entire
|
||||||
|
* program to track each string's length.
|
||||||
|
*/
|
||||||
|
for (i = 1; i < NCHARS; i++) {
|
||||||
if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
|
if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
|
||||||
FATAL("out of space for reg expr %.10s...", lastre);
|
FATAL("out of space for reg expr %.10s...", lastre);
|
||||||
if (cc->cc_func(i)) {
|
if (cc->cc_func(i)) {
|
||||||
|
|
|
@ -30,4 +30,12 @@ being assigned to, meant that expressions like "print (a = 1) (a = 2)" would
|
||||||
print "22" rather than "12".
|
print "22" rather than "12".
|
||||||
|
|
||||||
9. missing-precision: When using the format string "%*s", the precision
|
9. missing-precision: When using the format string "%*s", the precision
|
||||||
argument was used without checking if it was present first.
|
argument was used without checking if it was present first.
|
||||||
|
|
||||||
|
10. missing-precision: When using the format string "%*s", the precision
|
||||||
|
argument was used without checking if it was present first.
|
||||||
|
|
||||||
|
11. fmt-overflow: The buffer used for OFMT/CONVFMT conversions was written
|
||||||
|
to with sprintf(), which meant that some conversions could write past the
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
BEGIN { OFMT = "%.1000f"; print 1.25; }
|
|
@ -0,0 +1 @@
|
||||||
|
1.2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
18
lex.c
18
lex.c
|
@ -198,6 +198,7 @@ int yylex(void)
|
||||||
yylval.i = c;
|
yylval.i = c;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n': /* {EOL} */
|
case '\n': /* {EOL} */
|
||||||
|
lineno++;
|
||||||
RET(NL);
|
RET(NL);
|
||||||
case '\r': /* assume \n is coming */
|
case '\r': /* assume \n is coming */
|
||||||
case ' ': /* {WS}+ */
|
case ' ': /* {WS}+ */
|
||||||
|
@ -213,6 +214,7 @@ int yylex(void)
|
||||||
case '\\':
|
case '\\':
|
||||||
if (peek() == '\n') {
|
if (peek() == '\n') {
|
||||||
input();
|
input();
|
||||||
|
lineno++;
|
||||||
} else if (peek() == '\r') {
|
} else if (peek() == '\r') {
|
||||||
input(); input(); /* \n */
|
input(); input(); /* \n */
|
||||||
lineno++;
|
lineno++;
|
||||||
|
@ -370,10 +372,11 @@ int string(void)
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
case 0:
|
case 0:
|
||||||
|
*bp = '\0';
|
||||||
SYNTAX( "non-terminated string %.10s...", buf );
|
SYNTAX( "non-terminated string %.10s...", buf );
|
||||||
lineno++;
|
|
||||||
if (c == 0) /* hopeless */
|
if (c == 0) /* hopeless */
|
||||||
FATAL( "giving up" );
|
FATAL( "giving up" );
|
||||||
|
lineno++;
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
c = input();
|
c = input();
|
||||||
|
@ -515,6 +518,7 @@ int regexpr(void)
|
||||||
if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr"))
|
if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr"))
|
||||||
FATAL("out of space for reg expr %.10s...", buf);
|
FATAL("out of space for reg expr %.10s...", buf);
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
|
*bp = '\0';
|
||||||
SYNTAX( "newline in regular expression %.10s...", buf );
|
SYNTAX( "newline in regular expression %.10s...", buf );
|
||||||
unput('\n');
|
unput('\n');
|
||||||
break;
|
break;
|
||||||
|
@ -553,19 +557,19 @@ int input(void) /* get next lexical input character */
|
||||||
lexprog++;
|
lexprog++;
|
||||||
} else /* awk -f ... */
|
} else /* awk -f ... */
|
||||||
c = pgetc();
|
c = pgetc();
|
||||||
if (c == '\n')
|
if (c == EOF)
|
||||||
lineno++;
|
|
||||||
else if (c == EOF)
|
|
||||||
c = 0;
|
c = 0;
|
||||||
if (ep >= ebuf + sizeof ebuf)
|
if (ep >= ebuf + sizeof ebuf)
|
||||||
ep = ebuf;
|
ep = ebuf;
|
||||||
return *ep++ = c;
|
*ep = c;
|
||||||
|
if (c != 0) {
|
||||||
|
ep++;
|
||||||
|
}
|
||||||
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unput(int c) /* put lexical character back on input */
|
void unput(int c) /* put lexical character back on input */
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
|
||||||
lineno--;
|
|
||||||
if (yysptr >= yysbuf + sizeof(yysbuf))
|
if (yysptr >= yysbuf + sizeof(yysbuf))
|
||||||
FATAL("pushed back too much: %.20s...", yysbuf);
|
FATAL("pushed back too much: %.20s...", yysbuf);
|
||||||
*yysptr++ = c;
|
*yysptr++ = c;
|
||||||
|
|
2
lib.c
2
lib.c
|
@ -59,7 +59,7 @@ void recinit(unsigned int n)
|
||||||
{
|
{
|
||||||
if ( (record = (char *) malloc(n)) == NULL
|
if ( (record = (char *) malloc(n)) == NULL
|
||||||
|| (fields = (char *) malloc(n+1)) == NULL
|
|| (fields = (char *) malloc(n+1)) == NULL
|
||||||
|| (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
|
|| (fldtab = (Cell **) malloc((nfields+2) * sizeof(Cell *))) == NULL
|
||||||
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
|
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
|
||||||
FATAL("out of space for $0 and fields");
|
FATAL("out of space for $0 and fields");
|
||||||
*fldtab[0] = dollar0;
|
*fldtab[0] = dollar0;
|
||||||
|
|
2
main.c
2
main.c
|
@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strncmp(argv[1], "--", 2) == 0) { /* explicit end of args */
|
if (strcmp(argv[1], "--") == 0) { /* explicit end of args */
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
break;
|
break;
|
||||||
|
|
6
tran.c
6
tran.c
|
@ -395,7 +395,7 @@ Awkfloat getfval(Cell *vp) /* get float val of a Cell */
|
||||||
|
|
||||||
static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */
|
static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */
|
||||||
{
|
{
|
||||||
char s[100]; /* BUG: unchecked */
|
char s[256];
|
||||||
double dtemp;
|
double dtemp;
|
||||||
|
|
||||||
if ((vp->tval & (NUM | STR)) == 0)
|
if ((vp->tval & (NUM | STR)) == 0)
|
||||||
|
@ -434,9 +434,9 @@ static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cel
|
||||||
if (freeable(vp)) \
|
if (freeable(vp)) \
|
||||||
xfree(vp->sval); \
|
xfree(vp->sval); \
|
||||||
if (modf(vp->fval, &dtemp) == 0) /* it's integral */ \
|
if (modf(vp->fval, &dtemp) == 0) /* it's integral */ \
|
||||||
sprintf(s, "%.30g", vp->fval); \
|
snprintf(s, sizeof (s), "%.30g", vp->fval); \
|
||||||
else \
|
else \
|
||||||
sprintf(s, *fmt, vp->fval); \
|
snprintf(s, sizeof (s), *fmt, vp->fval); \
|
||||||
vp->sval = tostring(s); \
|
vp->sval = tostring(s); \
|
||||||
vp->tval &= ~DONTFREE; \
|
vp->tval &= ~DONTFREE; \
|
||||||
vp->tval |= STR; \
|
vp->tval |= STR; \
|
||||||
|
|
Loading…
Reference in New Issue