------------------------------------------------------------ revno: 117523 fixes bug: http://debbugs.gnu.org/17839 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2014-07-12 10:47:40 +0300 message: Minor fix for read_minibuf_noninteractive on MS-Windows. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode only if it is connected to a terminal. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 17:55:24 +0000 +++ src/ChangeLog 2014-07-12 07:47:40 +0000 @@ -1,3 +1,8 @@ +2014-07-12 Eli Zaretskii + + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch + stdin to binary mode only if it is connected to a terminal. + 2014-07-11 Paul Eggert Coalesce extern decls. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 17:55:24 +0000 +++ src/minibuf.c 2014-07-12 07:47:40 +0000 @@ -241,7 +241,8 @@ { emacs_get_tty (fileno (stdin), &etty); #ifdef WINDOWSNT - _setmode (fileno (stdin), O_BINARY); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_BINARY); #endif suppress_echo_on_tty (fileno (stdin)); } @@ -282,7 +283,8 @@ fprintf (stdout, "\n"); emacs_set_tty (fileno (stdin), &etty, 0); #ifdef WINDOWSNT - _setmode (fileno (stdin), O_TEXT); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_TEXT); #endif } ------------------------------------------------------------ revno: 117522 committer: Dmitry Antipov branch nick: trunk timestamp: Sat 2014-07-12 08:06:32 +0400 message: * XMenuInt.h (XDeleteAssoc): Remove duplicated prototype to pacify -Wredundant-decls. diff: === modified file 'oldXMenu/ChangeLog' --- oldXMenu/ChangeLog 2014-06-28 23:19:04 +0000 +++ oldXMenu/ChangeLog 2014-07-12 04:06:32 +0000 @@ -1,3 +1,8 @@ +2014-07-12 Dmitry Antipov + + * XMenuInt.h (XDeleteAssoc): Remove duplicated prototype to + pacify -Wredundant-decls. + 2014-06-28 Glenn Morris * deps.mk (${OBJS}): Depend on ../src/config.h. === modified file 'oldXMenu/XMenuInt.h' --- oldXMenu/XMenuInt.h 2012-12-04 20:42:29 +0000 +++ oldXMenu/XMenuInt.h 2014-07-12 04:06:32 +0000 @@ -62,7 +62,6 @@ void _XMRefreshSelection(Display *display, XMenu *menu, XMSelect *select); void emacs_insque (void *elem, void *prev); void emacs_remque (void *elem); -void XDeleteAssoc(Display *dpy, XAssocTable *table, XID x_id); void XDestroyAssocTable(XAssocTable *table); void XMakeAssoc(Display *dpy, XAssocTable *table, XID x_id, void *data); void XDeleteAssoc(Display *dpy, XAssocTable *table, XID x_id); ------------------------------------------------------------ revno: 117521 committer: Paul Eggert branch nick: trunk timestamp: Fri 2014-07-11 10:55:24 -0700 message: Coalesce extern decls. * minibuf.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty): * sysdep.c (emacs_get_tty, emacs_set_tty): Move duplicate extern decls from here ... * systty.h: ... to here, so that there's just one copy. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 16:33:17 +0000 +++ src/ChangeLog 2014-07-11 17:55:24 +0000 @@ -1,3 +1,11 @@ +2014-07-11 Paul Eggert + + Coalesce extern decls. + * minibuf.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty): + * sysdep.c (emacs_get_tty, emacs_set_tty): + Move duplicate extern decls from here ... + * systty.h: ... to here, so that there's just one copy. + 2014-07-11 Jan Djärv * nsterm.m (changeFont:): Add ifdef NS_IMPL_COCOA. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 15:44:25 +0000 +++ src/minibuf.c 2014-07-11 17:55:24 +0000 @@ -38,11 +38,7 @@ #include "intervals.h" #include "keymap.h" #include "termhooks.h" - #include "systty.h" -extern void emacs_get_tty (int, struct emacs_tty *); -extern int emacs_set_tty (int, struct emacs_tty *, bool); -extern void suppress_echo_on_tty (int); /* List of buffers for use as minibuffers. The first element of the list is used for the outermost minibuffer === modified file 'src/sysdep.c' --- src/sysdep.c 2014-07-11 13:58:02 +0000 +++ src/sysdep.c 2014-07-11 17:55:24 +0000 @@ -105,9 +105,6 @@ #include "syssignal.h" #include "systime.h" -void emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE; -int emacs_set_tty (int, struct emacs_tty *, bool) EXTERNALLY_VISIBLE; - /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ #ifndef ULLONG_MAX #define ULLONG_MAX TYPE_MAXIMUM (unsigned long long int) === modified file 'src/systty.h' --- src/systty.h 2014-07-11 13:58:02 +0000 +++ src/systty.h 2014-07-11 17:55:24 +0000 @@ -23,6 +23,7 @@ #include #endif /* not DOS_NT */ +#include #include #ifdef HPUX @@ -79,5 +80,8 @@ }; /* From sysdep.c or w32.c */ +extern void emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE; +extern int emacs_set_tty (int, struct emacs_tty *, bool) EXTERNALLY_VISIBLE; +extern void suppress_echo_on_tty (int); extern int serial_open (Lisp_Object); extern void serial_configure (struct Lisp_Process *, Lisp_Object); ------------------------------------------------------------ revno: 117520 committer: Jan D. branch nick: trunk timestamp: Fri 2014-07-11 18:33:17 +0200 message: Add ifdef NS_IMPL_COCOA aound OSX version check (for clang) * nsfns.m (Fns_popup_font_panel): Ditto. * nsterm.m (changeFont:): Add ifdef NS_IMPL_COCOA. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 15:44:25 +0000 +++ src/ChangeLog 2014-07-11 16:33:17 +0000 @@ -1,3 +1,9 @@ +2014-07-11 Jan Djärv + + * nsterm.m (changeFont:): Add ifdef NS_IMPL_COCOA. + + * nsfns.m (Fns_popup_font_panel): Ditto. + 2014-07-11 Eli Zaretskii * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r', === modified file 'src/nsfns.m' --- src/nsfns.m 2014-06-01 08:23:18 +0000 +++ src/nsfns.m 2014-07-11 16:33:17 +0000 @@ -1390,10 +1390,12 @@ NSFont *nsfont; if (EQ (font->driver->type, Qns)) nsfont = ((struct nsfont_info *)font)->nsfont; +#ifdef NS_IMPL_COCOA #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 else nsfont = (NSFont *) macfont_get_nsctfont (font); #endif +#endif [fm setSelectedFont: nsfont isMultiple: NO]; [fm orderFrontFontPanel: NSApp]; return Qnil; === modified file 'src/nsterm.m' --- src/nsterm.m 2014-06-30 18:44:56 +0000 +++ src/nsterm.m 2014-07-11 16:33:17 +0000 @@ -5012,10 +5012,12 @@ if (EQ (font->driver->type, Qns)) nsfont = ((struct nsfont_info *)font)->nsfont; +#ifdef NS_IMPL_COCOA #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 else nsfont = (NSFont *) macfont_get_nsctfont (font); #endif +#endif if ((newFont = [sender convertFont: nsfont])) { ------------------------------------------------------------ revno: 117519 fixes bug: http://debbugs.gnu.org/17839 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2014-07-11 18:44:25 +0300 message: Fix reading input without echoing on MS-Windows. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode when not echoing input. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 13:58:02 +0000 +++ src/ChangeLog 2014-07-11 15:44:25 +0000 @@ -2,6 +2,7 @@ * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r', not only on '\n'. + [WINDOWSNT]: Switch stdin to binary mode when not echoing input. * sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty) [DOS_NT]: Implement for WINDOWSNT. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 13:58:02 +0000 +++ src/minibuf.c 2014-07-11 15:44:25 +0000 @@ -22,6 +22,10 @@ #include #include +#ifdef WINDOWSNT +#include /* For O_BINARY, O_TEXT. */ +#endif + #include "lisp.h" #include "commands.h" #include "character.h" @@ -240,6 +244,9 @@ if (hide_char) { emacs_get_tty (fileno (stdin), &etty); +#ifdef WINDOWSNT + _setmode (fileno (stdin), O_BINARY); +#endif suppress_echo_on_tty (fileno (stdin)); } @@ -278,6 +285,9 @@ { fprintf (stdout, "\n"); emacs_set_tty (fileno (stdin), &etty, 0); +#ifdef WINDOWSNT + _setmode (fileno (stdin), O_TEXT); +#endif } if (len || c == '\n' || c == '\r') ------------------------------------------------------------ revno: 117518 fixes bug: http://debbugs.gnu.org/17839 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2014-07-11 16:58:02 +0300 message: Implement echo suppression in non-interactive mode for MS-Windows. src/minibuf.c (read_minibuf_noninteractive): Finish reading on '\r', not only on '\n'. src/sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty) [DOS_NT]: Implement for WINDOWSNT. src/systty.h (struct emacs_tty) [DOS_NT]: The struct member is now unsigned. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 12:35:23 +0000 +++ src/ChangeLog 2014-07-11 13:58:02 +0000 @@ -1,3 +1,14 @@ +2014-07-11 Eli Zaretskii + + * minibuf.c (read_minibuf_noninteractive): Finish reading on '\r', + not only on '\n'. + + * sysdep.c (emacs_get_tty, emacs_set_tty, suppress_echo_on_tty) + [DOS_NT]: Implement for WINDOWSNT. + + * systty.h (struct emacs_tty) [DOS_NT]: The struct member is now + unsigned. + 2014-07-11 Michael Albinus * sysdep.c (suppress_echo_on_tty): New function. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 12:35:23 +0000 +++ src/minibuf.c 2014-07-11 13:58:02 +0000 @@ -251,7 +251,7 @@ len = 0; line = xmalloc (size); - while ((c = getchar ()) != '\n') + while ((c = getchar ()) != '\n' && c != '\r') { if (c == EOF) { @@ -280,7 +280,7 @@ emacs_set_tty (fileno (stdin), &etty, 0); } - if (len || c == '\n') + if (len || c == '\n' || c == '\r') { val = make_string (line, len); xfree (line); === modified file 'src/sysdep.c' --- src/sysdep.c 2014-07-11 12:35:23 +0000 +++ src/sysdep.c 2014-07-11 13:58:02 +0000 @@ -783,9 +783,20 @@ emacs_get_tty (int fd, struct emacs_tty *settings) { /* Retrieve the primary parameters - baud rate, character size, etcetera. */ -#ifndef DOS_NT + memset (&settings->main, 0, sizeof (settings->main)); +#ifdef DOS_NT +#ifdef WINDOWSNT + HANDLE h = (HANDLE)_get_osfhandle (fd); + DWORD console_mode; + + if (h && h != INVALID_HANDLE_VALUE) + { + if (GetConsoleMode (h, &console_mode)) + settings->main = console_mode; + } +#endif /* WINDOWSNT */ +#else /* !DOS_NT */ /* We have those nifty POSIX tcmumbleattr functions. */ - memset (&settings->main, 0, sizeof (settings->main)); tcgetattr (fd, &settings->main); #endif } @@ -799,7 +810,22 @@ emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp) { /* Set the primary parameters - baud rate, character size, etcetera. */ -#ifndef DOS_NT +#ifdef DOS_NT +#ifdef WINDOWSNT + HANDLE h = (HANDLE)_get_osfhandle (fd); + + if (h && h != INVALID_HANDLE_VALUE) + { + DWORD new_mode; + + /* Assume the handle is open for input. */ + if (flushp) + FlushConsoleInputBuffer (h); + new_mode = settings->main; + SetConsoleMode (h, new_mode); + } +#endif /* WINDOWSNT */ +#else /* !DOS_NT */ int i; /* We have those nifty POSIX tcmumbleattr functions. William J. Smith writes: @@ -1149,7 +1175,10 @@ struct emacs_tty etty; emacs_get_tty (fd, &etty); -#ifndef WINDOWSNT +#ifdef DOS_NT + /* Set raw input mode. */ + etty.main = 0; +#else etty.main.c_lflag &= ~ICANON; /* Disable buffering */ etty.main.c_lflag &= ~ECHO; /* Disable echoing */ #endif /* ! WINDOWSNT */ === modified file 'src/systty.h' --- src/systty.h 2014-01-01 07:43:34 +0000 +++ src/systty.h 2014-07-11 13:58:02 +0000 @@ -74,7 +74,7 @@ #ifndef DOS_NT struct termios main; #else /* DOS_NT */ - int main; + unsigned main; #endif /* DOS_NT */ }; ------------------------------------------------------------ revno: 117517 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2014-07-11 15:49:49 +0300 message: doc/lispref/internals.texi (Garbage Collection): Fix last change. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2014-07-11 12:19:58 +0000 +++ doc/lispref/ChangeLog 2014-07-11 12:49:49 +0000 @@ -1,3 +1,7 @@ +2014-07-11 Eli Zaretskii + + * internals.texi (Garbage Collection): Fix last change. + 2014-07-11 Dmitry Antipov * internals.texi (Garbage Collection): Mention memory-info. === modified file 'doc/lispref/internals.texi' --- doc/lispref/internals.texi 2014-07-11 12:19:58 +0000 +++ doc/lispref/internals.texi 2014-07-11 12:49:49 +0000 @@ -516,6 +516,7 @@ @defun memory-info This functions returns an amount of total system memory and how much of it is free. On an unsupported system, the value may be @code{nil}. +@end defun @defvar gcs-done This variable contains the total number of garbage collections ------------------------------------------------------------ revno: 117516 committer: Michael Albinus branch nick: trunk timestamp: Fri 2014-07-11 14:35:23 +0200 message: * sysdep.c (suppress_echo_on_tty): New function. * minibuf.c (read_minibuf_noninteractive): Use it. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 12:19:58 +0000 +++ src/ChangeLog 2014-07-11 12:35:23 +0000 @@ -1,3 +1,8 @@ +2014-07-11 Michael Albinus + + * sysdep.c (suppress_echo_on_tty): New function. + * minibuf.c (read_minibuf_noninteractive): Use it. + 2014-07-11 Dmitry Antipov * alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 09:56:58 +0000 +++ src/minibuf.c 2014-07-11 12:35:23 +0000 @@ -38,6 +38,7 @@ #include "systty.h" extern void emacs_get_tty (int, struct emacs_tty *); extern int emacs_set_tty (int, struct emacs_tty *, bool); +extern void suppress_echo_on_tty (int); /* List of buffers for use as minibuffers. The first element of the list is used for the outermost minibuffer @@ -229,7 +230,7 @@ Lisp_Object val; int c; unsigned char hide_char = 0; - struct emacs_tty old, new; + struct emacs_tty etty; /* Check, whether we need to suppress echoing. */ if (CHARACTERP (Vread_hide_char)) @@ -238,13 +239,8 @@ /* Manipulate tty. */ if (hide_char) { - emacs_get_tty (fileno (stdin), &old); - new = old; -#ifndef WINDOWSNT - new.main.c_lflag &= ~ICANON; /* Disable buffering */ - new.main.c_lflag &= ~ECHO; /* Disable echoing */ -#endif - emacs_set_tty (fileno (stdin), &new, 0); + emacs_get_tty (fileno (stdin), &etty); + suppress_echo_on_tty (fileno (stdin)); } fprintf (stdout, "%s", SDATA (prompt)); @@ -281,7 +277,7 @@ if (hide_char) { fprintf (stdout, "\n"); - emacs_set_tty (fileno (stdin), &old, 0); + emacs_set_tty (fileno (stdin), &etty, 0); } if (len || c == '\n') === modified file 'src/sysdep.c' --- src/sysdep.c 2014-07-11 09:09:54 +0000 +++ src/sysdep.c 2014-07-11 12:35:23 +0000 @@ -1140,6 +1140,21 @@ return 0; #endif /* DOS_NT */ } + +/* Discard echoing. */ + +void +suppress_echo_on_tty (int fd) +{ + struct emacs_tty etty; + + emacs_get_tty (fd, &etty); +#ifndef WINDOWSNT + etty.main.c_lflag &= ~ICANON; /* Disable buffering */ + etty.main.c_lflag &= ~ECHO; /* Disable echoing */ +#endif /* ! WINDOWSNT */ + emacs_set_tty (fd, &etty, 0); +} /* Get terminal size from system. Store number of lines into *HEIGHTP and width into *WIDTHP. ------------------------------------------------------------ revno: 117515 committer: Dmitry Antipov branch nick: trunk timestamp: Fri 2014-07-11 16:19:58 +0400 message: * src/alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if sysinfo failed. Adjust docstring. * doc/lispref/internals.texi (Garbage Collection): Mention memory-info. * lisp/files.el (out-of-memory-warning-percentage): New defcustom. (warn-maybe-out-of-memory): Use it. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2014-07-11 09:09:54 +0000 +++ doc/lispref/ChangeLog 2014-07-11 12:19:58 +0000 @@ -1,3 +1,7 @@ +2014-07-11 Dmitry Antipov + + * internals.texi (Garbage Collection): Mention memory-info. + 2014-07-11 Michael Albinus * minibuf.texi (Intro to Minibuffers, Reading a Password): === modified file 'doc/lispref/internals.texi' --- doc/lispref/internals.texi 2014-05-17 08:11:31 +0000 +++ doc/lispref/internals.texi 2014-07-11 12:19:58 +0000 @@ -513,6 +513,10 @@ a certain kind of object. See the documentation string for details. @end defun +@defun memory-info +This functions returns an amount of total system memory and how much +of it is free. On an unsupported system, the value may be @code{nil}. + @defvar gcs-done This variable contains the total number of garbage collections done so far in this Emacs session. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-07-11 09:09:54 +0000 +++ lisp/ChangeLog 2014-07-11 12:19:58 +0000 @@ -1,3 +1,8 @@ +2014-07-11 Dmitry Antipov + + * files.el (out-of-memory-warning-percentage): New defcustom. + (warn-maybe-out-of-memory): Use it. + 2014-07-11 Michael Albinus * subr.el (read-passwd): Use `read-hide-char' if non-nil. Bind it === modified file 'lisp/files.el' --- lisp/files.el 2014-07-10 18:19:37 +0000 +++ lisp/files.el 2014-07-11 12:19:58 +0000 @@ -1786,6 +1786,14 @@ :version "22.1" :type '(choice integer (const :tag "Never request confirmation" nil))) +(defcustom out-of-memory-warning-percentage 50 + "Warn if file size exceeds this percentage of available free memory. +When nil, never issue warning." + :group 'files + :group 'find-file + :version "24.4" + :type '(choice integer (const :tag "Never issue warning" nil))) + (defun abort-if-file-too-large (size op-type filename) "If file SIZE larger than `large-file-warning-threshold', allow user to abort. OP-TYPE specifies the file operation being performed (for message to user)." @@ -1798,19 +1806,22 @@ (defun warn-maybe-out-of-memory (size) "Warn if an attempt to open file of SIZE bytes may run out of memory." - (when (and (numberp size) (not (zerop size))) + (when (and (numberp size) (not (zerop size)) + (integerp out-of-memory-warning-percentage)) (let ((meminfo (memory-info))) (when (consp meminfo) - (let ((total-free-memory (+ (nth 1 meminfo) (nth 3 meminfo)))) - (when (> (/ size 1024) total-free-memory) + (let ((total-free-memory (float (+ (nth 1 meminfo) (nth 3 meminfo))))) + (when (> (/ size 1024) + (/ (* total-free-memory out-of-memory-warning-percentage) + 100.0)) (warn "You are trying to open a file whose size (%s) -exceeds the amount of currently available free memory (%s). +exceeds the %S%% of currently available free memory (%s). If that fails, try to open it with `find-file-literally' \(but note that some characters might be displayed incorrectly)." (file-size-human-readable size) - (file-size-human-readable - (* (float total-free-memory) 1024))))))))) + out-of-memory-warning-percentage + (file-size-human-readable (* total-free-memory 1024))))))))) (defun find-file-noselect (filename &optional nowarn rawfile wildcards) "Read file FILENAME into a buffer and return the buffer. === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 10:09:51 +0000 +++ src/ChangeLog 2014-07-11 12:19:58 +0000 @@ -1,3 +1,8 @@ +2014-07-11 Dmitry Antipov + + * alloc.c (Fmemory_info) [HAVE_LINUX_SYSINFO]: Return nil if + sysinfo failed. Adjust docstring. + 2014-07-11 Eli Zaretskii Implement memory-info for MS-DOS. === modified file 'src/alloc.c' --- src/alloc.c 2014-07-11 10:09:51 +0000 +++ src/alloc.c 2014-07-11 12:19:58 +0000 @@ -6875,8 +6875,9 @@ DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0, doc: /* Return a list of (TOTAL-RAM FREE-RAM TOTAL-SWAP FREE-SWAP). -All values are in Kbytes. If there is no swap space, last two -values are zero. If the system is not supported, return nil. */) +All values are in Kbytes. If there is no swap space, +last two values are zero. If the system is not supported +or memory information can't be obtained, return nil. */) (void) { #if defined HAVE_LINUX_SYSINFO @@ -6884,7 +6885,7 @@ uintmax_t units; if (sysinfo (&si)) - emacs_abort (); + return Qnil; #ifdef LINUX_SYSINFO_UNIT units = si.mem_unit; #else ------------------------------------------------------------ revno: 117514 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2014-07-11 13:09:51 +0300 message: Implement memory-info for MS-DOS. src/dosfns.c (dos_memory_info): New function. src/dosfns.h (dos_memory_info): Add prototype. src/alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info. src/vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead of doing some of its job. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 09:56:58 +0000 +++ src/ChangeLog 2014-07-11 10:09:51 +0000 @@ -1,5 +1,12 @@ 2014-07-11 Eli Zaretskii + Implement memory-info for MS-DOS. + * dosfns.c (dos_memory_info): New function. + * dosfns.h (dos_memory_info): Add prototype. + * alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info. + * vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead + of doing some of its job. + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't reference termios structure members. === modified file 'src/alloc.c' --- src/alloc.c 2014-07-10 19:09:26 +0000 +++ src/alloc.c 2014-07-11 10:09:51 +0000 @@ -53,6 +53,10 @@ #include #endif +#ifdef MSDOS +#include "dosfns.h" /* For dos_memory_info. */ +#endif + #if (defined ENABLE_CHECKING \ && defined HAVE_VALGRIND_VALGRIND_H \ && !defined USE_VALGRIND) @@ -6900,10 +6904,21 @@ (uintmax_t) freeswap / 1024); else return Qnil; -#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT */ +#elif defined MSDOS + unsigned long totalram, freeram, totalswap, freeswap; + + if (dos_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0) + return list4i ((uintmax_t) totalram / 1024, + (uintmax_t) freeram / 1024, + (uintmax_t) totalswap / 1024, + (uintmax_t) freeswap / 1024); + else + return Qnil; +} +#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */ /* FIXME: add more systems. */ return Qnil; -#endif /* HAVE_LINUX_SYSINFO */ +#endif /* HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */ } /* Debugging aids. */ === modified file 'src/dosfns.c' --- src/dosfns.c 2014-04-03 20:46:04 +0000 +++ src/dosfns.c 2014-07-11 10:09:51 +0000 @@ -641,6 +641,48 @@ return attrs; } +/* Support for memory-info. */ +int +dos_memory_info (unsigned long *totalram, unsigned long *freeram, + unsigned long *totalswap, unsigned long *freeswap) +{ + _go32_dpmi_meminfo info; + unsigned long mem1, mem2, freemem; + + _go32_dpmi_get_free_memory_information (&info); + /* DPMI server of Windows NT and its descendants reports in + info.available_memory a much lower amount that is really + available, which causes bogus "past 95% of memory limit" + warnings. Try to overcome that via circumstantial evidence. */ + mem1 = info.available_memory; + mem2 = info.available_physical_pages; + /* DPMI Spec: "Fields that are unavailable will hold -1." */ + if ((long)mem1 == -1L) + mem1 = 0; + if ((long)mem2 == -1L) + mem2 = 0; + else + mem2 *= 4096; + /* Surely, the available memory is at least what we have physically + available, right? */ + if (mem1 >= mem2) + freemem = mem1; + else + freemem = mem2; + *freeram = freemem; + *totalswap = + ((long)info.max_pages_in_paging_file == -1L) + ? 0 + : info.max_pages_in_paging_file * 4096; + *totalram = + ((long)info.total_physical_pages == -1L) + ? (freemem + (unsigned long)sbrk (0) + *totalswap) + : info.total_physical_pages * 4096; + *freeswap = 0; + return 0; +} + + void dos_cleanup (void) { === modified file 'src/dosfns.h' --- src/dosfns.h 2014-01-01 07:43:34 +0000 +++ src/dosfns.h 2014-07-11 10:09:51 +0000 @@ -22,7 +22,8 @@ #define DOS_COUNTRY_INFO 34 /* no of bytes returned by dos int 38h */ extern unsigned char dos_country_info[DOS_COUNTRY_INFO]; - +extern int dos_memory_info (unsigned long *, unsigned long *, + unsigned long *, unsigned long *); #ifndef HAVE_X_WINDOWS extern int msdos_stdcolor_idx (const char *); extern Lisp_Object msdos_stdcolor_name (int); === modified file 'src/vm-limit.c' --- src/vm-limit.c 2014-04-16 15:16:35 +0000 +++ src/vm-limit.c 2014-07-11 10:09:51 +0000 @@ -21,7 +21,7 @@ #include "lisp.h" #ifdef MSDOS -#include +#include "dosfns.h" extern int etext; #endif @@ -106,29 +106,10 @@ void get_lim_data (void) { - _go32_dpmi_meminfo info; - unsigned long lim1, lim2; + unsigned long totalram, freeram, totalswap, freeswap; - _go32_dpmi_get_free_memory_information (&info); - /* DPMI server of Windows NT and its descendants reports in - info.available_memory a much lower amount that is really - available, which causes bogus "past 95% of memory limit" - warnings. Try to overcome that via circumstantial evidence. */ - lim1 = info.available_memory; - lim2 = info.available_physical_pages; - /* DPMI Spec: "Fields that are unavailable will hold -1." */ - if ((long)lim1 == -1L) - lim1 = 0; - if ((long)lim2 == -1L) - lim2 = 0; - else - lim2 *= 4096; - /* Surely, the available memory is at least what we have physically - available, right? */ - if (lim1 >= lim2) - lim_data = lim1; - else - lim_data = lim2; + dos_memory_info (&totalram, &freeram, &totalswap, &freeswap); + lim_data = freeram; /* Don't believe they will give us more that 0.5 GB. */ if (lim_data > 512U * 1024U * 1024U) lim_data = 512U * 1024U * 1024U; ------------------------------------------------------------ revno: 117513 fixes bug: http://debbugs.gnu.org/17839 committer: Eli Zaretskii branch nick: trunk timestamp: Fri 2014-07-11 12:56:58 +0300 message: Temporary fix for the MS-Windows build broken by last commit. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't reference termios structure members. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 09:09:54 +0000 +++ src/ChangeLog 2014-07-11 09:56:58 +0000 @@ -1,3 +1,8 @@ +2014-07-11 Eli Zaretskii + + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't + reference termios structure members. + 2014-07-11 Michael Albinus * sysdep.c (emacs_get_tty, emacs_set_tty): Make them externally visible. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 09:09:54 +0000 +++ src/minibuf.c 2014-07-11 09:56:58 +0000 @@ -240,8 +240,10 @@ { emacs_get_tty (fileno (stdin), &old); new = old; +#ifndef WINDOWSNT new.main.c_lflag &= ~ICANON; /* Disable buffering */ new.main.c_lflag &= ~ECHO; /* Disable echoing */ +#endif emacs_set_tty (fileno (stdin), &new, 0); } ------------------------------------------------------------ revno: 117512 committer: Michael Albinus branch nick: trunk timestamp: Fri 2014-07-11 11:33:06 +0200 message: * NEWS: Passwords in batch mode are hidden. diff: === modified file 'etc/ChangeLog' --- etc/ChangeLog 2014-07-09 02:04:12 +0000 +++ etc/ChangeLog 2014-07-11 09:33:06 +0000 @@ -1,3 +1,7 @@ +2014-07-11 Michael Albinus + + * NEWS: Passwords in batch mode are hidden. + 2014-07-03 Glenn Morris * refcards/calccard.tex (section{Getting Help}): === modified file 'etc/NEWS' --- etc/NEWS 2014-07-09 02:04:12 +0000 +++ etc/NEWS 2014-07-11 09:33:06 +0000 @@ -61,6 +61,11 @@ main features that Emacs was compiled with. This is mainly intended for use in Emacs bug reports. ++++ +** A password is now hidden also when typed in batch mode. Another +hiding character but the default `.' can be used by let-binding the +variable `read-hide-char'. + * Editing Changes in Emacs 24.5 ------------------------------------------------------------ revno: 117511 fixes bug: http://debbugs.gnu.org/17839 committer: Michael Albinus branch nick: trunk timestamp: Fri 2014-07-11 11:09:54 +0200 message: Hide password in batch mode * doc/lispref/minibuf.texi (Intro to Minibuffers, Reading a Password): Password hiding is available in batch mode, do not mention it in the exclusion list. Mention `read-hide-char'. * lisp/subr.el (read-passwd): Use `read-hide-char' if non-nil. Bind it when calling `read-string'. * src/minibuf.c (top): Include systty.h. Declare external emacs_get_tty and emacs_set_tty. (Vread_hide_char): New lisp variable. (read_minibuf_noninteractive): Hide characters with Vread_hide_char if it is a character. * src/sysdep.c (emacs_get_tty, emacs_set_tty): Make them externally visible. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2014-07-09 02:04:12 +0000 +++ doc/lispref/ChangeLog 2014-07-11 09:09:54 +0000 @@ -1,3 +1,9 @@ +2014-07-11 Michael Albinus + + * minibuf.texi (Intro to Minibuffers, Reading a Password): + Password hiding is available in batch mode, do not mention it in + the exclusion list. Mention `read-hide-char'. (Bug#17839) + 2014-07-09 Stefan Monnier * debugging.texi (Function Debugging, Debugger Commands): === modified file 'doc/lispref/minibuf.texi' --- doc/lispref/minibuf.texi 2014-06-28 17:27:29 +0000 +++ doc/lispref/minibuf.texi 2014-07-11 09:09:54 +0000 @@ -102,8 +102,8 @@ When Emacs is running in batch mode, any request to read from the minibuffer actually reads a line from the standard input descriptor that was supplied when Emacs was started. This supports only basic input: -none of the special minibuffer features (history, completion, -password hiding, etc.) are available in batch mode. +none of the special minibuffer features (history, completion, etc.) +are available in batch mode. @node Text from Minibuffer @section Reading Text Strings with the Minibuffer @@ -2147,9 +2147,10 @@ @defun read-passwd prompt &optional confirm default This function reads a password, prompting with @var{prompt}. It does -not echo the password as the user types it; instead, it echoes @samp{.} -for each character in the password. (Note that in batch mode, the -input is not hidden.) +not echo the password as the user types it; instead, it echoes +@samp{.} for each character in the password. If you want to apply +another character to hide the password, let-bind the variable +@code{read-hide-char} with that character. The optional argument @var{confirm}, if non-@code{nil}, says to read the password twice and insist it must be the same both times. If it isn't === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-07-10 18:19:37 +0000 +++ lisp/ChangeLog 2014-07-11 09:09:54 +0000 @@ -1,3 +1,8 @@ +2014-07-11 Michael Albinus + + * subr.el (read-passwd): Use `read-hide-char' if non-nil. Bind it + when calling `read-string'. (Bug#17839) + 2014-07-10 Eli Zaretskii * files.el (warn-maybe-out-of-memory): Fix the wording of the === modified file 'lisp/subr.el' --- lisp/subr.el 2014-06-28 17:27:29 +0000 +++ lisp/subr.el 2014-07-11 09:09:54 +0000 @@ -2016,7 +2016,7 @@ Optional DEFAULT is a default password to use instead of empty input. This function echoes `.' for each character that the user types. -Note that in batch mode, the input is not hidden! +You could let-bind `read-hide-char' to another hiding character, though. Once the caller uses the password, it can erase the password by doing (clear-string STRING)." @@ -2041,7 +2041,7 @@ beg))) (dotimes (i (- end beg)) (put-text-property (+ i beg) (+ 1 i beg) - 'display (string ?.))))) + 'display (string (or read-hide-char ?.)))))) minibuf) (minibuffer-with-setup-hook (lambda () @@ -2055,12 +2055,9 @@ (setq-local show-paren-mode nil) ;bug#16091. (add-hook 'after-change-functions hide-chars-fun nil 'local)) (unwind-protect - (let ((enable-recursive-minibuffers t)) - (read-string - (if noninteractive - (format "%s[INPUT WILL NOT BE HIDDEN!] " prompt) ; bug#17839 - prompt) - nil t default)) ; t = "no history" + (let ((enable-recursive-minibuffers t) + (read-hide-char (or read-hide-char ?.))) + (read-string prompt nil t default)) ; t = "no history" (when (buffer-live-p minibuf) (with-current-buffer minibuf ;; Not sure why but it seems that there might be cases where the === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-10 19:09:26 +0000 +++ src/ChangeLog 2014-07-11 09:09:54 +0000 @@ -1,3 +1,13 @@ +2014-07-11 Michael Albinus + + * sysdep.c (emacs_get_tty, emacs_set_tty): Make them externally visible. + + * minibuf.c (top): Include systty.h. Declare external + emacs_get_tty and emacs_set_tty. + (Vread_hide_char): New lisp variable. + (read_minibuf_noninteractive): Hide characters with + Vread_hide_char if it is a character. (Bug#17839) + 2014-07-10 Eli Zaretskii Implement memory-info for MS-Windows. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-05-26 02:28:09 +0000 +++ src/minibuf.c 2014-07-11 09:09:54 +0000 @@ -35,6 +35,10 @@ #include "keymap.h" #include "termhooks.h" +#include "systty.h" +extern void emacs_get_tty (int, struct emacs_tty *); +extern int emacs_set_tty (int, struct emacs_tty *, bool); + /* List of buffers for use as minibuffers. The first element of the list is used for the outermost minibuffer invocation, the next element is used for a recursive minibuffer @@ -224,6 +228,22 @@ char *line; Lisp_Object val; int c; + unsigned char hide_char = 0; + struct emacs_tty old, new; + + /* Check, whether we need to suppress echoing. */ + if (CHARACTERP (Vread_hide_char)) + hide_char = XFASTINT (Vread_hide_char); + + /* Manipulate tty. */ + if (hide_char) + { + emacs_get_tty (fileno (stdin), &old); + new = old; + new.main.c_lflag &= ~ICANON; /* Disable buffering */ + new.main.c_lflag &= ~ECHO; /* Disable echoing */ + emacs_set_tty (fileno (stdin), &new, 0); + } fprintf (stdout, "%s", SDATA (prompt)); fflush (stdout); @@ -242,6 +262,8 @@ } else { + if (hide_char) + fprintf (stdout, "%c", hide_char); if (len == size) { if (STRING_BYTES_BOUND / 2 < size) @@ -253,6 +275,13 @@ } } + /* Reset tty. */ + if (hide_char) + { + fprintf (stdout, "\n"); + emacs_set_tty (fileno (stdin), &old, 0); + } + if (len || c == '\n') { val = make_string (line, len); @@ -2079,6 +2108,12 @@ initialization-order problems. */ Vminibuffer_prompt_properties = list2 (intern_c_string ("read-only"), Qt); + DEFVAR_LISP ("read-hide-char", Vread_hide_char, + doc: /* Whether to hide input characters in noninteractive mode. +It must be a character, which will be used to mask the input +characters. This variable should never be set globally. */); + Vread_hide_char = Qnil; + defsubr (&Sactive_minibuffer_window); defsubr (&Sset_minibuffer_window); defsubr (&Sread_from_minibuffer); === modified file 'src/sysdep.c' --- src/sysdep.c 2014-06-09 14:50:57 +0000 +++ src/sysdep.c 2014-07-11 09:09:54 +0000 @@ -105,8 +105,8 @@ #include "syssignal.h" #include "systime.h" -static void emacs_get_tty (int, struct emacs_tty *); -static int emacs_set_tty (int, struct emacs_tty *, bool); +void emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE; +int emacs_set_tty (int, struct emacs_tty *, bool) EXTERNALLY_VISIBLE; /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ #ifndef ULLONG_MAX @@ -779,7 +779,7 @@ /* Set *TC to the parameters associated with the terminal FD, or clear it if the parameters are not available. */ -static void +void emacs_get_tty (int fd, struct emacs_tty *settings) { /* Retrieve the primary parameters - baud rate, character size, etcetera. */ @@ -795,7 +795,7 @@ *SETTINGS. If FLUSHP, discard input. Return 0 if all went well, and -1 (setting errno) if anything failed. */ -static int +int emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp) { /* Set the primary parameters - baud rate, character size, etcetera. */ ------------------------------------------------------------ revno: 117510 committer: Eli Zaretskii branch nick: trunk timestamp: Thu 2014-07-10 22:09:26 +0300 message: Implement memory-info for MS-Windows. src/w32.c (w32_memory_info): New function. src/w32.h (w32_memory_info): Prototype it. src/alloc.c (Fmemory_info) [WINDOWSNT]: Call it. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-10 12:33:35 +0000 +++ src/ChangeLog 2014-07-10 19:09:26 +0000 @@ -1,3 +1,10 @@ +2014-07-10 Eli Zaretskii + + Implement memory-info for MS-Windows. + * w32.c (w32_memory_info): New function. + * w32.h (w32_memory_info): Prototype it. + * alloc.c (Fmemory_info) [WINDOWSNT]: Call it. + 2014-07-10 Dmitry Antipov * coding.h (struct coding_system): Remove 'error_positions' (unused) === modified file 'src/alloc.c' --- src/alloc.c 2014-07-10 12:33:35 +0000 +++ src/alloc.c 2014-07-10 19:09:26 +0000 @@ -6875,7 +6875,7 @@ values are zero. If the system is not supported, return nil. */) (void) { -#ifdef HAVE_LINUX_SYSINFO +#if defined HAVE_LINUX_SYSINFO struct sysinfo si; uintmax_t units; @@ -6885,12 +6885,22 @@ units = si.mem_unit; #else units = 1; -#endif +#endif return list4i ((uintmax_t) si.totalram * units / 1024, (uintmax_t) si.freeram * units / 1024, (uintmax_t) si.totalswap * units / 1024, (uintmax_t) si.freeswap * units / 1024); -#else /* not HAVE_LINUX_SYSINFO */ +#elif defined WINDOWSNT + unsigned long long totalram, freeram, totalswap, freeswap; + + if (w32_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0) + return list4i ((uintmax_t) totalram / 1024, + (uintmax_t) freeram / 1024, + (uintmax_t) totalswap / 1024, + (uintmax_t) freeswap / 1024); + else + return Qnil; +#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT */ /* FIXME: add more systems. */ return Qnil; #endif /* HAVE_LINUX_SYSINFO */ === modified file 'src/w32.c' --- src/w32.c 2014-07-09 02:04:12 +0000 +++ src/w32.c 2014-07-10 19:09:26 +0000 @@ -6955,6 +6955,35 @@ return attrs; } +int +w32_memory_info (unsigned long long *totalram, unsigned long long *freeram, + unsigned long long *totalswap, unsigned long long *freeswap) +{ + MEMORYSTATUS memst; + MEMORY_STATUS_EX memstex; + + /* Use GlobalMemoryStatusEx if available, as it can report more than + 2GB of memory. */ + if (global_memory_status_ex (&memstex)) + { + *totalram = memstex.ullTotalPhys; + *freeram = memstex.ullAvailPhys; + *totalswap = memstex.ullTotalPageFile; + *freeswap = memstex.ullAvailPageFile; + return 0; + } + else if (global_memory_status (&memst)) + { + *totalram = memst.dwTotalPhys; + *freeram = memst.dwAvailPhys; + *totalswap = memst.dwTotalPageFile; + *freeswap = memst.dwAvailPageFile; + return 0; + } + else + return -1; +} + /* Wrappers for winsock functions to map between our file descriptors and winsock's handles; also set h_errno for convenience. === modified file 'src/w32.h' --- src/w32.h 2014-02-06 15:27:46 +0000 +++ src/w32.h 2014-07-10 19:09:26 +0000 @@ -206,6 +206,10 @@ extern void sys_sleep (int); extern int sys_link (const char *, const char *); +/* Return total and free memory info. */ +extern int w32_memory_info (unsigned long long *, unsigned long long *, + unsigned long long *, unsigned long long *); + #ifdef HAVE_GNUTLS #include