------------------------------------------------------------ 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)); ------------------------------------------------------------ revno: 117527 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-07-13 17:45:19 -0700 message: * make-docfile.c: Simplify a bit, to simplify further refactoring. (outfile): Remove static var. All uses changed to use stdout, since it's always stdout anyway. While we're at it, prefer putchar/puts/fputs to printf when there are no format strings. (main): Use freopen rather than fopen, so that stdout is reused. Move O_BINARY stuff after the freopen, so it affects the reopened file. (write_c_args): Omit first arg, since it's always stdout now. All uses changed. diff: === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2014-07-12 17:53:29 +0000 +++ lib-src/ChangeLog 2014-07-14 00:45:19 +0000 @@ -1,3 +1,15 @@ +2014-07-13 Paul Eggert + + * make-docfile.c: Simplify a bit, to simplify further refactoring. + (outfile): Remove static var. All uses changed to use stdout, + since it's always stdout anyway. While we're at it, prefer + putchar/puts/fputs to printf when there are no format strings. + (main): Use freopen rather than fopen, so that stdout is reused. + Move O_BINARY stuff after the freopen, so it affects the + reopened file. + (write_c_args): Omit first arg, since it's always stdout now. + All uses changed. + 2014-07-12 Paul Eggert * etags.c (Lisp_functions): Also record cl-defun etc. (Bug#17965) === modified file 'lib-src/make-docfile.c' --- lib-src/make-docfile.c 2014-06-17 16:09:19 +0000 +++ lib-src/make-docfile.c 2014-07-14 00:45:19 +0000 @@ -73,9 +73,6 @@ #include -/* Stdio stream for output to the DOC file. */ -FILE *outfile; - /* Name this program was invoked with. */ char *progname; @@ -135,33 +132,24 @@ progname = argv[0]; - outfile = stdout; - - /* Don't put CRs in the DOC 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 - outfile = 0; -#endif /* MSDOS */ -#ifdef WINDOWSNT - _fmode = O_BINARY; - _setmode (fileno (stdout), O_BINARY); -#endif /* WINDOWSNT */ - /* If first two args are -o FILE, output to FILE. */ i = 1; if (argc > i + 1 && !strcmp (argv[i], "-o")) { - outfile = fopen (argv[i + 1], "w"); + if (! freopen (argv[i + 1], "w", stdout)) + { + perror (argv[i + 1]); + return EXIT_FAILURE; + } i += 2; } if (argc > i + 1 && !strcmp (argv[i], "-a")) { - outfile = fopen (argv[i + 1], "a"); + if (! freopen (argv[i + 1], "a", stdout)) + { + perror (argv[i + 1]); + return EXIT_FAILURE; + } i += 2; } if (argc > i + 1 && !strcmp (argv[i], "-d")) @@ -179,8 +167,19 @@ ++i; } - if (outfile == 0) - fatal ("No output file specified", ""); + /* 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 */ if (generate_globals) start_globals (); @@ -215,13 +214,11 @@ filename = tmp + 1; } - putc (037, outfile); - putc ('S', outfile); - fprintf (outfile, "%s\n", filename); + printf ("\037S%s\n", filename); } -/* Read file FILENAME and output its doc strings to outfile. */ -/* Return 1 if file is not found, 0 if it is found. */ +/* Read file FILENAME and output its doc strings to stdout. + Return 1 if file is not found, 0 if it is found. */ static int scan_file (char *filename) @@ -242,9 +239,9 @@ static void start_globals (void) { - fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n"); - fprintf (outfile, "/* DO NOT EDIT. */\n"); - fprintf (outfile, "struct emacs_globals {\n"); + puts ("/* This file was auto-generated by make-docfile. */"); + puts ("/* DO NOT EDIT. */"); + puts ("struct emacs_globals {"); } static char input_buffer[128]; @@ -373,7 +370,7 @@ /* Skip a C string or C-style comment from INFILE, and return the character that follows. COMMENT non-zero means skip a comment. If - PRINTFLAG is positive, output string contents to outfile. If it is + PRINTFLAG is positive, output string contents to stdout. If it is negative, store contents in buf. Convert escape sequences \n and \t to newline and tab; discard \ followed by newline. If SAW_USAGE is non-zero, then any occurrences of the string `usage:' @@ -388,7 +385,7 @@ state.in_file = infile; state.buf_ptr = (printflag < 0 ? input_buffer : 0); - state.out_file = (printflag > 0 ? outfile : 0); + state.out_file = (printflag > 0 ? stdout : 0); state.pending_spaces = 0; state.pending_newlines = 0; state.keyword = (saw_usage ? "usage:" : 0); @@ -465,18 +462,18 @@ -/* Write to file OUT the argument names of function FUNC, whose text is in BUF. +/* Write to stdout the argument names of function FUNC, whose text is in BUF. MINARGS and MAXARGS are the minimum and maximum number of arguments. */ static void -write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) +write_c_args (char *func, char *buf, int minargs, int maxargs) { register char *p; int in_ident = 0; char *ident_start IF_LINT (= NULL); size_t ident_length = 0; - fprintf (out, "(fn"); + fputs ("(fn", stdout); if (*buf == '(') ++buf; @@ -517,10 +514,10 @@ if (strncmp (ident_start, "void", ident_length) == 0) continue; - putc (' ', out); + putchar (' '); if (minargs == 0 && maxargs > 0) - fprintf (out, "&optional "); + fputs ("&optional ", stdout); minargs--; maxargs--; @@ -528,7 +525,7 @@ /* In C code, `default' is a reserved word, so we spell it `defalt'; demangle that here. */ if (ident_length == 6 && memcmp (ident_start, "defalt", 6) == 0) - fprintf (out, "DEFAULT"); + fputs ("DEFAULT", stdout); else while (ident_length-- > 0) { @@ -539,12 +536,12 @@ else if (c == '_') /* Print underscore as hyphen. */ c = '-'; - putc (c, out); + putchar (c); } } } - putc (')', out); + putchar (')'); } /* The types of globals. These are sorted roughly in decreasing alignment @@ -613,8 +610,8 @@ static void close_emacs_globals (void) { - fprintf (outfile, "};\n"); - fprintf (outfile, "extern struct emacs_globals globals;\n"); + puts ("};"); + puts ("extern struct emacs_globals globals;"); } static void @@ -641,7 +638,7 @@ if (!seen_defun) { close_emacs_globals (); - fprintf (outfile, "\n"); + putchar ('\n'); seen_defun = 1; } break; @@ -651,9 +648,9 @@ if (type) { - fprintf (outfile, " %s f_%s;\n", type, globals[i].name); - fprintf (outfile, "#define %s globals.f_%s\n", - globals[i].name, globals[i].name); + printf (" %s f_%s;\n", type, globals[i].name); + printf ("#define %s globals.f_%s\n", + globals[i].name, globals[i].name); } else { @@ -664,16 +661,16 @@ || strcmp (globals[i].name, "Fkill_emacs") == 0 || strcmp (globals[i].name, "Fexit_recursive_edit") == 0 || strcmp (globals[i].name, "Fabort_recursive_edit") == 0) - fprintf (outfile, "_Noreturn "); + fputs ("_Noreturn ", stdout); - fprintf (outfile, "EXFUN (%s, ", globals[i].name); + printf ("EXFUN (%s, ", globals[i].name); if (globals[i].value == -1) - fprintf (outfile, "MANY"); + fputs ("MANY", stdout); else if (globals[i].value == -2) - fprintf (outfile, "UNEVALLED"); + fputs ("UNEVALLED", stdout); else - fprintf (outfile, "%d", globals[i].value); - fprintf (outfile, ")"); + printf ("%d", globals[i].value); + putchar (')'); /* It would be nice to have a cleaner way to deal with these special hacks, too. */ @@ -681,9 +678,9 @@ || strcmp (globals[i].name, "Ftool_bar_height") == 0 || strcmp (globals[i].name, "Fmax_char") == 0 || strcmp (globals[i].name, "Fidentity") == 0) - fprintf (outfile, " ATTRIBUTE_CONST"); + fputs (" ATTRIBUTE_CONST", stdout); - fprintf (outfile, ";\n"); + puts (";"); } while (i + 1 < num_globals @@ -952,9 +949,7 @@ int comment = c != '"'; int saw_usage; - putc (037, outfile); - putc (defvarflag ? 'V' : 'F', outfile); - fprintf (outfile, "%s\n", input_buffer); + printf ("\037%c%s\n", defvarflag ? 'V' : 'F', input_buffer); if (comment) getc (infile); /* Skip past `*'. */ @@ -996,8 +991,8 @@ while (c != ')'); *p = '\0'; /* Output them. */ - fprintf (outfile, "\n\n"); - write_c_args (outfile, input_buffer, argbuf, minargs, maxargs); + fputs ("\n\n", stdout); + write_c_args (input_buffer, argbuf, minargs, maxargs); } else if (defunflag && maxargs == -1 && !saw_usage) /* The DOC should provide the usage form. */ @@ -1433,12 +1428,10 @@ In the latter case, the opening quote (and leading backslash-newline) have already been read. */ - putc (037, outfile); - putc (type, outfile); - fprintf (outfile, "%s\n", buffer); + printf ("\037%c%s\n", type, buffer); if (saved_string) { - fputs (saved_string, outfile); + fputs (saved_string, stdout); /* Don't use one dynamic doc string twice. */ free (saved_string); saved_string = 0; ------------------------------------------------------------ revno: 117526 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-07-13 08:50:35 -0700 message: Improve behavior of 'bzr up; cd src; make -k'. * Makefile.in (ACLOCAL_INPUTS): Add all m4/*.m4 files. * src/Makefile.in (top_srcdir): New var. (ntsource, lispsource, ALL_CFLAGS, gl-stamp, emacs.res): Use '$(top_srcdir)' instead of '$(srcdir)/..'; its expansion is a bit shorter. (../config.status): Actually build config.status instead of just complaining. (ACLOCAL_INPUTS, AUTOCONF_INPUTS): New macros, copied and relocated from ../Makefile.in. ($(top_srcdir)/aclocal.m4, $(top_srcdir)/configure, config.in) (../config.status, Makefile): New dependencies and rules, copied with relocation from ../Makefile.in. This should be more likely to rebuild the build machinery properly if you do a 'make' in the src directory. diff: === modified file 'ChangeLog' --- ChangeLog 2014-07-12 20:02:44 +0000 +++ ChangeLog 2014-07-13 15:50:35 +0000 @@ -1,3 +1,8 @@ +2014-07-13 Paul Eggert + + Improve behavior of 'bzr up; cd src; make -k'. + * Makefile.in (ACLOCAL_INPUTS): Add all m4/*.m4 files. + 2014-07-12 Paul Eggert Merge from gnulib, incorporating: === modified file 'Makefile.in' --- Makefile.in 2014-07-12 17:53:29 +0000 +++ Makefile.in 2014-07-13 15:50:35 +0000 @@ -413,7 +413,7 @@ cd ${srcdir} && ${AUTOCONF} ACLOCAL_PATH = @ACLOCAL_PATH@ -ACLOCAL_INPUTS = $(srcdir)/configure.ac $(srcdir)/m4/gnulib-comp.m4 +ACLOCAL_INPUTS = $(srcdir)/configure.ac $(wildcard $(srcdir)/m4/*.m4) $(srcdir)/aclocal.m4: $(ACLOCAL_INPUTS) cd $(srcdir) && ACLOCAL_PATH='$(ACLOCAL_PATH)' $(ACLOCAL) -I m4 === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-12 17:53:29 +0000 +++ src/ChangeLog 2014-07-13 15:50:35 +0000 @@ -1,3 +1,20 @@ +2014-07-13 Paul Eggert + + Improve behavior of 'bzr up; cd src; make -k'. + * Makefile.in (top_srcdir): New var. + (ntsource, lispsource, ALL_CFLAGS, gl-stamp, emacs.res): + Use '$(top_srcdir)' instead of '$(srcdir)/..'; + its expansion is a bit shorter. + (../config.status): Actually build config.status instead of + just complaining. + (ACLOCAL_INPUTS, AUTOCONF_INPUTS): + New macros, copied and relocated from ../Makefile.in. + ($(top_srcdir)/aclocal.m4, $(top_srcdir)/configure, config.in) + (../config.status, Makefile): New dependencies and rules, + copied with relocation from ../Makefile.in. This should be more + likely to rebuild the build machinery properly if you do a 'make' + in the src directory. + 2014-07-12 Eli Zaretskii * xdisp.c (display_line): Don't call FETCH_BYTE with argument less === modified file 'src/Makefile.in' --- src/Makefile.in 2014-06-29 00:49:59 +0000 +++ src/Makefile.in 2014-07-13 15:50:35 +0000 @@ -28,9 +28,10 @@ # Here are the things that we expect ../configure to edit. # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH. srcdir = @srcdir@ +top_srcdir = @top_srcdir@ # MinGW CPPFLAGS may use this. abs_top_srcdir=@abs_top_srcdir@ -ntsource = $(srcdir)/../nt +ntsource = $(top_srcdir)/nt VPATH = $(srcdir) CC = @CC@ WINDRES = @WINDRES@ @@ -48,7 +49,7 @@ # LIBS = @LIBS@ LIBOBJS = @LIBOBJS@ -lispsource = $(srcdir)/../lisp +lispsource = $(top_srcdir)/lisp lib = ../lib libsrc = ../lib-src etc = ../etc @@ -319,7 +320,7 @@ ## ## FIXME? MYCPPFLAGS only referenced in etc/DEBUG. ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \ - -I$(lib) -I$(srcdir)/../lib \ + -I$(lib) -I$(top_srcdir)/lib \ $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ @@ -474,7 +475,7 @@ gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl.tmp - $(srcdir)/../build-aux/move-if-change gl.tmp globals.h + $(top_srcdir)/build-aux/move-if-change gl.tmp globals.h echo timestamp > $@ $(ALLOBJS): globals.h @@ -505,17 +506,23 @@ FORCE: .PHONY: FORCE -../config.status: config.in epaths.in - @echo "The file ${?:.in=.h} needs to be set up from $?." - @echo "Please run the 'configure' script again." - exit 1 +ACLOCAL_INPUTS = $(top_srcdir)/configure.ac $(wildcard $(top_srcdir)/m4/*.m4) +AUTOCONF_INPUTS = $(top_srcdir)/configure.ac $(top_srcdir)/aclocal.m4 +$(top_srcdir)/aclocal.m4: $(ACLOCAL_INPUTS) +$(top_srcdir)/configure config.in: $(AUTOCONF_INPUTS) +.PRECIOUS: ../config.status Makefile +../config.status: $(top_srcdir)/configure $(top_srcdir)/lisp/version.el +Makefile: ../config.status $(srcdir)/Makefile.in +$(top_srcdir)/aclocal.m4 $(top_srcdir)/configure config.in ../config.status \ + Makefile: + $(MAKE) -C .. am--refresh doc.o: buildobj.h emacs.res: $(ntsource)/emacs.rc \ $(ntsource)/icons/emacs.ico \ $(ntsource)/$(EMACS_MANIFEST) - $(WINDRES) -O COFF --include-dir=$(srcdir)/../nt \ + $(WINDRES) -O COFF --include-dir=$(top_srcdir)/nt \ -o $@ $(ntsource)/emacs.rc .PHONY: ns-app ------------------------------------------------------------ revno: 117525 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Sat 2014-07-12 13:02:44 -0700 message: Merge from gnulib, incorporating: 2014-06-27 mktime: merge #if/#ifdef usage from glibc * lib/mktime.c: Update from gnulib. diff: === modified file 'ChangeLog' --- ChangeLog 2014-07-12 17:53:29 +0000 +++ ChangeLog 2014-07-12 20:02:44 +0000 @@ -1,5 +1,9 @@ 2014-07-12 Paul Eggert + Merge from gnulib, incorporating: + 2014-06-27 mktime: merge #if/#ifdef usage from glibc + * lib/mktime.c: Update from gnulib. + * Makefile.in (install-arch-indep): Avoid readdir race (Bug#17971). 2014-07-10 Dmitry Antipov === modified file 'lib/mktime.c' --- lib/mktime.c 2014-01-01 07:43:34 +0000 +++ lib/mktime.c 2014-07-12 20:02:44 +0000 @@ -38,7 +38,7 @@ #include /* For the real memcpy prototype. */ -#if DEBUG +#if defined DEBUG && DEBUG # include # include /* Make it work even if the system's libc has its own mktime routine. */ @@ -600,7 +600,7 @@ libc_hidden_weak (timelocal) #endif -#if DEBUG +#if defined DEBUG && DEBUG static int not_equal_tm (const struct tm *a, const struct tm *b) ------------------------------------------------------------ revno: 117524 [merge] committer: Glenn Morris branch nick: trunk timestamp: Sat 2014-07-12 10:53:29 -0700 message: Merge from emacs-24; up to r117375 diff: === modified file 'ChangeLog' --- ChangeLog 2014-07-10 12:33:35 +0000 +++ ChangeLog 2014-07-12 17:53:29 +0000 @@ -1,3 +1,7 @@ +2014-07-12 Paul Eggert + + * Makefile.in (install-arch-indep): Avoid readdir race (Bug#17971). + 2014-07-10 Dmitry Antipov * configure.ac: Check whether sys/sysinfo.h provides === modified file 'Makefile.in' --- Makefile.in 2014-06-27 00:41:23 +0000 +++ Makefile.in 2014-07-12 17:53:29 +0000 @@ -594,8 +594,9 @@ [ -z "${GZIP_PROG}" ] || { \ echo "Compressing *.el ..." && \ cd "$(DESTDIR)${lispdir}" && \ - find . -name '*.elc' -exec $(SHELL) -c \ - '${GZIP_PROG} -9n `expr "$$1" : "\\(.*\\)c"`' dummy '{}' ';'; \ + for f in `find . -name "*.elc" -print | sed 's/.elc$$/.el/'`; do \ + ${GZIP_PROG} -9n "$$f"; \ + done; \ } -chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS} === modified file 'etc/PROBLEMS' --- etc/PROBLEMS 2014-06-15 00:06:30 +0000 +++ etc/PROBLEMS 2014-07-12 17:53:29 +0000 @@ -1931,6 +1931,16 @@ includes a short description of MSLU and a link where it can be downloaded. +** Emacs refuses to start on Windows 9X because ctime64 function is missing + +This is a sign that Emacs was compiled with MinGW runtime version +4.0.x or later. These versions of runtime call in their startup code +the ctime64 function, which does not exist in MSVCRT.DLL, the C +runtime shared library, distributed with Windows 9X. + +A workaround is to build Emacs with MinGW runtime 3.x (the latest +version is 3.20). + ** A few seconds delay is seen at startup and for many file operations This happens when the Net Logon service is enabled. During Emacs @@ -1965,6 +1975,26 @@ switch, which will force Emacs to load libgcc_s_dw2-1.dll on startup, ahead of any optional DLLs loaded on-demand later in the session. +** File selection dialog opens in incorrect directories + +Invoking the file selection dialog on Windows 7 or later shows a +directory that is different from what was passed to `read-file-name' +or `x-file-dialog' via their arguments. + +This is due to a deliberate change in behavior of the file selection +dialogs introduced in Windows 7. It is explicitly described in the +MSDN documentation of the GetOpenFileName API used by Emacs to pop up +the file selection dialog. For the details, see + + http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx + +The dialog shows the last directory in which the user selected a file +in a previous invocation of the dialog with the same initial +directory. + +You can reset this "memory" of that directory by invoking the file +selection dialog with a different initial directory. + ** PATH can contain unexpanded environment variables Old releases of TCC (version 9) and 4NT (up to version 8) do not correctly @@ -2098,7 +2128,7 @@ non-US timezones. This is due to over-simplistic handling of daylight savings switchovers by the Windows libraries. -** Files larger than 4GB report wrong size +** Files larger than 4GB report wrong size in a 32-bit Windows build Files larger than 4GB cause overflow in the size (represented as a 32-bit integer) reported by `file-attributes'. This affects Dired as === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2014-06-26 06:18:53 +0000 +++ lib-src/ChangeLog 2014-07-12 17:53:29 +0000 @@ -1,3 +1,7 @@ +2014-07-12 Paul Eggert + + * etags.c (Lisp_functions): Also record cl-defun etc. (Bug#17965) + 2014-06-26 Glenn Morris * Makefile.in (blessmail): Depend on lisp/mail/blessmail.el. === modified file 'lib-src/etags.c' --- lib-src/etags.c 2014-01-01 07:43:34 +0000 +++ lib-src/etags.c 2014-07-12 16:26:54 +0000 @@ -4747,6 +4747,9 @@ } } + if (strneq (dbp + 1, "cl-", 3) || strneq (dbp + 1, "CL-", 3)) + dbp += 3; + if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3)) { dbp = skip_non_spaces (dbp); === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-07-11 12:19:58 +0000 +++ lisp/ChangeLog 2014-07-12 17:53:29 +0000 @@ -1,3 +1,41 @@ +2014-07-12 Paul Eggert + + Fix bug: C-x v v discarded existing log message (Bug#17884). + * vc/vc-dispatcher.el (vc-log-edit): + Don't clobber an already-existing log message. + +2014-07-12 Glenn Morris + + * vc/log-edit.el (log-edit-changelog-entries): + Check for a visited-but-never-saved ChangeLog. + +2014-07-12 Stefan Monnier + + * vc/log-edit.el (log-edit-changelog-entries): Don't both visiting + a non-existing file (bug#17970). + + * faces.el (face-name): Undo last change. + (x-resolve-font-name): Don't call face-name (bug#17956). + +2014-07-12 Fabián Ezequiel Gallina + + Fix dedenters and electric colon handling. (Bug#15163) + * progmodes/python.el + (python-rx-constituents): Add dedenter and block-ender. + (python-indent-dedenters, python-indent-block-enders): Delete. + (python-indent-context): Return new case for dedenter-statement. + (python-indent-calculate-indentation): Handle new case. + (python-indent-calculate-levels): Fix levels calculation for + dedenter statements. + (python-indent-post-self-insert-function): Fix colon handling. + (python-info-dedenter-opening-block-message): New function. + (python-indent-line): Use it. + (python-info-closing-block) + (python-info-closing-block-message): Remove. + (python-info-dedenter-opening-block-position) + (python-info-dedenter-opening-block-positions) + (python-info-dedenter-statement-p): New functions. + 2014-07-11 Dmitry Antipov * files.el (out-of-memory-warning-percentage): New defcustom. === modified file 'lisp/faces.el' --- lisp/faces.el 2014-07-09 02:04:12 +0000 +++ lisp/faces.el 2014-07-12 17:53:29 +0000 @@ -370,10 +370,7 @@ (defun face-name (face) "Return the name of face FACE." - (check-face face) - (if (symbolp face) - (symbol-name face) - face)) + (symbol-name (check-face face))) (defun face-all-attributes (face &optional frame) @@ -2749,8 +2746,6 @@ contains wildcards. Given optional arguments FACE and FRAME, return a font which is also the same size as FACE on FRAME, or fail." - (when face - (setq face (face-name face))) (and (eq frame t) (setq frame nil)) (if pattern === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2014-07-03 06:00:53 +0000 +++ lisp/progmodes/python.el 2014-07-12 17:53:29 +0000 @@ -321,6 +321,13 @@ (or "def" "class" "if" "elif" "else" "try" "except" "finally" "for" "while" "with") symbol-end)) + (dedenter . ,(rx symbol-start + (or "elif" "else" "except" "finally") + symbol-end)) + (block-ender . ,(rx symbol-start + (or + "break" "continue" "pass" "raise" "return") + symbol-end)) (decorator . ,(rx line-start (* space) ?@ (any letter ?_) (* (any word ?_)))) (defun . ,(rx symbol-start (or "def" "class") symbol-end)) @@ -630,18 +637,6 @@ (defvar python-indent-levels '(0) "Levels of indentation available for `python-indent-line-function'.") -(defvar python-indent-dedenters '("else" "elif" "except" "finally") - "List of words that should be dedented. -These make `python-indent-calculate-indentation' subtract the value of -`python-indent-offset'.") - -(defvar python-indent-block-enders - '("break" "continue" "pass" "raise" "return") - "List of words that mark the end of a block. -These make `python-indent-calculate-indentation' subtract the -value of `python-indent-offset' when `python-indent-context' is -AFTER-LINE.") - (defun python-indent-guess-indent-offset () "Guess and set `python-indent-offset' for the current buffer." (interactive) @@ -692,6 +687,7 @@ * after-backslash: Previous line ends in a backslash * after-beginning-of-block: Point is after beginning of block * after-line: Point is after normal line + * dedenter-statement: Point is on a dedenter statement. * no-indent: Point is at beginning of buffer or other special case START is the buffer position where the sexp starts." (save-restriction @@ -746,6 +742,8 @@ (when (looking-at (python-rx block-start)) (point-marker))))) 'after-beginning-of-block) + ((when (setq start (python-info-dedenter-statement-p)) + 'dedenter-statement)) ;; After normal line ((setq start (save-excursion (back-to-indentation) @@ -776,8 +774,7 @@ (goto-char context-start) (+ (current-indentation) python-indent-offset)) ;; When after a simple line just use previous line - ;; indentation, in the case current line starts with a - ;; `python-indent-dedenters' de-indent one level. + ;; indentation. (`after-line (let* ((pair (save-excursion (goto-char context-start) @@ -785,25 +782,27 @@ (current-indentation) (python-info-beginning-of-block-p)))) (context-indentation (car pair)) - (after-block-start-p (cdr pair)) + ;; TODO: Separate block enders into its own case. (adjustment - (if (or (save-excursion - (back-to-indentation) - (and - ;; De-indent only when dedenters are not - ;; next to a block start. This allows - ;; one-liner constructs such as: - ;; if condition: print "yay" - ;; else: print "wry" - (not after-block-start-p) - (looking-at (regexp-opt python-indent-dedenters)))) - (save-excursion - (python-util-forward-comment -1) - (python-nav-beginning-of-statement) - (looking-at (regexp-opt python-indent-block-enders)))) + (if (save-excursion + (python-util-forward-comment -1) + (python-nav-beginning-of-statement) + (looking-at (python-rx block-ender))) python-indent-offset 0))) (- context-indentation adjustment))) + ;; When point is on a dedenter statement, search for the + ;; opening block that corresponds to it and use its + ;; indentation. If no opening block is found just remove + ;; indentation as this is an invalid python file. + (`dedenter-statement + (let ((block-start-point + (python-info-dedenter-opening-block-position))) + (save-excursion + (if (not block-start-point) + 0 + (goto-char block-start-point) + (current-indentation))))) ;; When inside of a string, do nothing. just use the current ;; indentation. XXX: perhaps it would be a good idea to ;; invoke standard text indentation here @@ -930,16 +929,25 @@ (defun python-indent-calculate-levels () "Calculate `python-indent-levels' and reset `python-indent-current-level'." - (let* ((indentation (python-indent-calculate-indentation)) - (remainder (% indentation python-indent-offset)) - (steps (/ (- indentation remainder) python-indent-offset))) - (setq python-indent-levels (list 0)) - (dotimes (step steps) - (push (* python-indent-offset (1+ step)) python-indent-levels)) - (when (not (eq 0 remainder)) - (push (+ (* python-indent-offset steps) remainder) python-indent-levels)) - (setq python-indent-levels (nreverse python-indent-levels)) - (setq python-indent-current-level (1- (length python-indent-levels))))) + (if (not (python-info-dedenter-statement-p)) + (let* ((indentation (python-indent-calculate-indentation)) + (remainder (% indentation python-indent-offset)) + (steps (/ (- indentation remainder) python-indent-offset))) + (setq python-indent-levels (list 0)) + (dotimes (step steps) + (push (* python-indent-offset (1+ step)) python-indent-levels)) + (when (not (eq 0 remainder)) + (push (+ (* python-indent-offset steps) remainder) python-indent-levels))) + (setq python-indent-levels + (or + (mapcar (lambda (pos) + (save-excursion + (goto-char pos) + (current-indentation))) + (python-info-dedenter-opening-block-positions)) + (list 0)))) + (setq python-indent-current-level (1- (length python-indent-levels)) + python-indent-levels (nreverse python-indent-levels))) (defun python-indent-toggle-levels () "Toggle `python-indent-current-level' over `python-indent-levels'." @@ -988,7 +996,7 @@ (indent-to next-indent) (goto-char starting-pos)) (and follow-indentation-p (back-to-indentation))) - (python-info-closing-block-message)) + (python-info-dedenter-opening-block-message)) (defun python-indent-line-function () "`indent-line-function' for Python mode. @@ -1124,14 +1132,7 @@ (eolp) (not (equal ?: (char-before (1- (point))))) (not (python-syntax-comment-or-string-p))) - (let ((indentation (current-indentation)) - (calculated-indentation (python-indent-calculate-indentation))) - (python-info-closing-block-message) - (when (> indentation calculated-indentation) - (save-excursion - (indent-line-to calculated-indentation) - (when (not (python-info-closing-block-message)) - (indent-line-to indentation))))))))) + (python-indent-line))))) ;;; Navigation @@ -3454,49 +3455,88 @@ (and (python-info-end-of-statement-p) (python-info-statement-ends-block-p))) -(defun python-info-closing-block () - "Return the point of the block the current line closes." - (let ((closing-word (save-excursion - (back-to-indentation) - (current-word))) - (indentation (current-indentation))) - (when (member closing-word python-indent-dedenters) +(define-obsolete-function-alias + 'python-info-closing-block + 'python-info-dedenter-opening-block-position "24.4") + +(defun python-info-dedenter-opening-block-position () + "Return the point of the closest block the current line closes. +Returns nil if point is not on a dedenter statement or no opening +block can be detected. The latter case meaning current file is +likely an invalid python file." + (let ((positions (python-info-dedenter-opening-block-positions)) + (indentation (current-indentation)) + (position)) + (while (and (not position) + positions) (save-excursion - (forward-line -1) - (while (and (> (current-indentation) indentation) - (not (bobp)) - (not (back-to-indentation)) - (forward-line -1))) - (back-to-indentation) - (cond - ((not (equal indentation (current-indentation))) nil) - ((string= closing-word "elif") - (when (member (current-word) '("if" "elif")) - (point-marker))) - ((string= closing-word "else") - (when (member (current-word) '("if" "elif" "except" "for" "while")) - (point-marker))) - ((string= closing-word "except") - (when (member (current-word) '("try")) - (point-marker))) - ((string= closing-word "finally") - (when (member (current-word) '("except" "else")) - (point-marker)))))))) - -(defun python-info-closing-block-message (&optional closing-block-point) - "Message the contents of the block the current line closes. -With optional argument CLOSING-BLOCK-POINT use that instead of -recalculating it calling `python-info-closing-block'." - (let ((point (or closing-block-point (python-info-closing-block)))) + (goto-char (car positions)) + (if (<= (current-indentation) indentation) + (setq position (car positions)) + (setq positions (cdr positions))))) + position)) + +(defun python-info-dedenter-opening-block-positions () + "Return points of blocks the current line may close sorted by closer. +Returns nil if point is not on a dedenter statement or no opening +block can be detected. The latter case meaning current file is +likely an invalid python file." + (save-excursion + (let ((dedenter-pos (python-info-dedenter-statement-p))) + (when dedenter-pos + (goto-char dedenter-pos) + (let* ((pairs '(("elif" "elif" "if") + ("else" "if" "elif" "except" "for" "while") + ("except" "except" "try") + ("finally" "else" "except" "try"))) + (dedenter (match-string-no-properties 0)) + (possible-opening-blocks (cdr (assoc-string dedenter pairs))) + (collected-indentations) + (opening-blocks)) + (catch 'exit + (while (python-nav--syntactically + (lambda () + (re-search-backward (python-rx block-start) nil t)) + #'<) + (let ((indentation (current-indentation))) + (when (and (not (memq indentation collected-indentations)) + (or (not collected-indentations) + (< indentation (apply #'min collected-indentations)))) + (setq collected-indentations + (cons indentation collected-indentations)) + (when (member (match-string-no-properties 0) + possible-opening-blocks) + (setq opening-blocks (cons (point) opening-blocks)))) + (when (zerop indentation) + (throw 'exit nil))))) + ;; sort by closer + (nreverse opening-blocks)))))) + +(define-obsolete-function-alias + 'python-info-closing-block-message + 'python-info-dedenter-opening-block-message "24.4") + +(defun python-info-dedenter-opening-block-message () + "Message the first line of the block the current statement closes." + (let ((point (python-info-dedenter-opening-block-position))) (when point (save-restriction (widen) (message "Closes %s" (save-excursion (goto-char point) - (back-to-indentation) (buffer-substring (point) (line-end-position)))))))) +(defun python-info-dedenter-statement-p () + "Return point if current statement is a dedenter. +Sets `match-data' to the keyword that starts the dedenter +statement." + (save-excursion + (python-nav-beginning-of-statement) + (when (and (not (python-syntax-context-type)) + (looking-at (python-rx dedenter))) + (point)))) + (defun python-info-line-ends-backslash-p (&optional line-number) "Return non-nil if current line ends with backslash. With optional argument LINE-NUMBER, check that line instead." === modified file 'lisp/vc/log-edit.el' --- lisp/vc/log-edit.el 2014-07-01 15:15:03 +0000 +++ lisp/vc/log-edit.el 2014-07-10 18:09:04 +0000 @@ -905,44 +905,46 @@ ;; that memoizing which is undesired here. (setq change-log-default-name nil) (find-change-log))))) - (with-current-buffer (find-file-noselect changelog-file-name) - (unless (eq major-mode 'change-log-mode) (change-log-mode)) - (goto-char (point-min)) - (if (looking-at "\\s-*\n") (goto-char (match-end 0))) - (if (not (log-edit-changelog-ours-p)) - (list (current-buffer)) - (save-restriction - (log-edit-narrow-changelog) - (goto-char (point-min)) - - ;; Search for the name of FILE relative to the ChangeLog. If that - ;; doesn't occur anywhere, they're not using full relative - ;; filenames in the ChangeLog, so just look for FILE; we'll accept - ;; some false positives. - (let ((pattern (file-relative-name - file (file-name-directory changelog-file-name)))) - (if (or (string= pattern "") - (not (save-excursion - (search-forward pattern nil t)))) - (setq pattern (file-name-nondirectory file))) - - (setq pattern (concat "\\(^\\|[^[:alnum:]]\\)" - (regexp-quote pattern) - "\\($\\|[^[:alnum:]]\\)")) - - (let (texts - (pos (point))) - (while (and (not (eobp)) (re-search-forward pattern nil t)) - (let ((entry (log-edit-changelog-entry))) - (if (< (elt entry 1) (max (1+ pos) (point))) - ;; This is not relevant, actually. - nil - (push entry texts)) - ;; Make sure we make progress. - (setq pos (max (1+ pos) (elt entry 1))) - (goto-char pos))) - - (cons (current-buffer) texts)))))))) + (when (or (find-buffer-visiting changelog-file-name) + (file-exists-p changelog-file-name)) + (with-current-buffer (find-file-noselect changelog-file-name) + (unless (eq major-mode 'change-log-mode) (change-log-mode)) + (goto-char (point-min)) + (if (looking-at "\\s-*\n") (goto-char (match-end 0))) + (if (not (log-edit-changelog-ours-p)) + (list (current-buffer)) + (save-restriction + (log-edit-narrow-changelog) + (goto-char (point-min)) + + ;; Search for the name of FILE relative to the ChangeLog. If that + ;; doesn't occur anywhere, they're not using full relative + ;; filenames in the ChangeLog, so just look for FILE; we'll accept + ;; some false positives. + (let ((pattern (file-relative-name + file (file-name-directory changelog-file-name)))) + (if (or (string= pattern "") + (not (save-excursion + (search-forward pattern nil t)))) + (setq pattern (file-name-nondirectory file))) + + (setq pattern (concat "\\(^\\|[^[:alnum:]]\\)" + (regexp-quote pattern) + "\\($\\|[^[:alnum:]]\\)")) + + (let (texts + (pos (point))) + (while (and (not (eobp)) (re-search-forward pattern nil t)) + (let ((entry (log-edit-changelog-entry))) + (if (< (elt entry 1) (max (1+ pos) (point))) + ;; This is not relevant, actually. + nil + (push entry texts)) + ;; Make sure we make progress. + (setq pos (max (1+ pos) (elt entry 1))) + (goto-char pos))) + + (cons (current-buffer) texts))))))))) (defun log-edit-changelog-insert-entries (buffer beg end &rest files) "Insert the text from BUFFER between BEG and END. === modified file 'lisp/vc/vc-dispatcher.el' --- lisp/vc/vc-dispatcher.el 2014-01-01 07:43:34 +0000 +++ lisp/vc/vc-dispatcher.el 2014-07-12 02:24:02 +0000 @@ -596,7 +596,7 @@ (setq default-directory (buffer-local-value 'default-directory vc-parent-buffer)) (log-edit 'vc-finish-logentry - t + (= (point-min) (point-max)) `((log-edit-listfun . (lambda () ;; FIXME: Should expand the list ;; for directories. === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-12 07:47:40 +0000 +++ src/ChangeLog 2014-07-12 17:53:29 +0000 @@ -1,5 +1,15 @@ 2014-07-12 Eli Zaretskii + * xdisp.c (display_line): Don't call FETCH_BYTE with argument less + than 1. (Bug#17962) + + * w32fns.c (Fx_file_dialog): Mention in the doc string the + behavior on Windows 7 and later when the function is repeatedly + invoked with the same value of DIR. (Bug#17950) + + * xfns.c (Fx_file_dialog) [USE_MOTIF, USE_GTK]: Update the doc + string to match the one in w32fns.c. + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode only if it is connected to a terminal. === modified file 'src/w32fns.c' --- src/w32fns.c 2014-07-03 18:12:41 +0000 +++ src/w32fns.c 2014-07-12 17:53:29 +0000 @@ -6394,7 +6394,11 @@ This function is only defined on NS, MS Windows, and X Windows with the Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. -Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) +Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. +On Windows 7 and later, the file selection dialog "remembers" the last +directory where the user selected a file, and will open that directory +instead of DIR on subsequent invocations of this function with the same +value of DIR as in previous invocations; this is standard Windows behavior. */) (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { /* Filter index: 1: All Files, 2: Directories only */ === modified file 'src/xdisp.c' --- src/xdisp.c 2014-07-09 02:04:12 +0000 +++ src/xdisp.c 2014-07-12 17:53:29 +0000 @@ -20494,7 +20494,10 @@ row->truncated_on_right_p = 1; it->continuation_lines_width = 0; reseat_at_next_visible_line_start (it, 0); - row->ends_at_zv_p = FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n'; + if (IT_BYTEPOS (*it) <= BEG_BYTE) + row->ends_at_zv_p = true; + else + row->ends_at_zv_p = FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n'; break; } } === modified file 'src/xfns.c' --- src/xfns.c 2014-07-09 02:04:12 +0000 +++ src/xfns.c 2014-07-12 17:53:29 +0000 @@ -5705,7 +5705,11 @@ This function is only defined on NS, MS Windows, and X Windows with the Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. -Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) +Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. +On Windows 7 and later, the file selection dialog "remembers" the last +directory where the user selected a file, and will open that directory +instead of DIR on subsequent invocations of this function with the same +value of DIR as in previous invocations; this is standard Windows behavior. */) (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { @@ -5877,7 +5881,11 @@ This function is only defined on NS, MS Windows, and X Windows with the Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. -Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) +Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. +On Windows 7 and later, the file selection dialog "remembers" the last +directory where the user selected a file, and will open that directory +instead of DIR on subsequent invocations of this function with the same +value of DIR as in previous invocations; this is standard Windows behavior. */) (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { struct frame *f = SELECTED_FRAME (); === modified file 'test/ChangeLog' --- test/ChangeLog 2014-07-08 16:51:35 +0000 +++ test/ChangeLog 2014-07-12 17:53:29 +0000 @@ -1,3 +1,33 @@ +2014-07-12 Fabián Ezequiel Gallina + + * automated/python-tests.el (python-indent-block-enders-1) + (python-indent-block-enders-2): Fix tests. + (python-indent-block-enders-3, python-indent-block-enders-4) + (python-indent-block-enders-5, python-indent-dedenters-1) + (python-indent-dedenters-2): Remove tests. + (python-indent-dedenters-1, python-indent-dedenters-2) + (python-indent-dedenters-3, python-indent-dedenters-4) + (python-indent-dedenters-5, python-indent-dedenters-6) + (python-indent-dedenters-7) + (python-info-dedenter-opening-block-position-1) + (python-info-dedenter-opening-block-position-2) + (python-info-dedenter-opening-block-position-3) + (python-info-dedenter-opening-block-positions-1) + (python-info-dedenter-opening-block-positions-2) + (python-info-dedenter-opening-block-positions-3) + (python-info-dedenter-opening-block-positions-4) + (python-info-dedenter-opening-block-positions-5) + (python-info-dedenter-opening-block-message-1) + (python-info-dedenter-opening-block-message-2) + (python-info-dedenter-opening-block-message-3) + (python-info-dedenter-opening-block-message-4) + (python-info-dedenter-opening-block-message-5) + (python-info-dedenter-statement-p-1) + (python-info-dedenter-statement-p-2) + (python-info-dedenter-statement-p-3) + (python-info-dedenter-statement-p-4) + (python-info-dedenter-statement-p-5): New tests. + 2014-07-08 Stefan Monnier * indent/perl.perl: Add indentation pattern for hash-table entries. === modified file 'test/automated/python-tests.el' --- test/automated/python-tests.el 2014-07-01 03:54:11 +0000 +++ test/automated/python-tests.el 2014-07-09 03:55:53 +0000 @@ -435,79 +435,6 @@ (should (eq (car (python-indent-context)) 'after-beginning-of-block)) (should (= (python-indent-calculate-indentation) 4)))) -(ert-deftest python-indent-dedenters-1 () - "Check all dedenters." - (python-tests-with-temp-buffer - " -def foo(a, b, c): - if a: - print (a) - elif b: - print (b) - else: - try: - print (c.pop()) - except (IndexError, AttributeError): - print (c) - finally: - print ('nor a, nor b are true') -" - (python-tests-look-at "if a:") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 4)) - (python-tests-look-at "print (a)") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "elif b:") - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 4)) - (python-tests-look-at "print (b)") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "else:") - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 4)) - (python-tests-look-at "try:") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "print (c.pop())") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 12)) - (python-tests-look-at "except (IndexError, AttributeError):") - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "print (c)") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 12)) - (python-tests-look-at "finally:") - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "print ('nor a, nor b are true')") - (should (eq (car (python-indent-context)) 'after-beginning-of-block)) - (should (= (python-indent-calculate-indentation) 12)))) - -(ert-deftest python-indent-dedenters-2 () - "Check one-liner block special case.." - (python-tests-with-temp-buffer - " -cond = True -if cond: - - if cond: print 'True' -else: print 'False' - -else: - return -" - (python-tests-look-at "else: print 'False'") - ;; When a block has code after ":" it's just considered a simple - ;; line as that's a common thing to happen in one-liners. - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 4)) - (python-tests-look-at "else:") - (should (eq (car (python-indent-context)) 'after-line)) - (should (= (python-indent-calculate-indentation) 0)))) - (ert-deftest python-indent-after-backslash-1 () "The most common case." (python-tests-with-temp-buffer @@ -575,9 +502,9 @@ (should (= (python-indent-calculate-indentation) 0)))) (ert-deftest python-indent-block-enders-1 () - "Test `python-indent-block-enders' value honoring." + "Test de-indentation for pass keyword." (python-tests-with-temp-buffer - " + " Class foo(object): def bar(self): @@ -589,17 +516,17 @@ else: pass " - (python-tests-look-at "3)") - (forward-line 1) - (should (= (python-indent-calculate-indentation) 8)) - (python-tests-look-at "pass") - (forward-line 1) - (should (= (python-indent-calculate-indentation) 8)))) + (python-tests-look-at "3)") + (forward-line 1) + (should (= (python-indent-calculate-indentation) 8)) + (python-tests-look-at "pass") + (forward-line 1) + (should (= (python-indent-calculate-indentation) 8)))) (ert-deftest python-indent-block-enders-2 () - "Test `python-indent-block-enders' value honoring." + "Test de-indentation for return keyword." (python-tests-with-temp-buffer - " + " Class foo(object): '''raise lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do @@ -612,10 +539,177 @@ 2, 3) " - (python-tests-look-at "def") - (should (= (python-indent-calculate-indentation) 4)) - (python-tests-look-at "if") - (should (= (python-indent-calculate-indentation) 8)))) + (python-tests-look-at "def") + (should (= (python-indent-calculate-indentation) 4)) + (python-tests-look-at "if") + (should (= (python-indent-calculate-indentation) 8)) + (python-tests-look-at "return") + (should (= (python-indent-calculate-indentation) 12)) + (goto-char (point-max)) + (should (= (python-indent-calculate-indentation) 8)))) + +(ert-deftest python-indent-block-enders-3 () + "Test de-indentation for continue keyword." + (python-tests-with-temp-buffer + " +for element in lst: + if element is None: + continue +" + (python-tests-look-at "if") + (should (= (python-indent-calculate-indentation) 4)) + (python-tests-look-at "continue") + (should (= (python-indent-calculate-indentation) 8)) + (forward-line 1) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-block-enders-4 () + "Test de-indentation for break keyword." + (python-tests-with-temp-buffer + " +for element in lst: + if element is None: + break +" + (python-tests-look-at "if") + (should (= (python-indent-calculate-indentation) 4)) + (python-tests-look-at "break") + (should (= (python-indent-calculate-indentation) 8)) + (forward-line 1) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-block-enders-5 () + "Test de-indentation for raise keyword." + (python-tests-with-temp-buffer + " +for element in lst: + if element is None: + raise ValueError('Element cannot be None') +" + (python-tests-look-at "if") + (should (= (python-indent-calculate-indentation) 4)) + (python-tests-look-at "raise") + (should (= (python-indent-calculate-indentation) 8)) + (forward-line 1) + (should (= (python-indent-calculate-indentation) 4)))) + +(ert-deftest python-indent-dedenters-1 () + "Test de-indentation for the elif keyword." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + finally: + cleanup() + elif +" + (python-tests-look-at "elif\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 0)) + (should (equal (python-indent-calculate-levels) '(0))))) + +(ert-deftest python-indent-dedenters-2 () + "Test de-indentation for the else keyword." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except IOError: + msg = 'Error saving to disk' + message(msg) + logger.exception(msg) + except Exception: + if hide_details: + logger.exception('Unhandled exception') + else + finally: + data.free() +" + (python-tests-look-at "else\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 8)) + (should (equal (python-indent-calculate-levels) '(0 4 8))))) + +(ert-deftest python-indent-dedenters-3 () + "Test de-indentation for the except keyword." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except +" + (python-tests-look-at "except\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 4)) + (should (equal (python-indent-calculate-levels) '(4))))) + +(ert-deftest python-indent-dedenters-4 () + "Test de-indentation for the finally keyword." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + finally +" + (python-tests-look-at "finally\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 4)) + (should (equal (python-indent-calculate-levels) '(4))))) + +(ert-deftest python-indent-dedenters-5 () + "Test invalid levels are skipped in a complex example." + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except IOError: + msg = 'Error saving to disk' + message(msg) + logger.exception(msg) + finally: + if cleanup: + do_cleanup() + else +" + (python-tests-look-at "else\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 8)) + (should (equal (python-indent-calculate-levels) '(0 8))))) + +(ert-deftest python-indent-dedenters-6 () + "Test indentation is zero when no opening block for dedenter." + (python-tests-with-temp-buffer + " +try: + # if save: + write_to_disk(data) + else +" + (python-tests-look-at "else\n") + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 0)) + (should (equal (python-indent-calculate-levels) '(0))))) + +(ert-deftest python-indent-dedenters-7 () + "Test indentation case from Bug#15163." + (python-tests-with-temp-buffer + " +if a: + if b: + pass + else: + pass + else: +" + (python-tests-look-at "else:" 2) + (should (eq (car (python-indent-context)) 'dedenter-statement)) + (should (= (python-indent-calculate-indentation) 0)) + (should (equal (python-indent-calculate-levels) '(0))))) ;;; Navigation @@ -2428,9 +2522,9 @@ (python-util-forward-comment -1) (should (python-info-end-of-block-p)))) -(ert-deftest python-info-closing-block-1 () +(ert-deftest python-info-dedenter-opening-block-position-1 () (python-tests-with-temp-buffer - " + " if request.user.is_authenticated(): try: profile = request.user.get_profile() @@ -2445,26 +2539,26 @@ profile.views += 1 profile.save() " - (python-tests-look-at "try:") - (should (not (python-info-closing-block))) - (python-tests-look-at "except Profile.DoesNotExist:") - (should (= (python-tests-look-at "try:" -1 t) - (python-info-closing-block))) - (python-tests-look-at "else:") - (should (= (python-tests-look-at "except Profile.DoesNotExist:" -1 t) - (python-info-closing-block))) - (python-tests-look-at "if profile.stats:") - (should (not (python-info-closing-block))) - (python-tests-look-at "else:") - (should (= (python-tests-look-at "if profile.stats:" -1 t) - (python-info-closing-block))) - (python-tests-look-at "finally:") - (should (= (python-tests-look-at "else:" -2 t) - (python-info-closing-block))))) + (python-tests-look-at "try:") + (should (not (python-info-dedenter-opening-block-position))) + (python-tests-look-at "except Profile.DoesNotExist:") + (should (= (python-tests-look-at "try:" -1 t) + (python-info-dedenter-opening-block-position))) + (python-tests-look-at "else:") + (should (= (python-tests-look-at "except Profile.DoesNotExist:" -1 t) + (python-info-dedenter-opening-block-position))) + (python-tests-look-at "if profile.stats:") + (should (not (python-info-dedenter-opening-block-position))) + (python-tests-look-at "else:") + (should (= (python-tests-look-at "if profile.stats:" -1 t) + (python-info-dedenter-opening-block-position))) + (python-tests-look-at "finally:") + (should (= (python-tests-look-at "else:" -2 t) + (python-info-dedenter-opening-block-position))))) -(ert-deftest python-info-closing-block-2 () +(ert-deftest python-info-dedenter-opening-block-position-2 () (python-tests-with-temp-buffer - " + " if request.user.is_authenticated(): profile = Profile.objects.get_or_create(user=request.user) if profile.stats: @@ -2475,10 +2569,440 @@ } 'else' " - (python-tests-look-at "'else': 'do it'") - (should (not (python-info-closing-block))) - (python-tests-look-at "'else'") - (should (not (python-info-closing-block))))) + (python-tests-look-at "'else': 'do it'") + (should (not (python-info-dedenter-opening-block-position))) + (python-tests-look-at "'else'") + (should (not (python-info-dedenter-opening-block-position))))) + +(ert-deftest python-info-dedenter-opening-block-position-3 () + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except IOError: + msg = 'Error saving to disk' + message(msg) + logger.exception(msg) + except Exception: + if hide_details: + logger.exception('Unhandled exception') + else + finally: + data.free() +" + (python-tests-look-at "try:") + (should (not (python-info-dedenter-opening-block-position))) + + (python-tests-look-at "except IOError:") + (should (= (python-tests-look-at "try:" -1 t) + (python-info-dedenter-opening-block-position))) + + (python-tests-look-at "except Exception:") + (should (= (python-tests-look-at "except IOError:" -1 t) + (python-info-dedenter-opening-block-position))) + + (python-tests-look-at "if hide_details:") + (should (not (python-info-dedenter-opening-block-position))) + + ;; check indentation modifies the detected opening block + (python-tests-look-at "else") + (should (= (python-tests-look-at "if hide_details:" -1 t) + (python-info-dedenter-opening-block-position))) + + (indent-line-to 8) + (should (= (python-tests-look-at "if hide_details:" -1 t) + (python-info-dedenter-opening-block-position))) + + (indent-line-to 4) + (should (= (python-tests-look-at "except Exception:" -1 t) + (python-info-dedenter-opening-block-position))) + + (indent-line-to 0) + (should (= (python-tests-look-at "if save:" -1 t) + (python-info-dedenter-opening-block-position))))) + +(ert-deftest python-info-dedenter-opening-block-positions-1 () + (python-tests-with-temp-buffer + " +if save: + try: + write_to_disk(data) + except IOError: + msg = 'Error saving to disk' + message(msg) + logger.exception(msg) + except Exception: + if hide_details: + logger.exception('Unhandled exception') + else + finally: + data.free() +" + (python-tests-look-at "try:") + (should (not (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "except IOError:") + (should + (equal (list + (python-tests-look-at "try:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "except Exception:") + (should + (equal (list + (python-tests-look-at "except IOError:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "if hide_details:") + (should (not (python-info-dedenter-opening-block-positions))) + + ;; check indentation does not modify the detected opening blocks + (python-tests-look-at "else") + (should + (equal (list + (python-tests-look-at "if hide_details:" -1 t) + (python-tests-look-at "except Exception:" -1 t) + (python-tests-look-at "if save:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (indent-line-to 8) + (should + (equal (list + (python-tests-look-at "if hide_details:" -1 t) + (python-tests-look-at "except Exception:" -1 t) + (python-tests-look-at "if save:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (indent-line-to 4) + (should + (equal (list + (python-tests-look-at "if hide_details:" -1 t) + (python-tests-look-at "except Exception:" -1 t) + (python-tests-look-at "if save:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (indent-line-to 0) + (should + (equal (list + (python-tests-look-at "if hide_details:" -1 t) + (python-tests-look-at "except Exception:" -1 t) + (python-tests-look-at "if save:" -1 t)) + (python-info-dedenter-opening-block-positions))))) + +(ert-deftest python-info-dedenter-opening-block-positions-2 () + "Test detection of opening blocks for elif." + (python-tests-with-temp-buffer + " +if var: + if var2: + something() + elif var3: + something_else() + elif +" + (python-tests-look-at "elif var3:") + (should + (equal (list + (python-tests-look-at "if var2:" -1 t) + (python-tests-look-at "if var:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "elif\n") + (should + (equal (list + (python-tests-look-at "elif var3:" -1 t) + (python-tests-look-at "if var:" -1 t)) + (python-info-dedenter-opening-block-positions))))) + +(ert-deftest python-info-dedenter-opening-block-positions-3 () + "Test detection of opening blocks for else." + (python-tests-with-temp-buffer + " +try: + something() +except: + if var: + if var2: + something() + elif var3: + something_else() + else + +if var4: + while var5: + var4.pop() + else + + for value in var6: + if value > 0: + print value + else +" + (python-tests-look-at "else\n") + (should + (equal (list + (python-tests-look-at "elif var3:" -1 t) + (python-tests-look-at "if var:" -1 t) + (python-tests-look-at "except:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "else\n") + (should + (equal (list + (python-tests-look-at "while var5:" -1 t) + (python-tests-look-at "if var4:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "else\n") + (should + (equal (list + (python-tests-look-at "if value > 0:" -1 t) + (python-tests-look-at "for value in var6:" -1 t) + (python-tests-look-at "if var4:" -1 t)) + (python-info-dedenter-opening-block-positions))))) + +(ert-deftest python-info-dedenter-opening-block-positions-4 () + "Test detection of opening blocks for except." + (python-tests-with-temp-buffer + " +try: + something() +except ValueError: + something_else() + except +" + (python-tests-look-at "except ValueError:") + (should + (equal (list (python-tests-look-at "try:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "except\n") + (should + (equal (list (python-tests-look-at "except ValueError:" -1 t)) + (python-info-dedenter-opening-block-positions))))) + +(ert-deftest python-info-dedenter-opening-block-positions-5 () + "Test detection of opening blocks for finally." + (python-tests-with-temp-buffer + " +try: + something() + finally + +try: + something_else() +except: + logger.exception('something went wrong') + finally + +try: + something_else_else() +except Exception: + logger.exception('something else went wrong') +else: + print ('all good') + finally +" + (python-tests-look-at "finally\n") + (should + (equal (list (python-tests-look-at "try:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "finally\n") + (should + (equal (list (python-tests-look-at "except:" -1 t)) + (python-info-dedenter-opening-block-positions))) + + (python-tests-look-at "finally\n") + (should + (equal (list (python-tests-look-at "else:" -1 t)) + (python-info-dedenter-opening-block-positions))))) + +(ert-deftest python-info-dedenter-opening-block-message-1 () + "Test dedenters inside strings are ignored." + (python-tests-with-temp-buffer + "''' +try: + something() +except: + logger.exception('something went wrong') +''' +" + (python-tests-look-at "except\n") + (should (not (python-info-dedenter-opening-block-message))))) + +(ert-deftest python-info-dedenter-opening-block-message-2 () + "Test except keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +" + (python-tests-look-at "except:") + (should (string= + "Closes try:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))) + (end-of-line) + (should (string= + "Closes try:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))))) + +(ert-deftest python-info-dedenter-opening-block-message-3 () + "Test else keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +else: + logger.debug('all good') +" + (python-tests-look-at "else:") + (should (string= + "Closes except:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))) + (end-of-line) + (should (string= + "Closes except:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))))) + +(ert-deftest python-info-dedenter-opening-block-message-4 () + "Test finally keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +else: + logger.debug('all good') +finally: + clean() +" + (python-tests-look-at "finally:") + (should (string= + "Closes else:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))) + (end-of-line) + (should (string= + "Closes else:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))))) + +(ert-deftest python-info-dedenter-opening-block-message-5 () + "Test elif keyword." + (python-tests-with-temp-buffer + " +if a: + something() +elif b: +" + (python-tests-look-at "elif b:") + (should (string= + "Closes if a:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))) + (end-of-line) + (should (string= + "Closes if a:" + (substring-no-properties + (python-info-dedenter-opening-block-message)))))) + + +(ert-deftest python-info-dedenter-statement-p-1 () + "Test dedenters inside strings are ignored." + (python-tests-with-temp-buffer + "''' +try: + something() +except: + logger.exception('something went wrong') +''' +" + (python-tests-look-at "except\n") + (should (not (python-info-dedenter-statement-p))))) + +(ert-deftest python-info-dedenter-statement-p-2 () + "Test except keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +" + (python-tests-look-at "except:") + (should (= (point) (python-info-dedenter-statement-p))) + (end-of-line) + (should (= (save-excursion + (back-to-indentation) + (point)) + (python-info-dedenter-statement-p))))) + +(ert-deftest python-info-dedenter-statement-p-3 () + "Test else keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +else: + logger.debug('all good') +" + (python-tests-look-at "else:") + (should (= (point) (python-info-dedenter-statement-p))) + (end-of-line) + (should (= (save-excursion + (back-to-indentation) + (point)) + (python-info-dedenter-statement-p))))) + +(ert-deftest python-info-dedenter-statement-p-4 () + "Test finally keyword." + (python-tests-with-temp-buffer + " +try: + something() +except: + logger.exception('something went wrong') +else: + logger.debug('all good') +finally: + clean() +" + (python-tests-look-at "finally:") + (should (= (point) (python-info-dedenter-statement-p))) + (end-of-line) + (should (= (save-excursion + (back-to-indentation) + (point)) + (python-info-dedenter-statement-p))))) + +(ert-deftest python-info-dedenter-statement-p-5 () + "Test elif keyword." + (python-tests-with-temp-buffer + " +if a: + something() +elif b: +" + (python-tests-look-at "elif b:") + (should (= (point) (python-info-dedenter-statement-p))) + (end-of-line) + (should (= (save-excursion + (back-to-indentation) + (point)) + (python-info-dedenter-statement-p))))) (ert-deftest python-info-line-ends-backslash-p-1 () (python-tests-with-temp-buffer ------------------------------------------------------------ revno: 117523 fixes bug: http://debbugs.gnu.org/17839 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2014-07-12 10:47:40 +0300 message: Minor fix for read_minibuf_noninteractive on MS-Windows. src/minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch stdin to binary mode only if it is connected to a terminal. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-07-11 17:55:24 +0000 +++ src/ChangeLog 2014-07-12 07:47:40 +0000 @@ -1,3 +1,8 @@ +2014-07-12 Eli Zaretskii + + * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Switch + stdin to binary mode only if it is connected to a terminal. + 2014-07-11 Paul Eggert Coalesce extern decls. === modified file 'src/minibuf.c' --- src/minibuf.c 2014-07-11 17:55:24 +0000 +++ src/minibuf.c 2014-07-12 07:47:40 +0000 @@ -241,7 +241,8 @@ { emacs_get_tty (fileno (stdin), &etty); #ifdef WINDOWSNT - _setmode (fileno (stdin), O_BINARY); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_BINARY); #endif suppress_echo_on_tty (fileno (stdin)); } @@ -282,7 +283,8 @@ fprintf (stdout, "\n"); emacs_set_tty (fileno (stdin), &etty, 0); #ifdef WINDOWSNT - _setmode (fileno (stdin), O_TEXT); + if (isatty (fileno (stdin))) + _setmode (fileno (stdin), O_TEXT); #endif } ------------------------------------------------------------ Use --include-merged or -n0 to see merged revisions.