Now on revision 112469. ------------------------------------------------------------ revno: 112469 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Sun 2013-05-05 21:52:00 -0700 message: * unexelf.c: Fix some 32-bit integer problems, notably when debugging. Include , , , . Verify that ElfW (Half) fits in int. (fatal): Use same signature as lisp.h. (UNEXELF_DEBUG): New macro, replacing DEBUG, so that people can configure and build with -DUNEXELF_DEBUG without worrying about other modules that use DEBUG. (DEBUG_LOG) [UNEXELF_DEBUG]: New macro. All debug code that prints possibly-wide integers now uses it instead of plain fprintf. (entry_address): New function, which avoids problems with 32-bit overflow on 64-bit hosts. (OLD_SECTION_H, NEW_SECTION_H, NEW_PROGRAM_H): Use it. (round_up): Don't assume the remainder fits in int. (find_section): Use bool for boolean. Simplify debug code. (unexec): Don't assume file sizes fit in int or size_t. Omit unnecessary trailing newline in 'fatal' format. Use strerror rather than outputting decimal error number. Remove unused code when emacs is not defined; this file relies on Emacs now. Don't assume e_phnum and e_shnum are positive. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-05-06 04:31:16 +0000 +++ src/ChangeLog 2013-05-06 04:52:00 +0000 @@ -1,5 +1,26 @@ 2013-05-06 Paul Eggert + * unexelf.c: Fix some 32-bit integer problems, notably when debugging. + Include , , , . + Verify that ElfW (Half) fits in int. + (fatal): Use same signature as lisp.h. + (UNEXELF_DEBUG): New macro, replacing DEBUG, so that people can + configure and build with -DUNEXELF_DEBUG without worrying about + other modules that use DEBUG. + (DEBUG_LOG) [UNEXELF_DEBUG]: New macro. All debug code that prints + possibly-wide integers now uses it instead of plain fprintf. + (entry_address): New function, which avoids problems with 32-bit + overflow on 64-bit hosts. + (OLD_SECTION_H, NEW_SECTION_H, NEW_PROGRAM_H): Use it. + (round_up): Don't assume the remainder fits in int. + (find_section): Use bool for boolean. Simplify debug code. + (unexec): Don't assume file sizes fit in int or size_t. + Omit unnecessary trailing newline in 'fatal' format. + Use strerror rather than outputting decimal error number. + Remove unused code when emacs is not defined; + this file relies on Emacs now. + Don't assume e_phnum and e_shnum are positive. + * regex.c: Fix problems when DEBUG is defined. (extract_number, extract_number_and_incr): Define regardless of whether DEBUG is defined; that's simpler and makes the code less === modified file 'src/unexelf.c' --- src/unexelf.c 2013-01-01 09:11:05 +0000 +++ src/unexelf.c 2013-05-06 04:52:00 +0000 @@ -388,16 +388,19 @@ #include #include -extern void fatal (const char *msgid, ...); +extern _Noreturn void fatal (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); -#include +#include +#include +#include +#include +#include #include #include #include -#include -#include +#include #include -#include + #if !defined (__NetBSD__) && !defined (__OpenBSD__) #include #endif /* not __NetBSD__ and not __OpenBSD__ */ @@ -519,6 +522,17 @@ # define ElfW(type) ElfExpandBitsW (ELFSIZE, type) #endif +/* The code often converts ElfW (Half) values like e_shentsize to int; + check that this doesn't lose information. */ +#include +#include +verify ((! TYPE_SIGNED (ElfW (Half)) || INT_MIN <= TYPE_MINIMUM (ElfW (Half))) + && TYPE_MAXIMUM (ElfW (Half)) <= INT_MAX); + +#ifdef UNEXELF_DEBUG +# define DEBUG_LOG(expr) fprintf (stderr, #expr " 0x%jx\n", (uintmax_t) (expr)) +#endif + /* Get the address of a particular section or program header entry, * accounting for the size of the entries. */ @@ -546,17 +560,25 @@ Apr 23, 1996 */ +static void * +entry_address (void *section_h, int idx, int num, int entsize) +{ + char *h = section_h; + ptrdiff_t n = idx; + return h + entsize * n; +} + #define OLD_SECTION_H(n) \ - (*(ElfW (Shdr) *) ((byte *) old_section_h + old_file_h->e_shentsize * (n))) + (*(ElfW (Shdr) *) entry_address (old_section_h, n, old_file_h->e_shnum, \ + old_file_h->e_shentsize)) #define NEW_SECTION_H(n) \ - (*(ElfW (Shdr) *) ((byte *) new_section_h + new_file_h->e_shentsize * (n))) + (*(ElfW (Shdr) *) entry_address (new_section_h, n, new_file_h->e_shnum, \ + new_file_h->e_shentsize)) #define NEW_PROGRAM_H(n) \ - (*(ElfW (Phdr) *) ((byte *) new_program_h + new_file_h->e_phentsize * (n))) + (*(ElfW (Phdr) *) entry_address (new_program_h, n, new_file_h->e_phnum, \ + new_file_h->e_phentsize)) -#define PATCH_INDEX(n) \ - do { \ - if ((int) (n) >= old_bss_index) \ - (n)++; } while (0) +#define PATCH_INDEX(n) ((n) += old_bss_index <= (n)) typedef unsigned char byte; /* Round X up to a multiple of Y. */ @@ -564,7 +586,7 @@ static ElfW (Addr) round_up (ElfW (Addr) x, ElfW (Addr) y) { - int rem = x % y; + ElfW (Addr) rem = x % y; if (rem == 0) return x; return x - rem + y; @@ -575,33 +597,28 @@ about the file we are looking in. If we don't find the section NAME, that is a fatal error - if NOERROR is 0; we return -1 if NOERROR is nonzero. */ + if NOERROR is false; return -1 if NOERROR is true. */ static int find_section (const char *name, const char *section_names, const char *file_name, - ElfW (Ehdr) *old_file_h, ElfW (Shdr) *old_section_h, int noerror) + ElfW (Ehdr) *old_file_h, ElfW (Shdr) *old_section_h, + bool noerror) { int idx; for (idx = 1; idx < old_file_h->e_shnum; idx++) { -#ifdef DEBUG - fprintf (stderr, "Looking for %s - found %s\n", name, - section_names + OLD_SECTION_H (idx).sh_name); + char const *found_name = section_names + OLD_SECTION_H (idx).sh_name; +#ifdef UNEXELF_DEBUG + fprintf (stderr, "Looking for %s - found %s\n", name, found_name); #endif - if (!strcmp (section_names + OLD_SECTION_H (idx).sh_name, - name)) - break; - } - if (idx == old_file_h->e_shnum) - { - if (noerror) - return -1; - else - fatal ("Can't find %s in %s.\n", name, file_name); + if (strcmp (name, found_name) == 0) + return idx; } - return idx; + if (! noerror) + fatal ("Can't find %s in %s", name, file_name); + return -1; } /* **************************************************************** @@ -616,11 +633,9 @@ void unexec (const char *new_name, const char *old_name) { - int new_file, old_file, new_file_size; - -#if defined (emacs) || !defined (DEBUG) + int new_file, old_file; + off_t new_file_size; void *new_break; -#endif /* Pointers to the base of the image of the two files. */ caddr_t old_base, new_base; @@ -654,7 +669,7 @@ int old_mdebug_index; #endif struct stat stat_buf; - int old_file_size; + off_t old_file_size; /* Open the old file, allocate a buffer of the right size, and read in the file contents. */ @@ -662,15 +677,15 @@ old_file = open (old_name, O_RDONLY); if (old_file < 0) - fatal ("Can't open %s for reading: errno %d\n", old_name, errno); + fatal ("Can't open %s for reading: %s", old_name, strerror (errno)); - if (fstat (old_file, &stat_buf) == -1) - fatal ("Can't fstat (%s): errno %d\n", old_name, errno); + if (fstat (old_file, &stat_buf) != 0) + fatal ("Can't fstat (%s): %s", old_name, strerror (errno)); #if MAP_ANON == 0 mmap_fd = open ("/dev/zero", O_RDONLY); if (mmap_fd < 0) - fatal ("Can't open /dev/zero for reading: errno %d\n", errno, 0); + fatal ("Can't open /dev/zero for reading: %s", strerror (errno)); #endif /* We cannot use malloc here because that may use sbrk. If it does, @@ -678,13 +693,15 @@ extra careful to use the correct value of sbrk(0) after allocating all buffers in the code below, which we aren't. */ old_file_size = stat_buf.st_size; + if (! (0 <= old_file_size && old_file_size <= SIZE_MAX)) + fatal ("File size out of range"); old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, mmap_fd, 0); if (old_base == MAP_FAILED) - fatal ("Can't allocate buffer for %s\n", old_name, 0); + fatal ("Can't allocate buffer for %s: %s", old_name, strerror (errno)); - if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size) - fatal ("Didn't read all of %s: errno %d\n", old_name, errno); + if (read (old_file, old_base, old_file_size) != old_file_size) + fatal ("Didn't read all of %s: %s", old_name, strerror (errno)); /* Get pointers to headers & section names */ @@ -755,12 +772,8 @@ old_data_index = find_section (".data", old_section_names, old_name, old_file_h, old_section_h, 0); -#if defined (emacs) || !defined (DEBUG) new_break = sbrk (0); new_bss_addr = (ElfW (Addr)) new_break; -#else - new_bss_addr = old_bss_addr + old_bss_size + 0x1234; -#endif new_data2_addr = old_bss_addr; new_data2_size = new_bss_addr - old_bss_addr; new_data2_offset = OLD_SECTION_H (old_data_index).sh_offset @@ -771,38 +784,38 @@ section) was unaligned. */ new_data2_incr = new_data2_size + (new_data2_offset - old_bss_offset); -#ifdef DEBUG +#ifdef UNEXELF_DEBUG fprintf (stderr, "old_bss_index %d\n", old_bss_index); - fprintf (stderr, "old_bss_addr %x\n", old_bss_addr); - fprintf (stderr, "old_bss_size %x\n", old_bss_size); - fprintf (stderr, "old_bss_offset %x\n", old_bss_offset); - fprintf (stderr, "new_bss_addr %x\n", new_bss_addr); - fprintf (stderr, "new_data2_addr %x\n", new_data2_addr); - fprintf (stderr, "new_data2_size %x\n", new_data2_size); - fprintf (stderr, "new_data2_offset %x\n", new_data2_offset); - fprintf (stderr, "new_data2_incr %x\n", new_data2_incr); + DEBUG_LOG (old_bss_addr); + DEBUG_LOG (old_bss_size); + DEBUG_LOG (old_bss_offset); + DEBUG_LOG (new_bss_addr); + DEBUG_LOG (new_data2_addr); + DEBUG_LOG (new_data2_size); + DEBUG_LOG (new_data2_offset); + DEBUG_LOG (new_data2_incr); #endif - if ((uintptr_t) new_bss_addr < (uintptr_t) old_bss_addr + old_bss_size) - fatal (".bss shrank when undumping???\n", 0, 0); + if (new_bss_addr < old_bss_addr + old_bss_size) + fatal (".bss shrank when undumping"); /* Set the output file to the right size. Allocate a buffer to hold the image of the new file. Set pointers to various interesting - objects. stat_buf still has old_file data. */ + objects. */ new_file = open (new_name, O_RDWR | O_CREAT, 0666); if (new_file < 0) - fatal ("Can't creat (%s): errno %d\n", new_name, errno); + fatal ("Can't creat (%s): %s", new_name, strerror (errno)); - new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_incr; + new_file_size = old_file_size + old_file_h->e_shentsize + new_data2_incr; if (ftruncate (new_file, new_file_size)) - fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); + fatal ("Can't ftruncate (%s): %s", new_name, strerror (errno)); new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, mmap_fd, 0); if (new_base == MAP_FAILED) - fatal ("Can't allocate buffer for %s\n", old_name, 0); + fatal ("Can't allocate buffer for %s: %s", old_name, strerror (errno)); new_file_h = (ElfW (Ehdr) *) new_base; new_program_h = (ElfW (Phdr) *) ((byte *) new_base + old_file_h->e_phoff); @@ -825,10 +838,10 @@ new_file_h->e_shoff += new_data2_incr; new_file_h->e_shnum += 1; -#ifdef DEBUG - fprintf (stderr, "Old section offset %x\n", old_file_h->e_shoff); +#ifdef UNEXELF_DEBUG + DEBUG_LOG (old_file_h->e_shoff); fprintf (stderr, "Old section count %d\n", old_file_h->e_shnum); - fprintf (stderr, "New section offset %x\n", new_file_h->e_shoff); + DEBUG_LOG (new_file_h->e_shoff); fprintf (stderr, "New section count %d\n", new_file_h->e_shnum); #endif @@ -839,7 +852,7 @@ to adjust the offset and address of any segment that is above data2, just in case we decide to allow this later. */ - for (n = new_file_h->e_phnum - 1; n >= 0; n--) + for (n = new_file_h->e_phnum; --n >= 0; ) { /* Compute maximum of all requirements for alignment of section. */ ElfW (Word) alignment = (NEW_PROGRAM_H (n)).p_align; @@ -857,7 +870,7 @@ > (old_sbss_index == -1 ? old_bss_addr : round_up (old_bss_addr, alignment))) - fatal ("Program segment above .bss in %s\n", old_name, 0); + fatal ("Program segment above .bss in %s", old_name); if (NEW_PROGRAM_H (n).p_type == PT_LOAD && (round_up ((NEW_PROGRAM_H (n)).p_vaddr @@ -867,7 +880,7 @@ break; } if (n < 0) - fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0); + fatal ("Couldn't find segment next to .bss in %s", old_name); /* Make sure that the size includes any padding before the old .bss section. */ @@ -875,7 +888,7 @@ NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz; #if 0 /* Maybe allow section after data2 - does this ever happen? */ - for (n = new_file_h->e_phnum - 1; n >= 0; n--) + for (n = new_file_h->e_phnum; --n >= 0; ) { if (NEW_PROGRAM_H (n).p_vaddr && NEW_PROGRAM_H (n).p_vaddr >= new_data2_addr) @@ -894,7 +907,7 @@ /* Walk through all section headers, insert the new data2 section right before the new bss section. */ - for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++) + for (n = 1, nn = 1; n < old_file_h->e_shnum; n++, nn++) { caddr_t src; /* If it is (s)bss section, insert the new data2 section before it. */ @@ -1173,7 +1186,7 @@ } /* Update the symbol values of _edata and _end. */ - for (n = new_file_h->e_shnum - 1; n; n--) + for (n = new_file_h->e_shnum; 0 < --n; ) { byte *symnames; ElfW (Sym) *symp, *symendp; @@ -1233,7 +1246,7 @@ /* This loop seeks out relocation sections for the data section, so that it can undo relocations performed by the runtime linker. */ - for (n = new_file_h->e_shnum - 1; n; n--) + for (n = new_file_h->e_shnum; 0 < --n; ) { ElfW (Shdr) section = NEW_SECTION_H (n); @@ -1293,8 +1306,8 @@ /* Write out new_file, and free the buffers. */ if (write (new_file, new_base, new_file_size) != new_file_size) - fatal ("Didn't write %d bytes to %s: errno %d\n", - new_file_size, new_name, errno); + fatal ("Didn't write %lu bytes to %s: %s", + (unsigned long) new_file_size, new_name, strerror (errno)); munmap (old_base, old_file_size); munmap (new_base, new_file_size); @@ -1304,18 +1317,18 @@ close (mmap_fd); #endif - if (close (old_file)) - fatal ("Can't close (%s): errno %d\n", old_name, errno); - - if (close (new_file)) - fatal ("Can't close (%s): errno %d\n", new_name, errno); - - if (stat (new_name, &stat_buf) == -1) - fatal ("Can't stat (%s): errno %d\n", new_name, errno); + if (close (old_file) != 0) + fatal ("Can't close (%s): %s", old_name, strerror (errno)); + + if (close (new_file) != 0) + fatal ("Can't close (%s): %s", new_name, strerror (errno)); + + if (stat (new_name, &stat_buf) != 0) + fatal ("Can't stat (%s): %s", new_name, strerror (errno)); n = umask (777); umask (n); stat_buf.st_mode |= 0111 & ~n; - if (chmod (new_name, stat_buf.st_mode) == -1) - fatal ("Can't chmod (%s): errno %d\n", new_name, errno); + if (chmod (new_name, stat_buf.st_mode) != 0) + fatal ("Can't chmod (%s): %s", new_name, strerror (errno)); } ------------------------------------------------------------ revno: 112468 committer: Paul Eggert branch nick: trunk timestamp: Sun 2013-05-05 21:31:16 -0700 message: * regex.c: Fix problems when DEBUG is defined. (extract_number, extract_number_and_incr): Define regardless of whether DEBUG is defined; that's simpler and makes the code less likely to go stale in the normal case when DEBUG is not defined. Return int rather than taking an int * arg. All callers changed. (DEBUG_PRINT1, DEBUG_PRINT2, DEBUG_PRINT3, DEBUG_PRINT4): Remove, replacing with ... (DEBUG_PRINT): New macro. All callers changed. (DEBUG_COMPILES_ARGUMENTS): New macro. (print_fastmap, print_partial_compiled_pattern) [DEBUG]: (print_compiled_pattern, print_double_string) [DEBUG]: Use prototype rather than old-style definition. (print_partial_compiled_pattern, print_compiled_pattern) [DEBUG]: (ENSURE_FAIL_STACK, PUSH_FAILURE_REG) [DEBUG]: (POP_FAILURE_REG_OR_COUNT, PUSH_FAILURE_POINT) [DEBUG]: (POP_FAILURE_POINT, re_match_2_internal) [DEBUG]: Don't assume ptrdiff_t, size_t, and long are the same width as int. (POINTER_TO_OFFSET): Return ptrdiff_t, not regoff_t. This matters only when DEBUG is defined. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-05-05 17:41:09 +0000 +++ src/ChangeLog 2013-05-06 04:31:16 +0000 @@ -1,3 +1,25 @@ +2013-05-06 Paul Eggert + + * regex.c: Fix problems when DEBUG is defined. + (extract_number, extract_number_and_incr): Define regardless of + whether DEBUG is defined; that's simpler and makes the code less + likely to go stale in the normal case when DEBUG is not defined. + Return int rather than taking an int * arg. All callers changed. + (DEBUG_PRINT1, DEBUG_PRINT2, DEBUG_PRINT3, DEBUG_PRINT4): + Remove, replacing with ... + (DEBUG_PRINT): New macro. All callers changed. + (DEBUG_COMPILES_ARGUMENTS): New macro. + (print_fastmap, print_partial_compiled_pattern) [DEBUG]: + (print_compiled_pattern, print_double_string) [DEBUG]: + Use prototype rather than old-style definition. + (print_partial_compiled_pattern, print_compiled_pattern) [DEBUG]: + (ENSURE_FAIL_STACK, PUSH_FAILURE_REG) [DEBUG]: + (POP_FAILURE_REG_OR_COUNT, PUSH_FAILURE_POINT) [DEBUG]: + (POP_FAILURE_POINT, re_match_2_internal) [DEBUG]: + Don't assume ptrdiff_t, size_t, and long are the same width as int. + (POINTER_TO_OFFSET): Return ptrdiff_t, not regoff_t. + This matters only when DEBUG is defined. + 2013-05-05 Eli Zaretskii * xdisp.c (set_iterator_to_next): Set the === modified file 'src/regex.c' --- src/regex.c 2013-03-24 12:59:45 +0000 +++ src/regex.c 2013-05-06 04:31:16 +0000 @@ -710,51 +710,27 @@ at SOURCE. */ #define EXTRACT_NUMBER(destination, source) \ - do { \ - (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ - } while (0) + ((destination) = extract_number (source)) -#ifdef DEBUG -static void -extract_number (int *dest, re_char *source) +static int +extract_number (re_char *source) { - int temp = SIGN_EXTEND_CHAR (*(source + 1)); - *dest = *source & 0377; - *dest += temp << 8; + return (SIGN_EXTEND_CHAR (source[1]) << 8) + source[0]; } -# ifndef EXTRACT_MACROS /* To debug the macros. */ -# undef EXTRACT_NUMBER -# define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -# endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. SOURCE must be an lvalue. */ #define EXTRACT_NUMBER_AND_INCR(destination, source) \ - do { \ - EXTRACT_NUMBER (destination, source); \ - (source) += 2; \ - } while (0) + ((destination) = extract_number_and_incr (&source)) -#ifdef DEBUG -static void -extract_number_and_incr (int *destination, re_char **source) +static int +extract_number_and_incr (re_char **source) { - extract_number (destination, *source); + int num = extract_number (*source); *source += 2; + return num; } - -# ifndef EXTRACT_MACROS -# undef EXTRACT_NUMBER_AND_INCR -# define EXTRACT_NUMBER_AND_INCR(dest, src) \ - extract_number_and_incr (&dest, &src) -# endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ /* Store a multibyte character in three contiguous bytes starting DESTINATION, and increment DESTINATION to the byte after where the @@ -861,10 +837,8 @@ static int debug = -100000; # define DEBUG_STATEMENT(e) e -# define DEBUG_PRINT1(x) if (debug > 0) printf (x) -# define DEBUG_PRINT2(x1, x2) if (debug > 0) printf (x1, x2) -# define DEBUG_PRINT3(x1, x2, x3) if (debug > 0) printf (x1, x2, x3) -# define DEBUG_PRINT4(x1, x2, x3, x4) if (debug > 0) printf (x1, x2, x3, x4) +# define DEBUG_PRINT(...) if (debug > 0) printf (__VA_ARGS__) +# define DEBUG_COMPILES_ARGUMENTS # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ if (debug > 0) print_partial_compiled_pattern (s, e) # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ @@ -873,9 +847,8 @@ /* Print the fastmap in human-readable form. */ -void -print_fastmap (fastmap) - char *fastmap; +static void +print_fastmap (char *fastmap) { unsigned was_a_range = 0; unsigned i = 0; @@ -905,10 +878,8 @@ /* Print a compiled pattern string in human-readable form, starting at the START pointer into it and ending just before the pointer END. */ -void -print_partial_compiled_pattern (start, end) - re_char *start; - re_char *end; +static void +print_partial_compiled_pattern (re_char *start, re_char *end) { int mcnt, mcnt2; re_char *p = start; @@ -923,7 +894,7 @@ /* Loop over pattern commands. */ while (p < pend) { - fprintf (stderr, "%d:\t", p - start); + fprintf (stderr, "%td:\t", p - start); switch ((re_opcode_t) *p++) { @@ -1027,51 +998,58 @@ break; case on_failure_jump: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/on_failure_jump to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/on_failure_jump to %td", p + mcnt - start); break; case on_failure_keep_string_jump: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/on_failure_keep_string_jump to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/on_failure_keep_string_jump to %td", + p + mcnt - start); break; case on_failure_jump_nastyloop: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/on_failure_jump_nastyloop to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/on_failure_jump_nastyloop to %td", + p + mcnt - start); break; case on_failure_jump_loop: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/on_failure_jump_loop to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/on_failure_jump_loop to %td", + p + mcnt - start); break; case on_failure_jump_smart: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/on_failure_jump_smart to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/on_failure_jump_smart to %td", + p + mcnt - start); break; case jump: - extract_number_and_incr (&mcnt, &p); - fprintf (stderr, "/jump to %d", p + mcnt - start); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + fprintf (stderr, "/jump to %td", p + mcnt - start); break; case succeed_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - fprintf (stderr, "/succeed_n to %d, %d times", p - 2 + mcnt - start, mcnt2); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + EXTRACT_NUMBER_AND_INCR (mcnt2, p); + fprintf (stderr, "/succeed_n to %td, %d times", + p - 2 + mcnt - start, mcnt2); break; case jump_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - fprintf (stderr, "/jump_n to %d, %d times", p - 2 + mcnt - start, mcnt2); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + EXTRACT_NUMBER_AND_INCR (mcnt2, p); + fprintf (stderr, "/jump_n to %td, %d times", + p - 2 + mcnt - start, mcnt2); break; case set_number_at: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - fprintf (stderr, "/set_number_at location %d to %d", p - 2 + mcnt - start, mcnt2); + EXTRACT_NUMBER_AND_INCR (mcnt, p); + EXTRACT_NUMBER_AND_INCR (mcnt2, p); + fprintf (stderr, "/set_number_at location %td to %d", + p - 2 + mcnt - start, mcnt2); break; case wordbound: @@ -1151,13 +1129,12 @@ fprintf (stderr, "\n"); } - fprintf (stderr, "%d:\tend of pattern.\n", p - start); + fprintf (stderr, "%td:\tend of pattern.\n", p - start); } -void -print_compiled_pattern (bufp) - struct re_pattern_buffer *bufp; +static void +print_compiled_pattern (struct re_pattern_buffer *bufp) { re_char *buffer = bufp->buffer; @@ -1171,7 +1148,7 @@ print_fastmap (bufp->fastmap); } - printf ("re_nsub: %d\t", bufp->re_nsub); + printf ("re_nsub: %zu\t", bufp->re_nsub); printf ("regs_alloc: %d\t", bufp->regs_allocated); printf ("can_be_null: %d\t", bufp->can_be_null); printf ("no_sub: %d\t", bufp->no_sub); @@ -1183,13 +1160,9 @@ } -void -print_double_string (where, string1, size1, string2, size2) - re_char *where; - re_char *string1; - re_char *string2; - ssize_t size1; - ssize_t size2; +static void +print_double_string (re_char *where, re_char *string1, ssize_t size1, + re_char *string2, ssize_t size2) { ssize_t this_char; @@ -1216,10 +1189,12 @@ # define assert(e) # define DEBUG_STATEMENT(e) -# define DEBUG_PRINT1(x) -# define DEBUG_PRINT2(x1, x2) -# define DEBUG_PRINT3(x1, x2, x3) -# define DEBUG_PRINT4(x1, x2, x3, x4) +# if __STDC_VERSION__ < 199901L +# define DEBUG_COMPILES_ARGUMENTS +# define DEBUG_PRINT /* 'DEBUG_PRINT (x, y)' discards X and Y. */ (void) +# else +# define DEBUG_PRINT(...) +# endif # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) @@ -1469,20 +1444,21 @@ while (REMAINING_AVAIL_SLOTS <= space) { \ if (!GROW_FAIL_STACK (fail_stack)) \ return -2; \ - DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", (fail_stack).size);\ - DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ + DEBUG_PRINT ("\n Doubled stack; size now: %zd\n", (fail_stack).size);\ + DEBUG_PRINT (" slots available: %zd\n", REMAINING_AVAIL_SLOTS);\ } /* Push register NUM onto the stack. */ #define PUSH_FAILURE_REG(num) \ do { \ char *destination; \ + long n = num; \ ENSURE_FAIL_STACK(3); \ - DEBUG_PRINT4 (" Push reg %d (spanning %p -> %p)\n", \ - num, regstart[num], regend[num]); \ - PUSH_FAILURE_POINTER (regstart[num]); \ - PUSH_FAILURE_POINTER (regend[num]); \ - PUSH_FAILURE_INT (num); \ + DEBUG_PRINT (" Push reg %ld (spanning %p -> %p)\n", \ + n, regstart[n], regend[n]); \ + PUSH_FAILURE_POINTER (regstart[n]); \ + PUSH_FAILURE_POINTER (regend[n]); \ + PUSH_FAILURE_INT (n); \ } while (0) /* Change the counter's value to VAL, but make sure that it will @@ -1493,7 +1469,7 @@ int c; \ ENSURE_FAIL_STACK(3); \ EXTRACT_NUMBER (c, ptr); \ - DEBUG_PRINT4 (" Push number %p = %d -> %d\n", ptr, c, val); \ + DEBUG_PRINT (" Push number %p = %d -> %d\n", ptr, c, val); \ PUSH_FAILURE_INT (c); \ PUSH_FAILURE_POINTER (ptr); \ PUSH_FAILURE_INT (-1); \ @@ -1511,14 +1487,14 @@ unsigned char *ptr = (unsigned char*) POP_FAILURE_POINTER (); \ pfreg = POP_FAILURE_INT (); \ STORE_NUMBER (ptr, pfreg); \ - DEBUG_PRINT3 (" Pop counter %p = %d\n", ptr, pfreg); \ + DEBUG_PRINT (" Pop counter %p = %ld\n", ptr, pfreg); \ } \ else \ { \ regend[pfreg] = POP_FAILURE_POINTER (); \ regstart[pfreg] = POP_FAILURE_POINTER (); \ - DEBUG_PRINT4 (" Pop reg %d (spanning %p -> %p)\n", \ - pfreg, regstart[pfreg], regend[pfreg]); \ + DEBUG_PRINT (" Pop reg %ld (spanning %p -> %p)\n", \ + pfreg, regstart[pfreg], regend[pfreg]); \ } \ } while (0) @@ -1538,10 +1514,10 @@ cycle = 1; \ break; \ } \ - DEBUG_PRINT2 (" Other pattern: %p\n", FAILURE_PAT (failure)); \ + DEBUG_PRINT (" Other pattern: %p\n", FAILURE_PAT (failure)); \ failure = NEXT_FAILURE_HANDLE(failure); \ } \ - DEBUG_PRINT2 (" Other string: %p\n", FAILURE_STR (failure)); \ + DEBUG_PRINT (" Other string: %p\n", FAILURE_STR (failure)); \ } while (0) /* Push the information about the state we will need @@ -1560,23 +1536,23 @@ of 0 + -1 isn't done as unsigned. */ \ \ DEBUG_STATEMENT (nfailure_points_pushed++); \ - DEBUG_PRINT1 ("\nPUSH_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail); \ - DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ + DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n"); \ + DEBUG_PRINT (" Before push, next avail: %zd\n", (fail_stack).avail); \ + DEBUG_PRINT (" size: %zd\n", (fail_stack).size);\ \ ENSURE_FAIL_STACK (NUM_NONREG_ITEMS); \ \ - DEBUG_PRINT1 ("\n"); \ + DEBUG_PRINT ("\n"); \ \ - DEBUG_PRINT2 (" Push frame index: %d\n", fail_stack.frame); \ + DEBUG_PRINT (" Push frame index: %zd\n", fail_stack.frame); \ PUSH_FAILURE_INT (fail_stack.frame); \ \ - DEBUG_PRINT2 (" Push string %p: `", string_place); \ + DEBUG_PRINT (" Push string %p: `", string_place); \ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, size2);\ - DEBUG_PRINT1 ("'\n"); \ + DEBUG_PRINT ("'\n"); \ PUSH_FAILURE_POINTER (string_place); \ \ - DEBUG_PRINT2 (" Push pattern %p: ", pattern); \ + DEBUG_PRINT (" Push pattern %p: ", pattern); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern, pend); \ PUSH_FAILURE_POINTER (pattern); \ \ @@ -1609,28 +1585,28 @@ assert (!FAIL_STACK_EMPTY ()); \ \ /* Remove failure points and point to how many regs pushed. */ \ - DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ - DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ + DEBUG_PRINT ("POP_FAILURE_POINT:\n"); \ + DEBUG_PRINT (" Before pop, next avail: %zd\n", fail_stack.avail); \ + DEBUG_PRINT (" size: %zd\n", fail_stack.size); \ \ /* Pop the saved registers. */ \ while (fail_stack.frame < fail_stack.avail) \ POP_FAILURE_REG_OR_COUNT (); \ \ - pat = POP_FAILURE_POINTER (); \ - DEBUG_PRINT2 (" Popping pattern %p: ", pat); \ + pat = POP_FAILURE_POINTER (); \ + DEBUG_PRINT (" Popping pattern %p: ", pat); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ \ /* If the saved string location is NULL, it came from an \ on_failure_keep_string_jump opcode, and we want to throw away the \ saved NULL, thus retaining our current position in the string. */ \ str = POP_FAILURE_POINTER (); \ - DEBUG_PRINT2 (" Popping string %p: `", str); \ + DEBUG_PRINT (" Popping string %p: `", str); \ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ - DEBUG_PRINT1 ("'\n"); \ + DEBUG_PRINT ("'\n"); \ \ fail_stack.frame = POP_FAILURE_INT (); \ - DEBUG_PRINT2 (" Popping frame index: %d\n", fail_stack.frame); \ + DEBUG_PRINT (" Popping frame index: %zd\n", fail_stack.frame); \ \ assert (fail_stack.avail >= 0); \ assert (fail_stack.frame <= fail_stack.avail); \ @@ -2493,7 +2469,7 @@ #ifdef DEBUG debug++; - DEBUG_PRINT1 ("\nCompiling pattern: "); + DEBUG_PRINT ("\nCompiling pattern: "); if (debug > 0) { unsigned debug_count; @@ -3697,7 +3673,7 @@ if (debug > 0) { re_compile_fastmap (bufp); - DEBUG_PRINT1 ("\nCompiled pattern: \n"); + DEBUG_PRINT ("\nCompiled pattern: \n"); print_compiled_pattern (bufp); } debug--; @@ -4523,8 +4499,8 @@ and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ (FIRST_STRING_P (ptr) \ - ? ((regoff_t) ((ptr) - string1)) \ - : ((regoff_t) ((ptr) - string2 + size1))) + ? (ptr) - string1 \ + : (ptr) - string2 + (ptrdiff_t) size1) /* Call before fetching a character with *d. This switches over to string2 if necessary. @@ -4711,7 +4687,7 @@ /* If we're at the end of the pattern, we can change. */ if (skip_one_char (p1)) { - DEBUG_PRINT1 (" End of pattern: fast loop.\n"); + DEBUG_PRINT (" End of pattern: fast loop.\n"); return 1; } break; @@ -4727,7 +4703,7 @@ { if (c != RE_STRING_CHAR (p1 + 2, multibyte)) { - DEBUG_PRINT3 (" '%c' != '%c' => fast loop.\n", c, p1[2]); + DEBUG_PRINT (" '%c' != '%c' => fast loop.\n", c, p1[2]); return 1; } } @@ -4752,14 +4728,14 @@ that we can't change to pop_failure_jump. */ if (!not) { - DEBUG_PRINT1 (" No match => fast loop.\n"); + DEBUG_PRINT (" No match => fast loop.\n"); return 1; } } else if ((re_opcode_t) *p1 == anychar && c == '\n') { - DEBUG_PRINT1 (" . != \\n => fast loop.\n"); + DEBUG_PRINT (" . != \\n => fast loop.\n"); return 1; } } @@ -4802,7 +4778,7 @@ if (idx == p2[1] || idx == CHARSET_BITMAP_SIZE (p1)) { - DEBUG_PRINT1 (" No match => fast loop.\n"); + DEBUG_PRINT (" No match => fast loop.\n"); return 1; } } @@ -4819,7 +4795,7 @@ if (idx == p2[1]) { - DEBUG_PRINT1 (" No match => fast loop.\n"); + DEBUG_PRINT (" No match => fast loop.\n"); return 1; } } @@ -4945,7 +4921,7 @@ ssize_t pos, struct re_registers *regs, ssize_t stop) { /* General temporaries. */ - ssize_t mcnt; + int mcnt; size_t reg; /* Just past the end of the corresponding string. */ @@ -4987,7 +4963,7 @@ #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ fail_stack_type fail_stack; #endif -#ifdef DEBUG +#ifdef DEBUG_COMPILES_ARGUMENTS unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif @@ -5032,12 +5008,12 @@ and need to test it, it's not garbage. */ re_char *match_end = NULL; -#ifdef DEBUG +#ifdef DEBUG_COMPILES_ARGUMENTS /* Counts the total number of registers pushed. */ unsigned num_regs_pushed = 0; #endif - DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); + DEBUG_PRINT ("\n\nEntering re_match_2.\n"); INIT_FAIL_STACK (); @@ -5133,22 +5109,25 @@ dend = end_match_1; } - DEBUG_PRINT1 ("The compiled pattern is: "); + DEBUG_PRINT ("The compiled pattern is: "); DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); - DEBUG_PRINT1 ("The string to match is: `"); + DEBUG_PRINT ("The string to match is: `"); DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); + DEBUG_PRINT ("'\n"); /* This loops over pattern commands. It exits by returning from the function if the match is complete, or it drops through if the match fails at this starting point in the input data. */ for (;;) { - DEBUG_PRINT2 ("\n%p: ", p); + DEBUG_PRINT ("\n%p: ", p); if (p == pend) - { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("end of pattern ... "); + { + ptrdiff_t dcnt; + + /* End of pattern means we might have succeeded. */ + DEBUG_PRINT ("end of pattern ... "); /* If we haven't matched the entire string, and we want the longest match, try backtracking. */ @@ -5168,7 +5147,7 @@ else best_match_p = !FIRST_STRING_P (d); - DEBUG_PRINT1 ("backtracking.\n"); + DEBUG_PRINT ("backtracking.\n"); if (!FAIL_STACK_EMPTY ()) { /* More failure points to try. */ @@ -5179,7 +5158,7 @@ best_regs_set = true; match_end = d; - DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); + DEBUG_PRINT ("\nSAVING match as best so far.\n"); for (reg = 1; reg < num_regs; reg++) { @@ -5201,7 +5180,7 @@ For example, the pattern `x.*y.*z' against the strings `x-' and `y-z-', if the two strings are not consecutive in memory. */ - DEBUG_PRINT1 ("Restoring best registers.\n"); + DEBUG_PRINT ("Restoring best registers.\n"); d = match_end; dend = ((d >= string1 && d <= end1) @@ -5216,7 +5195,7 @@ } /* d != end_match_2 */ succeed_label: - DEBUG_PRINT1 ("Accepting match.\n"); + DEBUG_PRINT ("Accepting match.\n"); /* If caller wants register contents data back, do it. */ if (regs && !bufp->no_sub) @@ -5276,10 +5255,8 @@ regs->start[reg] = regs->end[reg] = -1; else { - regs->start[reg] - = (regoff_t) POINTER_TO_OFFSET (regstart[reg]); - regs->end[reg] - = (regoff_t) POINTER_TO_OFFSET (regend[reg]); + regs->start[reg] = POINTER_TO_OFFSET (regstart[reg]); + regs->end[reg] = POINTER_TO_OFFSET (regend[reg]); } } @@ -5292,17 +5269,17 @@ regs->start[reg] = regs->end[reg] = -1; } /* regs && !bufp->no_sub */ - DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", - nfailure_points_pushed, nfailure_points_popped, - nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); - - mcnt = POINTER_TO_OFFSET (d) - pos; - - DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); + DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n", + nfailure_points_pushed, nfailure_points_popped, + nfailure_points_pushed - nfailure_points_popped); + DEBUG_PRINT ("%u registers pushed.\n", num_regs_pushed); + + dcnt = POINTER_TO_OFFSET (d) - pos; + + DEBUG_PRINT ("Returning %td from re_match_2.\n", dcnt); FREE_VARIABLES (); - return mcnt; + return dcnt; } /* Otherwise match next pattern command. */ @@ -5311,11 +5288,11 @@ /* Ignore these. Used to ignore the n of succeed_n's which currently have n == 0. */ case no_op: - DEBUG_PRINT1 ("EXECUTING no_op.\n"); + DEBUG_PRINT ("EXECUTING no_op.\n"); break; case succeed: - DEBUG_PRINT1 ("EXECUTING succeed.\n"); + DEBUG_PRINT ("EXECUTING succeed.\n"); goto succeed_label; /* Match the next n pattern characters exactly. The following @@ -5323,7 +5300,7 @@ are the characters to match. */ case exactn: mcnt = *p++; - DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); + DEBUG_PRINT ("EXECUTING exactn %d.\n", mcnt); /* Remember the start point to rollback upon failure. */ dfail = d; @@ -5429,7 +5406,7 @@ int buf_charlen; re_wchar_t buf_ch; - DEBUG_PRINT1 ("EXECUTING anychar.\n"); + DEBUG_PRINT ("EXECUTING anychar.\n"); PREFETCH (); buf_ch = RE_STRING_CHAR_AND_LENGTH (d, buf_charlen, @@ -5442,7 +5419,7 @@ && buf_ch == '\000')) goto fail; - DEBUG_PRINT2 (" Matched `%d'.\n", *d); + DEBUG_PRINT (" Matched `%d'.\n", *d); d += buf_charlen; } break; @@ -5469,7 +5446,7 @@ /* Whether matching against a unibyte character. */ boolean unibyte_char = false; - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); + DEBUG_PRINT ("EXECUTING charset%s.\n", not ? "_not" : ""); range_table_exists = CHARSET_RANGE_TABLE_EXISTS_P (&p[-1]); @@ -5553,14 +5530,14 @@ matched within the group is recorded (in the internal registers data structure) under the register number. */ case start_memory: - DEBUG_PRINT2 ("EXECUTING start_memory %d:\n", *p); + DEBUG_PRINT ("EXECUTING start_memory %d:\n", *p); /* In case we need to undo this operation (via backtracking). */ - PUSH_FAILURE_REG ((unsigned int)*p); + PUSH_FAILURE_REG (*p); regstart[*p] = d; regend[*p] = NULL; /* probably unnecessary. -sm */ - DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); + DEBUG_PRINT (" regstart: %td\n", POINTER_TO_OFFSET (regstart[*p])); /* Move past the register number and inner group count. */ p += 1; @@ -5570,7 +5547,7 @@ /* The stop_memory opcode represents the end of a group. Its argument is the same as start_memory's: the register number. */ case stop_memory: - DEBUG_PRINT2 ("EXECUTING stop_memory %d:\n", *p); + DEBUG_PRINT ("EXECUTING stop_memory %d:\n", *p); assert (!REG_UNSET (regstart[*p])); /* Strictly speaking, there should be code such as: @@ -5588,7 +5565,7 @@ is *not* undone. */ regend[*p] = d; - DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); + DEBUG_PRINT (" regend: %td\n", POINTER_TO_OFFSET (regend[*p])); /* Move past the register number and the inner group count. */ p += 1; @@ -5601,7 +5578,7 @@ { register re_char *d2, *dend2; int regno = *p++; /* Get which register to match against. */ - DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); + DEBUG_PRINT ("EXECUTING duplicate %d.\n", regno); /* Can't back reference a group which we've never matched. */ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) @@ -5623,6 +5600,8 @@ ? regend[regno] : end_match_1); for (;;) { + ptrdiff_t dcnt; + /* If necessary, advance to next segment in register contents. */ while (d2 == dend2) @@ -5641,23 +5620,23 @@ PREFETCH (); /* How many characters left in this segment to match. */ - mcnt = dend - d; + dcnt = dend - d; /* Want how many consecutive characters we can match in one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; + if (dcnt > dend2 - d2) + dcnt = dend2 - d2; /* Compare that many; failure if mismatch, else move past them. */ if (RE_TRANSLATE_P (translate) - ? bcmp_translate (d, d2, mcnt, translate, target_multibyte) - : memcmp (d, d2, mcnt)) + ? bcmp_translate (d, d2, dcnt, translate, target_multibyte) + : memcmp (d, d2, dcnt)) { d = dfail; goto fail; } - d += mcnt, d2 += mcnt; + d += dcnt, d2 += dcnt; } } break; @@ -5666,7 +5645,7 @@ /* begline matches the empty string at the beginning of the string (unless `not_bol' is set in `bufp'), and after newlines. */ case begline: - DEBUG_PRINT1 ("EXECUTING begline.\n"); + DEBUG_PRINT ("EXECUTING begline.\n"); if (AT_STRINGS_BEG (d)) { @@ -5685,7 +5664,7 @@ /* endline is the dual of begline. */ case endline: - DEBUG_PRINT1 ("EXECUTING endline.\n"); + DEBUG_PRINT ("EXECUTING endline.\n"); if (AT_STRINGS_END (d)) { @@ -5702,7 +5681,7 @@ /* Match at the very beginning of the data. */ case begbuf: - DEBUG_PRINT1 ("EXECUTING begbuf.\n"); + DEBUG_PRINT ("EXECUTING begbuf.\n"); if (AT_STRINGS_BEG (d)) break; goto fail; @@ -5710,7 +5689,7 @@ /* Match at the very end of the data. */ case endbuf: - DEBUG_PRINT1 ("EXECUTING endbuf.\n"); + DEBUG_PRINT ("EXECUTING endbuf.\n"); if (AT_STRINGS_END (d)) break; goto fail; @@ -5734,8 +5713,8 @@ case; that seems worse than this. */ case on_failure_keep_string_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 ("EXECUTING on_failure_keep_string_jump %d (to %p):\n", - mcnt, p + mcnt); + DEBUG_PRINT ("EXECUTING on_failure_keep_string_jump %d (to %p):\n", + mcnt, p + mcnt); PUSH_FAILURE_POINT (p - 3, NULL); break; @@ -5756,8 +5735,8 @@ the loop. */ case on_failure_jump_nastyloop: EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 ("EXECUTING on_failure_jump_nastyloop %d (to %p):\n", - mcnt, p + mcnt); + DEBUG_PRINT ("EXECUTING on_failure_jump_nastyloop %d (to %p):\n", + mcnt, p + mcnt); assert ((re_opcode_t)p[-4] == no_op); { @@ -5777,8 +5756,8 @@ case on_failure_jump_loop: on_failure: EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 ("EXECUTING on_failure_jump_loop %d (to %p):\n", - mcnt, p + mcnt); + DEBUG_PRINT ("EXECUTING on_failure_jump_loop %d (to %p):\n", + mcnt, p + mcnt); { int cycle = 0; CHECK_INFINITE_LOOP (p - 3, d); @@ -5809,8 +5788,8 @@ pop_failure_jump back to this on_failure_jump. */ case on_failure_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 ("EXECUTING on_failure_jump %d (to %p):\n", - mcnt, p + mcnt); + DEBUG_PRINT ("EXECUTING on_failure_jump %d (to %p):\n", + mcnt, p + mcnt); PUSH_FAILURE_POINT (p -3, d); break; @@ -5824,8 +5803,8 @@ on_failure_keep_string_jump instead of on_failure_jump. */ case on_failure_jump_smart: EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 ("EXECUTING on_failure_jump_smart %d (to %p).\n", - mcnt, p + mcnt); + DEBUG_PRINT ("EXECUTING on_failure_jump_smart %d (to %p).\n", + mcnt, p + mcnt); { re_char *p1 = p; /* Next operation. */ /* Here, we discard `const', making re_match non-reentrant. */ @@ -5845,14 +5824,14 @@ if (mutually_exclusive_p (bufp, p1, p2)) { /* Use a fast `on_failure_keep_string_jump' loop. */ - DEBUG_PRINT1 (" smart exclusive => fast loop.\n"); + DEBUG_PRINT (" smart exclusive => fast loop.\n"); *p3 = (unsigned char) on_failure_keep_string_jump; STORE_NUMBER (p2 - 2, mcnt + 3); } else { /* Default to a safe `on_failure_jump' loop. */ - DEBUG_PRINT1 (" smart default => slow loop.\n"); + DEBUG_PRINT (" smart default => slow loop.\n"); *p3 = (unsigned char) on_failure_jump; } DEBUG_STATEMENT (debug -= 2); @@ -5864,9 +5843,9 @@ unconditional_jump: IMMEDIATE_QUIT_CHECK; EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); + DEBUG_PRINT ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ - DEBUG_PRINT2 ("(to %p).\n", p); + DEBUG_PRINT ("(to %p).\n", p); break; @@ -5875,7 +5854,7 @@ case succeed_n: /* Signedness doesn't matter since we only compare MCNT to 0. */ EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); + DEBUG_PRINT ("EXECUTING succeed_n %d.\n", mcnt); /* Originally, mcnt is how many times we HAVE to succeed. */ if (mcnt != 0) @@ -5894,7 +5873,7 @@ case jump_n: /* Signedness doesn't matter since we only compare MCNT to 0. */ EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); + DEBUG_PRINT ("EXECUTING jump_n %d.\n", mcnt); /* Originally, this is how many times we CAN jump. */ if (mcnt != 0) @@ -5913,14 +5892,14 @@ case set_number_at: { unsigned char *p2; /* Location of the counter. */ - DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); + DEBUG_PRINT ("EXECUTING set_number_at.\n"); EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Here, we discard `const', making re_match non-reentrant. */ p2 = (unsigned char*) p + mcnt; /* Signedness doesn't matter since we only copy MCNT's bits . */ EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" Setting %p to %d.\n", p2, mcnt); + DEBUG_PRINT (" Setting %p to %d.\n", p2, mcnt); PUSH_NUMBER (p2, mcnt); break; } @@ -5929,7 +5908,7 @@ case notwordbound: { boolean not = (re_opcode_t) *(p - 1) == notwordbound; - DEBUG_PRINT2 ("EXECUTING %swordbound.\n", not?"not":""); + DEBUG_PRINT ("EXECUTING %swordbound.\n", not ? "not" : ""); /* We SUCCEED (or FAIL) in one of the following cases: */ @@ -5971,7 +5950,7 @@ } case wordbeg: - DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); + DEBUG_PRINT ("EXECUTING wordbeg.\n"); /* We FAIL in one of the following cases: */ @@ -6016,7 +5995,7 @@ break; case wordend: - DEBUG_PRINT1 ("EXECUTING wordend.\n"); + DEBUG_PRINT ("EXECUTING wordend.\n"); /* We FAIL in one of the following cases: */ @@ -6061,7 +6040,7 @@ break; case symbeg: - DEBUG_PRINT1 ("EXECUTING symbeg.\n"); + DEBUG_PRINT ("EXECUTING symbeg.\n"); /* We FAIL in one of the following cases: */ @@ -6104,7 +6083,7 @@ break; case symend: - DEBUG_PRINT1 ("EXECUTING symend.\n"); + DEBUG_PRINT ("EXECUTING symend.\n"); /* We FAIL in one of the following cases: */ @@ -6151,7 +6130,8 @@ { boolean not = (re_opcode_t) *(p - 1) == notsyntaxspec; mcnt = *p++; - DEBUG_PRINT3 ("EXECUTING %ssyntaxspec %d.\n", not?"not":"", mcnt); + DEBUG_PRINT ("EXECUTING %ssyntaxspec %d.\n", not ? "not" : "", + mcnt); PREFETCH (); #ifdef emacs { @@ -6174,19 +6154,19 @@ #ifdef emacs case before_dot: - DEBUG_PRINT1 ("EXECUTING before_dot.\n"); + DEBUG_PRINT ("EXECUTING before_dot.\n"); if (PTR_BYTE_POS (d) >= PT_BYTE) goto fail; break; case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); + DEBUG_PRINT ("EXECUTING at_dot.\n"); if (PTR_BYTE_POS (d) != PT_BYTE) goto fail; break; case after_dot: - DEBUG_PRINT1 ("EXECUTING after_dot.\n"); + DEBUG_PRINT ("EXECUTING after_dot.\n"); if (PTR_BYTE_POS (d) <= PT_BYTE) goto fail; break; @@ -6196,8 +6176,8 @@ { boolean not = (re_opcode_t) *(p - 1) == notcategoryspec; mcnt = *p++; - DEBUG_PRINT3 ("EXECUTING %scategoryspec %d.\n", - not?"not":"", mcnt); + DEBUG_PRINT ("EXECUTING %scategoryspec %d.\n", + not ? "not" : "", mcnt); PREFETCH (); { @@ -6226,7 +6206,7 @@ { re_char *str, *pat; /* A restart point is known. Restore to that state. */ - DEBUG_PRINT1 ("\nFAIL:\n"); + DEBUG_PRINT ("\nFAIL:\n"); POP_FAILURE_POINT (str, pat); switch (*pat++) { @@ -6271,7 +6251,7 @@ FREE_VARIABLES (); return -1; /* Failure to match. */ -} /* re_match_2 */ +} /* Subroutine definitions for re_match_2. */ ------------------------------------------------------------ revno: 112467 committer: Paul Eggert branch nick: trunk timestamp: Sun 2013-05-05 20:32:19 -0700 message: * make-docfile.c (search_lisp_doc_at_eol) [DEBUG]: Fix typo, by removing references to no-longer-existing locals. diff: === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2013-04-04 03:46:25 +0000 +++ lib-src/ChangeLog 2013-05-06 03:32:19 +0000 @@ -1,3 +1,8 @@ +2013-05-06 Paul Eggert + + * make-docfile.c (search_lisp_doc_at_eol) [DEBUG]: Fix typo, + by removing references to no-longer-existing locals. + 2013-03-26 Eli Zaretskii Fix incompatibilities between MinGW.org and MinGW64 headers. === modified file 'lib-src/make-docfile.c' --- lib-src/make-docfile.c 2013-01-15 21:26:01 +0000 +++ lib-src/make-docfile.c 2013-05-06 03:32:19 +0000 @@ -1090,8 +1090,7 @@ if (c2 != '"' || c1 != '\\') { #ifdef DEBUG - fprintf (stderr, "## non-docstring in %s (%s)\n", - buffer, filename); + fprintf (stderr, "## non-docstring found\n"); #endif if (c != EOF) ungetc (c, infile); ------------------------------------------------------------ revno: 112466 committer: Stefan Monnier branch nick: trunk timestamp: Sun 2013-05-05 22:29:42 -0400 message: * lisp/progmodes/octave.el (octave-texinfo-font-lock-keywords): Remove. (octave-font-lock-texinfo-comment): Use texinfo-font-lock-keywords with some tweaks, instead. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 15:29:51 +0000 +++ lisp/ChangeLog 2013-05-06 02:29:42 +0000 @@ -1,3 +1,9 @@ +2013-05-06 Stefan Monnier + + * progmodes/octave.el (octave-texinfo-font-lock-keywords): Remove. + (octave-font-lock-texinfo-comment): Use texinfo-font-lock-keywords with + some tweaks, instead. + 2013-05-05 Leo Liu * progmodes/octave.el (octave-font-lock-keywords) === modified file 'lisp/progmodes/octave.el' --- lisp/progmodes/octave.el 2013-05-05 15:29:51 +0000 +++ lisp/progmodes/octave.el 2013-05-06 02:29:42 +0000 @@ -998,49 +998,40 @@ nil 'delimited nil nil beg end) (message "Function names match"))))) -;; Adapted from texinfo-font-lock-keywords -(defvar octave-texinfo-font-lock-keywords - `(("@\\([a-zA-Z]+\\|[^ \t\n]\\)" 1 font-lock-keyword-face prepend) ;commands - ("^\\*\\([^\n:]*\\)" 1 font-lock-function-name-face prepend) ;menu items - ("@\\(emph\\|i\\|sc\\){\\([^}]+\\)" 2 'italic prepend) - ("@\\(strong\\|b\\){\\([^}]+\\)" 2 'bold prepend) - ("@\\(kbd\\|key\\|url\\|uref\\){\\([^}]+\\)" - 2 font-lock-string-face prepend) - ("@\\(file\\|email\\){\\([^}]+\\)" 2 font-lock-string-face prepend) - ("@\\(samp\\|code\\|var\\|math\\|env\\|command\\|option\\){\\([^}]+\\)" - 2 font-lock-variable-name-face prepend) - ("@\\(cite\\|x?ref\\|pxref\\|dfn\\|inforef\\){\\([^}]+\\)" - 2 font-lock-constant-face prepend) - ("@\\(anchor\\){\\([^}]+\\)" 2 font-lock-type-face prepend) - ("@\\(dmn\\|acronym\\|value\\){\\([^}]+\\)" - 2 font-lock-builtin-face prepend) - ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face prepend)) - "Additional keywords to highlight in texinfo comment block.") - (defface octave-function-comment-block '((t (:inherit font-lock-doc-face))) "Face used to highlight function comment block." :group 'octave) +(eval-when-compile (require 'texinfo)) + (defun octave-font-lock-texinfo-comment () - (font-lock-add-keywords - nil - `((,(lambda (limit) - (while (and (search-forward "-*- texinfo -*-" limit t) - (octave-in-comment-p)) - (let ((beg (nth 8 (syntax-ppss))) - (end (progn - (octave-skip-comment-forward (point-max)) - (point)))) - (put-text-property beg end 'font-lock-multiline t) - (font-lock-prepend-text-property - beg end 'face 'octave-function-comment-block) - (dolist (kw octave-texinfo-font-lock-keywords) - (goto-char beg) - (while (re-search-forward (car kw) end 'move) - (font-lock-apply-highlight (cdr kw)))))) - nil))) - 'append)) + (let ((kws + (eval-when-compile + (delq nil (mapcar + (lambda (kw) + (if (numberp (nth 1 kw)) + `(,(nth 0 kw) ,(nth 1 kw) ,(nth 2 kw) prepend) + (message "Ignoring Texinfo highlight: %S" kw))) + texinfo-font-lock-keywords))))) + (font-lock-add-keywords + nil + `((,(lambda (limit) + (while (and (search-forward "-*- texinfo -*-" limit t) + (octave-in-comment-p)) + (let ((beg (nth 8 (syntax-ppss))) + (end (progn + (octave-skip-comment-forward (point-max)) + (point)))) + (put-text-property beg end 'font-lock-multiline t) + (font-lock-prepend-text-property + beg end 'face 'octave-function-comment-block) + (dolist (kw kws) + (goto-char beg) + (while (re-search-forward (car kw) end 'move) + (font-lock-apply-highlight (cdr kw)))))) + nil))) + 'append))) ;;; Indentation ------------------------------------------------------------ revno: 112465 fixes bug: http://debbugs.gnu.org/14306 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2013-05-05 20:41:09 +0300 message: Fix bug #14306 with whitespace mode together with linum-mode. src/xdisp.c (set_iterator_to_next): Set the ignore_overlay_strings_at_pos_p flag only if we are _really_ iterating over an overlay string, as indicated by the current.overlay_string_index member. diff: === modified file 'lisp/mail/rmail.el' --- lisp/mail/rmail.el 2013-02-12 04:46:18 +0000 +++ lisp/mail/rmail.el 2013-05-05 17:41:09 +0000 @@ -4752,7 +4752,7 @@ ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic ;;;;;; rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels -;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "119ce8b431f01e7f54bb6fa99603b3d9") +;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "61e7ad0931be1e07034dd57825ff326a") ;;; Generated autoloads from rmailsum.el (autoload 'rmail-summary "rmailsum" "\ === modified file 'src/ChangeLog' --- src/ChangeLog 2013-05-05 15:16:06 +0000 +++ src/ChangeLog 2013-05-05 17:41:09 +0000 @@ -1,3 +1,10 @@ +2013-05-05 Eli Zaretskii + + * xdisp.c (set_iterator_to_next): Set the + ignore_overlay_strings_at_pos_p flag only if we are _really_ + iterating over an overlay string, as indicated by the + current.overlay_string_index member. (Bug#14306) + 2013-05-05 Jan Djärv * nsmenu.m (ns_update_menubar): Move initialization of submenuTitle === modified file 'src/xdisp.c' --- src/xdisp.c 2013-04-02 01:54:56 +0000 +++ src/xdisp.c 2013-05-05 17:41:09 +0000 @@ -7153,6 +7153,7 @@ else if (it->dpvec_char_len > 0) { if (it->method == GET_FROM_STRING + && it->current.overlay_string_index >= 0 && it->n_overlay_strings > 0) it->ignore_overlay_strings_at_pos_p = 1; it->len = it->dpvec_char_len; ------------------------------------------------------------ revno: 112464 committer: Leo Liu branch nick: trunk timestamp: Sun 2013-05-05 23:29:51 +0800 message: * progmodes/octave.el (octave-font-lock-keywords) (octave-font-lock-texinfo-comment): Adjust for the byte-compiler. (inferior-octave-send-list-and-digest): Improve error message. (octave-mode, inferior-octave-mode): Use setq-local. (octave-help): Set info-lookup-mode. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 14:10:51 +0000 +++ lisp/ChangeLog 2013-05-05 15:29:51 +0000 @@ -1,3 +1,11 @@ +2013-05-05 Leo Liu + + * progmodes/octave.el (octave-font-lock-keywords) + (octave-font-lock-texinfo-comment): Adjust for the byte-compiler. + (inferior-octave-send-list-and-digest): Improve error message. + (octave-mode, inferior-octave-mode): Use setq-local. + (octave-help): Set info-lookup-mode. + 2013-05-05 Richard Stallman * vc/compare-w.el (compare-windows-whitespace): === modified file 'lisp/progmodes/octave.el' --- lisp/progmodes/octave.el 2013-05-05 04:49:27 +0000 +++ lisp/progmodes/octave.el 2013-05-05 15:29:51 +0000 @@ -24,9 +24,9 @@ ;;; Commentary: -;; This package provides emacs support for octave. It defines a major -;; mode for editing octave code and contains code for interacting with -;; an inferior octave process using comint. +;; This package provides emacs support for Octave. It defines a major +;; mode for editing Octave code and contains code for interacting with +;; an inferior Octave process using comint. ;; See the documentation of `octave-mode' and `run-octave' for further ;; information on usage and customization. @@ -109,19 +109,19 @@ 'font-lock-keyword-face) ;; Note: 'end' also serves as the last index in an indexing expression. ;; Ref: http://www.mathworks.com/help/matlab/ref/end.html - '((lambda (limit) - (while (re-search-forward "\\_" limit 'move) - (let ((beg (match-beginning 0)) - (end (match-end 0))) - (unless (octave-in-string-or-comment-p) - (unwind-protect - (progn - (goto-char beg) - (backward-up-list) - (when (memq (char-after) '(?\( ?\[ ?\{)) - (put-text-property beg end 'face nil))) - (goto-char end))))) - nil)) + (list (lambda (limit) + (while (re-search-forward "\\_" limit 'move) + (let ((beg (match-beginning 0)) + (end (match-end 0))) + (unless (octave-in-string-or-comment-p) + (unwind-protect + (progn + (goto-char beg) + (backward-up-list) + (when (memq (char-after) '(?\( ?\[ ?\{)) + (put-text-property beg end 'face nil))) + (goto-char end))))) + nil)) ;; Fontify all builtin operators. (cons "\\(&\\||\\|<=\\|>=\\|==\\|<\\|>\\|!=\\|!\\)" (if (boundp 'font-lock-builtin-face) @@ -527,8 +527,8 @@ (setq-local syntax-propertize-function #'octave-syntax-propertize-function) - (setq imenu-generic-expression octave-mode-imenu-generic-expression) - (setq imenu-case-fold-search nil) + (setq-local imenu-generic-expression octave-mode-imenu-generic-expression) + (setq-local imenu-case-fold-search nil) (add-hook 'completion-at-point-functions 'octave-completion-at-point-function nil t) @@ -638,7 +638,7 @@ (setq font-lock-defaults '(inferior-octave-font-lock-keywords nil nil)) - (setq info-lookup-mode 'octave-mode) + (setq-local info-lookup-mode 'octave-mode) (setq comint-input-ring-file-name (or (getenv "OCTAVE_HISTFILE") "~/.octave_hist") @@ -802,6 +802,10 @@ "Send LIST to the inferior Octave process and digest the output. The elements of LIST have to be strings and are sent one by one. All output is passed to the filter `inferior-octave-output-digest'." + (or (and inferior-octave-process + (process-live-p inferior-octave-process)) + (error (substitute-command-keys + "No inferior octave process running. Type \\[run-octave]"))) (let* ((proc inferior-octave-process) (filter (process-filter proc)) string) @@ -1021,21 +1025,21 @@ (defun octave-font-lock-texinfo-comment () (font-lock-add-keywords nil - '(((lambda (limit) - (while (and (search-forward "-*- texinfo -*-" limit t) - (octave-in-comment-p)) - (let ((beg (nth 8 (syntax-ppss))) - (end (progn - (octave-skip-comment-forward (point-max)) - (point)))) - (put-text-property beg end 'font-lock-multiline t) - (font-lock-prepend-text-property - beg end 'face 'octave-function-comment-block) - (dolist (kw octave-texinfo-font-lock-keywords) - (goto-char beg) - (while (re-search-forward (car kw) end 'move) - (font-lock-apply-highlight (cdr kw)))))) - nil))) + `((,(lambda (limit) + (while (and (search-forward "-*- texinfo -*-" limit t) + (octave-in-comment-p)) + (let ((beg (nth 8 (syntax-ppss))) + (end (progn + (octave-skip-comment-forward (point-max)) + (point)))) + (put-text-property beg end 'font-lock-multiline t) + (font-lock-prepend-text-property + beg end 'face 'octave-function-comment-block) + (dolist (kw octave-texinfo-font-lock-keywords) + (goto-char beg) + (while (re-search-forward (car kw) end 'move) + (font-lock-apply-highlight (cdr kw)))))) + nil))) 'append)) @@ -1493,6 +1497,7 @@ (let ((help-xref-following t)) (help-setup-xref (list 'octave-help fn) (called-interactively-p 'interactive))) + (setq-local info-lookup-mode 'octave-mode) ;; Note: can be turned off by suppress_verbose_help_message. ;; ;; Remove boring trailing text: Additional help for built-in functions ------------------------------------------------------------ revno: 112463 fixes bug: http://debbugs.gnu.org/14050 committer: Jan D. branch nick: trunk timestamp: Sun 2013-05-05 17:16:06 +0200 message: * nsmenu.m (ns_update_menubar): Move initialization of submenuTitle to where it is used, to avoid autorelease issues. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2013-05-05 00:51:49 +0000 +++ src/ChangeLog 2013-05-05 15:16:06 +0000 @@ -1,3 +1,8 @@ +2013-05-05 Jan Djärv + + * nsmenu.m (ns_update_menubar): Move initialization of submenuTitle + to where it is used, to avoid autorelease issues (Bug#14050). + 2013-05-05 Paul Eggert `write-region-inhibit-fsync' defaults to noninteractive (Bug#14273). === modified file 'src/nsmenu.m' --- src/nsmenu.m 2013-04-07 04:41:19 +0000 +++ src/nsmenu.m 2013-05-05 15:16:06 +0000 @@ -119,7 +119,6 @@ id menu = [NSApp mainMenu]; static EmacsMenu *last_submenu = nil; BOOL needsSet = NO; - const char *submenuTitle = [[submenu title] UTF8String]; bool owfi; Lisp_Object items; widget_value *wv, *first_wv, *prev_wv = 0; @@ -239,7 +238,7 @@ /* FIXME: we'd like to only parse the needed submenu, but this was causing crashes in the _common parsing code.. need to make sure proper initialization done.. */ -/* if (submenu && strcmp (submenuTitle, SSDATA (string))) +/* if (submenu && strcmp ([[submenu title] UTF8String], SSDATA (string))) continue; */ submenu_start[i] = menu_items_used; @@ -259,7 +258,7 @@ { /* should have found a menu for this one but didn't */ fprintf (stderr, "ERROR: did not find lisp menu for submenu '%s'.\n", - submenuTitle); + [[submenu title] UTF8String]); discard_menu_items (); unbind_to (specpdl_count, Qnil); [pool release]; @@ -346,8 +345,6 @@ string = AREF (items, i + 1); if (NILP (string)) break; -/* if (submenu && strcmp (submenuTitle, SSDATA (string))) - continue; */ wv->name = SSDATA (string); update_submenu_strings (wv->contents); @@ -358,6 +355,7 @@ create a new menu for each sub and fill it. */ if (submenu) { + const char *submenuTitle = [[submenu title] UTF8String]; for (wv = first_wv->contents; wv; wv = wv->next) { if (!strcmp (submenuTitle, wv->name)) ------------------------------------------------------------ revno: 112462 committer: Richard Stallman branch nick: trunk timestamp: Sun 2013-05-05 10:10:51 -0400 message: * vc/compare-w.el (compare-windows-whitespace): Treat no-break space as whitespace. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 14:08:50 +0000 +++ lisp/ChangeLog 2013-05-05 14:10:51 +0000 @@ -1,5 +1,8 @@ 2013-05-05 Richard Stallman + * vc/compare-w.el (compare-windows-whitespace): + Treat no-break space as whitespace. + * mail/rmailsum.el (rmail-summary-rmail-update): Detect empty summary and don't change selected message. (rmail-summary-goto-msg): Likewise. === modified file 'lisp/vc/compare-w.el' --- lisp/vc/compare-w.el 2013-01-11 23:08:55 +0000 +++ lisp/vc/compare-w.el 2013-05-05 14:10:51 +0000 @@ -35,7 +35,7 @@ :prefix "compare-" :group 'tools) -(defcustom compare-windows-whitespace "\\(\\s-\\|\n\\)+" +(defcustom compare-windows-whitespace "\\(\\s-\\|\n\\|\240\\)+" "Regexp or function that defines whitespace sequences for `compare-windows'. That command optionally ignores changes in whitespace. ------------------------------------------------------------ revno: 112461 committer: Richard Stallman branch nick: trunk timestamp: Sun 2013-05-05 10:08:50 -0400 message: * mail/rmailsum.el (rmail-new-summary, rmail-new-summary-1): Doc fixes, rename args. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 13:56:54 +0000 +++ lisp/ChangeLog 2013-05-05 14:08:50 +0000 @@ -4,6 +4,9 @@ Detect empty summary and don't change selected message. (rmail-summary-goto-msg): Likewise. + * mail/rmailsum.el (rmail-new-summary, rmail-new-summary-1): + Doc fixes, rename args. + 2013-05-05 Alan Mackenzie * progmodes/cc-defs.el (c-version): Increment to 5.32.5. === modified file 'lisp/mail/rmailsum.el' --- lisp/mail/rmailsum.el 2013-05-05 13:56:54 +0000 +++ lisp/mail/rmailsum.el 2013-05-05 14:08:50 +0000 @@ -394,12 +394,16 @@ (defvar rmail-new-summary-line-count) -(defun rmail-new-summary (desc redo func &rest args) +(defun rmail-new-summary (desc redo function &rest args) "Create a summary of selected messages. -DESC makes part of the mode line of the summary buffer. REDO is form ... -For each message, FUNC is applied to the message number and ARGS... -and if the result is non-nil, that message is included. -nil for FUNCTION means all messages." +DESC makes part of the mode line of the summary buffer. +REDO is what to put in `rmail-summary-redo'; usually +its car is the function that called `rmail-new-summary' +and its cdr is the arguments passed to that function. + +For each message, applies FUNCTION to the message number and ARGS..., +and if the result is non-nil, it includes that message in the summary. +If FUNCTION is nil, includes all messages." (message "Computing summary lines...") (unless rmail-buffer (error "No RMAIL buffer found")) @@ -407,7 +411,7 @@ (if (eq major-mode 'rmail-summary-mode) (setq was-in-summary t)) (with-current-buffer rmail-buffer - (setq rmail-summary-buffer (rmail-new-summary-1 desc redo func args) + (setq rmail-summary-buffer (rmail-new-summary-1 desc redo function args) ;; r-s-b is buffer-local. sumbuf rmail-summary-buffer mesg rmail-current-message)) @@ -435,14 +439,14 @@ (rmail-summary-construct-io-menu) (message "Computing summary lines...done"))) -(defun rmail-new-summary-1 (description form function args) +(defun rmail-new-summary-1 (description redo function args) "Filter messages to obtain summary lines. DESCRIPTION is added to the mode line. Return the summary buffer by invoking FUNCTION on each message -passing the message number and ARGS... +passing the message number and ARGS. -REDO is a form ... +REDO is what to put in `rmail-summary-redo'. The current buffer must be a Rmail buffer either containing a collection of mbox formatted messages or displaying a single @@ -511,7 +515,7 @@ (make-local-variable 'minor-mode-alist) (setq minor-mode-alist (list (list t (concat ": " description)))) (setq rmail-buffer rbuf - rmail-summary-redo form + rmail-summary-redo redo rmail-total-messages total))) sumbuf)) ------------------------------------------------------------ revno: 112460 committer: Richard Stallman branch nick: trunk timestamp: Sun 2013-05-05 09:56:54 -0400 message: Don't let an empty summary change current message. * mail/rmailsum.el (rmail-summary-rmail-update): Detect empty summary and don't change selected message. (rmail-summary-goto-msg): Likewise. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 12:17:12 +0000 +++ lisp/ChangeLog 2013-05-05 13:56:54 +0000 @@ -1,3 +1,9 @@ +2013-05-05 Richard Stallman + + * mail/rmailsum.el (rmail-summary-rmail-update): + Detect empty summary and don't change selected message. + (rmail-summary-goto-msg): Likewise. + 2013-05-05 Alan Mackenzie * progmodes/cc-defs.el (c-version): Increment to 5.32.5. === modified file 'lisp/mail/rmailsum.el' --- lisp/mail/rmailsum.el 2013-02-12 04:46:18 +0000 +++ lisp/mail/rmailsum.el 2013-05-05 13:56:54 +0000 @@ -490,8 +490,7 @@ ;; we "don't have" a summary. (setq rmail-summary-buffer nil) ;; I have not a clue what this clause is doing. If you read this - ;; chunk of code and have a clue, then please email that clue to - ;; pmr@pajato.com + ;; chunk of code and have a clue, then please write it here. (if rmail-enable-mime (with-current-buffer rmail-buffer (setq rmail-summary-buffer nil))) @@ -1122,57 +1121,59 @@ (forward-line -1)) (beginning-of-line) (skip-chars-forward " ") - (let ((msg-num (string-to-number (buffer-substring - (point) - (progn (skip-chars-forward "0-9") - (point)))))) - ;; Always leave `unseen' removed - ;; if we get out of isearch mode. - ;; Don't let a subsequent isearch restore that `unseen'. - (if (not isearch-mode) - (setq rmail-summary-put-back-unseen nil)) + ;; If the summary is empty, don't do anything. + (unless (eobp) + (let ((msg-num (string-to-number (buffer-substring + (point) + (progn (skip-chars-forward "0-9") + (point)))))) + ;; Always leave `unseen' removed + ;; if we get out of isearch mode. + ;; Don't let a subsequent isearch restore that `unseen'. + (if (not isearch-mode) + (setq rmail-summary-put-back-unseen nil)) - (or (eq rmail-current-message msg-num) - (let ((window (get-buffer-window rmail-buffer t)) - (owin (selected-window))) - (if isearch-mode - (progn - ;; If we first saw the previous message in this search, - ;; and we have gone to a different message while searching, - ;; put back `unseen' on the former one. - (when rmail-summary-put-back-unseen - (rmail-set-attribute rmail-unseen-attr-index t - rmail-current-message) - (save-excursion - (goto-char rmail-summary-put-back-unseen) - (rmail-summary-mark-seen rmail-current-message t t))) - ;; Arrange to do that later, for the new current message, - ;; if it still has `unseen'. - (setq rmail-summary-put-back-unseen - (if (rmail-message-unseen-p msg-num) - (point)))) - (setq rmail-summary-put-back-unseen nil)) - ;; Go to the desired message. - (setq rmail-current-message msg-num) - ;; Update the summary to show the message has been seen. - (rmail-summary-mark-seen msg-num t) - (if window - ;; Using save-window-excursion would cause the new value - ;; of point to get lost. - (unwind-protect - (progn - (select-window window) - (rmail-show-message msg-num t)) - (select-window owin)) - (if (buffer-name rmail-buffer) - (with-current-buffer rmail-buffer - (rmail-show-message msg-num t)))) - ;; In linum mode, the message buffer must be specially - ;; updated (Bug#4878). - (and (fboundp 'linum-update) - (buffer-name rmail-buffer) - (linum-update rmail-buffer)))) - (rmail-summary-update-highlight nil))))) + (or (eq rmail-current-message msg-num) + (let ((window (get-buffer-window rmail-buffer t)) + (owin (selected-window))) + (if isearch-mode + (progn + ;; If we first saw the previous message in this search, + ;; and we have gone to a different message while searching, + ;; put back `unseen' on the former one. + (when rmail-summary-put-back-unseen + (rmail-set-attribute rmail-unseen-attr-index t + rmail-current-message) + (save-excursion + (goto-char rmail-summary-put-back-unseen) + (rmail-summary-mark-seen rmail-current-message t t))) + ;; Arrange to do that later, for the new current message, + ;; if it still has `unseen'. + (setq rmail-summary-put-back-unseen + (if (rmail-message-unseen-p msg-num) + (point)))) + (setq rmail-summary-put-back-unseen nil)) + ;; Go to the desired message. + (setq rmail-current-message msg-num) + ;; Update the summary to show the message has been seen. + (rmail-summary-mark-seen msg-num t) + (if window + ;; Using save-window-excursion would cause the new value + ;; of point to get lost. + (unwind-protect + (progn + (select-window window) + (rmail-show-message msg-num t)) + (select-window owin)) + (if (buffer-name rmail-buffer) + (with-current-buffer rmail-buffer + (rmail-show-message msg-num t)))) + ;; In linum mode, the message buffer must be specially + ;; updated (Bug#4878). + (and (fboundp 'linum-update) + (buffer-name rmail-buffer) + (linum-update rmail-buffer)))) + (rmail-summary-update-highlight nil)))))) (defun rmail-summary-save-buffer () "Save the buffer associated with this RMAIL summary." @@ -1208,6 +1209,10 @@ (buffer-substring (point) (min (point-max) (+ 6 (point)))))) (total (with-current-buffer buf rmail-total-messages))) + ;; CURMSG should be nil when there's no current summary message + ;; (for instance, if the summary is empty). + (if (= curmsg 0) + (setq curmsg nil)) ;; If message number N was specified, find that message's line ;; or set message-not-found. ;; If N wasn't specified or that message can't be found. @@ -1228,17 +1233,20 @@ (setq n curmsg) (setq message-not-found t) (goto-char cur)))) - (rmail-summary-mark-seen n) - (rmail-summary-update-highlight message-not-found) - (beginning-of-line) - (unless skip-rmail - (let ((selwin (selected-window))) - (unwind-protect - (progn (rmail-pop-to-buffer buf) - (rmail-show-message n)) - (select-window selwin) - ;; The actions above can alter the current buffer. Preserve it. - (set-buffer obuf)))) + ;; N can be nil now, along with CURMSG, + ;; if the summary is empty. + (when n + (rmail-summary-mark-seen n) + (rmail-summary-update-highlight message-not-found) + (beginning-of-line) + (unless skip-rmail + (let ((selwin (selected-window))) + (unwind-protect + (progn (rmail-pop-to-buffer buf) + (rmail-show-message n)) + (select-window selwin) + ;; The actions above can alter the current buffer. Preserve it. + (set-buffer obuf))))) (not message-not-found))) ;; Update the highlighted line in an rmail summary buffer. ------------------------------------------------------------ revno: 112459 committer: Alan Mackenzie branch nick: trunk timestamp: Sun 2013-05-05 12:17:12 +0000 message: * progmodes/cc-defs.el (c-version): Increment to 5.32.5. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 08:48:44 +0000 +++ lisp/ChangeLog 2013-05-05 12:17:12 +0000 @@ -1,3 +1,7 @@ +2013-05-05 Alan Mackenzie + + * progmodes/cc-defs.el (c-version): Increment to 5.32.5. + 2013-05-05 Juri Linkov * info.el (Info-read-subfile): Use (point-min) instead of (point) === modified file 'lisp/progmodes/cc-defs.el' --- lisp/progmodes/cc-defs.el 2013-03-04 19:33:23 +0000 +++ lisp/progmodes/cc-defs.el 2013-05-05 12:17:12 +0000 @@ -93,7 +93,7 @@ ;;; Variables also used at compile time. -(defconst c-version "5.32.4" +(defconst c-version "5.32.5" "CC Mode version number.") (defconst c-version-sym (intern c-version)) ------------------------------------------------------------ revno: 112458 fixes bug: http://debbugs.gnu.org/14125 committer: Juri Linkov branch nick: trunk timestamp: Sun 2013-05-05 11:48:44 +0300 message: * lisp/info.el (Info-read-subfile): Use (point-min) instead of (point) to not add the length of the summary segment to the return value. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-05-05 04:49:27 +0000 +++ lisp/ChangeLog 2013-05-05 08:48:44 +0000 @@ -1,3 +1,9 @@ +2013-05-05 Juri Linkov + + * info.el (Info-read-subfile): Use (point-min) instead of (point) + to not add the length of the summary segment to the return value. + (Bug#14125) + 2013-05-05 Leo Liu * progmodes/octave.el (inferior-octave-strip-ctrl-g) === modified file 'lisp/info.el' --- lisp/info.el 2013-04-12 13:56:03 +0000 +++ lisp/info.el 2013-05-05 08:48:44 +0000 @@ -1530,11 +1530,14 @@ ;; Widen in case we are in the same subfile as before. (widen) (goto-char (point-min)) + ;; Skip the summary segment for `Info-search'. (if (looking-at "\^_") (forward-char 1) (search-forward "\n\^_")) + ;; Don't add the length of the skipped summary segment to + ;; the value returned to `Info-find-node-2'. (Bug#14125) (if (numberp nodepos) - (+ (- nodepos lastfilepos) (point))))) + (+ (- nodepos lastfilepos) (point-min))))) (defun Info-unescape-quotes (value) "Unescape double quotes and backslashes in VALUE." ------------------------------------------------------------ revno: 112457 committer: Paul Eggert branch nick: trunk timestamp: Sat 2013-05-04 22:03:08 -0700 message: Spelling fixes (or remove unnecessary and unusually-spelled words). diff: === modified file 'lisp/ls-lisp.el' --- lisp/ls-lisp.el 2013-04-27 16:55:29 +0000 +++ lisp/ls-lisp.el 2013-05-05 05:03:08 +0000 @@ -404,8 +404,8 @@ ;; the wildcard; let's say something similar. (insert "(No match)\n")) (insert (format "total %.0f\n" (fceiling (/ sum 1024.0)))))) - ;; dired-insert-directory exprects to find point after the - ;; text. But if the listinmg is empty, as e.g. in empty + ;; dired-insert-directory expects to find point after the + ;; text. But if the listing is empty, as e.g. in empty ;; directories with -a removed from switches, point will be ;; before the inserted text, and dired-insert-directory will ;; not indent the listing correctly. Going to the end of the === modified file 'src/fileio.c' --- src/fileio.c 2013-05-05 00:51:49 +0000 +++ src/fileio.c 2013-05-05 05:03:08 +0000 @@ -6076,9 +6076,8 @@ Hence, for now by default fsync is used only when interactive. For more on why fsync often fails to work on today's hardware, see: - Zheng M, Tucek J, Qin F, Lillibridge M. Understanding the - robustness of SSDs under power fault. 11th USENIX Conference on - File and Storage Technologies, 2013 (FAST '13), 271-84 + Zheng M et al. Understanding the robustness of SSDs under power fault. + 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84 http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf For more on why fsync does not suffice even if it works properly, see: === modified file 'src/nsfns.m' --- src/nsfns.m 2013-05-01 07:02:19 +0000 +++ src/nsfns.m 2013-05-05 05:03:08 +0000 @@ -1502,7 +1502,7 @@ ret = (ret == NSOKButton) || panelOK; - if (ret) + if (ret) { NSString *str = [panel getFilename]; if (! str) str = [panel getDirectory]; @@ -1699,7 +1699,7 @@ (Lisp_Object display) { NSWindowDepth depth; - + check_ns_display_info (display); depth = [ns_get_screen (display) depth]; @@ -2267,7 +2267,7 @@ { NSWindowDepth depth; NSString *colorSpace; - + check_ns_display_info (display); depth = [ns_get_screen (display) depth]; colorSpace = NSColorSpaceFromDepth (depth); @@ -2546,7 +2546,7 @@ /* Handle arrow/function/control keys and copy/paste/cut in file dialogs. - Return YES if handeled, NO if not. + Return YES if handled, NO if not. */ static BOOL handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)