version 1.9, 2002/06/01 01:40:38 |
version 1.10, 2002/07/05 05:39:42 |
|
|
#include "rpc_parse.h" |
#include "rpc_parse.h" |
#include "rpc_util.h" |
#include "rpc_util.h" |
|
|
static unget_token(token *tokp); |
static void unget_token(token *tokp); |
static findstrconst(char **, char **); |
static void findstrconst(char **, char **); |
static findchrconst(char **, char **); |
static void findchrconst(char **, char **); |
static findconst(char **, char **); |
static void findconst(char **, char **); |
static findkind(char **, token *); |
static void findkind(char **, token *); |
static cppline(char *); |
static int cppline(char *); |
static directive(char *); |
static int directive(char *); |
static printdirective(char *); |
static void printdirective(char *); |
static docppline(char *, int *, char **); |
static void docppline(char *, int *, char **); |
|
|
#define startcomment(where) (where[0] == '/' && where[1] == '*') |
#define startcomment(where) (where[0] == '/' && where[1] == '*') |
#define endcomment(where) (where[-1] == '*' && where[0] == '/') |
#define endcomment(where) (where[-1] == '*' && where[0] == '/') |
|
|
} |
} |
} |
} |
|
|
static |
static void |
unget_token(tokp) |
unget_token(tokp) |
token *tokp; |
token *tokp; |
{ |
{ |
|
|
pushed = 1; |
pushed = 1; |
} |
} |
|
|
static |
static void |
findstrconst(str, val) |
findstrconst(str, val) |
char **str; |
char **str; |
char **val; |
char **val; |
|
|
|
|
p = *str; |
p = *str; |
do { |
do { |
*p++; |
p++; |
} while (*p && *p != '"'); |
} while (*p && *p != '"'); |
if (*p == 0) { |
if (*p == 0) { |
error("unterminated string constant"); |
error("unterminated string constant"); |
|
|
p++; |
p++; |
size = p - *str; |
size = p - *str; |
*val = alloc(size + 1); |
*val = alloc(size + 1); |
|
if (val == NULL) |
|
error("alloc failed"); |
(void) strncpy(*val, *str, size); |
(void) strncpy(*val, *str, size); |
(*val)[size] = 0; |
(*val)[size] = 0; |
*str = p; |
*str = p; |
} |
} |
|
|
static |
static void |
findchrconst(str, val) |
findchrconst(str, val) |
char **str; |
char **str; |
char **val; |
char **val; |
|
|
|
|
p = *str; |
p = *str; |
do { |
do { |
*p++; |
p++; |
} while (*p && *p != '\''); |
} while (*p && *p != '\''); |
if (*p == 0) { |
if (*p == 0) { |
error("unterminated string constant"); |
error("unterminated string constant"); |
|
|
error("empty char string"); |
error("empty char string"); |
} |
} |
*val = alloc(size + 1); |
*val = alloc(size + 1); |
|
if (val == NULL) |
|
error("alloc failed"); |
(void) strncpy(*val, *str, size); |
(void) strncpy(*val, *str, size); |
(*val)[size] = 0; |
(*val)[size] = 0; |
*str = p; |
*str = p; |
} |
} |
|
|
static |
static void |
findconst(str, val) |
findconst(str, val) |
char **str; |
char **str; |
char **val; |
char **val; |
|
|
} |
} |
size = p - *str; |
size = p - *str; |
*val = alloc(size + 1); |
*val = alloc(size + 1); |
|
if (val == NULL) |
|
error("alloc failed"); |
(void) strncpy(*val, *str, size); |
(void) strncpy(*val, *str, size); |
(*val)[size] = 0; |
(*val)[size] = 0; |
*str = p; |
*str = p; |
|
|
{TOK_EOF, "??????"}, |
{TOK_EOF, "??????"}, |
}; |
}; |
|
|
static |
static void |
findkind(mark, tokp) |
findkind(mark, tokp) |
char **mark; |
char **mark; |
token *tokp; |
token *tokp; |
|
|
tokp->kind = TOK_IDENT; |
tokp->kind = TOK_IDENT; |
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); |
for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); |
tokp->str = alloc(len + 1); |
tokp->str = alloc(len + 1); |
|
if (tokp->str == NULL) |
|
error("alloc failed"); |
(void) strncpy(tokp->str, str, len); |
(void) strncpy(tokp->str, str, len); |
tokp->str[len] = 0; |
tokp->str[len] = 0; |
*mark = str + len; |
*mark = str + len; |
} |
} |
|
|
static |
static int |
cppline(line) |
cppline(line) |
char *line; |
char *line; |
{ |
{ |
return (line == curline && *line == '#'); |
return (line == curline && *line == '#'); |
} |
} |
|
|
static |
static int |
directive(line) |
directive(line) |
char *line; |
char *line; |
{ |
{ |
return (line == curline && *line == '%'); |
return (line == curline && *line == '%'); |
} |
} |
|
|
static |
static void |
printdirective(line) |
printdirective(line) |
char *line; |
char *line; |
{ |
{ |
fprintf(fout, "%s", line + 1); |
fprintf(fout, "%s", line + 1); |
} |
} |
|
|
static |
static void |
docppline(line, lineno, fname) |
docppline(line, lineno, fname) |
char *line; |
char *line; |
int *lineno; |
int *lineno; |
|
|
} |
} |
line++; |
line++; |
p = file = alloc(strlen(line) + 1); |
p = file = alloc(strlen(line) + 1); |
|
if (p == NULL) |
|
error("alloc failed"); |
while (*line && *line != '"') { |
while (*line && *line != '"') { |
*p++ = *line++; |
*p++ = *line++; |
} |
} |