------------------------------------------------------------ revno: 117534 committer: Daniel Colascione branch nick: trunk timestamp: Mon 2014-07-14 16:58:52 -0700 message: Unbreak compilation of derived cc-mode modes * lisp/progmodes/cc-defs.el (c-lang-defconst-eval-immediately): Use `macroexpand-all' instead of `cl-macroexpand-all'. * lisp/progmodes/cc-langs.el: Change comments from `cl-macroexpand-all' to `macroexpand-all' diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-07-12 17:53:29 +0000 +++ lisp/ChangeLog 2014-07-14 23:58:52 +0000 @@ -1,3 +1,11 @@ +2014-07-14 Daniel Colascione + + * progmodes/cc-langs.el: Change comments from `cl-macroexpand-all' + to `macroexpand-all' + + * progmodes/cc-defs.el (c-lang-defconst-eval-immediately): + Use `macroexpand-all' instead of `cl-macroexpand-all'. + 2014-07-12 Paul Eggert Fix bug: C-x v v discarded existing log message (Bug#17884). === modified file 'lisp/progmodes/cc-defs.el' --- lisp/progmodes/cc-defs.el 2014-06-29 11:26:47 +0000 +++ lisp/progmodes/cc-defs.el 2014-07-14 23:58:52 +0000 @@ -1836,12 +1836,9 @@ immediately, i.e. at the same time as the `c-lang-defconst' form itself is evaluated." ;; Evaluate at macro expansion time, i.e. in the - ;; `cl-macroexpand-all' inside `c-lang-defconst'. + ;; `macroexpand-all' inside `c-lang-defconst'. (eval form)) -;; Only used at compile time - suppress "might not be defined at runtime". -(declare-function cl-macroexpand-all "cl" (form &optional env)) - (defmacro c-lang-defconst (name &rest args) "Set the language specific values of the language constant NAME. The second argument can optionally be a docstring. The rest of the @@ -1883,7 +1880,7 @@ (let* ((sym (intern (symbol-name name) c-lang-constants)) ;; Make `c-lang-const' expand to a straightforward call to - ;; `c-get-lang-constant' in `cl-macroexpand-all' below. + ;; `c-get-lang-constant' in `macroexpand-all' below. ;; ;; (The default behavior, i.e. to expand to a call inside ;; `eval-when-compile' should be equivalent, since that macro @@ -1946,7 +1943,7 @@ ;; reason, but we also use this expansion handle ;; `c-lang-defconst-eval-immediately' and to register ;; dependencies on the `c-lang-const's in VAL.) - (setq val (cl-macroexpand-all val)) + (setq val (macroexpand-all val)) (setq bindings (cons (cons assigned-mode val) bindings) args (cdr args)))) === modified file 'lisp/progmodes/cc-langs.el' --- lisp/progmodes/cc-langs.el 2014-06-29 11:26:47 +0000 +++ lisp/progmodes/cc-langs.el 2014-07-14 23:58:52 +0000 @@ -213,7 +213,6 @@ ;; These are defined in cl as aliases to the cl- versions. ;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t) ;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t) -;(declare-function cl-macroexpand-all "cl" (form &optional env)) (eval-and-compile ;; Some helper functions used when building the language constants. @@ -3185,7 +3184,7 @@ `(lambda () ;; This let sets up the context for `c-mode-var' and similar - ;; that could be in the result from `cl-macroexpand-all'. + ;; that could be in the result from `macroexpand-all'. (let ((c-buffer-is-cc-mode ',mode) current-var source-eval) (c-make-emacs-variables-local) @@ -3195,7 +3194,7 @@ (setq ,@(let ((c-buffer-is-cc-mode mode) (c-lang-const-expansion 'immediate)) ;; `c-lang-const' will expand to the evaluated - ;; constant immediately in `cl-macroexpand-all' + ;; constant immediately in `macroexpand-all' ;; below. (cl-mapcan (lambda (init) ------------------------------------------------------------ revno: 117533 fixes bug: http://debbugs.gnu.org/18006 committer: Paul Eggert branch nick: trunk timestamp: Mon 2014-07-14 12:23:18 -0700 message: Use binary-io module, O_BINARY, and "b" flag. * admin/merge-gnulib (GNULIB_MODULES): Add binary-io. It was already present implicitly; this just makes the dependence explicit. * lib-src/etags.c, lib-src/hexl.c, lib-src/make-docfile.c: Include binary-io.h instead of fcntl.h and/or io.h. (main): Use set_binary_mode or SET_BINARY in place of handcrafted code. * lib-src/etags.c (main) [DOS_NT]: * lib-src/movemail.c (main) [WINDOWSNT]: Don't mess with _fmode. * lib-src/etags.c (main, process_file_name, analyse_regex): Use fopen/popen's "b" flag instead. * lib-src/movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY instead. * src/callproc.c (create_temp_file): Use mkostemp's O_BINARY flag. * src/emacs.c [MSDOS]: * src/emacs.c (main) [DOS_NT]: Don't mess with _fmode. (main) [MSDOS]: Use SET_BINARY instead of setmode. * src/minibuf.c: Include binary-io.h instead of fcntl.h. (read_minibuf_noninteractive): Use set_binary_mode instead of handcrafted code. Don't call emacs_set_tty if emacs_get_tty failed. * src/sysdep.c, src/systty.h (emacs_get_tty): Return int, not void. * src/sysdep.c (emacs_open, emacs_pipe): Use O_BINARY. * src/w32.c (pipe2): Adjust eassert to include O_BINARY. diff: === modified file 'admin/ChangeLog' --- admin/ChangeLog 2014-06-30 00:01:51 +0000 +++ admin/ChangeLog 2014-07-14 19:23:18 +0000 @@ -1,3 +1,9 @@ +2014-07-14 Paul Eggert + + Use binary-io module, O_BINARY, and "b" flag (Bug#18006). + * merge-gnulib (GNULIB_MODULES): Add binary-io. It was already + present implicitly; this just makes the dependence explicit. + 2014-06-30 Glenn Morris * update_autogen: Find loaddefs targets rather than === modified file 'admin/merge-gnulib' --- admin/merge-gnulib 2014-05-17 08:11:31 +0000 +++ admin/merge-gnulib 2014-07-14 19:23:18 +0000 @@ -26,7 +26,7 @@ GNULIB_URL=git://git.savannah.gnu.org/gnulib.git GNULIB_MODULES=' - alloca-opt byteswap c-ctype c-strcase + alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2014-07-14 00:45:19 +0000 +++ lib-src/ChangeLog 2014-07-14 19:23:18 +0000 @@ -1,3 +1,18 @@ +2014-07-14 Paul Eggert + + Use binary-io module, O_BINARY, and "b" flag (Bug#18006). + * etags.c, hexl.c, make-docfile.c: + Include binary-io.h instead of fcntl.h and/or io.h. + (main): Use set_binary_mode or SET_BINARY + in place of handcrafted code. + * etags.c (main) [DOS_NT]: + * movemail.c (main) [WINDOWSNT]: + Don't mess with _fmode. + * etags.c (main, process_file_name, analyse_regex): + Use fopen/popen's "b" flag instead. + * movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY + instead. + 2014-07-13 Paul Eggert * make-docfile.c: Simplify a bit, to simplify further refactoring. === modified file 'lib-src/etags.c' --- lib-src/etags.c 2014-07-12 16:26:54 +0000 +++ lib-src/etags.c 2014-07-14 19:23:18 +0000 @@ -105,17 +105,13 @@ #ifdef MSDOS # undef MSDOS # define MSDOS true -# include # include -# include #else # define MSDOS false #endif /* MSDOS */ #ifdef WINDOWSNT -# include # include -# include # define MAXPATHLEN _MAX_PATH # undef HAVE_NTGUI # undef DOS_NT @@ -131,6 +127,7 @@ #include #include #include +#include #include #include @@ -1002,13 +999,8 @@ linebuffer filename_lb; bool help_asked = false; ptrdiff_t len; - char *optstring; - int opt; - - -#ifdef DOS_NT - _fmode = O_BINARY; /* all of files are treated as binary files */ -#endif /* DOS_NT */ + char *optstring; + int opt; progname = argv[0]; nincluded_files = 0; @@ -1195,15 +1187,10 @@ if (streq (tagfile, "-")) { tagf = stdout; -#ifdef DOS_NT - /* Switch redirected `stdout' to binary mode (setting `_fmode' - doesn't take effect until after `stdout' is already open). */ - if (!isatty (fileno (stdout))) - setmode (fileno (stdout), O_BINARY); -#endif /* DOS_NT */ + SET_BINARY (fileno (stdout)); } else - tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); + tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb"); if (tagf == NULL) pfatal (tagfile); } @@ -1306,7 +1293,7 @@ append_to_tagfile = true; } - tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); + tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb"); if (tagf == NULL) pfatal (tagfile); put_entries (nodehead); /* write all the tags (CTAGS) */ @@ -1547,11 +1534,11 @@ if (real_name == compressed_name) { char *cmd = concat (compr->command, " ", real_name); - inf = (FILE *) popen (cmd, "r"); + inf = popen (cmd, "rb"); free (cmd); } else - inf = fopen (real_name, "r"); + inf = fopen (real_name, "rb"); if (inf == NULL) { perror (real_name); @@ -5614,7 +5601,7 @@ char *regexfile = regex_arg + 1; /* regexfile is a file containing regexps, one per line. */ - regexfp = fopen (regexfile, "r"); + regexfp = fopen (regexfile, "rb"); if (regexfp == NULL) pfatal (regexfile); linebuffer_init (®exbuf); === modified file 'lib-src/hexl.c' --- lib-src/hexl.c 2014-01-01 07:43:34 +0000 +++ lib-src/hexl.c 2014-07-14 19:23:18 +0000 @@ -24,15 +24,8 @@ #include #include -#ifdef DOS_NT -#include -#if __DJGPP__ >= 2 -#include -#endif -#endif -#ifdef WINDOWSNT -#include -#endif + +#include #define DEFAULT_GROUPING 0x01 #define DEFAULT_BASE 16 @@ -155,20 +148,12 @@ if (un_flag) { - char buf[18]; + SET_BINARY (fileno (stdout)); -#ifdef DOS_NT -#if (__DJGPP__ >= 2) || (defined WINDOWSNT) - if (!isatty (fileno (stdout))) - setmode (fileno (stdout), O_BINARY); -#else - (stdout)->_flag &= ~_IOTEXT; /* print binary */ - _setmode (fileno (stdout), O_BINARY); -#endif -#endif for (;;) { - register int i, c = 0, d; + int i, c = 0, d; + char buf[18]; #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) @@ -210,15 +195,7 @@ } else { -#ifdef DOS_NT -#if (__DJGPP__ >= 2) || (defined WINDOWSNT) - if (!isatty (fileno (fp))) - setmode (fileno (fp), O_BINARY); -#else - (fp)->_flag &= ~_IOTEXT; /* read binary */ - _setmode (fileno (fp), O_BINARY); -#endif -#endif + SET_BINARY (fileno (fp)); address = 0; string[0] = ' '; string[17] = '\0'; === modified file 'lib-src/make-docfile.c' --- lib-src/make-docfile.c 2014-07-14 00:45:19 +0000 +++ lib-src/make-docfile.c 2014-07-14 19:23:18 +0000 @@ -38,17 +38,16 @@ #include #include /* config.h unconditionally includes this anyway */ -#ifdef MSDOS -#include -#endif /* MSDOS */ + #ifdef WINDOWSNT /* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this is really just insurance. */ #undef fopen -#include #include #endif /* WINDOWSNT */ +#include + #ifdef DOS_NT /* Defined to be sys_chdir in ms-w32.h, but only #ifdef emacs, so this is really just insurance. @@ -167,19 +166,7 @@ ++i; } - /* Don't put CRs in the output file. */ -#ifdef MSDOS - _fmode = O_BINARY; -#if 0 /* Suspicion is that this causes hanging. - So instead we require people to use -o on MSDOS. */ - (stdout)->_flag &= ~_IOTEXT; - _setmode (fileno (stdout), O_BINARY); -#endif -#endif /* MSDOS */ -#ifdef WINDOWSNT - _fmode = O_BINARY; - _setmode (fileno (stdout), O_BINARY); -#endif /* WINDOWSNT */ + set_binary_mode (fileno (stdout), O_BINARY); if (generate_globals) start_globals (); === modified file 'lib-src/movemail.c' --- lib-src/movemail.c 2014-01-01 07:43:34 +0000 +++ lib-src/movemail.c 2014-07-14 19:23:18 +0000 @@ -191,11 +191,6 @@ uid_t real_gid = getgid (); uid_t priv_gid = getegid (); -#ifdef WINDOWSNT - /* Ensure all file i/o is in binary mode. */ - _fmode = _O_BINARY; -#endif - delete_lockname = 0; while ((c = getopt (argc, argv, ARGSTR)) != EOF) @@ -304,7 +299,7 @@ memcpy (tempname, inname, inname_dirlen); strcpy (tempname + inname_dirlen, "EXXXXXX"); - desc = mkostemp (tempname, 0); + desc = mkostemp (tempname, O_BINARY); if (desc < 0) { int mkostemp_errno = errno; @@ -358,12 +353,12 @@ #ifndef MAIL_USE_MMDF #ifdef MAIL_USE_SYSTEM_LOCK - indesc = open (inname, O_RDWR); + indesc = open (inname, O_RDWR | O_BINARY); #else /* if not MAIL_USE_SYSTEM_LOCK */ - indesc = open (inname, O_RDONLY); + indesc = open (inname, O_RDONLY | O_BINARY); #endif /* not MAIL_USE_SYSTEM_LOCK */ #else /* MAIL_USE_MMDF */ - indesc = lk_open (inname, O_RDONLY, 0, 0, 10); + indesc = lk_open (inname, O_RDONLY | O_BINARY, 0, 0, 10); #endif /* MAIL_USE_MMDF */ if (indesc < 0) @@ -372,7 +367,7 @@ /* Make sure the user can read the output file. */ umask (umask (0) & 0377); - outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666); + outdesc = open (outname, O_WRONLY | O_BINARY | O_CREAT | O_EXCL, 0666); if (outdesc < 0) pfatal_with_name (outname); @@ -675,7 +670,7 @@ return EXIT_SUCCESS; } - mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666); + mbfi = open (outfile, O_WRONLY | O_BINARY | O_CREAT | O_EXCL, 0666); if (mbfi < 0) { pop_close (server); === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-14 19:07:54 +0000 +++ src/ChangeLog 2014-07-14 19:23:18 +0000 @@ -1,5 +1,18 @@ 2014-07-14 Paul Eggert + Use binary-io module, O_BINARY, and "b" flag (Bug#18006). + * callproc.c (create_temp_file): Use mkostemp's O_BINARY flag. + * emacs.c [MSDOS]: + * emacs.c (main) [DOS_NT]: Don't mess with _fmode. + (main) [MSDOS]: Use SET_BINARY instead of setmode. + * minibuf.c: Include binary-io.h instead of fcntl.h. + (read_minibuf_noninteractive): + Use set_binary_mode instead of handcrafted code. + Don't call emacs_set_tty if emacs_get_tty failed. + * sysdep.c, systty.h (emacs_get_tty): Return int, not void. + * sysdep.c (emacs_open, emacs_pipe): Use O_BINARY. + * w32.c (pipe2): Adjust eassert to include O_BINARY. + * macros.c (Fstart_kbd_macro): Avoid need for overflow check. This works around a GCC compiler bug when Emacs is configured with --enable-gcc-warnings. === modified file 'src/callproc.c' --- src/callproc.c 2014-06-08 00:35:27 +0000 +++ src/callproc.c 2014-07-14 19:23:18 +0000 @@ -982,7 +982,7 @@ count = SPECPDL_INDEX (); record_unwind_protect_nothing (); - fd = mkostemp (tempfile, O_CLOEXEC); + fd = mkostemp (tempfile, O_BINARY | O_CLOEXEC); if (fd < 0) report_file_error ("Failed to open temporary file using pattern", pattern); === modified file 'src/emacs.c' --- src/emacs.c 2014-06-03 20:08:08 +0000 +++ src/emacs.c 2014-07-14 19:23:18 +0000 @@ -51,6 +51,10 @@ #include "cygw32.h" #endif +#ifdef MSDOS +#include +#endif + #ifdef HAVE_WINDOW_SYSTEM #include TERM_HEADER #endif /* HAVE_WINDOW_SYSTEM */ @@ -918,20 +922,10 @@ #endif /* not SYSTEM_MALLOC */ -#if defined (MSDOS) || defined (WINDOWSNT) - /* We do all file input/output as binary files. When we need to translate - newlines, we do that manually. */ - _fmode = O_BINARY; -#endif /* MSDOS || WINDOWSNT */ - #ifdef MSDOS - if (!isatty (fileno (stdin))) - setmode (fileno (stdin), O_BINARY); - if (!isatty (fileno (stdout))) - { - fflush (stdout); - setmode (fileno (stdout), O_BINARY); - } + SET_BINARY (fileno (stdin)); + fflush (stdout); + SET_BINARY (fileno (stdout)); #endif /* MSDOS */ /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-12 07:47:40 +0000 +++ src/minibuf.c 2014-07-14 19:23:18 +0000 @@ -22,9 +22,7 @@ #include #include -#ifdef WINDOWSNT -#include /* For O_BINARY, O_TEXT. */ -#endif +#include #include "lisp.h" #include "commands.h" @@ -231,6 +229,7 @@ int c; unsigned char hide_char = 0; struct emacs_tty etty; + bool etty_valid; /* Check, whether we need to suppress echoing. */ if (CHARACTERP (Vread_hide_char)) @@ -239,11 +238,9 @@ /* Manipulate tty. */ if (hide_char) { - emacs_get_tty (fileno (stdin), &etty); -#ifdef WINDOWSNT - if (isatty (fileno (stdin))) - _setmode (fileno (stdin), O_BINARY); -#endif + etty_valid = emacs_get_tty (fileno (stdin), &etty) == 0; + if (etty_valid) + set_binary_mode (fileno (stdin), O_BINARY); suppress_echo_on_tty (fileno (stdin)); } @@ -281,11 +278,11 @@ if (hide_char) { fprintf (stdout, "\n"); - emacs_set_tty (fileno (stdin), &etty, 0); -#ifdef WINDOWSNT - if (isatty (fileno (stdin))) - _setmode (fileno (stdin), O_TEXT); -#endif + if (etty_valid) + { + emacs_set_tty (fileno (stdin), &etty, 0); + set_binary_mode (fileno (stdin), O_TEXT); + } } if (len || c == '\n' || c == '\r') === modified file 'src/sysdep.c' --- src/sysdep.c 2014-07-11 17:55:24 +0000 +++ src/sysdep.c 2014-07-14 19:23:18 +0000 @@ -775,8 +775,9 @@ /* Getting and setting emacs_tty structures. */ /* Set *TC to the parameters associated with the terminal FD, - or clear it if the parameters are not available. */ -void + or clear it if the parameters are not available. + Return 0 on success, -1 on failure. */ +int emacs_get_tty (int fd, struct emacs_tty *settings) { /* Retrieve the primary parameters - baud rate, character size, etcetera. */ @@ -786,15 +787,16 @@ HANDLE h = (HANDLE)_get_osfhandle (fd); DWORD console_mode; - if (h && h != INVALID_HANDLE_VALUE) + if (h && h != INVALID_HANDLE_VALUE && GetConsoleMode (h, &console_mode)) { - if (GetConsoleMode (h, &console_mode)) - settings->main = console_mode; + settings->main = console_mode; + return 0; } #endif /* WINDOWSNT */ + return -1; #else /* !DOS_NT */ /* We have those nifty POSIX tcmumbleattr functions. */ - tcgetattr (fd, &settings->main); + return tcgetattr (fd, &settings->main); #endif } @@ -2198,6 +2200,7 @@ #endif /* Open FILE for Emacs use, using open flags OFLAG and mode MODE. + Use binary I/O on systems that care about text vs binary I/O. Arrange for subprograms to not inherit the file descriptor. Prefer a method that is multithread-safe, if available. Do not fail merely because the open was interrupted by a signal. @@ -2207,6 +2210,8 @@ emacs_open (const char *file, int oflags, int mode) { int fd; + if (! (oflags & O_TEXT)) + oflags |= O_BINARY; oflags |= O_CLOEXEC; while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR) QUIT; @@ -2254,7 +2259,7 @@ #ifdef MSDOS return pipe (fd); #else /* !MSDOS */ - int result = pipe2 (fd, O_CLOEXEC); + int result = pipe2 (fd, O_BINARY | O_CLOEXEC); if (! O_CLOEXEC && result == 0) { fcntl (fd[0], F_SETFD, FD_CLOEXEC); === modified file 'src/systty.h' --- src/systty.h 2014-07-11 17:55:24 +0000 +++ src/systty.h 2014-07-14 19:23:18 +0000 @@ -80,7 +80,7 @@ }; /* From sysdep.c or w32.c */ -extern void emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE; +extern int emacs_get_tty (int, struct emacs_tty *) EXTERNALLY_VISIBLE; extern int emacs_set_tty (int, struct emacs_tty *, bool) EXTERNALLY_VISIBLE; extern void suppress_echo_on_tty (int); extern int serial_open (Lisp_Object); === modified file 'src/w32.c' --- src/w32.c 2014-07-10 19:09:26 +0000 +++ src/w32.c 2014-07-14 19:23:18 +0000 @@ -882,7 +882,7 @@ g_b_init_set_named_security_info_a = 1; hm_advapi32 = LoadLibrary ("Advapi32.dll"); s_pfn_Set_Named_Security_InfoA = - (SetNamedSecurityInfoA_Proc) GetProcAddress (hm_advapi32, + (SetNamedSecurityInfoA_Proc) GetProcAddress (hm_advapi32, "SetNamedSecurityInfoA"); } if (s_pfn_Set_Named_Security_InfoA == NULL) @@ -7865,7 +7865,7 @@ int rc; unsigned flags; - eassert (pipe2_flags == O_CLOEXEC); + eassert (pipe2_flags == (O_BINARY | O_CLOEXEC)); /* make pipe handles non-inheritable; when we spawn a child, we replace the relevant handle with an inheritable one. Also put ------------------------------------------------------------ revno: 117532 committer: Paul Eggert branch nick: trunk timestamp: Mon 2014-07-14 12:07:54 -0700 message: * macros.c (Fstart_kbd_macro): Avoid need for overflow check. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-14 18:56:35 +0000 +++ src/ChangeLog 2014-07-14 19:07:54 +0000 @@ -1,6 +1,6 @@ 2014-07-14 Paul Eggert - * macros.c (Fstart_kbd_macro): Simplify. + * macros.c (Fstart_kbd_macro): Avoid need for overflow check. This works around a GCC compiler bug when Emacs is configured with --enable-gcc-warnings. === modified file 'src/macros.c' --- src/macros.c 2014-07-14 18:56:35 +0000 +++ src/macros.c 2014-07-14 19:07:54 +0000 @@ -87,16 +87,13 @@ /* Check the type of last-kbd-macro in case Lisp code changed it. */ len = CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); - if (INT_ADD_OVERFLOW (len, incr)) - memory_full (SIZE_MAX); - /* Copy last-kbd-macro into the buffer, in case the Lisp code has put another macro there. */ - if (current_kboard->kbd_macro_bufsize < len + incr) + if (current_kboard->kbd_macro_bufsize - incr < len) current_kboard->kbd_macro_buffer = xpalloc (current_kboard->kbd_macro_buffer, ¤t_kboard->kbd_macro_bufsize, - len + incr - current_kboard->kbd_macro_bufsize, -1, + len - current_kboard->kbd_macro_bufsize + incr, -1, sizeof *current_kboard->kbd_macro_buffer); /* Must convert meta modifier when copying string to vector. */ ------------------------------------------------------------ revno: 117531 committer: Paul Eggert branch nick: trunk timestamp: Mon 2014-07-14 11:56:35 -0700 message: * macros.c (Fstart_kbd_macro): Simplify. This works around a GCC compiler bug when Emacs is configured with --enable-gcc-warnings. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-14 15:10:20 +0000 +++ src/ChangeLog 2014-07-14 18:56:35 +0000 @@ -1,3 +1,9 @@ +2014-07-14 Paul Eggert + + * macros.c (Fstart_kbd_macro): Simplify. + This works around a GCC compiler bug when Emacs is configured with + --enable-gcc-warnings. + 2014-07-14 Dmitry Antipov * lisp.h (CHECK_VECTOR_OR_STRING): Return number of elements === modified file 'src/macros.c' --- src/macros.c 2014-07-14 04:44:01 +0000 +++ src/macros.c 2014-07-14 18:56:35 +0000 @@ -80,7 +80,7 @@ } else { - const ptrdiff_t incr = 30; + int incr = 30; ptrdiff_t i, len; bool cvt; ------------------------------------------------------------ revno: 117530 committer: Eli Zaretskii branch nick: trunk timestamp: Mon 2014-07-14 18:10:20 +0300 message: src/ChangeLog: Fix a typo in a recently added entry. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-14 15:06:52 +0000 +++ src/ChangeLog 2014-07-14 15:10:20 +0000 @@ -9,7 +9,7 @@ * term.c (tty_menu_add_pane, tty_menu_add_selection): Use menu_item_width. - (tty_menu_show): Simplify because ty_menu_create never return NULL. + (tty_menu_show): Simplify because tty_menu_create never return NULL. 2014-07-13 Paul Eggert ------------------------------------------------------------ revno: 117529 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2014-07-14 19:06:52 +0400 message: * term.c (tty_menu_add_pane, tty_menu_add_selection): Use menu_item_width. (tty_menu_show): Simplify because ty_menu_create never return NULL. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-14 04:44:01 +0000 +++ src/ChangeLog 2014-07-14 15:06:52 +0000 @@ -7,6 +7,10 @@ * keymap.c (Fdefine_key, Flookup_key): * macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength. + * term.c (tty_menu_add_pane, tty_menu_add_selection): + Use menu_item_width. + (tty_menu_show): Simplify because ty_menu_create never return NULL. + 2014-07-13 Paul Eggert Improve behavior of 'bzr up; cd src; make -k'. === modified file 'src/term.c' --- src/term.c 2014-06-23 04:11:29 +0000 +++ src/term.c 2014-07-14 15:06:52 +0000 @@ -2942,7 +2942,6 @@ tty_menu_add_pane (tty_menu *menu, const char *txt) { int len; - const unsigned char *p; tty_menu_make_room (menu); menu->submenu[menu->count] = tty_menu_create (); @@ -2952,15 +2951,7 @@ menu->count++; /* Update the menu width, if necessary. */ - for (len = 0, p = (unsigned char *) txt; *p; ) - { - int ch_len; - int ch = STRING_CHAR_AND_LENGTH (p, ch_len); - - len += CHAR_WIDTH (ch); - p += ch_len; - } - + len = menu_item_width ((const unsigned char *) txt); if (len > menu->width) menu->width = len; @@ -2974,7 +2965,6 @@ char *txt, bool enable, char const *help_text) { int len; - unsigned char *p; if (pane) { @@ -2990,15 +2980,7 @@ menu->count++; /* Update the menu width, if necessary. */ - for (len = 0, p = (unsigned char *) txt; *p; ) - { - int ch_len; - int ch = STRING_CHAR_AND_LENGTH (p, ch_len); - - len += CHAR_WIDTH (ch); - p += ch_len; - } - + len = menu_item_width ((const unsigned char *) txt); if (len > menu->width) menu->width = len; @@ -3609,11 +3591,6 @@ /* Make the menu on that window. */ menu = tty_menu_create (); - if (menu == NULL) - { - *error_name = "Can't create menu"; - return Qnil; - } /* Don't GC while we prepare and show the menu, because we give the menu functions pointers to the contents of strings. */ ------------------------------------------------------------ revno: 117528 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2014-07-14 08:44:01 +0400 message: * lisp.h (CHECK_VECTOR_OR_STRING): Return number of elements or characters in string, respectively. Add comment. * fringe.c (Fdefine_fringe_bitmap): * fns.c (Fsubstring, substring_both): Use it. * keymap.c (Fdefine_key, Flookup_key): * macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-13 15:50:35 +0000 +++ src/ChangeLog 2014-07-14 04:44:01 +0000 @@ -1,3 +1,12 @@ +2014-07-14 Dmitry Antipov + + * lisp.h (CHECK_VECTOR_OR_STRING): Return number of elements + or characters in string, respectively. Add comment. + * fringe.c (Fdefine_fringe_bitmap): + * fns.c (Fsubstring, substring_both): Use it. + * keymap.c (Fdefine_key, Flookup_key): + * macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength. + 2014-07-13 Paul Eggert Improve behavior of 'bzr up; cd src; make -k'. === modified file 'src/fns.c' --- src/fns.c 2014-06-26 07:13:13 +0000 +++ src/fns.c 2014-07-14 04:44:01 +0000 @@ -1151,13 +1151,7 @@ Lisp_Object res; ptrdiff_t size, ifrom, ito; - if (STRINGP (string)) - size = SCHARS (string); - else if (VECTORP (string)) - size = ASIZE (string); - else - wrong_type_argument (Qarrayp, string); - + size = CHECK_VECTOR_OR_STRING (string); validate_subarray (string, from, to, size, &ifrom, &ito); if (STRINGP (string)) @@ -1212,11 +1206,7 @@ ptrdiff_t to, ptrdiff_t to_byte) { Lisp_Object res; - ptrdiff_t size; - - CHECK_VECTOR_OR_STRING (string); - - size = STRINGP (string) ? SCHARS (string) : ASIZE (string); + ptrdiff_t size = CHECK_VECTOR_OR_STRING (string); if (!(0 <= from && from <= to && to <= size)) args_out_of_range_3 (string, make_number (from), make_number (to)); === modified file 'src/fringe.c' --- src/fringe.c 2014-06-10 03:13:41 +0000 +++ src/fringe.c 2014-07-14 04:44:01 +0000 @@ -1571,13 +1571,7 @@ int fill1 = 0, fill2 = 0; CHECK_SYMBOL (bitmap); - - if (STRINGP (bits)) - h = SCHARS (bits); - else if (VECTORP (bits)) - h = ASIZE (bits); - else - wrong_type_argument (Qsequencep, bits); + h = CHECK_VECTOR_OR_STRING (bits); if (NILP (height)) fb.height = h; === modified file 'src/keymap.c' --- src/keymap.c 2014-07-02 01:49:31 +0000 +++ src/keymap.c 2014-07-14 04:44:01 +0000 @@ -1092,9 +1092,7 @@ GCPRO3 (keymap, key, def); keymap = get_keymap (keymap, 1, 1); - CHECK_VECTOR_OR_STRING (key); - - length = XFASTINT (Flength (key)); + length = CHECK_VECTOR_OR_STRING (key); if (length == 0) RETURN_UNGCPRO (Qnil); @@ -1248,9 +1246,7 @@ GCPRO2 (keymap, key); keymap = get_keymap (keymap, 1, 1); - CHECK_VECTOR_OR_STRING (key); - - length = XFASTINT (Flength (key)); + length = CHECK_VECTOR_OR_STRING (key); if (length == 0) RETURN_UNGCPRO (keymap); === modified file 'src/lisp.h' --- src/lisp.h 2014-07-08 07:17:04 +0000 +++ src/lisp.h 2014-07-14 04:44:01 +0000 @@ -2555,10 +2555,15 @@ { CHECK_TYPE (BOOL_VECTOR_P (x), Qbool_vector_p, x); } -INLINE void +/* This is a bit special because we always need size afterwards. */ +INLINE ptrdiff_t CHECK_VECTOR_OR_STRING (Lisp_Object x) { - CHECK_TYPE (VECTORP (x) || STRINGP (x), Qarrayp, x); + if (VECTORP (x)) + return ASIZE (x); + if (STRINGP (x)) + return SCHARS (x); + wrong_type_argument (Qarrayp, x); } INLINE void CHECK_ARRAY (Lisp_Object x, Lisp_Object predicate) === modified file 'src/macros.c' --- src/macros.c 2014-06-17 16:09:19 +0000 +++ src/macros.c 2014-07-14 04:44:01 +0000 @@ -80,28 +80,24 @@ } else { - ptrdiff_t i; - EMACS_INT len; + const ptrdiff_t incr = 30; + ptrdiff_t i, len; bool cvt; /* Check the type of last-kbd-macro in case Lisp code changed it. */ - CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); + len = CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); - len = XINT (Flength (KVAR (current_kboard, Vlast_kbd_macro))); + if (INT_ADD_OVERFLOW (len, incr)) + memory_full (SIZE_MAX); /* Copy last-kbd-macro into the buffer, in case the Lisp code has put another macro there. */ - if (current_kboard->kbd_macro_bufsize < len + 30) - { - if (PTRDIFF_MAX < MOST_POSITIVE_FIXNUM + 30 - && PTRDIFF_MAX < len + 30) - memory_full (SIZE_MAX); - current_kboard->kbd_macro_buffer = - xpalloc (current_kboard->kbd_macro_buffer, - ¤t_kboard->kbd_macro_bufsize, - len + 30 - current_kboard->kbd_macro_bufsize, -1, - sizeof *current_kboard->kbd_macro_buffer); - } + if (current_kboard->kbd_macro_bufsize < len + incr) + current_kboard->kbd_macro_buffer = + xpalloc (current_kboard->kbd_macro_buffer, + ¤t_kboard->kbd_macro_bufsize, + len + incr - current_kboard->kbd_macro_bufsize, -1, + sizeof *current_kboard->kbd_macro_buffer); /* Must convert meta modifier when copying string to vector. */ cvt = STRINGP (KVAR (current_kboard, Vlast_kbd_macro));