const char * fnnalloc(const char *s, size_t len) { fn_t *fn; static int nxt_id = 0; if (s == NULL) return (NULL); if ((fn = srchfn(s, len)) == NULL) { if ((fn = malloc(sizeof (fn_t))) == NULL) nomem(); /* Do not used strdup() because string is not NUL-terminated.*/ if ((fn->fn_name = malloc(len + 1)) == NULL) nomem(); (void)memcpy(fn->fn_name, s, len); fn->fn_name[len] = '\0'; fn->fn_len = len; fn->fn_id = nxt_id++; fn->fn_nxt = fnames; fnames = fn; /* Write id of this filename to the output file. */ outclr(); outint(fn->fn_id); outchar('s'); outstrg(fn->fn_name); } return (fn->fn_name); }
/* * Write a new lint library. */ void outlib(const char *name) { /* Open of output file and initialisation of the output buffer */ outopen(name); /* write name of lint library */ outsrc(name); /* name of lint lib has index 0 */ outclr(); outint(0); outchar('s'); outstrg(name); /* * print the names of all files references by unnamed * struct/union/enum declarations. */ outfiles(); /* write all definitions with external linkage */ forall(dumpname); /* close the output */ outclose(); }
static void outfiles(void) { struct outflist *ofl; int i; for (ofl = outflist, i = 1; ofl != NULL; ofl = ofl->ofl_next, i++) { /* reset output buffer */ outclr(); outint(i); outchar('s'); outstrg(fnames[ofl->ofl_num]); } }
/* * Write a new lint library. */ void outlib(const char *name) { /* Open of output file and initialisation of the output buffer */ outopen(name); /* write name of lint library */ outsrc(name); /* name of lint lib has index 0 */ outclr(); outint(0); outchar('s'); outstrg(name); /* write all definitions with external linkage */ forall(dumpname); /* close the output */ outclose(); }