From 68c45bf06516ed4650eb7f9f617742d84750600a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 19 Oct 1999 07:25:11 +0000 Subject: [PATCH] Add support for large files, 64-bit Solaris, system locale codings. * Makefile.in (emacs): Set the LC_ALL environment variable to "C" when dumping, so that the dumped Emacs doesn't have stray locale info. (dired.o): Depend on systime.h. (editfns.o): Depend on coding.h. * alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c, dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c, keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c, unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c, w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Include before any system include files. * alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c, m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Do not include , as does this now. * callproc.c (Fcall_process): Synchronize messages locale before invoking strerror. Decode resulting string with locale-coding-system. * coding.c (Vlocale_coding_system): New var. (syms_of_coding): Adjust to above change. (emacs_strerror): New function. * coding.h (emacs_strerror, Vlocale_coding_system): New decls. * config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING, HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN, HAVE_STRSIGNAL): New macros. (BITS_PER_LONG): Default to 64 if _LP64 is defined. : Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't. * dired.c: Include "systime.h". (Ffile_attributes): Do not cast s.st_size to int; this loses information if int is 32 bits but st_size and EMACS_INT are larger. Treat large device numbers like large inode numbers. * dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available. * editfns.c: Include coding.h. (emacs_strftime): Remove decl. (emacs_strftimeu): New decl. (emacs_memftimeu): Renamed from emacs_memftime; new arg UT. Use emacs_strftimeu instead of emacs_strftime. (Fformat_time_string): Convert format string using Vlocale_coding_system, and convert result back. Synchronize time locale before invoking lower level function. Invoke emacs_memftimeu, passing ut, instead of emacs_memftime. * emacs.c: Include if HAVE_SETLOCALE is defined. (Vmessages_locale, Vprevious_messages_locale, Vtime_locale, Vprevious_time_locale): New variables. (main): Invoke setlocale early, so that initial error messages are localized properly. But skip locale-setting if LC_ALL is "C". Fix up locale when it's safe to do so. (fixup_locale): Moved here from xterm.c. (synchronize_locale, synchronize_time_locale, synchronize_messages_locale): New functions. (syms_of_emacs): Accommodate above changes. * fileio.c (report_file_error): Convert strerror output according to Vlocale_coding_system. (Finsert_file_contents): Check for arithmetic overflow in computations that depend on file size. Report IO errors with emacs_strerror, not strerror. * fns.c (Fgethash): Declare dflt parameter. * gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H is defined; that's config.h's job. * lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64, default these values to long, BITS_PER_LONG, and unsigned long. (VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT. (PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int. (code_convert_string_norecord, fixup_locale, synchronize_messages_locale, synchronize_time_locale, emacs_open, emacs_close, emacs_read, emacs_write): New decls. All Emacs callers of open, close, read, write changed to use emacs_open, emacs_close, emacs_read, emacs_write. * lread.c (file_offset, file_tell): New macros. All uses of ftell changed to file_tell. (saved_doc_string_position, prev_saved_doc_string_position): Now of type file_offset. (init_lread): Do not fix locale here; fixup_locale now does this. * m/amdahl.h, s/usg5-4.h: (NSIG): Remove. (NSIG_MINIMUM): New macro. * m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h, m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/umips.h, s/usg5-4.h: (SIGIO): Do not undef. (BROKEN_SIGIO): New macro. * m/ustation.h: (SIGTSTP): Do not undef. (BROKEN_SIGTSTP): New macro. * s/gnu-linux.h: (SIGPOLL, SIGURG): Do not undef. (BROKEN_SIGPOLL, BROKEN_SIGURG): New macros. * s/ptx4.h: (SIGINFO): Do not undef. (BROKEN_SIGINFO): New macros. * m/delta.h, s/ptx.h, s/template.h: Doc fix. * mktime.c, strftime.c: Update to glibc 2.1.2 version, with some Emacs-related changes merged. * print.c (float_to_string): Prepend "-" to representation of a NaN if the NaN is negative. * process.c (sys_siglist): Omit if HAVE_STRSIGNAL. (wait_reading_process_input): Use emacs_strerror, not strerror. * process.c (status_message, sigchld_handler): Synchronize locale, then use strsignal istead of sys_siglist. * w32proc.c (sys_wait): Likewise. * s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h, s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h, s/usg5-2.h, s/usg5-3.h, s/xenix.h: (open, close, read, write, INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove. * s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros. * sysdep.c (sys_read, sys_write, read, write, sys_close, close, sys_open, open): Remove. (emacs_open, emacs_close, emacs_read, emacs_write): Always define; the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO macros are no longer used. (emacs_open): Renamed from sys_open. Merge BSD4_1 version. (emacs_close): Renamed from sys_close. (emacs_read): Renamed from sys_read. (emacs_write): Renamed from sys_write. (sys_siglist): Do not declare if HAVE_STRSIGNAL. (dup2): Do not print error on failure; the real dup2 doesn't. (strsignal): New function, defined if !HAVE_STRSIGNAL. * syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO is defined. (SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise. (NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM. (strsignal): Declare if !HAVE_STRSIGNAL. * unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros. (ElfW): Define in terms of ElfExpandBitsW. * w32proc.c (sys_siglist): Remove decl. * xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply with ANSI C. (display_string): Declare face_string_pos arg. * xfns.c (Fx_show_tip): Declare timeout param. * xterm.c: No need to include locale.h. (x_alloc_lighter_color, x_setup_relief_color): Pass arg as double, not float, for compatibility with ANSI C. (fixup_locale): Move to emacs.c. (x_term_init): Do not setlocale or fixup locale; the main program does this now. --- src/ChangeLog | 176 +++++++++++++++++++++++++++++++++++++ src/Makefile.in | 11 +-- src/alloc.c | 10 +-- src/buffer.c | 5 +- src/callproc.c | 97 ++++++++++---------- src/ccl.c | 10 +-- src/charset.c | 5 +- src/coding.c | 31 ++++++- src/coding.h | 4 + src/config.in | 23 ++++- src/data.c | 6 +- src/dired.c | 15 +++- src/dispnew.c | 8 +- src/doc.c | 20 ++--- src/editfns.c | 45 +++++----- src/emacs.c | 113 +++++++++++++++++++++--- src/eval.c | 6 +- src/fileio.c | 108 ++++++++++++----------- src/filelock.c | 9 +- src/floatfns.c | 5 +- src/fns.c | 2 +- src/frame.c | 5 +- src/gmalloc.c | 4 +- src/hftctl.c | 8 +- src/insdel.c | 5 +- src/keyboard.c | 8 +- src/keymap.c | 5 +- src/lisp.h | 35 ++++++-- src/lread.c | 37 ++++---- src/mktime.c | 159 ++++++++++++++++----------------- src/msdos.c | 8 +- src/print.c | 16 +++- src/process.c | 108 +++++++++++------------ src/search.c | 5 +- src/sound.c | 18 ++-- src/strftime.c | 219 +++++++++++++++++++++++++--------------------- src/sunfns.c | 4 +- src/sysdep.c | 129 +++++++++++---------------- src/syssignal.h | 30 ++++++- src/unexelf.c | 28 +++--- src/unexhp9k800.c | 8 +- src/unexsunos4.c | 13 ++- src/vmsfns.c | 4 +- src/vmsgmalloc.c | 10 +-- src/w32faces.c | 4 +- src/w32menu.c | 5 +- src/w32proc.c | 18 ++-- src/w32term.c | 4 +- src/w32xfns.c | 4 +- src/xdisp.c | 9 +- src/xfaces.c | 3 +- src/xfns.c | 10 +-- src/xmenu.c | 8 +- src/xterm.c | 48 ++-------- 54 files changed, 1003 insertions(+), 685 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bafec6aff2..2517179218 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,179 @@ +1999-10-19 Paul Eggert + + Add support for large files, 64-bit Solaris, system locale codings. + + * Makefile.in (emacs): Set the LC_ALL environment variable to "C" + when dumping, so that the dumped Emacs doesn't have stray locale info. + (dired.o): Depend on systime.h. + (editfns.o): Depend on coding.h. + + * alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c, + dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c, + keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c, + unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c, + w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c: + Include before any system include files. + + * alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c, + fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c, + m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c, + xmenu.c, xterm.c: + Do not include , as does this now. + + * callproc.c (Fcall_process): + Synchronize messages locale before invoking strerror. + Decode resulting string with locale-coding-system. + + * coding.c (Vlocale_coding_system): New var. + (syms_of_coding): Adjust to above change. + (emacs_strerror): New function. + + * coding.h (emacs_strerror, Vlocale_coding_system): New decls. + + * config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING, + HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN, + HAVE_STRSIGNAL): New macros. + (BITS_PER_LONG): Default to 64 if _LP64 is defined. + : Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't. + + * dired.c: Include "systime.h". + (Ffile_attributes): Do not cast s.st_size to int; this loses + information if int is 32 bits but st_size and EMACS_INT are larger. + Treat large device numbers like large inode numbers. + + * dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available. + + * editfns.c: Include coding.h. + (emacs_strftime): Remove decl. + (emacs_strftimeu): New decl. + (emacs_memftimeu): Renamed from emacs_memftime; new arg UT. + Use emacs_strftimeu instead of emacs_strftime. + (Fformat_time_string): Convert format string using + Vlocale_coding_system, and convert result back. Synchronize time + locale before invoking lower level function. Invoke + emacs_memftimeu, passing ut, instead of emacs_memftime. + + * emacs.c: Include if HAVE_SETLOCALE is defined. + (Vmessages_locale, Vprevious_messages_locale, Vtime_locale, + Vprevious_time_locale): New variables. + (main): Invoke setlocale early, so that initial error messages are + localized properly. But skip locale-setting if LC_ALL is "C". + Fix up locale when it's safe to do so. + (fixup_locale): Moved here from xterm.c. + (synchronize_locale, synchronize_time_locale, + synchronize_messages_locale): New functions. + (syms_of_emacs): Accommodate above changes. + + * fileio.c (report_file_error): Convert strerror output according + to Vlocale_coding_system. + (Finsert_file_contents): Check for arithmetic overflow in + computations that depend on file size. Report IO errors + with emacs_strerror, not strerror. + + * fns.c (Fgethash): Declare dflt parameter. + + * gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H + is defined; that's config.h's job. + + * lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64, + default these values to long, BITS_PER_LONG, and unsigned long. + (VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT. + (PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int. + (code_convert_string_norecord, fixup_locale, + synchronize_messages_locale, synchronize_time_locale, + emacs_open, emacs_close, emacs_read, emacs_write): New decls. + All Emacs callers of open, close, read, write changed to use + emacs_open, emacs_close, emacs_read, emacs_write. + + * lread.c (file_offset, file_tell): New macros. All uses of ftell + changed to file_tell. + (saved_doc_string_position, prev_saved_doc_string_position): Now + of type file_offset. + (init_lread): Do not fix locale here; fixup_locale now does this. + + * m/amdahl.h, s/usg5-4.h: + (NSIG): Remove. + (NSIG_MINIMUM): New macro. + + * m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h, + m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, + s/umips.h, s/usg5-4.h: + (SIGIO): Do not undef. + (BROKEN_SIGIO): New macro. + + * m/ustation.h: + (SIGTSTP): Do not undef. + (BROKEN_SIGTSTP): New macro. + + * s/gnu-linux.h: + (SIGPOLL, SIGURG): Do not undef. + (BROKEN_SIGPOLL, BROKEN_SIGURG): New macros. + + * s/ptx4.h: + (SIGINFO): Do not undef. + (BROKEN_SIGINFO): New macros. + + * m/delta.h, s/ptx.h, s/template.h: Doc fix. + + * mktime.c, strftime.c: Update to glibc 2.1.2 version, with + some Emacs-related changes merged. + + * print.c (float_to_string): Prepend "-" to representation of a + NaN if the NaN is negative. + + * process.c (sys_siglist): Omit if HAVE_STRSIGNAL. + (wait_reading_process_input): Use emacs_strerror, not strerror. + + * process.c (status_message, sigchld_handler): Synchronize locale, + then use strsignal istead of sys_siglist. + * w32proc.c (sys_wait): Likewise. + + * s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h, + s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h, + s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h, + s/usg5-2.h, s/usg5-3.h, s/xenix.h: + (open, close, read, write, INTERRUPTIBLE_OPEN, + INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove. + + * s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros. + + * sysdep.c (sys_read, sys_write, read, write, sys_close, close, + sys_open, open): Remove. + (emacs_open, emacs_close, emacs_read, emacs_write): Always define; + the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO + macros are no longer used. + (emacs_open): Renamed from sys_open. Merge BSD4_1 version. + (emacs_close): Renamed from sys_close. + (emacs_read): Renamed from sys_read. + (emacs_write): Renamed from sys_write. + (sys_siglist): Do not declare if HAVE_STRSIGNAL. + (dup2): Do not print error on failure; the real dup2 doesn't. + (strsignal): New function, defined if !HAVE_STRSIGNAL. + + * syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO + is defined. + (SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise. + (NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM. + (strsignal): Declare if !HAVE_STRSIGNAL. + + * unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros. + (ElfW): Define in terms of ElfExpandBitsW. + + * w32proc.c (sys_siglist): Remove decl. + + * xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply + with ANSI C. + (display_string): Declare face_string_pos arg. + + * xfns.c (Fx_show_tip): Declare timeout param. + + * xterm.c: No need to include locale.h. + (x_alloc_lighter_color, x_setup_relief_color): + Pass arg as double, not float, for compatibility with ANSI C. + (fixup_locale): Move to emacs.c. + (x_term_init): Do not setlocale or fixup locale; the main program + does this now. + 1999-10-18 Dave Love * doc.c (Fdocumentation_property): Gcpro `tem'. diff --git a/src/Makefile.in b/src/Makefile.in index b5403c2f35..509a1bf058 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,5 +1,5 @@ # Makefile for GNU Emacs. -# Copyright (C) 1985, 87, 88, 93, 94, 95 Free Software Foundation, Inc. +# Copyright (C) 1985, 87, 88, 93, 94, 95, 1999 Free Software Foundation, Inc. # This file is part of GNU Emacs. @@ -856,9 +856,9 @@ emacs: temacs ${etc}DOC ${lisp} ln temacs emacs #else #ifdef HAVE_SHM - ./temacs -nl -batch -l loadup dump + LC_ALL=C ./temacs -nl -batch -l loadup dump #else /* ! defined (HAVE_SHM) */ - ./temacs -batch -l loadup dump + LC_ALL=C ./temacs -batch -l loadup dump #endif /* ! defined (HAVE_SHM) */ #endif /* ! defined (CANNOT_DUMP) */ -./emacs -q -batch -f list-load-path-shadows @@ -1057,7 +1057,8 @@ cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \ pre-crt0.o: pre-crt0.c ecrt0.o: ecrt0.c $(config_h) CRT0_COMPILE ${srcdir}/ecrt0.c -dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h +dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \ + systime.h dispnew.o: dispnew.c commands.h frame.h window.h buffer.h dispextern.h \ termchar.h termopts.h termhooks.h cm.h disptab.h systty.h systime.h \ xterm.h blockinput.h charset.h msdos.h $(config_h) @@ -1065,7 +1066,7 @@ doc.o: doc.c $(config_h) epaths.h buffer.h keyboard.h doprnt.o: doprnt.c charset.h $(config_h) dosfns.o: buffer.h termchar.h termhooks.h frame.h msdos.h dosfns.h $(config_h) editfns.o: editfns.c window.h buffer.h systime.h INTERVAL_SRC charset.h \ - $(config_h) + coding.h $(config_h) emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \ termhooks.h buffer.h INTERVAL_SRC $(config_h) fileio.o: fileio.c window.h buffer.h systime.h INTERVAL_SRC charset.h \ diff --git a/src/alloc.c b/src/alloc.c index 7120cae26b..0e3ad2dbf9 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,5 +1,5 @@ /* Storage allocation and gc for GNU Emacs Lisp interpreter. - Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 1998 + Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,14 +19,10 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Note that this declares bzero on OSF/1. How dumb. */ -#include - #include -#ifdef STDC_HEADERS -#include -#endif +/* Note that this declares bzero on OSF/1. How dumb. */ +#include #include "lisp.h" #include "intervals.h" diff --git a/src/buffer.c b/src/buffer.c index 6ab4200b75..59f4bcc478 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -19,6 +19,7 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include @@ -32,10 +33,6 @@ extern int errno; #define MAXPATHLEN 1024 #endif /* not MAXPATHLEN */ -#include -#ifdef STDC_HEADERS -#include -#endif #ifdef HAVE_UNISTD_H #include #endif diff --git a/src/callproc.c b/src/callproc.c index de6856b506..5ea59bf462 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1,5 +1,5 @@ /* Synchronous subprocess invocation for GNU Emacs. - Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc. + Copyright (C) 1985, 86,87,88,93,94,95, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,10 +19,9 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include - -#include #include extern int errno; @@ -134,7 +133,7 @@ static Lisp_Object call_process_kill (fdpid) Lisp_Object fdpid; { - close (XFASTINT (Fcar (fdpid))); + emacs_close (XFASTINT (Fcar (fdpid))); EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL); synch_process_alive = 0; return Qnil; @@ -148,7 +147,7 @@ call_process_cleanup (fdpid) /* for MSDOS fdpid is really (fd . tempfile) */ register Lisp_Object file; file = Fcdr (fdpid); - close (XFASTINT (Fcar (fdpid))); + emacs_close (XFASTINT (Fcar (fdpid))); if (strcmp (XSTRING (file)-> data, NULL_DEVICE) != 0) unlink (XSTRING (file)->data); #else /* not MSDOS and not macintosh */ @@ -156,7 +155,7 @@ call_process_cleanup (fdpid) if (call_process_exited) { - close (XFASTINT (Fcar (fdpid))); + emacs_close (XFASTINT (Fcar (fdpid))); return Qnil; } @@ -173,7 +172,7 @@ call_process_cleanup (fdpid) message1 ("Waiting for process to die...done"); } synch_process_alive = 0; - close (XFASTINT (Fcar (fdpid))); + emacs_close (XFASTINT (Fcar (fdpid))); #endif /* not MSDOS */ return Qnil; } @@ -359,7 +358,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") display = nargs >= 4 ? args[3] : Qnil; - filefd = open (XSTRING (infile)->data, O_RDONLY, 0); + filefd = emacs_open (XSTRING (infile)->data, O_RDONLY, 0); if (filefd < 0) { report_file_error ("Opening process input file", Fcons (infile, Qnil)); @@ -374,7 +373,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") } if (NILP (path)) { - close (filefd); + emacs_close (filefd); report_file_error ("Searching for program", Fcons (args[0], Qnil)); } new_argv[0] = XSTRING (path)->data; @@ -436,7 +435,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") outfilefd = creat (tempfile, S_IREAD | S_IWRITE); if (outfilefd < 0) { - close (filefd); + emacs_close (filefd); report_file_error ("Opening process output file", Fcons (build_string (tempfile), Qnil)); } @@ -465,7 +464,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") #endif /* macintosh */ if (INTEGERP (buffer)) - fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; + fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1; else { #ifndef MSDOS @@ -500,13 +499,13 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") synch_process_retcode = 0; if (NILP (error_file)) - fd_error = open (NULL_DEVICE, O_WRONLY); + fd_error = emacs_open (NULL_DEVICE, O_WRONLY, 0); else if (STRINGP (error_file)) { #ifdef DOS_NT - fd_error = open (XSTRING (error_file)->data, - O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, - S_IREAD | S_IWRITE); + fd_error = emacs_open (XSTRING (error_file)->data, + O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, + S_IREAD | S_IWRITE); #else /* not DOS_NT */ fd_error = creat (XSTRING (error_file)->data, 0666); #endif /* not DOS_NT */ @@ -514,11 +513,11 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") if (fd_error < 0) { - close (filefd); + emacs_close (filefd); if (fd[0] != filefd) - close (fd[0]); + emacs_close (fd[0]); if (fd1 >= 0) - close (fd1); + emacs_close (fd1); #ifdef MSDOS unlink (tempfile); #endif @@ -560,7 +559,10 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") synch_process_alive = 0; synch_process_retcode = pid; if (synch_process_retcode < 0) /* means it couldn't be exec'ed */ - synch_process_death = strerror (errno); + { + synchronize_messages_locale (); + synch_process_death = strerror (errno); + } /* Since CRLF is converted to LF within `decode_coding', we can always open a file with binary mode. */ @@ -585,19 +587,22 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") synch_process_alive = 0; synch_process_retcode = pid; if (synch_process_retcode < 0) /* means it couldn't be exec'ed */ - synch_process_death = strerror (errno); + { + synchronize_messages_locale (); + synch_process_death = strerror (errno); + } - close (outfilefd); + emacs_close (outfilefd); if (fd_error != outfilefd) - close (fd_error); + emacs_close (fd_error); fd1 = -1; /* No harm in closing that one! */ /* Since CRLF is converted to LF within `decode_coding', we can always open a file with binary mode. */ - fd[0] = open (tempfile, O_BINARY); + fd[0] = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); if (fd[0] < 0) { unlink (tempfile); - close (filefd); + emacs_close (filefd); report_file_error ("Cannot re-open temporary file", Qnil); } #else /* not MSDOS */ @@ -610,7 +615,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") if (pid == 0) { if (fd[0] >= 0) - close (fd[0]); + emacs_close (fd[0]); #ifdef HAVE_SETSID setsid (); #endif @@ -626,7 +631,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") /* The MSDOS case did this already. */ if (fd_error >= 0) - close (fd_error); + emacs_close (fd_error); #endif /* not MSDOS */ #endif /* not macintosh */ @@ -634,22 +639,22 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") /* Close most of our fd's, but not fd[0] since we will use that to read input from. */ - close (filefd); + emacs_close (filefd); if (fd1 >= 0 && fd1 != fd_error) - close (fd1); + emacs_close (fd1); } if (pid < 0) { if (fd[0] >= 0) - close (fd[0]); + emacs_close (fd[0]); report_file_error ("Doing vfork", Qnil); } if (INTEGERP (buffer)) { if (fd[0] >= 0) - close (fd[0]); + emacs_close (fd[0]); #ifndef subprocesses /* If Emacs has been built with asynchronous subprocess support, we don't need to do this, I think because it will then have @@ -737,7 +742,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") nread = carryover; while (nread < bufsize - 1024) { - int this_read = read (fd[0], bufptr + nread, bufsize - nread); + int this_read = emacs_read (fd[0], bufptr + nread, + bufsize - nread); if (this_read < 0) goto give_up; @@ -849,7 +855,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") unbind_to (count, Qnil); if (synch_process_death) - return build_string (synch_process_death); + return code_convert_string_norecord (build_string (synch_process_death), + Vlocale_coding_system, 0); return make_number (synch_process_retcode); } #endif @@ -1163,16 +1170,16 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) } #ifndef MSDOS - close (0); - close (1); - close (2); + emacs_close (0); + emacs_close (1); + emacs_close (2); dup2 (in, 0); dup2 (out, 1); dup2 (err, 2); - close (in); - close (out); - close (err); + emacs_close (in); + emacs_close (out); + emacs_close (err); #endif /* not MSDOS */ #endif /* not WINDOWSNT */ @@ -1212,9 +1219,9 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) environ = env; execvp (new_argv[0], new_argv); - write (1, "Can't exec program: ", 20); - write (1, new_argv[0], strlen (new_argv[0])); - write (1, "\n", 1); + emacs_write (1, "Can't exec program: ", 20); + emacs_write (1, new_argv[0], strlen (new_argv[0])); + emacs_write (1, "\n", 1); _exit (1); #endif /* not WINDOWSNT */ #endif /* not MSDOS */ @@ -1236,15 +1243,15 @@ relocate_fd (fd, minfd) char *message1 = "Error while setting up child: "; char *errmessage = strerror (errno); char *message2 = "\n"; - write (2, message1, strlen (message1)); - write (2, errmessage, strlen (errmessage)); - write (2, message2, strlen (message2)); + emacs_write (2, message1, strlen (message1)); + emacs_write (2, errmessage, strlen (errmessage)); + emacs_write (2, message2, strlen (message2)); _exit (1); } /* Note that we hold the original FD open while we recurse, to guarantee we'll get a new FD if we need it. */ new = relocate_fd (new, minfd); - close (fd); + emacs_close (fd); return new; } } diff --git a/src/ccl.c b/src/ccl.c index fb9fbf60e4..6a6876df7c 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -19,16 +19,14 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include - #ifdef emacs - #include - -#ifdef STDC_HEADERS -#include #endif +#include + +#ifdef emacs + #include "lisp.h" #include "charset.h" #include "ccl.h" diff --git a/src/charset.c b/src/charset.c index 61fdcf66ef..fefb2380de 100644 --- a/src/charset.c +++ b/src/charset.c @@ -22,12 +22,15 @@ Boston, MA 02111-1307, USA. */ /* At first, see the document in `charset.h' to understand the code in this file. */ +#ifdef emacs +#include +#endif + #include #ifdef emacs #include -#include #include "lisp.h" #include "buffer.h" #include "charset.h" diff --git a/src/coding.c b/src/coding.c index 4bf0b2aea8..1e75be5ab6 100644 --- a/src/coding.c +++ b/src/coding.c @@ -268,11 +268,14 @@ encode_coding_XXX (coding, source, destination, src_bytes, dst_bytes) /*** 1. Preamble ***/ +#ifdef emacs +#include +#endif + #include #ifdef emacs -#include #include "lisp.h" #include "buffer.h" #include "charset.h" @@ -357,6 +360,8 @@ Lisp_Object Vfile_coding_system_alist; Lisp_Object Vprocess_coding_system_alist; Lisp_Object Vnetwork_coding_system_alist; +Lisp_Object Vlocale_coding_system; + #endif /* emacs */ Lisp_Object Qcoding_category, Qcoding_category_index; @@ -5786,6 +5791,10 @@ or a cons of coding systems which are used as above.\n\ See also the function `find-operation-coding-system'."); Vnetwork_coding_system_alist = Qnil; + DEFVAR_LISP ("locale-coding-system", &Vlocale_coding_system, + "Coding system to use with system messages."); + Vlocale_coding_system = Qnil; + DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix, "*String displayed in mode line for UNIX-like (LF) end-of-line format."); eol_mnemonic_unix = build_string (":"); @@ -5853,4 +5862,24 @@ The default value is `select-safe-coding-system' (which see)."); } +char * +emacs_strerror (error_number) + int error_number; +{ + char *str; + + synchronize_messages_locale (); + str = strerror (error_number); + + if (! NILP (Vlocale_coding_system)) + { + Lisp_Object dec = code_convert_string_norecord (build_string (str), + Vlocale_coding_system, + 0); + str = (char *) XSTRING (dec)->data; + } + + return str; +} + #endif /* emacs */ diff --git a/src/coding.h b/src/coding.h index 7bbfdbd662..5ef9f2a08c 100644 --- a/src/coding.h +++ b/src/coding.h @@ -551,12 +551,16 @@ extern Lisp_Object Qfile_coding_system; extern Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; extern Lisp_Object Qstart_process, Qopen_network_stream; +extern char *emacs_strerror P_ ((int)); + /* Coding-system for reading files and receiving data from process. */ extern Lisp_Object Vcoding_system_for_read; /* Coding-system for writing files and sending data to process. */ extern Lisp_Object Vcoding_system_for_write; /* Coding-system actually used in the latest I/O. */ extern Lisp_Object Vlast_coding_system_used; +/* Coding-system to use with system messages (e.g. strerror). */ +extern Lisp_Object Vlocale_coding_system; /* If non-zero, process buffer inherits the coding system used to decode the subprocess output. */ diff --git a/src/config.in b/src/config.in index 6d1b2342f8..abf084ce73 100644 --- a/src/config.in +++ b/src/config.in @@ -1,5 +1,5 @@ /* GNU Emacs site configuration template file. -*- C -*- - Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1988, 1993, 1994, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -166,10 +166,11 @@ Boston, MA 02111-1307, USA. */ #undef HAVE_TERMIOS_H #undef HAVE_LIMITS_H #undef HAVE_STRING_H -#undef STDC_HEADERS -#undef TIME_WITH_SYS_TIME #undef HAVE_STDLIB_H #undef HAVE_TERMCAP_H +#undef HAVE_STDIO_EXT_H +#undef STDC_HEADERS +#undef TIME_WITH_SYS_TIME #undef HAVE_LIBDNET #undef HAVE_LIBPTHREADS @@ -226,6 +227,7 @@ Boston, MA 02111-1307, USA. */ #undef TM_IN_SYS_TIME #undef HAVE_TM_ZONE #undef HAVE_TZNAME +#undef HAVE_TM_GMTOFF #undef const @@ -270,6 +272,12 @@ Boston, MA 02111-1307, USA. */ #undef HAVE_SHUTDOWN #undef HAVE_STRFTIME #undef HAVE_GETADDRINFO +#undef HAVE___FPENDING +#undef HAVE_FTELLO +#undef HAVE_GETLOADAVG +#undef HAVE_MBLEN +#undef HAVE_MBRLEN +#undef HAVE_STRSIGNAL #undef LOCALTIME_CACHE #undef HAVE_INET_SOCKETS @@ -447,12 +455,19 @@ extern char *getenv (); #endif #ifndef BITS_PER_LONG +#ifdef _LP64 +#define BITS_PER_LONG 64 +#else #define BITS_PER_LONG 32 #endif +#endif -/* Don't include during configure. */ +/* Don't include "string.h" or in non-C code. */ #ifndef NOT_C_CODE #ifdef HAVE_STRING_H #include "string.h" #endif +#ifdef HAVE_STDLIB_H +#include +#endif #endif diff --git a/src/data.c b/src/data.c index 2c7e2298a5..ff361c87f0 100644 --- a/src/data.c +++ b/src/data.c @@ -1,5 +1,5 @@ /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. - Copyright (C) 1985,86,88,93,94,95,97, 1998 Free Software Foundation, Inc. + Copyright (C) 1985,86,88,93,94,95,97,98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,9 +19,8 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include - #include +#include #include #include "lisp.h" #include "puresize.h" @@ -38,7 +37,6 @@ Boston, MA 02111-1307, USA. */ #ifdef LISP_FLOAT_TYPE #ifdef STDC_HEADERS -#include #include #endif diff --git a/src/dired.c b/src/dired.c index d9c2ab0f86..ca762c360d 100644 --- a/src/dired.c +++ b/src/dired.c @@ -1,5 +1,5 @@ /* Lisp functions for making directory listings. - Copyright (C) 1985, 1986, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1985, 1986, 1993, 1994, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -25,6 +25,8 @@ Boston, MA 02111-1307, USA. */ #include #include +#include "systime.h" + #ifdef VMS #include #include @@ -790,7 +792,7 @@ If file does not exist, returns nil.") values[4] = make_time (s.st_atime); values[5] = make_time (s.st_mtime); values[6] = make_time (s.st_ctime); - values[7] = make_number ((int) s.st_size); + values[7] = make_number (s.st_size); /* If the size is out of range for an integer, return a float. */ if (XINT (values[7]) != s.st_size) values[7] = make_float ((double)s.st_size); @@ -822,7 +824,14 @@ If file does not exist, returns nil.") else /* But keep the most common cases as integers. */ values[10] = make_number (s.st_ino); - values[11] = make_number (s.st_dev); + + /* Likewise for device. */ + if (s.st_dev & (((EMACS_INT) (-1)) << VALBITS)) + values[11] = Fcons (make_number (s.st_dev >> 16), + make_number (s.st_dev & 0xffff)); + else + values[11] = make_number (s.st_dev); + return Flist (sizeof(values) / sizeof(values[0]), values); } diff --git a/src/dispnew.c b/src/dispnew.c index 54facf43aa..a92ee9159d 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -1,5 +1,5 @@ /* Updating of data structures for redisplay. - Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 1998 + Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,8 +19,8 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include +#include #include #include @@ -91,6 +91,10 @@ Boston, MA 02111-1307, USA. */ #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->__bufp - (FILE)->__buffer) #endif #else /* not __GNU_LIBRARY__ */ +#if !defined (PENDING_OUTPUT_COUNT) && HAVE_STDIO_EXT_H && HAVE___FPENDING +#include +#define PENDING_OUTPUT_COUNT(FILE) __fpending (FILE) +#endif #ifndef PENDING_OUTPUT_COUNT #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_ptr - (FILE)->_base) #endif diff --git a/src/doc.c b/src/doc.c index 7590054201..4378551059 100644 --- a/src/doc.c +++ b/src/doc.c @@ -1,5 +1,5 @@ /* Record indices of function doc strings stored in a file. - Copyright (C) 1985, 86, 93, 94, 95, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1985, 86,93,94,95,97,98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -161,7 +161,7 @@ get_doc_string (filepos, unibyte, definition) name = (char *) XSTRING (file)->data; } - fd = open (name, O_RDONLY, 0); + fd = emacs_open (name, O_RDONLY, 0); if (fd < 0) { #ifndef CANNOT_DUMP @@ -173,7 +173,7 @@ get_doc_string (filepos, unibyte, definition) strcat (name, XSTRING (file)->data); munge_doc_file_name (name); - fd = open (name, O_RDONLY, 0); + fd = emacs_open (name, O_RDONLY, 0); } #endif if (fd < 0) @@ -184,7 +184,7 @@ get_doc_string (filepos, unibyte, definition) offset = position % (8 * 1024); if (0 > lseek (fd, position - offset, 0)) { - close (fd); + emacs_close (fd); error ("Position %ld out of range in doc string file \"%s\"", position, name); } @@ -216,10 +216,10 @@ get_doc_string (filepos, unibyte, definition) If we read the same block last time, maybe skip this? */ if (space_left > 1024 * 8) space_left = 1024 * 8; - nread = read (fd, p, space_left); + nread = emacs_read (fd, p, space_left); if (nread < 0) { - close (fd); + emacs_close (fd); error ("Read error on documentation file"); } p[nread] = 0; @@ -237,7 +237,7 @@ get_doc_string (filepos, unibyte, definition) } p += nread; } - close (fd); + emacs_close (fd); /* Scan the text and perform quoting with ^A (char code 1). ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */ @@ -507,7 +507,7 @@ when doc strings are referred to later in the dumped Emacs.") #endif /* VMS4_4 */ #endif /* VMS */ - fd = open (name, O_RDONLY, 0); + fd = emacs_open (name, O_RDONLY, 0); if (fd < 0) report_file_error ("Opening doc string file", Fcons (build_string (name), Qnil)); @@ -517,7 +517,7 @@ when doc strings are referred to later in the dumped Emacs.") while (1) { if (filled < 512) - filled += read (fd, &buf[filled], sizeof buf - 1 - filled); + filled += emacs_read (fd, &buf[filled], sizeof buf - 1 - filled); if (!filled) break; @@ -557,7 +557,7 @@ when doc strings are referred to later in the dumped Emacs.") filled -= end - buf; bcopy (end, buf, filled); } - close (fd); + emacs_close (fd); return Qnil; } diff --git a/src/editfns.c b/src/editfns.c index a9c2b5f585..ae710dbff7 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -19,9 +19,8 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include - #include +#include #ifdef VMS #include "vms-pwd.h" @@ -29,10 +28,6 @@ Boston, MA 02111-1307, USA. */ #include #endif -#ifdef STDC_HEADERS -#include -#endif - #ifdef HAVE_UNISTD_H #include #endif @@ -41,6 +36,7 @@ Boston, MA 02111-1307, USA. */ #include "intervals.h" #include "buffer.h" #include "charset.h" +#include "coding.h" #include "window.h" #include "systime.h" @@ -57,7 +53,7 @@ extern Lisp_Object make_time (); extern void insert_from_buffer (); static int tm_diff (); static void update_buffer_properties (); -size_t emacs_strftime (); +size_t emacs_strftimeu (); void set_time_zone_rule (); Lisp_Object Vbuffer_access_fontify_functions; @@ -1174,27 +1170,29 @@ lisp_time_argument (specified_time, result) /* Write information into buffer S of size MAXSIZE, according to the FORMAT of length FORMAT_LEN, using time information taken from *TP. + Default to Universal Time if UT is nonzero, local time otherwise. Return the number of bytes written, not including the terminating '\0'. If S is NULL, nothing will be written anywhere; so to determine how many bytes would be written, use NULL for S and ((size_t) -1) for MAXSIZE. - This function behaves like emacs_strftime, except it allows null + This function behaves like emacs_strftimeu, except it allows null bytes in FORMAT. */ static size_t -emacs_memftime (s, maxsize, format, format_len, tp) +emacs_memftimeu (s, maxsize, format, format_len, tp, ut) char *s; size_t maxsize; const char *format; size_t format_len; const struct tm *tp; + int ut; { size_t total = 0; /* Loop through all the null-terminated strings in the format argument. Normally there's just one null-terminated string, but there can be arbitrarily many, concatenated together, if the - format contains '\0' bytes. emacs_strftime stops at the first + format contains '\0' bytes. emacs_strftimeu stops at the first '\0' byte so we must invoke it separately for each such string. */ for (;;) { @@ -1204,7 +1202,7 @@ emacs_memftime (s, maxsize, format, format_len, tp) if (s) s[0] = '\1'; - result = emacs_strftime (s, maxsize, format, tp); + result = emacs_strftimeu (s, maxsize, format, tp, ut); if (s) { @@ -1283,36 +1281,43 @@ DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, time_t value; int size; struct tm *tm; + int ut = ! NILP (universal); CHECK_STRING (format_string, 1); if (! lisp_time_argument (time, &value)) error ("Invalid time specification"); + format_string = code_convert_string_norecord (format_string, + Vlocale_coding_system, 1); + /* This is probably enough. */ size = STRING_BYTES (XSTRING (format_string)) * 6 + 50; - tm = NILP (universal) ? localtime (&value) : gmtime (&value); + tm = ut ? gmtime (&value) : localtime (&value); if (! tm) error ("Specified time is not representable"); + synchronize_time_locale (); + while (1) { char *buf = (char *) alloca (size + 1); int result; buf[0] = '\1'; - result = emacs_memftime (buf, size, XSTRING (format_string)->data, - STRING_BYTES (XSTRING (format_string)), - tm); + result = emacs_memftimeu (buf, size, XSTRING (format_string)->data, + STRING_BYTES (XSTRING (format_string)), + tm, ut); if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) - return make_string (buf, result); + return code_convert_string_norecord (make_string (buf, result), + Vlocale_coding_system, 0); /* If buffer was too small, make it bigger and try again. */ - result = emacs_memftime (NULL, (size_t) -1, - XSTRING (format_string)->data, - STRING_BYTES (XSTRING (format_string)), - tm); + result = emacs_memftimeu (NULL, (size_t) -1, + XSTRING (format_string)->data, + STRING_BYTES (XSTRING (format_string)), + tm, ut); size = result + 1; } } diff --git a/src/emacs.c b/src/emacs.c index 8d105289a9..4a52e2ee8d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1,5 +1,5 @@ /* Fully extensible Emacs, running on Unix, intended for GNU. - Copyright (C) 1985,86,87,93,94,95,97,1998 Free Software Foundation, Inc. + Copyright (C) 1985,86,87,93,94,95,97,98,1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,10 +19,9 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include - -#include #include #include @@ -40,10 +39,6 @@ Boston, MA 02111-1307, USA. */ #include #endif -#ifdef STDC_HEADERS -#include -#endif - #include "lisp.h" #include "commands.h" #include "intervals.h" @@ -56,6 +51,10 @@ Boston, MA 02111-1307, USA. */ #include "termhooks.h" #include "keyboard.h" +#ifdef HAVE_SETLOCALE +#include +#endif + #ifdef HAVE_SETRLIMIT #include #include @@ -128,6 +127,12 @@ Lisp_Object Vsystem_configuration_options; Lisp_Object Qfile_name_handler_alist; +/* Current and previous system locales for messages and time. */ +Lisp_Object Vmessages_locale; +Lisp_Object Vprevious_messages_locale; +Lisp_Object Vtime_locale; +Lisp_Object Vprevious_time_locale; + /* If non-zero, emacs should not attempt to use an window-specific code, but instead should use the virtual terminal under which it was started */ int inhibit_window_system; @@ -602,6 +607,7 @@ main (argc, argv, envp) char **envp; { char stack_bottom_variable; + int do_initial_setlocale; int skip_args = 0; extern int errno; extern int sys_nerr; @@ -785,6 +791,20 @@ main (argc, argv, envp) setuid (getuid ()); #endif /* SET_EMACS_PRIORITY */ + /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case. + The build procedure uses this while dumping, to ensure that the + dumped Emacs does not have its system locale tables initialized, + as that might cause screwups when the dumped Emacs starts up. */ + { + char *lc_all = getenv ("LC_ALL"); + do_initial_setlocale = ! lc_all || strcmp (lc_all, "C"); + } + + /* Set locale now, so that initial error messages are localized properly. + fixup_locale must wait until later, since it builds strings. */ + if (do_initial_setlocale) + setlocale (LC_ALL, ""); + #ifdef EXTRA_INITIALIZE EXTRA_INITIALIZE; #endif @@ -798,9 +818,9 @@ main (argc, argv, envp) if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) { int result; - close (0); - close (1); - result = open (term, O_RDWR, 2 ); + emacs_close (0); + emacs_close (1); + result = emacs_open (term, O_RDWR, 0); if (result < 0) { char *errstring = strerror (errno); @@ -994,6 +1014,14 @@ the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]); } init_alloc (); + + if (do_initial_setlocale) + { + fixup_locale (); + Vmessages_locale = Vprevious_messages_locale; + Vtime_locale = Vprevious_time_locale; + } + init_eval (); init_coding (); init_data (); @@ -1859,6 +1887,55 @@ You must run Emacs in batch mode in order to dump it.") #endif /* not CANNOT_DUMP */ +#if HAVE_SETLOCALE +/* Recover from setlocale (LC_ALL, ""). */ +void +fixup_locale () +{ + char *l; + + /* The Emacs Lisp reader needs LC_NUMERIC to be "C", + so that numbers are read and printed properly for Emacs Lisp. */ + setlocale (LC_NUMERIC, "C"); + +#ifdef LC_MESSAGES + l = setlocale (LC_MESSAGES, (char *) 0); + Vprevious_messages_locale = l ? build_string (l) : Qnil; +#endif + l = setlocale (LC_TIME, (char *) 0); + Vprevious_time_locale = l ? build_string (l) : Qnil; +} + +static void +synchronize_locale (category, plocale, desired_locale) + int category; + Lisp_Object *plocale; + Lisp_Object desired_locale; +{ + if (STRINGP (desired_locale) + && (NILP (*plocale) || NILP (Fstring_equal (*plocale, desired_locale))) + && setlocale (category, XSTRING (desired_locale)->data)) + *plocale = desired_locale; +} + +/* Set system time locale to match Vtime_locale, if possible. */ +void +synchronize_time_locale () +{ + synchronize_locale (LC_TIME, &Vprevious_time_locale, Vtime_locale); +} + +/* Set system messages locale to match Vmessages_locale, if possible. */ +void +synchronize_messages_locale () +{ +#ifdef LC_MESSAGES + synchronize_locale (LC_MESSAGES, &Vprevious_messages_locale, + Vmessages_locale); +#endif +} +#endif /* HAVE_SETLOCALE */ + #ifndef SEPCHAR #define SEPCHAR ':' #endif @@ -2003,4 +2080,20 @@ This is non-nil when we can't find those directories in their standard\n\ installed locations, but we can find them\n\ near where the Emacs executable was found."); Vinstallation_directory = Qnil; + + DEFVAR_LISP ("messages-locale", &Vmessages_locale, + "System locale for messages."); + Vmessages_locale = Qnil; + + DEFVAR_LISP ("previous-messages-locale", &Vprevious_messages_locale, + "Most recently used system locale for messages."); + Vprevious_messages_locale = Qnil; + + DEFVAR_LISP ("time-locale", &Vtime_locale, + "System locale for time."); + Vtime_locale = Qnil; + + DEFVAR_LISP ("previous-time-locale", &Vprevious_time_locale, + "Most recently used system locale for time."); + Vprevious_time_locale = Qnil; } diff --git a/src/eval.c b/src/eval.c index c879ecb7ec..59150df232 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1,5 +1,5 @@ /* Evaluator for GNU Emacs Lisp interpreter. - Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1985, 86, 87, 93, 94, 95, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -21,10 +21,6 @@ Boston, MA 02111-1307, USA. */ #include -#ifdef STDC_HEADERS -#include -#endif - #include "lisp.h" #include "blockinput.h" diff --git a/src/fileio.c b/src/fileio.c index 39927008d5..5a00649d79 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1,5 +1,5 @@ /* File IO for GNU Emacs. - Copyright (C) 1985,86,87,88,93,94,95,96,97,1998 Free Software Foundation, Inc. + Copyright (C) 1985,86,87,88,93,94,95,96,97,98,1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -32,10 +32,6 @@ Boston, MA 02111-1307, USA. */ #include #endif -#ifdef STDC_HEADERS -#include -#endif - #if !defined (S_ISLNK) && defined (S_IFLNK) # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) #endif @@ -253,7 +249,10 @@ report_file_error (string, data) Lisp_Object errstring; int errorno = errno; - errstring = build_string (strerror (errno)); + synchronize_messages_locale (); + errstring = code_convert_string_norecord (build_string (strerror (errorno)), + Vlocale_coding_system, 0); + while (1) switch (errorno) { @@ -275,7 +274,7 @@ Lisp_Object close_file_unwind (fd) Lisp_Object fd; { - close (XFASTINT (fd)); + emacs_close (XFASTINT (fd)); return Qnil; } @@ -2287,7 +2286,7 @@ A prefix arg makes KEEP-TIME non-nil.") else if (stat (XSTRING (encoded_newname)->data, &out_st) < 0) out_st.st_mode = 0; - ifd = open (XSTRING (encoded_file)->data, O_RDONLY); + ifd = emacs_open (XSTRING (encoded_file)->data, O_RDONLY, 0); if (ifd < 0) report_file_error ("Opening input file", Fcons (file, Qnil)); @@ -2339,13 +2338,13 @@ A prefix arg makes KEEP-TIME non-nil.") immediate_quit = 1; QUIT; - while ((n = read (ifd, buf, sizeof buf)) > 0) - if (write (ofd, buf, n) != n) + while ((n = emacs_read (ifd, buf, sizeof buf)) > 0) + if (emacs_write (ofd, buf, n) != n) report_file_error ("I/O error", Fcons (newname, Qnil)); immediate_quit = 0; /* Closing the output clobbers the file times on some systems. */ - if (close (ofd) < 0) + if (emacs_close (ofd) < 0) report_file_error ("I/O error", Fcons (newname, Qnil)); if (input_file_statable_p) @@ -2375,7 +2374,7 @@ A prefix arg makes KEEP-TIME non-nil.") #endif /* MSDOS */ } - close (ifd); + emacs_close (ifd); /* Discard the unwind protects. */ specpdl_ptr = specpdl + count; @@ -2914,10 +2913,10 @@ See also `file-exists-p' and `file-attributes'.") if (S_ISFIFO (statbuf.st_mode)) flags |= O_NONBLOCK; #endif - desc = open (XSTRING (absname)->data, flags); + desc = emacs_open (XSTRING (absname)->data, flags, 0); if (desc < 0) return Qnil; - close (desc); + emacs_close (desc); return Qt; #endif /* not DOS_NT */ } @@ -2983,10 +2982,10 @@ If there is no error, we return nil.") encoded_filename = ENCODE_FILE (filename); - fd = open (XSTRING (encoded_filename)->data, O_RDONLY); + fd = emacs_open (XSTRING (encoded_filename)->data, O_RDONLY, 0); if (fd < 0) report_file_error (XSTRING (string)->data, Fcons (filename, Qnil)); - close (fd); + emacs_close (fd); return Qnil; } @@ -3403,12 +3402,12 @@ actually used.") #ifndef APOLLO if (stat (XSTRING (filename)->data, &st) < 0) #else - if ((fd = open (XSTRING (filename)->data, O_RDONLY)) < 0 + if ((fd = emacs_open (XSTRING (filename)->data, O_RDONLY, 0)) < 0 || fstat (fd, &st) < 0) #endif /* not APOLLO */ #endif /* WINDOWSNT */ { - if (fd >= 0) close (fd); + if (fd >= 0) emacs_close (fd); badopen: if (NILP (visit)) report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); @@ -3438,7 +3437,7 @@ actually used.") #endif if (fd < 0) - if ((fd = open (XSTRING (filename)->data, O_RDONLY)) < 0) + if ((fd = emacs_open (XSTRING (filename)->data, O_RDONLY, 0)) < 0) goto badopen; /* Replacement should preserve point as it preserves markers. */ @@ -3470,7 +3469,13 @@ actually used.") if (! not_regular) { XSETINT (end, st.st_size); - if (XINT (end) != st.st_size) + + /* Arithmetic overflow can occur if an Emacs integer cannot + represent the file size, or if the calculations below + overflow. The calculations below double the file size + twice, so check that it can be multiplied by 4 safely. */ + if (XINT (end) != st.st_size + || ((int) st.st_size * 4) / 4 != st.st_size) error ("Maximum buffer size exceeded"); } } @@ -3503,22 +3508,22 @@ actually used.") int how_many, nread; if (st.st_size <= (1024 * 4)) - nread = read (fd, read_buf, 1024 * 4); + nread = emacs_read (fd, read_buf, 1024 * 4); else { - nread = read (fd, read_buf, 1024); + nread = emacs_read (fd, read_buf, 1024); if (nread >= 0) { if (lseek (fd, st.st_size - (1024 * 3), 0) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); - nread += read (fd, read_buf + nread, 1024 * 3); + nread += emacs_read (fd, read_buf + nread, 1024 * 3); } } if (nread < 0) error ("IO error reading %s: %s", - XSTRING (orig_filename)->data, strerror (errno)); + XSTRING (orig_filename)->data, emacs_strerror (errno)); else if (nread > 0) { int count = specpdl_ptr - specpdl; @@ -3618,10 +3623,10 @@ actually used.") { int nread, bufpos; - nread = read (fd, buffer, sizeof buffer); + nread = emacs_read (fd, buffer, sizeof buffer); if (nread < 0) error ("IO error reading %s: %s", - XSTRING (orig_filename)->data, strerror (errno)); + XSTRING (orig_filename)->data, emacs_strerror (errno)); else if (nread == 0) break; @@ -3660,7 +3665,7 @@ actually used.") there's no need to replace anything. */ if (same_at_start - BEGV_BYTE == XINT (end)) { - close (fd); + emacs_close (fd); specpdl_ptr--; /* Truncate the buffer to the size of the file. */ del_range_1 (same_at_start, same_at_end, 0); @@ -3689,10 +3694,10 @@ actually used.") total_read = 0; while (total_read < trial) { - nread = read (fd, buffer + total_read, trial - total_read); + nread = emacs_read (fd, buffer + total_read, trial - total_read); if (nread <= 0) error ("IO error reading %s: %s", - XSTRING (orig_filename)->data, strerror (errno)); + XSTRING (orig_filename)->data, emacs_strerror (errno)); total_read += nread; } /* Scan this bufferful from the end, comparing with @@ -3809,7 +3814,7 @@ actually used.") /* Allow quitting out of the actual I/O. */ immediate_quit = 1; QUIT; - this = read (fd, destination, trytry); + this = emacs_read (fd, destination, trytry); immediate_quit = 0; if (this < 0 || this + unprocessed == 0) @@ -3862,7 +3867,7 @@ actually used.") if (how_much == -1) error ("IO error reading %s: %s", - XSTRING (orig_filename)->data, strerror (errno)); + XSTRING (orig_filename)->data, emacs_strerror (errno)); else if (how_much == -2) error ("maximum buffer size exceeded"); } @@ -3881,7 +3886,7 @@ actually used.") if (bufpos == inserted) { xfree (conversion_buffer); - close (fd); + emacs_close (fd); specpdl_ptr--; /* Truncate the buffer to the size of the file. */ del_range_byte (same_at_start, same_at_end, 0); @@ -3946,7 +3951,7 @@ actually used.") inserted = PT - temp; free (conversion_buffer); - close (fd); + emacs_close (fd); specpdl_ptr--; goto handled; @@ -4003,7 +4008,8 @@ actually used.") /* Allow quitting out of the actual I/O. */ immediate_quit = 1; QUIT; - this = read (fd, BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1, trytry); + this = emacs_read (fd, BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1, + trytry); immediate_quit = 0; if (this <= 0) @@ -4034,14 +4040,14 @@ actually used.") /* Put an anchor to ensure multi-byte form ends at gap. */ *GPT_ADDR = 0; - close (fd); + emacs_close (fd); /* Discard the unwind protect for closing the file. */ specpdl_ptr--; if (how_much < 0) error ("IO error reading %s: %s", - XSTRING (orig_filename)->data, strerror (errno)); + XSTRING (orig_filename)->data, emacs_strerror (errno)); if (! coding_system_decided) { @@ -4496,9 +4502,9 @@ This does code conversion according to the value of\n\ desc = -1; if (!NILP (append)) #ifdef DOS_NT - desc = open (fn, O_WRONLY | buffer_file_type); + desc = emacs_open (fn, O_WRONLY | buffer_file_type, 0); #else /* not DOS_NT */ - desc = open (fn, O_WRONLY); + desc = emacs_open (fn, O_WRONLY, 0); #endif /* not DOS_NT */ if (desc < 0 && (NILP (append) || errno == ENOENT)) @@ -4506,7 +4512,7 @@ This does code conversion according to the value of\n\ if (auto_saving) /* Overwrite any previous version of autosave file */ { vms_truncate (fn); /* if fn exists, truncate to zero length */ - desc = open (fn, O_RDWR); + desc = emacs_open (fn, O_RDWR, 0); if (desc < 0) desc = creat_copy_attrs (STRINGP (current_buffer->filename) ? XSTRING (current_buffer->filename)->data : 0, @@ -4539,7 +4545,7 @@ This does code conversion according to the value of\n\ /* We can't make a new version; try to truncate and rewrite existing version if any. */ vms_truncate (fn); - desc = open (fn, O_RDWR); + desc = emacs_open (fn, O_RDWR, 0); } #endif } @@ -4549,14 +4555,14 @@ This does code conversion according to the value of\n\ } #else /* not VMS */ #ifdef DOS_NT - desc = open (fn, - O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type - | (mustbenew == Qexcl ? O_EXCL : 0), - S_IREAD | S_IWRITE); + desc = emacs_open (fn, + O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type + | (mustbenew == Qexcl ? O_EXCL : 0), + S_IREAD | S_IWRITE); #else /* not DOS_NT */ - desc = open (fn, O_WRONLY | O_TRUNC | O_CREAT - | (mustbenew == Qexcl ? O_EXCL : 0), - auto_saving ? auto_save_mode_bits : 0666); + desc = emacs_open (fn, O_WRONLY | O_TRUNC | O_CREAT + | (mustbenew == Qexcl ? O_EXCL : 0), + auto_saving ? auto_save_mode_bits : 0666); #endif /* not DOS_NT */ #endif /* not VMS */ @@ -4701,7 +4707,7 @@ This does code conversion according to the value of\n\ #endif /* NFS can report a write failure now. */ - if (close (desc) < 0) + if (emacs_close (desc) < 0) failure = 1, save_errno = errno; #ifdef VMS @@ -4735,7 +4741,7 @@ This does code conversion according to the value of\n\ if (failure) error ("IO error writing %s: %s", XSTRING (filename)->data, - strerror (save_errno)); + emacs_strerror (save_errno)); if (visiting) { @@ -4927,14 +4933,14 @@ e_write (desc, addr, nbytes, coding) nbytes -= coding->consumed, addr += coding->consumed; if (coding->produced > 0) { - coding->produced -= write (desc, buf, coding->produced); + coding->produced -= emacs_write (desc, buf, coding->produced); if (coding->produced) return -1; } if (result == CODING_FINISH_INSUFFICIENT_SRC) { /* The source text ends by an incomplete multibyte form. There's no way other than write it out as is. */ - nbytes -= write (desc, addr, nbytes); + nbytes -= emacs_write (desc, addr, nbytes); if (nbytes) return -1; } if (nbytes <= 0) diff --git a/src/filelock.c b/src/filelock.c index c08a8a41f5..66f347b479 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -19,14 +19,11 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include #include -#include #include -#ifdef HAVE_STDLIB_H -#include -#endif #ifdef VMS #include "vms-pwd.h" @@ -255,11 +252,11 @@ get_boot_time_1 (filename, newest) { /* On some versions of IRIX, opening a nonexistent file name is likely to crash in the utmp routines. */ - desc = open (filename, O_RDONLY); + desc = emacs_open (filename, O_RDONLY, 0); if (desc < 0) return; - close (desc); + emacs_close (desc); utmpname (filename); } diff --git a/src/floatfns.c b/src/floatfns.c index b989591cc8..ebe1b7de43 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -1,5 +1,5 @@ /* Primitive operations on floating point for GNU Emacs Lisp interpreter. - Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1988, 1993, 1994, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -44,9 +44,8 @@ Boston, MA 02111-1307, USA. */ a domain error occurs.) */ -#include - #include +#include #include "lisp.h" #include "syssignal.h" diff --git a/src/fns.c b/src/fns.c index 887e8f8c86..e5c3a2be42 100644 --- a/src/fns.c +++ b/src/fns.c @@ -4404,7 +4404,7 @@ DEFUN ("gethash", Fgethash, Sgethash, 2, 3, 0, "Look up KEY in TABLE and return its associated value.\n\ If KEY is not found, return DFLT which defaults to nil.") (key, table, dflt) - Lisp_Object key, table; + Lisp_Object key, table, dflt; { struct Lisp_Hash_Table *h = check_hash_table (table); int i = hash_lookup (h, key, NULL); diff --git a/src/frame.c b/src/frame.c index 2e2c7e50cd..e5f80fdea1 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1,5 +1,5 @@ /* Generic frame functions. - Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation. + Copyright (C) 1993, 1994, 1995, 1997, 1999 Free Software Foundation. This file is part of GNU Emacs. @@ -21,9 +21,6 @@ Boston, MA 02111-1307, USA. */ #include #include -#ifdef HAVE_STDLIB_H -#include -#endif #include "lisp.h" #include "charset.h" #ifdef HAVE_X_WINDOWS diff --git a/src/gmalloc.c b/src/gmalloc.c index 4f132391c7..b291903fa5 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -5,7 +5,7 @@ /* The malloc headers and source files from the C library follow here. */ /* Declarations for `malloc' and friends. - Copyright 1990, 91, 92, 93, 95, 96 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 95, 96, 99 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -44,8 +44,10 @@ Cambridge, MA 02139, USA. #else /* Not C++ or ANSI C. */ #undef PP #define PP(args) () +#ifndef HAVE_CONFIG_H #undef const #define const +#endif #undef __ptr_t #define __ptr_t char * #endif /* C++ or ANSI C. */ diff --git a/src/hftctl.c b/src/hftctl.c index 5fe816abbb..8a264a70a2 100644 --- a/src/hftctl.c +++ b/src/hftctl.c @@ -41,11 +41,9 @@ /* */ /***************************************************************/ +#include #include #include - -#include - #include #include #include @@ -102,7 +100,7 @@ static struct hfctlack ACK = /* read a buffer */ #define RD_BUF(f,p,l) \ while ((l)) \ - if ((j = read((f),(p),(l))) < 0) \ + if ((j = emacs_read (f, p, l)) < 0) \ if (errno != EINTR) return (-1); \ else continue; \ else { (l) -= j; (p) += j; } @@ -333,7 +331,7 @@ WR_REQ (fd, request, cmdlen, cmd, resplen) } /* write request to terminal */ - if (write(fd,p.c,size) == -1) return (-1); + if (emacs_write (fd, p.c, size) == -1) return (-1); if (p.req != &req) /* free if allocated */ xfree (p.c); return (0); diff --git a/src/insdel.c b/src/insdel.c index b4f6ac5a5a..6a4aa46d99 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1,5 +1,5 @@ /* Buffer insertion/deletion and gap motion for GNU Emacs. - Copyright (C) 1985, 86, 93, 94, 95, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1985, 86,93,94,95,97,98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,9 +20,6 @@ Boston, MA 02111-1307, USA. */ #include -#ifdef HAVE_STDLIB_H -#include -#endif #include "lisp.h" #include "intervals.h" #include "buffer.h" diff --git a/src/keyboard.c b/src/keyboard.c index 93f5ebbf2c..ab331cadcb 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,5 +1,5 @@ /* Keyboard and mouse input; editor command loop. - Copyright (C) 1985,86,87,88,89,93,94,95,96,97 Free Software Foundation, Inc. + Copyright (C) 1985,86,87,88,89,93,94,95,96,97,99 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,10 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Allow config.h to undefine symbols found here. */ -#include - #include +#include #include #include "termchar.h" #include "termopts.h" @@ -5572,7 +5570,7 @@ read_avail_input (expected) cbuf[0] = dos_keyread (); nread = 1; #else - nread = read (input_fd, cbuf, n_to_read); + nread = emacs_read (input_fd, cbuf, n_to_read); #endif /* POSIX infers that processes which are not in the session leader's process group won't get SIGHUP's at logout time. BSDI adheres to diff --git a/src/keymap.c b/src/keymap.c index e20e4fd79a..b4a1083ed5 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1,5 +1,5 @@ /* Manipulation of keymaps - Copyright (C) 1985, 86,87,88,93,94,95,98 Free Software Foundation, Inc. + Copyright (C) 1985, 86,87,88,93,94,95,98,99 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -21,9 +21,6 @@ Boston, MA 02111-1307, USA. */ #include #include -#ifdef STDC_HEADERS -#include -#endif #undef NULL #include "lisp.h" #include "commands.h" diff --git a/src/lisp.h b/src/lisp.h index d40a129830..e624523d35 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1,5 +1,5 @@ /* Fundamental definitions for GNU Emacs Lisp interpreter. - Copyright (C) 1985,86,87,93,94,95,97,1998 Free Software Foundation, Inc. + Copyright (C) 1985,86,87,93,94,95,97,98,1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -27,6 +27,15 @@ Boston, MA 02111-1307, USA. */ /* These are default choices for the types to use. */ +#ifdef _LP64 +#ifndef EMACS_INT +#define EMACS_INT long +#define BITS_PER_EMACS_INT BITS_PER_LONG +#endif +#ifndef EMACS_UINT +#define EMACS_UINT unsigned long +#endif +#else /* not _LP64 */ #ifndef EMACS_INT #define EMACS_INT int #define BITS_PER_EMACS_INT BITS_PER_INT @@ -34,6 +43,7 @@ Boston, MA 02111-1307, USA. */ #ifndef EMACS_UINT #define EMACS_UINT unsigned int #endif +#endif /* Define the fundamental Lisp data structures. */ @@ -98,7 +108,7 @@ enum Lisp_Misc_Type /* These values are overridden by the m- file on some machines. */ #ifndef VALBITS -#define VALBITS 28 +#define VALBITS (BITS_PER_EMACS_INT - 4) #endif #ifndef GCTYPEBITS @@ -212,7 +222,7 @@ Lisp_Object; rather than being part of a string block. */ #ifndef MARKBIT -#define MARKBIT ((int) ((unsigned int) 1 << (VALBITS + GCTYPEBITS))) +#define MARKBIT ((EMACS_INT) ((EMACS_UINT) 1 << (VALBITS + GCTYPEBITS))) #endif /*MARKBIT */ /* In the size word of a vector, this bit means the vector has been marked. @@ -278,7 +288,7 @@ enum pvec_type /* Extract the value of a Lisp_Object as a signed integer. */ #ifndef XINT /* Some machines need to do this differently. */ -#define XINT(a) (((a) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS)) +#define XINT(a) (((a) << (BITS_PER_EMACS_INT-VALBITS)) >> (BITS_PER_EMACS_INT-VALBITS)) #endif /* Extract the value as an unsigned integer. This is a basis @@ -1332,7 +1342,7 @@ typedef unsigned char UCHAR; /* Cast pointers to this type to compare them. Some machines want int. */ #ifndef PNTR_COMPARISON_TYPE -#define PNTR_COMPARISON_TYPE unsigned int +#define PNTR_COMPARISON_TYPE EMACS_UINT #endif /* Define a built-in function for calling from Lisp. @@ -1765,6 +1775,7 @@ EXFUN (Ffind_operation_coding_system, MANY); EXFUN (Fencode_coding_string, 3); EXFUN (Fdecode_coding_string, 3); extern Lisp_Object detect_coding_system P_ ((unsigned char *, int, int)); +Lisp_Object code_convert_string_norecord P_ ((Lisp_Object, Lisp_Object, int)); extern void init_coding P_ ((void)); extern void init_coding_once P_ ((void)); extern void syms_of_coding P_ ((void)); @@ -2506,6 +2517,16 @@ extern Lisp_Object decode_env_path P_ ((char *, char *)); extern Lisp_Object Vinvocation_name, Vinvocation_directory; extern Lisp_Object Vinstallation_directory; EXFUN (Fkill_emacs, 1); +#if HAVE_SETLOCALE +void fixup_locale P_ ((void)); +void synchronize_messages_locale P_ ((void)); +void synchronize_time_locale P_ ((void)); +#else +#define setlocale(category, locale) +#define fixup_locale() +#define synchronize_messages_locale() +#define synchronize_time_locale() +#endif void shut_down_emacs P_ ((int, int, Lisp_Object)); /* Nonzero means don't do interactive redisplay and don't change tty modes */ extern int noninteractive; @@ -2627,6 +2648,10 @@ extern int set_window_size P_ ((int, int, int)); extern void create_process P_ ((Lisp_Object, char **, Lisp_Object)); extern int tabs_safe_p P_ ((void)); extern void init_baud_rate P_ ((void)); +extern int emacs_open P_ ((char *, int, int)); +extern int emacs_close P_ ((int)); +extern int emacs_read P_ ((int, char *, unsigned int)); +extern int emacs_write P_ ((int, char *, unsigned int)); /* defined in filelock.c */ EXFUN (Funlock_buffer, 0); diff --git a/src/lread.c b/src/lread.c index c14554f5b3..e08b4ddcdc 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1,5 +1,5 @@ /* Lisp parsing and input streams. - Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 1998 + Copyright (C) 1985, 86, 87, 88, 89, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -58,10 +58,6 @@ Boston, MA 02111-1307, USA. */ #endif #ifdef LISP_FLOAT_TYPE -#ifdef STDC_HEADERS -#include -#endif - #include #endif /* LISP_FLOAT_TYPE */ @@ -73,6 +69,14 @@ Boston, MA 02111-1307, USA. */ #define O_RDONLY 0 #endif +#ifdef HAVE_FTELLO +#define file_offset off_t +#define file_tell ftello +#else +#define file_offset long +#define file_tell ftell +#endif + extern int errno; Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; @@ -156,7 +160,7 @@ static int saved_doc_string_size; /* Length of actual data in saved_doc_string. */ static int saved_doc_string_length; /* This is the file position that string came from. */ -static int saved_doc_string_position; +static file_offset saved_doc_string_position; /* This contains the previous string skipped with #@. We copy it from saved_doc_string when a new string @@ -167,7 +171,7 @@ static int prev_saved_doc_string_size; /* Length of actual data in prev_saved_doc_string. */ static int prev_saved_doc_string_length; /* This is the file position that string came from. */ -static int prev_saved_doc_string_position; +static file_offset prev_saved_doc_string_position; /* Nonzero means inside a new-style backquote with no surrounding parentheses. @@ -714,7 +718,7 @@ Return t if file exists.") if (!NILP (Vload_source_file_function)) { if (fd != 0) - close (fd); + emacs_close (fd); return call4 (Vload_source_file_function, found, file, NILP (noerror) ? Qnil : Qt, NILP (nomessage) ? Qnil : Qt); @@ -722,14 +726,14 @@ Return t if file exists.") } #ifdef WINDOWSNT - close (fd); + emacs_close (fd); stream = fopen ((char *) XSTRING (found)->data, fmode); #else /* not WINDOWSNT */ stream = fdopen (fd, fmode); #endif /* not WINDOWSNT */ if (stream == 0) { - close (fd); + emacs_close (fd); error ("Failure to create stdio stream for %s", XSTRING (file)->data); } @@ -817,7 +821,7 @@ close_load_descs () #ifndef WINDOWSNT Lisp_Object tail; for (tail = load_descriptor_list; !NILP (tail); tail = XCDR (tail)) - close (XFASTINT (XCAR (tail))); + emacs_close (XFASTINT (XCAR (tail))); #endif } @@ -966,7 +970,7 @@ openp (path, str, suffix, storeptr, exec_only) if (exec_only) fd = (access (fn, X_OK) == 0) ? 1 : -1; else - fd = open (fn, O_RDONLY, 0); + fd = emacs_open (fn, O_RDONLY, 0); if (fd >= 0) { @@ -1751,7 +1755,7 @@ read1 (readcharfun, pch, first_in_list) { char *temp = saved_doc_string; int temp_size = saved_doc_string_size; - int temp_pos = saved_doc_string_position; + file_offset temp_pos = saved_doc_string_position; int temp_len = saved_doc_string_length; saved_doc_string = prev_saved_doc_string; @@ -1777,7 +1781,7 @@ read1 (readcharfun, pch, first_in_list) saved_doc_string_size); } - saved_doc_string_position = ftell (instream); + saved_doc_string_position = file_tell (instream); /* Copy that many characters into saved_doc_string. */ for (i = 0; i < nskip && c >= 0; i++) @@ -3129,11 +3133,6 @@ init_lread () char *normal; int turn_off_warning = 0; -#ifdef HAVE_SETLOCALE - /* Make sure numbers are parsed as we expect. */ - setlocale (LC_NUMERIC, "C"); -#endif /* HAVE_SETLOCALE */ - /* Compute the default load-path. */ #ifdef CANNOT_DUMP normal = PATH_LOADSEARCH; diff --git a/src/mktime.c b/src/mktime.c index de5b47ddef..3b3330eea0 100644 --- a/src/mktime.c +++ b/src/mktime.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Convert a `struct tm' to a time_t value. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. Contributed by Paul Eggert (eggert@twinsun.com). NOTE: The canonical source of this file is maintained with the GNU C Library. @@ -27,14 +28,8 @@ # include #endif -/* Some systems need this in order to declare localtime_r properly. */ -#ifndef _REENTRANT -# define _REENTRANT 1 -#endif - #ifdef _LIBC # define HAVE_LIMITS_H 1 -# define HAVE_LOCALTIME_R 1 # define STDC_HEADERS 1 #endif @@ -62,7 +57,7 @@ #endif /* DEBUG */ #ifndef __P -# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +# if defined __GNUC__ || (defined __STDC__ && __STDC__) # define __P(args) args # else # define __P(args) () @@ -114,26 +109,15 @@ const unsigned short int __mon_yday[2][13] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; -static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *, - struct tm *)), - time_t *, struct tm *)); -static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); -time_t __mktime_internal __P ((struct tm *, - struct tm *(*) (const time_t *, struct tm *), - time_t *)); - #ifdef _LIBC -# define localtime_r __localtime_r +# define my_mktime_localtime_r __localtime_r #else -# if ! HAVE_LOCALTIME_R && ! defined localtime_r -/* Approximate localtime_r as best we can in its absence. */ -# define localtime_r my_mktime_localtime_r -static struct tm *localtime_r __P ((const time_t *, struct tm *)); +/* If we're a mktime substitute in a GNU program, then prefer + localtime to localtime_r, since many localtime_r implementations + are buggy. */ static struct tm * -localtime_r (t, tp) - const time_t *t; - struct tm *tp; +my_mktime_localtime_r (const time_t *t, struct tm *tp) { struct tm *l = localtime (t); if (! l) @@ -141,7 +125,6 @@ localtime_r (t, tp) *tp = *l; return tp; } -# endif /* ! HAVE_LOCALTIME_R && ! defined (localtime_r) */ #endif /* ! _LIBC */ @@ -152,9 +135,8 @@ localtime_r (t, tp) If TP is null, return a nonzero value. If overflow occurs, yield the low order bits of the correct answer. */ static time_t -ydhms_tm_diff (year, yday, hour, min, sec, tp) - int year, yday, hour, min, sec; - const struct tm *tp; +ydhms_tm_diff (int year, int yday, int hour, int min, int sec, + const struct tm *tp) { if (!tp) return 1; @@ -181,32 +163,12 @@ ydhms_tm_diff (year, yday, hour, min, sec, tp) } } - -static time_t localtime_offset; - -/* Convert *TP to a time_t value. */ -time_t -mktime (tp) - struct tm *tp; -{ -#ifdef _LIBC - /* POSIX.1 8.1.1 requires that whenever mktime() is called, the - time zone names contained in the external variable `tzname' shall - be set as if the tzset() function had been called. */ - __tzset (); -#endif - - return __mktime_internal (tp, localtime_r, &localtime_offset); -} - /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ static struct tm * -ranged_convert (convert, t, tp) - struct tm *(*convert) __P ((const time_t *, struct tm *)); - time_t *t; - struct tm *tp; +ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), + time_t *t, struct tm *tp) { struct tm *r; @@ -253,19 +215,18 @@ ranged_convert (convert, t, tp) compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. */ time_t -__mktime_internal (tp, convert, offset) - struct tm *tp; - struct tm *(*convert) __P ((const time_t *, struct tm *)); - time_t *offset; +__mktime_internal (struct tm *tp, + struct tm *(*convert) (const time_t *, struct tm *), + time_t *offset) { - time_t t, dt, t0; + time_t t, dt, t0, t1, t2; struct tm tm; /* The maximum number of probes (calls to CONVERT) should be enough to handle any combinations of time zone rule changes, solar time, - and leap seconds. POSIX.1 prohibits leap seconds, but some hosts - have them anyway. */ - int remaining_probes = 4; + leap seconds, and oscillations around a spring-forward gap. + POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ + int remaining_probes = 6; /* Time requested. Copy it in case CONVERT modifies *TP; this can occur if TP is localtime's returned value and CONVERT is localtime. */ @@ -311,36 +272,52 @@ __mktime_internal (tp, convert, offset) tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm); - for (t = t0 + *offset; + for (t = t1 = t2 = t0 + *offset; (dt = ydhms_tm_diff (year, yday, hour, min, sec, ranged_convert (convert, &t, &tm))); - t += dt) - if (--remaining_probes == 0) + t1 = t2, t2 = t, t += dt) + if (t == t1 && t != t2 + && (isdst < 0 || tm.tm_isdst < 0 + || (isdst != 0) != (tm.tm_isdst != 0))) + /* We can't possibly find a match, as we are oscillating + between two values. The requested time probably falls + within a spring-forward gap of size DT. Follow the common + practice in this case, which is to return a time that is DT + away from the requested time, preferring a time whose + tm_isdst differs from the requested value. In practice, + this is more useful than returning -1. */ + break; + else if (--remaining_probes == 0) return -1; - /* Check whether tm.tm_isdst has the requested value, if any. */ - if (0 <= isdst && 0 <= tm.tm_isdst) + /* If we have a match, check whether tm.tm_isdst has the requested + value, if any. */ + if (dt == 0 && isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst) { - int dst_diff = (isdst != 0) - (tm.tm_isdst != 0); - if (dst_diff) + /* tm.tm_isdst has the wrong value. Look for a neighboring + time with the right value, and use its UTC offset. + Heuristic: probe the previous three calendar quarters (approximately), + looking for the desired isdst. This isn't perfect, + but it's good enough in practice. */ + int quarter = 7889238; /* seconds per average 1/4 Gregorian year */ + int i; + + /* If we're too close to the time_t limit, look in future quarters. */ + if (t < TIME_T_MIN + 3 * quarter) + quarter = -quarter; + + for (i = 1; i <= 3; i++) { - /* Move two hours in the direction indicated by the disagreement, - probe some more, and switch to a new time if found. - The largest known fallback due to daylight savings is two hours: - once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */ - time_t ot = t - 2 * 60 * 60 * dst_diff; - while (--remaining_probes != 0) + time_t ot = t - i * quarter; + struct tm otm; + ranged_convert (convert, &ot, &otm); + if (otm.tm_isdst == isdst) { - struct tm otm; - if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec, - ranged_convert (convert, &ot, &otm)))) - { - t = ot; - tm = otm; - break; - } - if ((ot += dt) == t) - break; /* Avoid a redundant probe. */ + /* We found the desired tm_isdst. + Extrapolate back to the desired time. */ + t = ot + ydhms_tm_diff (year, yday, hour, min, sec, &otm); + ranged_convert (convert, &t, &tm); + break; } } } @@ -386,6 +363,24 @@ __mktime_internal (tp, convert, offset) return t; } + +static time_t localtime_offset; + +/* Convert *TP to a time_t value. */ +time_t +mktime (tp) + struct tm *tp; +{ +#ifdef _LIBC + /* POSIX.1 8.1.1 requires that whenever mktime() is called, the + time zone names contained in the external variable `tzname' shall + be set as if the tzset() function had been called. */ + __tzset (); +#endif + + return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); +} + #ifdef weak_alias weak_alias (mktime, timelocal) #endif @@ -530,6 +525,6 @@ main (argc, argv) /* Local Variables: -compile-command: "gcc -DDEBUG -D__EXTENSIONS__ -DHAVE_LIMITS_H -DHAVE_LOCALTIME_R -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime" +compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mktime.c -o mktime" End: */ diff --git a/src/msdos.c b/src/msdos.c index 1cea4af486..7b8d74da31 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -1,5 +1,5 @@ /* MS-DOS specific C utilities. -*- coding: raw-text -*- - Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -3654,9 +3654,9 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv) dup2 (inbak, 0); dup2 (outbak, 1); dup2 (errbak, 2); - close (inbak); - close (outbak); - close (errbak); + emacs_close (inbak); + emacs_close (outbak); + emacs_close (errbak); dos_ttraw (); if (have_mouse > 0) diff --git a/src/print.c b/src/print.c index 163c23cb8b..ad45035c7a 100644 --- a/src/print.c +++ b/src/print.c @@ -1,5 +1,5 @@ /* Lisp object printing and output streams. - Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 1998 + Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -60,7 +60,6 @@ Lisp_Object Vfloat_output_format, Qfloat_output_format; #if STDC_HEADERS #include -#include #endif /* Default to values appropriate for IEEE floating point. */ @@ -960,6 +959,19 @@ float_to_string (buf, data) /* Check for NaN in a way that won't fail if there are no NaNs. */ if (! (data * 0.0 >= 0.0)) { + /* Prepend "-" if the NaN's sign bit is negative. + The sign bit of a double is the bit that is 1 in -0.0. */ + int i; + union { double d; char c[sizeof (double)]; } u_data, u_minus_zero; + u_data.d = data; + u_minus_zero.d = - 0.0; + for (i = 0; i < sizeof (double); i++) + if (u_data.c[i] & u_minus_zero.c[i]) + { + *buf++ = '-'; + break; + } + strcpy (buf, "0.0e+NaN"); return; } diff --git a/src/process.c b/src/process.c index d2804763e3..144e69af7c 100644 --- a/src/process.c +++ b/src/process.c @@ -1,5 +1,5 @@ /* Asynchronous subprocess control for GNU Emacs. - Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 1998 + Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,10 +20,10 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include - #include +#include + /* This file is split into two parts by the following preprocessor conditional. The 'then' clause contains all of the support for asynchronous subprocesses. The 'else' clause contains stub @@ -155,6 +155,7 @@ extern char *sys_errlist[]; extern int h_errno; #endif +#ifndef HAVE_STRSIGNAL #ifndef SYS_SIGLIST_DECLARED #ifndef VMS #ifndef BSD4_1 @@ -196,6 +197,7 @@ char *sys_siglist[] = #endif #endif /* VMS */ #endif /* ! SYS_SIGLIST_DECLARED */ +#endif /* ! HAVE_STRSIGNAL */ /* t means use pty, nil means use a pipe, maybe other values to come. */ @@ -357,16 +359,9 @@ status_message (status) if (EQ (symbol, Qsignal) || EQ (symbol, Qstop)) { - char *signame = 0; - if (code < NSIG) - { -#ifndef VMS - /* Cast to suppress warning if the table has const char *. */ - signame = (char *) sys_siglist[code]; -#else - signame = sys_errlist[code]; -#endif - } + char *signame; + synchronize_messages_locale (); + signame = strsignal (code); if (signame == 0) signame = "unknown"; string = build_string (signame); @@ -426,7 +421,7 @@ allocate_pty () #else /* no PTY_OPEN */ #ifdef IRIS /* Unusual IRIS code */ - *ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0); + *ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0); if (fd < 0) return -1; if (fstat (fd, &stb) < 0) @@ -441,9 +436,9 @@ allocate_pty () else failed_count = 0; #ifdef O_NONBLOCK - fd = open (pty_name, O_RDWR | O_NONBLOCK, 0); + fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); #else - fd = open (pty_name, O_RDWR | O_NDELAY, 0); + fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); #endif #endif /* not IRIS */ #endif /* no PTY_OPEN */ @@ -460,7 +455,7 @@ allocate_pty () #ifndef UNIPLUS if (access (pty_name, 6) != 0) { - close (fd); + emacs_close (fd); #if !defined(IRIS) && !defined(__sgi) continue; #else @@ -1361,9 +1356,9 @@ create_process (process, new_argv, current_dir) #ifdef O_NOCTTY /* Don't let this terminal become our controlling terminal (in case we don't have one). */ - forkout = forkin = open (pty_name, O_RDWR | O_NOCTTY, 0); + forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); #else - forkout = forkin = open (pty_name, O_RDWR, 0); + forkout = forkin = emacs_open (pty_name, O_RDWR, 0); #endif if (forkin < 0) report_file_error ("Opening pty", Qnil); @@ -1392,8 +1387,8 @@ create_process (process, new_argv, current_dir) tem = pipe (sv); if (tem < 0) { - close (inchannel); - close (forkout); + emacs_close (inchannel); + emacs_close (forkout); report_file_error ("Creating pipe", Qnil); } outchannel = sv[1]; @@ -1592,7 +1587,7 @@ create_process (process, new_argv, current_dir) tcgetattr (xforkin, &t); t.c_lflag = LDISC1; if (tcsetattr (xforkin, TCSANOW, &t) < 0) - write (1, "create_process/tcsetattr LDISC1 failed\n", 39); + emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39); } #else #if defined (NTTYDISC) && defined (TIOCSETD) @@ -1611,9 +1606,9 @@ create_process (process, new_argv, current_dir) { /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? I can't test it since I don't have 4.3. */ - int j = open ("/dev/tty", O_RDWR, 0); + int j = emacs_open ("/dev/tty", O_RDWR, 0); ioctl (j, TIOCNOTTY, 0); - close (j); + emacs_close (j); #ifndef USG /* In order to get a controlling terminal on some versions of BSD, it is necessary to put the process in pgrp 0 @@ -1642,16 +1637,17 @@ create_process (process, new_argv, current_dir) int pgrp = getpid (); #endif - /* I wonder if close (open (pty_name, ...)) would work? */ + /* I wonder if emacs_close (emacs_open (pty_name, ...)) + would work? */ if (xforkin >= 0) - close (xforkin); - xforkout = xforkin = open (pty_name, O_RDWR, 0); + emacs_close (xforkin); + xforkout = xforkin = emacs_open (pty_name, O_RDWR, 0); if (xforkin < 0) { - write (1, "Couldn't open the pty terminal ", 31); - write (1, pty_name, strlen (pty_name)); - write (1, "\n", 1); + emacs_write (1, "Couldn't open the pty terminal ", 31); + emacs_write (1, pty_name, strlen (pty_name)); + emacs_write (1, "\n", 1); _exit (1); } @@ -1717,9 +1713,9 @@ create_process (process, new_argv, current_dir) if (pid < 0) { if (forkin >= 0) - close (forkin); + emacs_close (forkin); if (forkin != forkout && forkout >= 0) - close (forkout); + emacs_close (forkout); } else { @@ -1738,11 +1734,11 @@ create_process (process, new_argv, current_dir) alarm (1); XPROCESS (process)->subtty = Qnil; if (forkin >= 0) - close (forkin); + emacs_close (forkin); alarm (0); start_polling (); if (forkin != forkout && forkout >= 0) - close (forkout); + emacs_close (forkout); #ifdef HAVE_PTYS if (pty_flag) @@ -1926,7 +1922,7 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ ret = connect (s, lres->ai_addr, lres->ai_addrlen); if (ret == 0) break; - close (s); + emacs_close (s); s = -1; } @@ -2033,7 +2029,7 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ /* Discard the unwind protect. */ specpdl_ptr = specpdl + count1; - close (s); + emacs_close (s); if (interrupt_input) request_sigio (); @@ -2200,9 +2196,9 @@ deactivate_process (proc) give_back_vms_process_stuff (vs); } #else - close (inchannel); + emacs_close (inchannel); if (outchannel >= 0 && outchannel != inchannel) - close (outchannel); + emacs_close (outchannel); #endif XSETINT (p->infd, -1); @@ -2241,9 +2237,9 @@ close_process_descs () int in = XINT (XPROCESS (process)->infd); int out = XINT (XPROCESS (process)->outfd); if (in >= 0) - close (in); + emacs_close (in); if (out >= 0 && in != out) - close (out); + emacs_close (out); } } #endif @@ -2651,7 +2647,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) #endif } else - error ("select error: %s", strerror (xerrno)); + error ("select error: %s", emacs_strerror (xerrno)); } #if defined(sun) && !defined(USG5_4) else if (nfds > 0 && keyboard_bit_set (&Available) @@ -2955,13 +2951,13 @@ read_process_output (proc, channel) buf, carryover); if (proc_buffered_char[channel] < 0) - nbytes = read (channel, buf + carryover, (sizeof buf) - carryover); + nbytes = emacs_read (channel, buf + carryover, (sizeof buf) - carryover); else { buf[carryover] = proc_buffered_char[channel]; proc_buffered_char[channel] = -1; - nbytes = read (channel, buf + carryover + 1, - (sizeof buf) - carryover - 1); + nbytes = emacs_read (channel, buf + carryover + 1, + (sizeof buf) - carryover - 1); if (nbytes < 0) nbytes = 1; else @@ -3452,7 +3448,7 @@ send_process (proc, buf, len, object) while (this > 0) { old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); - rv = write (XINT (XPROCESS (proc)->outfd), buf, this); + rv = emacs_write (XINT (XPROCESS (proc)->outfd), buf, this); signal (SIGPIPE, old_sigpipe); if (rv < 0) @@ -4073,11 +4069,11 @@ text to PROCESS after you call this function.") shutdown (XINT (XPROCESS (proc)->outfd), 1); /* In case of socketpair, outfd == infd, so don't close it. */ if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) - close (XINT (XPROCESS (proc)->outfd)); + emacs_close (XINT (XPROCESS (proc)->outfd)); #else /* not HAVE_SHUTDOWN */ - close (XINT (XPROCESS (proc)->outfd)); + emacs_close (XINT (XPROCESS (proc)->outfd)); #endif /* not HAVE_SHUTDOWN */ - new_outfd = open (NULL_DEVICE, O_WRONLY); + new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); old_outfd = XINT (XPROCESS (proc)->outfd); if (!proc_encode_coding_system[new_outfd]) @@ -4256,17 +4252,11 @@ sigchld_handler (signo) else if (WIFSIGNALED (w)) { int code = WTERMSIG (w); - char *signame = 0; + char *signame; + + synchronize_messages_locale (); + signame = strsignal (code); - if (code < NSIG) - { -#ifndef VMS - /* Suppress warning if the table has const char *. */ - signame = (char *) sys_siglist[code]; -#else - signame = sys_errlist[code]; -#endif - } if (signame == 0) signame = "unknown"; @@ -4923,7 +4913,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) if (xerrno == EINTR) FD_ZERO (&waitchannels); else - error ("select error: %s", strerror (xerrno)); + error ("select error: %s", emacs_strerror (xerrno)); } #ifdef sun else if (nfds > 0 && (waitchannels & 1) && interrupt_input) diff --git a/src/search.c b/src/search.c index cbecadcdc0..df7b825edc 100644 --- a/src/search.c +++ b/src/search.c @@ -1,5 +1,5 @@ /* String search routines for GNU Emacs. - Copyright (C) 1985, 86, 87, 93, 94, 97, 1998 Free Software Foundation, Inc. + Copyright (C) 1985, 86,87,93,94,97,98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,9 +20,6 @@ Boston, MA 02111-1307, USA. */ #include -#ifdef STDC_HEADERS -#include -#endif #include "lisp.h" #include "syntax.h" #include "category.h" diff --git a/src/sound.c b/src/sound.c index 871833dba9..2909e8f0f3 100644 --- a/src/sound.c +++ b/src/sound.c @@ -1,5 +1,5 @@ /* sound.c -- sound support. - Copyright (C) 1998 Free Software Foundation. + Copyright (C) 1998, 1999 Free Software Foundation. This file is part of GNU Emacs. @@ -335,7 +335,7 @@ sound_cleanup (arg) { sound_device->close (sound_device); if (sound_file->fd > 0) - close (sound_file->fd); + emacs_close (sound_file->fd); } } @@ -378,7 +378,7 @@ DEFUN ("play-sound", Fplay_sound, Splay_sound, 1, 1, 0, sound_perror ("Open sound file"); /* Read the first bytes from the file. */ - nbytes = read (sf.fd, sf.header, MAX_SOUND_HEADER_BYTES); + nbytes = emacs_read (sf.fd, sf.header, MAX_SOUND_HEADER_BYTES); if (nbytes < 0) sound_perror ("Reading sound file header"); @@ -405,7 +405,7 @@ DEFUN ("play-sound", Fplay_sound, Splay_sound, 1, 1, 0, sd.open (&sd); sf.play (&sf, &sd); - close (sf.fd); + emacs_close (sf.fd); sf.fd = -1; sd.close (&sd); sound_device = NULL; @@ -557,7 +557,7 @@ wav_play (sf, sd) buffer = (char *) alloca (blksize); lseek (sf->fd, sizeof *header, SEEK_SET); - while ((nbytes = read (sf->fd, buffer, blksize)) > 0) + while ((nbytes = emacs_read (sf->fd, buffer, blksize)) > 0) sd->write (sd, buffer, nbytes); if (nbytes < 0) @@ -639,7 +639,7 @@ au_play (sf, sd) /* Copy sound data to the device. */ buffer = (char *) alloca (blksize); - while ((nbytes = read (sf->fd, buffer, blksize)) > 0) + while ((nbytes = emacs_read (sf->fd, buffer, blksize)) > 0) sd->write (sd, buffer, nbytes); if (nbytes < 0) @@ -671,7 +671,7 @@ vox_open (sd) else file = "/dev/dsp"; - sd->fd = open (file, O_WRONLY); + sd->fd = emacs_open (file, O_WRONLY, 0); if (sd->fd < 0) sound_perror (file); } @@ -731,7 +731,7 @@ vox_close (sd) ioctl (sd->fd, SNDCTL_DSP_RESET, NULL); /* Close the device. */ - close (sd->fd); + emacs_close (sd->fd); sd->fd = -1; } } @@ -805,7 +805,7 @@ vox_write (sd, buffer, nbytes) char *buffer; int nbytes; { - int nwritten = write (sd->fd, buffer, nbytes); + int nwritten = emacs_write (sd->fd, buffer, nbytes); if (nwritten < 0) sound_perror ("Writing to sound device"); } diff --git a/src/strftime.c b/src/strftime.c index ec6068a3b2..b89d324362 100644 --- a/src/strftime.c +++ b/src/strftime.c @@ -1,5 +1,4 @@ /* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc. - NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. @@ -14,19 +13,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include #endif -/* Some hosts need this in order to declare localtime_r properly. */ -#ifndef _REENTRANT -# define _REENTRANT 1 -#endif - #ifdef _LIBC # define HAVE_LIMITS_H 1 # define HAVE_MBLEN 1 @@ -136,7 +129,7 @@ extern char *tzname[]; add one for integer division truncation; add one more for a minus sign if t is signed. */ #define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 100 + 1 + TYPE_SIGNED (t)) + ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t)) #define TM_YEAR_BASE 1900 @@ -149,19 +142,20 @@ extern char *tzname[]; #ifdef _LIBC -# define gmtime_r __gmtime_r -# define localtime_r __localtime_r +# define my_strftime_gmtime_r __gmtime_r +# define my_strftime_localtime_r __localtime_r # define tzname __tzname # define tzset __tzset #else -# if ! HAVE_LOCALTIME_R -# if ! HAVE_TM_GMTOFF -/* Approximate gmtime_r as best we can in its absence. */ -# undef gmtime_r -# define gmtime_r my_gmtime_r -static struct tm *gmtime_r __P ((const time_t *, struct tm *)); + +/* If we're a strftime substitute in a GNU program, then prefer gmtime + to gmtime_r, since many gmtime_r implementations are buggy. + Similarly for localtime_r. */ + +# if ! HAVE_TM_GMTOFF +static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *)); static struct tm * -gmtime_r (t, tp) +my_strftime_gmtime_r (t, tp) const time_t *t; struct tm *tp; { @@ -171,14 +165,11 @@ gmtime_r (t, tp) *tp = *l; return tp; } -# endif /* ! HAVE_TM_GMTOFF */ +# endif /* ! HAVE_TM_GMTOFF */ -/* Approximate localtime_r as best we can in its absence. */ -# undef localtime_r -# define localtime_r my_ftime_localtime_r -static struct tm *localtime_r __P ((const time_t *, struct tm *)); +static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *)); static struct tm * -localtime_r (t, tp) +my_strftime_localtime_r (t, tp) const time_t *t; struct tm *tp; { @@ -188,7 +179,6 @@ localtime_r (t, tp) *tp = *l; return tp; } -# endif /* ! HAVE_LOCALTIME_R */ #endif /* ! defined _LIBC */ @@ -376,30 +366,38 @@ static char const month_name[][10] = #ifdef emacs -# define my_strftime emacs_strftime +# define my_strftime emacs_strftimeu +# define ut_argument , ut +# define ut_argument_spec int ut; +# define ut_argument_spec_iso , int ut #else # define my_strftime strftime +# define ut_argument +# define ut_argument_spec +# define ut_argument_spec_iso +/* We don't have this information in general. */ +# define ut 0 #endif #if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. Work around this bug by copying *tp before it might be munged. */ size_t _strftime_copytm __P ((char *, size_t, const char *, - const struct tm *)); + const struct tm * ut_argument_spec_iso)); size_t - my_strftime (s, maxsize, format, tp) + my_strftime (s, maxsize, format, tp ut_argument) char *s; size_t maxsize; const char *format; const struct tm *tp; + ut_argument_spec { struct tm tmcopy; tmcopy = *tp; - return _strftime_copytm (s, maxsize, format, &tmcopy); + return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument); } # undef my_strftime -# define my_strftime(S, Maxsize, Format, Tp) \ - _strftime_copytm (S, Maxsize, Format, Tp) +# define my_strftime _strftime_copytm #endif @@ -410,41 +408,44 @@ static char const month_name[][10] = anywhere, so to determine how many characters would be written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ size_t -my_strftime (s, maxsize, format, tp) +my_strftime (s, maxsize, format, tp ut_argument) char *s; size_t maxsize; const char *format; const struct tm *tp; + ut_argument_spec { int hour12 = tp->tm_hour; #ifdef _NL_CURRENT - const char *const a_wkday = _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday); - const char *const f_wkday = _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday); - const char *const a_month = _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon); - const char *const f_month = _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon); - const char *const ampm = _NL_CURRENT (LC_TIME, - hour12 > 11 ? PM_STR : AM_STR); - size_t aw_len = strlen (a_wkday); - size_t am_len = strlen (a_month); - size_t ap_len = strlen (ampm); + /* We cannot make the following values variables since we must delay + the evaluation of these values until really needed since some + expressions might not be valid in every situation. The `struct tm' + might be generated by a strptime() call that initialized + only a few elements. Dereference the pointers only if the format + requires this. Then it is ok to fail if the pointers are invalid. */ +# define a_wkday _NL_CURRENT (LC_TIME, ABDAY_1 + tp->tm_wday) +# define f_wkday _NL_CURRENT (LC_TIME, DAY_1 + tp->tm_wday) +# define a_month _NL_CURRENT (LC_TIME, ABMON_1 + tp->tm_mon) +# define f_month _NL_CURRENT (LC_TIME, MON_1 + tp->tm_mon) +# define ampm _NL_CURRENT (LC_TIME, tp->tm_hour > 11 ? PM_STR : AM_STR) + +# define aw_len strlen (a_wkday) +# define am_len strlen (a_month) +# define ap_len strlen (ampm) #else # if !HAVE_STRFTIME - const char *const f_wkday = weekday_name[tp->tm_wday]; - const char *const f_month = month_name[tp->tm_mon]; - const char *const a_wkday = f_wkday; - const char *const a_month = f_month; - const char *const ampm = "AMPM" + 2 * (hour12 > 11); +# define f_wkday (weekday_name[tp->tm_wday]) +# define f_month (month_name[tp->tm_mon]) +# define a_wkday f_wkday +# define a_month f_month +# define ampm ("AMPM" + 2 * (tp->tm_hour > 11)) + size_t aw_len = 3; size_t am_len = 3; size_t ap_len = 2; # endif -#endif -#if defined _NL_CURRENT || !HAVE_STRFTIME - size_t wkday_len = strlen (f_wkday); - size_t month_len = strlen (f_month); #endif const char *zone; - size_t zonelen; size_t i = 0; char *p = s; const char *f; @@ -460,25 +461,27 @@ my_strftime (s, maxsize, format, tp) zone = (const char *) tp->tm_zone; #endif #if HAVE_TZNAME - /* POSIX.1 8.1.1 requires that whenever strftime() is called, the - time zone names contained in the external variable `tzname' shall - be set as if the tzset() function had been called. */ + if (ut) + { + if (! (zone && *zone)) + zone = "GMT"; + } + else + { + /* POSIX.1 8.1.1 requires that whenever strftime() is called, the + time zone names contained in the external variable `tzname' shall + be set as if the tzset() function had been called. */ # if HAVE_TZSET - tzset (); + tzset (); # endif - - if (!(zone && *zone) && tp->tm_isdst >= 0) - zone = tzname[tp->tm_isdst]; + } #endif - if (! zone) - zone = ""; /* POSIX.2 requires the empty string here. */ - - zonelen = strlen (zone); if (hour12 > 12) hour12 -= 12; else - if (hour12 == 0) hour12 = 12; + if (hour12 == 0) + hour12 = 12; for (f = format; *f != '\0'; ++f) { @@ -544,7 +547,13 @@ my_strftime (s, maxsize, format, tp) if (bytes == 0) break; - if (bytes == (size_t) -2 || bytes == (size_t) -1) + if (bytes == (size_t) -2) + { + len += strlen (f + len); + break; + } + + if (bytes == (size_t) -1) { len++; break; @@ -555,6 +564,7 @@ my_strftime (s, maxsize, format, tp) while (! mbsinit (&mbstate)); cpy (len, f); + f += len - 1; continue; } } @@ -664,7 +674,7 @@ my_strftime (s, maxsize, format, tp) to_lowcase = 0; } #if defined _NL_CURRENT || !HAVE_STRFTIME - cpy (wkday_len, f_wkday); + cpy (strlen (f_wkday), f_wkday); break; #else goto underlying_strftime; @@ -690,7 +700,7 @@ my_strftime (s, maxsize, format, tp) to_lowcase = 0; } #if defined _NL_CURRENT || !HAVE_STRFTIME - cpy (month_len, f_month); + cpy (strlen (f_month), f_month); break; #else goto underlying_strftime; @@ -714,10 +724,9 @@ my_strftime (s, maxsize, format, tp) subformat: { char *old_start = p; - size_t len = my_strftime (NULL, maxsize - i, subfmt, tp); - if (len == 0 && *subfmt) - return 0; - add (len, my_strftime (p, maxsize - i, subfmt, tp)); + size_t len = my_strftime (NULL, (size_t) -1, subfmt, + tp ut_argument); + add (len, my_strftime (p, maxsize - i, subfmt, tp ut_argument)); if (to_uppcase) while (old_start < p) @@ -742,7 +751,6 @@ my_strftime (s, maxsize, format, tp) *u++ = modifier; *u++ = format_char; *u = '\0'; - ubuf[0] = '\1'; len = strftime (ubuf, sizeof ubuf, ufmt, tp); if (len == 0 && ubuf[0] != '\0') return 0; @@ -1033,7 +1041,6 @@ my_strftime (s, maxsize, format, tp) add (1, *p = '\t'); break; - case 'f': case 'u': /* POSIX.2 extension. */ DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); @@ -1142,7 +1149,16 @@ my_strftime (s, maxsize, format, tp) to_uppcase = 0; to_lowcase = 1; } - cpy (zonelen, zone); + +#if HAVE_TZNAME + /* The tzset() call might have changed the value. */ + if (!(zone && *zone) && tp->tm_isdst >= 0) + zone = tzname[tp->tm_isdst]; +#endif + if (! zone) + zone = ""; /* POSIX.2 requires the empty string here. */ + + cpy (strlen (zone), zone); break; case 'z': /* GNU extension. */ @@ -1154,34 +1170,39 @@ my_strftime (s, maxsize, format, tp) #if HAVE_TM_GMTOFF diff = tp->tm_gmtoff; #else - struct tm gtm; - struct tm ltm; - time_t lt; + if (ut) + diff = 0; + else + { + struct tm gtm; + struct tm ltm; + time_t lt; - ltm = *tp; - lt = mktime (<m); + ltm = *tp; + lt = mktime (<m); - if (lt == (time_t) -1) - { - /* mktime returns -1 for errors, but -1 is also a - valid time_t value. Check whether an error really - occurred. */ - struct tm tm; - - if (! localtime_r (<, &tm) - || ((ltm.tm_sec ^ tm.tm_sec) - | (ltm.tm_min ^ tm.tm_min) - | (ltm.tm_hour ^ tm.tm_hour) - | (ltm.tm_mday ^ tm.tm_mday) - | (ltm.tm_mon ^ tm.tm_mon) - | (ltm.tm_year ^ tm.tm_year))) - break; - } + if (lt == (time_t) -1) + { + /* mktime returns -1 for errors, but -1 is also a + valid time_t value. Check whether an error really + occurred. */ + struct tm tm; + + if (! my_strftime_localtime_r (<, &tm) + || ((ltm.tm_sec ^ tm.tm_sec) + | (ltm.tm_min ^ tm.tm_min) + | (ltm.tm_hour ^ tm.tm_hour) + | (ltm.tm_mday ^ tm.tm_mday) + | (ltm.tm_mon ^ tm.tm_mon) + | (ltm.tm_year ^ tm.tm_year))) + break; + } - if (! gmtime_r (<, >m)) - break; + if (! my_strftime_gmtime_r (<, >m)) + break; - diff = tm_diff (<m, >m); + diff = tm_diff (<m, >m); + } #endif if (diff < 0) @@ -1214,7 +1235,7 @@ my_strftime (s, maxsize, format, tp) } } - if (p) + if (p && maxsize != 0) *p = '\0'; return i; } diff --git a/src/sunfns.c b/src/sunfns.c index 504eed3d40..2c94af082b 100644 --- a/src/sunfns.c +++ b/src/sunfns.c @@ -1,5 +1,5 @@ /* Functions for Sun Windows menus and selection buffer. - Copyright (C) 1987 Free Software Foundation, Inc. + Copyright (C) 1987, 1999 Free Software Foundation, Inc. This file is probably totally obsolete. In any case, the FSF is unwilling to support it. We agreed to include it in our distribution @@ -120,7 +120,7 @@ or -1 if can not open it.") if ((! already_initialized) || (!NILP(force))) { cp = getenv("WINDOW_GFX"); - if (cp != 0) win_fd = open(cp, 2); + if (cp != 0) win_fd = emacs_open (cp, O_RDWR, 0); if (win_fd > 0) { Sun_Font = pf_default(); diff --git a/src/sysdep.c b/src/sysdep.c index 90a0ebdb48..1a3123d7ac 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1,5 +1,5 @@ /* Interfaces to system-dependent kernel and library entries. - Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc. + Copyright (C) 1985, 86,87,88,93,94,95, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,13 +19,10 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include -#include -#ifdef STDC_HEADERS -#include -#endif #include "lisp.h" #include "blockinput.h" #undef NULL @@ -50,18 +47,6 @@ Lisp_Object Vx_bitmap_file_path; #define min(x,y) ((x) > (y) ? (y) : (x)) -/* In this file, open, read and write refer to the system calls, - not our sugared interfaces sys_open, sys_read and sys_write. - Contrariwise, for systems where we use the system calls directly, - define sys_read, etc. here as aliases for them. */ -#ifndef read -#define sys_read read -#define sys_write write -#endif /* `read' is not a macro */ - -#undef read -#undef write - #ifdef WINDOWSNT #define read _read #define write _write @@ -69,18 +54,6 @@ Lisp_Object Vx_bitmap_file_path; extern int errno; #endif /* not WINDOWSNT */ -#ifndef close -#define sys_close close -#else -#undef close -#endif - -#ifndef open -#define sys_open open -#else /* `open' is a macro */ -#undef open -#endif /* `open' is a macro */ - /* Does anyone other than VMS need this? */ #ifndef fwrite #define sys_fwrite fwrite @@ -2710,25 +2683,6 @@ read_input_waiting () #endif /* not MSDOS */ #ifdef BSD4_1 -/* - * Partially emulate 4.2 open call. - * open is defined as this in 4.1. - * - * - added by Michael Bloom @ Citicorp/TTI - * - */ - -int -sys_open (path, oflag, mode) - char *path; - int oflag, mode; -{ - if (oflag & O_CREAT) - return creat (path, mode); - else - return open (path, oflag); -} - void init_sigio (fd) int fd; @@ -3093,27 +3047,25 @@ strerror (errnum) #endif /* not WINDOWSNT */ #endif /* ! HAVE_STRERROR */ -#ifdef INTERRUPTIBLE_OPEN - int -/* VARARGS 2 */ -sys_open (path, oflag, mode) +emacs_open (path, oflag, mode) char *path; int oflag, mode; { register int rtnval; + +#ifdef BSD4_1 + if (oflag & O_CREAT) + return creat (path, mode); +#endif while ((rtnval = open (path, oflag, mode)) == -1 && (errno == EINTR)); return (rtnval); } -#endif /* INTERRUPTIBLE_OPEN */ - -#ifdef INTERRUPTIBLE_CLOSE - int -sys_close (fd) +emacs_close (fd) int fd; { int did_retry = 0; @@ -3132,12 +3084,8 @@ sys_close (fd) return rtnval; } -#endif /* INTERRUPTIBLE_CLOSE */ - -#ifdef INTERRUPTIBLE_IO - int -sys_read (fildes, buf, nbyte) +emacs_read (fildes, buf, nbyte) int fildes; char *buf; unsigned int nbyte; @@ -3150,7 +3098,7 @@ sys_read (fildes, buf, nbyte) } int -sys_write (fildes, buf, nbyte) +emacs_write (fildes, buf, nbyte) int fildes; char *buf; unsigned int nbyte; @@ -3177,8 +3125,6 @@ sys_write (fildes, buf, nbyte) } return (bytes_written); } - -#endif /* INTERRUPTIBLE_IO */ #ifndef HAVE_VFORK #ifndef WINDOWSNT @@ -3210,6 +3156,7 @@ vfork () * always negligible. Fred Fish, Unisoft Systems Inc. */ +#ifndef HAVE_STRSIGNAL #ifndef HAVE_SYS_SIGLIST char *sys_siglist[NSIG + 1] = { @@ -3296,6 +3243,7 @@ char *sys_siglist[NSIG + 1] = 0 }; #endif /* HAVE_SYS_SIGLIST */ +#endif /* HAVE_STRSIGNAL */ /* * Warning, this function may not duplicate 4.2 action properly @@ -3384,12 +3332,10 @@ dup2 (oldd, newd) { register int fd, ret; - sys_close (newd); + emacs_close (newd); #ifdef F_DUPFD - fd = fcntl (oldd, F_DUPFD, newd); - if (fd != newd) - error ("can't dup2 (%i,%i) : %s", oldd, newd, strerror (errno)); + return fcntl (oldd, F_DUPFD, newd); #else fd = dup (old); if (fd == -1) @@ -3397,7 +3343,7 @@ dup2 (oldd, newd) if (fd == new) return new; ret = dup2 (old,new); - sys_close (fd); + emacs_close (fd); return ret; #endif } @@ -3452,6 +3398,7 @@ croak (badfunc) #ifdef DGUX +#ifndef HAVE_STRSIGNAL char *sys_siglist[NSIG + 1] = { "null signal", /* 0 SIGNULL */ @@ -3521,6 +3468,7 @@ char *sys_siglist[NSIG + 1] = "notification message in mess. queue", /* 64 SIGDGNOTIFY */ 0 }; +#endif /* HAVE_STRSIGNAL */ #endif /* DGUX */ @@ -3538,7 +3486,7 @@ closedir (dirp) { int rtnval; - rtnval = sys_close (dirp->dd_fd); + rtnval = emacs_close (dirp->dd_fd); /* Some systems (like Solaris) allocate the buffer and the DIR all in one block. Why in the world are we freeing this ourselves @@ -3563,7 +3511,7 @@ opendir (filename) register int fd; /* file descriptor for read */ struct stat sbuf; /* result of fstat */ - fd = sys_open (filename, 0); + fd = emacs_open (filename, O_RDONLY, 0); if (fd < 0) return 0; @@ -3572,7 +3520,7 @@ opendir (filename) || (sbuf.st_mode & S_IFMT) != S_IFDIR || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) { - sys_close (fd); + emacs_close (fd); UNBLOCK_INPUT; return 0; /* bad luck today */ } @@ -3588,7 +3536,7 @@ void closedir (dirp) register DIR *dirp; /* stream from opendir */ { - sys_close (dirp->dd_fd); + emacs_close (dirp->dd_fd); xfree ((char *) dirp); } @@ -3622,7 +3570,7 @@ readdir (dirp) dirp->dd_loc = dirp->dd_size = 0; if (dirp->dd_size == 0 /* refill buffer */ - && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) + && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) return 0; #ifndef VMS @@ -3775,7 +3723,7 @@ mkdir (dpath, dmode) */ status = umask (0); /* Get current umask */ status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ - fd = sys_open ("/dev/null", 2); + fd = emacs_open ("/dev/null", O_RDWR, 0); if (fd >= 0) { dup2 (fd, 0); @@ -3821,7 +3769,7 @@ rmdir (dpath) return (-1); /* Errno is set already */ case 0: /* Child process */ - fd = sys_open ("/dev/null", 2); + fd = emacs_open ("/dev/null", O_RDWR, 0); if (fd >= 0) { dup2 (fd, 0); @@ -4240,6 +4188,7 @@ sys_getuid () return (getgid () << 16) | getuid (); } +#undef read int sys_read (fildes, buf, nbyte) int fildes; @@ -4279,6 +4228,7 @@ sys_write (fildes, buf, nbyte) * Thus we do this stupidity below. */ +#undef write int sys_write (fildes, buf, nbytes) int fildes; @@ -5322,7 +5272,28 @@ bcmp (b1, b2, length) /* This could be a macro! */ } #endif /* no bcmp */ #endif /* not BSTRING */ + +#ifndef HAVE_STRSIGNAL +char * +strsignal (code) + int code; +{ + char *signame = 0; + + if (0 <= code && code < NSIG) + { +#ifdef VMS + signame = sys_errlist[code]; +#else + /* Cast to suppress warning if the table has const char *. */ + signame = (char *) sys_siglist[code]; +#endif + } + return signame; +} +#endif /* HAVE_STRSIGNAL */ + /* All the Macintosh stuffs go here */ #ifdef macintosh @@ -5502,10 +5473,10 @@ Unix2MacPathname (const char *ufn, char *mfn, int mfnbuflen) /* Define our own stat function for both MrC and CW. The reason for doing this: "stat" is both the name of a struct and function name: - can't use the same trick like that for sys_open, sys_close, etc. to + we can't #define stat to something else to redirect Emacs's calls to our own version that converts Unix style filenames to Mac style filename because all sorts of compilation - errors will be generated if stat is #define'd to be sys_stat. */ + errors will be generated if stat is #define'd to be something else. */ int stat (const char *path, struct stat *buf) diff --git a/src/syssignal.h b/src/syssignal.h index 868cfb7c71..66e6ffa61f 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -1,5 +1,5 @@ /* syssignal.h - System-dependent definitions for signals. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -123,6 +123,29 @@ sigset_t sys_sigsetmask P_ ((sigset_t new_mask)); #define sigfree() sigsetmask (SIGEMPTYMASK) #endif /* not BSD4_1 */ +#if defined (SIGINFO) && defined (BROKEN_SIGINFO) +#undef SIGINFO +#endif +#if defined (SIGIO) && defined (BROKEN_SIGIO) +#undef SIGIO +#endif +#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) +#undef SIGPOLL +#endif +#if defined (SIGTSTP) && defined (BROKEN_SIGTSTP) +#undef SIGTSTP +#endif +#if defined (SIGURG) && defined (BROKEN_SIGURG) +#undef SIGURG +#endif + +#if NSIG < NSIG_MINIMUM +# ifdef NSIG +# undef NSIG +# endif +# define NSIG NSIG_MINIMUM +#endif + #ifdef BSD4_1 #define SIGIO SIGTINT /* sigfree is in sysdep.c */ @@ -149,3 +172,8 @@ sigset_t sys_sigsetmask P_ ((sigset_t new_mask)); #endif /* SIGCHLD */ #endif /* ! defined (SIGCLD) */ #endif /* VMS */ + +#ifndef HAVE_STRSIGNAL +/* strsignal is in sysdep.c */ +char *strsignal (); +#endif diff --git a/src/unexelf.c b/src/unexelf.c index 015522638f..804e86b45e 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992 +/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -412,6 +412,13 @@ Filesz Memsz Flags Align */ +#ifndef emacs +#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) +#else +#include +extern void fatal (char *, ...); +#endif + #include #include #include @@ -517,17 +524,18 @@ typedef struct { #ifndef ElfW # ifdef __STDC__ -# define ElfW(type) Elf32_##type +# define ElfBitsW(bits, type) Elf##bits##_##type # else -# define ElfW(type) Elf32_/**/type +# define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type # endif -#endif - -#ifndef emacs -#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) -#else -#include -extern void fatal (char *, ...); +# ifdef _LP64 +# define ELFSIZE 64 +# else +# define ELFSIZE 32 +# endif + /* This macro expands `bits' before invoking ElfBitsW. */ +# define ElfExpandBitsW(bits, type) ElfBitsW (bits, type) +# define ElfW(type) ElfExpandBitsW (ELFSIZE, type) #endif #ifndef ELF_BSS_SECTION_NAME diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c index f33340c4d8..686a1ed1eb 100644 --- a/src/unexhp9k800.c +++ b/src/unexhp9k800.c @@ -37,16 +37,16 @@ sigsetreturn (_sigreturn); */ +#ifdef emacs +#include +#endif + #include #include #include #include -#ifdef emacs -#include -#endif - #ifdef HPUX_USE_SHLIBS #include #endif diff --git a/src/unexsunos4.c b/src/unexsunos4.c index bdc2033628..76480db9b3 100644 --- a/src/unexsunos4.c +++ b/src/unexsunos4.c @@ -1,5 +1,5 @@ /* Unexec for Sunos 4 using shared libraries. - Copyright (C) 1990, 1994 Free Software Foundation, Inc. + Copyright (C) 1990, 1994, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -43,6 +43,11 @@ Boston, MA 02111-1307, USA. */ * is somewhat abused here) is loaded first! * */ + +#ifdef emacs +#include +#endif + #include #include #include @@ -51,12 +56,6 @@ Boston, MA 02111-1307, USA. */ #include #include -/* Do this after the above #include's in case a configuration file wants - to define things for this file based on what defines. */ -#ifdef emacs -#include -#endif - #if defined (SUNOS4) || defined (__FreeBSD__) || defined (__NetBSD__) #define UNDO_RELOCATION #endif diff --git a/src/vmsfns.c b/src/vmsfns.c index 716ba21def..fe79ebee30 100644 --- a/src/vmsfns.c +++ b/src/vmsfns.c @@ -1,5 +1,5 @@ /* VMS subprocess and command interface. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. + Copyright (C) 1987, 1988, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -56,11 +56,11 @@ Boston, MA 02111-1307, USA. */ #ifdef VMS +#include #include #include #undef NULL -#include #include "lisp.h" #include #include diff --git a/src/vmsgmalloc.c b/src/vmsgmalloc.c index a3545f5eb0..93a3fd7f8b 100644 --- a/src/vmsgmalloc.c +++ b/src/vmsgmalloc.c @@ -5,7 +5,7 @@ /* The malloc headers and source files from the C library follow here. */ /* Declarations for `malloc' and friends. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright 1990, 1991, 1992, 1993, 1999 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This file is part of GNU Emacs. @@ -57,6 +57,10 @@ extern "C" #define NULL 0 #endif +#if defined (HAVE_CONFIG_H) || defined (emacs) +#include +#endif + #ifdef __STDC__ #include #else @@ -105,10 +109,6 @@ extern void __vms_free __P ((__ptr_t __ptr)); #include /* Harmless, gets __GNU_LIBRARY__ defined. */ -#if defined(HAVE_CONFIG_H) || defined(emacs) -#include -#endif - #if defined(__GNU_LIBRARY__) || defined(STDC_HEADERS) || defined(USG) #include #else diff --git a/src/w32faces.c b/src/w32faces.c index 61aeee1779..1a13c28f11 100644 --- a/src/w32faces.c +++ b/src/w32faces.c @@ -1,5 +1,5 @@ /* "Face" primitives on the Microsoft W32 API. - Copyright (C) 1993, 1994, 1995 Free Software Foundation. + Copyright (C) 1993, 1994, 1995, 1999 Free Software Foundation. This file is part of GNU Emacs. @@ -20,10 +20,10 @@ Boston, MA 02111-1307, USA. */ /* Ported xfaces.c for w32 - Kevin Gallo */ +#include #include #include -#include #include "lisp.h" #include "w32term.h" diff --git a/src/w32menu.c b/src/w32menu.c index aa3ef60d12..c93c589f07 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -1,5 +1,5 @@ /* Menu support for GNU Emacs on the Microsoft W32 API. - Copyright (C) 1986, 1988, 1993, 1994, 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1986, 88, 93, 94, 96, 98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,9 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include - +#include #include #include "lisp.h" #include "termhooks.h" diff --git a/src/w32proc.c b/src/w32proc.c index c64918c5bd..8a188015d8 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1,5 +1,5 @@ /* Process support for GNU Emacs on the Microsoft W32 API. - Copyright (C) 1992, 1995 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -91,10 +91,6 @@ Lisp_Object Vw32_get_true_file_attributes; Lisp_Object Qhigh, Qlow; -#ifndef SYS_SIGLIST_DECLARED -extern char *sys_siglist[]; -#endif - #ifdef EMACSDEBUG void _DebPrint (const char *fmt, ...) { @@ -546,13 +542,11 @@ get_result: else if (WIFSIGNALED (retval)) { int code = WTERMSIG (retval); - char *signame = 0; - - if (code < NSIG) - { - /* Suppress warning if the table has const char *. */ - signame = (char *) sys_siglist[code]; - } + char *signame; + + synchronize_messages_locale (); + signame = strsignal (code); + if (signame == 0) signame = "unknown"; diff --git a/src/w32term.c b/src/w32term.c index ac7a173feb..cc71e411a0 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1,5 +1,5 @@ /* Implementation of GUI terminal on the Microsoft W32 API. - Copyright (C) 1989, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1989, 93,94,95,96,97,98, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,8 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include +#include #include #include "lisp.h" #include "charset.h" diff --git a/src/w32xfns.c b/src/w32xfns.c index 617eec7841..df3984eb4b 100644 --- a/src/w32xfns.c +++ b/src/w32xfns.c @@ -1,5 +1,5 @@ /* Functions taken directly from X sources for use with the Microsoft W32 API. - Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation. + Copyright (C) 1989, 1992, 1993, 1994, 1995, 1999 Free Software Foundation. This file is part of GNU Emacs. @@ -18,8 +18,8 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include +#include #include #include "lisp.h" #include "frame.h" diff --git a/src/xdisp.c b/src/xdisp.c index 15ec41adf0..ebfe075d17 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -169,9 +169,6 @@ Boston, MA 02111-1307, USA. */ #include #include -#ifdef STDC_HEADERS -#include -#endif #include "lisp.h" #include "frame.h" #include "window.h" @@ -628,7 +625,7 @@ static void display_mode_lines P_ ((struct window *)); static void display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object)); -static char *decode_mode_spec P_ ((struct window *, char, int, int)); +static char *decode_mode_spec P_ ((struct window *, int, int, int)); static void display_menu_bar P_ ((struct window *)); static int display_count_lines P_ ((int, int, int, int, int *)); static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, @@ -11883,7 +11880,7 @@ static char lots_of_dashes[] = "------------------------------------------------ static char * decode_mode_spec (w, c, field_width, precision) struct window *w; - register char c; + register int c; int field_width, precision; { Lisp_Object obj; @@ -12379,6 +12376,8 @@ display_string (string, lisp_string, face_string, face_string_pos, start, it, field_width, precision, max_x, multibyte) unsigned char *string; Lisp_Object lisp_string; + Lisp_Object face_string; + int face_string_pos; int start; struct it *it; int field_width, precision, max_x; diff --git a/src/xfaces.c b/src/xfaces.c index 7e1c0799e7..52b9f1b584 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -177,9 +177,9 @@ Boston, MA 02111-1307, USA. */ #define SCALABLE_FONTS 1 +#include #include #include -#include #include "lisp.h" #include "charset.h" #include "frame.h" @@ -223,7 +223,6 @@ Boston, MA 02111-1307, USA. */ #endif /* HAVE_X_WINDOWS */ #include -#include #include #include "keyboard.h" diff --git a/src/xfns.c b/src/xfns.c index eee9b919ee..77615a78ac 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -27,8 +27,8 @@ Boston, MA 02111-1307, USA. */ /* Rewritten for X11 by Joseph Arceneaux */ -#include #include +#include #include #include @@ -52,9 +52,7 @@ Boston, MA 02111-1307, USA. */ #ifdef HAVE_X_WINDOWS -#ifdef STDC_HEADERS -#include -#else +#ifndef STDC_HEADERS extern void abort (); #endif #include @@ -667,7 +665,7 @@ x_create_bitmap_from_file (f, file) /* XReadBitmapFile won't handle magic file names. */ if (fd == 0) return -1; - close (fd); + emacs_close (fd); filename = (char *) XSTRING (found)->data; @@ -9761,7 +9759,7 @@ used to change the tooltip's appearance.\n\ Automatically hide the tooltip after TIMEOUT seconds.\n\ TIMEOUT nil means use the default timeout of 5 seconds.") (string, frame, parms, timeout) - Lisp_Object string, frame, parms; + Lisp_Object string, frame, parms, timeout; { struct frame *f; struct window *w; diff --git a/src/xmenu.c b/src/xmenu.c index e5fffdaef5..a9bda2154d 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1,5 +1,5 @@ /* X Communication module for terminals which understand the X protocol. - Copyright (C) 1986, 1988, 1993, 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1986, 88, 93, 94, 96, 1999 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -30,12 +30,10 @@ Boston, MA 02111-1307, USA. */ /* Rewritten for clarity and GC protection by rms in Feb 94. */ +#include + /* On 4.3 this loses if it comes after xterm.h. */ #include -#include -#ifdef HAVE_STDLIB_H -#include -#endif #include #include "lisp.h" diff --git a/src/xterm.c b/src/xterm.c index 2c671ffced..e2f7850829 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -22,17 +22,13 @@ Boston, MA 02111-1307, USA. */ /* New display code by Gerd Moellmann . */ /* Xt features made by Fred Pierresteguy. */ +#include + /* On 4.3 these lose if they come after xterm.h. */ -/* On HP-UX 8.0 signal.h loses if it comes after config.h. */ /* Putting these at the beginning seems to be standard for other .c files. */ #include -#include - #include -#ifdef STDC_HEADERS -#include -#endif #ifdef HAVE_X_WINDOWS @@ -145,11 +141,6 @@ extern void _XEditResCheckMessages (); #endif #endif -#ifdef HAVE_SETLOCALE -/* So we can do setlocale. */ -#include -#endif - #ifdef SOLARIS2 /* memmove will be defined as a macro in Xfuncs.h unless is included beforehand. The declaration for memmove in @@ -2157,9 +2148,9 @@ static void x_get_glyph_overhangs P_ ((struct glyph *, struct frame *, int *, int *)); static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int)); static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap, - unsigned long *, float, int)); + unsigned long *, double, int)); static void x_setup_relief_color P_ ((struct frame *, struct relief *, - float, int, unsigned long)); + double, int, unsigned long)); static void x_setup_relief_colors P_ ((struct glyph_string *)); static void x_draw_image_glyph_string P_ ((struct glyph_string *)); static void x_draw_image_relief P_ ((struct glyph_string *)); @@ -3049,7 +3040,7 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta) Display *display; Colormap cmap; unsigned long *pixel; - float factor; + double factor; int delta; { XColor color, new; @@ -3108,7 +3099,7 @@ static void x_setup_relief_color (f, relief, factor, delta, default_pixel) struct frame *f; struct relief *relief; - float factor; + double factor; int delta; unsigned long default_pixel; { @@ -12392,28 +12383,6 @@ same_x_server (name1, name2) } #endif -#if defined (HAVE_X_I18N) || (defined (USE_X_TOOLKIT) && defined (HAVE_X11XTR6)) -/* Recover from setlocale (LC_ALL, ""). */ -static void -fixup_locale () -{ - /* Currently we require strerror to use the "C" locale, - since we don't yet support decoding its string result. */ -#ifdef LC_MESSAGES - setlocale (LC_MESSAGES, "C"); -#endif - - /* The Emacs Lisp reader needs LC_NUMERIC to be "C", - so that numbers are read and printed properly for Emacs Lisp. */ - setlocale (LC_NUMERIC, "C"); - - /* Currently we require strftime to use the "C" locale, - since we don't yet support encoding its format argument, - or decoding its string result. */ - setlocale (LC_TIME, "C"); -} -#endif - struct x_display_info * x_term_init (display_name, xrm_option, resource_name) Lisp_Object display_name; @@ -12433,11 +12402,6 @@ x_term_init (display_name, xrm_option, resource_name) x_initialized = 1; } -#ifdef HAVE_X_I18N - setlocale (LC_ALL, ""); - fixup_locale (); -#endif - #ifdef USE_X_TOOLKIT /* weiner@footloose.sps.mot.com reports that this causes errors with X11R5: -- 2.20.1