X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4fc5845fe896177307f553d8af0d48834206c060..14b6e3bb481f4cb48f397c50ae8116b6fc39c937:/src/w32proc.c diff --git a/src/w32proc.c b/src/w32proc.c index 0e3f8f2fd4..7d27172781 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1,5 +1,6 @@ /* Process support for GNU Emacs on the Microsoft W32 API. - Copyright (C) 1992, 95, 99, 2000, 01, 04 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -48,6 +49,11 @@ Boston, MA 02110-1301, USA. extern BOOL WINAPI IsValidLocale(LCID, DWORD); #endif +#ifdef HAVE_LANGINFO_CODESET +#include +#include +#endif + #include "lisp.h" #include "w32.h" #include "w32heap.h" @@ -279,7 +285,10 @@ reader_thread (void *arg) { int rc; - rc = _sys_read_ahead (cp->fd); + if (fd_info[cp->fd].flags & FILE_LISTEN) + rc = _sys_wait_accept (cp->fd); + else + rc = _sys_read_ahead (cp->fd); /* The name char_avail is a misnomer - it really just means the read-ahead has completed, whether successfully or not. */ @@ -477,7 +486,8 @@ sys_wait (int *status) { for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--) /* some child_procs might be sockets; ignore them */ - if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess) + if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess + && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)) { wait_hnd[nh] = cp->procinfo.hProcess; cps[nh] = cp; @@ -1813,6 +1823,69 @@ If successful, the return value is t, otherwise nil. */) return result; } +#ifdef HAVE_LANGINFO_CODESET +/* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */ +char *nl_langinfo (nl_item item) +{ + /* Conversion of Posix item numbers to their Windows equivalents. */ + static const LCTYPE w32item[] = { + LOCALE_IDEFAULTANSICODEPAGE, + LOCALE_SDAYNAME1, LOCALE_SDAYNAME2, LOCALE_SDAYNAME3, + LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6, LOCALE_SDAYNAME7, + LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3, + LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6, + LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9, + LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12 + }; + + static char *nl_langinfo_buf = NULL; + static int nl_langinfo_len = 0; + + if (nl_langinfo_len <= 0) + nl_langinfo_buf = xmalloc (nl_langinfo_len = 1); + + if (item < 0 || item >= _NL_NUM) + nl_langinfo_buf[0] = 0; + else + { + LCID cloc = GetThreadLocale (); + int need_len = GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP, + NULL, 0); + + if (need_len <= 0) + nl_langinfo_buf[0] = 0; + else + { + if (item == CODESET) + { + need_len += 2; /* for the "cp" prefix */ + if (need_len < 8) /* for the case we call GetACP */ + need_len = 8; + } + if (nl_langinfo_len <= need_len) + nl_langinfo_buf = xrealloc (nl_langinfo_buf, + nl_langinfo_len = need_len); + if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP, + nl_langinfo_buf, nl_langinfo_len)) + nl_langinfo_buf[0] = 0; + else if (item == CODESET) + { + if (strcmp (nl_langinfo_buf, "0") == 0 /* CP_ACP */ + || strcmp (nl_langinfo_buf, "1") == 0) /* CP_OEMCP */ + sprintf (nl_langinfo_buf, "cp%u", GetACP ()); + else + { + memmove (nl_langinfo_buf + 2, nl_langinfo_buf, + strlen (nl_langinfo_buf) + 1); + nl_langinfo_buf[0] = 'c'; + nl_langinfo_buf[1] = 'p'; + } + } + } + } + return nl_langinfo_buf; +} +#endif /* HAVE_LANGINFO_CODESET */ DEFUN ("w32-get-locale-info", Fw32_get_locale_info, Sw32_get_locale_info, 1, 2, 0, @@ -2146,6 +2219,8 @@ syms_of_ntproc () { Qhigh = intern ("high"); Qlow = intern ("low"); + staticpro (&Qhigh); + staticpro (&Qlow); #ifdef HAVE_SOCKETS defsubr (&Sw32_has_winsock); @@ -2241,6 +2316,9 @@ the truename of a file can be slow. */); Note that this option is only useful for files on NTFS volumes, where hard links are supported. Moreover, it slows down `file-attributes' noticeably. */); Vw32_get_true_file_attributes = Qt; + + staticpro (&Vw32_valid_locale_ids); + staticpro (&Vw32_valid_codepages); } /* end of ntproc.c */