Print this page
5396 gcc 4.8.2 longjmp errors for cscope-fast
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/cscope-fast/input.c
+++ new/usr/src/tools/cscope-fast/input.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 + * Copyright 2015 Gary Mills
23 24 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
24 25 */
25 26
26 27 /* Copyright (c) 1988 AT&T */
27 28 /* All Rights Reserved */
28 29
29 30 /*
30 31 * cscope - interactive C symbol cross-reference
31 32 *
32 33 * terminal input functions
33 34 */
34 35
35 36 #include "global.h"
36 37 #include <curses.h> /* KEY_BACKSPACE, KEY_BREAK, and KEY_ENTER */
37 38 #include <setjmp.h> /* jmp_buf */
38 39
39 40 static jmp_buf env; /* setjmp/longjmp buffer */
40 41 static int prevchar; /* previous, ungotten character */
41 42
42 43 /* catch the interrupt signal */
43 44
44 45 /*ARGSUSED*/
45 46 SIGTYPE
46 47 catchint(int sig)
47 48 {
48 49 (void) signal(SIGINT, catchint);
49 50 longjmp(env, 1);
50 51 }
51 52
52 53 /* unget a character */
53 54
54 55 int
55 56 ungetch(int c)
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
56 57 {
57 58 prevchar = c;
58 59 return (0);
59 60 }
60 61
61 62 /* get a character from the terminal */
62 63
63 64 int
64 65 mygetch(void)
65 66 {
66 - SIGTYPE (*savesig)(); /* old value of signal */
67 + SIGTYPE (*volatile savesig)() = SIG_DFL; /* old value of signal */
67 68 int c;
68 69
69 70 /* change an interrupt signal to a break key character */
70 71 if (setjmp(env) == 0) {
71 72 savesig = signal(SIGINT, catchint);
72 73 (void) refresh(); /* update the display */
73 74 reinitmouse(); /* curses can change the menu number */
74 75 if (prevchar) {
75 76 c = prevchar;
76 77 prevchar = 0;
77 78 } else {
78 79 c = getch(); /* get a character from the terminal */
79 80 }
80 81 } else { /* longjmp to here from signal handler */
81 82 c = KEY_BREAK;
82 83 }
83 84 (void) signal(SIGINT, savesig);
84 85 return (c);
85 86 }
86 87
87 88 /* get a line from the terminal in non-canonical mode */
88 89
89 90 int
90 91 getaline(char s[], size_t size, int firstchar, BOOL iscaseless)
91 92 {
92 93 int c, i = 0;
93 94 int j;
94 95
95 96 /* if a character already has been typed */
96 97 if (firstchar != '\0') {
97 98 if (iscaseless == YES) {
98 99 firstchar = tolower(firstchar);
99 100 }
100 101 (void) addch((unsigned)firstchar); /* display it */
101 102 s[i++] = firstchar; /* save it */
102 103 }
103 104 /* until the end of the line is reached */
104 105 while ((c = mygetch()) != '\r' && c != '\n' && c != KEY_ENTER &&
105 106 c != '\003' && c != KEY_BREAK) {
106 107 if (c == erasechar() || c == '\b' || /* erase */
107 108 c == KEY_BACKSPACE) {
108 109 if (i > 0) {
109 110 (void) addstr("\b \b");
110 111 --i;
111 112 }
112 113 } else if (c == killchar()) { /* kill */
113 114 for (j = 0; j < i; ++j) {
114 115 (void) addch('\b');
115 116 }
116 117 for (j = 0; j < i; ++j) {
117 118 (void) addch(' ');
118 119 }
119 120 for (j = 0; j < i; ++j) {
120 121 (void) addch('\b');
121 122 }
122 123 i = 0;
123 124 } else if (isprint(c) || c == '\t') { /* printable */
124 125 if (iscaseless == YES) {
125 126 c = tolower(c);
126 127 }
127 128 /* if it will fit on the line */
128 129 if (i < size) {
129 130 (void) addch((unsigned)c); /* display it */
130 131 s[i++] = c; /* save it */
131 132 }
132 133 } else if (c == ctrl('X')) {
133 134 /* mouse */
134 135 (void) getmouseevent(); /* ignore it */
135 136 } else if (c == EOF) { /* end-of-file */
136 137 break;
137 138 }
138 139 /* return on an empty line to allow a command to be entered */
139 140 if (firstchar != '\0' && i == 0) {
140 141 break;
141 142 }
142 143 }
143 144 s[i] = '\0';
144 145 return (i);
145 146 }
146 147
147 148 /* ask user to enter a character after reading the message */
148 149
149 150 void
150 151 askforchar(void)
151 152 {
152 153 (void) addstr("Type any character to continue: ");
153 154 (void) mygetch();
154 155 }
155 156
156 157 /* ask user to press the RETURN key after reading the message */
157 158
158 159 void
159 160 askforreturn(void)
160 161 {
161 162 if (linemode == NO) {
162 163 (void) fprintf(stderr, "Press the RETURN key to continue: ");
163 164 (void) getchar();
164 165 }
165 166 }
166 167
167 168 /* expand the ~ and $ shell meta characters in a path */
168 169
169 170 void
170 171 shellpath(char *out, int limit, char *in)
171 172 {
172 173 char *lastchar;
173 174 char *s, *v;
174 175
175 176 /* skip leading white space */
176 177 while (isspace(*in)) {
177 178 ++in;
178 179 }
179 180 lastchar = out + limit - 1;
180 181
181 182 /*
182 183 * a tilde (~) by itself represents $HOME; followed by a name it
183 184 * represents the $LOGDIR of that login name
184 185 */
185 186 if (*in == '~') {
186 187 *out++ = *in++; /* copy the ~ because it may not be expanded */
187 188
188 189 /* get the login name */
189 190 s = out;
190 191 while (s < lastchar && *in != '/' && *in != '\0' &&
191 192 !isspace(*in)) {
192 193 *s++ = *in++;
193 194 }
194 195 *s = '\0';
195 196
196 197 /* if the login name is null, then use $HOME */
197 198 if (*out == '\0') {
198 199 v = getenv("HOME");
199 200 } else { /* get the home directory of the login name */
200 201 v = logdir(out);
201 202 }
202 203 /* copy the directory name */
203 204 if (v != NULL) {
204 205 (void) strcpy(out - 1, v);
205 206 out += strlen(v) - 1;
206 207 } else {
207 208 /* login not found so ~ must be part of the file name */
208 209 out += strlen(out);
209 210 }
210 211 }
211 212 /* get the rest of the path */
212 213 while (out < lastchar && *in != '\0' && !isspace(*in)) {
213 214
214 215 /* look for an environment variable */
215 216 if (*in == '$') {
216 217 /* copy the $ because it may not be expanded */
217 218 *out++ = *in++;
218 219
219 220 /* get the variable name */
220 221 s = out;
221 222 while (s < lastchar && *in != '/' && *in != '\0' &&
222 223 !isspace(*in)) {
223 224 *s++ = *in++;
224 225 }
225 226 *s = '\0';
226 227
227 228 /* get its value */
228 229 if ((v = getenv(out)) != NULL) {
229 230 (void) strcpy(out - 1, v);
230 231 out += strlen(v) - 1;
231 232 } else {
232 233 /*
233 234 * var not found, so $ must be part of
234 235 * the file name
235 236 */
236 237 out += strlen(out);
237 238 }
238 239 } else { /* ordinary character */
239 240 *out++ = *in++;
240 241 }
241 242 }
242 243 *out = '\0';
243 244 }
↓ open down ↓ |
167 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX