run.c (85587) | run.c (90902) |
---|---|
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 --- 1434 unchanged lines hidden (view full) --- 1443Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg list */ 1444{ 1445 Cell *x, *y; 1446 Awkfloat u; 1447 int t; 1448 char *p, *buf; 1449 Node *nextarg; 1450 FILE *fp; | 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 --- 1434 unchanged lines hidden (view full) --- 1443Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg list */ 1444{ 1445 Cell *x, *y; 1446 Awkfloat u; 1447 int t; 1448 char *p, *buf; 1449 Node *nextarg; 1450 FILE *fp; |
1451 void flush_all(void); |
|
1451 1452 t = ptoi(a[0]); 1453 x = execute(a[1]); 1454 nextarg = a[1]->nnext; 1455 switch (t) { 1456 case FLENGTH: | 1452 1453 t = ptoi(a[0]); 1454 x = execute(a[1]); 1455 nextarg = a[1]->nnext; 1456 switch (t) { 1457 case FLENGTH: |
1457 u = strlen(getsval(x)); break; | 1458 if (isarr(x)) 1459 u = ((Array *) x->sval)->nelem; /* GROT. should be function*/ 1460 else 1461 u = strlen(getsval(x)); 1462 break; |
1458 case FLOG: 1459 u = errcheck(log(getfval(x)), "log"); break; 1460 case FINT: 1461 modf(getfval(x), &u); break; 1462 case FEXP: 1463 u = errcheck(exp(getfval(x)), "exp"); break; 1464 case FSQRT: 1465 u = errcheck(sqrt(getfval(x)), "sqrt"); break; --- 40 unchanged lines hidden (view full) --- 1506 *p = tolower(*p); 1507 } 1508 tempfree(x); 1509 x = gettemp(); 1510 setsval(x, buf); 1511 free(buf); 1512 return x; 1513 case FFLUSH: | 1463 case FLOG: 1464 u = errcheck(log(getfval(x)), "log"); break; 1465 case FINT: 1466 modf(getfval(x), &u); break; 1467 case FEXP: 1468 u = errcheck(exp(getfval(x)), "exp"); break; 1469 case FSQRT: 1470 u = errcheck(sqrt(getfval(x)), "sqrt"); break; --- 40 unchanged lines hidden (view full) --- 1511 *p = tolower(*p); 1512 } 1513 tempfree(x); 1514 x = gettemp(); 1515 setsval(x, buf); 1516 free(buf); 1517 return x; 1518 case FFLUSH: |
1514 if ((fp = openfile(FFLUSH, getsval(x))) == NULL) | 1519 if (isrec(x) || strlen(getsval(x)) == 0) { 1520 flush_all(); /* fflush() or fflush("") -> all */ 1521 u = 0; 1522 } else if ((fp = openfile(FFLUSH, getsval(x))) == NULL) |
1515 u = EOF; 1516 else 1517 u = fflush(fp); 1518 break; 1519 default: /* can't happen */ 1520 FATAL("illegal function type %d", t); 1521 break; 1522 } --- 174 unchanged lines hidden (view full) --- 1697 else 1698 stat = fclose(files[i].fp); 1699 if (stat == EOF) 1700 WARNING( "i/o error occurred while closing %s", files[i].fname ); 1701 } 1702 } 1703} 1704 | 1523 u = EOF; 1524 else 1525 u = fflush(fp); 1526 break; 1527 default: /* can't happen */ 1528 FATAL("illegal function type %d", t); 1529 break; 1530 } --- 174 unchanged lines hidden (view full) --- 1705 else 1706 stat = fclose(files[i].fp); 1707 if (stat == EOF) 1708 WARNING( "i/o error occurred while closing %s", files[i].fname ); 1709 } 1710 } 1711} 1712 |
1713void flush_all(void) 1714{ 1715 int i; 1716 1717 for (i = 0; i < FOPEN_MAX; i++) 1718 if (files[i].fp) 1719 fflush(files[i].fp); 1720} 1721 |
|
1705void backsub(char **pb_ptr, char **sptr_ptr); 1706 1707Cell *sub(Node **a, int nnn) /* substitute command */ 1708{ 1709 char *sptr, *pb, *q; 1710 Cell *x, *y, *result; 1711 char *t, *buf; 1712 fa *pfa; --- 179 unchanged lines hidden --- | 1722void backsub(char **pb_ptr, char **sptr_ptr); 1723 1724Cell *sub(Node **a, int nnn) /* substitute command */ 1725{ 1726 char *sptr, *pb, *q; 1727 Cell *x, *y, *result; 1728 char *t, *buf; 1729 fa *pfa; --- 179 unchanged lines hidden --- |