Mercurial > hg > xemacs-beta
comparison src/sysdep.c @ 2957:5eb04c84c7ae
[xemacs-hg @ 2005-09-27 05:32:19 by ben]
[21.4] Fix bugs in nt.c, sysdep.c
sysdep.c: Fix bit-rotted dup2 code. Also new -> new_.
nt.c: Fix possible use of uninitialized var. Also new -> new_.
author | ben |
---|---|
date | Tue, 27 Sep 2005 05:32:22 +0000 |
parents | a25c824ed558 |
children | 3e7493e76dc7 |
comparison
equal
deleted
inserted
replaced
2956:ee35a8fdcfcd | 2957:5eb04c84c7ae |
---|---|
1456 else | 1456 else |
1457 return -1; | 1457 return -1; |
1458 } | 1458 } |
1459 else | 1459 else |
1460 { | 1460 { |
1461 struct termios new; | 1461 struct termios new_; |
1462 | 1462 |
1463 /* Get the current settings, and see if they're what we asked for. */ | 1463 /* Get the current settings, and see if they're what we asked for. */ |
1464 tcgetattr (fd, &new); | 1464 tcgetattr (fd, &new_); |
1465 /* We cannot use memcmp on the whole structure here because under | 1465 /* We cannot use memcmp on the whole structure here because under |
1466 * aix386 the termios structure has some reserved field that may | 1466 * aix386 the termios structure has some reserved field that may |
1467 * not be filled in. | 1467 * not be filled in. |
1468 */ | 1468 */ |
1469 if ( new.c_iflag == settings->main.c_iflag | 1469 if ( new_.c_iflag == settings->main.c_iflag |
1470 && new.c_oflag == settings->main.c_oflag | 1470 && new_.c_oflag == settings->main.c_oflag |
1471 && new.c_cflag == settings->main.c_cflag | 1471 && new_.c_cflag == settings->main.c_cflag |
1472 && new.c_lflag == settings->main.c_lflag | 1472 && new_.c_lflag == settings->main.c_lflag |
1473 && memcmp(new.c_cc, settings->main.c_cc, NCCS) == 0) | 1473 && memcmp(new_.c_cc, settings->main.c_cc, NCCS) == 0) |
1474 break; | 1474 break; |
1475 else | 1475 else |
1476 continue; | 1476 continue; |
1477 } | 1477 } |
1478 #elif defined HAVE_TERMIO | 1478 #elif defined HAVE_TERMIO |
3291 #endif | 3291 #endif |
3292 } | 3292 } |
3293 | 3293 |
3294 #if defined (HAVE_LINK) | 3294 #if defined (HAVE_LINK) |
3295 int | 3295 int |
3296 qxe_link (const Ibyte *existing, const Ibyte *new) | 3296 qxe_link (const Ibyte *existing, const Ibyte *new_) |
3297 { | 3297 { |
3298 #ifdef WIN32_NATIVE | 3298 #ifdef WIN32_NATIVE |
3299 return mswindows_link (existing, new); | 3299 return mswindows_link (existing, new_); |
3300 #else /* not WIN32_NATIVE */ | 3300 #else /* not WIN32_NATIVE */ |
3301 Extbyte *existingout, *newout; | 3301 Extbyte *existingout, *newout; |
3302 PATHNAME_CONVERT_OUT (existing, existingout); | 3302 PATHNAME_CONVERT_OUT (existing, existingout); |
3303 PATHNAME_CONVERT_OUT (new, newout); | 3303 PATHNAME_CONVERT_OUT (new_, newout); |
3304 return link (existingout, newout); | 3304 return link (existingout, newout); |
3305 #endif /* WIN32_NATIVE */ | 3305 #endif /* WIN32_NATIVE */ |
3306 } | 3306 } |
3307 #endif /* defined (HAVE_LINK) */ | 3307 #endif /* defined (HAVE_LINK) */ |
3308 | 3308 |
3309 int | 3309 int |
3310 qxe_rename (const Ibyte *old, const Ibyte *new) | 3310 qxe_rename (const Ibyte *old, const Ibyte *new_) |
3311 { | 3311 { |
3312 #ifdef WIN32_NATIVE | 3312 #ifdef WIN32_NATIVE |
3313 return mswindows_rename (old, new); | 3313 return mswindows_rename (old, new_); |
3314 #else /* not WIN32_NATIVE */ | 3314 #else /* not WIN32_NATIVE */ |
3315 Extbyte *oldout, *newout; | 3315 Extbyte *oldout, *newout; |
3316 PATHNAME_CONVERT_OUT (old, oldout); | 3316 PATHNAME_CONVERT_OUT (old, oldout); |
3317 PATHNAME_CONVERT_OUT (new, newout); | 3317 PATHNAME_CONVERT_OUT (new_, newout); |
3318 return rename (oldout, newout); | 3318 return rename (oldout, newout); |
3319 #endif /* WIN32_NATIVE */ | 3319 #endif /* WIN32_NATIVE */ |
3320 } | 3320 } |
3321 | 3321 |
3322 #if defined (HAVE_SYMLINK) | 3322 #if defined (HAVE_SYMLINK) |
3592 fd = fcntl (oldd, F_DUPFD, newd); | 3592 fd = fcntl (oldd, F_DUPFD, newd); |
3593 if (fd != newd) | 3593 if (fd != newd) |
3594 signal_ferror_with_frob (Qfile_error, lisp_strerror (errno), | 3594 signal_ferror_with_frob (Qfile_error, lisp_strerror (errno), |
3595 "can't dup2 (%i, %i)", oldd, newd); | 3595 "can't dup2 (%i, %i)", oldd, newd); |
3596 #else | 3596 #else |
3597 fd = dup (old); | 3597 fd = dup (oldd); |
3598 if (fd == -1) | 3598 if (fd == -1) |
3599 return -1; | 3599 return -1; |
3600 if (fd == new) | 3600 if (fd == newd) |
3601 return new; | 3601 return newd; |
3602 ret = dup2 (old, new); | 3602 ret = dup2 (oldd, newd); |
3603 retry_close (fd); | 3603 retry_close (fd); |
3604 return ret; | 3604 return ret; |
3605 #endif /* F_DUPFD */ | 3605 #endif /* F_DUPFD */ |
3606 } | 3606 } |
3607 | 3607 |