Changeset 3438 for trunk/src/kash/expand.c
- Timestamp:
- Sep 9, 2020, 10:01:39 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/expand.c
r2653 r3438 89 89 90 90 STATIC void argstr(shinstance *, char *, int); 91 STATIC void expari(shinstance *, int); 91 92 STATIC char *exptilde(shinstance *, char *, int); 92 93 STATIC void expbackq(shinstance *, union node *, int, int); … … 106 107 STATIC int pmatch(char *, char *, int); 107 108 STATIC char *cvtnum(shinstance *, int, char *); 109 STATIC char *cvtnum64(shinstance *, KI64, char *); 108 110 109 111 /* … … 343 345 * evaluate, place result in (backed up) result, adjust string position. 344 346 */ 345 void347 STATIC void 346 348 expari(shinstance *psh, int flag) 347 349 { … … 869 871 switch (*name) { 870 872 case '$': 873 #ifndef SH_FORKED_MODE 874 psh->expdest = cvtnum64(psh, psh->rootpid, psh->expdest); 875 break; 876 #else 871 877 num = psh->rootpid; 872 878 goto numvar; 879 #endif 873 880 case '?': 874 881 num = psh->exitstatus; … … 876 883 case '#': 877 884 num = psh->shellparam.nparam; 878 goto numvar;879 case '!':880 num = psh->backgndpid;881 885 numvar: 882 886 psh->expdest = cvtnum(psh, num, psh->expdest); 883 887 break; 888 case '!': 889 #ifndef SH_FORKED_MODE 890 psh->expdest = cvtnum64(psh, psh->backgndpid, psh->expdest); 891 break; 892 #else 893 num = psh->backgndpid; 894 goto numvar; 895 #endif 884 896 case '-': 885 897 for (i = 0; psh->optlist[i].name; i++) { … … 1561 1573 } 1562 1574 1575 STATIC char * 1576 cvtnum64(shinstance *psh, KI64 num, char *buf) 1577 { 1578 char temp[32]; 1579 int neg = num < 0; 1580 char *p = temp + 31; 1581 1582 temp[31] = '\0'; 1583 1584 do { 1585 *--p = num % 10 + '0'; 1586 } while ((num /= 10) != 0); 1587 1588 if (neg) 1589 *--p = '-'; 1590 1591 while (*p) 1592 STPUTC(psh, *p++, buf); 1593 return buf; 1594 } 1595 1563 1596 /* 1564 1597 * Do most of the work for wordexp(3).
Note:
See TracChangeset
for help on using the changeset viewer.