Mercurial > hg > xemacs-beta
comparison src/sysdep.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
29 | 29 |
30 #define DONT_ENCAPSULATE | 30 #define DONT_ENCAPSULATE |
31 | 31 |
32 #include <config.h> | 32 #include <config.h> |
33 | 33 |
34 #ifdef WINDOWSNT | 34 #ifdef WIN32_NATIVE |
35 #include <direct.h> | 35 #ifdef MINGW |
36 #ifdef __MINGW32__ | |
37 #include <mingw32/process.h> | 36 #include <mingw32/process.h> |
38 #else | 37 #else |
39 /* <process.h> should not conflict with "process.h", as per ANSI definition. | 38 /* <process.h> should not conflict with "process.h", as per ANSI definition. |
40 This is not true with visual c though. The trick below works with | 39 This is not true with visual c though. The trick below works with |
41 VC4.2b, 5.0 and 6.0. It assumes that VC is installed in a kind of | 40 VC4.2b, 5.0 and 6.0. It assumes that VC is installed in a kind of |
43 | 42 |
44 Unfortunately, this must go before lisp.h, since process.h defines abort() | 43 Unfortunately, this must go before lisp.h, since process.h defines abort() |
45 which will conflict with the macro defined in lisp.h | 44 which will conflict with the macro defined in lisp.h |
46 */ | 45 */ |
47 #include <../include/process.h> | 46 #include <../include/process.h> |
48 #endif /* __MINGW32__ */ | 47 #endif /* MINGW */ |
49 #endif /* WINDOWSNT */ | 48 #endif /* WIN32_NATIVE */ |
50 | 49 |
51 #include "lisp.h" | 50 #include "lisp.h" |
52 | |
53 #include <stdlib.h> | |
54 | 51 |
55 /* ------------------------------- */ | 52 /* ------------------------------- */ |
56 /* basic includes */ | 53 /* basic includes */ |
57 /* ------------------------------- */ | 54 /* ------------------------------- */ |
58 | 55 |
79 #endif | 76 #endif |
80 #include "sysfile.h" | 77 #include "sysfile.h" |
81 #include "syswait.h" | 78 #include "syswait.h" |
82 #include "sysdir.h" | 79 #include "sysdir.h" |
83 #include "systime.h" | 80 #include "systime.h" |
84 #if defined(WINDOWSNT) || defined(__CYGWIN32__) | 81 #if defined(WIN32_NATIVE) || defined(CYGWIN) |
85 #include "syssignal.h" | 82 #include "syssignal.h" |
86 #endif | 83 #endif |
87 #ifndef WINDOWSNT | 84 |
85 #include "sysproc.h" | |
86 | |
87 #ifndef WIN32_NATIVE | |
88 #include <sys/times.h> | 88 #include <sys/times.h> |
89 #endif | 89 #endif |
90 | 90 |
91 #ifdef WINDOWSNT | 91 #ifdef WIN32_NATIVE |
92 #include <sys/utime.h> | 92 #include <sys/utime.h> |
93 #include "ntheap.h" | 93 #include "ntheap.h" |
94 #include "nt.h" | |
94 #endif | 95 #endif |
95 | 96 |
96 /* ------------------------------- */ | 97 /* ------------------------------- */ |
97 /* TTY definitions */ | 98 /* TTY definitions */ |
98 /* ------------------------------- */ | 99 /* ------------------------------- */ |
107 #include <sys/stream.h> | 108 #include <sys/stream.h> |
108 #include <sys/ptem.h> | 109 #include <sys/ptem.h> |
109 #endif | 110 #endif |
110 #endif /* TIOCGWINSZ or ISC4_0 */ | 111 #endif /* TIOCGWINSZ or ISC4_0 */ |
111 #endif /* USG */ | 112 #endif /* USG */ |
112 | |
113 #ifdef HAVE_SYS_STROPTS_H | |
114 #include <sys/stropts.h> | |
115 #endif /* HAVE_SYS_STROPTS_H */ | |
116 | 113 |
117 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ | 114 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ |
118 #ifndef LPASS8 | 115 #ifndef LPASS8 |
119 #define LPASS8 0 | 116 #define LPASS8 0 |
120 #endif | 117 #endif |
231 #endif /* BSD */ | 228 #endif /* BSD */ |
232 | 229 |
233 #endif /* NO_SUBPROCESSES */ | 230 #endif /* NO_SUBPROCESSES */ |
234 | 231 |
235 | 232 |
236 #ifdef WINDOWSNT | 233 #ifdef WIN32_NATIVE |
237 void wait_for_termination (HANDLE pHandle) | 234 void wait_for_termination (HANDLE pHandle) |
238 #else | 235 #else |
239 void wait_for_termination (int pid) | 236 void wait_for_termination (int pid) |
240 #endif | 237 #endif |
241 { | 238 { |
345 - EINVAL (incorrect arguments), | 342 - EINVAL (incorrect arguments), |
346 which are both program bugs. | 343 which are both program bugs. |
347 | 344 |
348 Since implementations may add their own error indicators on top, | 345 Since implementations may add their own error indicators on top, |
349 we ignore it by default. */ | 346 we ignore it by default. */ |
350 #elif defined (WINDOWSNT) | 347 #elif defined (WIN32_NATIVE) |
351 int ret = 0, status = 0; | 348 int ret = 0, status = 0; |
352 if (pHandle == NULL) | 349 if (pHandle == NULL) |
353 { | 350 { |
354 warn_when_safe (Qprocess, Qwarning, "Cannot wait for unknown process to terminate"); | 351 warn_when_safe (Qprocess, Qwarning, "Cannot wait for unknown process to terminate"); |
355 return; | 352 return; |
419 sigpause()/sigsuspend(), then your OS doesn't implement | 416 sigpause()/sigsuspend(), then your OS doesn't implement |
420 this properly (this applies under hpux9, for example). | 417 this properly (this applies under hpux9, for example). |
421 Try defining BROKEN_WAIT_FOR_SIGNAL. */ | 418 Try defining BROKEN_WAIT_FOR_SIGNAL. */ |
422 EMACS_WAIT_FOR_SIGNAL (SIGCHLD); | 419 EMACS_WAIT_FOR_SIGNAL (SIGCHLD); |
423 } | 420 } |
424 #else /* not HAVE_WAITPID and not WINDOWSNT and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */ | 421 #else /* not HAVE_WAITPID and not WIN32_NATIVE and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */ |
425 /* This approach is kind of cheesy but is guaranteed(?!) to work | 422 /* This approach is kind of cheesy but is guaranteed(?!) to work |
426 for all systems. */ | 423 for all systems. */ |
427 while (1) | 424 while (1) |
428 { | 425 { |
429 QUIT; | 426 QUIT; |
457 and nonzero means something different. */ | 454 and nonzero means something different. */ |
458 ioctl (channel, TIOCFLUSH, &zero); | 455 ioctl (channel, TIOCFLUSH, &zero); |
459 #endif | 456 #endif |
460 } | 457 } |
461 | 458 |
462 #ifndef WINDOWSNT | 459 #ifndef WIN32_NATIVE |
463 /* Set up the terminal at the other end of a pseudo-terminal that | 460 /* Set up the terminal at the other end of a pseudo-terminal that |
464 we will be controlling an inferior through. | 461 we will be controlling an inferior through. |
465 It should not echo or do line-editing, since that is done | 462 It should not echo or do line-editing, since that is done |
466 in Emacs. No padding needed for insertion into an Emacs buffer. */ | 463 in Emacs. No padding needed for insertion into an Emacs buffer. */ |
467 | 464 |
568 int zero = 0; | 565 int zero = 0; |
569 ioctl (out, FIOASYNC, &zero); | 566 ioctl (out, FIOASYNC, &zero); |
570 } | 567 } |
571 #endif /* RTU */ | 568 #endif /* RTU */ |
572 } | 569 } |
573 #endif /* WINDOWSNT */ | 570 #endif /* WIN32_NATIVE */ |
574 | 571 |
575 #endif /* not NO_SUBPROCESSES */ | 572 #endif /* not NO_SUBPROCESSES */ |
576 | 573 |
577 | 574 |
578 #if !defined (SIGTSTP) && !defined (USG_JOBCTRL) | 575 #if !defined (SIGTSTP) && !defined (USG_JOBCTRL) |
609 signal (saved_handlers->code, saved_handlers->handler); | 606 signal (saved_handlers->code, saved_handlers->handler); |
610 saved_handlers++; | 607 saved_handlers++; |
611 } | 608 } |
612 } | 609 } |
613 | 610 |
614 #ifdef WINDOWSNT | 611 #ifdef WIN32_NATIVE |
612 | |
615 pid_t | 613 pid_t |
616 sys_getpid (void) | 614 sys_getpid (void) |
617 { | 615 { |
618 return abs (getpid ()); | 616 return abs (getpid ()); |
619 } | 617 } |
620 #endif /* WINDOWSNT */ | 618 |
619 #endif /* WIN32_NATIVE */ | |
621 | 620 |
622 /* Fork a subshell. */ | 621 /* Fork a subshell. */ |
623 static void | 622 static void |
624 sys_subshell (void) | 623 sys_subshell (void) |
625 { | 624 { |
626 #ifdef WINDOWSNT | 625 #ifndef WIN32_NATIVE |
627 HANDLE pid; | |
628 #else | |
629 int pid; | 626 int pid; |
630 #endif | 627 #endif |
631 struct save_signal saved_handlers[5]; | 628 struct save_signal saved_handlers[5]; |
632 Lisp_Object dir; | 629 Lisp_Object dir; |
633 unsigned char *str = 0; | 630 unsigned char *str = 0; |
658 dir = expand_and_dir_to_file (dir, Qnil); | 655 dir = expand_and_dir_to_file (dir, Qnil); |
659 UNGCPRO; | 656 UNGCPRO; |
660 str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2); | 657 str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2); |
661 len = XSTRING_LENGTH (dir); | 658 len = XSTRING_LENGTH (dir); |
662 memcpy (str, XSTRING_DATA (dir), len); | 659 memcpy (str, XSTRING_DATA (dir), len); |
663 /* #### Unix specific */ | 660 if (!IS_ANY_SEP (str[len - 1])) |
664 if (str[len - 1] != '/') str[len++] = '/'; | 661 str[len++] = DIRECTORY_SEP; |
665 str[len] = 0; | 662 str[len] = 0; |
666 xyzzy: | 663 xyzzy: |
667 | 664 |
668 #ifdef WINDOWSNT | 665 #ifndef WIN32_NATIVE |
669 pid = NULL; | |
670 #else /* not WINDOWSNT */ | |
671 | |
672 pid = fork (); | 666 pid = fork (); |
673 | 667 |
674 if (pid == -1) | 668 if (pid == -1) |
675 error ("Can't spawn subshell"); | 669 error ("Can't spawn subshell"); |
676 if (pid == 0) | 670 if (pid == 0) |
677 | 671 #endif /* not WIN32_NATIVE */ |
678 #endif /* not WINDOWSNT */ | |
679 { | 672 { |
680 char *sh = 0; | 673 char *sh = 0; |
681 | 674 |
682 if (sh == 0) | 675 if (sh == 0) |
683 sh = (char *) egetenv ("SHELL"); | 676 sh = (char *) egetenv ("SHELL"); |
686 | 679 |
687 /* Use our buffer's default directory for the subshell. */ | 680 /* Use our buffer's default directory for the subshell. */ |
688 if (str) | 681 if (str) |
689 sys_chdir (str); | 682 sys_chdir (str); |
690 | 683 |
691 #if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT) | 684 #ifdef WIN32_NATIVE |
685 | |
686 /* Waits for process completion */ | |
687 if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0) | |
688 error ("Can't spawn subshell"); | |
689 else | |
690 return; /* we're done, no need to wait for termination */ | |
691 } | |
692 | |
693 #else | |
694 | |
695 #if !defined (NO_SUBPROCESSES) | |
692 close_process_descs (); /* Close Emacs's pipes/ptys */ | 696 close_process_descs (); /* Close Emacs's pipes/ptys */ |
693 #endif | 697 #endif |
694 | 698 |
695 #ifdef SET_EMACS_PRIORITY | 699 #ifdef SET_EMACS_PRIORITY |
696 if (emacs_priority != 0) | 700 if (emacs_priority != 0) |
697 nice (-emacs_priority); /* Give the new shell the default priority */ | 701 nice (-emacs_priority); /* Give the new shell the default priority */ |
698 #endif | 702 #endif |
699 | 703 |
700 #ifdef WINDOWSNT | |
701 /* Waits for process completion */ | |
702 pid = _spawnlp (_P_WAIT, sh, sh, NULL); | |
703 if (pid == NULL) | |
704 write (1, "Can't execute subshell", 22); | |
705 | |
706 #else /* not WINDOWSNT */ | |
707 execlp (sh, sh, 0); | 704 execlp (sh, sh, 0); |
708 write (1, "Can't execute subshell", 22); | 705 write (1, "Can't execute subshell", 22); |
709 _exit (1); | 706 _exit (1); |
710 #endif /* not WINDOWSNT */ | |
711 } | 707 } |
712 | 708 |
713 save_signal_handlers (saved_handlers); | 709 save_signal_handlers (saved_handlers); |
714 synch_process_alive = 1; | 710 synch_process_alive = 1; |
715 wait_for_termination (pid); | 711 wait_for_termination (pid); |
716 restore_signal_handlers (saved_handlers); | 712 restore_signal_handlers (saved_handlers); |
713 | |
714 #endif /* not WIN32_NATIVE */ | |
715 | |
717 } | 716 } |
718 | 717 |
719 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */ | 718 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */ |
720 | 719 |
721 | 720 |
758 #endif | 757 #endif |
759 } | 758 } |
760 | 759 |
761 | 760 |
762 /* Given FD, obtain pty buffer size. When no luck, a good guess is made, | 761 /* Given FD, obtain pty buffer size. When no luck, a good guess is made, |
763 so that the function works even fd is not a pty. */ | 762 so that the function works even when fd is not a pty. */ |
764 | 763 |
765 int | 764 int |
766 get_pty_max_bytes (int fd) | 765 get_pty_max_bytes (int fd) |
767 { | 766 { |
768 int pty_max_bytes; | 767 /* DEC OSF 4.0 fpathconf returns 255, but xemacs hangs on long shell |
769 | 768 input lines if we return 253. 252 is OK!. So let's leave a bit |
769 of slack for the newline that xemacs will insert, and for those | |
770 inevitable vendor off-by-one-or-two-or-three bugs. */ | |
771 #define MAX_CANON_SLACK 10 | |
772 #define SAFE_MAX_CANON (127 - MAX_CANON_SLACK) | |
770 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) | 773 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) |
771 pty_max_bytes = fpathconf (fd, _PC_MAX_CANON); | 774 { |
772 if (pty_max_bytes < 0) | 775 int max_canon = fpathconf (fd, _PC_MAX_CANON); |
773 #endif | 776 #ifdef __hpux__ |
774 pty_max_bytes = 250; | 777 /* HP-UX 10.20 fpathconf returns 768, but this results in |
775 | 778 truncated input lines, while 255 works. */ |
776 /* Deduct one, to leave space for the eof. */ | 779 if (max_canon > 255) max_canon = 255; |
777 pty_max_bytes--; | 780 #endif |
778 | 781 return (max_canon < 0 ? SAFE_MAX_CANON : |
779 return pty_max_bytes; | 782 max_canon > SAFE_MAX_CANON ? max_canon - MAX_CANON_SLACK : |
783 max_canon); | |
784 } | |
785 #elif defined (_POSIX_MAX_CANON) | |
786 return (_POSIX_MAX_CANON > SAFE_MAX_CANON ? | |
787 _POSIX_MAX_CANON - MAX_CANON_SLACK : | |
788 _POSIX_MAX_CANON); | |
789 #else | |
790 return SAFE_MAX_CANON; | |
791 #endif | |
780 } | 792 } |
781 | 793 |
782 /* Figure out the eof character for the FD. */ | 794 /* Figure out the eof character for the FD. */ |
783 | 795 |
784 Bufbyte | 796 Bufbyte |
785 get_eof_char (int fd) | 797 get_eof_char (int fd) |
786 { | 798 { |
787 CONST Bufbyte ctrl_d = (Bufbyte) '\004'; | 799 const Bufbyte ctrl_d = (Bufbyte) '\004'; |
788 | 800 |
789 if (!isatty (fd)) | 801 if (!isatty (fd)) |
790 return ctrl_d; | 802 return ctrl_d; |
791 #ifdef HAVE_TERMIOS | 803 #ifdef HAVE_TERMIOS |
792 { | 804 { |
793 struct termios t; | 805 struct termios t; |
794 tcgetattr (fd, &t); | 806 tcgetattr (fd, &t); |
795 #if 0 | 807 #if 0 |
796 /* What is the following line designed to do??? -mrb */ | 808 /* What is the following line designed to do??? -mrb */ |
797 if (strlen ((CONST char *) t.c_cc) < (unsigned int) (VEOF + 1)) | 809 if (strlen ((const char *) t.c_cc) < (unsigned int) (VEOF + 1)) |
798 return ctrl_d; | 810 return ctrl_d; |
799 else | 811 else |
800 return (Bufbyte) t.c_cc[VEOF]; | 812 return (Bufbyte) t.c_cc[VEOF]; |
801 #endif | 813 #endif |
802 return t.c_cc[VEOF] == _POSIX_VDISABLE ? ctrl_d : (Bufbyte) t.c_cc[VEOF]; | 814 return t.c_cc[VEOF] == _POSIX_VDISABLE ? ctrl_d : (Bufbyte) t.c_cc[VEOF]; |
815 characters. */ | 827 characters. */ |
816 #ifdef TCGETA | 828 #ifdef TCGETA |
817 { | 829 { |
818 struct termio t; | 830 struct termio t; |
819 ioctl (fd, TCGETA, &t); | 831 ioctl (fd, TCGETA, &t); |
820 if (strlen ((CONST char *) t.c_cc) < (unsigned int) (VINTR + 1)) | 832 if (strlen ((const char *) t.c_cc) < (unsigned int) (VINTR + 1)) |
821 return ctrl_d; | 833 return ctrl_d; |
822 else | 834 else |
823 return (Bufbyte) t.c_cc[VINTR]; | 835 return (Bufbyte) t.c_cc[VINTR]; |
824 } | 836 } |
825 #else /* ! defined (TCGETA) */ | 837 #else /* ! defined (TCGETA) */ |
870 /* Set up the proper status flags for use of a pty. */ | 882 /* Set up the proper status flags for use of a pty. */ |
871 | 883 |
872 void | 884 void |
873 setup_pty (int fd) | 885 setup_pty (int fd) |
874 { | 886 { |
875 /* I'm told that TOICREMOTE does not mean control chars | 887 /* I'm told that TIOCREMOTE does not mean control chars |
876 "can't be sent" but rather that they don't have | 888 "can't be sent" but rather that they don't have |
877 input-editing or signaling effects. | 889 input-editing or signaling effects. |
878 That should be good, because we have other ways | 890 That should be good, because we have other ways |
879 to do those things in Emacs. | 891 to do those things in Emacs. |
880 However, telnet mode seems not to work on 4.2. | 892 However, telnet mode seems not to work on 4.2. |
949 | 961 |
950 #ifdef HAVE_TTY | 962 #ifdef HAVE_TTY |
951 assert (DEVICE_TTY_P (d)); | 963 assert (DEVICE_TTY_P (d)); |
952 { | 964 { |
953 int input_fd = CONSOLE_TTY_DATA (con)->infd; | 965 int input_fd = CONSOLE_TTY_DATA (con)->infd; |
954 #if defined (WINDOWSNT) | 966 #if defined (WIN32_NATIVE) |
955 DEVICE_TTY_DATA (d)->ospeed = 15; | 967 DEVICE_TTY_DATA (d)->ospeed = 15; |
956 #elif defined (HAVE_TERMIOS) | 968 #elif defined (HAVE_TERMIOS) |
957 struct termios sg; | 969 struct termios sg; |
958 | 970 |
959 sg.c_cflag = B9600; | 971 sg.c_cflag = B9600; |
1214 SIGTTmumble when we try to change the tty's pgroup, and a CONT if | 1226 SIGTTmumble when we try to change the tty's pgroup, and a CONT if |
1215 it goes foreground in the future, which is what should happen. */ | 1227 it goes foreground in the future, which is what should happen. */ |
1216 | 1228 |
1217 #ifdef SIGIO_REQUIRES_SEPARATE_PROCESS_GROUP | 1229 #ifdef SIGIO_REQUIRES_SEPARATE_PROCESS_GROUP |
1218 | 1230 |
1219 static int inherited_pgroup; | 1231 static pid_t inherited_pgroup; |
1220 static int inherited_tty_pgroup; | 1232 static pid_t inherited_tty_pgroup; |
1221 | 1233 |
1222 #endif | 1234 #endif |
1223 | 1235 |
1224 void | 1236 void |
1225 munge_tty_process_group (void) | 1237 munge_tty_process_group (void) |
1233 | 1245 |
1234 if (CONSOLEP (Vcontrolling_terminal) && | 1246 if (CONSOLEP (Vcontrolling_terminal) && |
1235 CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal))) | 1247 CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal))) |
1236 { | 1248 { |
1237 int fd = open ("/dev/tty", O_RDWR, 0); | 1249 int fd = open ("/dev/tty", O_RDWR, 0); |
1238 int me = getpid (); | 1250 pid_t me = getpid (); |
1239 EMACS_BLOCK_SIGNAL (SIGTTOU); | 1251 EMACS_BLOCK_SIGNAL (SIGTTOU); |
1240 EMACS_SET_TTY_PROCESS_GROUP (fd, &me); | 1252 EMACS_SET_TTY_PROCESS_GROUP (fd, &me); |
1241 EMACS_UNBLOCK_SIGNAL (SIGTTOU); | 1253 EMACS_UNBLOCK_SIGNAL (SIGTTOU); |
1242 close (fd); | 1254 close (fd); |
1243 } | 1255 } |
1375 /* ------------------------------------------------------ */ | 1387 /* ------------------------------------------------------ */ |
1376 | 1388 |
1377 /* It's wrong to encase these into #ifdef HAVE_TTY because we need | 1389 /* It's wrong to encase these into #ifdef HAVE_TTY because we need |
1378 them for child TTY processes. */ | 1390 them for child TTY processes. */ |
1379 /* However, this does break NT support while we don't do child TTY processes */ | 1391 /* However, this does break NT support while we don't do child TTY processes */ |
1380 #ifndef WINDOWSNT | 1392 #ifndef WIN32_NATIVE |
1381 | 1393 |
1382 /* Set *TC to the parameters associated with the terminal FD. | 1394 /* Set *TC to the parameters associated with the terminal FD. |
1383 Return zero if all's well, or -1 if we ran into an error we | 1395 Return zero if all's well, or -1 if we ran into an error we |
1384 couldn't deal with. */ | 1396 couldn't deal with. */ |
1385 int | 1397 int |
1394 #elif defined HAVE_TERMIO | 1406 #elif defined HAVE_TERMIO |
1395 /* The SYSV-style interface? */ | 1407 /* The SYSV-style interface? */ |
1396 if (ioctl (fd, TCGETA, &settings->main) < 0) | 1408 if (ioctl (fd, TCGETA, &settings->main) < 0) |
1397 return -1; | 1409 return -1; |
1398 | 1410 |
1399 #elif !defined (WINDOWSNT) | 1411 #elif !defined (WIN32_NATIVE) |
1400 /* I give up - I hope you have the BSD ioctls. */ | 1412 /* I give up - I hope you have the BSD ioctls. */ |
1401 if (ioctl (fd, TIOCGETP, &settings->main) < 0) | 1413 if (ioctl (fd, TIOCGETP, &settings->main) < 0) |
1402 return -1; | 1414 return -1; |
1403 #endif /* HAVE_TCATTR */ | 1415 #endif /* HAVE_TCATTR */ |
1404 | 1416 |
1468 #elif defined HAVE_TERMIO | 1480 #elif defined HAVE_TERMIO |
1469 /* The SYSV-style interface? */ | 1481 /* The SYSV-style interface? */ |
1470 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) | 1482 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) |
1471 return -1; | 1483 return -1; |
1472 | 1484 |
1473 #elif !defined (WINDOWSNT) | 1485 #elif !defined (WIN32_NATIVE) |
1474 /* I give up - I hope you have the BSD ioctls. */ | 1486 /* I give up - I hope you have the BSD ioctls. */ |
1475 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) | 1487 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) |
1476 return -1; | 1488 return -1; |
1477 #endif /* HAVE_TCATTR */ | 1489 #endif /* HAVE_TCATTR */ |
1478 | 1490 |
1491 | 1503 |
1492 /* We have survived the tempest. */ | 1504 /* We have survived the tempest. */ |
1493 return 0; | 1505 return 0; |
1494 } | 1506 } |
1495 | 1507 |
1496 #endif /* WINDOWSNT */ | 1508 #endif /* WIN32_NATIVE */ |
1497 | 1509 |
1498 /* ------------------------------------------------------ */ | 1510 /* ------------------------------------------------------ */ |
1499 /* Initializing a device */ | 1511 /* Initializing a device */ |
1500 /* ------------------------------------------------------ */ | 1512 /* ------------------------------------------------------ */ |
1501 | 1513 |
1651 or via TELNET or the like, but does no harm elsewhere. */ | 1663 or via TELNET or the like, but does no harm elsewhere. */ |
1652 tty.main.c_iflag &= ~IGNBRK; | 1664 tty.main.c_iflag &= ~IGNBRK; |
1653 tty.main.c_iflag &= ~BRKINT; | 1665 tty.main.c_iflag &= ~BRKINT; |
1654 #endif /* AIX */ | 1666 #endif /* AIX */ |
1655 #else /* if not HAVE_TERMIO */ | 1667 #else /* if not HAVE_TERMIO */ |
1656 #if !defined (WINDOWSNT) | 1668 #if !defined (WIN32_NATIVE) |
1657 con->tty_erase_char = make_char (tty.main.sg_erase); | 1669 con->tty_erase_char = make_char (tty.main.sg_erase); |
1658 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); | 1670 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
1659 if (TTY_FLAGS (con).meta_key) | 1671 if (TTY_FLAGS (con).meta_key) |
1660 tty.main.sg_flags |= ANYP; | 1672 tty.main.sg_flags |= ANYP; |
1661 /* #### should we be using RAW mode here? */ | 1673 /* #### should we be using RAW mode here? */ |
1662 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK; | 1674 tty.main.sg_flags |= /* interrupt_input ? RAW : */ CBREAK; |
1663 #endif /* not WINDOWSNT */ | 1675 #endif /* not WIN32_NATIVE */ |
1664 #endif /* not HAVE_TERMIO */ | 1676 #endif /* not HAVE_TERMIO */ |
1665 | 1677 |
1666 /* If going to use CBREAK mode, we must request C-g to interrupt | 1678 /* If going to use CBREAK mode, we must request C-g to interrupt |
1667 and turn off start and stop chars, etc. If not going to use | 1679 and turn off start and stop chars, etc. If not going to use |
1668 CBREAK mode, do this anyway so as to turn off local flow | 1680 CBREAK mode, do this anyway so as to turn off local flow |
2141 * | 2153 * |
2142 */ | 2154 */ |
2143 | 2155 |
2144 #if !defined(HAVE_TEXT_START) && !defined(PDUMP) | 2156 #if !defined(HAVE_TEXT_START) && !defined(PDUMP) |
2145 | 2157 |
2146 #ifdef __cplusplus | 2158 EXTERN_C int _start (void); |
2147 extern "C" int _start (void); | |
2148 #else | |
2149 extern int _start (void); | |
2150 #endif | |
2151 | 2159 |
2152 char * | 2160 char * |
2153 start_of_text (void) | 2161 start_of_text (void) |
2154 { | 2162 { |
2155 #ifdef TEXT_START | 2163 #ifdef TEXT_START |
2156 return ((char *) TEXT_START); | 2164 return (char *) TEXT_START; |
2157 #else | 2165 #else |
2158 #ifdef GOULD | 2166 return (char *) _start; |
2159 extern csrt (); | |
2160 return ((char *) csrt); | |
2161 #else /* not GOULD */ | |
2162 return ((char *) _start); | |
2163 #endif /* GOULD */ | |
2164 #endif /* TEXT_START */ | 2167 #endif /* TEXT_START */ |
2165 } | 2168 } |
2166 #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */ | 2169 #endif /* !defined(HAVE_TEXT_START) && !defined(PDUMP) */ |
2167 | 2170 |
2168 /* | 2171 /* |
2169 * Return the address of the start of the data segment prior to | 2172 * Return the address of the start of the data segment prior to |
2170 * doing an unexec. After unexec the return value is undefined. | 2173 * doing an unexec. After unexec the return value is undefined. |
2171 * See crt0.c for further information and definition of data_start. | 2174 * See ecrt0.c for further information and definition of data_start. |
2172 * | 2175 * |
2173 * Apparently, on BSD systems this is etext at startup. On | 2176 * Apparently, on BSD systems this is etext at startup. On |
2174 * USG systems (swapping) this is highly mmu dependent and | 2177 * USG systems (swapping) this is highly mmu dependent and |
2175 * is also dependent on whether or not the program is running | 2178 * is also dependent on whether or not the program is running |
2176 * with shared text. Generally there is a (possibly large) | 2179 * with shared text. Generally there is a (possibly large) |
2189 * at the normal shared text boundary and the startofdata variable | 2192 * at the normal shared text boundary and the startofdata variable |
2190 * will be patched by unexec to the correct value. | 2193 * will be patched by unexec to the correct value. |
2191 * | 2194 * |
2192 */ | 2195 */ |
2193 | 2196 |
2194 #ifdef ORDINARY_LINK | 2197 #if defined(ORDINARY_LINK) && !defined(MINGW) |
2195 extern char **environ; | 2198 extern char **environ; |
2196 #endif | 2199 #endif |
2197 | 2200 |
2198 void * | 2201 void * |
2199 start_of_data (void) | 2202 start_of_data (void) |
2206 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, | 2209 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, |
2207 * data_start isn't defined. We take the address of environ, which | 2210 * data_start isn't defined. We take the address of environ, which |
2208 * is known to live at or near the start of the system crt0.c, and | 2211 * is known to live at or near the start of the system crt0.c, and |
2209 * we don't sweat the handful of bytes that might lose. | 2212 * we don't sweat the handful of bytes that might lose. |
2210 */ | 2213 */ |
2211 #ifdef HEAP_IN_DATA | 2214 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
2212 extern char* static_heap_base; | 2215 extern char* static_heap_base; |
2213 if (!initialized) | 2216 if (!initialized) |
2214 return static_heap_base; | 2217 return static_heap_base; |
2215 #endif | 2218 #endif |
2216 return((char *) &environ); | 2219 return((char *) &environ); |
2267 /* init_system_name sets up the string for the Lisp function | 2270 /* init_system_name sets up the string for the Lisp function |
2268 system-name to return. */ | 2271 system-name to return. */ |
2269 | 2272 |
2270 extern Lisp_Object Vsystem_name; | 2273 extern Lisp_Object Vsystem_name; |
2271 | 2274 |
2272 #ifdef HAVE_SOCKETS | |
2273 # include <sys/socket.h> | |
2274 # include <netdb.h> | |
2275 #endif /* HAVE_SOCKETS */ | |
2276 | |
2277 void | 2275 void |
2278 init_system_name (void) | 2276 init_system_name (void) |
2279 { | 2277 { |
2280 #if defined (WINDOWSNT) | 2278 #if defined (WIN32_NATIVE) |
2281 char hostname [MAX_COMPUTERNAME_LENGTH + 1]; | 2279 char hostname [MAX_COMPUTERNAME_LENGTH + 1]; |
2282 size_t size = sizeof (hostname); | 2280 size_t size = sizeof (hostname); |
2283 GetComputerName (hostname, &size); | 2281 GetComputerName (hostname, &size); |
2284 Vsystem_name = build_string (hostname); | 2282 Vsystem_name = build_string (hostname); |
2285 #elif !defined (HAVE_GETHOSTNAME) | 2283 #elif !defined (HAVE_GETHOSTNAME) |
2333 Fsleep_for (make_int (1)); | 2331 Fsleep_for (make_int (1)); |
2334 } | 2332 } |
2335 # endif | 2333 # endif |
2336 if (hp) | 2334 if (hp) |
2337 { | 2335 { |
2338 CONST char *fqdn = (CONST char *) hp->h_name; | 2336 const char *fqdn = (const char *) hp->h_name; |
2339 | 2337 |
2340 if (!strchr (fqdn, '.')) | 2338 if (!strchr (fqdn, '.')) |
2341 { | 2339 { |
2342 /* We still don't have a fully qualified domain name. | 2340 /* We still don't have a fully qualified domain name. |
2343 Try to find one in the list of alternate names */ | 2341 Try to find one in the list of alternate names */ |
2493 | 2491 |
2494 #if !defined(NeXT) && !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX) && !defined(__NetBSD__) | 2492 #if !defined(NeXT) && !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX) && !defined(__NetBSD__) |
2495 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */ | 2493 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */ |
2496 /* Irix added here by gparker@sni-usa.com for XEmacs. */ | 2494 /* Irix added here by gparker@sni-usa.com for XEmacs. */ |
2497 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */ | 2495 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */ |
2498 extern CONST char *sys_errlist[]; | 2496 extern const char *sys_errlist[]; |
2499 extern int sys_nerr; | 2497 extern int sys_nerr; |
2500 #endif | 2498 #endif |
2501 | 2499 |
2502 #ifdef __NetBSD__ | 2500 #ifdef __NetBSD__ |
2503 extern char *sys_errlist[]; | 2501 extern char *sys_errlist[]; |
2504 extern int sys_nerr; | 2502 extern int sys_nerr; |
2505 #endif | 2503 #endif |
2506 | 2504 |
2507 | 2505 |
2508 CONST char * | 2506 const char * |
2509 strerror (int errnum) | 2507 strerror (int errnum) |
2510 { | 2508 { |
2511 if (errnum >= 0 && errnum < sys_nerr) | 2509 if (errnum >= 0 && errnum < sys_nerr) |
2512 return sys_errlist[errnum]; | 2510 return sys_errlist[errnum]; |
2513 return ((CONST char *) GETTEXT ("Unknown error")); | 2511 return ((const char *) GETTEXT ("Unknown error")); |
2514 } | 2512 } |
2515 | 2513 |
2516 #endif /* ! HAVE_STRERROR */ | 2514 #endif /* ! HAVE_STRERROR */ |
2517 | 2515 |
2518 #ifdef WINDOWSNT | 2516 #ifdef WIN32_NATIVE |
2519 | 2517 |
2520 struct errentry { | 2518 struct errentry { |
2521 unsigned long oscode; /* Win32 error */ | 2519 unsigned long oscode; /* Win32 error */ |
2522 int errnocode; /* unix errno */ | 2520 int errnocode; /* unix errno */ |
2523 }; | 2521 }; |
2610 mswindows_set_last_errno (void) | 2608 mswindows_set_last_errno (void) |
2611 { | 2609 { |
2612 mswindows_set_errno (GetLastError ()); | 2610 mswindows_set_errno (GetLastError ()); |
2613 } | 2611 } |
2614 | 2612 |
2615 #endif /* WINDOWSNT */ | 2613 #endif /* WIN32_NATIVE */ |
2616 | 2614 |
2617 | 2615 |
2618 /************************************************************************/ | 2616 /************************************************************************/ |
2619 /* Encapsulations of system calls */ | 2617 /* Encapsulations of system calls */ |
2620 /************************************************************************/ | 2618 /************************************************************************/ |
2642 interruptible-system-call business. To find it, look on | 2640 interruptible-system-call business. To find it, look on |
2643 Jamie's home page (http://www.jwz.org/worse-is-better.html). */ | 2641 Jamie's home page (http://www.jwz.org/worse-is-better.html). */ |
2644 | 2642 |
2645 #ifdef ENCAPSULATE_OPEN | 2643 #ifdef ENCAPSULATE_OPEN |
2646 int | 2644 int |
2647 sys_open (CONST char *path, int oflag, ...) | 2645 sys_open (const char *path, int oflag, ...) |
2648 { | 2646 { |
2649 int mode; | 2647 int mode; |
2650 va_list ap; | 2648 va_list ap; |
2651 | 2649 |
2652 va_start (ap, oflag); | 2650 va_start (ap, oflag); |
2653 mode = va_arg (ap, int); | 2651 mode = va_arg (ap, int); |
2654 va_end (ap); | 2652 va_end (ap); |
2655 | 2653 |
2656 #ifdef WINDOWSNT | 2654 PATHNAME_CONVERT_OUT (path); |
2655 | |
2656 #ifdef WIN32_NATIVE | |
2657 /* Make all handles non-inheritable */ | 2657 /* Make all handles non-inheritable */ |
2658 oflag |= _O_NOINHERIT; | 2658 oflag |= _O_NOINHERIT; |
2659 #endif | 2659 #endif |
2660 | 2660 |
2661 #ifdef INTERRUPTIBLE_OPEN | 2661 #ifdef INTERRUPTIBLE_OPEN |
2679 | 2679 |
2680 This function will not function as expected on systems where open() | 2680 This function will not function as expected on systems where open() |
2681 is not interrupted by C-g. However, the worst that can happen is | 2681 is not interrupted by C-g. However, the worst that can happen is |
2682 the fallback to simple open(). */ | 2682 the fallback to simple open(). */ |
2683 int | 2683 int |
2684 interruptible_open (CONST char *path, int oflag, int mode) | 2684 interruptible_open (const char *path, int oflag, int mode) |
2685 { | 2685 { |
2686 /* This function can GC */ | 2686 /* This function can GC */ |
2687 size_t len = strlen (path); | 2687 size_t len = strlen (path); |
2688 char *nonreloc = (char *) alloca (len + 1); | 2688 char *nonreloc = (char *) alloca (len + 1); |
2689 | 2689 |
2691 which could be relocated by GC when checking for QUIT. */ | 2691 which could be relocated by GC when checking for QUIT. */ |
2692 memcpy (nonreloc, path, len + 1); | 2692 memcpy (nonreloc, path, len + 1); |
2693 | 2693 |
2694 PATHNAME_CONVERT_OUT (nonreloc); | 2694 PATHNAME_CONVERT_OUT (nonreloc); |
2695 | 2695 |
2696 #ifdef WINDOWSNT | 2696 #ifdef WIN32_NATIVE |
2697 /* Make all handles non-inheritable */ | 2697 /* Make all handles non-inheritable */ |
2698 oflag |= _O_NOINHERIT; | 2698 oflag |= _O_NOINHERIT; |
2699 #endif | 2699 #endif |
2700 | 2700 |
2701 for (;;) | 2701 for (;;) |
2755 return sys_read_1 (fildes, buf, nbyte, 0); | 2755 return sys_read_1 (fildes, buf, nbyte, 0); |
2756 } | 2756 } |
2757 #endif /* ENCAPSULATE_READ */ | 2757 #endif /* ENCAPSULATE_READ */ |
2758 | 2758 |
2759 ssize_t | 2759 ssize_t |
2760 sys_write_1 (int fildes, CONST void *buf, size_t nbyte, int allow_quit) | 2760 sys_write_1 (int fildes, const void *buf, size_t nbyte, int allow_quit) |
2761 { | 2761 { |
2762 ssize_t bytes_written = 0; | 2762 ssize_t bytes_written = 0; |
2763 CONST char *b = (CONST char *) buf; | 2763 const char *b = (const char *) buf; |
2764 | 2764 |
2765 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */ | 2765 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */ |
2766 while (nbyte > 0) | 2766 while (nbyte > 0) |
2767 { | 2767 { |
2768 ssize_t rtnval = write (fildes, b, nbyte); | 2768 ssize_t rtnval = write (fildes, b, nbyte); |
2784 return bytes_written; | 2784 return bytes_written; |
2785 } | 2785 } |
2786 | 2786 |
2787 #ifdef ENCAPSULATE_WRITE | 2787 #ifdef ENCAPSULATE_WRITE |
2788 ssize_t | 2788 ssize_t |
2789 sys_write (int fildes, CONST void *buf, size_t nbyte) | 2789 sys_write (int fildes, const void *buf, size_t nbyte) |
2790 { | 2790 { |
2791 return sys_write_1 (fildes, buf, nbyte, 0); | 2791 return sys_write_1 (fildes, buf, nbyte, 0); |
2792 } | 2792 } |
2793 #endif /* ENCAPSULATE_WRITE */ | 2793 #endif /* ENCAPSULATE_WRITE */ |
2794 | 2794 |
2802 /* #### Should also encapsulate fflush(). | 2802 /* #### Should also encapsulate fflush(). |
2803 #### Should conceivably encapsulate getchar() etc. What a pain! */ | 2803 #### Should conceivably encapsulate getchar() etc. What a pain! */ |
2804 | 2804 |
2805 #ifdef ENCAPSULATE_FOPEN | 2805 #ifdef ENCAPSULATE_FOPEN |
2806 FILE * | 2806 FILE * |
2807 sys_fopen (CONST char *path, CONST char *type) | 2807 sys_fopen (const char *path, const char *type) |
2808 { | 2808 { |
2809 PATHNAME_CONVERT_OUT (path); | 2809 PATHNAME_CONVERT_OUT (path); |
2810 #if defined (WINDOWSNT) | 2810 #if defined (WIN32_NATIVE) |
2811 { | 2811 { |
2812 int fd; | 2812 int fd; |
2813 int oflag; | 2813 int oflag; |
2814 const char * type_save = type; | 2814 const char * type_save = type; |
2815 | 2815 |
2912 #endif /* ENCAPSULATE_FREAD */ | 2912 #endif /* ENCAPSULATE_FREAD */ |
2913 | 2913 |
2914 | 2914 |
2915 #ifdef ENCAPSULATE_FWRITE | 2915 #ifdef ENCAPSULATE_FWRITE |
2916 size_t | 2916 size_t |
2917 sys_fwrite (CONST void *ptr, size_t size, size_t nitem, FILE *stream) | 2917 sys_fwrite (const void *ptr, size_t size, size_t nitem, FILE *stream) |
2918 { | 2918 { |
2919 #ifdef INTERRUPTIBLE_IO | 2919 #ifdef INTERRUPTIBLE_IO |
2920 size_t rtnval; | 2920 size_t rtnval; |
2921 size_t items_written = 0; | 2921 size_t items_written = 0; |
2922 CONST char *b = (CONST char *) ptr; | 2922 const char *b = (const char *) ptr; |
2923 | 2923 |
2924 while (nitem > 0) | 2924 while (nitem > 0) |
2925 { | 2925 { |
2926 rtnval = fwrite (b, size, nitem, stream); | 2926 rtnval = fwrite (b, size, nitem, stream); |
2927 if (rtnval == 0) | 2927 if (rtnval == 0) |
2945 | 2945 |
2946 /********************* directory calls *******************/ | 2946 /********************* directory calls *******************/ |
2947 | 2947 |
2948 #ifdef ENCAPSULATE_CHDIR | 2948 #ifdef ENCAPSULATE_CHDIR |
2949 int | 2949 int |
2950 sys_chdir (CONST char *path) | 2950 sys_chdir (const char *path) |
2951 { | 2951 { |
2952 PATHNAME_CONVERT_OUT (path); | 2952 PATHNAME_CONVERT_OUT (path); |
2953 return chdir (path); | 2953 return chdir (path); |
2954 } | 2954 } |
2955 #endif /* ENCAPSULATE_CHDIR */ | 2955 #endif /* ENCAPSULATE_CHDIR */ |
2956 | 2956 |
2957 | 2957 |
2958 #ifdef ENCAPSULATE_MKDIR | 2958 #ifdef ENCAPSULATE_MKDIR |
2959 int | 2959 int |
2960 sys_mkdir (CONST char *path, mode_t mode) | 2960 sys_mkdir (const char *path, mode_t mode) |
2961 { | 2961 { |
2962 PATHNAME_CONVERT_OUT (path); | 2962 PATHNAME_CONVERT_OUT (path); |
2963 #ifdef WINDOWSNT | 2963 #ifdef WIN32_NATIVE |
2964 return mkdir (path); | 2964 return mkdir (path); |
2965 #else | 2965 #else |
2966 return mkdir (path, mode); | 2966 return mkdir (path, mode); |
2967 #endif | 2967 #endif |
2968 } | 2968 } |
2969 #endif /* ENCAPSULATE_MKDIR */ | 2969 #endif /* ENCAPSULATE_MKDIR */ |
2970 | 2970 |
2971 | 2971 |
2972 #ifdef ENCAPSULATE_OPENDIR | 2972 #ifdef ENCAPSULATE_OPENDIR |
2973 DIR * | 2973 DIR * |
2974 sys_opendir (CONST char *filename) | 2974 sys_opendir (const char *filename) |
2975 { | 2975 { |
2976 DIR *rtnval; | 2976 DIR *rtnval; |
2977 PATHNAME_CONVERT_OUT (filename); | 2977 PATHNAME_CONVERT_OUT (filename); |
2978 | 2978 |
2979 while (!(rtnval = opendir (filename)) | 2979 while (!(rtnval = opendir (filename)) |
3001 if (rtnval == NULL) /* End of directory */ | 3001 if (rtnval == NULL) /* End of directory */ |
3002 return NULL; | 3002 return NULL; |
3003 { | 3003 { |
3004 Extcount external_len; | 3004 Extcount external_len; |
3005 int ascii_filename_p = 1; | 3005 int ascii_filename_p = 1; |
3006 CONST Extbyte * CONST external_name = (CONST Extbyte *) rtnval->d_name; | 3006 const Extbyte * const external_name = (const Extbyte *) rtnval->d_name; |
3007 | 3007 |
3008 /* Optimize for the common all-ASCII case, computing len en passant */ | 3008 /* Optimize for the common all-ASCII case, computing len en passant */ |
3009 for (external_len = 0; external_name[external_len] ; external_len++) | 3009 for (external_len = 0; external_name[external_len] ; external_len++) |
3010 { | 3010 { |
3011 if (!BYTE_ASCII_P (external_name[external_len])) | 3011 if (!BYTE_ASCII_P (external_name[external_len])) |
3014 if (ascii_filename_p) | 3014 if (ascii_filename_p) |
3015 return rtnval; | 3015 return rtnval; |
3016 | 3016 |
3017 { /* Non-ASCII filename */ | 3017 { /* Non-ASCII filename */ |
3018 static Bufbyte_dynarr *internal_DIRENTRY; | 3018 static Bufbyte_dynarr *internal_DIRENTRY; |
3019 CONST Bufbyte *internal_name; | 3019 const Bufbyte *internal_name; |
3020 Bytecount internal_len; | 3020 Bytecount internal_len; |
3021 if (!internal_DIRENTRY) | 3021 if (!internal_DIRENTRY) |
3022 internal_DIRENTRY = Dynarr_new (Bufbyte); | 3022 internal_DIRENTRY = Dynarr_new (Bufbyte); |
3023 else | 3023 else |
3024 Dynarr_reset (internal_DIRENTRY); | 3024 Dynarr_reset (internal_DIRENTRY); |
3054 #endif /* ENCAPSULATE_CLOSEDIR */ | 3054 #endif /* ENCAPSULATE_CLOSEDIR */ |
3055 | 3055 |
3056 | 3056 |
3057 #ifdef ENCAPSULATE_RMDIR | 3057 #ifdef ENCAPSULATE_RMDIR |
3058 int | 3058 int |
3059 sys_rmdir (CONST char *path) | 3059 sys_rmdir (const char *path) |
3060 { | 3060 { |
3061 PATHNAME_CONVERT_OUT (path); | 3061 PATHNAME_CONVERT_OUT (path); |
3062 return rmdir (path); | 3062 return rmdir (path); |
3063 } | 3063 } |
3064 #endif /* ENCAPSULATE_RMDIR */ | 3064 #endif /* ENCAPSULATE_RMDIR */ |
3066 | 3066 |
3067 /***************** file-information calls ******************/ | 3067 /***************** file-information calls ******************/ |
3068 | 3068 |
3069 #ifdef ENCAPSULATE_ACCESS | 3069 #ifdef ENCAPSULATE_ACCESS |
3070 int | 3070 int |
3071 sys_access (CONST char *path, int mode) | 3071 sys_access (const char *path, int mode) |
3072 { | 3072 { |
3073 PATHNAME_CONVERT_OUT (path); | 3073 PATHNAME_CONVERT_OUT (path); |
3074 return access (path, mode); | 3074 return access (path, mode); |
3075 } | 3075 } |
3076 #endif /* ENCAPSULATE_ACCESS */ | 3076 #endif /* ENCAPSULATE_ACCESS */ |
3077 | 3077 |
3078 | 3078 |
3079 #ifdef HAVE_EACCESS | 3079 #ifdef HAVE_EACCESS |
3080 #ifdef ENCAPSULATE_EACCESS | 3080 #ifdef ENCAPSULATE_EACCESS |
3081 int | 3081 int |
3082 sys_eaccess (CONST char *path, int mode) | 3082 sys_eaccess (const char *path, int mode) |
3083 { | 3083 { |
3084 PATHNAME_CONVERT_OUT (path); | 3084 PATHNAME_CONVERT_OUT (path); |
3085 return eaccess (path, mode); | 3085 return eaccess (path, mode); |
3086 } | 3086 } |
3087 #endif /* ENCAPSULATE_EACCESS */ | 3087 #endif /* ENCAPSULATE_EACCESS */ |
3088 #endif /* HAVE_EACCESS */ | 3088 #endif /* HAVE_EACCESS */ |
3089 | 3089 |
3090 | 3090 |
3091 #ifdef ENCAPSULATE_LSTAT | 3091 #ifdef ENCAPSULATE_LSTAT |
3092 int | 3092 int |
3093 sys_lstat (CONST char *path, struct stat *buf) | 3093 sys_lstat (const char *path, struct stat *buf) |
3094 { | 3094 { |
3095 PATHNAME_CONVERT_OUT (path); | 3095 PATHNAME_CONVERT_OUT (path); |
3096 return lstat (path, buf); | 3096 return lstat (path, buf); |
3097 } | 3097 } |
3098 #endif /* ENCAPSULATE_LSTAT */ | 3098 #endif /* ENCAPSULATE_LSTAT */ |
3099 | 3099 |
3100 | 3100 |
3101 #ifdef ENCAPSULATE_READLINK | 3101 #ifdef ENCAPSULATE_READLINK |
3102 int | 3102 int |
3103 sys_readlink (CONST char *path, char *buf, size_t bufsiz) | 3103 sys_readlink (const char *path, char *buf, size_t bufsiz) |
3104 { | 3104 { |
3105 PATHNAME_CONVERT_OUT (path); | 3105 PATHNAME_CONVERT_OUT (path); |
3106 /* #### currently we don't do conversions on the incoming data */ | 3106 /* #### currently we don't do conversions on the incoming data */ |
3107 return readlink (path, buf, bufsiz); | 3107 return readlink (path, buf, bufsiz); |
3108 } | 3108 } |
3109 #endif /* ENCAPSULATE_READLINK */ | 3109 #endif /* ENCAPSULATE_READLINK */ |
3110 | 3110 |
3111 | |
3112 #ifdef ENCAPSULATE_FSTAT | 3111 #ifdef ENCAPSULATE_FSTAT |
3113 int | 3112 int |
3114 sys_fstat (int fd, struct stat *buf) | 3113 sys_fstat (int fd, struct stat *buf) |
3115 { | 3114 { |
3115 #ifdef WIN32_NATIVE | |
3116 return mswindows_fstat (fd, buf); | |
3117 #else | |
3116 return fstat (fd, buf); | 3118 return fstat (fd, buf); |
3119 #endif | |
3117 } | 3120 } |
3118 #endif /* ENCAPSULATE_FSTAT */ | 3121 #endif /* ENCAPSULATE_FSTAT */ |
3119 | 3122 |
3120 | |
3121 #ifdef ENCAPSULATE_STAT | |
3122 int | 3123 int |
3123 sys_stat (CONST char *path, struct stat *buf) | 3124 xemacs_stat (const char *path, struct stat *buf) |
3124 { | 3125 { |
3125 PATHNAME_CONVERT_OUT (path); | 3126 PATHNAME_CONVERT_OUT (path); |
3127 #ifdef WIN32_NATIVE | |
3128 return mswindows_stat (path, buf); | |
3129 #else | |
3126 return stat (path, buf); | 3130 return stat (path, buf); |
3127 } | 3131 #endif |
3128 #endif /* ENCAPSULATE_STAT */ | 3132 } |
3129 | |
3130 | 3133 |
3131 /****************** file-manipulation calls *****************/ | 3134 /****************** file-manipulation calls *****************/ |
3132 | 3135 |
3133 #ifdef ENCAPSULATE_CHMOD | 3136 #ifdef ENCAPSULATE_CHMOD |
3134 int | 3137 int |
3135 sys_chmod (CONST char *path, mode_t mode) | 3138 sys_chmod (const char *path, mode_t mode) |
3136 { | 3139 { |
3137 PATHNAME_CONVERT_OUT (path); | 3140 PATHNAME_CONVERT_OUT (path); |
3138 return chmod (path, mode); | 3141 return chmod (path, mode); |
3139 } | 3142 } |
3140 #endif /* ENCAPSULATE_CHMOD */ | 3143 #endif /* ENCAPSULATE_CHMOD */ |
3141 | 3144 |
3142 | 3145 |
3143 #ifdef ENCAPSULATE_CREAT | 3146 #ifdef ENCAPSULATE_CREAT |
3144 int | 3147 int |
3145 sys_creat (CONST char *path, mode_t mode) | 3148 sys_creat (const char *path, mode_t mode) |
3146 { | 3149 { |
3147 PATHNAME_CONVERT_OUT (path); | 3150 PATHNAME_CONVERT_OUT (path); |
3148 return creat (path, mode); | 3151 return creat (path, mode); |
3149 } | 3152 } |
3150 #endif /* ENCAPSULATE_CREAT */ | 3153 #endif /* ENCAPSULATE_CREAT */ |
3151 | 3154 |
3152 | 3155 |
3153 #ifdef ENCAPSULATE_LINK | 3156 #ifdef ENCAPSULATE_LINK |
3154 int | 3157 int |
3155 sys_link (CONST char *existing, CONST char *new) | 3158 sys_link (const char *existing, const char *new) |
3156 { | 3159 { |
3157 PATHNAME_CONVERT_OUT (existing); | 3160 PATHNAME_CONVERT_OUT (existing); |
3158 PATHNAME_CONVERT_OUT (new); | 3161 PATHNAME_CONVERT_OUT (new); |
3159 return link (existing, new); | 3162 return link (existing, new); |
3160 } | 3163 } |
3161 #endif /* ENCAPSULATE_LINK */ | 3164 #endif /* ENCAPSULATE_LINK */ |
3162 | 3165 |
3163 | 3166 |
3164 #ifdef ENCAPSULATE_RENAME | 3167 #ifdef ENCAPSULATE_RENAME |
3165 int | 3168 int |
3166 sys_rename (CONST char *old, CONST char *new) | 3169 sys_rename (const char *old, const char *new) |
3167 { | 3170 { |
3168 PATHNAME_CONVERT_OUT (old); | 3171 PATHNAME_CONVERT_OUT (old); |
3169 PATHNAME_CONVERT_OUT (new); | 3172 PATHNAME_CONVERT_OUT (new); |
3170 #ifdef WINDOWSNT | 3173 #ifdef WIN32_NATIVE |
3171 /* Windows rename fails if NEW exists */ | 3174 /* Windows rename fails if NEW exists */ |
3172 if (rename (old, new) == 0) | 3175 if (rename (old, new) == 0) |
3173 return 0; | 3176 return 0; |
3174 if (errno != EEXIST) | 3177 if (errno != EEXIST) |
3175 return -1; | 3178 return -1; |
3176 unlink (new); | 3179 unlink (new); |
3177 #endif /* WINDOWSNT */ | 3180 #endif /* WIN32_NATIVE */ |
3178 return rename (old, new); | 3181 return rename (old, new); |
3179 } | 3182 } |
3180 #endif /* ENCAPSULATE_RENAME */ | 3183 #endif /* ENCAPSULATE_RENAME */ |
3181 | 3184 |
3182 | 3185 |
3183 #ifdef ENCAPSULATE_SYMLINK | 3186 #ifdef ENCAPSULATE_SYMLINK |
3184 int | 3187 int |
3185 sys_symlink (CONST char *name1, CONST char *name2) | 3188 sys_symlink (const char *name1, const char *name2) |
3186 { | 3189 { |
3187 PATHNAME_CONVERT_OUT (name1); | 3190 PATHNAME_CONVERT_OUT (name1); |
3188 PATHNAME_CONVERT_OUT (name2); | 3191 PATHNAME_CONVERT_OUT (name2); |
3189 return symlink (name1, name2); | 3192 return symlink (name1, name2); |
3190 } | 3193 } |
3191 #endif /* ENCAPSULATE_SYMLINK */ | 3194 #endif /* ENCAPSULATE_SYMLINK */ |
3192 | 3195 |
3193 | 3196 |
3194 #ifdef ENCAPSULATE_UNLINK | 3197 #ifdef ENCAPSULATE_UNLINK |
3195 int | 3198 int |
3196 sys_unlink (CONST char *path) | 3199 sys_unlink (const char *path) |
3197 { | 3200 { |
3198 PATHNAME_CONVERT_OUT (path); | 3201 PATHNAME_CONVERT_OUT (path); |
3199 return unlink (path); | 3202 return unlink (path); |
3200 } | 3203 } |
3201 #endif /* ENCAPSULATE_UNLINK */ | 3204 #endif /* ENCAPSULATE_UNLINK */ |
3202 | 3205 |
3203 | 3206 |
3204 #ifdef ENCAPSULATE_EXECVP | 3207 #ifdef ENCAPSULATE_EXECVP |
3205 int | 3208 int |
3206 sys_execvp (CONST char *path, char * CONST * argv) | 3209 sys_execvp (const char *path, char * const * argv) |
3207 { | 3210 { |
3208 int i, argc; | 3211 int i, argc; |
3209 char ** new_argv; | 3212 char ** new_argv; |
3210 | 3213 |
3211 PATHNAME_CONVERT_OUT (path); | 3214 PATHNAME_CONVERT_OUT (path); |
3229 | 3232 |
3230 /***** (these are primarily required for USG, it seems) *****/ | 3233 /***** (these are primarily required for USG, it seems) *****/ |
3231 | 3234 |
3232 #ifndef HAVE_GETCWD | 3235 #ifndef HAVE_GETCWD |
3233 char * | 3236 char * |
3234 getcwd (char *pathname, int size) | 3237 getcwd (char *pathname, size_t size) |
3235 { | 3238 { |
3236 return getwd (pathname); | 3239 return getwd (pathname); |
3237 } | 3240 } |
3238 #endif /* emulate getcwd */ | 3241 #endif /* emulate getcwd */ |
3239 | 3242 |
3273 * that files be of same type (regular->regular, dir->dir, etc). | 3276 * that files be of same type (regular->regular, dir->dir, etc). |
3274 */ | 3277 */ |
3275 | 3278 |
3276 #ifndef HAVE_RENAME | 3279 #ifndef HAVE_RENAME |
3277 int | 3280 int |
3278 rename (CONST char *from, CONST char *to) | 3281 rename (const char *from, const char *to) |
3279 { | 3282 { |
3280 if (access (from, 0) == 0) | 3283 if (access (from, 0) == 0) |
3281 { | 3284 { |
3282 unlink (to); | 3285 unlink (to); |
3283 if (link (from, to) == 0) | 3286 if (link (from, to) == 0) |
3387 for increased accuracy. */ | 3390 for increased accuracy. */ |
3388 | 3391 |
3389 static int | 3392 static int |
3390 get_process_times_1 (long *user_ticks, long *system_ticks) | 3393 get_process_times_1 (long *user_ticks, long *system_ticks) |
3391 { | 3394 { |
3392 #if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WINDOWSNT) | 3395 #if defined (_SC_CLK_TCK) || defined (CLK_TCK) && !defined(WIN32_NATIVE) |
3393 /* We have the POSIX times() function available. */ | 3396 /* We have the POSIX times() function available. */ |
3394 struct tms tttt; | 3397 struct tms tttt; |
3395 times (&tttt); | 3398 times (&tttt); |
3396 *user_ticks = (long) tttt.tms_utime; | 3399 *user_ticks = (long) tttt.tms_utime; |
3397 *system_ticks = (long) tttt.tms_stime; | 3400 *system_ticks = (long) tttt.tms_stime; |
3529 /* Strings corresponding to defined signals */ | 3532 /* Strings corresponding to defined signals */ |
3530 /************************************************************************/ | 3533 /************************************************************************/ |
3531 | 3534 |
3532 #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST) | 3535 #if !defined (SYS_SIGLIST_DECLARED) && !defined (HAVE_SYS_SIGLIST) |
3533 | 3536 |
3534 #if defined(WINDOWSNT) || defined(__CYGWIN32__) | 3537 #if defined(WIN32_NATIVE) || defined(CYGWIN) |
3535 CONST char *sys_siglist[] = | 3538 const char *sys_siglist[] = |
3536 { | 3539 { |
3537 "bum signal!!", | 3540 "bum signal!!", |
3538 "hangup", | 3541 "hangup", |
3539 "interrupt", | 3542 "interrupt", |
3540 "quit", | 3543 "quit", |
3563 }; | 3566 }; |
3564 #endif | 3567 #endif |
3565 | 3568 |
3566 #ifdef USG | 3569 #ifdef USG |
3567 #ifdef AIX | 3570 #ifdef AIX |
3568 CONST char *sys_siglist[NSIG + 1] = | 3571 const char *sys_siglist[NSIG + 1] = |
3569 { | 3572 { |
3570 /* AIX has changed the signals a bit */ | 3573 /* AIX has changed the signals a bit */ |
3571 DEFER_GETTEXT ("bogus signal"), /* 0 */ | 3574 DEFER_GETTEXT ("bogus signal"), /* 0 */ |
3572 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ | 3575 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ |
3573 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ | 3576 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ |
3603 DEFER_GETTEXT ("HFT input ready"), /* 31 SIGMSG */ | 3606 DEFER_GETTEXT ("HFT input ready"), /* 31 SIGMSG */ |
3604 #endif | 3607 #endif |
3605 0 | 3608 0 |
3606 }; | 3609 }; |
3607 #else /* USG, not AIX */ | 3610 #else /* USG, not AIX */ |
3608 CONST char *sys_siglist[NSIG + 1] = | 3611 const char *sys_siglist[NSIG + 1] = |
3609 { | 3612 { |
3610 DEFER_GETTEXT ("bogus signal"), /* 0 */ | 3613 DEFER_GETTEXT ("bogus signal"), /* 0 */ |
3611 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ | 3614 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ |
3612 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ | 3615 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ |
3613 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ | 3616 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ |
3652 0 | 3655 0 |
3653 }; | 3656 }; |
3654 #endif /* not AIX */ | 3657 #endif /* not AIX */ |
3655 #endif /* USG */ | 3658 #endif /* USG */ |
3656 #ifdef DGUX | 3659 #ifdef DGUX |
3657 CONST char *sys_siglist[NSIG + 1] = | 3660 const char *sys_siglist[NSIG + 1] = |
3658 { | 3661 { |
3659 DEFER_GETTEXT ("null signal"), /* 0 SIGNULL */ | 3662 DEFER_GETTEXT ("null signal"), /* 0 SIGNULL */ |
3660 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ | 3663 DEFER_GETTEXT ("hangup"), /* 1 SIGHUP */ |
3661 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ | 3664 DEFER_GETTEXT ("interrupt"), /* 2 SIGINT */ |
3662 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ | 3665 DEFER_GETTEXT ("quit"), /* 3 SIGQUIT */ |
3757 #endif /* SYSV_SYSTEM_DIR */ | 3760 #endif /* SYSV_SYSTEM_DIR */ |
3758 | 3761 |
3759 #ifdef NONSYSTEM_DIR_LIBRARY | 3762 #ifdef NONSYSTEM_DIR_LIBRARY |
3760 | 3763 |
3761 DIR * | 3764 DIR * |
3762 opendir (CONST char *filename) /* name of directory */ | 3765 opendir (const char *filename) /* name of directory */ |
3763 { | 3766 { |
3764 DIR *dirp; /* -> malloc'ed storage */ | 3767 DIR *dirp; /* -> malloc'ed storage */ |
3765 int fd; /* file descriptor for read */ | 3768 int fd; /* file descriptor for read */ |
3766 struct stat sbuf; /* result of fstat */ | 3769 struct stat sbuf; /* result of fstat */ |
3767 | 3770 |
3859 */ | 3862 */ |
3860 #ifdef MKDIR_PROTOTYPE | 3863 #ifdef MKDIR_PROTOTYPE |
3861 MKDIR_PROTOTYPE | 3864 MKDIR_PROTOTYPE |
3862 #else | 3865 #else |
3863 int | 3866 int |
3864 mkdir (CONST char *dpath, int dmode) | 3867 mkdir (const char *dpath, int dmode) |
3865 #endif | 3868 #endif |
3866 { | 3869 { |
3867 int cpid, status, fd; | 3870 int cpid, status, fd; |
3868 struct stat statbuf; | 3871 struct stat statbuf; |
3869 | 3872 |
3870 if (stat (dpath, &statbuf) == 0) | 3873 if (stat (dpath, &statbuf) == 0) /* we do want stat() here */ |
3871 { | 3874 { |
3872 errno = EEXIST; /* Stat worked, so it already exists */ | 3875 errno = EEXIST; /* Stat worked, so it already exists */ |
3873 return -1; | 3876 return -1; |
3874 } | 3877 } |
3875 | 3878 |
3919 } | 3922 } |
3920 #endif /* not HAVE_MKDIR */ | 3923 #endif /* not HAVE_MKDIR */ |
3921 | 3924 |
3922 #ifndef HAVE_RMDIR | 3925 #ifndef HAVE_RMDIR |
3923 int | 3926 int |
3924 rmdir (CONST char *dpath) | 3927 rmdir (const char *dpath) |
3925 { | 3928 { |
3926 int cpid, status, fd; | 3929 int cpid, status, fd; |
3927 struct stat statbuf; | 3930 struct stat statbuf; |
3928 | 3931 |
3929 if (stat (dpath, &statbuf) != 0) | 3932 if (stat (dpath, &statbuf) != 0) /* we do want stat() here */ |
3930 { | 3933 { |
3931 /* Stat just set errno. We don't have to */ | 3934 /* Stat just set errno. We don't have to */ |
3932 return -1; | 3935 return -1; |
3933 } | 3936 } |
3934 | 3937 |
3993 { | 3996 { |
3994 return -1; | 3997 return -1; |
3995 } | 3998 } |
3996 | 3999 |
3997 #endif /* USE_DL_STUBS */ | 4000 #endif /* USE_DL_STUBS */ |
3998 | |
3999 | |
4000 | |
4001 #ifndef HAVE_STRCASECMP | |
4002 /* | |
4003 * From BSD | |
4004 */ | |
4005 static unsigned char charmap[] = { | |
4006 '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', | |
4007 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', | |
4008 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', | |
4009 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', | |
4010 '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', | |
4011 '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', | |
4012 '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', | |
4013 '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', | |
4014 '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', | |
4015 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', | |
4016 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', | |
4017 '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', | |
4018 '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', | |
4019 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', | |
4020 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', | |
4021 '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', | |
4022 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', | |
4023 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', | |
4024 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', | |
4025 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', | |
4026 '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', | |
4027 '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', | |
4028 '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', | |
4029 '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', | |
4030 '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', | |
4031 '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', | |
4032 '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', | |
4033 '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', | |
4034 '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', | |
4035 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', | |
4036 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | |
4037 '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', | |
4038 }; | |
4039 | |
4040 int | |
4041 strcasecmp (char *s1, char *s2) | |
4042 { | |
4043 unsigned char *cm = charmap; | |
4044 unsigned char *us1 = (unsigned char *) s1; | |
4045 unsigned char *us2 = (unsigned char *)s2; | |
4046 | |
4047 while (cm[*us1] == cm[*us2++]) | |
4048 if (*us1++ == '\0') | |
4049 return (0); | |
4050 | |
4051 return (cm[*us1] - cm[*--us2]); | |
4052 } | |
4053 #endif /* !HAVE_STRCASECMP */ |