lexical.c, new function cp_readchar() for abstraction
This commit is contained in:
parent
9bd2cdfc7b
commit
448099ef94
|
|
@ -104,6 +104,13 @@ pwlist_echo(wordlist *wlist, char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
cp_readchar(char **string, FILE *fptr)
|
||||||
|
{
|
||||||
|
return (*string) ? *(*string)++ : input(fptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CDHW */
|
/* CDHW */
|
||||||
|
|
||||||
wordlist *
|
wordlist *
|
||||||
|
|
@ -169,7 +176,7 @@ nloop:
|
||||||
c = strip(c);
|
c = strip(c);
|
||||||
|
|
||||||
if ((c == '\\' && DIR_TERM != '\\') || (c == '\026') /* ^V */ ) {
|
if ((c == '\\' && DIR_TERM != '\\') || (c == '\026') /* ^V */ ) {
|
||||||
c = quote(string ? *string++ : input(cp_inp_cur));
|
c = quote(cp_readchar(&string, cp_inp_cur));
|
||||||
linebuf[j++] = (char) strip(c);
|
linebuf[j++] = (char) strip(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +219,7 @@ nloop:
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
case '\'':
|
case '\'':
|
||||||
while (((c = (string ? *string++ : input(cp_inp_cur))) != '\'') &&
|
while (((c = cp_readchar(&string, cp_inp_cur)) != '\'') &&
|
||||||
(i < NEW_BSIZE_SP - 1))
|
(i < NEW_BSIZE_SP - 1))
|
||||||
{
|
{
|
||||||
if ((c == '\n') || (c == EOF) || (c == ESCAPE))
|
if ((c == '\n') || (c == EOF) || (c == ESCAPE))
|
||||||
|
|
@ -227,14 +234,14 @@ nloop:
|
||||||
case '`':
|
case '`':
|
||||||
d = c;
|
d = c;
|
||||||
buf[i++] = (char) d;
|
buf[i++] = (char) d;
|
||||||
while (((c = (string ? *string++ : input(cp_inp_cur))) != d) &&
|
while (((c = cp_readchar(&string, cp_inp_cur)) != d) &&
|
||||||
(i < NEW_BSIZE_SP - 2))
|
(i < NEW_BSIZE_SP - 2))
|
||||||
{
|
{
|
||||||
if ((c == '\n') || (c == EOF) || (c == ESCAPE))
|
if ((c == '\n') || (c == EOF) || (c == ESCAPE))
|
||||||
goto gotchar;
|
goto gotchar;
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
linebuf[j++] = (char) c;
|
linebuf[j++] = (char) c;
|
||||||
c = (string ? *string++ : input(cp_inp_cur));
|
c = cp_readchar(&string, cp_inp_cur);
|
||||||
buf[i++] = (char) quote(c);
|
buf[i++] = (char) quote(c);
|
||||||
linebuf[j++] = (char) c;
|
linebuf[j++] = (char) c;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue