Minor fixes.

This commit is contained in:
Arnold D. Robbins 2020-01-06 00:01:46 -07:00
parent c7eeb57210
commit 944989bf68
4 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2020-01-06 Arnold D. Robbins <arnold@skeeve.com>
Minor fixes.
* b.c (replace_repeat): Turn init_q back into an int.
* lex.c (string): Use \a instead of \007.
* tran.c (catstr): Use snprintf instead of sprintf.
2020-01-01 Arnold D. Robbins <arnold@skeeve.com>
* tran.c (syminit, arginit, envinit): Free sval member before

2
b.c
View File

@ -909,7 +909,7 @@ replace_repeat(const uschar *reptok, int reptoklen, const uschar *atom,
int i, j;
uschar *buf = 0;
int ret = 1;
bool init_q = (firstnum == 0); /* first added char will be ? */
int init_q = (firstnum == 0); /* first added char will be ? */
int n_q_reps = secondnum-firstnum; /* m>n, so reduce until {1,m-n} left */
int prefix_length = reptok - basestr; /* prefix includes first rep */
int suffix_length = strlen((const char *) reptok) - reptoklen; /* string after rep specifier */

2
lex.c
View File

@ -390,7 +390,7 @@ int string(void)
case 'r': *bp++ = '\r'; break;
case 'b': *bp++ = '\b'; break;
case 'v': *bp++ = '\v'; break;
case 'a': *bp++ = '\007'; break;
case 'a': *bp++ = '\a'; break;
case '\\': *bp++ = '\\'; break;
case '0': case '1': case '2': /* octal: \d \dd \ddd */

6
tran.c
View File

@ -527,12 +527,14 @@ Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */
if (p == NULL)
FATAL("out of space concatenating %s and %s", sa, sb);
snprintf(p, l, "%s%s", sa, sb);
char *newbuf = malloc(strlen(p) + 2);
l++; // add room for ' '
char *newbuf = malloc(l);
if (newbuf == NULL)
FATAL("out of space concatenating %s and %s", sa, sb);
// See string() in lex.c; a string "xx" is stored in the symbol
// table as "xx ".
sprintf(newbuf, "%s ", p);
snprintf(newbuf, l, "%s ", p);
c = setsymtab(newbuf, p, 0.0, CON|STR|DONTFREE, symtab);
free(p);
free(newbuf);