[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/wasted-byte, updated. gawk-4.1.0
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/wasted-byte, updated. gawk-4.1.0-1300-g24ddf27 |
Date: |
Thu, 09 Apr 2015 15:04:35 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/wasted-byte has been updated
via 24ddf2742b0034089bce38e5f4ebd99b93c6e161 (commit)
from 9091a155190093c3d2dbbed4bd29b0feec50c8ce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=24ddf2742b0034089bce38e5f4ebd99b93c6e161
commit 24ddf2742b0034089bce38e5f4ebd99b93c6e161
Author: Arnold D. Robbins <address@hidden>
Date: Thu Apr 9 18:04:18 2015 +0300
Further fixes from Andrew Schorr.
diff --git a/ChangeLog b/ChangeLog
index f94afcf..83d1ffa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-04-09 Andrew J. Schorr <address@hidden>
+
+ * awkgram.y (yyerror): Rationalize buffer size computations. Remove
+ old valgrind workarounds.
+ * debug.c (gprintf): Rationalize buffer size computations.
+ (serialize_subscript): Ditto.
+ * io.c (iop_finish): Rationalize buffer size computations.
+ * profile.c (pp_string): Correct space allocation computation.
+
2015-04-08 John E. Malmberg <address@hidden>
* custom.h: VMS shares some code paths with ZOS_USS in
diff --git a/awkgram.c b/awkgram.c
index 2cc2c54..23213da 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4516,7 +4516,6 @@ yyerror(const char *m, ...)
char *buf;
int count;
static char end_of_file_line[] = "(END OF FILE)";
- char save;
print_included_from();
@@ -4544,24 +4543,15 @@ yyerror(const char *m, ...)
bp = thisline + strlen(thisline);
}
- /*
- * Saving and restoring *bp keeps valgrind happy,
- * since the guts of glibc uses strlen, even though
- * we're passing an explict precision. Sigh.
- *
- * 8/2003: We may not need this anymore.
- */
- save = *bp;
- *bp = '\0';
-
msg("%.*s", (int) (bp - thisline), thisline);
- *bp = save;
va_start(args, m);
if (mesg == NULL)
mesg = m;
- count = (bp - thisline) + strlen(mesg) + 1 + 1;
+ count = strlen(mesg) + 1;
+ if (lexptr != NULL)
+ count += (lexeme - thisline) + 2;
emalloc(buf, char *, count, "yyerror");
bp = buf;
diff --git a/awkgram.y b/awkgram.y
index 9c29db4..ecfab02 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2178,7 +2178,6 @@ yyerror(const char *m, ...)
char *buf;
int count;
static char end_of_file_line[] = "(END OF FILE)";
- char save;
print_included_from();
@@ -2206,24 +2205,15 @@ yyerror(const char *m, ...)
bp = thisline + strlen(thisline);
}
- /*
- * Saving and restoring *bp keeps valgrind happy,
- * since the guts of glibc uses strlen, even though
- * we're passing an explict precision. Sigh.
- *
- * 8/2003: We may not need this anymore.
- */
- save = *bp;
- *bp = '\0';
-
msg("%.*s", (int) (bp - thisline), thisline);
- *bp = save;
va_start(args, m);
if (mesg == NULL)
mesg = m;
- count = (bp - thisline) + strlen(mesg) + 1 + 1;
+ count = strlen(mesg) + 1;
+ if (lexptr != NULL)
+ count += (lexeme - thisline) + 2;
emalloc(buf, char *, count, "yyerror");
bp = buf;
diff --git a/debug.c b/debug.c
index c2f1135..6aaba09 100644
--- a/debug.c
+++ b/debug.c
@@ -4205,10 +4205,10 @@ gprintf(FILE *fp, const char *format, ...)
#define GPRINTF_BUFSIZ 512
if (buf == NULL) {
buflen = GPRINTF_BUFSIZ;
- emalloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ emalloc(buf, char *, buflen * sizeof(char), "gprintf");
} else if (buflen - bl < GPRINTF_BUFSIZ/2) {
buflen += GPRINTF_BUFSIZ;
- erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ erealloc(buf, char *, buflen * sizeof(char), "gprintf");
}
#undef GPRINTF_BUFSIZ
@@ -4227,7 +4227,7 @@ gprintf(FILE *fp, const char *format, ...)
/* enlarge buffer, and try again */
buflen *= 2;
- erealloc(buf, char *, (buflen + 1) * sizeof(char), "gprintf");
+ erealloc(buf, char *, buflen * sizeof(char), "gprintf");
}
bl = 0;
@@ -4267,7 +4267,7 @@ gprintf(FILE *fp, const char *format, ...)
static int
serialize_subscript(char *buf, int buflen, struct list_item *item)
{
- int bl = 0, nchar, i;
+ int bl, nchar, i;
NODE *sub;
nchar = snprintf(buf, buflen, "%d%c%d%c%s%c%d%c",
@@ -4277,7 +4277,7 @@ serialize_subscript(char *buf, int buflen, struct
list_item *item)
return 0;
else if (nchar >= buflen) /* need larger buffer */
return nchar;
- bl += nchar;
+ bl = nchar;
for (i = 0; i < item->num_subs; i++) {
sub = item->subs[i];
nchar = snprintf(buf + bl, buflen - bl, "%lu%c%s%c",
diff --git a/helpers/ChangeLog b/helpers/ChangeLog
index 2cb3be4..5a3f2fe 100644
--- a/helpers/ChangeLog
+++ b/helpers/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-09 Andrew J. Schorr <address@hidden>
+
+ * testdfa.c (setup_pattern): Rationalize buffer size computations.
+
2014-12-18 Arnold D. Robbins <address@hidden>
* testdfa.c (setup_pattern): Do not waste a byte at the end of a string.
diff --git a/helpers/testdfa.c b/helpers/testdfa.c
index 092a13d..2b77346 100644
--- a/helpers/testdfa.c
+++ b/helpers/testdfa.c
@@ -372,10 +372,10 @@ setup_pattern(const char *pattern, size_t *len)
{
size_t is_multibyte = 0;
int c, c2;
- size_t buflen = 0;
+ size_t buflen;
mbstate_t mbs;
bool has_anchor = false;
- char *buf = NULL;
+ char *buf;
char *dest;
const char *src, *end;
@@ -391,21 +391,12 @@ setup_pattern(const char *pattern, size_t *len)
* escaped characters translated, and generate the regex
* from that.
*/
+ buf = (char *) malloc(*len + 1);
if (buf == NULL) {
- buf = (char *) malloc(*len + 1);
- if (buf == NULL) {
- fprintf(stderr, "%s: malloc failed\n", __func__);
- exit(EXIT_FAILURE);
- }
- buflen = *len;
- } else if (*len > buflen) {
- buf = (char *) realloc(buf, *len + 1);
- if (buf == NULL) {
- fprintf(stderr, "%s: realloc failed\n", __func__);
- exit(EXIT_FAILURE);
- }
- buflen = *len;
+ fprintf(stderr, "%s: malloc failed\n", __func__);
+ exit(EXIT_FAILURE);
}
+ buflen = *len;
dest = buf;
while (src < end) {
diff --git a/io.c b/io.c
index da3a04c..1c3d6e2 100644
--- a/io.c
+++ b/io.c
@@ -3164,7 +3164,7 @@ iop_finish(IOBUF *iop)
lintwarn(_("data file `%s' is empty"), iop->public.name);
iop->errcode = errno = 0;
iop->count = iop->scanoff = 0;
- emalloc(iop->buf, char *, iop->size += 2, "iop_finish");
+ emalloc(iop->buf, char *, iop->size += 1, "iop_finish");
iop->off = iop->buf;
iop->dataend = NULL;
iop->end = iop->buf + iop->size;
diff --git a/old-extension/ChangeLog b/old-extension/ChangeLog
index 51f44db..dad5c79 100644
--- a/old-extension/ChangeLog
+++ b/old-extension/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-09 Andrew J. Schorr <address@hidden>
+
+ * bindarr.c (do_bind_array): Undo Arnold's change of 2014-12-18.
+
2014-12-18 Arnold D. Robbins <address@hidden>
* bindarr.c (do_bind_array): Do not waste a byte at the end of a string.
diff --git a/old-extension/bindarr.c b/old-extension/bindarr.c
index 28da389..4146742 100644
--- a/old-extension/bindarr.c
+++ b/old-extension/bindarr.c
@@ -235,7 +235,7 @@ do_bind_array(int nargs)
}
/* copy the array -- this is passed as the second argument to the
functions */
- emalloc(aname, char *, strlen(t->vname) + 1, "do_bind_array");
+ emalloc(aname, char *, 1 + strlen(symbol->vname) + 1, "do_bind_array");
aname[0] = '~'; /* any illegal character */
strcpy(& aname[1], symbol->vname);
td = make_array();
diff --git a/profile.c b/profile.c
index d6d4909..32dfca0 100644
--- a/profile.c
+++ b/profile.c
@@ -1371,10 +1371,9 @@ pp_string(const char *in_str, size_t len, int delim)
*obufout++ = '\\';
*obufout++ = delim;
} else if (*str == '\0') {
- chksize(4);
-
*obufout++ = '\\';
*obufout++ = '0';
+ chksize(2); /* need 2 more chars for this case */
*obufout++ = '0';
*obufout++ = '0';
} else if ((cp = strchr(escapes, *str)) != NULL) {
@@ -1384,7 +1383,7 @@ pp_string(const char *in_str, size_t len, int delim)
/* NB: Deliberate use of lower-case versions. */
} else if (isascii(*str) && isprint(*str)) {
*obufout++ = *str;
- ofre += 1;
+ ofre += 1; /* used 1 less than expected */
} else {
size_t len;
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 9 +++++++++
awkgram.c | 16 +++-------------
awkgram.y | 16 +++-------------
debug.c | 10 +++++-----
helpers/ChangeLog | 4 ++++
helpers/testdfa.c | 21 ++++++---------------
io.c | 2 +-
old-extension/ChangeLog | 4 ++++
old-extension/bindarr.c | 2 +-
profile.c | 5 ++---
10 files changed, 38 insertions(+), 51 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/wasted-byte, updated. gawk-4.1.0-1300-g24ddf27,
Arnold Robbins <=