Module Name: src Committed By: rillig Date: Sat Aug 12 20:48:24 UTC 2023
Modified Files: src/usr.bin/xlint/common: emit.c externs.h src/usr.bin/xlint/lint1: emit1.c mem1.c src/usr.bin/xlint/lint2: emit2.c Log Message: lint: for each record in the output file, write the newline immediately There's no point delaying the '\n' until the next line is written. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.29 -r1.30 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.73 -r1.74 src/usr.bin/xlint/lint1/emit1.c \ src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint2/emit2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/emit.c diff -u src/usr.bin/xlint/common/emit.c:1.23 src/usr.bin/xlint/common/emit.c:1.24 --- src/usr.bin/xlint/common/emit.c:1.23 Sat Aug 12 17:13:27 2023 +++ src/usr.bin/xlint/common/emit.c Sat Aug 12 20:48:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.23 2023/08/12 17:13:27 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.24 2023/08/12 20:48:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: emit.c,v 1.23 2023/08/12 17:13:27 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.24 2023/08/12 20:48:24 rillig Exp $"); #endif #include <stdio.h> @@ -47,7 +47,6 @@ __RCSID("$NetBSD: emit.c,v 1.23 2023/08/ static const char *output_name; static FILE *output_file; -static bool in_line; void outopen(const char *name) @@ -62,25 +61,15 @@ void outclose(void) { - outclr(); if (fclose(output_file) == EOF) err(1, "cannot close '%s'", output_name); } void -outclr(void) -{ - - if (in_line) - outchar('\n'); -} - -void outchar(char c) { fputc(c, output_file); - in_line = c != '\n'; } /* @@ -119,7 +108,7 @@ void outsrc(const char *name) { - outclr(); outchar('S'); outstrg(name); + outchar('\n'); } Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.29 src/usr.bin/xlint/common/externs.h:1.30 --- src/usr.bin/xlint/common/externs.h:1.29 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/common/externs.h Sat Aug 12 20:48:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.29 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.30 2023/08/12 20:48:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -54,7 +54,6 @@ char *xasprintf(const char *, ...) __pri #if defined(IS_LINT1) || defined(IS_LINT2) void outopen(const char *); void outclose(void); -void outclr(void); void outchar(char); void outstrg(const char *); void outint(int); Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.73 src/usr.bin/xlint/lint1/emit1.c:1.74 --- src/usr.bin/xlint/lint1/emit1.c:1.73 Wed Aug 2 18:51:25 2023 +++ src/usr.bin/xlint/lint1/emit1.c Sat Aug 12 20:48:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.73 2023/08/02 18:51:25 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.74 2023/08/12 20:48:24 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: emit1.c,v 1.73 2023/08/02 18:51:25 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.74 2023/08/12 20:48:24 rillig Exp $"); #endif #include "lint1.h" @@ -191,9 +191,6 @@ outsym(const sym_t *sym, scl_t sc, def_t if (ch_isdigit(sym->s_name[0])) /* 00000000_tmp */ return; - /* reset buffer */ - outclr(); - outint(csrc_pos.p_line); outchar('d'); /* declaration */ outint(get_filename_id(sym->s_def_pos.p_file)); @@ -233,6 +230,7 @@ outsym(const sym_t *sym, scl_t sc, def_t /* type of the symbol */ outtype(sym->s_type); + outchar('\n'); } /* @@ -246,9 +244,6 @@ outfdef(const sym_t *fsym, const pos_t * int narg; const sym_t *arg; - /* reset the buffer */ - outclr(); - if (posp->p_file == csrc_pos.p_file) { outint(posp->p_line); } else { @@ -325,6 +320,7 @@ outfdef(const sym_t *fsym, const pos_t * } else { outtype(fsym->s_type); } + outchar('\n'); } /* @@ -342,9 +338,6 @@ outcall(const tnode_t *tn, bool retval_u int narg, n, i; tspec_t t; - /* reset buffer */ - outclr(); - outint(csrc_pos.p_line); outchar('c'); /* function call */ outint(get_filename_id(curr_pos.p_file)); @@ -412,6 +405,7 @@ outcall(const tnode_t *tn, bool retval_u } /* expected type of return value */ outtype(tn->tn_type); + outchar('\n'); } /* write a character to the output buffer, quoted if necessary */ @@ -573,9 +567,6 @@ outusg(const sym_t *sym) if (ch_isdigit(sym->s_name[0])) /* 00000000_tmp, from mktempsym */ return; - /* reset buffer */ - outclr(); - outint(csrc_pos.p_line); outchar('u'); /* used */ outint(get_filename_id(curr_pos.p_file)); @@ -586,4 +577,5 @@ outusg(const sym_t *sym) outchar('x'); outname(sym->s_name); + outchar('\n'); } Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.73 src/usr.bin/xlint/lint1/mem1.c:1.74 --- src/usr.bin/xlint/lint1/mem1.c:1.73 Sun Jul 30 08:58:54 2023 +++ src/usr.bin/xlint/lint1/mem1.c Sat Aug 12 20:48:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.73 2023/07/30 08:58:54 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.74 2023/08/12 20:48:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: mem1.c,v 1.73 2023/07/30 08:58:54 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.74 2023/08/12 20:48:24 rillig Exp $"); #endif #include <sys/param.h> @@ -138,11 +138,10 @@ record_filename(const char *s, size_t sl fn->fn_next = filenames; filenames = fn; - /* Write the ID of this filename to the output file. */ - outclr(); outint(fn->fn_id); outchar('s'); outstrg(transform_filename(fn->fn_name, fn->fn_len)); + outchar('\n'); return fn->fn_name; } Index: src/usr.bin/xlint/lint2/emit2.c diff -u src/usr.bin/xlint/lint2/emit2.c:1.33 src/usr.bin/xlint/lint2/emit2.c:1.34 --- src/usr.bin/xlint/lint2/emit2.c:1.33 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/lint2/emit2.c Sat Aug 12 20:48:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit2.c,v 1.33 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: emit2.c,v 1.34 2023/08/12 20:48:24 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -34,7 +34,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: emit2.c,v 1.33 2023/07/13 08:40:38 rillig Exp $"); +__RCSID("$NetBSD: emit2.c,v 1.34 2023/08/12 20:48:24 rillig Exp $"); #endif #include "lint2.h" @@ -116,9 +116,6 @@ static void outdef(hte_t *hte, sym_t *sym) { - /* reset output buffer */ - outclr(); - /* line number in C source file */ outint(0); @@ -158,6 +155,7 @@ outdef(hte_t *hte, sym_t *sym) /* type */ outtype(TP(sym->s_type)); + outchar('\n'); } /* @@ -205,10 +203,10 @@ outlib(const char *name) outsrc(name); /* name of lint lib has index 0 */ - outclr(); outint(0); outchar('s'); outstrg(name); + outchar('\n'); /* * print the names of all files referenced by unnamed @@ -266,11 +264,9 @@ outfiles(void) 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]); + outchar('\n'); } }