Changeset 2652 in kBuild for trunk/src/kash/shfile.c
- Timestamp:
- Sep 9, 2012 5:21:48 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shfile.c
r2650 r2652 164 164 static void shfile_native_close(intptr_t native, unsigned flags) 165 165 { 166 # if K_OS == K_OS_WINDOWS166 # if K_OS == K_OS_WINDOWS 167 167 BOOL fRc = CloseHandle((HANDLE)native); 168 168 assert(fRc); (void)fRc; 169 # else169 # else 170 170 int s = errno; 171 171 close(native); 172 172 errno = s; 173 # endif173 # endif 174 174 (void)flags; 175 175 } … … 289 289 } 290 290 291 # if K_OS != K_OS_WINDOWS291 # if K_OS != K_OS_WINDOWS 292 292 /** 293 293 * Makes a copy of the native file, closes the original, and inserts the copy … … 318 318 return fd; 319 319 } 320 # endif /* !K_OS_WINDOWS */320 # endif /* !K_OS_WINDOWS */ 321 321 322 322 /** … … 385 385 } 386 386 if ( *path == '/' 387 # if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2387 # if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2 388 388 || *path == '\\' 389 389 || ( *path … … 391 391 && ( (*path >= 'A' && *path <= 'Z') 392 392 || (*path >= 'a' && *path <= 'z'))) 393 # endif393 # endif 394 394 ) 395 395 { … … 419 419 } 420 420 421 # if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2421 # if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2 422 422 if (!strcmp(buf, "/dev/null")) 423 423 strcpy(buf, "NUL"); 424 # endif424 # endif 425 425 return 0; 426 426 } … … 528 528 529 529 /** 530 * Converts DOS slashes to UNIX slashes if necessary. 531 * 532 * @param pszPath The path to fix. 533 */ 534 static void shfile_fix_slashes(char *pszPath) 535 { 536 #if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2 537 while ((pszPath = strchr(pszPath, '\\'))) 538 *pszPath++ = '/'; 539 #else 540 (void)pszPath; 541 #endif 542 } 543 544 /** 530 545 * Initializes the global variables in this file. 531 546 */ … … 574 589 if (getcwd(buf, sizeof(buf))) 575 590 { 576 # if K_OS == K_OS_WINDOWS || K_OS == K_OS_OS2 577 char *pszSlash = strchr(buf, '\\'); 578 while (pszSlash) 579 { 580 *pszSlash = '/'; 581 pszSlash = strchr(pszSlash + 1, '\\'); 582 } 583 # endif 591 shfile_fix_slashes(buf); 584 592 585 593 pfdtab->cwd = sh_strdup(NULL, buf); … … 1390 1398 rc = -1; 1391 1399 1392 # else1400 # ifdef DEBUG 1393 1401 if (fd != shthread_get_shell()->tracefd) 1394 { 1402 TRACE2((NULL, "shfile_write(%d,,%d) -> %d [%d]\n", fd, len, rc, errno)); 1403 # endif 1404 1405 #else 1406 if (fd != shthread_get_shell()->tracefd) 1407 { 1408 int iSavedErrno = errno; 1395 1409 struct stat s; 1396 1410 int x; … … 1398 1412 TRACE2((NULL, "shfile_write(%d) - %lu bytes (%d) - pos %lu - before; %o\n", 1399 1413 fd, (long)s.st_size, x, (long)lseek(fd, 0, SEEK_CUR), s.st_mode )); 1400 errno = 0;1414 errno = iSavedErrno; 1401 1415 } 1402 1416 1403 1417 rc = write(fd, buf, len); 1404 #endif1405 1406 #ifdef DEBUG1407 if (fd != shthread_get_shell()->tracefd)1408 {1409 struct stat s;1410 int x;1411 TRACE2((NULL, "shfile_write(%d,,%d) -> %d [%d]\n", fd, len, rc, errno));1412 x=fstat(fd, &s);1413 TRACE2((NULL, "shfile_write(%d) - %lu bytes (%d) - pos %lu - after\n", fd, (long)s.st_size, x, (long)lseek(fd, 0, SEEK_CUR) ));1414 }1415 1418 #endif 1416 1419 return rc; … … 1601 1604 char *abspath_copy = sh_strdup(psh, abspath); 1602 1605 char *free_me = abspath_copy; 1603 rc = chdir( path);1606 rc = chdir(abspath); 1604 1607 if (!rc) 1605 1608 { … … 1607 1610 shmtx_enter(&pfdtab->mtx, &tmp); 1608 1611 1612 shfile_fix_slashes(abspath_copy); 1609 1613 free_me = pfdtab->cwd; 1610 1614 pfdtab->cwd = abspath_copy;
Note:
See TracChangeset
for help on using the changeset viewer.