Ignore:
Timestamp:
Sep 9, 2020, 10:01:39 PM (5 years ago)
Author:
bird
Message:

kash: Hammering on threaded mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/expand.c

    r2653 r3438  
    8989
    9090STATIC void argstr(shinstance *, char *, int);
     91STATIC void expari(shinstance *, int);
    9192STATIC char *exptilde(shinstance *, char *, int);
    9293STATIC void expbackq(shinstance *, union node *, int, int);
     
    106107STATIC int pmatch(char *, char *, int);
    107108STATIC char *cvtnum(shinstance *, int, char *);
     109STATIC char *cvtnum64(shinstance *, KI64, char *);
    108110
    109111/*
     
    343345 * evaluate, place result in (backed up) result, adjust string position.
    344346 */
    345 void
     347STATIC void
    346348expari(shinstance *psh, int flag)
    347349{
     
    869871        switch (*name) {
    870872        case '$':
     873#ifndef SH_FORKED_MODE
     874                psh->expdest = cvtnum64(psh, psh->rootpid, psh->expdest);
     875                break;
     876#else
    871877                num = psh->rootpid;
    872878                goto numvar;
     879#endif
    873880        case '?':
    874881                num = psh->exitstatus;
     
    876883        case '#':
    877884                num = psh->shellparam.nparam;
    878                 goto numvar;
    879         case '!':
    880                 num = psh->backgndpid;
    881885numvar:
    882886                psh->expdest = cvtnum(psh, num, psh->expdest);
    883887                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
    884896        case '-':
    885897                for (i = 0; psh->optlist[i].name; i++) {
     
    15611573}
    15621574
     1575STATIC char *
     1576cvtnum64(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
    15631596/*
    15641597 * Do most of the work for wordexp(3).
Note: See TracChangeset for help on using the changeset viewer.