static void reverse_names(ProcList *p) { if (!p) return; reverse_names(p->nxt); fprintf(th, " \"%s\",\n", p->n->name); }
void genheader(void) { ProcList *p; int i; if (separate == 2) { putunames(th); goto here; } fprintf(th, "#define SYNC %d\n", u_sync); fprintf(th, "#define ASYNC %d\n\n", u_async); putunames(th); fprintf(tc, "short Air[] = { "); for (p = rdy, i=0; p; p = p->nxt, i++) fprintf(tc, "%s (short) Air%d", (p!=rdy)?",":"", i); fprintf(tc, ", (short) Air%d", i); /* np_ */ fprintf(tc, " };\n"); fprintf(th, "char *procname[] = {\n"); reverse_names(rdy); fprintf(th, " \":np_:\",\n"); fprintf(th, "};\n\n"); here: for (p = rdy; p; p = p->nxt) put_ptype(p->n->name, p->tn, mst, nrRdy+1); /* +1 for np_ */ put_ptype("np_", nrRdy, mst, nrRdy+1); ntimes(th, 0, 1, Head0); if (separate != 2) { extern void c_add_stack(FILE *); ntimes(th, 0, 1, Header); c_add_stack(th); ntimes(th, 0, 1, Header0); } ntimes(th, 0, 1, Head1); LstSet = ZS; (void) doglobal("", PUTV); hastrack = c_add_sv(th); fprintf(th, " uchar sv[VECTORSZ];\n"); fprintf(th, "} State"); #ifdef SOLARIS fprintf(th,"\n#ifdef GCC\n"); fprintf(th, "\t__attribute__ ((aligned(8)))"); fprintf(th, "\n#endif\n\t"); #endif fprintf(th, ";\n\n"); fprintf(th, "#define HAS_TRACK %d\n", hastrack); if (separate != 2) dohidden(); }
void reference::output(FILE *fp) { fputs(".]-\n", fp); for (int i = 0; i < 256; i++) if (field_index[i] != NULL_FIELD_INDEX && i != annotation_field) { string &f = field[field_index[i]]; if (!csdigit(i)) { int j = reverse_fields.search(i); if (j >= 0) { int n; int len = reverse_fields.length(); if (++j < len && csdigit(reverse_fields[j])) { n = reverse_fields[j] - '0'; for (++j; j < len && csdigit(reverse_fields[j]); j++) // should check for overflow n = n*10 + reverse_fields[j] - '0'; } else n = INT_MAX; reverse_names(f, n); } } int is_multiple = join_fields(f) > 0; if (capitalize_fields.search(i) >= 0) capitalize_field(f); if (memchr(f.contents(), '\n', f.length()) == 0) { fprintf(fp, ".ds [%c ", i); if (f[0] == ' ' || f[0] == '\\' || f[0] == '"') putc('"', fp); put_string(f, fp); putc('\n', fp); } else { fprintf(fp, ".de [%c\n", i); put_string(f, fp); fputs("..\n", fp); } if (i == 'P') { int multiple_pages = 0; const char *s = f.contents(); const char *end = f.contents() + f.length(); for (;;) { const char *token_start = s; if (!get_token(&s, end)) break; const token_info *ti = lookup_token(token_start, s); if (ti->is_hyphen() || ti->is_range_sep()) { multiple_pages = 1; break; } } fprintf(fp, ".nr [P %d\n", multiple_pages); } else if (i == 'E') fprintf(fp, ".nr [E %d\n", is_multiple); } for (const char *p = "TAO"; *p; p++) { int fi = field_index[(unsigned char)*p]; if (fi != NULL_FIELD_INDEX) { string &f = field[fi]; fprintf(fp, ".nr [%c %d\n", *p, is_terminated(f.contents(), f.contents() + f.length())); } } int t = classify(); fprintf(fp, ".][ %d %s\n", t, reference_types[t]); if (annotation_macro.length() > 0 && annotation_field >= 0 && field_index[annotation_field] != NULL_FIELD_INDEX) { putc('.', fp); put_string(annotation_macro, fp); putc('\n', fp); put_string(field[field_index[annotation_field]], fp); } }