b.c (112336) | b.c (118194) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 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" 35 | 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 --- 19 unchanged lines hidden (view full) --- 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" 35 |
36#define HAT (NCHARS-2) /* matches ^ in regular expr */ | 36#define HAT (NCHARS+2) /* matches ^ in regular expr */ |
37 /* NCHARS is 2**n */ 38#define MAXLIN 22 39 40#define type(v) (v)->nobj /* badly overloaded here */ 41#define info(v) (v)->ntype /* badly overloaded here */ 42#define left(v) (v)->narg[0] 43#define right(v) (v)->narg[1] 44#define parent(v) (v)->nnext --- 232 unchanged lines hidden (view full) --- 277 } 278 c = n; 279 } /* else */ 280 /* c = c; */ 281 *pp = p; 282 return c; 283} 284 | 37 /* NCHARS is 2**n */ 38#define MAXLIN 22 39 40#define type(v) (v)->nobj /* badly overloaded here */ 41#define info(v) (v)->ntype /* badly overloaded here */ 42#define left(v) (v)->narg[0] 43#define right(v) (v)->narg[1] 44#define parent(v) (v)->nnext --- 232 unchanged lines hidden (view full) --- 277 } 278 c = n; 279 } /* else */ 280 /* c = c; */ 281 *pp = p; 282 return c; 283} 284 |
285static int collate_range_cmp(int a, int b) 286{ 287 int r; 288 static char s[2][2]; 289 290 if ((uschar)a == (uschar)b) 291 return 0; 292 s[0][0] = a; 293 s[1][0] = b; 294 if ((r = strcoll(s[0], s[1])) == 0) 295 r = (uschar)a - (uschar)b; 296 return r; 297} 298 | |
299char *cclenter(const char *argp) /* add a character class */ 300{ 301 int i, c, c2; | 285char *cclenter(const char *argp) /* add a character class */ 286{ 287 int i, c, c2; |
302 int j; | |
303 uschar *p = (uschar *) argp; 304 uschar *op, *bp; 305 static uschar *buf = 0; 306 static int bufsz = 100; 307 308 op = p; 309 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL) 310 FATAL("out of space for character class [%.10s...] 1", p); 311 bp = buf; 312 for (i = 0; (c = *p++) != 0; ) { 313 if (c == '\\') { 314 c = quoted((char **) &p); 315 } else if (c == '-' && i > 0 && bp[-1] != 0) { 316 if (*p != 0) { 317 c = bp[-1]; 318 c2 = *p++; 319 if (c2 == '\\') 320 c2 = quoted((char **) &p); | 288 uschar *p = (uschar *) argp; 289 uschar *op, *bp; 290 static uschar *buf = 0; 291 static int bufsz = 100; 292 293 op = p; 294 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL) 295 FATAL("out of space for character class [%.10s...] 1", p); 296 bp = buf; 297 for (i = 0; (c = *p++) != 0; ) { 298 if (c == '\\') { 299 c = quoted((char **) &p); 300 } else if (c == '-' && i > 0 && bp[-1] != 0) { 301 if (*p != 0) { 302 c = bp[-1]; 303 c2 = *p++; 304 if (c2 == '\\') 305 c2 = quoted((char **) &p); |
321 if (collate_range_cmp(c, c2) > 0) { /* empty; ignore */ | 306 if (c > c2) { /* empty; ignore */ |
322 bp--; 323 i--; 324 continue; 325 } | 307 bp--; 308 i--; 309 continue; 310 } |
326 for (j = 0; j < NCHARS; j++) { 327 if ((collate_range_cmp(c, j) > 0) || 328 collate_range_cmp(j, c2) > 0) 329 continue; | 311 while (c < c2) { |
330 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) 331 FATAL("out of space for character class [%.10s...] 2", p); | 312 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) 313 FATAL("out of space for character class [%.10s...] 2", p); |
332 *bp++ = j; | 314 *bp++ = ++c; |
333 i++; 334 } 335 continue; 336 } 337 } 338 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) 339 FATAL("out of space for character class [%.10s...] 3", p); 340 *bp++ = c; --- 372 unchanged lines hidden (view full) --- 713 * relex(), the expanded character class (prior to range expansion) 714 * must be less than twice the size of their full name. 715 */ 716 717/* Because isblank doesn't show up in any of the header files on any 718 * system i use, it's defined here. if some other locale has a richer 719 * definition of "blank", define HAS_ISBLANK and provide your own 720 * version. | 315 i++; 316 } 317 continue; 318 } 319 } 320 if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0)) 321 FATAL("out of space for character class [%.10s...] 3", p); 322 *bp++ = c; --- 372 unchanged lines hidden (view full) --- 695 * relex(), the expanded character class (prior to range expansion) 696 * must be less than twice the size of their full name. 697 */ 698 699/* Because isblank doesn't show up in any of the header files on any 700 * system i use, it's defined here. if some other locale has a richer 701 * definition of "blank", define HAS_ISBLANK and provide your own 702 * version. |
703 * the parentheses here are an attempt to find a path through the maze 704 * of macro definition and/or function and/or version provided. thanks 705 * to nelson beebe for the suggestion; let's see if it works everywhere. |
|
721 */ 722 723#ifndef HAS_ISBLANK 724 | 706 */ 707 708#ifndef HAS_ISBLANK 709 |
725int isblank(int c) | 710int (isblank)(int c) |
726{ 727 return c==' ' || c=='\t'; 728} 729 730#endif 731 732struct charclass { 733 const char *cc_name; --- 100 unchanged lines hidden (view full) --- 834 } 835} 836 837int cgoto(fa *f, int s, int c) 838{ 839 int i, j, k; 840 int *p, *q; 841 | 711{ 712 return c==' ' || c=='\t'; 713} 714 715#endif 716 717struct charclass { 718 const char *cc_name; --- 100 unchanged lines hidden (view full) --- 819 } 820} 821 822int cgoto(fa *f, int s, int c) 823{ 824 int i, j, k; 825 int *p, *q; 826 |
842 if (c < 0 || c > 255) 843 FATAL("can't happen: neg char %d in cgoto", c); | |
844 while (f->accept >= maxsetvec) { /* guessing here! */ 845 maxsetvec *= 4; 846 setvec = (int *) realloc(setvec, maxsetvec * sizeof(int)); 847 tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int)); 848 if (setvec == 0 || tmpset == 0) 849 overflo("out of space in cgoto()"); 850 } 851 for (i = 0; i <= f->accept; i++) --- 91 unchanged lines hidden --- | 827 while (f->accept >= maxsetvec) { /* guessing here! */ 828 maxsetvec *= 4; 829 setvec = (int *) realloc(setvec, maxsetvec * sizeof(int)); 830 tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int)); 831 if (setvec == 0 || tmpset == 0) 832 overflo("out of space in cgoto()"); 833 } 834 for (i = 0; i <= f->accept; i++) --- 91 unchanged lines hidden --- |