| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: show.c,v 1.49 2018/08/19 10:47:45 kre Exp $ */ | | 1 | /* $NetBSD: show.c,v 1.50 2018/10/18 04:44:27 kre Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved. | | 7 | * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved. |
8 | * | | 8 | * |
9 | * This code is derived from software contributed to Berkeley by | | 9 | * This code is derived from software contributed to Berkeley by |
10 | * Kenneth Almquist. | | 10 | * Kenneth Almquist. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #include <sys/cdefs.h> | | 37 | #include <sys/cdefs.h> |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95"; | | 40 | static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95"; |
41 | #else | | 41 | #else |
42 | __RCSID("$NetBSD: show.c,v 1.49 2018/08/19 10:47:45 kre Exp $"); | | 42 | __RCSID("$NetBSD: show.c,v 1.50 2018/10/18 04:44:27 kre Exp $"); |
43 | #endif | | 43 | #endif |
44 | #endif /* not lint */ | | 44 | #endif /* not lint */ |
45 | | | 45 | |
46 | #include <stdio.h> | | 46 | #include <stdio.h> |
47 | #include <stdarg.h> | | 47 | #include <stdarg.h> |
48 | #include <stdlib.h> | | 48 | #include <stdlib.h> |
49 | #include <unistd.h> | | 49 | #include <unistd.h> |
50 | #include <fcntl.h> | | 50 | #include <fcntl.h> |
51 | #include <errno.h> | | 51 | #include <errno.h> |
52 | #include <limits.h> | | 52 | #include <limits.h> |
53 | | | 53 | |
54 | #include <sys/types.h> | | 54 | #include <sys/types.h> |
55 | #include <sys/uio.h> | | 55 | #include <sys/uio.h> |
| @@ -58,41 +58,26 @@ __RCSID("$NetBSD: show.c,v 1.49 2018/08/ | | | @@ -58,41 +58,26 @@ __RCSID("$NetBSD: show.c,v 1.49 2018/08/ |
58 | #include "parser.h" | | 58 | #include "parser.h" |
59 | #include "nodes.h" | | 59 | #include "nodes.h" |
60 | #include "mystring.h" | | 60 | #include "mystring.h" |
61 | #include "show.h" | | 61 | #include "show.h" |
62 | #include "options.h" | | 62 | #include "options.h" |
63 | #include "redir.h" | | 63 | #include "redir.h" |
64 | #include "error.h" | | 64 | #include "error.h" |
65 | #include "syntax.h" | | 65 | #include "syntax.h" |
66 | #include "input.h" | | 66 | #include "input.h" |
67 | #include "output.h" | | 67 | #include "output.h" |
68 | #include "var.h" | | 68 | #include "var.h" |
69 | #include "builtins.h" | | 69 | #include "builtins.h" |
70 | | | 70 | |
71 | #if defined(DEBUG) && !defined(DBG_PID) | | | |
72 | /* | | | |
73 | * If this is compiled, it means this is being compiled in a shell that still | | | |
74 | * has an older shell.h (a simpler TRACE() mechanism than is coming soon.) | | | |
75 | * | | | |
76 | * Compensate for as much of that as is missing and is needed here | | | |
77 | * to compile and operate at all. After the other changes have appeared, | | | |
78 | * this little block can (and should be) deleted (sometime). | | | |
79 | * | | | |
80 | * Try to avoid waiting 22 years... | | | |
81 | */ | | | |
82 | #define DBG_PID 1 | | | |
83 | #define DBG_NEST 2 | | | |
84 | #endif | | | |
85 | | | | |
86 | #define DEFINE_NODENAMES | | 71 | #define DEFINE_NODENAMES |
87 | #include "nodenames.h" /* does almost nothing if !defined(DEBUG) */ | | 72 | #include "nodenames.h" /* does almost nothing if !defined(DEBUG) */ |
88 | | | 73 | |
89 | #define TR_STD_WIDTH 60 /* tend to fold lines wider than this */ | | 74 | #define TR_STD_WIDTH 60 /* tend to fold lines wider than this */ |
90 | #define TR_IOVECS 10 /* number of lines or trace (max) / write */ | | 75 | #define TR_IOVECS 10 /* number of lines or trace (max) / write */ |
91 | | | 76 | |
92 | typedef struct traceinfo { | | 77 | typedef struct traceinfo { |
93 | int tfd; /* file descriptor for open trace file */ | | 78 | int tfd; /* file descriptor for open trace file */ |
94 | int nxtiov; /* the buffer we should be writing to */ | | 79 | int nxtiov; /* the buffer we should be writing to */ |
95 | char lastc; /* the last non-white character output */ | | 80 | char lastc; /* the last non-white character output */ |
96 | uint8_t supr; /* char classes to suppress after \n */ | | 81 | uint8_t supr; /* char classes to suppress after \n */ |
97 | pid_t pid; /* process id of process that opened that file */ | | 82 | pid_t pid; /* process id of process that opened that file */ |
98 | size_t llen; /* number of chars in current output line */ | | 83 | size_t llen; /* number of chars in current output line */ |