Deleted Added
full compact
b.c (201951) b.c (201989)
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 10 unchanged lines hidden (view full) ---

19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22THIS SOFTWARE.
23****************************************************************/
24
25/* lasciate ogne speranza, voi ch'intrate. */
26
1/****************************************************************
2Copyright (C) Lucent Technologies 1997
3All Rights Reserved
4
5Permission to use, copy, modify, and distribute this software and
6its documentation for any purpose and without fee is hereby
7granted, provided that the above copyright notice appear in all
8copies and that both that the copyright notice and this

--- 10 unchanged lines hidden (view full) ---

19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22THIS SOFTWARE.
23****************************************************************/
24
25/* lasciate ogne speranza, voi ch'intrate. */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/contrib/one-true-awk/b.c 201989 2010-01-10 08:02:07Z ru $");
29
27#define DEBUG
28
29#include <ctype.h>
30#include <stdio.h>
31#include <string.h>
32#include <stdlib.h>
33#include "awk.h"
34#include "ytab.h"

--- 245 unchanged lines hidden (view full) ---

280 }
281 c = n;
282 } /* else */
283 /* c = c; */
284 *pp = p;
285 return c;
286}
287
30#define DEBUG
31
32#include <ctype.h>
33#include <stdio.h>
34#include <string.h>
35#include <stdlib.h>
36#include "awk.h"
37#include "ytab.h"

--- 245 unchanged lines hidden (view full) ---

283 }
284 c = n;
285 } /* else */
286 /* c = c; */
287 *pp = p;
288 return c;
289}
290
291static int collate_range_cmp(int a, int b)
292{
293 static char s[2][2];
294
295 if ((uschar)a == (uschar)b)
296 return 0;
297 s[0][0] = a;
298 s[1][0] = b;
299 return (strcoll(s[0], s[1]));
300}
301
288char *cclenter(const char *argp) /* add a character class */
289{
290 int i, c, c2;
302char *cclenter(const char *argp) /* add a character class */
303{
304 int i, c, c2;
305 int j;
291 uschar *p = (uschar *) argp;
292 uschar *op, *bp;
293 static uschar *buf = 0;
294 static int bufsz = 100;
295
296 op = p;
297 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
298 FATAL("out of space for character class [%.10s...] 1", p);
299 bp = buf;
300 for (i = 0; (c = *p++) != 0; ) {
301 if (c == '\\') {
302 c = quoted((char **) &p);
303 } else if (c == '-' && i > 0 && bp[-1] != 0) {
304 if (*p != 0) {
305 c = bp[-1];
306 c2 = *p++;
307 if (c2 == '\\')
308 c2 = quoted((char **) &p);
306 uschar *p = (uschar *) argp;
307 uschar *op, *bp;
308 static uschar *buf = 0;
309 static int bufsz = 100;
310
311 op = p;
312 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
313 FATAL("out of space for character class [%.10s...] 1", p);
314 bp = buf;
315 for (i = 0; (c = *p++) != 0; ) {
316 if (c == '\\') {
317 c = quoted((char **) &p);
318 } else if (c == '-' && i > 0 && bp[-1] != 0) {
319 if (*p != 0) {
320 c = bp[-1];
321 c2 = *p++;
322 if (c2 == '\\')
323 c2 = quoted((char **) &p);
309 if (c > c2) { /* empty; ignore */
324 if (collate_range_cmp(c, c2) > 0) {
310 bp--;
311 i--;
312 continue;
313 }
325 bp--;
326 i--;
327 continue;
328 }
314 while (c < c2) {
329 for (j = 0; j < NCHARS; j++) {
330 if ((collate_range_cmp(c, j) > 0) ||
331 collate_range_cmp(j, c2) > 0)
332 continue;
315 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1"))
316 FATAL("out of space for character class [%.10s...] 2", p);
333 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1"))
334 FATAL("out of space for character class [%.10s...] 2", p);
317 *bp++ = ++c;
335 *bp++ = j;
318 i++;
319 }
320 continue;
321 }
322 }
323 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2"))
324 FATAL("out of space for character class [%.10s...] 3", p);
325 *bp++ = c;

--- 629 unchanged lines hidden ---
336 i++;
337 }
338 continue;
339 }
340 }
341 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter2"))
342 FATAL("out of space for character class [%.10s...] 3", p);
343 *bp++ = c;

--- 629 unchanged lines hidden ---