lib.c (85587) | lib.c (107806) |
---|---|
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 --- 376 unchanged lines hidden (view full) --- 385 nf = n; 386 fldtab = (Cell **) realloc(fldtab, (nf+1) * (sizeof (struct Cell *))); 387 if (fldtab == NULL) 388 FATAL("out of space creating %d fields", nf); 389 makefields(nfields+1, nf); 390 nfields = nf; 391} 392 | 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 --- 376 unchanged lines hidden (view full) --- 385 nf = n; 386 fldtab = (Cell **) realloc(fldtab, (nf+1) * (sizeof (struct Cell *))); 387 if (fldtab == NULL) 388 FATAL("out of space creating %d fields", nf); 389 makefields(nfields+1, nf); 390 nfields = nf; 391} 392 |
393int refldbld(char *rec, char *fs) /* build fields from reg expr in FS */ | 393int refldbld(const char *rec, const char *fs) /* build fields from reg expr in FS */ |
394{ 395 /* this relies on having fields[] the same length as $0 */ 396 /* the fields are all stored in this one array with \0's */ 397 char *fr; 398 int i, tempstat, n; 399 fa *pfa; 400 401 n = strlen(rec); --- 68 unchanged lines hidden (view full) --- 470 471 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); 472 dprintf( ("recbld = |%s|\n", record) ); 473 donerec = 1; 474} 475 476int errorflag = 0; 477 | 394{ 395 /* this relies on having fields[] the same length as $0 */ 396 /* the fields are all stored in this one array with \0's */ 397 char *fr; 398 int i, tempstat, n; 399 fa *pfa; 400 401 n = strlen(rec); --- 68 unchanged lines hidden (view full) --- 470 471 dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); 472 dprintf( ("recbld = |%s|\n", record) ); 473 donerec = 1; 474} 475 476int errorflag = 0; 477 |
478void yyerror(char *s) | 478void yyerror(const char *s) |
479{ 480 SYNTAX(s); 481} 482 | 479{ 480 SYNTAX(s); 481} 482 |
483void SYNTAX(char *fmt, ...) | 483void SYNTAX(const char *fmt, ...) |
484{ 485 extern char *cmdname, *curfname; 486 static int been_here = 0; 487 va_list varg; 488 489 if (been_here++ > 2) 490 return; 491 fprintf(stderr, "%s: ", cmdname); --- 38 unchanged lines hidden (view full) --- 530 else if (n > 1) 531 fprintf(stderr, "\t%d missing %c's\n", n, c2); 532 else if (n == -1) 533 fprintf(stderr, "\textra %c\n", c2); 534 else if (n < -1) 535 fprintf(stderr, "\t%d extra %c's\n", -n, c2); 536} 537 | 484{ 485 extern char *cmdname, *curfname; 486 static int been_here = 0; 487 va_list varg; 488 489 if (been_here++ > 2) 490 return; 491 fprintf(stderr, "%s: ", cmdname); --- 38 unchanged lines hidden (view full) --- 530 else if (n > 1) 531 fprintf(stderr, "\t%d missing %c's\n", n, c2); 532 else if (n == -1) 533 fprintf(stderr, "\textra %c\n", c2); 534 else if (n < -1) 535 fprintf(stderr, "\t%d extra %c's\n", -n, c2); 536} 537 |
538void FATAL(char *fmt, ...) | 538void FATAL(const char *fmt, ...) |
539{ 540 extern char *cmdname; 541 va_list varg; 542 543 fflush(stdout); 544 fprintf(stderr, "%s: ", cmdname); 545 va_start(varg, fmt); 546 vfprintf(stderr, fmt, varg); 547 va_end(varg); 548 error(); 549 if (dbg > 1) /* core dump if serious debugging on */ 550 abort(); 551 exit(2); 552} 553 | 539{ 540 extern char *cmdname; 541 va_list varg; 542 543 fflush(stdout); 544 fprintf(stderr, "%s: ", cmdname); 545 va_start(varg, fmt); 546 vfprintf(stderr, fmt, varg); 547 va_end(varg); 548 error(); 549 if (dbg > 1) /* core dump if serious debugging on */ 550 abort(); 551 exit(2); 552} 553 |
554void WARNING(char *fmt, ...) | 554void WARNING(const char *fmt, ...) |
555{ 556 extern char *cmdname; 557 va_list varg; 558 559 fflush(stdout); 560 fprintf(stderr, "%s: ", cmdname); 561 va_start(varg, fmt); 562 vfprintf(stderr, fmt, varg); --- 65 unchanged lines hidden (view full) --- 628 case '}': bracecnt--; break; 629 case '[': brackcnt++; break; 630 case ']': brackcnt--; break; 631 case '(': parencnt++; break; 632 case ')': parencnt--; break; 633 } 634} 635 | 555{ 556 extern char *cmdname; 557 va_list varg; 558 559 fflush(stdout); 560 fprintf(stderr, "%s: ", cmdname); 561 va_start(varg, fmt); 562 vfprintf(stderr, fmt, varg); --- 65 unchanged lines hidden (view full) --- 628 case '}': bracecnt--; break; 629 case '[': brackcnt++; break; 630 case ']': brackcnt--; break; 631 case '(': parencnt++; break; 632 case ')': parencnt--; break; 633 } 634} 635 |
636double errcheck(double x, char *s) | 636double errcheck(double x, const char *s) |
637{ 638 639 if (errno == EDOM) { 640 errno = 0; 641 WARNING("%s argument out of domain", s); 642 x = 1; 643 } else if (errno == ERANGE) { 644 errno = 0; 645 WARNING("%s result out of range", s); 646 x = 1; 647 } 648 return x; 649} 650 | 637{ 638 639 if (errno == EDOM) { 640 errno = 0; 641 WARNING("%s argument out of domain", s); 642 x = 1; 643 } else if (errno == ERANGE) { 644 errno = 0; 645 WARNING("%s result out of range", s); 646 x = 1; 647 } 648 return x; 649} 650 |
651int isclvar(char *s) /* is s of form var=something ? */ | 651int isclvar(const char *s) /* is s of form var=something ? */ |
652{ | 652{ |
653 char *os = s; | 653 const char *os = s; |
654 655 if (!isalpha((uschar) *s) && *s != '_') 656 return 0; 657 for ( ; *s; s++) 658 if (!(isalnum((uschar) *s) || *s == '_')) 659 break; 660 return *s == '=' && s > os && *(s+1) != '='; 661} 662 663/* strtod is supposed to be a proper test of what's a valid number */ 664/* appears to be broken in gcc on linux: thinks 0x123 is a valid FP number */ 665/* wrong: violates 4.10.1.4 of ansi C standard */ 666 667#include <math.h> | 654 655 if (!isalpha((uschar) *s) && *s != '_') 656 return 0; 657 for ( ; *s; s++) 658 if (!(isalnum((uschar) *s) || *s == '_')) 659 break; 660 return *s == '=' && s > os && *(s+1) != '='; 661} 662 663/* strtod is supposed to be a proper test of what's a valid number */ 664/* appears to be broken in gcc on linux: thinks 0x123 is a valid FP number */ 665/* wrong: violates 4.10.1.4 of ansi C standard */ 666 667#include <math.h> |
668int is_number(char *s) | 668int is_number(const char *s) |
669{ 670 double r; 671 char *ep; 672 errno = 0; 673 r = strtod(s, &ep); 674 if (ep == s || r == HUGE_VAL || errno == ERANGE) 675 return 0; 676 while (*ep == ' ' || *ep == '\t' || *ep == '\n') 677 ep++; 678 if (*ep == '\0') 679 return 1; 680 else 681 return 0; 682} | 669{ 670 double r; 671 char *ep; 672 errno = 0; 673 r = strtod(s, &ep); 674 if (ep == s || r == HUGE_VAL || errno == ERANGE) 675 return 0; 676 while (*ep == ' ' || *ep == '\t' || *ep == '\n') 677 ep++; 678 if (*ep == '\0') 679 return 1; 680 else 681 return 0; 682} |