Print this page
10097 indenting fixes in usr/src/{lib,common}
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libeti/form/common/regcmp.c
+++ new/usr/src/lib/libeti/form/common/regcmp.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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
21 21 */
22 22 /* Copyright (c) 1988 AT&T */
23 23 /* All Rights Reserved */
24 24
25 25
26 26 /*
27 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 28 * Use is subject to license terms.
29 29 */
30 30
31 -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
31 +/*
32 + * Copyright (c) 2018, Joyent, Inc.
33 + */
32 34
33 35 /*LINTLIBRARY*/
34 36
35 37 #include <sys/types.h>
36 38 #include <stdlib.h>
37 39 #include "utility.h"
38 40
39 41 /* this code was taken from REGCMP(3X) */
40 42
41 43 #define SSIZE 16
42 44 #define TGRP 48
43 45 #define A256 02
44 46 #define ZERO 01
45 47 #define NBRA 10
46 48 #define CIRCFL 32;
47 49 #define SLOP 5
48 50 #define FEOF 0 /* This was originally EOF but it clashes with the header */
49 51 /* definition so it was changed to FEOF */
50 52
51 53 #define CBRA 60
52 54 #define GRP 40
53 55 #define SGRP 56
54 56 #define PGRP 68
55 57 #define EGRP 44
56 58 #define RNGE 03
57 59 #define CCHR 20
58 60 #define CDOT 64
59 61 #define CCL 24
60 62 #define NCCL 8
61 63 #define CDOL 28
62 64 #define FCEOF 52 /* This was originally CEOF but it clashes with the header */
63 65 /* definition so it was changed to FCEOF */
64 66 #define CKET 12
65 67
66 68 #define STAR 01
67 69 #define PLUS 02
68 70 #define MINUS 16
69 71
70 72 intptr_t *__sp_;
71 73 intptr_t *__stmax;
72 74 int __i_size;
73 75
74 76 /*ARGSUSED2*/
75 77 char *
76 78 libform_regcmp(char *cs1, char *cs2)
77 79 {
78 80 char c;
79 81 char *ep, *sp;
80 82 int *adx;
81 83 int i, cflg;
82 84 char *lastep, *sep, *eptr;
83 85 int nbra, ngrp;
84 86 int cclcnt;
85 87 intptr_t stack[SSIZE];
86 88
87 89 __sp_ = stack;
88 90 *__sp_ = -1;
89 91 __stmax = &stack[SSIZE];
90 92
91 93 adx = (int *)&cs1;
92 94 i = nbra = ngrp = 0;
93 95 while (*adx)
94 96 i += __size((char *)(intptr_t)*adx++);
95 97 adx = (int *)&cs1;
96 98 sp = (char *)(intptr_t)*adx++;
97 99 if ((sep = ep = malloc((unsigned)(2 * i + SLOP))) == NULL)
98 100 return (NULL);
99 101 if ((c = *sp++) == FEOF)
100 102 goto cerror;
101 103 if (c == '^') {
102 104 c = *sp++;
103 105 *ep++ = CIRCFL;
104 106 }
105 107 if ((c == '*') || (c == '+') || (c == '{'))
106 108 goto cerror;
107 109 sp--;
108 110 for (;;) {
109 111 if ((c = *sp++) == FEOF) {
110 112 if (*adx) {
111 113 sp = (char *)(intptr_t)*adx++;
112 114 continue;
113 115 }
114 116 *ep++ = FCEOF;
115 117 if (--nbra > NBRA || *__sp_ != -1)
116 118 goto cerror;
117 119 __i_size = (int) (ep - sep);
118 120 return (sep);
119 121 }
120 122 if ((c != '*') && (c != '{') && (c != '+'))
121 123 lastep = ep;
122 124 switch (c) {
123 125
124 126 case '(':
125 127 if (!__rpush(ep)) goto cerror;
126 128 *ep++ = CBRA;
127 129 *ep++ = -1;
128 130 continue;
129 131 case ')':
130 132 if (!(eptr = (char *)__rpop())) goto cerror;
131 133 if ((c = *sp++) == '$') {
132 134 if ('0' > (c = *sp++) || c > '9')
133 135 goto cerror;
134 136 *ep++ = CKET;
135 137 *ep++ = *++eptr = nbra++;
136 138 *ep++ = (c-'0');
137 139 continue;
138 140 }
139 141 *ep++ = EGRP;
140 142 *ep++ = ngrp++;
141 143 sp--;
142 144 switch (c) {
143 145 case '+':
144 146 *eptr = PGRP;
145 147 break;
146 148 case '*':
147 149 *eptr = SGRP;
148 150 break;
149 151 case '{':
150 152 *eptr = TGRP;
151 153 break;
152 154 default:
153 155 *eptr = GRP;
154 156 continue;
155 157 }
156 158 i = (int) (ep - eptr - 2);
157 159 for (cclcnt = 0; i >= 256; cclcnt++)
158 160 i -= 256;
159 161 if (cclcnt > 3) goto cerror;
160 162 *eptr |= cclcnt;
161 163 *++eptr = (char) i;
162 164 continue;
163 165
164 166 case '\\':
165 167 *ep++ = CCHR;
166 168 if ((c = *sp++) == FEOF)
167 169 goto cerror;
168 170 *ep++ = c;
169 171 continue;
170 172
171 173 case '{':
172 174 *lastep |= RNGE;
173 175 cflg = 0;
174 176 nlim:
175 177 if ((c = *sp++) == '}') goto cerror;
176 178 i = 0;
177 179 do {
178 180 if ('0' <= c && c <= '9')
179 181 i = (i*10+(c-'0'));
180 182 else goto cerror;
181 183 } while (((c = *sp++) != '}') && (c != ','));
182 184 if (i > 255) goto cerror;
183 185 *ep++ = (char) i;
184 186 if (c == ',') {
185 187 if (cflg++) goto cerror;
186 188 if ((c = *sp++) == '}') {
187 189 *ep++ = -1;
188 190 continue;
189 191 } else {
190 192 sp--;
191 193 goto nlim;
192 194 }
193 195 }
194 196 if (!cflg)
195 197 *ep++ = (char) i;
196 198 else if ((ep[-1]&0377) < (ep[-2]&0377))
197 199 goto cerror;
198 200 continue;
199 201
200 202 case '.':
201 203 *ep++ = CDOT;
↓ open down ↓ |
160 lines elided |
↑ open up ↑ |
202 204 continue;
203 205
204 206 case '+':
205 207 if (*lastep == CBRA || *lastep == CKET)
206 208 goto cerror;
207 209 *lastep |= PLUS;
208 210 continue;
209 211
210 212 case '*':
211 213 if (*lastep == CBRA || *lastep == CKET)
212 - goto cerror;
214 + goto cerror;
213 215 *lastep |= STAR;
214 216 continue;
215 217
216 218 case '$':
217 219 if ((*sp != FEOF) || (*adx))
218 220 goto defchar;
219 221 *ep++ = CDOL;
220 222 continue;
221 223
222 224 case '[':
223 225 *ep++ = CCL;
224 226 *ep++ = 0;
225 227 cclcnt = 1;
226 228 if ((c = *sp++) == '^') {
227 229 c = *sp++;
228 230 ep[-2] = NCCL;
229 231 }
230 232 do {
231 233 if (c == FEOF)
232 234 goto cerror;
233 235 if ((c == '-') && (cclcnt > 1) &&
234 236 (*sp != ']')) {
235 237 *ep = ep[-1];
236 238 ep++;
237 239 ep[-2] = MINUS;
238 240 cclcnt++;
239 241 continue;
240 242 }
241 243 *ep++ = c;
242 244 cclcnt++;
243 245 } while ((c = *sp++) != ']');
244 246 lastep[1] = (char) cclcnt;
245 247 continue;
246 248
247 249 defchar:
248 250 default:
249 251 *ep++ = CCHR;
250 252 *ep++ = c;
251 253 }
252 254 }
253 255 cerror:
254 256 free(sep);
255 257 return (0);
256 258 }
257 259
258 260 int
259 261 __size(char *strg)
260 262 {
261 263 int i;
262 264
263 265 i = 1;
264 266 while (*strg++)
265 267 i++;
266 268 return (i);
267 269 }
268 270
269 271 intptr_t
270 272 __rpop(void)
271 273 {
272 274 return ((*__sp_ == -1)?0:*__sp_--);
273 275 }
274 276
275 277 int
276 278 __rpush(char *ptr)
277 279 {
278 280 if (__sp_ >= __stmax)
279 281 return (0);
280 282 *++__sp_ = (intptr_t)ptr;
281 283 return (1);
282 284 }
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX