version 1.9, 2015/02/23 14:36:03 |
version 1.11, 2015/02/23 17:24:51 |
Line 170 texiputchar(struct texi *p, char c) |
|
Line 170 texiputchar(struct texi *p, char c) |
|
|
|
if ('.' == c && 0 == p->outcol) |
if ('.' == c && 0 == p->outcol) |
fputs("\\&", stdout); |
fputs("\\&", stdout); |
|
if ('\'' == c && 0 == p->outcol) |
|
fputs("\\&", stdout); |
|
|
putchar(c); |
putchar(c); |
p->seenvs = 0; |
p->seenvs = 0; |
|
|
texiexecmacro(struct texi *p, struct teximacro *m, |
texiexecmacro(struct texi *p, struct teximacro *m, |
const char *buf, size_t sz, size_t *pos) |
const char *buf, size_t sz, size_t *pos) |
{ |
{ |
size_t valsz, realsz, aasz, asz, |
size_t valsz, realsz, aasz, asz, |
ssz, i, j, k, start, end; |
ssz, i, j, k, start, end; |
char *val; |
char *val; |
char **args; |
char **args; |
|
const char *cp; |
|
|
args = argparse(p, buf, sz, pos, &asz, m->argsz); |
args = argparse(p, buf, sz, pos, &asz, m->argsz); |
if (asz != m->argsz) |
if (asz != m->argsz) |
Line 492 texiexecmacro(struct texi *p, struct teximacro *m, |
|
Line 495 texiexecmacro(struct texi *p, struct teximacro *m, |
|
texiabort(p, NULL); |
texiabort(p, NULL); |
} |
} |
|
|
j = strlcat(val, args[k], valsz + 1); |
for (cp = args[k]; '\0' != *cp; cp++) |
|
val[j++] = *cp; |
|
|
|
val[j] = '\0'; |
i = end; |
i = end; |
} |
} |
|
|
Line 542 texiword(struct texi *p, const char *buf, |
|
Line 548 texiword(struct texi *p, const char *buf, |
|
'\'' == buf[*pos + 1]) { |
'\'' == buf[*pos + 1]) { |
texiputchars(p, "\\(rq"); |
texiputchars(p, "\\(rq"); |
advance(p, buf, pos); |
advance(p, buf, pos); |
|
} else if ('\\' == buf[*pos]) { |
|
texiputchar(p, buf[*pos]); |
|
texiputchar(p, 'e'); |
} else |
} else |
texiputchar(p, buf[*pos]); |
texiputchar(p, buf[*pos]); |
advance(p, buf, pos); |
advance(p, buf, pos); |
Line 1158 argparse(struct texi *p, const char *buf, |
|
Line 1167 argparse(struct texi *p, const char *buf, |
|
args = NULL; |
args = NULL; |
*argsz = 0; |
*argsz = 0; |
|
|
/* Check for no arguments. */ |
if ('{' != buf[*pos] && hint) { |
if ('{' != buf[*pos]) |
/* |
|
* Special case: if we encounter an unbracketed argument |
|
* and we're being invoked with non-zero arguments |
|
* (versus being set, i.e., hint>0), then parse until |
|
* the end of line. |
|
*/ |
|
*argsz = 1; |
|
args = calloc(1, sizeof(char *)); |
|
if (NULL == args) |
|
texiabort(p, NULL); |
|
start = *pos; |
|
while (*pos < sz) { |
|
if ('\n' == buf[*pos]) |
|
break; |
|
advance(p, buf, pos); |
|
} |
|
args[0] = malloc(*pos - start + 1); |
|
memcpy(args[0], &buf[start], *pos - start); |
|
args[0][*pos - start] = '\0'; |
|
if (*pos < sz && '\n' == buf[*pos]) |
|
advance(p, buf, pos); |
return(args); |
return(args); |
|
} else if ('{' != buf[*pos]) |
|
return(args); |
|
|
/* Parse til the closing '}', putting into the array. */ |
/* Parse til the closing '}', putting into the array. */ |
advance(p, buf, pos); |
advance(p, buf, pos); |
Line 1194 argparse(struct texi *p, const char *buf, |
|
Line 1225 argparse(struct texi *p, const char *buf, |
|
/* Test for zero-length '{ }'. */ |
/* Test for zero-length '{ }'. */ |
if (start == end && '}' == buf[*pos] && 0 == *argsz) |
if (start == end && '}' == buf[*pos] && 0 == *argsz) |
break; |
break; |
if (start == end) |
|
texierr(p, "zero-length argument"); |
|
/* FIXME: use reallocarray. */ |
/* FIXME: use reallocarray. */ |
args = realloc |
args = realloc |
(args, sizeof(char *) * |
(args, sizeof(char *) * |