Deleted Added
sdiff udiff text old ( 201951 ) new ( 201989 )
full compact
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
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
302char *cclenter(const char *argp) /* add a character class */
303{
304 int i, c, c2;
305 int j;
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);
324 if (collate_range_cmp(c, c2) > 0) {
325 bp--;
326 i--;
327 continue;
328 }
329 for (j = 0; j < NCHARS; j++) {
330 if ((collate_range_cmp(c, j) > 0) ||
331 collate_range_cmp(j, c2) > 0)
332 continue;
333 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "cclenter1"))
334 FATAL("out of space for character class [%.10s...] 2", p);
335 *bp++ = j;
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 ---