commit aa89c84e00d8dc85100e6fedab7631c415e6364d (HEAD, refs/remotes/origin/master) Author: Juri Linkov Date: Wed Nov 27 01:43:49 2019 +0200 message uses minibuffer-message in the active minibuffer (bug#17272 bug#19064) * doc/lispref/display.texi (Displaying Messages): Explain the behavior of using minibuffer-message if the minibuffer is active. * src/editfns.c (Fmessage_in_echo_area): New function with body copied from Fmessage. (Fmessage): Call minibuffer-message in the active minibuffer, otherwise call Fmessage_in_echo_area. (message-in-echo-area): New variable. * lisp/isearch.el (isearch--momentary-message, isearch-message): * lisp/minibuffer.el (minibuffer-message, minibuffer-completion-help): Use 'message-in-echo-area' instead of 'message' where necessary. * lisp/autorevert.el (auto-revert-handler): * lisp/man.el (Man-bgproc-sentinel): * lisp/subr.el (do-after-load-evaluation): Revert recent changes that replaced 'message' with 'minibuffer-message'. This is not needed anymore since 'message' uses 'minibuffer-message' in the active minibuffer. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index ddbae40ac9..1f7cc93c9c 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -276,11 +276,13 @@ followed by a newline. When @code{inhibit-message} is non-@code{nil}, no message will be displayed in the echo area, it will only be logged to @samp{*Messages*}. +If the minibuffer is active, it uses the @code{minibuffer-message} +function to display the message temporarily at the end of the +minibuffer (@pxref{Minibuffer Misc}). + If @var{format-string} is @code{nil} or the empty string, @code{message} clears the echo area; if the echo area has been -expanded automatically, this brings it back to its normal size. If -the minibuffer is active, this brings the minibuffer contents back -onto the screen immediately. +expanded automatically, this brings it back to its normal size. @example @group diff --git a/etc/NEWS b/etc/NEWS index 662156d684..eb32d70f57 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -754,6 +754,10 @@ the minibuffer. If non-nil, point will move to the end of the prompt *** Minibuffer now uses 'minibuffer-message' to display error messages at the end of the active minibuffer. ++++ +*** The function 'message' now displays the message at the end of the minibuffer +when the minibuffer is active. + +++ *** 'y-or-n-p' now uses the minibuffer to read 'y' or 'n' answer. diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 079750a3f6..9275513c8d 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -815,8 +815,7 @@ This is an internal function used by Auto-Revert Mode." (when revert (when (and auto-revert-verbose (not (eq revert 'fast))) - (with-current-buffer (window-buffer (old-selected-window)) - (minibuffer-message "Reverting buffer `%s'." (buffer-name)))) + (message "Reverting buffer `%s'." (buffer-name))) ;; If point (or a window point) is at the end of the buffer, we ;; want to keep it at the end after reverting. This allows one ;; to tail a file. diff --git a/lisp/isearch.el b/lisp/isearch.el index 4f3342782d..7c22e6ad97 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2011,7 +2011,7 @@ Turning on character-folding turns off regexp mode.") (defun isearch--momentary-message (string) "Print STRING at the end of the isearch prompt for 1 second." (let ((message-log-max nil)) - (message "%s%s%s" + (message-in-echo-area "%s%s%s" (isearch-message-prefix nil isearch-nonincremental) isearch-message (apply #'propertize (format " [%s]" string) @@ -3168,7 +3168,7 @@ If there is no completion possible, say so and continue searching." (isearch-message-prefix ellipsis isearch-nonincremental) m (isearch-message-suffix c-q-hack))) - (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))) + (if c-q-hack m (let ((message-log-max nil)) (message-in-echo-area "%s" m))))) (defun isearch--describe-regexp-mode (regexp-function &optional space-before) "Make a string for describing REGEXP-FUNCTION. diff --git a/lisp/man.el b/lisp/man.el index ce01fdc805..beec2e616f 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1474,7 +1474,7 @@ manpage command." (kill-buffer Man-buffer))) (when message - (minibuffer-message "%s" message))))) + (message "%s" message))))) (defun Man-page-from-arguments (args) ;; Skip arguments and only print the page name. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index b9e5d5a3a2..a7bdde478f 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -712,16 +712,16 @@ If ARGS are provided, then pass MESSAGE through `format-message'." (progn (if args (apply #'message message args) - (message "%s" message)) + (message-in-echo-area "%s" message)) (prog1 (sit-for (or minibuffer-message-timeout 1000000)) - (message nil))) + (message-in-echo-area nil))) ;; Record message in the *Messages* buffer (let ((inhibit-message t)) (if args (apply #'message message args) - (message "%s" message))) + (message-in-echo-area "%s" message))) ;; Clear out any old echo-area message to make way for our new thing. - (message nil) + (message-in-echo-area nil) (setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message)) ;; Make sure we can put-text-property. @@ -1840,7 +1840,7 @@ variables.") (defun minibuffer-completion-help (&optional start end) "Display a list of possible completions of the current minibuffer contents." (interactive) - (message "Making completion list...") + (message-in-echo-area "Making completion list...") (let* ((start (or start (minibuffer-prompt-end))) (end (or end (point-max))) (string (buffer-substring start end)) @@ -1851,7 +1851,7 @@ variables.") minibuffer-completion-predicate (- (point) start) md))) - (message nil) + (message-in-echo-area nil) (if (or (null completions) (and (not (consp (cdr completions))) (equal (car completions) string))) diff --git a/lisp/subr.el b/lisp/subr.el index 01f4f531b1..7e8c4fc23c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4607,7 +4607,7 @@ This function is called directly from the C code." (string-match "\\.elc?\\>" file)) obarray)) (msg (format "Package %s is deprecated" package)) - (fun (lambda (msg) (minibuffer-message "%s" msg)))) + (fun (lambda (msg) (message "%s" msg)))) ;; Cribbed from cl--compiling-file. (when (or (not (fboundp 'byte-compile-warning-enabled-p)) (byte-compile-warning-enabled-p 'obsolete package)) diff --git a/src/editfns.c b/src/editfns.c index 8fc866d391..72a9cdba7a 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -2875,8 +2875,58 @@ If the first argument is nil or the empty string, the function clears any existing message; this lets the minibuffer contents show. See also `current-message'. +When the variable `message-in-echo-area' is non-nil, use the function +`message-in-echo-area' to display the message in the echo area. +Otherwise, when the minibuffer is active, use `minibuffer-message' +to temporarily display the message at the end of the minibuffer. + usage: (message FORMAT-STRING &rest ARGS) */) (ptrdiff_t nargs, Lisp_Object *args) +{ + if (NILP (Vmessage_in_echo_area) + && !inhibit_message + && !(NILP (args[0]) || (STRINGP (args[0]) && SBYTES (args[0]) == 0)) + && WINDOW_LIVE_P (Factive_minibuffer_window ()) + && WINDOW_LIVE_P (Fold_selected_window ()) + && BUFFERP (Fwindow_buffer (Fold_selected_window ())) + && !NILP (Fminibufferp (Fwindow_buffer (Fold_selected_window ())))) + { + ptrdiff_t count = SPECPDL_INDEX (); + + /* Avoid possible recursion. */ + specbind (Qmessage_in_echo_area, Qt); + + record_unwind_current_buffer (); + Fset_buffer (Fwindow_buffer (Fold_selected_window ())); + + return unbind_to (count, CALLN (Fapply, intern ("minibuffer-message"), + Flist (nargs, args))); + } + else + return Fmessage_in_echo_area (nargs, args); +} + +DEFUN ("message-in-echo-area", Fmessage_in_echo_area, Smessage_in_echo_area, 1, MANY, 0, + doc: /* Display a message at the bottom of the screen. +The message also goes into the `*Messages*' buffer, if `message-log-max' +is non-nil. (In keyboard macros, that's all it does.) +Return the message. + +In batch mode, the message is printed to the standard error stream, +followed by a newline. + +The first argument is a format control string, and the rest are data +to be formatted under control of the string. Percent sign (%), grave +accent (\\=`) and apostrophe (\\=') are special in the format; see +`format-message' for details. To display STRING without special +treatment, use (message-in-echo-area "%s" STRING). + +If the first argument is nil or the empty string, the function clears +any existing message; this lets the minibuffer contents show. See +also `current-message'. + +usage: (message-in-echo-area FORMAT-STRING &rest ARGS) */) + (ptrdiff_t nargs, Lisp_Object *args) { if (NILP (args[0]) || (STRINGP (args[0]) @@ -4520,6 +4570,11 @@ This variable is experimental; email 32252@debbugs.gnu.org if you need it to be non-nil. */); binary_as_unsigned = false; + DEFVAR_LISP ("message-in-echo-area", Vmessage_in_echo_area, + doc: /* Non-nil means overwrite the minibuffer with a message in the echo area. */); + Vmessage_in_echo_area = Qnil; + DEFSYM (Qmessage_in_echo_area, "message-in-echo-area"); + defsubr (&Spropertize); defsubr (&Schar_equal); defsubr (&Sgoto_char); @@ -4594,6 +4649,7 @@ it to be non-nil. */); defsubr (&Semacs_pid); defsubr (&Ssystem_name); defsubr (&Smessage); + defsubr (&Smessage_in_echo_area); defsubr (&Smessage_box); defsubr (&Smessage_or_box); defsubr (&Scurrent_message); commit b3c0fb21bd910f5d86490154451cc324ce9ad66b Author: Juri Linkov Date: Wed Nov 27 01:18:17 2019 +0200 Allow recursive minibuffers for yes-or-no-p and y-or-n-p (bug#17272 bug#19064) * lisp/subr.el (y-or-n-p): Let-bind enable-recursive-minibuffers to t. * src/fns.c (Fyes_or_no_p): Specbind Qenable_recursive_minibuffers to Qt. diff --git a/lisp/subr.el b/lisp/subr.el index fe55566b52..01f4f531b1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2847,6 +2847,7 @@ is nil and `use-dialog-box' is non-nil." (t (setq prompt (funcall padded prompt)) (let* ((empty-history '()) + (enable-recursive-minibuffers t) (str (read-from-minibuffer prompt nil (make-composed-keymap y-or-n-p-map query-replace-map) diff --git a/src/fns.c b/src/fns.c index cbb6879223..3ae3192b3d 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2805,15 +2805,18 @@ if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */) AUTO_STRING (yes_or_no, "(yes or no) "); prompt = CALLN (Fconcat, prompt, yes_or_no); + ptrdiff_t count = SPECPDL_INDEX (); + specbind (Qenable_recursive_minibuffers, Qt); + while (1) { ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil, Qyes_or_no_p_history, Qnil, Qnil)); if (SCHARS (ans) == 3 && !strcmp (SSDATA (ans), "yes")) - return Qt; + return unbind_to (count, Qt); if (SCHARS (ans) == 2 && !strcmp (SSDATA (ans), "no")) - return Qnil; + return unbind_to (count, Qnil); Fding (Qnil); Fdiscard_input (); commit 6960a7543cef8cadc2cb9c20d3f21983ed71621a Author: Juri Linkov Date: Wed Nov 27 00:29:31 2019 +0200 * lisp/tab-bar.el (display-buffer-in-tab): New function (bug#38354) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 69a26c515e..5eb332884c 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1254,6 +1254,36 @@ in the selected frame." (goto-char (posn-point (event-end event))) (tab-bar-list-select)) + +(defun display-buffer-in-tab (buffer alist) + "Display BUFFER in a tab. +ALIST is an association list of action symbols and values. See +Info node `(elisp) Buffer Display Action Alists' for details of +such alists. + +If ALIST contains a `name' entry, it creates a new tab with that name and +displays BUFFER in a new tab. If a tab with this name already exists, it +switches to that tab before displaying BUFFER. The `name' entry can be +a function, then it is called with two arguments: BUFFER and ALIST, and +should return the tab name. When a `name' entry is omitted, create +a new tab without an explicit name. + +This is an action function for buffer display, see Info +node `(elisp) Buffer Display Action Functions'. It should be +called only by `display-buffer' or a function directly or +indirectly called by the latter." + (let ((name (cdr (assq 'name alist)))) + (when (functionp name) + (setq name (funcall name buffer alist))) + (if name + (let ((tab-index (tab-bar--tab-index-by-name name))) + (if tab-index + (tab-bar-select-tab (1+ tab-index)) + (let ((tab-bar-new-tab-choice t)) + (tab-bar-new-tab) + (tab-bar-rename-tab name)))) + (tab-bar-new-tab)))) + (defun switch-to-buffer-other-tab (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in another tab. commit cffa5703b95fba3624dc54db5e693bae559eac5f Author: Paul Eggert Date: Tue Nov 26 13:53:41 2019 -0800 etags: remove some arbitrary limits etags had undefined behavior if input files, lines, tags, etc., had more than INT_MAX bytes. Clean up the usage of integer types to fix the overflow errors I found. * admin/merge-gnulib (GNULIB_MODULES): Add mempcpy. * lib-src/etags.c: Include inttypes.h, intprops.h. (memcpyz): New function. Use it to simplify several occurrences of memcpy followed by storing a trailing '\0'. (xnew): Use xnmalloc, to catch overflow on integer multiplication. (xrnew): Change last arg to multiplier. The type is not needed. All callers changed. (node, lineno, charno, linecharno, invalidcharno, make_tag): (pfnote, add_node, number_len, C_symtype, lbz, Makefile_targets) (readline): Use intmax_t for line numbers and character positions, instead of int or long. (linebuffer, make_tag, pfnote, total_size_of_entries, put_entry) (in_word_set, C_symtype, token, cstack, pushclass_above): (popclass_above, write_classname, consider_token, C_entries) (Ruby_functions, Makefile_targets, Lua_functions, TeX_commands) (TeX_decode_env, erlang_func, erlang_attribute, erlang_atom) (substitute, regex_tag_multiline, nocase_tail, readline_interval) (readline, savenstr, concat, etags_getcwd, relative_filename) (linebuffer_setlen): Use ptrdiff_t for object sizes, instead of int or long or unsigned or size_t. (write_classname, C_entries): Avoid sprintf, as the result could exceed INT_MAX bytes and then behavior goes haywire. (main): Use int, instead of unsigned, for argv counts. (get_language_from_filename): Use bool for boolean. (Ruby_functions): Prefer strcpy to memcpy when copying "=". (linebuffer_setlen): Use ‘if’ instead of ‘while’. (memory_full, xnmalloc, xnrealloc): New functions. (xmalloc): Use memory_full, and take a ptrdiff_t instead of a size_t. (xrealloc): Remove; no longer needed. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/mempcpy.c, m4/mempcpy.m4: New files, copied from Gnulib. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 50b0c762a8..5192916abd 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -37,7 +37,7 @@ GNULIB_MODULES=' filemode filevercmp flexmember fpieee fstatat fsusage fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ieee754-h ignore-value intprops largefile lstat - manywarnings memmem-simple memrchr minmax mkostemp mktime nstrftime + manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime pathmax pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat regex sig2str socklen stat-time std-gnu11 stdalign stddef stdio diff --git a/lib-src/etags.c b/lib-src/etags.c index 6409407e46..0665cb00b9 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -114,6 +114,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; # define O_CLOEXEC O_NOINHERIT #endif /* WINDOWSNT */ +#include #include #include #include @@ -123,6 +124,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; #include #include #include +#include #include #include #include @@ -141,6 +143,14 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; # define CTAGS false #endif +/* Copy to DEST from SRC (containing LEN bytes), and append a NUL byte. */ +static void +memcpyz (void *dest, void const *src, ptrdiff_t len) +{ + char *e = mempcpy (dest, src, len); + *e = '\0'; +} + static bool streq (char const *s, char const *t) { @@ -235,11 +245,11 @@ endtoken (unsigned char c) /* * xnew, xrnew -- allocate, reallocate storage * - * SYNOPSIS: Type *xnew (int n, Type); - * void xrnew (OldPointer, int n, Type); + * SYNOPSIS: Type *xnew (ptrdiff_t n, Type); + * void xrnew (OldPointer, ptrdiff_t n, int multiplier); */ -#define xnew(n, Type) ((Type *) xmalloc ((n) * sizeof (Type))) -#define xrnew(op, n, Type) ((op) = (Type *) xrealloc (op, (n) * sizeof (Type))) +#define xnew(n, Type) ((Type *) xnmalloc (n, sizeof (Type))) +#define xrnew(op, n, m) ((op) = xnrealloc (op, n, (m) * sizeof *(op))) typedef void Lang_function (FILE *); @@ -282,8 +292,8 @@ typedef struct node_st bool valid; /* write this tag on the tag file */ bool is_func; /* function tag: use regexp in CTAGS mode */ bool been_warned; /* warning already given for duplicated tag */ - int lno; /* line number tag is on */ - long cno; /* character number line starts on */ + intmax_t lno; /* line number tag is on */ + intmax_t cno; /* character number line starts on */ } node; /* @@ -295,8 +305,8 @@ typedef struct node_st */ typedef struct { - long size; - int len; + ptrdiff_t size; + ptrdiff_t len; char *buffer; } linebuffer; @@ -365,7 +375,7 @@ static void just_read_file (FILE *); static language *get_language_from_langname (const char *); static void readline (linebuffer *, FILE *); -static long readline_internal (linebuffer *, FILE *, char const *); +static ptrdiff_t readline_internal (linebuffer *, FILE *, char const *); static bool nocase_tail (const char *); static void get_tag (char *, char **); static void get_lispy_tag (char *); @@ -385,7 +395,7 @@ static void process_file (FILE *, char *, language *); static void find_entries (FILE *); static void free_tree (node *); static void free_fdesc (fdesc *); -static void pfnote (char *, bool, char *, int, int, long); +static void pfnote (char *, bool, char *, ptrdiff_t, intmax_t, intmax_t); static void invalidate_nodes (fdesc *, node **); static void put_entries (node *); @@ -393,7 +403,7 @@ static char *concat (const char *, const char *, const char *); static char *skip_spaces (char *); static char *skip_non_spaces (char *); static char *skip_name (char *); -static char *savenstr (const char *, int); +static char *savenstr (const char *, ptrdiff_t); static char *savestr (const char *); static char *etags_getcwd (void); static char *relative_filename (char *, char *); @@ -403,9 +413,11 @@ static bool filename_is_absolute (char *f); static void canonicalize_filename (char *); static char *etags_mktmp (void); static void linebuffer_init (linebuffer *); -static void linebuffer_setlen (linebuffer *, int); -static void *xmalloc (size_t); -static void *xrealloc (void *, size_t); +static void linebuffer_setlen (linebuffer *, ptrdiff_t); +static void *xmalloc (ptrdiff_t) ATTRIBUTE_MALLOC_SIZE ((1)); +static void *xnmalloc (ptrdiff_t, ptrdiff_t) ATTRIBUTE_MALLOC_SIZE ((1,2)); +static void *xnrealloc (void *, ptrdiff_t, ptrdiff_t) + ATTRIBUTE_ALLOC_SIZE ((2,3)); static char searchar = '/'; /* use /.../ searches */ @@ -420,12 +432,12 @@ static ptrdiff_t whatlen_max; /* maximum length of any 'what' member */ static fdesc *fdhead; /* head of file description list */ static fdesc *curfdp; /* current file description */ static char *infilename; /* current input file name */ -static int lineno; /* line number of current line */ -static long charno; /* current character number */ -static long linecharno; /* charno of start of current line */ +static intmax_t lineno; /* line number of current line */ +static intmax_t charno; /* current character number */ +static intmax_t linecharno; /* charno of start of current line */ static char *dbp; /* pointer to start of current tag */ -static const int invalidcharno = -1; +static intmax_t const invalidcharno = -1; static node *nodehead; /* the head of the binary tree of tags */ static node *last_node; /* the last node created */ @@ -1070,7 +1082,7 @@ int main (int argc, char **argv) { int i; - unsigned int nincluded_files; + int nincluded_files; char **included_files; argument *argbuffer; int current_arg, file_count; @@ -1484,7 +1496,7 @@ get_language_from_interpreter (char *interpreter) * Return a language given the file name. */ static language * -get_language_from_filename (char *file, int case_sensitive) +get_language_from_filename (char *file, bool case_sensitive) { language *lang; const char **name, **ext, *suffix; @@ -1918,26 +1930,26 @@ find_entries (FILE *inf) */ static void make_tag (const char *name, /* tag name, or NULL if unnamed */ - int namelen, /* tag length */ + ptrdiff_t namelen, /* tag length */ bool is_func, /* tag is a function */ char *linestart, /* start of the line where tag is */ - int linelen, /* length of the line where tag is */ - int lno, /* line number */ - long int cno) /* character number */ + ptrdiff_t linelen, /* length of the line where tag is */ + intmax_t lno, /* line number */ + intmax_t cno) /* character number */ { bool named = (name != NULL && namelen > 0); char *nname = NULL; if (debug) - fprintf (stderr, "%s on %s:%d: %s\n", + fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", named ? name : "(unnamed)", curfdp->taggedfname, lno, linestart); if (!CTAGS && named) /* maybe set named to false */ /* Let's try to make an implicit tag name, that is, create an unnamed tag such that etags.el can guess a name from it. */ { - int i; - register const char *cp = name; + ptrdiff_t i; + const char *cp = name; for (i = 0; i < namelen; i++) if (notinname (*cp++)) @@ -1963,8 +1975,8 @@ make_tag (const char *name, /* tag name, or NULL if unnamed */ /* Record a tag. */ static void -pfnote (char *name, bool is_func, char *linestart, int linelen, int lno, - long int cno) +pfnote (char *name, bool is_func, char *linestart, ptrdiff_t linelen, + intmax_t lno, intmax_t cno) /* tag name, or NULL if unnamed */ /* tag is a function */ /* start of the line where tag is */ @@ -2197,7 +2209,8 @@ add_node (node *np, node **cur_node_p) if (!no_warnings) { fprintf (stderr, - "Duplicate entry in file %s, line %d: %s\n", + ("Duplicate entry in file %s, " + "line %"PRIdMAX": %s\n"), np->fdp->infname, lineno, np->name); fprintf (stderr, "Second entry ignored\n"); } @@ -2293,12 +2306,12 @@ invalidate_nodes (fdesc *badfdp, node **npp) } -static int total_size_of_entries (node *); -static int number_len (long) ATTRIBUTE_CONST; +static ptrdiff_t total_size_of_entries (node *); +static int number_len (intmax_t) ATTRIBUTE_CONST; /* Length of a non-negative number's decimal representation. */ static int -number_len (long int num) +number_len (intmax_t num) { int len = 1; while ((num /= 10) > 0) @@ -2312,10 +2325,10 @@ number_len (long int num) * This count is irrelevant with etags.el since emacs 19.34 at least, * but is still supplied for backward compatibility. */ -static int -total_size_of_entries (register node *np) +static ptrdiff_t +total_size_of_entries (node *np) { - register int total = 0; + ptrdiff_t total = 0; for (; np != NULL; np = np->right) if (np->valid) @@ -2323,7 +2336,7 @@ total_size_of_entries (register node *np) total += strlen (np->regex) + 1; /* pat\177 */ if (np->name != NULL) total += strlen (np->name) + 1; /* name\001 */ - total += number_len ((long) np->lno) + 1; /* lno, */ + total += number_len (np->lno) + 1; /* lno, */ if (np->cno != invalidcharno) /* cno */ total += number_len (np->cno); total += 1; /* newline */ @@ -2347,7 +2360,7 @@ put_entry (node *np) if (fdp != np->fdp) { fdp = np->fdp; - fprintf (tagf, "\f\n%s,%d\n", + fprintf (tagf, "\f\n%s,%"PRIdPTR"\n", fdp->taggedfname, total_size_of_entries (np)); fdp->written = true; } @@ -2358,9 +2371,9 @@ put_entry (node *np) fputs (np->name, tagf); fputc ('\001', tagf); } - fprintf (tagf, "%d,", np->lno); + fprintf (tagf, "%"PRIdMAX",", np->lno); if (np->cno != invalidcharno) - fprintf (tagf, "%ld", np->cno); + fprintf (tagf, "%"PRIdMAX, np->cno); fputs ("\n", tagf); } else @@ -2372,10 +2385,10 @@ put_entry (node *np) if (cxref_style) { if (vgrind_style) - fprintf (stdout, "%s %s %d\n", + fprintf (stdout, "%s %s %"PRIdMAX"\n", np->name, np->fdp->taggedfname, (np->lno + 63) / 64); else - fprintf (stdout, "%-16s %3d %-16s %s\n", + fprintf (stdout, "%-16s %3"PRIdMAX" %-16s %s\n", np->name, np->lno, np->fdp->taggedfname, np->regex); } else @@ -2397,7 +2410,7 @@ put_entry (node *np) } else { /* anything else; text pattern inadequate */ - fprintf (tagf, "%d", np->lno); + fprintf (tagf, "%"PRIdMAX, np->lno); } putc ('\n', tagf); } @@ -2591,7 +2604,7 @@ hash (const char *str, int len) } static struct C_stab_entry * -in_word_set (register const char *str, register unsigned int len) +in_word_set (const char *str, ptrdiff_t len) { enum { @@ -2658,9 +2671,9 @@ in_word_set (register const char *str, register unsigned int len) /*%>*/ static enum sym_type -C_symtype (char *str, int len, int c_ext) +C_symtype (char *str, ptrdiff_t len, int c_ext) { - register struct C_stab_entry *se = in_word_set (str, len); + struct C_stab_entry *se = in_word_set (str, len); if (se == NULL || (se->c_ext && !(c_ext & se->c_ext))) return st_none; @@ -2770,8 +2783,8 @@ static enum static struct tok { char *line; /* string containing the token */ - int offset; /* where the token starts in LINE */ - int length; /* token length */ + ptrdiff_t offset; /* where the token starts in LINE */ + ptrdiff_t length; /* token length */ /* The previous members can be used to pass strings around for generic purposes. The following ones specifically refer to creating tags. In this @@ -2782,23 +2795,23 @@ static struct tok invalidated whenever a state machine is reset prematurely */ bool named; /* create a named tag */ - int lineno; /* source line number of tag */ - long linepos; /* source char number of tag */ + intmax_t lineno; /* source line number of tag */ + intmax_t linepos; /* source char number of tag */ } token; /* latest token read */ /* * Variables and functions for dealing with nested structures. * Idea by Mykola Dzyuba (2001) */ -static void pushclass_above (int, char *, int); -static void popclass_above (int); +static void pushclass_above (ptrdiff_t, char *, ptrdiff_t); +static void popclass_above (ptrdiff_t); static void write_classname (linebuffer *, const char *qualifier); static struct { char **cname; /* nested class names */ - int *bracelev; /* nested class brace level */ - int nl; /* class nesting level (elements used) */ - int size; /* length of the array */ + ptrdiff_t *bracelev; /* nested class brace level */ + ptrdiff_t nl; /* class nesting level (elements used) */ + ptrdiff_t size; /* length of the array */ } cstack; /* stack for nested declaration tags */ /* Current struct nesting depth (namespace, class, struct, union, enum). */ #define nestlev (cstack.nl) @@ -2807,17 +2820,17 @@ static struct { && bracelev == cstack.bracelev[nestlev-1] + 1) static void -pushclass_above (int bracelev, char *str, int len) +pushclass_above (ptrdiff_t bracelev, char *str, ptrdiff_t len) { - int nl; + ptrdiff_t nl; popclass_above (bracelev); nl = cstack.nl; if (nl >= cstack.size) { - int size = cstack.size *= 2; - xrnew (cstack.cname, size, char *); - xrnew (cstack.bracelev, size, int); + xrnew (cstack.cname, cstack.size, 2); + xrnew (cstack.bracelev, cstack.size, 2); + cstack.size *= 2; } assert (nl == 0 || cstack.bracelev[nl-1] < bracelev); cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len); @@ -2826,11 +2839,9 @@ pushclass_above (int bracelev, char *str, int len) } static void -popclass_above (int bracelev) +popclass_above (ptrdiff_t bracelev) { - int nl; - - for (nl = cstack.nl - 1; + for (ptrdiff_t nl = cstack.nl - 1; nl >= 0 && cstack.bracelev[nl] >= bracelev; nl--) { @@ -2842,8 +2853,7 @@ popclass_above (int bracelev) static void write_classname (linebuffer *cn, const char *qualifier) { - int i, len; - int qlen = strlen (qualifier); + ptrdiff_t len; if (cstack.nl == 0 || cstack.cname[0] == NULL) { @@ -2857,18 +2867,22 @@ write_classname (linebuffer *cn, const char *qualifier) linebuffer_setlen (cn, len); strcpy (cn->buffer, cstack.cname[0]); } - for (i = 1; i < cstack.nl; i++) + for (ptrdiff_t i = 1; i < cstack.nl; i++) { char *s = cstack.cname[i]; if (s == NULL) continue; - linebuffer_setlen (cn, len + qlen + strlen (s)); - len += sprintf (cn->buffer + len, "%s%s", qualifier, s); + int qlen = strlen (qualifier); + ptrdiff_t slen = strlen (s); + linebuffer_setlen (cn, len + qlen + slen); + memcpyz (stpcpy (cn->buffer + len, qualifier), s, slen); + len += qlen + slen; } } -static bool consider_token (char *, int, int, int *, int, int, bool *); +static bool consider_token (char *, ptrdiff_t, int, int *, + ptrdiff_t, ptrdiff_t, bool *); static void make_C_tag (bool); /* @@ -2889,8 +2903,8 @@ static void make_C_tag (bool); */ static bool -consider_token (char *str, int len, int c, int *c_extp, - int bracelev, int parlev, bool *is_func_or_var) +consider_token (char *str, ptrdiff_t len, int c, int *c_extp, + ptrdiff_t bracelev, ptrdiff_t parlev, bool *is_func_or_var) /* IN: token pointer */ /* IN: token length */ /* IN: first char after the token */ @@ -2903,7 +2917,7 @@ consider_token (char *str, int len, int c, int *c_extp, structtype is the type of the preceding struct-like keyword, and structbracelev is the brace level where it has been seen. */ static enum sym_type structtype; - static int structbracelev; + static ptrdiff_t structbracelev; static enum sym_type toktype; @@ -3098,8 +3112,7 @@ consider_token (char *str, int len, int c, int *c_extp, fvdef = fvnone; objdef = omethodtag; linebuffer_setlen (&token_name, len); - memcpy (token_name.buffer, str, len); - token_name.buffer[len] = '\0'; + memcpyz (token_name.buffer, str, len); return true; } return false; @@ -3113,11 +3126,10 @@ consider_token (char *str, int len, int c, int *c_extp, objdef = omethodtag; if (class_qualify) { - int oldlen = token_name.len; + ptrdiff_t oldlen = token_name.len; fvdef = fvnone; linebuffer_setlen (&token_name, oldlen + len); - memcpy (token_name.buffer + oldlen, str, len); - token_name.buffer[oldlen + len] = '\0'; + memcpyz (token_name.buffer + oldlen, str, len); } return true; } @@ -3228,7 +3240,7 @@ consider_token (char *str, int len, int c, int *c_extp, */ static struct { - long linepos; + intmax_t linepos; linebuffer lb; } lbs[2]; @@ -3302,19 +3314,19 @@ C_entries (int c_ext, FILE *inf) /* extension of C */ /* input file */ { - register char c; /* latest char read; '\0' for end of line */ - register char *lp; /* pointer one beyond the character `c' */ - int curndx, newndx; /* indices for current and new lb */ - register int tokoff; /* offset in line of start of current token */ - register int toklen; /* length of current token */ + char c; /* latest char read; '\0' for end of line */ + char *lp; /* pointer one beyond the character `c' */ + bool curndx, newndx; /* indices for current and new lb */ + ptrdiff_t tokoff; /* offset in line of start of current token */ + ptrdiff_t toklen; /* length of current token */ const char *qualifier; /* string used to qualify names */ int qlen; /* length of qualifier */ - int bracelev; /* current brace level */ - int bracketlev; /* current bracket level */ - int parlev; /* current parenthesis level */ - int attrparlev; /* __attribute__ parenthesis level */ - int templatelev; /* current template level */ - int typdefbracelev; /* bracelev where a typedef struct body begun */ + ptrdiff_t bracelev; /* current brace level */ + ptrdiff_t bracketlev; /* current bracket level */ + ptrdiff_t parlev; /* current parenthesis level */ + ptrdiff_t attrparlev; /* __attribute__ parenthesis level */ + ptrdiff_t templatelev; /* current template level */ + ptrdiff_t typdefbracelev; /* bracelev where a typedef struct body begun */ bool incomm, inquote, inchar, quotednl, midtoken; bool yacc_rules; /* in the rules part of a yacc file */ struct tok savetoken = {0}; /* token saved during preprocessor handling */ @@ -3327,7 +3339,7 @@ C_entries (int c_ext, FILE *inf) cstack.size = (DEBUG) ? 1 : 4; cstack.nl = 0; cstack.cname = xnew (cstack.size, char *); - cstack.bracelev = xnew (cstack.size, int); + cstack.bracelev = xnew (cstack.size, ptrdiff_t); } tokoff = toklen = typdefbracelev = 0; /* keep compiler quiet */ @@ -3579,20 +3591,19 @@ C_entries (int c_ext, FILE *inf) { if (class_qualify) { - int len; write_classname (&token_name, qualifier); - len = token_name.len; + ptrdiff_t len = token_name.len; linebuffer_setlen (&token_name, len + qlen + toklen); - sprintf (token_name.buffer + len, "%s%.*s", - qualifier, toklen, - newlb.buffer + tokoff); + memcpyz (stpcpy (token_name.buffer + len, + qualifier), + newlb.buffer + tokoff, toklen); } else { linebuffer_setlen (&token_name, toklen); - sprintf (token_name.buffer, "%.*s", - toklen, newlb.buffer + tokoff); + memcpyz (token_name.buffer, + newlb.buffer + tokoff, toklen); } token.named = true; } @@ -3601,17 +3612,19 @@ C_entries (int c_ext, FILE *inf) { if (class_qualify) { - int len = strlen (objtag) + 2 + toklen; + ptrdiff_t len = strlen (objtag) + 2 + toklen; linebuffer_setlen (&token_name, len); - sprintf (token_name.buffer, "%s(%.*s)", - objtag, toklen, - newlb.buffer + tokoff); + char *p1 = stpcpy (token_name.buffer, objtag); + char *p2 = stpcpy (p1, "("); + char *p3 = mempcpy (p2, newlb.buffer + tokoff, + toklen); + strcpy (p3, ")"); } else { linebuffer_setlen (&token_name, toklen); - sprintf (token_name.buffer, "%.*s", - toklen, newlb.buffer + tokoff); + memcpyz (token_name.buffer, + newlb.buffer + tokoff, toklen); } token.named = true; } @@ -3625,8 +3638,8 @@ C_entries (int c_ext, FILE *inf) /* GNU DEFUN and similar macros */ { bool defun = (newlb.buffer[tokoff] == 'F'); - int off = tokoff; - int len = toklen; + ptrdiff_t off = tokoff; + ptrdiff_t len = toklen; if (defun) { @@ -3635,9 +3648,8 @@ C_entries (int c_ext, FILE *inf) /* First, tag it as its C name */ linebuffer_setlen (&token_name, toklen); - memcpy (token_name.buffer, - newlb.buffer + tokoff, toklen); - token_name.buffer[toklen] = '\0'; + memcpyz (token_name.buffer, + newlb.buffer + tokoff, toklen); token.named = true; token.lineno = lineno; token.offset = tokoff; @@ -3650,9 +3662,8 @@ C_entries (int c_ext, FILE *inf) /* Rewrite the tag so that emacs lisp DEFUNs can be found also by their elisp name */ linebuffer_setlen (&token_name, len); - memcpy (token_name.buffer, - newlb.buffer + off, len); - token_name.buffer[len] = '\0'; + memcpyz (token_name.buffer, + newlb.buffer + off, len); if (defun) while (--len >= 0) if (token_name.buffer[len] == '_') @@ -3662,9 +3673,8 @@ C_entries (int c_ext, FILE *inf) else { linebuffer_setlen (&token_name, toklen); - memcpy (token_name.buffer, - newlb.buffer + tokoff, toklen); - token_name.buffer[toklen] = '\0'; + memcpyz (token_name.buffer, + newlb.buffer + tokoff, toklen); /* Name macros and members. */ token.named = (structdef == stagseen || typdef == ttypeseen @@ -3790,7 +3800,7 @@ C_entries (int c_ext, FILE *inf) objdef = omethodcolon; if (class_qualify) { - int toklen = token_name.len; + ptrdiff_t toklen = token_name.len; linebuffer_setlen (&token_name, toklen + 1); strcpy (token_name.buffer + toklen, ":"); } @@ -4061,7 +4071,7 @@ C_entries (int c_ext, FILE *inf) } if (uqname > token_name.buffer) { - int uqlen = strlen (uqname); + ptrdiff_t uqlen = strlen (uqname); linebuffer_setlen (&token_name, uqlen); memmove (token_name.buffer, uqname, uqlen + 1); } @@ -4979,12 +4989,11 @@ Ruby_functions (FILE *inf) size_t name_len = cp - np + 1; char *wr_name = xnew (name_len + 1, char); - memcpy (wr_name, np, name_len - 1); - memcpy (wr_name + name_len - 1, "=", 2); + strcpy (mempcpy (wr_name, np, name_len - 1), "="); pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); if (debug) - fprintf (stderr, "%s on %s:%d: %s\n", wr_name, + fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", wr_name, curfdp->taggedfname, lineno, lb.buffer); continuation = false; } @@ -5178,8 +5187,8 @@ static void Pascal_functions (FILE *inf) { linebuffer tline; /* mostly copied from C_entries */ - long save_lcno; - int save_lineno, namelen, taglen; + intmax_t save_lcno, save_lineno; + ptrdiff_t namelen, taglen; char c, *name; bool /* each of these flags is true if: */ @@ -5455,7 +5464,7 @@ Lua_functions (FILE *inf) if (tp_dot || tp_colon) { char *p = tp_dot > tp_colon ? tp_dot : tp_colon; - int len_add = p - tag_name + 1; + ptrdiff_t len_add = p - tag_name + 1; get_tag (bp + len_add, NULL); } @@ -5656,7 +5665,7 @@ TeX_commands (FILE *inf) if (strneq (cp, key->buffer, key->len)) { char *p; - int namelen, linelen; + ptrdiff_t namelen, linelen; bool opgrp = false; cp = skip_spaces (cp + key->len); @@ -5693,8 +5702,8 @@ TeX_commands (FILE *inf) static void TEX_decode_env (const char *evarname, const char *defenv) { - register const char *env, *p; - int i, len; + const char *env, *p; + ptrdiff_t len; /* Append default string to environment. */ env = getenv (evarname); @@ -5711,7 +5720,7 @@ TEX_decode_env (const char *evarname, const char *defenv) /* Unpack environment string into token table. Be careful about */ /* zero-length strings (leading ':', "::" and trailing ':') */ - for (i = 0; *env != '\0';) + for (ptrdiff_t i = 0; *env != '\0'; ) { p = strchr (env, ':'); if (!p) /* End of environment string. */ @@ -5811,8 +5820,7 @@ HTML_labels (FILE *inf) for (end = dbp; *end != '\0' && intoken (*end); end++) continue; linebuffer_setlen (&token_name, end - dbp); - memcpy (token_name.buffer, dbp, end - dbp); - token_name.buffer[end - dbp] = '\0'; + memcpyz (token_name.buffer, dbp, end - dbp); dbp = end; intag = false; /* we found what we looked for */ @@ -5906,11 +5914,10 @@ Prolog_functions (FILE *inf) tags later. */ if (allocated <= len) { - xrnew (last, len + 1, char); + xrnew (last, len + 1, 1); allocated = len + 1; } - memcpy (last, cp, len); - last[len] = '\0'; + memcpyz (last, cp, len); lastlen = len; } } @@ -6031,9 +6038,9 @@ prolog_atom (char *s, size_t pos) * Assumes that Erlang functions start at column 0. * Original code by Anders Lindgren (1996) */ -static int erlang_func (char *, char *, ptrdiff_t, ptrdiff_t *); +static ptrdiff_t erlang_func (char *, char *, ptrdiff_t, ptrdiff_t *); static void erlang_attribute (char *); -static int erlang_atom (char *); +static ptrdiff_t erlang_atom (char *); static void Erlang_functions (FILE *inf) @@ -6070,11 +6077,10 @@ Erlang_functions (FILE *inf) tags later. */ if (allocated <= len) { - xrnew (last, len + 1, char); + xrnew (last, len + 1, 1); allocated = len + 1; } - memcpy (last, cp + name_offset, len); - last[len] = '\0'; + memcpyz (last, cp + name_offset, len); lastlen = len; } } @@ -6093,7 +6099,7 @@ Erlang_functions (FILE *inf) * Return the size of the name of the function, or 0 if no function * was found. */ -static int +static ptrdiff_t erlang_func (char *s, char *last, ptrdiff_t lastlen, ptrdiff_t *name_offset) { char *name = s; @@ -6133,15 +6139,13 @@ static void erlang_attribute (char *s) { char *cp = s; - int pos; - int len; if ((LOOKING_AT (cp, "-define") || LOOKING_AT (cp, "-record")) && *cp++ == '(') { cp = skip_spaces (cp); - len = erlang_atom (cp); - pos = cp + len - s; + ptrdiff_t len = erlang_atom (cp); + ptrdiff_t pos = cp + len - s; if (len > 0) { /* If the name is quoted, the quotes are not part of the name. */ @@ -6161,10 +6165,10 @@ erlang_attribute (char *s) * Consume an Erlang atom (or variable). * Return the number of bytes consumed, or -1 if there was an error. */ -static int +static ptrdiff_t erlang_atom (char *s) { - int pos = 0; + ptrdiff_t pos = 0; if (c_isalpha (s[pos]) || s[pos] == '_') { @@ -6437,10 +6441,9 @@ static char * substitute (char *in, char *out, struct re_registers *regs) { char *result, *t; - int size, dig, diglen; result = NULL; - size = strlen (out); + ptrdiff_t size = strlen (out); /* Pass 1: figure out how much to allocate by finding all \N strings. */ if (out[size - 1] == '\\') @@ -6450,8 +6453,8 @@ substitute (char *in, char *out, struct re_registers *regs) t = strchr (t + 2, '\\')) if (c_isdigit (t[1])) { - dig = t[1] - '0'; - diglen = regs->end[dig] - regs->start[dig]; + int dig = t[1] - '0'; + ptrdiff_t diglen = regs->end[dig] - regs->start[dig]; size += diglen - 2; } else @@ -6464,8 +6467,8 @@ substitute (char *in, char *out, struct re_registers *regs) for (t = result; *out != '\0'; out++) if (*out == '\\' && c_isdigit (*++out)) { - dig = *out - '0'; - diglen = regs->end[dig] - regs->start[dig]; + int dig = *out - '0'; + ptrdiff_t diglen = regs->end[dig] - regs->start[dig]; memcpy (t, in + regs->start[dig], diglen); t += diglen; } @@ -6474,7 +6477,7 @@ substitute (char *in, char *out, struct re_registers *regs) *t = '\0'; assert (t <= result + size); - assert (t - result == (int)strlen (result)); + assert (t == result + strlen (result)); return result; } @@ -6511,7 +6514,7 @@ regex_tag_multiline (void) for (rp = p_head; rp != NULL; rp = rp->p_next) { - int match = 0; + ptrdiff_t match = 0; if (!rp->multi_line) continue; /* skip normal regexps */ @@ -6572,7 +6575,7 @@ regex_tag_multiline (void) charno - linecharno + 1, lineno, linecharno); if (debug) - fprintf (stderr, "%s on %s:%d: %s\n", + fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", name ? name : "(unnamed)", curfdp->taggedfname, lineno, buffer + linecharno); } @@ -6589,7 +6592,7 @@ regex_tag_multiline (void) static bool nocase_tail (const char *cp) { - int len = 0; + ptrdiff_t len = 0; while (*cp != '\0' && c_tolower (*cp) == c_tolower (dbp[len])) cp++, len++; @@ -6648,7 +6651,7 @@ get_lispy_tag (register char *bp) * If multi-line regular expressions are requested, each line read is * appended to `filebuf'. */ -static long +static ptrdiff_t readline_internal (linebuffer *lbp, FILE *stream, char const *filename) { char *buffer = lbp->buffer; @@ -6664,8 +6667,8 @@ readline_internal (linebuffer *lbp, FILE *stream, char const *filename) if (p == pend) { /* We're at the end of linebuffer: expand it. */ + xrnew (buffer, lbp->size, 2); lbp->size *= 2; - xrnew (buffer, lbp->size, char); p += buffer - lbp->buffer; pend = buffer + lbp->size; lbp->buffer = buffer; @@ -6702,13 +6705,12 @@ readline_internal (linebuffer *lbp, FILE *stream, char const *filename) while (filebuf.size <= filebuf.len + lbp->len + 1) /* +1 for \n */ { /* Expand filebuf. */ + xrnew (filebuf.buffer, filebuf.size, 2); filebuf.size *= 2; - xrnew (filebuf.buffer, filebuf.size, char); } - memcpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len); - filebuf.len += lbp->len; - filebuf.buffer[filebuf.len++] = '\n'; - filebuf.buffer[filebuf.len] = '\0'; + strcpy (mempcpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len), + "\n"); + filebuf.len += lbp->len + 1; } return lbp->len + chars_deleted; @@ -6722,10 +6724,8 @@ readline_internal (linebuffer *lbp, FILE *stream, char const *filename) static void readline (linebuffer *lbp, FILE *stream) { - long result; - linecharno = charno; /* update global char number of line start */ - result = readline_internal (lbp, stream, infilename); /* read line */ + ptrdiff_t result = readline_internal (lbp, stream, infilename); lineno += 1; /* increment global line number */ charno += result; /* increment global char number */ @@ -6737,10 +6737,10 @@ readline (linebuffer *lbp, FILE *stream) /* Check whether this is a #line directive. */ if (result > 12 && strneq (lbp->buffer, "#line ", 6)) { - unsigned int lno; + intmax_t lno; int start = 0; - if (sscanf (lbp->buffer, "#line %u \"%n", &lno, &start) >= 1 + if (sscanf (lbp->buffer, "#line %"SCNdMAX" \"%n", &lno, &start) >= 1 && start > 0) /* double quote character found */ { char *endp = lbp->buffer + start; @@ -6850,7 +6850,7 @@ readline (linebuffer *lbp, FILE *stream) } /* if #line directives should be considered */ { - int match; + ptrdiff_t match; regexp *rp; char *name; @@ -6900,7 +6900,7 @@ readline (linebuffer *lbp, FILE *stream) /* Force explicit tag name, if a name is there. */ pfnote (name, true, lbp->buffer, match, lineno, linecharno); if (debug) - fprintf (stderr, "%s on %s:%d: %s\n", + fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", name ? name : "(unnamed)", curfdp->taggedfname, lineno, lbp->buffer); } @@ -6925,11 +6925,11 @@ savestr (const char *cp) } /* - * Return a pointer to a space of size LEN+1 allocated with xnew where - * the string CP has been copied for at most the first LEN characters. + * Return a pointer to a space of size LEN+1 allocated with xnew + * with a copy of CP (containing LEN bytes) followed by a NUL byte. */ static char * -savenstr (const char *cp, int len) +savenstr (const char *cp, ptrdiff_t len) { char *dp = xnew (len + 1, char); dp[len] = '\0'; @@ -7013,13 +7013,9 @@ verror (char const *format, va_list ap) static char * concat (const char *s1, const char *s2, const char *s3) { - int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); + ptrdiff_t len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); char *result = xnew (len1 + len2 + len3 + 1, char); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - + strcpy (stpcpy (stpcpy (result, s1), s2), s3); return result; } @@ -7029,16 +7025,16 @@ concat (const char *s1, const char *s2, const char *s3) static char * etags_getcwd (void) { - int bufsize = 200; + ptrdiff_t bufsize = 200; char *path = xnew (bufsize, char); while (getcwd (path, bufsize) == NULL) { if (errno != ERANGE) pfatal ("getcwd"); - bufsize *= 2; free (path); - path = xnew (bufsize, char); + path = xnmalloc (bufsize, 2 * sizeof *path); + bufsize *= 2; } canonicalize_filename (path); @@ -7099,7 +7095,7 @@ static char * relative_filename (char *file, char *dir) { char *fp, *dp, *afn, *res; - int i; + ptrdiff_t i; /* Find the common root of file and dir (with a trailing slash). */ afn = absolute_filename (file, cwd); @@ -7282,32 +7278,54 @@ linebuffer_init (linebuffer *lbp) /* Set the minimum size of a string contained in a linebuffer. */ static void -linebuffer_setlen (linebuffer *lbp, int toksize) +linebuffer_setlen (linebuffer *lbp, ptrdiff_t toksize) { - while (lbp->size <= toksize) + if (lbp->size <= toksize) { - lbp->size *= 2; - xrnew (lbp->buffer, lbp->size, char); + ptrdiff_t multiplier = toksize / lbp->size + 1; + xrnew (lbp->buffer, lbp->size, multiplier); + lbp->size *= multiplier; } lbp->len = toksize; } -/* Like malloc but get fatal error if memory is exhausted. */ -static void * ATTRIBUTE_MALLOC -xmalloc (size_t size) +/* Memory allocators with a fatal error if memory is exhausted. */ + +static void +memory_full (void) +{ + fatal ("virtual memory exhausted"); +} + +static void * +xmalloc (ptrdiff_t size) { + if (SIZE_MAX < size) + memory_full (); void *result = malloc (size); if (result == NULL) - fatal ("virtual memory exhausted"); + memory_full (); return result; } static void * -xrealloc (void *ptr, size_t size) +xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size) { - void *result = realloc (ptr, size); - if (result == NULL) - fatal ("virtual memory exhausted"); + ptrdiff_t nbytes; + if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes)) + memory_full (); + return xmalloc (nbytes); +} + +static void * +xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size) +{ + ptrdiff_t nbytes; + if (INT_MULTIPLY_WRAPV (nitems, item_size, &nbytes) || SIZE_MAX < nbytes) + memory_full (); + void *result = realloc (pa, nbytes); + if (!result) + memory_full (); return result; } diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 9a2709c22a..8e3b569b94 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -116,6 +116,7 @@ # lstat \ # manywarnings \ # memmem-simple \ +# mempcpy \ # memrchr \ # minmax \ # mkostemp \ @@ -2027,6 +2028,17 @@ EXTRA_libgnu_a_SOURCES += memmem.c endif ## end gnulib module memmem-simple +## begin gnulib module mempcpy +ifeq (,$(OMIT_GNULIB_MODULE_mempcpy)) + + +EXTRA_DIST += mempcpy.c + +EXTRA_libgnu_a_SOURCES += mempcpy.c + +endif +## end gnulib module mempcpy + ## begin gnulib module memrchr ifeq (,$(OMIT_GNULIB_MODULE_memrchr)) diff --git a/lib/mempcpy.c b/lib/mempcpy.c new file mode 100644 index 0000000000..d0220e10fb --- /dev/null +++ b/lib/mempcpy.c @@ -0,0 +1,28 @@ +/* Copy memory area and return pointer after last written byte. + Copyright (C) 2003, 2007, 2009-2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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, see . */ + +#include + +/* Specification. */ +#include + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +void * +mempcpy (void *dest, const void *src, size_t n) +{ + return (char *) memcpy (dest, src, n) + n; +} diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 625c221166..baf9511aca 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -118,6 +118,7 @@ AC_DEFUN([gl_EARLY], # Code from module malloca: # Code from module manywarnings: # Code from module memmem-simple: + # Code from module mempcpy: # Code from module memrchr: # Code from module minmax: # Code from module mkostemp: @@ -327,6 +328,12 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([memmem]) fi gl_STRING_MODULE_INDICATOR([memmem]) + gl_FUNC_MEMPCPY + if test $HAVE_MEMPCPY = 0; then + AC_LIBOBJ([mempcpy]) + gl_PREREQ_MEMPCPY + fi + gl_STRING_MODULE_INDICATOR([mempcpy]) gl_FUNC_MEMRCHR if test $ac_cv_func_memrchr = no; then AC_LIBOBJ([memrchr]) @@ -954,6 +961,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/md5.c lib/md5.h lib/memmem.c + lib/mempcpy.c lib/memrchr.c lib/minmax.h lib/mkostemp.c @@ -1094,6 +1102,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/mbstate_t.m4 m4/md5.m4 m4/memmem.m4 + m4/mempcpy.m4 m4/memrchr.m4 m4/minmax.m4 m4/mkostemp.m4 diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 new file mode 100644 index 0000000000..b6090eed28 --- /dev/null +++ b/m4/mempcpy.m4 @@ -0,0 +1,26 @@ +# mempcpy.m4 serial 11 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2019 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MEMPCPY], +[ + dnl Persuade glibc to declare mempcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([mempcpy]) + if test $ac_cv_func_mempcpy = no; then + HAVE_MEMPCPY=0 + fi +]) + +# Prerequisites of lib/mempcpy.c. +AC_DEFUN([gl_PREREQ_MEMPCPY], [ + : +]) commit 75b41a38dd0735fe63457e12741656c63972d3ce Author: Juanma Barranquero Date: Tue Nov 26 22:35:04 2019 +0100 Fix previous change to (next|previous)-buffer * lisp/window.el (next-buffer, previous-buffer): If no other buffer is available, signal 'user-error' only when called interactively. diff --git a/etc/NEWS b/etc/NEWS index d3331daf17..662156d684 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2620,10 +2620,6 @@ scrolling. ** help-follow-symbol now signals 'user-error' if point (or the position pointed to by the argument POS) is not in a symbol. ---- -*** next-buffer and previous-buffer now signal 'user-error' if there -is no buffer to switch to. - * Lisp Changes in Emacs 27.1 @@ -3259,6 +3255,10 @@ by setting 'undo-inhibit-region' symbol property of that command to non-nil. This is used by 'mouse-drag-region' to make the effect easier to undo immediately afterwards. +--- +** When called interactively, next-buffer and previous-buffer now +signal 'user-error' if there is no buffer to switch to. + * Changes in Emacs 27.1 on Non-Free Operating Systems diff --git a/lisp/window.el b/lisp/window.el index c8a5816b8c..c750ea71ea 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4850,7 +4850,8 @@ minibuffer window or is dedicated to its buffer." (user-error "Window is strongly dedicated to its buffer")) (t (dotimes (_ (or arg 1)) - (unless (switch-to-next-buffer) + (when (and (not (switch-to-next-buffer)) + (called-interactively-p 'interactive)) (user-error "No next buffer")))))) (defun previous-buffer (&optional arg) @@ -4865,7 +4866,8 @@ minibuffer window or is dedicated to its buffer." (user-error "Window is strongly dedicated to its buffer")) (t (dotimes (_ (or arg 1)) - (unless (switch-to-prev-buffer) + (when (and (not (switch-to-prev-buffer)) + (called-interactively-p 'interactive)) (user-error "No previous buffer")))))) (defun delete-windows-on (&optional buffer-or-name frame) commit 1b9dbca826ad8a742ab22719279f5ce3c5888a67 Author: Paul Eggert Date: Tue Nov 26 13:14:42 2019 -0800 Update from Gnulib This incorporates: 2019-11-24 Fix errors in C++ mode on mingw 2019-11-24 time_r: Fix for mingw (regression from 2019-11-16) 2019-11-24 sys_time: Fix errors in C++ mode on mingw 2019-11-22 intprops: INT_MULTIPLY_WRAPV speedup for GCC 8.4+ 2019-11-21 Disable many _GL_CXXALIASWARN on non-glibc 2019-11-21 Fix various errors in _GL_CXXALIAS_SYS invocations 2019-11-19 intprops: INT_MULTIPLY_WRAPV speedup for GCC 9.3+ 2019-11-18 stdint: Define [u]intptr_t correctly on 64-bit native Windows 2019-11-18 stdint: Fix value of WINT_MAX when we override wint_t 2019-11-18 stdint: Avoid "conflicting types" error on mingw 5.22 2019-11-16 time_r: Fix for mingw 2019-11-06 regex: now back in sync with glibc * lib/intprops.h, lib/regexec.c, lib/signal.in.h: * lib/stdint.in.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/string.in.h, lib/sys_select.in.h, lib/sys_time.in.h: * lib/time.in.h, lib/unistd.in.h, m4/time_r.m4: Copy from Gnulib. diff --git a/lib/intprops.h b/lib/intprops.h index bf561ad0a6..0c3963d330 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -373,12 +373,17 @@ _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) #endif #if _GL_HAS_BUILTIN_MUL_OVERFLOW -/* Work around GCC bug 91450. */ -# define INT_MULTIPLY_WRAPV(a, b, r) \ - ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \ - && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ - ? ((void) __builtin_mul_overflow (a, b, r), 1) \ - : __builtin_mul_overflow (a, b, r)) +# if (9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ + || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) +# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) +# else + /* Work around GCC bug 91450. */ +# define INT_MULTIPLY_WRAPV(a, b, r) \ + ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \ + && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ + ? ((void) __builtin_mul_overflow (a, b, r), 1) \ + : __builtin_mul_overflow (a, b, r)) +# endif #else # define INT_MULTIPLY_WRAPV(a, b, r) \ _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) diff --git a/lib/regexec.c b/lib/regexec.c index c5dc6220b2..03a6b65047 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -1266,10 +1266,13 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, if (type == OP_BACK_REF) { Idx subexp_idx = dfa->nodes[node].opr.idx + 1; - naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; + if (subexp_idx < nregs) + naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; if (fs != NULL) { - if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) + if (subexp_idx >= nregs + || regs[subexp_idx].rm_so == -1 + || regs[subexp_idx].rm_eo == -1) return -1; else if (naccepted) { diff --git a/lib/signal.in.h b/lib/signal.in.h index a6960a252d..b4e432d7fe 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -144,7 +144,9 @@ _GL_FUNCDECL_SYS (pthread_sigmask, int, _GL_CXXALIAS_SYS (pthread_sigmask, int, (int how, const sigset_t *new_mask, sigset_t *old_mask)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (pthread_sigmask); +# endif #elif defined GNULIB_POSIXCHECK # undef pthread_sigmask # if HAVE_RAW_DECL_PTHREAD_SIGMASK @@ -168,7 +170,9 @@ _GL_FUNCDECL_SYS (raise, int, (int sig)); # endif _GL_CXXALIAS_SYS (raise, int, (int sig)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (raise); +# endif #elif defined GNULIB_POSIXCHECK # undef raise /* Assume raise is always declared. */ @@ -321,7 +325,9 @@ _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, (int sig, _gl_function_taking_int_returning_void_t func)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (signal); +# endif # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE /* Raise signal SIGPIPE. */ diff --git a/lib/stdint.in.h b/lib/stdint.in.h index d32de34da1..39b6a4f88a 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -299,16 +299,26 @@ typedef gl_uint_fast32_t gl_uint_fast16_t; /* 7.18.1.4. Integer types capable of holding object pointers */ -/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own +/* kLIBC's defines _INTPTR_T_DECLARED and needs its own definitions of intptr_t and uintptr_t (which use int and unsigned) - to avoid clashes with declarations of system functions like sbrk. */ -# ifndef _INTPTR_T_DECLARED -# undef intptr_t -# undef uintptr_t + to avoid clashes with declarations of system functions like sbrk. + Similarly, mingw 5.22 defines _INTPTR_T_DEFINED and + _UINTPTR_T_DEFINED and needs its own definitions of intptr_t and + uintptr_t to avoid conflicting declarations of system functions like + _findclose in . */ +# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ + || (defined __MINGW32__ && defined _INTPTR_T_DEFINED && defined _UINTPTR_T_DEFINED)) +# undef intptr_t +# undef uintptr_t +# ifdef _WIN64 +typedef long long int gl_intptr_t; +typedef unsigned long long int gl_uintptr_t; +# else typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; -# define intptr_t gl_intptr_t -# define uintptr_t gl_uintptr_t +# endif +# define intptr_t gl_intptr_t +# define uintptr_t gl_uintptr_t # endif /* 7.18.1.5. Greatest-width integer types */ @@ -485,9 +495,15 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) # undef INTPTR_MIN # undef INTPTR_MAX # undef UINTPTR_MAX -# define INTPTR_MIN LONG_MIN -# define INTPTR_MAX LONG_MAX -# define UINTPTR_MAX ULONG_MAX +# ifdef _WIN64 +# define INTPTR_MIN LLONG_MIN +# define INTPTR_MAX LLONG_MAX +# define UINTPTR_MAX ULLONG_MAX +# else +# define INTPTR_MIN LONG_MIN +# define INTPTR_MAX LONG_MAX +# define UINTPTR_MAX ULONG_MAX +# endif /* 7.18.2.5. Limits of greatest-width integer types */ @@ -586,17 +602,21 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) /* wint_t limits */ -# undef WINT_MIN -# undef WINT_MAX -# if @HAVE_SIGNED_WINT_T@ -# define WINT_MIN \ - _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) -# else -# define WINT_MIN \ - _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +/* If gnulib's or overrides wint_t, @WINT_T_SUFFIX@ is not + accurate, therefore use the definitions from above. */ +# if !@GNULIB_OVERRIDES_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# if @HAVE_SIGNED_WINT_T@ +# define WINT_MIN \ + _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# else +# define WINT_MIN \ + _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +# endif +# define WINT_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) # endif -# define WINT_MAX \ - _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) /* 7.18.4. Macros for integer constants */ diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 4a8aa55528..7c283ad391 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -203,7 +203,9 @@ _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fclose); +# endif #elif defined GNULIB_POSIXCHECK # undef fclose /* Assume fclose is always declared. */ @@ -247,7 +249,9 @@ _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); # else _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fflush); +# endif #elif defined GNULIB_POSIXCHECK # undef fflush /* Assume fflush is always declared. */ @@ -266,7 +270,9 @@ _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fgetc); +# endif #endif #if @GNULIB_FGETS@ @@ -281,7 +287,9 @@ _GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); # else _GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fgets); +# endif #endif #if @GNULIB_FOPEN@ @@ -296,7 +304,9 @@ _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); # else _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fopen); +# endif #elif defined GNULIB_POSIXCHECK # undef fopen /* Assume fopen is always declared. */ @@ -324,7 +334,9 @@ _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); # else _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fprintf); +# endif #endif #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_fprintf @@ -375,7 +387,9 @@ _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fputc); +# endif #endif #if @GNULIB_FPUTS@ @@ -390,7 +404,9 @@ _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); # else _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fputs); +# endif #endif #if @GNULIB_FREAD@ @@ -405,7 +421,9 @@ _GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); # else _GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fread); +# endif #endif #if @GNULIB_FREOPEN@ @@ -423,7 +441,9 @@ _GL_CXXALIAS_RPL (freopen, FILE *, _GL_CXXALIAS_SYS (freopen, FILE *, (const char *filename, const char *mode, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (freopen); +# endif #elif defined GNULIB_POSIXCHECK # undef freopen /* Assume freopen is always declared. */ @@ -445,7 +465,9 @@ _GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); # else _GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fscanf); +# endif #endif @@ -496,7 +518,9 @@ _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); # else _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fseek); +# endif #endif #if @GNULIB_FSEEKO@ @@ -559,7 +583,9 @@ _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); # else _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (ftell); +# endif #endif #if @GNULIB_FTELLO@ @@ -639,7 +665,9 @@ extern size_t __REDIRECT (rpl_fwrite_unlocked, # define fwrite_unlocked rpl_fwrite_unlocked # endif # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fwrite); +# endif #endif #if @GNULIB_GETC@ @@ -653,7 +681,9 @@ _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); # else _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getc); +# endif #endif #if @GNULIB_GETCHAR@ @@ -667,7 +697,9 @@ _GL_CXXALIAS_RPL (getchar, int, (void)); # else _GL_CXXALIAS_SYS (getchar, int, (void)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getchar); +# endif #endif #if @GNULIB_GETDELIM@ @@ -832,7 +864,9 @@ _GL_CXXALIAS_RPL (perror, void, (const char *string)); # else _GL_CXXALIAS_SYS (perror, void, (const char *string)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (perror); +# endif #elif defined GNULIB_POSIXCHECK # undef perror /* Assume perror is always declared. */ @@ -903,7 +937,9 @@ _GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); # else _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (printf); +# endif #endif #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_printf @@ -926,7 +962,9 @@ _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); # else _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (putc); +# endif #endif #if @GNULIB_PUTCHAR@ @@ -940,7 +978,9 @@ _GL_CXXALIAS_RPL (putchar, int, (int c)); # else _GL_CXXALIAS_SYS (putchar, int, (int c)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (putchar); +# endif #endif #if @GNULIB_PUTS@ @@ -954,7 +994,9 @@ _GL_CXXALIAS_RPL (puts, int, (const char *string)); # else _GL_CXXALIAS_SYS (puts, int, (const char *string)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (puts); +# endif #endif #if @GNULIB_REMOVE@ @@ -968,7 +1010,9 @@ _GL_CXXALIAS_RPL (remove, int, (const char *name)); # else _GL_CXXALIAS_SYS (remove, int, (const char *name)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (remove); +# endif #elif defined GNULIB_POSIXCHECK # undef remove /* Assume remove is always declared. */ @@ -991,7 +1035,9 @@ _GL_CXXALIAS_RPL (rename, int, _GL_CXXALIAS_SYS (rename, int, (const char *old_filename, const char *new_filename)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (rename); +# endif #elif defined GNULIB_POSIXCHECK # undef rename /* Assume rename is always declared. */ @@ -1056,7 +1102,9 @@ _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); # else _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (scanf); +# endif #endif #if @GNULIB_SNPRINTF@ @@ -1110,7 +1158,9 @@ _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); # else _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (sprintf); +# endif #elif defined GNULIB_POSIXCHECK # undef sprintf /* Assume sprintf is always declared. */ @@ -1129,7 +1179,9 @@ _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); # else _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (tmpfile); +# endif #elif defined GNULIB_POSIXCHECK # undef tmpfile # if HAVE_RAW_DECL_TMPFILE @@ -1240,7 +1292,9 @@ _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); _GL_CXXALIAS_SYS_CAST (vfprintf, int, (FILE *fp, const char *format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vfprintf); +# endif #endif #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_vfprintf @@ -1294,7 +1348,9 @@ _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); and GCC's fixincludes did not change this to __gnuc_va_list. */ _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vprintf); +# endif #endif #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK # if !GNULIB_overrides_vprintf @@ -1370,7 +1426,9 @@ _GL_CXXALIAS_RPL (vsprintf, int, _GL_CXXALIAS_SYS_CAST (vsprintf, int, (char *str, const char *format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vsprintf); +# endif #elif defined GNULIB_POSIXCHECK # undef vsprintf /* Assume vsprintf is always declared. */ diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index e5583d967c..2d02b4b012 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -176,7 +176,9 @@ _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); # else _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (calloc); +# endif #elif defined GNULIB_POSIXCHECK # undef calloc /* Assume calloc is always declared. */ @@ -288,7 +290,9 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); # else _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (malloc); +# endif #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef malloc /* Assume malloc is always declared. */ @@ -311,7 +315,9 @@ _GL_FUNCDECL_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # endif _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mbtowc); +# endif #elif defined GNULIB_POSIXCHECK # undef mbtowc # if HAVE_RAW_DECL_MBTOWC @@ -616,7 +622,9 @@ _GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); # if !@HAVE_RANDOM@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); # endif -_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed)); +/* Need to cast, because on FreeBSD, the first parameter is + unsigned long seed. */ +_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); # endif _GL_CXXALIASWARN (srandom); #elif defined GNULIB_POSIXCHECK @@ -644,8 +652,10 @@ _GL_FUNCDECL_SYS (initstate, char *, (unsigned int seed, char *buf, size_t buf_size) _GL_ARG_NONNULL ((2))); # endif -_GL_CXXALIAS_SYS (initstate, char *, - (unsigned int seed, char *buf, size_t buf_size)); +/* Need to cast, because on FreeBSD, the first parameter is + unsigned long seed. */ +_GL_CXXALIAS_SYS_CAST (initstate, char *, + (unsigned int seed, char *buf, size_t buf_size)); # endif _GL_CXXALIASWARN (initstate); #elif defined GNULIB_POSIXCHECK @@ -668,7 +678,9 @@ _GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); # endif -_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state)); +/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter + is const char *arg_state. */ +_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); # endif _GL_CXXALIASWARN (setstate); #elif defined GNULIB_POSIXCHECK @@ -809,7 +821,9 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (realloc); +# endif #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC # undef realloc /* Assume realloc is always declared. */ @@ -940,7 +954,9 @@ _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) # endif _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (strtod); +# endif #elif defined GNULIB_POSIXCHECK # undef strtod # if HAVE_RAW_DECL_STRTOD @@ -1079,7 +1095,9 @@ _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); # else _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (wctomb); +# endif #endif diff --git a/lib/string.in.h b/lib/string.in.h index c57f041c06..9b8ced24cd 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -149,7 +149,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr, _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); _GL_CXXALIASWARN1 (memchr, void const *, (void const *__s, int __c, size_t __n)); -# else +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (memchr); # endif #elif defined GNULIB_POSIXCHECK @@ -417,7 +417,9 @@ _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); # else _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (strncat); +# endif #elif defined GNULIB_POSIXCHECK # undef strncat # if HAVE_RAW_DECL_STRNCAT @@ -512,7 +514,7 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk, _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); _GL_CXXALIASWARN1 (strpbrk, char const *, (char const *__s, char const *__accept)); -# else +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strpbrk); # endif # if defined GNULIB_POSIXCHECK @@ -614,7 +616,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr, _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strstr, const char *, (const char *haystack, const char *needle)); -# else +# elif __GLIBC__ >= 2 _GL_CXXALIASWARN (strstr); # endif #elif defined GNULIB_POSIXCHECK @@ -980,7 +982,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int)); # else _GL_CXXALIAS_SYS (strerror, char *, (int)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (strerror); +# endif #elif defined GNULIB_POSIXCHECK # undef strerror /* Assume strerror is always declared. */ diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index 4cf7cfc8e1..1a3c14fb0a 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h @@ -295,11 +295,11 @@ _GL_FUNCDECL_RPL (select, int, struct timeval *restrict)); _GL_CXXALIAS_RPL (select, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, - struct timeval *restrict)); + timeval *restrict)); # else _GL_CXXALIAS_SYS (select, int, (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, - struct timeval *restrict)); + timeval *restrict)); # endif _GL_CXXALIASWARN (select); #elif @HAVE_WINSOCK2_H@ diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h index 539768889d..d6c215e1f5 100644 --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -112,8 +112,12 @@ _GL_CXXALIASWARN (gettimeofday); # if defined __cplusplus && defined GNULIB_NAMESPACE namespace GNULIB_NAMESPACE { typedef ::timeval -#undef timeval +# undef timeval timeval; +# if @REPLACE_STRUCT_TIMEVAL@ +# define timeval rpl_timeval + typedef ::timeval timeval; +# endif } # endif #elif defined GNULIB_POSIXCHECK diff --git a/lib/time.in.h b/lib/time.in.h index 40e5b2063f..1b3bf3ea7e 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -37,6 +37,12 @@ # define _@GUARD_PREFIX@_TIME_H +/* mingw's provides the functions asctime_r, ctime_r, gmtime_r, + localtime_r only if or has been included before. */ +# if defined __MINGW32__ +# include +# endif + # @INCLUDE_NEXT@ @NEXT_TIME_H@ /* NetBSD 5.0 mis-defines NULL. */ @@ -149,7 +155,9 @@ _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); # else _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (mktime); +# endif # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See @@ -217,7 +225,9 @@ _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); # else _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (localtime); +# endif # endif # if 0 || @REPLACE_GMTIME@ @@ -264,7 +274,9 @@ _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); # else _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (ctime); +# endif # endif /* Convert *TP to a date and time string. See @@ -283,7 +295,9 @@ _GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize, _GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize, const char *__fmt, const struct tm *__tp)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (strftime); +# endif # endif # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ diff --git a/lib/unistd.in.h b/lib/unistd.in.h index cc57ce680d..4700ccb28e 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -749,7 +749,9 @@ _GL_CXXALIAS_RPL (getdtablesize, int, (void)); # if !@HAVE_GETDTABLESIZE@ _GL_FUNCDECL_SYS (getdtablesize, int, (void)); # endif -_GL_CXXALIAS_SYS (getdtablesize, int, (void)); +/* Need to cast, because on AIX, the parameter list is + (...). */ +_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void)); # endif _GL_CXXALIASWARN (getdtablesize); #elif defined GNULIB_POSIXCHECK diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 5caeca7509..cc4b3e009b 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -17,7 +17,15 @@ AC_DEFUN([gl_TIME_R], dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is dnl not defined. - AC_CHECK_DECLS([localtime_r], [], [], [[#include ]]) + AC_CHECK_DECLS([localtime_r], [], [], + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]]) if test $ac_cv_have_decl_localtime_r = no; then HAVE_DECL_LOCALTIME_R=0 fi @@ -29,7 +37,14 @@ AC_DEFUN([gl_TIME_R], [gl_cv_time_r_posix], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include ]], + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], [[/* We don't need to append 'restrict's to the argument types, even though the POSIX signature has the 'restrict's, since C99 says they can't affect type compatibility. */ @@ -49,6 +64,32 @@ AC_DEFUN([gl_TIME_R], fi else HAVE_LOCALTIME_R=0 + dnl On mingw, localtime_r() is defined as an inline function; use through a + dnl direct function call works but the use as a function pointer leads to a + dnl link error. + AC_CACHE_CHECK([whether localtime_r exists as an inline function], + [gl_cv_func_localtime_r_inline], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], + [[time_t a; + struct tm r; + localtime_r (&a, &r); + ]]) + ], + [gl_cv_func_localtime_r_inline=yes], + [gl_cv_func_localtime_r_inline=no]) + ]) + if test $gl_cv_func_localtime_r_inline = yes; then + REPLACE_LOCALTIME_R=1 + fi fi ]) commit 50b52390ee5894e91965bd37f2d0c571df1e2e89 Author: Stefan Monnier Date: Tue Nov 26 13:58:39 2019 -0500 * lisp/subr.el (do-after-load-evaluation): Handle batch mode as well diff --git a/lisp/subr.el b/lisp/subr.el index 20daed623f..fe55566b52 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4599,31 +4599,31 @@ This function is called directly from the C code." ;; discard the file name regexp (mapc #'funcall (cdr a-l-element)))) ;; Complain when the user uses obsolete files. - (when (string-match-p "/obsolete/\\([^/]*\\)\\'" abs-file) + (when (string-match-p "/obsolete/[^/]*\\'" abs-file) ;; Maybe we should just use display-warning? This seems yucky... (let* ((file (file-name-nondirectory abs-file)) (package (intern (substring file 0 (string-match "\\.elc?\\>" file)) obarray)) - (msg (format "Package %s is deprecated" package))) + (msg (format "Package %s is deprecated" package)) + (fun (lambda (msg) (minibuffer-message "%s" msg)))) ;; Cribbed from cl--compiling-file. (when (or (not (fboundp 'byte-compile-warning-enabled-p)) (byte-compile-warning-enabled-p 'obsolete package)) - (if (and (boundp 'byte-compile--outbuffer) - (bufferp (symbol-value 'byte-compile--outbuffer)) - (equal (buffer-name (symbol-value 'byte-compile--outbuffer)) - " *Compiler Output*")) - ;; Don't warn about obsolete files using other obsolete files. - (unless (and (stringp byte-compile-current-file) - (string-match-p "/obsolete/[^/]*\\'" - (expand-file-name - byte-compile-current-file - byte-compile-root-dir))) - (byte-compile-warn "%s" msg)) - (run-with-idle-timer 0 nil - (lambda (msg) - (minibuffer-message "%s" msg)) - msg))))) + (cond + ((and (boundp 'byte-compile--outbuffer) + (bufferp (symbol-value 'byte-compile--outbuffer)) + (equal (buffer-name (symbol-value 'byte-compile--outbuffer)) + " *Compiler Output*")) + ;; Don't warn about obsolete files using other obsolete files. + (unless (and (stringp byte-compile-current-file) + (string-match-p "/obsolete/[^/]*\\'" + (expand-file-name + byte-compile-current-file + byte-compile-root-dir))) + (byte-compile-warn "%s" msg))) + (noninteractive (funcall fun)) ;; No timer will be run! + (t (run-with-idle-timer 0 nil fun msg)))))) ;; Finally, run any other hook. (run-hook-with-args 'after-load-functions abs-file)) commit 95e218af145d843750c9f05ae7682230a36044a6 Author: Robert Pluim Date: Tue Nov 26 19:07:42 2019 +0100 Use 127.0.0.1 in nsm-tests Winsock doesn't like "127.1" * test/lisp/net/nsm-tests.el (nsm-check-local-subnet-ipv4): Spell numeric localhost as "127.0.0.1" instead of "127.1". diff --git a/test/lisp/net/nsm-tests.el b/test/lisp/net/nsm-tests.el index bf6ac04b52..f354437038 100644 --- a/test/lisp/net/nsm-tests.el +++ b/test/lisp/net/nsm-tests.el @@ -42,11 +42,11 @@ (should-error (nsm-network-same-subnet local-ip wrong-length-mask remote-ip-yes)) (should (eq nil (nsm-network-same-subnet local-ip wrong-mask remote-ip-yes))) (should (eq t (nsm-should-check "google.com"))) - (should (eq t (nsm-should-check "127.1"))) + (should (eq t (nsm-should-check "127.0.0.1"))) (should (eq t (nsm-should-check "localhost"))) (let ((nsm-trust-local-network t)) (should (eq t (nsm-should-check "google.com"))) - (should (eq nil (nsm-should-check "127.1"))) + (should (eq nil (nsm-should-check "127.0.0.1"))) (should (eq nil (nsm-should-check "localhost")))))) ;; FIXME This will never return true, since commit 384d1c47cec8e61d1896694b14fcf88710f9dc4d Author: Stefan Monnier Date: Tue Nov 26 13:18:18 2019 -0500 * test/lisp/minibuffer-tests.el (completion-table-test-quoting): New test * test/data/minibuffer-test-cttq$tion: New file-name test data. diff --git a/test/data/minibuffer-test-cttq$tion b/test/data/minibuffer-test-cttq$tion new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 35df7cc17f..6b29724421 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -80,5 +80,26 @@ (should (equal (try-completion "B-hel" subvtable) "B-hello")))) +(ert-deftest completion-table-test-quoting () + (let ((process-environment + `("CTTQ1=ed" "CTTQ2=et/" ,@process-environment))) + (pcase-dolist (`(,input ,output) + '( + ;; Test that $ in files is properly $$ quoted. + ("data/m-cttq" "data/minibuffer-test-cttq$$tion") + ;; Test that $$ in input is properly unquoted. + ("data/m-cttq$$t" "data/minibuffer-test-cttq$$tion") + ;; Test that env-vars are preserved. + ("lisp/c${CTTQ1}et/se-u" "lisp/c${CTTQ1}et/semantic-utest") + ("lisp/ced${CTTQ2}se-u" "lisp/ced${CTTQ2}semantic-utest") + ;; Test that env-vars don't prevent partial-completion. + ;; FIXME: Ideally we'd like to keep the ${CTTQ}! + ("lis/c${CTTQ1}/se-u" "lisp/cedet/semantic-utest") + )) + (should (equal (completion-try-completion input + #'completion--file-name-table + nil (length input)) + (cons output (length output))))))) + (provide 'completion-tests) ;;; completion-tests.el ends here commit d4515f3cabcb2e70d71cd4133d069f5286d30654 Author: Eli Zaretskii Date: Tue Nov 26 19:29:45 2019 +0200 Support ':extend' in faces defined by list of key/value pairs * src/xfaces.c: Update and improve commentary at the beginning of the file. (face_attr_sym): New static array. (init_xfaces): Initialize 'face_attr_sym'. (merge_face_ref): Handle the :extend attribute in faces specified as lists of key/value pairs. (Bug#37774) diff --git a/src/xfaces.c b/src/xfaces.c index c3b455c928..440cf4f191 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -68,17 +68,25 @@ along with GNU Emacs. If not, see . */ On the other hand, if one of the other font-related attributes are specified, the corresponding specs in this attribute is set to nil. - 15. A face name or list of face names from which to inherit attributes. - - 16. A specified average font width, which is invisible from Lisp, - and is used to ensure that a font specified on the command line, - for example, can be matched exactly. + 16. A face name or list of face names from which to inherit attributes. 17. A fontset name. This is another special attribute. A fontset is a mappings from characters to font-specs, and the specs overwrite the font-spec in the 14th attribute. + 18. A "distant background" color, to be used when the foreground is + too close to the background and is hard to read. + + 19. Whether to extend the face to end of line when the face + "covers" the newline that ends the line. + + On the C level, a Lisp face is completely represented by its array + of attributes. In that array, the zeroth element is Qface, and the + rest are the 19 face attributes described above. The + lface_attribute_index enumeration, defined on dispextern.h, with + values given by the LFACE_*_INDEX constants, is used to reference + the individual attributes. Faces are frame-local by nature because Emacs allows you to define the same named face (face names are symbols) differently for different @@ -100,10 +108,18 @@ along with GNU Emacs. If not, see . */ The display style of a given character in the text is determined by combining several faces. This process is called `face merging'. - Any aspect of the display style that isn't specified by overlays or - text properties is taken from the `default' face. Since it is made - sure that the default face is always fully-specified, face merging - always results in a fully-specified face. + Face merging combines the attributes of each of the faces being + merged such that the attributes of the face that is merged later + override those of a face merged earlier in the process. In + particular, this replaces any 'unspecified' attributes with + non-'unspecified' values. Also, if a face inherits from another + (via the :inherit attribute), the attributes of the parent face, + recursively, are applied where the inheriting face doesn't specify + non-'unspecified' values. Any aspect of the display style that + isn't specified by overlays or text properties is taken from the + 'default' face. Since it is made sure that the default face is + always fully-specified, face merging always results in a + fully-specified face. Face realization. @@ -1604,6 +1620,9 @@ the WIDTH times as wide as FACE on FRAME. */) && EQ (AREF (LFACE, 0), Qface)) +/* Face attribute symbols for each value of LFACE_*_INDEX. */ +static Lisp_Object face_attr_sym[LFACE_VECTOR_SIZE]; + #ifdef GLYPH_DEBUG /* Check consistency of Lisp face attribute vector ATTRS. */ @@ -2397,6 +2416,58 @@ merge_face_ref (struct window *w, && *SDATA (SYMBOL_NAME (first)) == ':') { /* Assume this is the property list form. */ + if (attr_filter > 0) + { + eassert (attr_filter < LFACE_VECTOR_SIZE); + /* ATTR_FILTER positive means don't merge this face if + the corresponding attribute is nil, or not mentioned, + or if it's unspecified and the face doesn't inherit + from a face whose attribute is non-nil. The code + below determines whether a face given as a property + list shall be merged. */ + Lisp_Object parent_face = Qnil; + bool attr_filter_seen = false; + Lisp_Object face_ref_tem = face_ref; + while (CONSP (face_ref_tem) && CONSP (XCDR (face_ref_tem))) + { + Lisp_Object keyword = XCAR (face_ref_tem); + Lisp_Object value = XCAR (XCDR (face_ref_tem)); + + if (EQ (keyword, face_attr_sym[attr_filter]) + || (attr_filter == LFACE_INVERSE_INDEX + && EQ (keyword, QCreverse_video))) + { + attr_filter_seen = true; + if (NILP (value)) + return true; + } + else if (EQ (keyword, QCinherit)) + parent_face = value; + face_ref_tem = XCDR (XCDR (face_ref_tem)); + } + if (!attr_filter_seen) + { + if (NILP (parent_face)) + return true; + + Lisp_Object scratch_attrs[LFACE_VECTOR_SIZE]; + int i; + + scratch_attrs[0] = Qface; + for (i = 1; i < LFACE_VECTOR_SIZE; i++) + scratch_attrs[i] = Qunspecified; + if (!merge_face_ref (w, f, parent_face, scratch_attrs, + err_msgs, named_merge_points, 0)) + { + add_to_log ("Invalid face attribute %S %S", + QCinherit, parent_face); + return false; + } + if (NILP (scratch_attrs[attr_filter]) + || UNSPECIFIEDP (scratch_attrs[attr_filter])) + return true; + } + } while (CONSP (face_ref) && CONSP (XCDR (face_ref))) { Lisp_Object keyword = XCAR (face_ref); @@ -6590,6 +6661,25 @@ init_xfaces (void) lface_id_to_name[i--] = XCAR (lface); } } + face_attr_sym[0] = Qface; + face_attr_sym[LFACE_FOUNDRY_INDEX] = QCfoundry; + face_attr_sym[LFACE_SWIDTH_INDEX] = QCwidth; + face_attr_sym[LFACE_HEIGHT_INDEX] = QCheight; + face_attr_sym[LFACE_WEIGHT_INDEX] = QCweight; + face_attr_sym[LFACE_SLANT_INDEX] = QCslant; + face_attr_sym[LFACE_UNDERLINE_INDEX] = QCunderline; + face_attr_sym[LFACE_INVERSE_INDEX] = QCinverse_video; + face_attr_sym[LFACE_FOREGROUND_INDEX] = QCforeground; + face_attr_sym[LFACE_BACKGROUND_INDEX] = QCbackground; + face_attr_sym[LFACE_STIPPLE_INDEX] = QCstipple; + face_attr_sym[LFACE_OVERLINE_INDEX] = QCoverline; + face_attr_sym[LFACE_STRIKE_THROUGH_INDEX] = QCstrike_through; + face_attr_sym[LFACE_BOX_INDEX] = QCbox; + face_attr_sym[LFACE_FONT_INDEX] = QCfont; + face_attr_sym[LFACE_INHERIT_INDEX] = QCinherit; + face_attr_sym[LFACE_FONTSET_INDEX] = QCfontset; + face_attr_sym[LFACE_DISTANT_FOREGROUND_INDEX] = QCdistant_foreground; + face_attr_sym[LFACE_EXTEND_INDEX] = QCextend; } #endif commit 094eb04ce5d8c1ccef78113c8cc6791d1d3b6bf8 Author: Eli Zaretskii Date: Tue Nov 26 19:13:12 2019 +0200 Fix MS-Windows build with mingw.org's MinGW mingw.org's MinGW by default targets Windows 9X, so _WIN32_WINNT is set to a value that bypasses declarations in system headers we need to compile network_interface_list. Also, the code needed a workaround for Windows XP, where some functionality is missing from the GetAdaptersAddresses API. * src/w32.c (_WIN32_WINNT): Define to 0x0501, if the value is lower, temporarily while processing iphlpapi.h. (address_prefix_match): New helper function. (network_interface_list): Work around the fact that the OnLinkPrefixLength member of IP_ADAPTER_UNICAST_ADDRESS is not available when _WIN32_WINNT < 0x0600. On Windows XP use special code that calls address_prefix_match to compute the network prefix length. diff --git a/src/w32.c b/src/w32.c index 76c226892a..cb82d51fb9 100644 --- a/src/w32.c +++ b/src/w32.c @@ -242,8 +242,22 @@ typedef struct _REPARSE_DATA_BUFFER { #undef recvfrom #undef sendto +/* We need at least XP level for GetAdaptersAddresses stuff. */ +#if _WIN32_WINNT < 0x0501 +# undef ORIG_WIN32_WINNT +# define ORIG_WIN32_WINNT _WIN32_WINNT +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +#endif + #include /* should be after winsock2.h */ +#ifdef ORIG_WIN32_WINNT +# undef _WIN32_WINNT +# define _WIN32_WINNT ORIG_WIN32_WINNT +# undef ORIG_WIN32_WINNT +#endif + #include #include @@ -9432,6 +9446,40 @@ network_interface_get_info (Lisp_Object ifname) return res; } +static bool +address_prefix_match (int family, struct sockaddr *address, + struct sockaddr *prefix_address, ULONG prefix_len) +{ + UINT8 *address_data; + UINT8 *prefix_address_data; + int i; + + if (family == AF_INET6) + { + address_data = (UINT8 *) &(((struct sockaddr_in6 *) address)->sin6_addr); + prefix_address_data = + (UINT8 *) &(((struct sockaddr_in6 *) prefix_address)->sin6_addr); + } + else + { + address_data = (UINT8 *) &(((struct sockaddr_in *) address)->sin_addr); + prefix_address_data = + (UINT8 *) &(((struct sockaddr_in *) prefix_address)->sin_addr); + } + + for (i = 0; i < prefix_len >> 3; i++) + { + if (address_data[i] != prefix_address_data[i]) + return false; + } + + if (prefix_len % 8) + return (prefix_address_data[i] == + (address_data[i] & (0xff << (8 - prefix_len % 8)))); + + return true; +} + Lisp_Object network_interface_list (bool full, unsigned short match) { @@ -9586,7 +9634,37 @@ network_interface_list (bool full, unsigned short match) byte order, so convert from host to network order when generating the netmask. */ int i; - ULONG numbits = address->OnLinkPrefixLength; + ULONG numbits; + if (w32_major_version >= 6) /* Vista or later */ + { +#if _WIN32_WINNT >= 0x0600 + numbits = address->OnLinkPrefixLength; +#else + /* Kludge alert! OnLinkPrefixLength is only defined + when compiling for Vista and later. */ + numbits = *(UINT8 *) (address->LeaseLifetime + + sizeof (address->LeaseLifetime)); +#endif + } + else /* Windows XP */ + { + IP_ADAPTER_PREFIX *prefix = adapter->FirstPrefix; + numbits = 0; + for ( ; prefix; prefix = prefix->Next) + { + /* We want the longest matching prefix. */ + if (prefix->Address.lpSockaddr->sa_family + != ifa_addr->sa_family + || prefix->PrefixLength <= numbits) + continue; + if (address_prefix_match (ifa_addr->sa_family, ifa_addr, + prefix->Address.lpSockaddr, + prefix->PrefixLength)) + numbits = prefix->PrefixLength; + } + if (!numbits) + numbits = (ifa_addr->sa_family == AF_INET6) ? 128 : 32; + } for (i = 0; i < addr_len; i++) { if (numbits >= 32) commit 52eca2d3bdef293e9f5d64aa2b9ca36f1e00e817 Author: Stefan Monnier Date: Tue Nov 26 09:04:12 2019 -0500 * lisp/progmodes/asm-mode.el (asm-mode-map): Obey electric-indent-mode diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el index 017a5b5bac..04ef043067 100644 --- a/lisp/progmodes/asm-mode.el +++ b/lisp/progmodes/asm-mode.el @@ -73,8 +73,6 @@ ;; Note that the comment character isn't set up until asm-mode is called. (define-key map ":" 'asm-colon) (define-key map "\C-c;" 'comment-region) - (define-key map "\C-j" 'newline-and-indent) - (define-key map "\C-m" 'newline-and-indent) (define-key map [menu-bar asm-mode] (cons "Asm" (make-sparse-keymap))) (define-key map [menu-bar asm-mode comment-region] '(menu-item "Comment Region" comment-region @@ -135,7 +133,7 @@ Special commands: ;; Make our own local child of asm-mode-map ;; so we can define our own comment character. (use-local-map (nconc (make-sparse-keymap) asm-mode-map)) - (local-set-key (vector asm-comment-char) 'asm-comment) + (local-set-key (vector asm-comment-char) #'asm-comment) (set-syntax-table (make-syntax-table asm-mode-syntax-table)) (modify-syntax-entry asm-comment-char "< b") @@ -185,7 +183,7 @@ Special commands: (delete-horizontal-space) (tab-to-tab-stop)))) -(define-obsolete-function-alias 'asm-newline 'newline-and-indent "27.1") +(define-obsolete-function-alias 'asm-newline #'newline-and-indent "27.1") (defun asm-comment () "Convert an empty comment to a `larger' kind, or start a new one. commit e495dbea7035bcb1f26ed82f0d56a5abc90974fa Author: Juanma Barranquero Date: Tue Nov 26 15:03:57 2019 +0100 (next|previous)-buffer no longer fail silently (bug#38384) * lisp/window.el (next-buffer, previous-buffer): Signal 'user-error' if there is no buffer to switch to. * etc/NEWS: Document it. diff --git a/etc/NEWS b/etc/NEWS index 2a14eb2ecf..d3331daf17 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2620,6 +2620,10 @@ scrolling. ** help-follow-symbol now signals 'user-error' if point (or the position pointed to by the argument POS) is not in a symbol. +--- +*** next-buffer and previous-buffer now signal 'user-error' if there +is no buffer to switch to. + * Lisp Changes in Emacs 27.1 diff --git a/lisp/window.el b/lisp/window.el index 49fad75d3c..c8a5816b8c 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4850,7 +4850,8 @@ minibuffer window or is dedicated to its buffer." (user-error "Window is strongly dedicated to its buffer")) (t (dotimes (_ (or arg 1)) - (switch-to-next-buffer))))) + (unless (switch-to-next-buffer) + (user-error "No next buffer")))))) (defun previous-buffer (&optional arg) "In selected window switch to ARGth previous buffer. @@ -4864,7 +4865,8 @@ minibuffer window or is dedicated to its buffer." (user-error "Window is strongly dedicated to its buffer")) (t (dotimes (_ (or arg 1)) - (switch-to-prev-buffer))))) + (unless (switch-to-prev-buffer) + (user-error "No previous buffer")))))) (defun delete-windows-on (&optional buffer-or-name frame) "Delete all windows showing BUFFER-OR-NAME. commit 90a7cd073bfc7461e0bc824e9883499fe9026727 Author: Juanma Barranquero Date: Tue Nov 26 14:00:25 2019 +0100 lisp/auth-source.el: Depend on cl-lib unconditionally A change in 2016-04-24 introduced a run-time dependency on cl-subseq. diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 89a468570a..452165a68b 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -42,7 +42,7 @@ (require 'json) (require 'password-cache) -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (require 'eieio) (autoload 'secrets-create-item "secrets") commit db2d6398a586f92020d4ef2742ca43f3900b80b4 Author: Juanma Barranquero Date: Tue Nov 26 12:55:29 2019 +0100 lisp/auth-source-pass.el: Require cl-lib unconditionally Changes in 2019-05-05 and 2019-05-14 introduced run-time dependencies on cl-maplist and cl-remove-if-not. diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 51322e4ec1..45d5a6ce81 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -34,8 +34,7 @@ (require 'seq) (eval-when-compile (require 'subr-x)) -(eval-when-compile - (require 'cl-lib)) +(require 'cl-lib) (require 'auth-source) (require 'url-parse)