static EORB_CPP_node *newname (char * name) { EORB_CPP_node *n; n = NEW(EORB_CPP_node); check_os_malloc(n); n->op = 'd'; n->name = copyofstr(name); check_os_malloc(n->name); return (n); }
extern void do_set (void) { char *mac; char c; char temp[64]; mac = read_ident(); if (! mac) { err_head(); fprintf(stderr, "@set: missing/illegal macro name\n"); return ; } if (! in_false_if()) { char *cp; c = getnonspace(); if (c != '(') { err_head(); fprintf(stderr, "@set must have ()s\n"); Push(c); return ; } os_sprintf(temp, "%d", eval_expr(0, 1)); undef(mac); cp = copyofstr(temp); check_os_malloc(cp); define(mac, -1, (unsigned char *) cp, DEF_DEFINE); } os_free(mac); }
extern void autodef_file (const char * f) { int i; i = strlen (f); temp = os_malloc (i + 2 + 1); check_os_malloc (temp); os_sprintf ((char*) temp, "\"%s\"", f); undef ("__FILE__"); define ("__FILE__", -1, temp, DEF_DEFINE); }
static EORB_CPP_node * newnode (EORB_CPP_node * l, int c, EORB_CPP_node * r) { EORB_CPP_node *n; n = NEW(EORB_CPP_node); check_os_malloc(n); n->left = l; n->right = r; n->op = c; return (n); }
static EORB_CPP_node * newleaf (int v) { EORB_CPP_node *n; n = NEW(EORB_CPP_node); check_os_malloc(n); n->op = 0; n->left = 0; n->right = 0; n->leaf = v; return (n); }
void init_preprocess(void) { int i; char *cp; init_symtbl(); for (i = 0; predefs[i]; i++) { cp = copyofstr("1"); check_os_malloc(cp); define(predefs[i], -1, (unsigned char *) cp, DEF_PREDEF); } init_include(); keep_comments = 0; no_line_lines = 0; do_at_ctrls = 0; incldep = 0; willbefirst = 1; quote = 0; ifstack = 0; n_skipped_ifs = 0; }
static void read_actuals (DEF * d) { int n; int i; int pc; char c; char last; char quote; int backslash; int comment; char *acc; n = d->nargs; actuals = (char **) os_malloc(n * sizeof(char *)); check_os_malloc(actuals); actlens = (int *) os_malloc(n * sizeof(int)); check_os_malloc(actlens); c = getnonspace(); if (c != '(') { err_head(); if (n == 0) { fprintf(stderr, "missing () on %s\n", d->name); } else { fprintf(stderr, "missing argument%s to %s\n", (n == 1) ? "" : "s", d->name); } for (i = 0;i < n;i++) { actuals[i] = copyofstr(""); check_os_malloc(actuals[i]); actlens[i] = 0; } Push(c); return ; } if (n == 0) { c = getnonspace(); if (c != ')') { err_head(); fprintf(stderr, "unwanted argument to %s\n", d->name); Push(c); } return ; } i = 0; while (1) { pc = 0; quote = 0; backslash = 0; comment = 0; c = 0; acc = init_accum(); while (1) { last = c; c = Get(); accum_char(acc, c); if (comment) { if ((last == '*') && (c == '/')) { comment = 0; } } else { if (backslash) { backslash = 0; } else if (quote && (c == quote)) { quote = 0; } else if (c == '\\') { backslash = 1; } else if (quote) {} else if ((last == '/') && (c == '*')) { comment = 1; } else if ((c == '\'') || (c == '"')) { quote = c; } else if (c == '(') { pc ++; } else if (c == ')') { if (pc > 0) { pc --; } else { accum_regret(acc); break; } } else if ((c == ',') && (pc == 0)) { accum_regret(acc); break; } } } if (i < n) { actuals[i] = accum_result(acc); actlens[i] = strlen(actuals[i]); i ++; } else if (i == n) { err_head(); fprintf(stderr, "too many arguments to %s\n", d->name); i ++; } if (c == ')') { break; } } if (i < n) { err_head(); fprintf(stderr, "too few arguments to %s\n", d->name); for (;i < n;i++) { actuals[i] = copyofstr(""); check_os_malloc(actuals[i]); actlens[i] = 0; } } }