Deleted Added
full compact
b.c (221381) b.c (224731)
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

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

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>
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

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

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 221381 2011-05-03 11:47:19Z ru $");
28__FBSDID("$FreeBSD: head/contrib/one-true-awk/b.c 224731 2011-08-09 12:54:43Z 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"

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

229 FATAL("can't happen: unknown type %d in freetr", type(p));
230 break;
231 }
232}
233
234/* in the parsing of regular expressions, metacharacters like . have */
235/* to be seen literally; \056 is not a metacharacter. */
236
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"

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

229 FATAL("can't happen: unknown type %d in freetr", type(p));
230 break;
231 }
232}
233
234/* in the parsing of regular expressions, metacharacters like . have */
235/* to be seen literally; \056 is not a metacharacter. */
236
237int hexstr(char **pp) /* find and eval hex string at pp, return new p */
237int hexstr(uschar **pp) /* find and eval hex string at pp, return new p */
238{ /* only pick up one 8-bit byte (2 chars) */
239 uschar *p;
240 int n = 0;
241 int i;
242
243 for (i = 0, p = (uschar *) *pp; i < 2 && isxdigit(*p); i++, p++) {
244 if (isdigit(*p))
245 n = 16 * n + *p - '0';
246 else if (*p >= 'a' && *p <= 'f')
247 n = 16 * n + *p - 'a' + 10;
248 else if (*p >= 'A' && *p <= 'F')
249 n = 16 * n + *p - 'A' + 10;
250 }
238{ /* only pick up one 8-bit byte (2 chars) */
239 uschar *p;
240 int n = 0;
241 int i;
242
243 for (i = 0, p = (uschar *) *pp; i < 2 && isxdigit(*p); i++, p++) {
244 if (isdigit(*p))
245 n = 16 * n + *p - '0';
246 else if (*p >= 'a' && *p <= 'f')
247 n = 16 * n + *p - 'a' + 10;
248 else if (*p >= 'A' && *p <= 'F')
249 n = 16 * n + *p - 'A' + 10;
250 }
251 *pp = (char *) p;
251 *pp = (uschar *) p;
252 return n;
253}
254
255#define isoctdigit(c) ((c) >= '0' && (c) <= '7') /* multiple use of arg */
256
252 return n;
253}
254
255#define isoctdigit(c) ((c) >= '0' && (c) <= '7') /* multiple use of arg */
256
257int quoted(char **pp) /* pick up next thing after a \\ */
257int quoted(uschar **pp) /* pick up next thing after a \\ */
258 /* and increment *pp */
259{
258 /* and increment *pp */
259{
260 char *p = *pp;
260 uschar *p = *pp;
261 int c;
262
263 if ((c = *p++) == 't')
264 c = '\t';
265 else if (c == 'n')
266 c = '\n';
267 else if (c == 'f')
268 c = '\f';

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

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 == '\\') {
261 int c;
262
263 if ((c = *p++) == 't')
264 c = '\t';
265 else if (c == 'n')
266 c = '\n';
267 else if (c == 'f')
268 c = '\f';

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

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);
317 c = quoted(&p);
318 } else if (c == '-' && i > 0 && bp[-1] != 0) {
319 if (*p != 0) {
320 c = bp[-1];
321 c2 = *p++;
322 if (c2 == '\\')
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);
323 c2 = quoted(&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)

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

802 case '.': return DOT;
803 case '\0': prestr--; return '\0';
804 case '^':
805 case '$':
806 case '(':
807 case ')':
808 return c;
809 case '\\':
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)

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

802 case '.': return DOT;
803 case '\0': prestr--; return '\0';
804 case '^':
805 case '$':
806 case '(':
807 case ')':
808 return c;
809 case '\\':
810 rlxval = quoted((char **) &prestr);
810 rlxval = quoted(&prestr);
811 return CHAR;
812 default:
813 rlxval = c;
814 return CHAR;
815 case '[':
816 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
817 FATAL("out of space in reg expr %.10s..", lastre);
818 bp = buf;

--- 158 unchanged lines hidden ---
811 return CHAR;
812 default:
813 rlxval = c;
814 return CHAR;
815 case '[':
816 if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
817 FATAL("out of space in reg expr %.10s..", lastre);
818 bp = buf;

--- 158 unchanged lines hidden ---