Fri Apr 2 22:05:44 2021 UTC ()
lint: reduce memory usage

No functional change.


(rillig)
diff -r1.22 -r1.23 src/usr.bin/xlint/lint1/lex.c
diff -r1.91 -r1.92 src/usr.bin/xlint/lint1/lint1.h

cvs diff -r1.22 -r1.23 src/usr.bin/xlint/lint1/lex.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lex.c 2021/04/02 12:16:50 1.22
+++ src/usr.bin/xlint/lint1/lex.c 2021/04/02 22:05:43 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lex.c,v 1.22 2021/04/02 12:16:50 rillig Exp $ */ 1/* $NetBSD: lex.c,v 1.23 2021/04/02 22:05:43 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,51 +28,51 @@ @@ -28,51 +28,51 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: lex.c,v 1.22 2021/04/02 12:16:50 rillig Exp $"); 41__RCSID("$NetBSD: lex.c,v 1.23 2021/04/02 22:05:43 rillig Exp $");
42#endif 42#endif
43 43
44#include <ctype.h> 44#include <ctype.h>
45#include <errno.h> 45#include <errno.h>
46#include <float.h> 46#include <float.h>
47#include <limits.h> 47#include <limits.h>
48#include <math.h> 48#include <math.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <string.h> 50#include <string.h>
51 51
52#include "lint1.h" 52#include "lint1.h"
53#include "cgram.h" 53#include "cgram.h"
54 54
55#define CHAR_MASK ((int)(~(~0U << CHAR_SIZE))) 55#define CHAR_MASK ((int)(~(~0U << CHAR_SIZE)))
56 56
57 57
58/* Current position (it's also updated when an included file is parsed) */ 58/* Current position (it's also updated when an included file is parsed) */
59pos_t curr_pos = { 1, "", 0 }; 59pos_t curr_pos = { "", 1, 0 };
60 60
61/* 61/*
62 * Current position in C source (not updated when an included file is 62 * Current position in C source (not updated when an included file is
63 * parsed). 63 * parsed).
64 */ 64 */
65pos_t csrc_pos = { 1, "", 0 }; 65pos_t csrc_pos = { "", 1, 0 };
66 66
67/* Are we parsing a gcc attribute? */ 67/* Are we parsing a gcc attribute? */
68bool attron; 68bool attron;
69 69
70bool in_system_header = false; 70bool in_system_header = false;
71 71
72static sbuf_t *allocsb(void); 72static sbuf_t *allocsb(void);
73static void freesb(sbuf_t *); 73static void freesb(sbuf_t *);
74static int inpc(void); 74static int inpc(void);
75static int hash(const char *); 75static int hash(const char *);
76static sym_t * search(sbuf_t *); 76static sym_t * search(sbuf_t *);
77static int keyw(sym_t *); 77static int keyw(sym_t *);
78static int get_escaped_char(int); 78static int get_escaped_char(int);

cvs diff -r1.91 -r1.92 src/usr.bin/xlint/lint1/lint1.h (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lint1.h 2021/04/02 09:39:25 1.91
+++ src/usr.bin/xlint/lint1/lint1.h 2021/04/02 22:05:43 1.92
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint1.h,v 1.91 2021/04/02 09:39:25 rillig Exp $ */ 1/* $NetBSD: lint1.h,v 1.92 2021/04/02 22:05:43 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -49,28 +49,28 @@ @@ -49,28 +49,28 @@
49# define AVAL 7 49# define AVAL 7
50#endif 50#endif
51#define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL) 51#define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL)
52#endif 52#endif
53 53
54#define LWARN_BAD (-3) 54#define LWARN_BAD (-3)
55#define LWARN_ALL (-2) 55#define LWARN_ALL (-2)
56#define LWARN_NONE (-1) 56#define LWARN_NONE (-1)
57 57
58/* 58/*
59 * Describes the position of a declaration or anything else. 59 * Describes the position of a declaration or anything else.
60 */ 60 */
61typedef struct { 61typedef struct {
62 int p_line; 
63 const char *p_file; 62 const char *p_file;
 63 int p_line;
64 int p_uniq; /* uniquifier */ 64 int p_uniq; /* uniquifier */
65} pos_t; 65} pos_t;
66 66
67/* Copies curr_pos, keeping things unique. */ 67/* Copies curr_pos, keeping things unique. */
68#define UNIQUE_CURR_POS(pos) \ 68#define UNIQUE_CURR_POS(pos) \
69 do { \ 69 do { \
70 (pos) = curr_pos; \ 70 (pos) = curr_pos; \
71 curr_pos.p_uniq++; \ 71 curr_pos.p_uniq++; \
72 if (curr_pos.p_file == csrc_pos.p_file) \ 72 if (curr_pos.p_file == csrc_pos.p_file) \
73 csrc_pos.p_uniq++; \ 73 csrc_pos.p_uniq++; \
74 } while (/*CONSTCOND*/false) 74 } while (/*CONSTCOND*/false)
75 75
76/* 76/*