Changeset 1198 for trunk/src/kash/cd.c
- Timestamp:
- Oct 6, 2007, 11:19:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/cd.c
r883 r1198 86 86 char *p, *d; 87 87 struct stat statb; 88 int print = psh->cdprint; /* set -cdprint to enable */88 int print = cdprint(psh); /* set -cdprint to enable */ 89 89 90 90 nextopt(psh, nullstr); … … 171 171 psh->cdcomppath = stalloc(psh, strlen(dest) + 1); 172 172 scopy(dest, psh->cdcomppath); 173 STARTSTACKSTR(p );173 STARTSTACKSTR(psh, p); 174 174 if (IS_ROOT(dest)) { 175 STPUTC( '/', p);175 STPUTC(psh, '/', p); 176 176 psh->cdcomppath++; 177 177 } … … 181 181 continue; 182 182 if (! first) 183 STPUTC( '/', p);183 STPUTC(psh, '/', p); 184 184 first = 0; 185 185 component = q; 186 186 while (*q) 187 STPUTC( *q++, p);187 STPUTC(psh, *q++, p); 188 188 if (equal(component, "..")) 189 189 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) 192 192 || (S_ISLNK(statb.st_mode))) { 193 193 /* print = 1; */ … … 204 204 updatepwd(psh, badstat ? NULL : dest); 205 205 INTON; 206 if (print && psh->iflag&& psh->curdir)206 if (print && iflag(psh) && psh->curdir) 207 207 out1fmt(psh, "%s\n", psh->curdir); 208 208 return 0; … … 272 272 psh->cdcomppath = stalloc(psh, strlen(dir) + 1); 273 273 scopy(dir, psh->cdcomppath); 274 STARTSTACKSTR( new);274 STARTSTACKSTR(psh, new); 275 275 if (!IS_ROOT(dir)) { 276 276 p = psh->curdir; 277 277 while (*p) 278 STPUTC( *p++, new);278 STPUTC(psh, *p++, new); 279 279 if (p[-1] == '/') 280 STUNPUTC( new);280 STUNPUTC(psh, new); 281 281 } 282 282 while ((p = getcomponent(psh)) != NULL) { 283 283 if (equal(p, "..")) { 284 while (new > stackblock( ) && (STUNPUTC(new), *new) != '/');284 while (new > stackblock(psh) && (STUNPUTC(psh, new), *new) != '/'); 285 285 } else if (*p != '\0' && ! equal(p, ".")) { 286 STPUTC( '/', new);286 STPUTC(psh, '/', new); 287 287 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); 294 294 INTOFF; 295 295 if (psh->prevdir) 296 296 ckfree(psh->prevdir); 297 297 psh->prevdir = psh->curdir; 298 psh->curdir = savestr(stackblock( ));298 psh->curdir = savestr(stackblock(psh)); 299 299 setvar(psh, "PWD", psh->curdir, VEXPORT); 300 300 INTON;
Note:
See TracChangeset
for help on using the changeset viewer.