Changeset 1198 for trunk/src/kash/cd.c


Ignore:
Timestamp:
Oct 6, 2007, 11:19:19 PM (18 years ago)
Author:
bird
Message:

moving globals into shinstance...

File:
1 edited

Legend:

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

    r883 r1198  
    8686        char *p, *d;
    8787        struct stat statb;
    88         int print = psh->cdprint;       /* set -cdprint to enable */
     88        int print = cdprint(psh);       /* set -cdprint to enable */
    8989
    9090        nextopt(psh, nullstr);
     
    171171        psh->cdcomppath = stalloc(psh, strlen(dest) + 1);
    172172        scopy(dest, psh->cdcomppath);
    173         STARTSTACKSTR(p);
     173        STARTSTACKSTR(psh, p);
    174174        if (IS_ROOT(dest)) {
    175                 STPUTC('/', p);
     175                STPUTC(psh, '/', p);
    176176                psh->cdcomppath++;
    177177        }
     
    181181                        continue;
    182182                if (! first)
    183                         STPUTC('/', p);
     183                        STPUTC(psh, '/', p);
    184184                first = 0;
    185185                component = q;
    186186                while (*q)
    187                         STPUTC(*q++, p);
     187                        STPUTC(psh, *q++, p);
    188188                if (equal(component, ".."))
    189189                        continue;
    190                 STACKSTRNUL(p);
    191                 if ((shfile_lstat(&psh->fdtab, stackblock(), &statb) < 0)
     190                STACKSTRNUL(psh, p);
     191                if ((shfile_lstat(&psh->fdtab, stackblock(psh), &statb) < 0)
    192192                    || (S_ISLNK(statb.st_mode)))  {
    193193                        /* print = 1; */
     
    204204        updatepwd(psh, badstat ? NULL : dest);
    205205        INTON;
    206         if (print && psh->iflag && psh->curdir)
     206        if (print && iflag(psh) && psh->curdir)
    207207                out1fmt(psh, "%s\n", psh->curdir);
    208208        return 0;
     
    272272        psh->cdcomppath = stalloc(psh, strlen(dir) + 1);
    273273        scopy(dir, psh->cdcomppath);
    274         STARTSTACKSTR(new);
     274        STARTSTACKSTR(psh, new);
    275275        if (!IS_ROOT(dir)) {
    276276                p = psh->curdir;
    277277                while (*p)
    278                         STPUTC(*p++, new);
     278                        STPUTC(psh, *p++, new);
    279279                if (p[-1] == '/')
    280                         STUNPUTC(new);
     280                        STUNPUTC(psh, new);
    281281        }
    282282        while ((p = getcomponent(psh)) != NULL) {
    283283                if (equal(p, "..")) {
    284                         while (new > stackblock() && (STUNPUTC(new), *new) != '/');
     284                        while (new > stackblock(psh) && (STUNPUTC(psh, new), *new) != '/');
    285285                } else if (*p != '\0' && ! equal(p, ".")) {
    286                         STPUTC('/', new);
     286                        STPUTC(psh, '/', new);
    287287                        while (*p)
    288                                 STPUTC(*p++, new);
    289                 }
    290         }
    291         if (new == stackblock())
    292                 STPUTC('/', new);
    293         STACKSTRNUL(new);
     288                                STPUTC(psh, *p++, new);
     289                }
     290        }
     291        if (new == stackblock(psh))
     292                STPUTC(psh, '/', new);
     293        STACKSTRNUL(psh, new);
    294294        INTOFF;
    295295        if (psh->prevdir)
    296296                ckfree(psh->prevdir);
    297297        psh->prevdir = psh->curdir;
    298         psh->curdir = savestr(stackblock());
     298        psh->curdir = savestr(stackblock(psh));
    299299        setvar(psh, "PWD", psh->curdir, VEXPORT);
    300300        INTON;
Note: See TracChangeset for help on using the changeset viewer.