Add ability to print new funcall tokens
Even though they can't be created yet.
This commit is contained in:
parent
26ea0e05b3
commit
d6b4adfc8c
@ -244,6 +244,18 @@ Token **scan(const char **s)
|
||||
return na;
|
||||
}
|
||||
/*}}}*/
|
||||
|
||||
static int print_fident(char* dest, size_t space, int id)
|
||||
{
|
||||
size_t identlen = strlen(tfunc[id].name);
|
||||
if ((identlen+1) < space) strcpy(dest, tfunc[id].name);
|
||||
else {
|
||||
(void)strncpy(dest, tfunc[id].name, space);
|
||||
dest[space-1] = '\0';
|
||||
}
|
||||
return identlen;
|
||||
}
|
||||
|
||||
/* printtok -- print a single token, passed by address, although not changed */ /*{{{*/
|
||||
size_t printtok(char* dest, size_t size, size_t field_width,
|
||||
int quote_strings, int use_scientific,
|
||||
@ -339,17 +351,11 @@ size_t printtok(char* dest, size_t size, size_t field_width,
|
||||
/*}}}*/
|
||||
/* FIDENT */ /*{{{*/
|
||||
case FIDENT:
|
||||
{
|
||||
size_t identlen;
|
||||
if (debug_level > 2) {
|
||||
printf("...Found function [%s].\n", tfunc[tok->u.fident].name);
|
||||
}
|
||||
identlen=strlen(tfunc[tok->u.fident].name);
|
||||
if ((cur+identlen+1)<=size) strcpy(dest+cur,tfunc[tok->u.fident].name);
|
||||
else (void)strncpy(dest+cur,tfunc[tok->u.fident].name,size-cur-1);
|
||||
cur+=identlen;
|
||||
cur += print_fident(dest+cur, size-cur-1, tok->u.fident);
|
||||
break;
|
||||
}
|
||||
/*}}}*/
|
||||
/* LOCATION */ /*{{{*/
|
||||
case LOCATION:
|
||||
@ -362,6 +368,24 @@ size_t printtok(char* dest, size_t size, size_t field_width,
|
||||
break;
|
||||
}
|
||||
/*}}}*/
|
||||
/* FUNCALL */ /*{{{*/
|
||||
case FUNCALL:
|
||||
{
|
||||
cur += print_fident(dest+cur, size-cur-1, tok->u.funcall.fident);
|
||||
if (tok->u.funcall.argc >= 0 && cur + 2 < size) /* -1 args is bare func */
|
||||
{
|
||||
dest[cur++] = '\(';
|
||||
for (size_t ai = 0; ai < tok->u.funcall.argc && cur < size-1; ++ai)
|
||||
{
|
||||
if (ai > 0 && cur < size) dest[cur++] = ',';
|
||||
cur += printtok(dest+cur, size-cur-1, field_width-cur, quote_strings,
|
||||
use_scientific, precision, verbose_error,
|
||||
tok->u.funcall.argv + ai);
|
||||
}
|
||||
if (cur < size) dest[cur++] = ')';
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* EEK */ /*{{{*/
|
||||
case EEK:
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user