CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Jan 20 10:25:57 UTC 2024 Modified Files: src/usr.bin/xlint/common: externs.h inittyp.c lint.h mem.c tyname.c Log Message: lint: unclutter conditional compilation To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.41 -r1.42 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/mem.c cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/common/tyname.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/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.32 src/usr.bin/xlint/common/externs.h:1.33 --- src/usr.bin/xlint/common/externs.h:1.32 Sat Jan 20 10:21:35 2024 +++ src/usr.bin/xlint/common/externs.h Sat Jan 20 10:25:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.32 2024/01/20 10:21:35 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.33 2024/01/20 10:25:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -34,7 +34,7 @@ /* * tyname.c */ -#if defined(IS_LINT1) || defined(IS_LINT2) +#if IS_LINT1 || IS_LINT2 const char *type_name(const type_t *); const char *tspec_name(tspec_t); #endif @@ -43,7 +43,7 @@ const char *tspec_name(tspec_t); * mem.c */ void *xmalloc(size_t); -#if defined(IS_LINT1) || defined(IS_LINT2) +#if IS_LINT1 || IS_LINT2 void *xcalloc(size_t, size_t); #endif void *xrealloc(void *, size_t); @@ -53,7 +53,7 @@ char *xasprintf(const char *, ...) __pri /* * emit.c */ -#if defined(IS_LINT1) || defined(IS_LINT2) +#if IS_LINT1 || IS_LINT2 void outopen(const char *); void outclose(void); void outchar(char); Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.41 src/usr.bin/xlint/common/inittyp.c:1.42 --- src/usr.bin/xlint/common/inittyp.c:1.41 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/common/inittyp.c Sat Jan 20 10:25:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.41 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.42 2024/01/20 10:25:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,10 +37,10 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: inittyp.c,v 1.41 2023/12/03 18:17:41 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.42 2024/01/20 10:25:57 rillig Exp $"); #endif -#if defined(IS_LINT1) +#if IS_LINT1 #include "lint1.h" #else #include "lint2.h" @@ -48,7 +48,7 @@ __RCSID("$NetBSD: inittyp.c,v 1.41 2023/ #define INT_RANK (/*CONSTCOND*/INTPTR_TSPEC == LONG ? 4 : 5) -#ifdef IS_LINT1 +#if IS_LINT1 #define typeinfo(name, signed_type, unsigned_type, size_in_bits, rv, c) \ { /*CONSTCOND*/ \ size_in_bits, \ Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.46 src/usr.bin/xlint/common/lint.h:1.47 --- src/usr.bin/xlint/common/lint.h:1.46 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/common/lint.h Sat Jan 20 10:25:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.46 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.47 2024/01/20 10:25:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -47,7 +47,7 @@ #include "param.h" -#if defined(IS_LINT1) || defined(IS_LINT2) +#if IS_LINT1 || IS_LINT2 /* * Type specifiers, used in type structures (type_t) and elsewhere. */ @@ -93,7 +93,7 @@ typedef enum { * size of types, name and classification */ typedef struct { -#ifdef IS_LINT1 +#if IS_LINT1 unsigned int tt_size_in_bits; enum rank_kind { RK_NONE, @@ -107,7 +107,7 @@ typedef struct { tspec_t tt_signed_counterpart; tspec_t tt_unsigned_counterpart; bool tt_is_integer:1; /* integer type */ -#ifdef IS_LINT1 +#if IS_LINT1 bool tt_is_uinteger:1; /* unsigned integer type */ bool tt_is_floating:1; /* floating point type */ bool tt_is_arithmetic:1; /* arithmetic type */ @@ -145,7 +145,7 @@ typedef enum { DEF /* defined */ } def_t; -#if defined(IS_LINT1) +#if IS_LINT1 typedef struct lint1_type type_t; #else typedef struct lint2_type type_t; Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.23 src/usr.bin/xlint/common/mem.c:1.24 --- src/usr.bin/xlint/common/mem.c:1.23 Sat Jan 20 10:21:35 2024 +++ src/usr.bin/xlint/common/mem.c Sat Jan 20 10:25:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.24 2024/01/20 10:25:57 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.24 2024/01/20 10:25:57 rillig Exp $"); #endif #include @@ -62,7 +62,7 @@ xmalloc(size_t s) return not_null(malloc(s)); } -#if defined(IS_LINT1) || defined(IS_LINT2) +#if IS_LINT1 || IS_LINT2 void * xcalloc(size_t n, size_t s) { Index:
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Jan 20 10:25:57 UTC 2024 Modified Files: src/usr.bin/xlint/common: externs.h inittyp.c lint.h mem.c tyname.c Log Message: lint: unclutter conditional compilation To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.41 -r1.42 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/common/mem.c cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/common/tyname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Jan 20 10:21:35 UTC 2024 Modified Files: src/usr.bin/xlint/common: externs.h mem.c Log Message: lint: only define xcalloc if actually used To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/mem.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/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.31 src/usr.bin/xlint/common/externs.h:1.32 --- src/usr.bin/xlint/common/externs.h:1.31 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/common/externs.h Sat Jan 20 10:21:35 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.31 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.32 2024/01/20 10:21:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -43,7 +43,9 @@ const char *tspec_name(tspec_t); * mem.c */ void *xmalloc(size_t); +#if defined(IS_LINT1) || defined(IS_LINT2) void *xcalloc(size_t, size_t); +#endif void *xrealloc(void *, size_t); char *xstrdup(const char *); char *xasprintf(const char *, ...) __printflike(1, 2); Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.22 src/usr.bin/xlint/common/mem.c:1.23 --- src/usr.bin/xlint/common/mem.c:1.22 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/common/mem.c Sat Jan 20 10:21:35 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.22 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: mem.c,v 1.22 2023/07/13 08:40:38 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $"); #endif #include @@ -62,12 +62,14 @@ xmalloc(size_t s) return not_null(malloc(s)); } +#if defined(IS_LINT1) || defined(IS_LINT2) void * xcalloc(size_t n, size_t s) { return not_null(calloc(n, s)); } +#endif void * xrealloc(void *p, size_t s)
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Jan 20 10:21:35 UTC 2024 Modified Files: src/usr.bin/xlint/common: externs.h mem.c Log Message: lint: only define xcalloc if actually used To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Aug 12 17:13:28 UTC 2023 Modified Files: src/usr.bin/xlint/common: emit.c Log Message: lint: remove unnecessary double-buffering for output files To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/emit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Aug 12 17:13:28 UTC 2023 Modified Files: src/usr.bin/xlint/common: emit.c Log Message: lint: remove unnecessary double-buffering for output files To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/emit.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.22 src/usr.bin/xlint/common/emit.c:1.23 --- src/usr.bin/xlint/common/emit.c:1.22 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/common/emit.c Sat Aug 12 17:13:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.22 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.23 2023/08/12 17:13:27 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: emit.c,v 1.22 2023/07/13 08:40:38 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.23 2023/08/12 17:13:27 rillig Exp $"); #endif #include @@ -45,121 +45,71 @@ __RCSID("$NetBSD: emit.c,v 1.22 2023/07/ #include "lint.h" -/* name and handle of output file */ -static const char *loname; -static FILE *lout; +static const char *output_name; +static FILE *output_file; +static bool in_line; -/* output buffer data */ -static ob_t ob; - -static void outxbuf(void); - - -/* - * initialize output - */ void outopen(const char *name) { - loname = name; - - /* Open output file */ - if ((lout = fopen(name, "w")) == NULL) + output_name = name; + if ((output_file = fopen(name, "w")) == NULL) err(1, "cannot open '%s'", name); - - /* Create output buffer */ - ob.o_len = 1024; - ob.o_end = (ob.o_buf = ob.o_next = xmalloc(ob.o_len)) + ob.o_len; } -/* - * flush output buffer and close file - */ void outclose(void) { outclr(); - if (fclose(lout) == EOF) - err(1, "cannot close '%s'", loname); -} - -/* - * resize output buffer - */ -static void -outxbuf(void) -{ - - size_t next = (size_t)(ob.o_next - ob.o_buf); - ob.o_len *= 2; - ob.o_buf = xrealloc(ob.o_buf, ob.o_len); - ob.o_end = ob.o_buf + ob.o_len; - ob.o_next = ob.o_buf + next; + if (fclose(output_file) == EOF) + err(1, "cannot close '%s'", output_name); } -/* - * reset output buffer - * if it is not empty, it is flushed - */ void outclr(void) { - if (ob.o_buf != ob.o_next) { + if (in_line) outchar('\n'); - size_t sz = (size_t)(ob.o_next - ob.o_buf); - if (sz > ob.o_len) - errx(1, "internal error: outclr"); - if (fwrite(ob.o_buf, sz, 1, lout) != 1) - err(1, "cannot write to %s", loname); - ob.o_next = ob.o_buf; - } } -/* - * write a character to the output buffer - */ void outchar(char c) { - if (ob.o_next == ob.o_end) - outxbuf(); - *ob.o_next++ = c; + fputc(c, output_file); + in_line = c != '\n'; } /* - * write a string to the output buffer - * the string must not contain any characters which - * should be quoted + * write a string to the output file + * the string must not contain any characters which should be quoted */ void outstrg(const char *s) { - while (*s != '\0') { - if (ob.o_next == ob.o_end) - outxbuf(); - *ob.o_next++ = *s++; - } + while (*s != '\0') + outchar(*s++); } -/* write an integer value to the output buffer */ +/* write an integer value to the output file */ void outint(int i) { + char buf[1 + 3 * sizeof(int)]; - if ((size_t)(ob.o_end - ob.o_next) < 3 * sizeof(int)) - outxbuf(); - ob.o_next += snprintf(ob.o_next, ob.o_end - ob.o_next, "%d", i); + snprintf(buf, sizeof(buf), "%d", i); + outstrg(buf); } -/* write a name to the output buffer, preceded by its length */ +/* write a name to the output file, preceded by its length */ void outname(const char *name) { + outint((int)strlen(name)); outstrg(name); }
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Thu Jul 6 07:59:00 UTC 2023 Modified Files: src/usr.bin/xlint/common: externs.h lint.h Log Message: lint: add type safety for accessing properties of basic types No functional change. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/common/lint.h 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/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.27 src/usr.bin/xlint/common/externs.h:1.28 --- src/usr.bin/xlint/common/externs.h:1.27 Thu Jun 29 10:31:32 2023 +++ src/usr.bin/xlint/common/externs.h Thu Jul 6 07:59:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.27 2023/06/29 10:31:32 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.28 2023/07/06 07:59:00 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -34,8 +34,10 @@ /* * tyname.c */ +#if defined(IS_LINT1) || defined(IS_LINT2) const char *type_name(const type_t *); -const char *tspec_name(tspec_t); +const char *tspec_name(tspec_t); +#endif /* * mem.c Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.38 src/usr.bin/xlint/common/lint.h:1.39 --- src/usr.bin/xlint/common/lint.h:1.38 Mon Jul 3 07:03:19 2023 +++ src/usr.bin/xlint/common/lint.h Thu Jul 6 07:59:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.38 2023/07/03 07:03:19 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.39 2023/07/06 07:59:00 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -47,6 +47,7 @@ #include "param.h" +#if defined(IS_LINT1) || defined(IS_LINT2) /* * Type specifiers, used in type structures (type_t) and elsewhere. */ @@ -110,20 +111,23 @@ typedef struct { const char *tt_name; /* name of the type */ } ttab_t; -#define size_in_bits(t) (ttab[t].tt_size_in_bits) -#define portable_size_in_bits(t) (ttab[t].tt_portable_size_in_bits) -#define signed_type(t) (ttab[t].tt_signed_counterpart) -#define unsigned_type(t) (ttab[t].tt_unsigned_counterpart) -#define is_integer(t) (ttab[t].tt_is_integer) -#define is_uinteger(t) (ttab[t].tt_is_uinteger) -#define is_floating(t) (ttab[t].tt_is_floating) -#define is_arithmetic(t) (ttab[t].tt_is_arithmetic) -#define is_complex(t) (ttab[t].tt_is_complex) -#define is_scalar(t) (ttab[t].tt_is_scalar) - -#if defined(IS_LINT1) || defined(IS_LINT2) extern ttab_t ttab[]; -#endif + +static inline const ttab_t * +type_properties(tspec_t t) { + return ttab + t; +} + +#define size_in_bits(t) (type_properties(t)->tt_size_in_bits) +#define portable_size_in_bits(t) (type_properties(t)->tt_portable_size_in_bits) +#define signed_type(t) (type_properties(t)->tt_signed_counterpart) +#define unsigned_type(t) (type_properties(t)->tt_unsigned_counterpart) +#define is_integer(t) (type_properties(t)->tt_is_integer) +#define is_uinteger(t) (type_properties(t)->tt_is_uinteger) +#define is_floating(t) (type_properties(t)->tt_is_floating) +#define is_arithmetic(t) (type_properties(t)->tt_is_arithmetic) +#define is_complex(t) (type_properties(t)->tt_is_complex) +#define is_scalar(t) (type_properties(t)->tt_is_scalar) typedef enum { @@ -146,6 +150,7 @@ typedef struct lint1_type type_t; #else typedef struct lint2_type type_t; #endif +#endif #include "externs.h"
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Thu Jul 6 07:59:00 UTC 2023 Modified Files: src/usr.bin/xlint/common: externs.h lint.h Log Message: lint: add type safety for accessing properties of basic types No functional change. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/common/lint.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Wed Nov 30 20:50:22 UTC 2022 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: make definitions of basic types simpler No binary change. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/inittyp.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/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.32 src/usr.bin/xlint/common/inittyp.c:1.33 --- src/usr.bin/xlint/common/inittyp.c:1.32 Fri Jul 8 21:19:06 2022 +++ src/usr.bin/xlint/common/inittyp.c Wed Nov 30 20:50:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.32 2022/07/08 21:19:06 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.33 2022/11/30 20:50:22 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: inittyp.c,v 1.32 2022/07/08 21:19:06 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.33 2022/11/30 20:50:22 rillig Exp $"); #endif #if defined(IS_LINT1) @@ -52,89 +52,75 @@ __RCSID("$NetBSD: inittyp.c,v 1.32 2022/ #define typeinfo( \ name, signed_type, unsigned_type, \ size_in_bits, portable_size_in_bits, \ - is_integer, is_unsigned, is_floating, is_arithmetic, \ - is_scalar, is_complex) \ - { \ + c) \ + { /*CONSTCOND*/ \ size_in_bits, portable_size_in_bits, \ signed_type, unsigned_type, \ - (is_integer) > 0, (is_unsigned) > 0, (is_floating) > 0, \ - (is_arithmetic) > 0, (is_scalar) > 0, (is_complex) > 0, \ + (c) == 's' || (c) == 'u', \ + (c) == 'u' || (c) == 'p', \ + (c) == 'f' || (c) == 'c', \ + (c) == 's' || (c) == 'u' || (c) == 'f' || \ + (c) == 'c', \ + (c) == 's' || (c) == 'u' || (c) == 'f' || \ + (c) == 'c' || (c) == 'p', \ + (c) == 'c', \ name, \ } #else #define typeinfo( \ name, signed_type, unsigned_type, \ size_in_bits, portable_size_in_bits, \ - is_integer, is_unsigned, is_floating, is_arithmetic, \ - is_scalar, is_complex) \ - { \ + c) \ + { /*CONSTCOND*/ \ signed_type, unsigned_type, \ - (is_integer) > 0, \ + (c) == 's' || (c) == 'u', \ name, \ } #endif /* various type information */ ttab_t ttab[NTSPEC] = { - typeinfo(NULL, NOTSPEC, NOTSPEC, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("signed", SIGNED, UNSIGN, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("unsigned", SIGNED, UNSIGN, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("_Bool", BOOL, BOOL, CHAR_SIZE, - 1, 1, 1, 0, 1, 1, 0), + typeinfo(NULL, NOTSPEC, NOTSPEC, 0, 0, ' '), + typeinfo("signed", SIGNED, UNSIGN, 0, 0, ' '), + typeinfo("unsigned", SIGNED, UNSIGN, 0, 0, ' '), + typeinfo("_Bool", BOOL, BOOL, CHAR_SIZE, 1, 'u'), typeinfo("char", SCHAR, UCHAR, CHAR_SIZE, 8, - 1, /*CONSTCOND*/ TARG_CHAR_MIN == 0 ? 1 : 0, 0, 1, 1, 0), - typeinfo("signed char", SCHAR, UCHAR, CHAR_SIZE, 8, - 1, 0, 0, 1, 1, 0), - typeinfo("unsigned char", SCHAR, UCHAR, CHAR_SIZE, 8, - 1, 1, 0, 1, 1, 0), - typeinfo("short", SHORT, USHORT, SHORT_SIZE, 16, - 1, 0, 0, 1, 1, 0), - typeinfo("unsigned short", SHORT, USHORT, SHORT_SIZE, 16, - 1, 1, 0, 1, 1, 0), - typeinfo("int", INT, UINT, INT_SIZE, INT_RSIZE * 8, - 1, 0, 0, 1, 1, 0), - typeinfo("unsigned int", INT, UINT, INT_SIZE, INT_RSIZE * 8, - 1, 1, 0, 1, 1, 0), - typeinfo("long", LONG, ULONG, LONG_SIZE, 32, - 1, 0, 0, 1, 1, 0), - typeinfo("unsigned long", LONG, ULONG, LONG_SIZE, 32, - 1, 1, 0, 1, 1, 0), - typeinfo("long long", QUAD, UQUAD, QUAD_SIZE, 64, - 1, 0, 0, 1, 1, 0), - typeinfo("unsigned long long", QUAD, UQUAD, QUAD_SIZE, 64, - 1, 1, 0, 1, 1, 0), + TARG_CHAR_MIN == 0 ? 'u' : 's'), + typeinfo("signed char", SCHAR, UCHAR, CHAR_SIZE, 8, 's'), + typeinfo("unsigned char", SCHAR, UCHAR, CHAR_SIZE, 8, 'u'), + typeinfo("short", SHORT, USHORT, SHORT_SIZE, 16, 's'), + typeinfo("unsigned short", SHORT, USHORT, SHORT_SIZE, 16, 'u'), + typeinfo("int", INT, UINT, INT_SIZE, INT_RSIZE * 8, 's'), + typeinfo("unsigned int", INT, UINT, INT_SIZE, INT_RSIZE * 8, 'u'), + typeinfo("long", LONG, ULONG, LONG_SIZE, 32, 's'), + typeinfo("unsigned long", LONG, ULONG, LONG_SIZE, 32, 'u'), + typeinfo("long long", QUAD, UQUAD, QUAD_SIZE, 64, 's'), + typeinfo("unsigned long long", QUAD, UQUAD, QUAD_SIZE, 64, 'u'), #ifdef INT128_SIZE - typeinfo("__int128_t", INT128, UINT128, INT128_SIZE, 128, - 1, 0, 0, 1, 1, 0), - typeinfo("__uint128_t", INT128, UINT128, INT128_SIZE, 128, - 1, 1, 0, 1, 1, 0), -#endif - typeinfo("float", FLOAT, FLOAT, FLOAT_SIZE, 32, - 0, 0, 1, 1, 1, 0), - typeinfo("double", DOUBLE, DOUBLE, DOUBLE_SIZE, 64, - 0, 0, 1, 1, 1, 0), - typeinfo("long double", LDOUBLE, LDOUBLE, LDOUBLE_SIZE, 80, - 0, 0, 1, 1, 1, 0), - typeinfo("void", VOID, VOID, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("struct", STRUCT, STRUCT, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("union", UNION, UNION, 0, 0, 0, 0, 0, 0, 0, 0), - typeinfo("enum", ENUM,
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Wed Nov 30 20:50:22 UTC 2022 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: make definitions of basic types simpler No binary change. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/usr.bin/xlint/common/inittyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 15:39:41 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: make initialization of the basic types table simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/common/inittyp.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/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.28 src/usr.bin/xlint/common/inittyp.c:1.29 --- src/usr.bin/xlint/common/inittyp.c:1.28 Sat Sep 4 14:07:51 2021 +++ src/usr.bin/xlint/common/inittyp.c Sat Sep 4 15:39:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.28 2021/09/04 14:07:51 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.29 2021/09/04 15:39:41 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: inittyp.c,v 1.28 2021/09/04 14:07:51 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.29 2021/09/04 15:39:41 rillig Exp $"); #endif #if defined(IS_LINT1) @@ -46,103 +46,92 @@ __RCSID("$NetBSD: inittyp.c,v 1.28 2021/ #include "lint2.h" #endif -/* various type information */ -ttab_t ttab[NTSPEC]; - #define INT_RSIZE (/*CONSTCOND*/INTPTR_TSPEC == LONG ? 3 : 4) -void -inittyp(void) -{ - size_t i; - static const struct { - tspec_t it_tspec; - ttab_t it_ttab; - } ittab[NTSPEC] = { #define typeinfo( \ - tspec, signed_type, unsigned_type, \ + name, signed_type, unsigned_type, \ size_in_bits, portable_size_in_bits, \ - in, un, fl, ar, sc, co, name) \ + is_integer, is_unsigned, is_floating, is_arithmetic, \ + is_scalar, is_complex) \ { \ - tspec, { \ size_in_bits, portable_size_in_bits, \ signed_type, unsigned_type, \ - (in) > 0, (un) > 0, (fl) > 0, (ar) > 0, (sc) > 0, (co) > 0, \ + (is_integer) > 0, (is_unsigned) > 0, (is_floating) > 0, \ + (is_arithmetic) > 0, (is_scalar) > 0, (is_complex) > 0, \ name, \ - } \ } - typeinfo(SIGNED, SIGNED, UNSIGN, 0, 0, - 0, 0, 0, 0, 0, 0, "signed"), - typeinfo(UNSIGN, SIGNED, UNSIGN, 0, 0, - 0, 0, 0, 0, 0, 0, "unsigned"), - typeinfo(BOOL, BOOL, BOOL, CHAR_SIZE, 1, - 1, 1, 0, 1, 1, 0, "_Bool"), - typeinfo(CHAR, SCHAR, UCHAR, CHAR_SIZE, 8, - 1, /*CONSTCOND*/ TARG_CHAR_MIN == 0 ? 1 : 0, - /* */ 0, 1, 1, 0, "char"), - typeinfo(SCHAR, SCHAR, UCHAR, CHAR_SIZE, 8, - 1, 0, 0, 1, 1, 0, "signed char"), - typeinfo(UCHAR, SCHAR, UCHAR, CHAR_SIZE, 8, - 1, 1, 0, 1, 1, 0, "unsigned char"), - typeinfo(SHORT, SHORT, USHORT, SHORT_SIZE, 16, - 1, 0, 0, 1, 1, 0, "short"), - typeinfo(USHORT, SHORT, USHORT, SHORT_SIZE, 16, - 1, 1, 0, 1, 1, 0, "unsigned short"), - typeinfo(INT, INT, UINT, INT_SIZE, INT_RSIZE * 8, - 1, 0, 0, 1, 1, 0, "int"), - typeinfo(UINT, INT, UINT, INT_SIZE, INT_RSIZE * 8, - 1, 1, 0, 1, 1, 0, "unsigned int"), - typeinfo(LONG, LONG, ULONG, LONG_SIZE, 32, - 1, 0, 0, 1, 1, 0, "long"), - typeinfo(ULONG, LONG, ULONG, LONG_SIZE, 32, - 1, 1, 0, 1, 1, 0, "unsigned long"), - typeinfo(QUAD, QUAD, UQUAD, QUAD_SIZE, 64, - 1, 0, 0, 1, 1, 0, "long long"), - typeinfo(UQUAD, QUAD, UQUAD, QUAD_SIZE, 64, - 1, 1, 0, 1, 1, 0, "unsigned long long"), + +/* various type information */ +ttab_t ttab[NTSPEC] = { + typeinfo(NULL, NOTSPEC, NOTSPEC, 0, 0, 0, 0, 0, 0, 0, 0), + typeinfo("signed", SIGNED, UNSIGN, 0, 0, 0, 0, 0, 0, 0, 0), + typeinfo("unsigned", SIGNED, UNSIGN, 0, 0, 0, 0, 0, 0, 0, 0), + typeinfo("_Bool", BOOL, BOOL, CHAR_SIZE, + 1, 1, 1, 0, 1, 1, 0), + typeinfo("char", SCHAR, UCHAR, CHAR_SIZE, 8, + 1, /*CONSTCOND*/ TARG_CHAR_MIN == 0 ? 1 : 0, 0, 1, 1, 0), + typeinfo("signed char", SCHAR, UCHAR, CHAR_SIZE, 8, + 1, 0, 0, 1, 1, 0), + typeinfo("unsigned char", SCHAR, UCHAR, CHAR_SIZE, 8, + 1, 1, 0, 1, 1, 0), + typeinfo("short", SHORT, USHORT, SHORT_SIZE, 16, + 1, 0, 0, 1, 1, 0), + typeinfo("unsigned short", SHORT, USHORT, SHORT_SIZE, 16, + 1, 1, 0, 1, 1, 0), + typeinfo("int", INT, UINT, INT_SIZE, INT_RSIZE * 8, + 1, 0, 0, 1, 1, 0), + typeinfo("unsigned int", INT, UINT, INT_SIZE, INT_RSIZE * 8, + 1, 1, 0, 1, 1, 0), + typeinfo("long", LONG, ULONG, LONG_SIZE, 32, + 1, 0, 0, 1, 1, 0), + typeinfo("unsigned long", LONG, ULONG, LONG_SIZE, 32, + 1, 1, 0, 1, 1, 0), + typeinfo("long long", QUAD, UQUAD, QUAD_SIZE, 64, + 1, 0, 0, 1, 1, 0), + typeinfo("unsigned long long", QUAD, UQUAD, QUAD_SIZE, 64, + 1, 1, 0, 1, 1, 0), #ifdef INT128_SIZE - typeinfo(INT128, INT128, UINT128, INT128_SIZE, 128, - 1, 0, 0, 1, 1, 0, "__int128_t"), - typeinfo(UINT128, INT128, UINT128, INT128_SIZE, 128, - 1, 1, 0, 1, 1, 0, "__uint128_t"), + typeinfo("__int128_t", INT128, UINT128, INT128_SIZE, 128, + 1, 0, 0, 1, 1, 0), + typeinfo("__uint128_t", INT128, UINT128, INT128_SIZE, 128, + 1, 1, 0, 1, 1, 0), #endif -
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 15:39:41 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: make initialization of the basic types table simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/common/inittyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 14:42:30 UTC 2021 Modified Files: src/usr.bin/xlint/common: emit.c externs.h Log Message: lint: trim down the code for writing the output files The output buffer is only needed in a single file, so unexport it. When calling outname, the chances for the name being null are close to zero, therefore omit the caller information. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/externs.h 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.14 src/usr.bin/xlint/common/emit.c:1.15 --- src/usr.bin/xlint/common/emit.c:1.14 Sat Sep 4 14:26:32 2021 +++ src/usr.bin/xlint/common/emit.c Sat Sep 4 14:42:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.14 2021/09/04 14:26:32 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit.c,v 1.14 2021/09/04 14:26:32 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.15 2021/09/04 14:42:30 rillig Exp $"); #endif #include @@ -50,7 +50,7 @@ static const char *loname; static FILE *lout; /* output buffer data */ -ob_t ob; +static ob_t ob; static void outxbuf(void); @@ -132,9 +132,7 @@ outchar(char c) } #if defined(IS_LINT1) -/* - * write a character to the output buffer, quoted if necessary - */ +/* write a character to the output buffer, quoted if necessary */ void outqchar(char c) { @@ -200,9 +198,7 @@ outstrg(const char *s) } } -/* - * write an integer value to the output buffer - */ +/* write an integer value to the output buffer */ void outint(int i) { @@ -212,23 +208,15 @@ outint(int i) ob.o_next += sprintf(ob.o_next, "%d", i); } -/* - * write the name of a symbol to the output buffer - * the name is preceded by its length - */ +/* write a name to the output buffer, preceded by its length */ void -outname1(const char *file, size_t line, const char *name) +outname(const char *name) { - - if (name == NULL) - errx(1, "%s, %zu: internal error: outname(NULL)", file, line); outint((int)strlen(name)); outstrg(name); } -/* - * write the name of the .c source - */ +/* write the name of the .c source */ void outsrc(const char *name) { Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.22 src/usr.bin/xlint/common/externs.h:1.23 --- src/usr.bin/xlint/common/externs.h:1.22 Sat Sep 4 14:26:32 2021 +++ src/usr.bin/xlint/common/externs.h Sat Sep 4 14:42:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.22 2021/09/04 14:26:32 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.23 2021/09/04 14:42:30 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -56,8 +56,6 @@ extern char *xasprintf(const char *, .. * emit.c */ #if defined(IS_LINT1) || defined(IS_LINT2) -extern ob_t ob; - extern void outopen(const char *); extern void outclose(void); extern void outclr(void); @@ -65,7 +63,6 @@ extern void outchar(char); extern void outqchar(char); extern void outstrg(const char *); extern void outint(int); -#define outname(a) outname1(__FILE__, __LINE__, a); -extern void outname1(const char *, size_t, const char *); +extern void outname(const char *); extern void outsrc(const char *); #endif
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 14:42:30 UTC 2021 Modified Files: src/usr.bin/xlint/common: emit.c externs.h Log Message: lint: trim down the code for writing the output files The output buffer is only needed in a single file, so unexport it. When calling outname, the chances for the name being null are close to zero, therefore omit the caller information. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/common/externs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 14:07:51 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c tyname.c Log Message: lint: remove _Complex from tspec_name That type is only used in the parser; the expression trees use FCOMPLEX, DCOMPLEX or LCOMPLEX instead. Sort the typeinfo definitions according to their order in tspec_t. Do not add _Complex there since it is not needed. This means that NOTSPEC and COMPLEX would both trigger an internal error. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/common/tyname.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/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.27 src/usr.bin/xlint/common/inittyp.c:1.28 --- src/usr.bin/xlint/common/inittyp.c:1.27 Sat Sep 4 10:26:44 2021 +++ src/usr.bin/xlint/common/inittyp.c Sat Sep 4 14:07:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.27 2021/09/04 10:26:44 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.28 2021/09/04 14:07:51 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: inittyp.c,v 1.27 2021/09/04 10:26:44 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.28 2021/09/04 14:07:51 rillig Exp $"); #endif #if defined(IS_LINT1) @@ -112,13 +112,6 @@ inittyp(void) 0, 0, 1, 1, 1, 0, "double"), typeinfo(LDOUBLE, LDOUBLE, LDOUBLE, LDOUBLE_SIZE, 80, 0, 0, 1, 1, 1, 0, "long double"), - typeinfo(FCOMPLEX, FCOMPLEX, FCOMPLEX, FLOAT_SIZE * 2, 32 * 2, - 0, 0, 1, 1, 1, 1, "float _Complex"), - typeinfo(DCOMPLEX, DCOMPLEX, DCOMPLEX, DOUBLE_SIZE * 2, 64 * 2, - 0, 0, 1, 1, 1, 1, "double _Complex"), - typeinfo(LCOMPLEX, LCOMPLEX, LCOMPLEX, - LDOUBLE_SIZE * 2, 80 * 2, - 0, 0, 1, 1, 1, 1, "long double _Complex"), typeinfo(VOID, VOID, VOID, 0, 0, 0, 0, 0, 0, 0, 0, "void"), typeinfo(STRUCT, STRUCT, STRUCT, 0, 0, @@ -133,6 +126,13 @@ inittyp(void) 0, 0, 0, 0, 0, 0, "array"), typeinfo(FUNC, FUNC, FUNC, 0, 0, 0, 0, 0, 0, 0, 0, "function"), + typeinfo(FCOMPLEX, FCOMPLEX, FCOMPLEX, FLOAT_SIZE * 2, 32 * 2, + 0, 0, 1, 1, 1, 1, "float _Complex"), + typeinfo(DCOMPLEX, DCOMPLEX, DCOMPLEX, DOUBLE_SIZE * 2, 64 * 2, + 0, 0, 1, 1, 1, 1, "double _Complex"), + typeinfo(LCOMPLEX, LCOMPLEX, LCOMPLEX, + LDOUBLE_SIZE * 2, 80 * 2, + 0, 0, 1, 1, 1, 1, "long double _Complex"), #undef typeinfo }; Index: src/usr.bin/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.48 src/usr.bin/xlint/common/tyname.c:1.49 --- src/usr.bin/xlint/common/tyname.c:1.48 Sat Sep 4 13:53:20 2021 +++ src/usr.bin/xlint/common/tyname.c Sat Sep 4 14:07:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.48 2021/09/04 13:53:20 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.49 2021/09/04 14:07:51 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.48 2021/09/04 13:53:20 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.49 2021/09/04 14:07:51 rillig Exp $"); #endif #include @@ -150,7 +150,7 @@ buf_add_int(buffer *buf, int n) const char * tspec_name(tspec_t t) { - const char *name = t == COMPLEX ? "_Complex" : ttab[t].tt_name; + const char *name = ttab[t].tt_name; if (name == NULL) INTERNAL_ERROR("tspec_name(%d)", t); return name;
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 14:07:51 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c tyname.c Log Message: lint: remove _Complex from tspec_name That type is only used in the parser; the expression trees use FCOMPLEX, DCOMPLEX or LCOMPLEX instead. Sort the typeinfo definitions according to their order in tspec_t. Do not add _Complex there since it is not needed. This means that NOTSPEC and COMPLEX would both trigger an internal error. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/common/tyname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 13:53:20 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c Log Message: lint: remove duplicate code in tspec_name No functional change. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/common/tyname.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/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.47 src/usr.bin/xlint/common/tyname.c:1.48 --- src/usr.bin/xlint/common/tyname.c:1.47 Sat Sep 4 13:45:36 2021 +++ src/usr.bin/xlint/common/tyname.c Sat Sep 4 13:53:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.47 2021/09/04 13:45:36 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.48 2021/09/04 13:53:20 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.47 2021/09/04 13:45:36 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.48 2021/09/04 13:53:20 rillig Exp $"); #endif #include @@ -147,47 +147,13 @@ buf_add_int(buffer *buf, int n) buf_add(buf, num); } -/* XXX: at least partly redundant with ttab[t].tt_name */ const char * tspec_name(tspec_t t) { - switch (t) { - case SIGNED: return "signed"; - case UNSIGN: return "unsigned"; - case BOOL: return "_Bool"; - case CHAR: return "char"; - case SCHAR: return "signed char"; - case UCHAR: return "unsigned char"; - case SHORT: return "short"; - case USHORT: return "unsigned short"; - case INT: return "int"; - case UINT: return "unsigned int"; - case LONG: return "long"; - case ULONG: return "unsigned long"; - case QUAD: return "long long"; - case UQUAD: return "unsigned long long"; -#ifdef INT128_SIZE - case INT128: return "__int128_t"; - case UINT128: return "__uint128_t"; -#endif - case FLOAT: return "float"; - case DOUBLE: return "double"; - case LDOUBLE: return "long double"; - case VOID: return "void"; - case STRUCT: return "struct"; - case UNION: return "union"; - case ENUM: return "enum"; - case PTR: return "pointer"; - case ARRAY: return "array"; - case FUNC: return "function"; - case COMPLEX: return "_Complex"; - case FCOMPLEX: return "float _Complex"; - case DCOMPLEX: return "double _Complex"; - case LCOMPLEX: return "long double _Complex"; - default: + const char *name = t == COMPLEX ? "_Complex" : ttab[t].tt_name; + if (name == NULL) INTERNAL_ERROR("tspec_name(%d)", t); - return NULL; - } + return name; } static void
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 13:53:20 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c Log Message: lint: remove duplicate code in tspec_name No functional change. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/common/tyname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 10:26:44 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: remove unnecessary includes The type definitions used to depend on the host's platform characteristics once, which required . To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/common/inittyp.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/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.26 src/usr.bin/xlint/common/inittyp.c:1.27 --- src/usr.bin/xlint/common/inittyp.c:1.26 Sat Aug 28 13:02:25 2021 +++ src/usr.bin/xlint/common/inittyp.c Sat Sep 4 10:26:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.26 2021/08/28 13:02:25 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.27 2021/09/04 10:26:44 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,12 +37,9 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: inittyp.c,v 1.26 2021/08/28 13:02:25 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.27 2021/09/04 10:26:44 rillig Exp $"); #endif -#include -#include - #if defined(IS_LINT1) #include "lint1.h" #else
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Sep 4 10:26:44 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: remove unnecessary includes The type definitions used to depend on the host's platform characteristics once, which required . To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/common/inittyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Tue Aug 31 23:49:22 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c Log Message: lint: remove unnecessary switch statement The switch statement covers only the few structural types, there is no need to list all integer types as well. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/common/tyname.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/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.45 src/usr.bin/xlint/common/tyname.c:1.46 --- src/usr.bin/xlint/common/tyname.c:1.45 Sat Aug 28 13:29:26 2021 +++ src/usr.bin/xlint/common/tyname.c Tue Aug 31 23:49:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.45 2021/08/28 13:29:26 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.46 2021/08/31 23:49:21 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.45 2021/08/28 13:29:26 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.46 2021/08/31 23:49:21 rillig Exp $"); #endif #include @@ -303,33 +303,6 @@ type_name(const type_t *tp) buf_add(, tspec_name(t)); switch (t) { - case BOOL: - case CHAR: - case UCHAR: - case SCHAR: - case SHORT: - case USHORT: - case INT: - case UINT: - case LONG: - case ULONG: - case QUAD: - case UQUAD: -#ifdef INT128_SIZE - case INT128: - case UINT128: -#endif - case FLOAT: - case DOUBLE: - case LDOUBLE: - case VOID: - case COMPLEX: - case FCOMPLEX: - case DCOMPLEX: - case LCOMPLEX: - case SIGNED: - case UNSIGN: - break; case PTR: buf_add(, " to "); buf_add(, type_name(tp->t_subt)); @@ -348,7 +321,7 @@ type_name(const type_t *tp) type_name_of_function(, tp); break; default: - INTERNAL_ERROR("type_name(%d)", t); + break; } name = intern(buf.data);
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Tue Aug 31 23:49:22 UTC 2021 Modified Files: src/usr.bin/xlint/common: tyname.c Log Message: lint: remove unnecessary switch statement The switch statement covers only the few structural types, there is no need to list all integer types as well. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/common/tyname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Aug 28 13:02:26 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: fix lint warning about initializing with negative number No functional change. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/common/inittyp.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/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.25 src/usr.bin/xlint/common/inittyp.c:1.26 --- src/usr.bin/xlint/common/inittyp.c:1.25 Sun Aug 22 14:50:06 2021 +++ src/usr.bin/xlint/common/inittyp.c Sat Aug 28 13:02:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.25 2021/08/22 14:50:06 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.26 2021/08/28 13:02:25 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: inittyp.c,v 1.25 2021/08/22 14:50:06 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.26 2021/08/28 13:02:25 rillig Exp $"); #endif #include @@ -122,19 +122,19 @@ inittyp(void) typeinfo(LCOMPLEX, LCOMPLEX, LCOMPLEX, LDOUBLE_SIZE * 2, 80 * 2, 0, 0, 1, 1, 1, 1, "long double _Complex"), - typeinfo(VOID, VOID, VOID, -1, -1, + typeinfo(VOID, VOID, VOID, 0, 0, 0, 0, 0, 0, 0, 0, "void"), - typeinfo(STRUCT, STRUCT, STRUCT, -1, -1, + typeinfo(STRUCT, STRUCT, STRUCT, 0, 0, 0, 0, 0, 0, 0, 0, "struct"), - typeinfo(UNION, UNION, UNION, -1, -1, + typeinfo(UNION, UNION, UNION, 0, 0, 0, 0, 0, 0, 0, 0, "union"), typeinfo(ENUM, ENUM, ENUM, ENUM_SIZE, 24, 1, 0, 0, 1, 1, 0, "enum"), typeinfo(PTR, PTR, PTR, PTR_SIZE, 32, 0, 1, 0, 0, 1, 0, "pointer"), - typeinfo(ARRAY, ARRAY, ARRAY, -1, -1, + typeinfo(ARRAY, ARRAY, ARRAY, 0, 0, 0, 0, 0, 0, 0, 0, "array"), - typeinfo(FUNC, FUNC, FUNC, -1, -1, + typeinfo(FUNC, FUNC, FUNC, 0, 0, 0, 0, 0, 0, 0, 0, "function"), #undef typeinfo };
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Sat Aug 28 13:02:26 UTC 2021 Modified Files: src/usr.bin/xlint/common: inittyp.c Log Message: lint: fix lint warning about initializing with negative number No functional change. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/common/inittyp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.