commit 9a6cba2bd397414c68217f4f5a9ea2888293ae1c (HEAD, refs/remotes/origin/master) Author: YAMAMOTO Mitsuharu Date: Tue Mar 26 16:39:07 2019 +0900 Fix cairo scrolling for left scroll bars case * src/xterm.c (x_scroll_run) [USE_CAIRO]: Fix scrolling by unusing WINDOW_LEFT_EDGE_X. (Bug#31288) diff --git a/src/xterm.c b/src/xterm.c index 1b0c2f5ec5..e3034772a4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -4315,7 +4315,6 @@ x_scroll_run (struct window *w, struct run *run) #ifdef USE_CAIRO if (FRAME_CR_CONTEXT (f)) { - int wx = WINDOW_LEFT_EDGE_X (w); cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cairo_t *cr = cairo_create (s); @@ -4326,8 +4325,8 @@ x_scroll_run (struct window *w, struct run *run) cr = FRAME_CR_CONTEXT (f); cairo_save (cr); - cairo_set_source_surface (cr, s, wx, to_y); - cairo_rectangle (cr, wx, to_y, width, height); + cairo_set_source_surface (cr, s, x, to_y); + cairo_rectangle (cr, x, to_y, width, height); cairo_fill (cr); cairo_restore (cr); cairo_surface_destroy (s); commit b40db491cbbfd30e495d049c133667ebed828e2a Author: YAMAMOTO Mitsuharu Date: Tue Mar 26 14:50:10 2019 +0900 Support tool bar icon image on GTK+ >= 3.10 with cairo * src/gtkutil.c (xg_get_image_for_pixmap) [USE_CAIRO]: Use cairo image surface for GtkImage source. (xg_tool_item_stale_p, update_frame_tool_bar) [USE_CAIRO]: Use cairo image surface instead of pixmap for data associated with tool bar item. diff --git a/src/gtkutil.c b/src/gtkutil.c index 58e95a4679..4bd73b1a6d 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -368,7 +368,11 @@ xg_get_image_for_pixmap (struct frame *f, GtkWidget *widget, GtkImage *old_widget) { +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + cairo_surface_t *surface; +#else GdkPixbuf *icon_buf; +#endif /* If we have a file, let GTK do all the image handling. This seems to be the only way to make insensitive and activated icons @@ -396,6 +400,17 @@ xg_get_image_for_pixmap (struct frame *f, on a monochrome display, and sometimes bad on all displays with certain themes. */ +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + surface = img->cr_data; + + if (surface) + { + if (! old_widget) + old_widget = GTK_IMAGE (gtk_image_new_from_surface (surface)); + else + gtk_image_set_from_surface (old_widget, surface); + } +#else /* This is a workaround to make icons look good on pseudo color displays. Apparently GTK expects the images to have an alpha channel. If they don't, insensitive and activated icons will @@ -416,6 +431,7 @@ xg_get_image_for_pixmap (struct frame *f, g_object_unref (G_OBJECT (icon_buf)); } +#endif return GTK_WIDGET (old_widget); } @@ -4765,9 +4781,15 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name, { gpointer gold_img = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA); +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + void *old_img = (void *) gold_img; + if (old_img != img->cr_data) + return 1; +#else Pixmap old_img = (Pixmap) gold_img; if (old_img != img->pixmap) return 1; +#endif } /* Check button configuration and label. */ @@ -5059,7 +5081,13 @@ update_frame_tool_bar (struct frame *f) img = IMAGE_FROM_ID (f, img_id); prepare_image_for_display (f, img); - if (img->load_failed_p || img->pixmap == None) + if (img->load_failed_p +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + || img->cr_data == NULL +#else + || img->pixmap == None +#endif + ) { if (ti) gtk_container_remove (GTK_CONTAINER (wtoolbar), @@ -5109,7 +5137,12 @@ update_frame_tool_bar (struct frame *f) { w = xg_get_image_for_pixmap (f, img, x->widget, NULL); g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, - (gpointer)img->pixmap); +#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0) + (gpointer)img->cr_data +#else + (gpointer)img->pixmap +#endif + ); } #if GTK_CHECK_VERSION (3, 14, 0) commit 75b7b2cf7cfd39dd595fa27ddeef859ed85861bb Author: YAMAMOTO Mitsuharu Date: Tue Mar 26 14:42:10 2019 +0900 Simplify cairo image surface creation and destruction * src/dispextern.h (struct image) [USE_CAIRO]: Remove member cr_data2. * src/image.c (set_cairo_image_surface): New function split from original create_cairo_image_surface. Call cairo_surface_mark_dirty. (create_cairo_image_surface): Just create image surface and return it. (x_clear_image): Don't free cr_data2. (xpm_load, pbm_load, png_load_body, jpeg_load_body, tiff_load) (gif_load, imagemagick_load_image, svg_load_image) [USE_CAIRO]: Use new create_cairo_image_surface and cairo_image_surface_get_data instead of xmalloc. Use set_cairo_image_surface instead of old create_cairo_image_surface. (pbm_load) [USE_CAIRO]: Call cairo_surface_destroy for surface instead of xfree for data. (gif_load) [USE_CAIRO]: Multiply y-coordinate value by width instead of subimg_width. diff --git a/src/dispextern.h b/src/dispextern.h index 7947dc2dba..4d96e51d73 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2957,7 +2957,6 @@ struct image #ifdef USE_CAIRO void *cr_data; - void *cr_data2; #endif #ifdef HAVE_X_WINDOWS /* X images of the image, corresponding to the above Pixmaps. diff --git a/src/image.c b/src/image.c index 854fbe40f7..16c5978db6 100644 --- a/src/image.c +++ b/src/image.c @@ -1157,24 +1157,22 @@ get_spec_bg_or_alpha_as_argb (struct image *img, return bgcolor; } -static void -create_cairo_image_surface (struct image *img, - unsigned char *data, - int width, - int height) +static cairo_surface_t * +create_cairo_image_surface (int width, int height) { - cairo_surface_t *surface; cairo_format_t format = CAIRO_FORMAT_ARGB32; - int stride = cairo_format_stride_for_width (format, width); - surface = cairo_image_surface_create_for_data (data, - format, - width, - height, - stride); - img->width = width; - img->height = height; + eassert (cairo_format_stride_for_width (format, width) == width * 4); + + return cairo_image_surface_create (format, width, height); +} + +static void +set_cairo_image_surface (struct image *img, cairo_surface_t *surface) +{ + cairo_surface_mark_dirty (surface); + img->width = cairo_image_surface_get_width (surface); + img->height = cairo_image_surface_get_height (surface); img->cr_data = surface; - img->cr_data2 = data; img->pixmap = 0; } #endif @@ -1404,7 +1402,6 @@ x_clear_image (struct frame *f, struct image *img) #ifdef USE_CAIRO if (img->cr_data) cairo_surface_destroy ((cairo_surface_t *)img->cr_data); - if (img->cr_data2) xfree (img->cr_data2); #endif x_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS); @@ -3967,9 +3964,9 @@ xpm_load (struct frame *f, struct image *img) { int width = img->ximg->width; int height = img->ximg->height; - void *data = xmalloc (width * height * 4); + cairo_surface_t *surface = create_cairo_image_surface (width, height); int i; - uint32_t *od = data; + uint32_t *od = (uint32_t *) cairo_image_surface_get_data (surface); uint32_t *id = (uint32_t *) img->ximg->data; char *mid = img->mask_img ? img->mask_img->data : 0; uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); @@ -3988,7 +3985,7 @@ xpm_load (struct frame *f, struct image *img) } } - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); } else { @@ -5625,8 +5622,8 @@ pbm_load (struct frame *f, struct image *img) height = pbm_scan_number (&p, end); #ifdef USE_CAIRO - void *data = xmalloc (width * height * 4); - uint32_t *dataptr = data; + cairo_surface_t *surface = create_cairo_image_surface (width, height); + uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface); #endif if (type != PBM_MONO) @@ -5710,7 +5707,7 @@ pbm_load (struct frame *f, struct image *img) if (p >= end) { #ifdef USE_CAIRO - xfree (data); + cairo_surface_destroy (surface); #else x_destroy_x_image (ximg); #endif @@ -5756,7 +5753,7 @@ pbm_load (struct frame *f, struct image *img) if (raw_p && p + expected_size > end) { #ifdef USE_CAIRO - xfree (data); + cairo_surface_destroy (surface); #else x_destroy_x_image (ximg); #endif @@ -5790,7 +5787,7 @@ pbm_load (struct frame *f, struct image *img) if (r < 0 || g < 0 || b < 0) { #ifdef USE_CAIRO - xfree (data); + cairo_surface_destroy (surface); #else x_destroy_x_image (ximg); #endif @@ -5827,7 +5824,7 @@ pbm_load (struct frame *f, struct image *img) /* Maybe fill in the background field while we have ximg handy. */ #ifdef USE_CAIRO - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); #else if (NILP (image_spec_value (img->spec, QCbackground, NULL))) /* Casting avoids a GCC warning. */ @@ -6173,7 +6170,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) ptrdiff_t nbytes; #ifdef USE_CAIRO - unsigned char *data = 0; + cairo_surface_t *surface; uint32_t *dataptr; #else XImagePtr ximg, mask_img = NULL; @@ -6388,8 +6385,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) } #ifdef USE_CAIRO - data = (unsigned char *) xmalloc (width * height * 4); - dataptr = (uint32_t *) data; + surface = create_cairo_image_surface (width, height); + dataptr = (uint32_t *) cairo_image_surface_get_data (surface); #else /* Create an image and pixmap serving as mask if the PNG image contains an alpha channel. */ @@ -6480,7 +6477,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) img->height = height; #ifdef USE_CAIRO - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); #else /* Maybe fill in the background field while we have ximg handy. Casting avoids a GCC warning. */ @@ -7084,8 +7081,8 @@ jpeg_load_body (struct frame *f, struct image *img, JPOOL_IMAGE, row_stride, 1); #ifdef USE_CAIRO { - unsigned char *data = (unsigned char *) xmalloc (width*height*4); - uint32_t *dataptr = (uint32_t *) data; + cairo_surface_t *surface = create_cairo_image_surface (width, height); + uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface); int r, g, b; for (y = 0; y < height; ++y) @@ -7102,7 +7099,7 @@ jpeg_load_body (struct frame *f, struct image *img, } } - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); } #else for (y = 0; y < height; ++y) @@ -7564,8 +7561,8 @@ tiff_load (struct frame *f, struct image *img) #ifdef USE_CAIRO { - unsigned char *data = (unsigned char *) xmalloc (width*height*4); - uint32_t *dataptr = (uint32_t *) data; + cairo_surface_t *surface = create_cairo_image_surface (width, height); + uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface); for (y = 0; y < height; ++y) { @@ -7581,7 +7578,7 @@ tiff_load (struct frame *f, struct image *img) } } - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); } #else /* Initialize the color table. */ @@ -8020,9 +8017,8 @@ gif_load (struct frame *f, struct image *img) } #ifdef USE_CAIRO - /* xzalloc so data is zero => transparent */ - void *data = xzalloc (width * height * 4); - uint32_t *data32 = data; + cairo_surface_t *surface = create_cairo_image_surface (width, height); + uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface); if (STRINGP (specified_bg)) { XColor color; @@ -8169,7 +8165,7 @@ gif_load (struct frame *f, struct image *img) { #ifdef USE_CAIRO uint32_t *dataptr = - (data32 + ((row + subimg_top) * subimg_width + (data32 + ((row + subimg_top) * width + x + subimg_left)); int r = gif_color_map->Colors[c].Red; int g = gif_color_map->Colors[c].Green; @@ -8181,7 +8177,7 @@ gif_load (struct frame *f, struct image *img) XPutPixel (ximg, x + subimg_left, row + subimg_top, pixel_colors[c]); #endif - } + } } } } @@ -8195,7 +8191,7 @@ gif_load (struct frame *f, struct image *img) { #ifdef USE_CAIRO uint32_t *dataptr = - (data32 + ((y + subimg_top) * subimg_width + (data32 + ((y + subimg_top) * width + x + subimg_left)); int r = gif_color_map->Colors[c].Red; int g = gif_color_map->Colors[c].Green; @@ -8265,7 +8261,7 @@ gif_load (struct frame *f, struct image *img) } #ifdef USE_CAIRO - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); #else /* Maybe fill in the background field while we have ximg handy. */ if (NILP (image_spec_value (img->spec, QCbackground, NULL))) @@ -8693,7 +8689,7 @@ imagemagick_load_image (struct frame *f, struct image *img, char hint_buffer[MaxTextExtent]; char *filename_hint = NULL; #ifdef USE_CAIRO - void *data = NULL; + cairo_surface_t *surface; #endif /* Initialize the ImageMagick environment. */ @@ -8905,9 +8901,9 @@ imagemagick_load_image (struct frame *f, struct image *img, ad-hoc and needs to be more researched. */ void *dataptr; #ifdef USE_CAIRO - data = xmalloc (width * height * 4); + surface = create_cairo_image_surface (width, height); const char *exportdepth = "BGRA"; - dataptr = data; + dataptr = cairo_image_surface_get_data (surface); #else int imagedepth = 24; /*MagickGetImageDepth(image_wand);*/ const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP"; /*"RGBP";*/ @@ -8954,7 +8950,8 @@ imagemagick_load_image (struct frame *f, struct image *img, double quantum_range = QuantumRange; MagickRealType color_scale = 65535.0 / quantum_range; #ifdef USE_CAIRO - data = xmalloc (width * height * 4); + surface = create_cairo_image_surface (width, height); + uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface); color_scale /= 256; #else /* Try to create a x pixmap to hold the imagemagick pixmap. */ @@ -8999,7 +8996,7 @@ imagemagick_load_image (struct frame *f, struct image *img, { PixelGetMagickColor (pixels[x], &pixel); #ifdef USE_CAIRO - ((uint32_t *)data)[width * y + x] = + dataptr[width * y + x] = lookup_rgb_color (f, color_scale * pixel.red, color_scale * pixel.green, @@ -9017,7 +9014,7 @@ imagemagick_load_image (struct frame *f, struct image *img, } #ifdef USE_CAIRO - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); #else #ifdef COLOR_TABLE_SUPPORT /* Remember colors allocated for this image. */ @@ -9480,13 +9477,13 @@ svg_load_image (struct frame *f, struct image *img, char *contents, { #ifdef USE_CAIRO - unsigned char *data = (unsigned char *) xmalloc (width*height*4); + cairo_surface_t *surface = create_cairo_image_surface (width, height); + uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface); uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); for (int y = 0; y < height; ++y) { const guchar *iconptr = pixels + y * rowstride; - uint32_t *dataptr = (uint32_t *) (data + y * rowstride); for (int x = 0; x < width; ++x) { @@ -9503,7 +9500,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, } } - create_cairo_image_surface (img, data, width, height); + set_cairo_image_surface (img, surface); g_object_unref (pixbuf); #else /* Try to create a x pixmap to hold the svg pixmap. */ commit 568af1e5822086f2457b6e98a22624b8138aa72f Author: Basil L. Contovounesios Date: Tue Mar 26 01:46:06 2019 +0000 ; * etc/NEWS: Fix Tabulated List mode nesting. diff --git a/etc/NEWS b/etc/NEWS index afee1e1dca..71127ac725 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1225,7 +1225,7 @@ frame when making a frame. ** Tabulated List mode +++ -** New user options for tabulated list sort indicators. +*** New user options for tabulated list sort indicators. You can now customize which sorting indicator character to display near the current column in Tabulated Lists (see variables 'tabulated-list-gui-sort-indicator-asc', commit 7f967b1658114530a19d34d93151804452cc724f Author: Paul Eggert Date: Mon Mar 25 15:20:20 2019 -0700 Port recent ngettext stub to non-glibc * src/editfns.c: Don’t try to call glibc ngettext; we’re not ready for that yet. (Fngettext): Do not restrict integer arguments to fixnums. Improve doc string a bit. diff --git a/src/editfns.c b/src/editfns.c index ab48cdb6fd..bfffadc733 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -53,12 +53,6 @@ along with GNU Emacs. If not, see . */ #include "window.h" #include "blockinput.h" -#ifdef _LIBC -# include -#else -# include "gettext.h" -#endif - static void update_buffer_properties (ptrdiff_t, ptrdiff_t); static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); @@ -2845,30 +2839,20 @@ usage: (save-restriction &rest BODY) */) /* i18n (internationalization). */ DEFUN ("ngettext", Fngettext, Sngettext, 3, 3, 0, - doc: /* Return the plural form of the translation of the string. -This function is similar to the `gettext' function as it finds the message -catalogs in the same way. But it takes two extra arguments. The MSGID -parameter must contain the singular form of the string to be converted. -It is also used as the key for the search in the catalog. -The MSGID_PLURAL parameter is the plural form. The parameter N is used -to determine the plural form. If no message catalog is found MSGID is -returned if N is equal to 1, otherwise MSGID_PLURAL. */) + doc: /* Return the translation of MSGID (plural MSGID_PLURAL) depending on N. +MSGID is the singular form of the string to be converted; +use it as the key for the search in the translation catalog. +MSGID_PLURAL is the plural form. Use N to select the proper translation. +If no message catalog is found, MSGID is returned if N is equal to 1, +otherwise MSGID_PLURAL. */) (Lisp_Object msgid, Lisp_Object msgid_plural, Lisp_Object n) { CHECK_STRING (msgid); CHECK_STRING (msgid_plural); - CHECK_FIXNUM (n); + CHECK_INTEGER (n); -#ifdef _LIBGETTEXT_H - return build_string (ngettext (SSDATA (msgid), - SSDATA (msgid_plural), - XFIXNUM (n))); -#else - if (XFIXNUM (n) == 1) - return msgid; - else - return msgid_plural; -#endif + /* Placeholder implementation until we get our act together. */ + return EQ (n, make_fixnum (1)) ? msgid : msgid_plural; } DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, commit a3c5530975e57f813ec0f52e16584aacaadc1d05 Author: Paul Eggert Date: Mon Mar 25 14:53:56 2019 -0700 Update from Gnulib. This incorporates: 2019-03-23 Support cross-compilation to musl libc 2019-03-23 noreturn: In C++ mode with clang, use _Noreturn as fallback 2019-03-22 _Noreturn: beware of C's _Noreturn in C++ pre C++11 2019-03-19 Help making signal handlers more reliable 2019-03-18 _Noreturn: clang and MSVC do support [[noreturn]] in C++11 2019-03-17 _Noreturn: GCC 4.7 does not support [[noreturn]] in C++11 2019-03-14 all: Update URLs to msdn.microsoft.com * doc/misc/texinfo.tex, lib/_Noreturn.h, lib/gettimeofday.c: * lib/mktime.c, lib/regcomp.c, lib/regexec.c, lib/stat-time.h: * lib/utimens.c, m4/fdopendir.m4, m4/getgroups.m4: * m4/gettimeofday.m4, m4/gnulib-common.m4, m4/putenv.m4, m4/utimes.m4: Update from gnulib. diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 5ae97d767d..667292a96a 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex @@ -3,8 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2019-03-09.13} - +\def\texinfoversion{2019-03-23.11} % % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. % @@ -449,11 +448,10 @@ }% } -% First remove any @comment, then any @c comment. Also remove a @texinfoc -% comment (see \scanmacro for details). Pass the result on to \argcheckspaces. +% First remove any @comment, then any @c comment. Pass the result on to +% \argcheckspaces. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} -\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm} -\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. % @@ -1125,6 +1123,16 @@ \fi \fi +\newif\ifpdforxetex +\pdforxetexfalse +\ifpdf + \pdforxetextrue +\fi +\ifx\XeTeXrevision\thisisundefined\else + \pdforxetextrue +\fi + + % PDF uses PostScript string constants for the names of xref targets, % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be @@ -2838,7 +2846,7 @@ % @t, explicit typewriter. \def\t#1{% - {\tt \rawbackslash \plainfrenchspacing #1}% + {\tt \plainfrenchspacing #1}% \null } @@ -2865,7 +2873,6 @@ % Turn off hyphenation. \nohyphenation % - \rawbackslash \plainfrenchspacing #1% }% @@ -3106,7 +3113,7 @@ % So now @email is just like @uref, unless we are pdf. % %\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf +\ifpdforxetex \def\email#1{\doemail#1,,\finish} \def\doemail#1,#2,#3\finish{\begingroup \unsepspaces @@ -3116,18 +3123,7 @@ \endlink \endgroup} \else - \ifx\XeTeXrevision\thisisundefined - \let\email=\uref - \else - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} - \fi + \let\email=\uref \fi % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), @@ -4661,19 +4657,6 @@ } } -% We have this subroutine so that we can handle at least some @value's -% properly in indexes (we call \makevalueexpandable in \indexdummies). -% The command has to be fully expandable (if the variable is set), since -% the result winds up in the index file. This means that if the -% variable's value contains other Texinfo commands, it's almost certain -% it will fail (although perhaps we could fix that with sufficient work -% to do a one-level expansion on the result, instead of complete). -% -% Unfortunately, this has the consequence that when _ is in the *value* -% of an @set, it does not print properly in the roman fonts (get the cmr -% dot accent at position 126 instead). No fix comes to mind, and it's -% been this way since 2003 or earlier, so just ignore it. -% \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% @@ -4702,7 +4685,7 @@ % if possible, otherwise sort late. \def\indexnofontsvalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax - ZZZZZZZ + ZZZZZZZ% \else \csname SET#1\endcsname \fi @@ -5238,17 +5221,25 @@ \xdef\indexsortkey{#1}\endgroup} } -% The default definition +\def\indexwriteseealso#1{ + \gdef\pagenumbertext{@seealso{#1}}% +} + +% The default definitions \def\sortas#1{}% +\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only +\def\putwordSeeAlso{see also} % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}": % * Set \bracedtext to "{aaa}{bbb}" % * Set \fullindexsortkey to "aaa @subentry ZZZ" +% * If @seealso occurs, set \pagenumbertext % \def\splitindexentry#1{% \gdef\fullindexsortkey{}% \xdef\bracedtext{}% \def\sep{}% + \def\seealso##1{}% \expandafter\doindexsegment#1\subentry\finish\subentry } @@ -5269,6 +5260,7 @@ % font commands turned off. \bgroup \let\sortas\indexwritesortas + \let\seealso\indexwriteseealso \indexnofonts % The braces around the commands are recognized by texindex. \def\lbracechar{{\indexlbrace}}% @@ -5279,8 +5271,9 @@ \def\atchar##1{\@}% % \let\indexsortkey\empty + \global\let\pagenumbertext\empty % Execute the segment and throw away the typeset output. This executes - % any @sortas commands in this segment. + % any @sortas or @seealso commands in this segment. \setbox\dummybox = \hbox{\segment}% \ifx\indexsortkey\empty{% \indexnonalnumdisappear @@ -5328,7 +5321,9 @@ % \edef\temp{% \write\writeto{% - \string\entry{\fullindexsortkey}{\noexpand\folio}\bracedtext}% + \string\entry{\fullindexsortkey}% + {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}% + \bracedtext}% }% \temp } @@ -5428,9 +5423,14 @@ % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} +% \entry {topic}{} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. +% \secondary {subtopic}{} +% for a subtopic with sub-subtopics +% \tertiary {subtopic}{subsubtopic}{pagelist} +% for each sub-subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. @@ -5480,8 +5480,6 @@ \fi \closein 1 \endgroup} -\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx} -\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next} % If the index file starts with a backslash, forgo reading the index % file altogether. If somebody upgrades texinfo.tex they may still have @@ -5493,42 +5491,12 @@ \message{skipping sorted index file}% (Skipped sorted index file in obsolete format) \else - \printindexzzz + \begindoublecolumns + \input \jobname.\indexname s + \enddoublecolumns \fi } -\def\printindexzzz{% - \begindoublecolumns - \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty - % - % Read input from the index file line by line. - \loopdo - \ifeof1 \else - \read 1 to \nextline - \fi - % - \indexinputprocessing - \thisline - % - \ifeof1\else - \let\thisline\nextline - \repeat - %% - \enddoublecolumns -} - -\def\indexinputprocessing{% - \ifeof1 - \let\firsttoken\relax - \else - \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}% - \act - \fi -} -\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken} -\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1} - - % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. @@ -5606,12 +5574,6 @@ % \def\entry{% \begingroup - % - % For pdfTeX and XeTeX. - % The redefinition of \domark stops marks being added in \pdflink to - % preserve coloured links across page boundaries. Otherwise the marks - % would get in the way of \lastbox in \insertentrybox. - \let\domark\relax % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. @@ -5645,35 +5607,31 @@ \gdef\finishentry#1{% \egroup % end box A \dimen@ = \wd\boxA % Length of text of entry - \global\setbox\boxA=\hbox\bgroup\unhbox\boxA - % #1 is the page number. - % - % Get the width of the page numbers, and only use - % leaders if they are present. - \global\setbox\boxB = \hbox{#1}% - \ifdim\wd\boxB = 0pt - \null\nobreak\hfill\ % - \else - % - \null\nobreak\indexdotfill % Have leaders before the page number. + \global\setbox\boxA=\hbox\bgroup + \unhbox\boxA + % #1 is the page number. % - \ifpdf - \pdfgettoks#1.% - \hskip\skip\thinshrinkable\the\toksA + % Get the width of the page numbers, and only use + % leaders if they are present. + \global\setbox\boxB = \hbox{#1}% + \ifdim\wd\boxB = 0pt + \null\nobreak\hfill\ % \else - \ifx\XeTeXrevision\thisisundefined - \hskip\skip\thinshrinkable #1% - \else + % + \null\nobreak\indexdotfill % Have leaders before the page number. + % + \ifpdforxetex \pdfgettoks#1.% \hskip\skip\thinshrinkable\the\toksA + \else + \hskip\skip\thinshrinkable #1% \fi \fi - \fi \egroup % end \boxA \ifdim\wd\boxB = 0pt - \global\setbox\entrybox=\vbox{\unhbox\boxA}% - \else - \global\setbox\entrybox=\vbox\bgroup + \noindent\unhbox\boxA\par + \nobreak + \else\bgroup % We want the text of the entries to be aligned to the left, and the % page numbers to be aligned to the right. % @@ -5739,55 +5697,11 @@ \egroup % The \vbox \fi \endgroup - \dotheinsertentrybox }} \newskip\thinshrinkable \skip\thinshrinkable=.15em minus .15em -\newbox\entrybox -\def\insertentrybox{% - \ourunvbox\entrybox -} - -% default definition -\let\dotheinsertentrybox\insertentrybox - -% Use \lastbox to take apart vbox box by box, and add each sub-box -% to the current vertical list. -\def\ourunvbox#1{% -\bgroup % for local binding of \delayedbox - % Remove the last box from box #1 - \global\setbox#1=\vbox{% - \unvbox#1% - \unskip % remove any glue - \unpenalty - \global\setbox\interbox=\lastbox - }% - \setbox\delayedbox=\box\interbox - \ifdim\ht#1=0pt\else - \ourunvbox#1 % Repeat on what's left of the box - \nobreak - \fi - \box\delayedbox -\egroup -} -\newbox\delayedbox -\newbox\interbox - -% Used from \printindex. \firsttoken should be the first token -% after the \entry. If it's not another \entry, we are at the last -% line of a group of index entries, so insert a penalty to discourage -% widowed index entries. -\def\dotheinsertentryboxwithpenalty{% - \ifx\firsttoken\isentry - \else - \penalty 9000 - \fi - \insertentrybox -} -\def\isentry{\entry}% - % Like plain.tex's \dotfill, except uses up at least 1 em. % The filll stretch here overpowers both the fil and fill stretch to push % the page number to the right. @@ -5797,24 +5711,15 @@ \def\primary #1{\line{#1\hfil}} -\newskip\secondaryindent \secondaryindent=0.5cm -\def\secondary#1#2{{% - \parfillskip=0in - \parskip=0in - \hangindent=1in - \hangafter=1 - \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill - \ifpdf - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \else - \ifx\XeTeXrevision\thisisundefined - #2 - \else - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \fi - \fi - \par -}} +\def\secondary{\indententry{0.5cm}} +\def\tertiary{\indententry{1cm}} + +\def\indententry#1#2#3{% + \bgroup + \leftskip=#1 + \entry{#2}{#3}% + \egroup +} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, @@ -5832,17 +5737,6 @@ \output = {% \savetopmark % - % Here is a possibility not foreseen in manmac: if we accumulate a - % whole lot of material, we might end up calling this \output - % routine twice in a row (see the doublecol-lose test, which is - % essentially a couple of indexes with @setchapternewpage off). In - % that case we just ship out what is in \partialpage with the normal - % output routine. Generally, \partialpage will be empty when this - % runs and this will be a no-op. See the indexspread.tex test case. - \ifvoid\partialpage \else - \onepageout{\pagecontents\partialpage}% - \fi - % \global\setbox\partialpage = \vbox{% % Unvbox the main output page. \unvbox\PAGE @@ -6122,11 +6016,9 @@ % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name % we only have subsub. \chardef\maxseclevel = 3 @@ -6778,13 +6670,8 @@ % 1 and 2 (the page numbers aren't printed), and so are the first % two pages of the document. Thus, we'd have two destinations named % `1', and two named `2'. - \ifpdf + \ifpdforxetex \global\pdfmakepagedesttrue - \else - \ifx\XeTeXrevision\thisisundefined - \else - \global\pdfmakepagedesttrue - \fi \fi } @@ -7147,11 +7034,7 @@ % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle + % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} @@ -7166,7 +7049,18 @@ % \newskip\lskip\newskip\rskip +% only require the font if @cartouche is actually used +\def\cartouchefontdefs{% + \font\circle=lcircle10\relax + \circthick=\fontdimen8\circle +} +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip + + \envdef\cartouche{% + \cartouchefontdefs \ifhmode\par\fi % can't be in the midst of a paragraph. \startsavinginserts \lskip=\leftskip \rskip=\rightskip @@ -8038,9 +7932,6 @@ } \fi -% alias because \c means cedilla in @tex or @math -\let\texinfoc=\c - % Used at the time of macro expansion. % Argument is macro body with arguments substituted \def\scanmacro#1{% @@ -8048,10 +7939,11 @@ \def\xeatspaces{\eatspaces}% % % Process the macro body under the current catcode regime. - \scantokens{#1@texinfoc}% + \scantokens{#1@comment}% % - % The \texinfoc is to remove the \newlinechar added by \scantokens, and - % can be noticed by \parsearg. + % The \comment is to remove the \newlinechar added by \scantokens, and + % can be noticed by \parsearg. Note \c isn't used because this means cedilla + % in math mode. } % Used for copying and captions @@ -8152,12 +8044,14 @@ \def\macroargctxt{% \scanctxt \catcode`\ =\active + \catcode`\@=\other \catcode`\^^M=\other \catcode`\\=\active } \def\macrolineargctxt{% used for whole-line arguments without braces \scanctxt + \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other } @@ -8721,9 +8615,21 @@ % also remove a trailing comma, in case of something like this: % @node Help-Cross, , , Cross-refs \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} -\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} +\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode} + +% Used so that the @top node doesn't have to be wrapped in an @ifnottex +% conditional. +% \doignore goes to more effort to skip nested conditionals but we don't need +% that here. +\def\omittopnode{% + \ifx\lastnode\wordTop + \expandafter\ignorenode\fi +} +\def\wordTop{Top} + +% Divert output to a box that is not output until the next @node command. +\def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}} -\let\nwnode=\node \let\lastnode=\empty % Write a cross-reference definition for the current node. #1 is the @@ -9198,19 +9104,6 @@ \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other - % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. - % in xref tags, i.e., node names. But since ^^e4 notation isn't - % supported in the main text, it doesn't seem desirable. Furthermore, - % that is not enough: for node names that actually contain a ^ - % character, we would end up writing a line like this: 'xrdef {'hat - % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first - % argument, and \hat is not an expandable control sequence. It could - % all be worked out, but why? Either we support ^^ or we don't. - % - % The other change necessary for this was to define \auxhat: - % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter - % and then to call \auxhat in \setq. - % \catcode`\^=\other % % Special characters. Should be turned off anyway, but... @@ -9228,14 +9121,7 @@ \catcode`\%=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % - % This is to support \ in node names and titles, since the \ - % characters end up in a \csname. It's easier than - % leaving it active and making its active definition an actual \ - % character. What I don't understand is why it works in the *value* - % of the xrdef. Seems like it should be a catcode12 \, and that - % should not typeset properly. But it works, so I'm moving on for - % now. --karl, 15jan04. - \catcode`\\=\other + \catcode`\\=\active % % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 @@ -11506,11 +11392,9 @@ % \backslashcurfont outputs one backslash character in current font, % as in \char`\\. \global\chardef\backslashcurfont=`\\ -\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work -% \realbackslash is an actual character `\' with catcode other, and -% \doublebackslash is two of them (for the pdf outlines). -{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} +% \realbackslash is an actual character `\' with catcode other. +{\catcode`\\=\other @gdef@realbackslash{\}} % In Texinfo, backslash is an active character; it prints the backslash % in fixed width font. @@ -11528,10 +11412,8 @@ @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. -% \rawbackslash defines an active \ to do \backslashcurfont. % \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. We switch back and forth between these. -@gdef@rawbackslash{@let\=@backslashcurfont} +% catcode other. @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of @@ -11603,7 +11485,7 @@ @ifx\@eatinput @let\ = @ttbackslash @fi @catcode13=5 % regular end of line @enableemergencynewline - @let@c=@texinfoc + @let@c=@comment @let@parsearg@originalparsearg % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index 94fdfaf022..7594e4b0c0 100644 --- a/lib/_Noreturn.h +++ b/lib/_Noreturn.h @@ -1,8 +1,11 @@ #ifndef _Noreturn -# if 201103 <= (defined __cplusplus ? __cplusplus : 0) +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) # define _Noreturn [[noreturn]] -# elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)) +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) /* _Noreturn works as-is. */ # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__)) diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index 360cdc4d79..e728bf4735 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -72,10 +72,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) /* On native Windows, there are two ways to get the current time: GetSystemTimeAsFileTime - + or GetSystemTimePreciseAsFileTime - . + . GetSystemTimeAsFileTime produces values that jump by increments of 15.627 milliseconds (!) on average. Whereas GetSystemTimePreciseAsFileTime values usually jump by 1 or 2 @@ -92,7 +92,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) GetSystemTimeAsFileTime (¤t_time); /* Convert from FILETIME to 'struct timeval'. */ - /* FILETIME: */ + /* FILETIME: */ ULONGLONG since_1601 = ((ULONGLONG) current_time.dwHighDateTime << 32) | (ULONGLONG) current_time.dwLowDateTime; diff --git a/lib/mktime.c b/lib/mktime.c index d411aa7705..e3783d7a95 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -72,7 +72,7 @@ my_tzset (void) /* Rectify the value of the environment variable TZ. There are four possible kinds of such values: - Traditional US time zone names, e.g. "PST8PDT". Syntax: see - + - Time zone names based on geography, that contain one or more slashes, e.g. "Europe/Moscow". - Time zone names based on geography, without slashes, e.g. diff --git a/lib/regcomp.c b/lib/regcomp.c index 10a0a49d97..892139a02a 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -1800,8 +1800,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->word_char = 0; #ifdef RE_ENABLE_I18N token->mb_partial = 0; - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; token->mb_partial = 1; @@ -1988,8 +1988,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->type = OP_PERIOD; break; case '^': - if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && - re_string_cur_idx (input) != 0) + if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) + && re_string_cur_idx (input) != 0) { char prev = re_string_peek_byte (input, -1); if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') @@ -1999,8 +1999,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->opr.ctx_type = LINE_FIRST; break; case '$': - if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && - re_string_cur_idx (input) + 1 != re_string_length (input)) + if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) + && re_string_cur_idx (input) + 1 != re_string_length (input)) { re_token_t next; re_string_skip_bytes (input, 1); @@ -2034,8 +2034,8 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->opr.c = c; #ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; return 1; @@ -2333,8 +2333,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, } FALLTHROUGH; case OP_CLOSE_SUBEXP: - if ((token->type == OP_CLOSE_SUBEXP) && - !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) + if ((token->type == OP_CLOSE_SUBEXP) + && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) { *err = REG_ERPAREN; return NULL; diff --git a/lib/regexec.c b/lib/regexec.c index 7fcd1a509a..f464869fb0 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -2204,9 +2204,9 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, int naccepted; /* Check the node can accept "multi byte". */ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); - if (naccepted > 0 && str_idx + naccepted <= max_str_idx && - !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], - dfa->nexts[node_idx])) + if (naccepted > 0 && str_idx + naccepted <= max_str_idx + && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], + dfa->nexts[node_idx])) /* The node can't accept the "multi byte", or the destination was already thrown away, then the node couldn't accept the current input "multi byte". */ @@ -3782,10 +3782,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, /* FIXME: I don't think this if is needed, as both '\n' and '\0' are char_len == 1. */ /* '.' accepts any one character except the following two cases. */ - if ((!(dfa->syntax & RE_DOT_NEWLINE) && - re_string_byte_at (input, str_idx) == '\n') || - ((dfa->syntax & RE_DOT_NOT_NULL) && - re_string_byte_at (input, str_idx) == '\0')) + if ((!(dfa->syntax & RE_DOT_NEWLINE) + && re_string_byte_at (input, str_idx) == '\n') + || ((dfa->syntax & RE_DOT_NOT_NULL) + && re_string_byte_at (input, str_idx) == '\0')) return 0; return char_len; } diff --git a/lib/stat-time.h b/lib/stat-time.h index d4f1f96104..38a1f55a6c 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -171,7 +171,7 @@ get_stat_birthtime (struct stat const *st _GL_UNUSED) #elif defined _WIN32 && ! defined __CYGWIN__ /* Native Windows platforms (but not Cygwin) put the "file creation time" in st_ctime (!). See - . */ + . */ # if _GL_WINDOWS_STAT_TIMESPEC t = st->st_ctim; # else diff --git a/lib/utimens.c b/lib/utimens.c index 34689bcd65..c9b65ef4c2 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -288,8 +288,8 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) #ifdef USE_SETFILETIME /* On native Windows, use SetFileTime(). See - - */ + + */ if (0 <= fd) { HANDLE handle; @@ -307,10 +307,10 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) if (ts == NULL || ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == UTIME_NOW) { /* GetSystemTimeAsFileTime - . + . It would be overkill to use GetSystemTimePreciseAsFileTime - . */ + . */ GetSystemTimeAsFileTime (¤t_time); } diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4 index 04905519d0..b2b3b03731 100644 --- a/m4/fdopendir.m4 +++ b/m4/fdopendir.m4 @@ -1,4 +1,4 @@ -# serial 10 +# serial 11 # See if we need to provide fdopendir. dnl Copyright (C) 2009-2019 Free Software Foundation, Inc. @@ -45,10 +45,12 @@ DIR *fdopendir (int); [gl_cv_func_fdopendir_works=yes], [gl_cv_func_fdopendir_works=no], [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_fdopendir_works="guessing no" ;; + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_fdopendir_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_fdopendir_works="guessing no" ;; esac ])]) case "$gl_cv_func_fdopendir_works" in diff --git a/m4/getgroups.m4 b/m4/getgroups.m4 index 2ce986ea79..c93447bb11 100644 --- a/m4/getgroups.m4 +++ b/m4/getgroups.m4 @@ -1,4 +1,4 @@ -# serial 21 +# serial 22 dnl From Jim Meyering. dnl A wrapper around AC_FUNC_GETGROUPS. @@ -42,6 +42,8 @@ AC_DEFUN([AC_FUNC_GETGROUPS], [case "$host_os" in # (( # Guess yes on glibc systems. *-gnu* | gnu*) ac_cv_func_getgroups_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) ac_cv_func_getgroups_works="guessing yes" ;; # If we don't know, assume the worst. *) ac_cv_func_getgroups_works="guessing no" ;; esac @@ -95,6 +97,8 @@ AC_DEFUN([gl_FUNC_GETGROUPS], [case "$host_os" in # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_getgroups_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_getgroups_works="guessing yes" ;; # If we don't know, assume the worst. *) gl_cv_func_getgroups_works="guessing no" ;; esac diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index d29b4bff2f..5e2ef6f47e 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -1,4 +1,4 @@ -# serial 25 +# serial 26 # Copyright (C) 2001-2003, 2005, 2007, 2009-2019 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -105,6 +105,8 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], case "$host_os" in # Guess all is fine on glibc systems. *-gnu* | gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; + # Guess all is fine on musl systems. + *-musl*) gl_cv_func_gettimeofday_clobber="guessing no" ;; # Guess no on native Windows. mingw*) gl_cv_func_gettimeofday_clobber="guessing no" ;; # If we don't know, assume the worst. diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 7c0e3e8fa4..57b94ed532 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 41 +# gnulib-common.m4 serial 44 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,10 +17,13 @@ AC_DEFUN([gl_COMMON_BODY], [ AH_VERBATIM([_Noreturn], [/* The _Noreturn keyword of C11. */ #ifndef _Noreturn -# if 201103 <= (defined __cplusplus ? __cplusplus : 0) +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) # define _Noreturn [[noreturn]] -# elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)) +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) /* _Noreturn works as-is. */ # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__)) @@ -84,6 +87,33 @@ AC_DEFUN([gl_COMMON_BODY], [ #else # define _GL_ATTRIBUTE_MALLOC /* empty */ #endif +]) + AH_VERBATIM([async_safe], +[/* The _GL_ASYNC_SAFE marker should be attached to functions that are + signal handlers (for signals other than SIGABRT, SIGPIPE) or can be + invoked from such signal handlers. Such functions have some restrictions: + * All functions that it calls should be marked _GL_ASYNC_SAFE as well, + or should be listed as async-signal-safe in POSIX + + section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in + particular, are NOT async-signal-safe. + * All memory locations (variables and struct fields) that these functions + access must be marked 'volatile'. This holds for both read and write + accesses. Otherwise the compiler might optimize away stores to and + reads from such locations that occur in the program, depending on its + data flow analysis. For example, when the program contains a loop + that is intended to inspect a variable set from within a signal handler + while (!signal_occurred) + ; + the compiler is allowed to transform this into an endless loop if the + variable 'signal_occurred' is not declared 'volatile'. + Additionally, recall that: + * A signal handler should not modify errno (except if it is a handler + for a fatal signal and ends by raising the same signal again, thus + provoking the termination of the process). If it invokes a function + that may clobber errno, it needs to save and restore the value of + errno. */ +#define _GL_ASYNC_SAFE ]) dnl Preparation for running test programs: dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not diff --git a/m4/putenv.m4 b/m4/putenv.m4 index f8960f66be..342ba2636a 100644 --- a/m4/putenv.m4 +++ b/m4/putenv.m4 @@ -1,4 +1,4 @@ -# putenv.m4 serial 22 +# putenv.m4 serial 23 dnl Copyright (C) 2002-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -36,6 +36,8 @@ AC_DEFUN([gl_FUNC_PUTENV], [case "$host_os" in # Guess yes on glibc systems. *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_svid_putenv="guessing yes" ;; # Guess no on native Windows. mingw*) gl_cv_func_svid_putenv="guessing no" ;; # If we don't know, assume the worst. diff --git a/m4/utimes.m4 b/m4/utimes.m4 index 7209b6dd59..5806d8fbbb 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,5 +1,5 @@ # Detect some bugs in glibc's implementation of utimes. -# serial 5 +# serial 6 dnl Copyright (C) 2003-2005, 2009-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -143,9 +143,11 @@ main () [gl_cv_func_working_utimes=yes], [gl_cv_func_working_utimes=no], [case "$host_os" in - # Guess no on native Windows. - mingw*) gl_cv_func_working_utimes="guessing no" ;; - *) gl_cv_func_working_utimes="guessing no" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_working_utimes="guessing yes" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_working_utimes="guessing no" ;; + *) gl_cv_func_working_utimes="guessing no" ;; esac ]) ]) commit d43af7b64bd22724e5e9a624bcc06b4ed28faf73 Author: Juri Linkov Date: Mon Mar 25 23:45:31 2019 +0200 * lisp/vc/vc.el (vc-diff-mergebase, vc-log-mergebase): New commands. * lisp/vc/vc-git.el (vc-git-mergebase): New function. (vc-git-print-log): Interpret string value of arg LIMIT as an end-revision. * lisp/vc/vc-hooks.el (vc-prefix-map): Bind 'vc-log-mergebase' to 'C-x v M L', and 'vc-diff-mergebase' to 'C-x v M D'. (Bug#33950) diff --git a/etc/NEWS b/etc/NEWS index ad01bd8516..afee1e1dca 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -511,6 +511,10 @@ and compares their entire trees. *** New user option 'vc-hg-revert-switches' specifies switches to pass to hg revert. +*** 'C-x v M D' ('vc-diff-mergebase') and 'C-x v M L' ('vc-log-mergebase') +print diffs and logs between the merge base (common ancestor) of two +given revisions. + ** Diff mode +++ *** Hunks are now automatically refined by font-lock. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 0f8c9c836c..a921ff1bb8 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -101,6 +101,7 @@ (eval-when-compile (require 'cl-lib) + (require 'subr-x) ; for string-trim-right (require 'vc) (require 'vc-dir)) @@ -1017,7 +1018,8 @@ This prompts for a branch to merge from." If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'. \(This requires at least Git version 1.5.6, for the --graph option.) If START-REVISION is non-nil, it is the newest revision to show. -If LIMIT is non-nil, show no more than this many entries." +If LIMIT is a number, show no more than this many entries. +If LIMIT is a revision string, use it as an end-revision." (let ((coding-system-for-read (or coding-system-for-read vc-git-log-output-coding-system))) ;; `vc-do-command' creates the buffer, but we need it before running @@ -1045,8 +1047,14 @@ If LIMIT is non-nil, show no more than this many entries." ,(format "--pretty=tformat:%s" (car vc-git-root-log-format)) "--abbrev-commit")) - (when limit (list "-n" (format "%s" limit))) - (when start-revision (list start-revision)) + (when (numberp limit) + (list "-n" (format "%s" limit))) + (when start-revision + (if (and limit (not (numberp limit))) + (list (concat start-revision ".." (if (equal limit "") + "HEAD" + limit))) + (list start-revision))) '("--"))))))) (defun vc-git-log-outgoing (buffer remote-location) @@ -1077,6 +1085,10 @@ If LIMIT is non-nil, show no more than this many entries." "@{upstream}" remote-location)))) +(defun vc-git-mergebase (rev1 &optional rev2) + (unless rev2 (setq rev2 "HEAD")) + (string-trim-right (vc-git--run-command-string nil "merge-base" rev1 rev2))) + (defvar log-view-message-re) (defvar log-view-file-re) (defvar log-view-font-lock-keywords) @@ -1093,7 +1105,7 @@ If LIMIT is non-nil, show no more than this many entries." (cadr vc-git-root-log-format) "^commit *\\([0-9a-z]+\\)")) ;; Allow expanding short log entries. - (when (memq vc-log-view-type '(short log-outgoing log-incoming)) + (when (memq vc-log-view-type '(short log-outgoing log-incoming mergebase)) (setq truncate-lines t) (set (make-local-variable 'log-view-expanded-log-entry-function) 'vc-git-expanded-log-entry)) diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 2052ace12b..07b3d86b51 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -890,6 +890,8 @@ In the latter case, VC mode is deactivated for this buffer." (define-key map "L" 'vc-print-root-log) (define-key map "I" 'vc-log-incoming) (define-key map "O" 'vc-log-outgoing) + (define-key map "ML" 'vc-log-mergebase) + (define-key map "MD" 'vc-diff-mergebase) (define-key map "m" 'vc-merge) (define-key map "r" 'vc-retrieve-tag) (define-key map "s" 'vc-create-tag) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 0a638ec7d7..e6f30c9f80 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -429,6 +429,10 @@ ;; - region-history-mode () ;; ;; Major mode to use for the output of `region-history'. +;; +;; - mergebase (rev1 &optional rev2) +;; +;; Return the common ancestor between REV1 and REV2 revisions. ;; TAG SYSTEM ;; @@ -1854,6 +1858,33 @@ saving the buffer." (vc-diff-internal t (vc-deduce-fileset t) nil nil (called-interactively-p 'interactive)))) +;;;###autoload +(defun vc-diff-mergebase (_files rev1 rev2) + "Report diffs between the merge base of REV1 and REV2 revisions. +The merge base is a common ancestor between REV1 and REV2 revisions." + (interactive + (vc-diff-build-argument-list-internal + (or (ignore-errors (vc-deduce-fileset t)) + (let ((backend (or (vc-deduce-backend) (vc-responsible-backend default-directory)))) + (list backend (list (vc-call-backend backend 'root default-directory))))))) + (when (and (not rev1) rev2) + (error "Not a valid revision range")) + (let ((backend (vc-deduce-backend)) + (default-directory default-directory) + rootdir) + (if backend + (setq rootdir (vc-call-backend backend 'root default-directory)) + (setq rootdir (read-directory-name "Directory for VC root-diff: ")) + (setq backend (vc-responsible-backend rootdir)) + (if backend + (setq default-directory rootdir) + (error "Directory is not version controlled"))) + (let ((default-directory rootdir) + (rev1 (vc-call-backend backend 'mergebase rev1 rev2))) + (vc-diff-internal + t (list backend (list rootdir)) rev1 rev2 + (called-interactively-p 'interactive))))) + (declare-function ediff-load-version-control "ediff" (&optional silent)) (declare-function ediff-vc-internal "ediff-vers" (rev1 rev2 &optional startup-hooks)) @@ -2484,6 +2515,28 @@ When called interactively with a prefix argument, prompt for REMOTE-LOCATION." (vc-incoming-outgoing-internal backend (or remote-location "") "*vc-outgoing*" 'log-outgoing))) +;;;###autoload +(defun vc-log-mergebase (_files rev1 rev2) + "Show a log of changes between the merge base of REV1 and REV2 revisions. +The merge base is a common ancestor between REV1 and REV2 revisions." + (interactive + (vc-diff-build-argument-list-internal + (or (ignore-errors (vc-deduce-fileset t)) + (let ((backend (or (vc-deduce-backend) (vc-responsible-backend default-directory)))) + (list backend (list (vc-call-backend backend 'root default-directory))))))) + (let ((backend (vc-deduce-backend)) + (default-directory default-directory) + rootdir) + (if backend + (setq rootdir (vc-call-backend backend 'root default-directory)) + (setq rootdir (read-directory-name "Directory for VC root-log: ")) + (setq backend (vc-responsible-backend rootdir)) + (unless backend + (error "Directory is not version controlled"))) + (setq default-directory rootdir) + (setq rev1 (vc-call-backend backend 'mergebase rev1 rev2)) + (vc-print-log-internal backend (list rootdir) rev1 t (or rev2 "")))) + ;;;###autoload (defun vc-region-history (from to) "Show the history of the region between FROM and TO. commit db53731c5f7e11240244161623b82b55cf303043 Author: Paul Eggert Date: Mon Mar 25 14:31:31 2019 -0700 Fix alignment bug with pure bignums Problem found on 32-bit sparc, which has stricter alignment checking than x86-64. * src/alloc.c (pure_alloc): When TYPE is negative it now specifies the negation of the required alignment of the result. (make_pure_bignum): Specify bignum limb alignment. diff --git a/src/alloc.c b/src/alloc.c index f929a37271..3a8bd30c34 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5342,7 +5342,8 @@ valid_lisp_object_p (Lisp_Object obj) /* Allocate room for SIZE bytes from pure Lisp storage and return a pointer to it. TYPE is the Lisp type for which the memory is - allocated. TYPE < 0 means it's not used for a Lisp object. */ + allocated. TYPE < 0 means it's not used for a Lisp object, + and that the result should have an alignment of -TYPE. */ static void * pure_alloc (size_t size, int type) @@ -5361,8 +5362,11 @@ pure_alloc (size_t size, int type) { /* Allocate space for a non-Lisp object from the end of the free space. */ - pure_bytes_used_non_lisp += size; - result = purebeg + pure_size - pure_bytes_used_non_lisp; + ptrdiff_t unaligned_non_lisp = pure_bytes_used_non_lisp + size; + char *unaligned = purebeg + pure_size - unaligned_non_lisp; + int decr = (intptr_t) unaligned & (-1 - type); + pure_bytes_used_non_lisp = unaligned_non_lisp + decr; + result = unaligned - decr; } pure_bytes_used = pure_bytes_used_lisp + pure_bytes_used_non_lisp; @@ -5549,7 +5553,8 @@ make_pure_bignum (struct Lisp_Bignum *value) struct Lisp_Bignum *b = pure_alloc (sizeof *b, Lisp_Vectorlike); XSETPVECTYPESIZE (b, PVEC_BIGNUM, 0, VECSIZE (struct Lisp_Bignum)); - pure_limbs = pure_alloc (nbytes, -1); + int limb_alignment = alignof (mp_limb_t); + pure_limbs = pure_alloc (nbytes, - limb_alignment); for (i = 0; i < nlimbs; ++i) pure_limbs[i] = mpz_getlimbn (value->value, i); commit 389475dbcc4fb8ac52367e103306a632ef3fd101 Author: Juri Linkov Date: Mon Mar 25 23:32:09 2019 +0200 * lisp/international/mule-cmds.el (ngettext): Move to editfns.c. * src/editfns.c (Fngettext): Move from mule-cmds.el and use gettext's ngettext when available. diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 035932e395..dfa9e4e6c8 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2430,7 +2430,7 @@ See `set-language-info-alist' for use in programs." ("ind" . "Latin-1") ; MS-Windows Indonesian ("sme" . "UTF-8") ; MS-Windows Northern Sami (Norway) ("smf" . "UTF-8") ; MS-Windows Northern Sami (Sweden) - ("smg" . "ITF-8") ; MS-Windows Northern Sami (Finland) + ("smg" . "UTF-8") ; MS-Windows Northern Sami (Finland) ("kdi" "Kannada" utf-8) ; MS-Windows Kannada ("mar" "Devanagari" utf-8) ; MS-Windows Marathi ("khm" "Khmer" utf-8) ; MS-Windows Khmer @@ -2798,20 +2798,6 @@ See also `locale-charset-language-names', `locale-language-names', 'a4))))))) nil) -;;; i18n (internationalization) - -(defun ngettext (msgid msgid_plural n) - "Return the plural form of the translation of the string. -This function is similar to the `gettext' function as it finds the message -catalogs in the same way. But it takes two extra arguments. The MSGID -parameter must contain the singular form of the string to be converted. -It is also used as the key for the search in the catalog. -The MSGID_PLURAL parameter is the plural form. The parameter N is used -to determine the plural form. If no message catalog is found MSGID is -returned if N is equal to 1, otherwise MSGID_PLURAL." - (if (= n 1) msgid msgid_plural)) - - ;;; Character property (put 'char-code-property-table 'char-table-extra-slots 5) diff --git a/src/editfns.c b/src/editfns.c index ac9b871835..ab48cdb6fd 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -53,6 +53,12 @@ along with GNU Emacs. If not, see . */ #include "window.h" #include "blockinput.h" +#ifdef _LIBC +# include +#else +# include "gettext.h" +#endif + static void update_buffer_properties (ptrdiff_t, ptrdiff_t); static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); @@ -2836,6 +2842,35 @@ usage: (save-restriction &rest BODY) */) return unbind_to (count, val); } +/* i18n (internationalization). */ + +DEFUN ("ngettext", Fngettext, Sngettext, 3, 3, 0, + doc: /* Return the plural form of the translation of the string. +This function is similar to the `gettext' function as it finds the message +catalogs in the same way. But it takes two extra arguments. The MSGID +parameter must contain the singular form of the string to be converted. +It is also used as the key for the search in the catalog. +The MSGID_PLURAL parameter is the plural form. The parameter N is used +to determine the plural form. If no message catalog is found MSGID is +returned if N is equal to 1, otherwise MSGID_PLURAL. */) + (Lisp_Object msgid, Lisp_Object msgid_plural, Lisp_Object n) +{ + CHECK_STRING (msgid); + CHECK_STRING (msgid_plural); + CHECK_FIXNUM (n); + +#ifdef _LIBGETTEXT_H + return build_string (ngettext (SSDATA (msgid), + SSDATA (msgid_plural), + XFIXNUM (n))); +#else + if (XFIXNUM (n) == 1) + return msgid; + else + return msgid_plural; +#endif +} + DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, doc: /* Display a message at the bottom of the screen. The message also goes into the `*Messages*' buffer, if `message-log-max' @@ -4554,6 +4589,8 @@ it to be non-nil. */); defsubr (&Sinsert_char); defsubr (&Sinsert_byte); + defsubr (&Sngettext); + defsubr (&Suser_login_name); defsubr (&Sgroup_name); defsubr (&Suser_real_login_name); commit 1f8a6b56a5c4342b1fc3ec1d62b9418656a6f953 Author: Eric Abrahamsen Date: Mon Mar 25 13:27:07 2019 -0700 Fix text property bug in gnus-group-list-active * lisp/gnus/gnus-group.el (gnus-group-list-active): The property value should be the group name, not the value of gethash. Ie, it should be the key, not the value. diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index f1202e176e..8c2411f4d9 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -4029,7 +4029,7 @@ entail asking the server for the groups." (insert " *: " (gnus-group-decoded-name group) "\n")) - (list 'gnus-group (gethash group gnus-active-hashtb) + (list 'gnus-group group 'gnus-unread t 'gnus-level (inline (gnus-group-level group))))) (goto-char (point-min)))) commit a09306d53ba86b4596219b2be723659f7c0f2669 Author: Eric Abrahamsen Date: Mon Mar 25 13:26:10 2019 -0700 Don't save Gnus' dummy.group to the .newsrc.eld file * lisp/gnus/gnus-start.el (gnus-gnus-to-quick-newsrc-format): Remove the "dummy.group" element. diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 5a78df9fe4..9b1be65067 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -2881,7 +2881,7 @@ SPECIFIC-VARIABLES, or those in `gnus-variable-list'." gnus-variable-list) (mapcar (lambda (g) (nth 1 (gethash g gnus-newsrc-hashtb))) - gnus-group-list)) + (delete "dummy.group" gnus-group-list))) ;; Insert the variables into the file. (while variables commit a8efdd4c62fbf9c275a57f71cc8a3ca845ad3b1f Author: Eric Abrahamsen Date: Mon Mar 25 13:25:12 2019 -0700 Handle multiple possible types for Gnus group names * lisp/gnus/gnus-start.el (gnus-active-to-gnus-format): Numbers, symbols, and strings. diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 82141e0221..5a78df9fe4 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -2145,9 +2145,12 @@ The info element is shared with the same element of (condition-case () (if (and (stringp (progn (setq group (read cur) - group (if (numberp group) - (number-to-string group) - (symbol-name group))))) + group (cond ((numberp group) + (number-to-string group)) + ((symbolp group) + (symbol-name group)) + ((stringp group) + group))))) (numberp (setq max (read cur))) (numberp (setq min (read cur))) (null (progn commit 6d0f7f708a32aeb994a86d68a5d05c399aba319a Author: Paul Eggert Date: Mon Mar 25 11:29:07 2019 -0700 Fix a dns-mode reentrancy bug * lisp/textmodes/dns-mode.el (dns-mode-ipv6-to-nibbles): Don’t assume kill-new does no matching. diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el index b303e1918e..1dbc7bd735 100644 --- a/lisp/textmodes/dns-mode.el +++ b/lisp/textmodes/dns-mode.el @@ -292,9 +292,9 @@ Examples: (skip-syntax-backward " ") (skip-syntax-backward "w_.") (re-search-forward "\\([[:xdigit:]:]+\\)\\(/-?[0-9]\\{2,3\\}\\)?") - (kill-new (match-string 0)) (let ((address (match-string 1)) (prefix-length (match-string 2))) + (kill-new (match-string 0)) (when prefix-length (setq prefix-length (string-to-number (substring prefix-length 1))) (if negate-prefix commit 04a228f46714406d51b52e688c1788d2a89fd8c4 Author: Basil L. Contovounesios Date: Mon Mar 25 17:42:32 2019 +0000 Fix non_local_exit_get signature in Elisp manual * doc/lispref/internals.texi (Module Nonlocal): Fix typo in return type of non_local_exit_get. diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 56465126f4..8ebe47d9ad 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -1708,7 +1708,7 @@ The last @acronym{API} function exited via @code{throw}. @end vtable @end deftypefn -@deftypefn Function emacs_funcall_exit non_local_exit_get (emacs_env *@var{env}, emacs_value *@var{symbol}, emacs_value *@var{data}) +@deftypefn Function enum emacs_funcall_exit non_local_exit_get (emacs_env *@var{env}, emacs_value *@var{symbol}, emacs_value *@var{data}) This function returns the kind of nonlocal exit condition stored in @var{env}, like @code{non_local_exit_check} does, but it also returns the full information about the nonlocal exit, if any. If the return commit ace29fcb3715531f3598c1aadde1564a7772990c Author: Michael Albinus Date: Mon Mar 25 18:53:07 2019 +0100 Explain messages with patches in CONTRIBUTE * CONTRIBUTE: A message shall contain the string "[PATCH]" in the subject if there's a patch in the message. diff --git a/CONTRIBUTE b/CONTRIBUTE index efd4bf10ec..e8bb95df45 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -59,7 +59,10 @@ such patch without additional remarks, you can use a command like The Emacs issue tracker at https://debbugs.gnu.org lets you view bug reports and search the database for bugs matching several criteria. Messages posted to the bug-gnu-emacs@gnu.org mailing list, mentioned -above, are recorded by the tracker with the corresponding bugs/issues. +above, are recorded by the tracker with the corresponding +bugs/issues. If a message to the bug tracker contains a patch, please +include the string "[PATCH]" in the subject of the message in order to +let the bug tracker tag the bug properly. GNU ELPA has a 'debbugs' package that allows accessing the tracker database from Emacs. commit 97a793cba9fc68a9df67622d8d82c443fe10dd9b Author: Paul Eggert Date: Mon Mar 25 10:46:04 2019 -0700 Support ./configure --with-gif=ifavailable etc. Suggested by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-03/msg00789.html * INSTALL, etc/NEWS: Document this. * configure.ac: Implement this. diff --git a/INSTALL b/INSTALL index 72bba25df8..8022385010 100644 --- a/INSTALL +++ b/INSTALL @@ -318,6 +318,12 @@ features enabled, you can combine --without-all with --with-FEATURE. For example, you can use --without-all --without-x --with-dbus to build with D-Bus support and nothing more. +Use --with-gnutls=ifavailable to use GnuTLS if available but go ahead +and build without it if not available. This overrides Emacs's default +behavior of refusing to build if GnuTLS is absent. When X11 support +is enabled, the libraries for gif, jpeg, png, tiff, and xpm are in the +same strongly-recommended category as GnuTLS, and have similar options. + Use --with-wide-int to implement Emacs values with the type 'long long', even on hosts where a narrower type would do. With this option, on a typical 32-bit host, Emacs integers have 62 bits instead of 30. diff --git a/configure.ac b/configure.ac index 110ea2909a..c93cfbbb59 100644 --- a/configure.ac +++ b/configure.ac @@ -2941,7 +2941,7 @@ fi AC_SUBST(LIBSELINUX_LIBS) HAVE_GNUTLS=no -if test "${with_gnutls}" = "yes" ; then +if test "${with_gnutls}" != "no" ; then EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2], [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no]) if test "${HAVE_GNUTLS}" = "yes"; then @@ -3512,7 +3512,10 @@ fi if test "${HAVE_X11}" = "yes"; then dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598. - test "$opsys$with_xpm_set" = aix4-2 && with_xpm=no + case $opsys,$with_xpm_set,$with_xpm in + aix4-2,set,yes) ;; + aix4-2,*) with_xpm=no;; + esac if test "${with_xpm}" != "no"; then AC_CHECK_HEADER(X11/xpm.h, @@ -3830,28 +3833,46 @@ AC_SUBST(LIBGIF) dnl Check for required libraries. MISSING= -WITH_NO= +WITH_IFAVAILABLE= if test "${HAVE_X11}" = "yes"; then - test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" && - MISSING="libXpm" && WITH_NO="--with-xpm=no" - test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" && - MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no" - test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" && - MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no" - test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" && - MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no" - test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" && - MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no" -fi -test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" && - MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no" + case $with_xpm,$HAVE_XPM in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="libXpm" + WITH_IFAVAILABLE="--with-xpm=ifavailable";; + esac + case $with_jpeg,$HAVE_JPEG in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING libjpeg" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-jpeg=ifavailable";; + esac + case $with_png,$HAVE_PNG in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING libpng" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-png=ifavailable";; + esac + case $with_gif,$HAVE_GIF in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING libgif/libungif" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gif=ifavailable";; + esac + case $with_tiff,$HAVE_TIFF in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING libtiff" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-tiff=ifavailable";; + esac +fi +case $with_gnutls,$HAVE_GNUTLS in + no,* | ifavailable,* | *,yes) ;; + *) MISSING="$MISSING gnutls" + WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gnutls=ifavailable";; +esac if test "X${MISSING}" != X; then AC_MSG_ERROR([The following required libraries were not found: $MISSING Maybe some development libraries/packages are missing? -If you don't want to link with them give - $WITH_NO -as options to configure]) +To build anyway, give: + $WITH_IFAVAILABLE +as options to configure.]) fi ### Use -lgpm if available, unless '--with-gpm=no'. diff --git a/etc/NEWS b/etc/NEWS index bbba59c549..ad01bd8516 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -37,6 +37,12 @@ functions 'json-serialize', 'json-insert', 'json-parse-string', and 'json-parse-buffer' are typically much faster than their Lisp counterparts from json.el. +** Several configure options now accept an option-argument 'ifavailable'. +For example, './configure --with-xpm=ifavailable' now configures Emacs +to attempt to use libxpm but to continue building even if libxpm is absent. +The other affected options are --with-gif, --with-gnutls, --with-jpeg, +--with-png, and --with-tiff. + ** The etags program now uses the C library's regular expression matcher when possible, and a compatible regex substitute otherwise. This will let developers maintain Emacs's own regex code without having to also commit 491885030c29f46d688c9b0325f95feccd8d653e Author: Stefan Monnier Date: Mon Mar 25 13:20:17 2019 -0400 * lisp/vc/diff-mode.el: Better handle empty lines in context diffs (diff-end-of-hunk): Obey diff-valid-unified-empty-line for context style. (diff--refine-hunk): Don't look further than the end. diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 40204404e7..b67caab7f5 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -533,7 +533,8 @@ See https://lists.gnu.org/r/emacs-devel/2007-11/msg01990.html") "^[^-+# \\\n]\\|" "^[^-+# \\]\\|") ;; A `unified' header is ambiguous. diff-file-header-re)) - ('context "^[^-+#! \\]") + ('context (if diff-valid-unified-empty-line + "^[^-+#! \n\\]" "^[^-+#! \\]")) ('normal "^[^<>#\\]") (_ "^[^-+#!<> \\]")) nil t) @@ -2116,7 +2117,7 @@ Return new point, if it was moved." (smerge-refine-regions beg-del beg-add beg-add end-add nil #'diff-refine-preproc props-r props-a))))) ('context - (let* ((middle (save-excursion (re-search-forward "^---"))) + (let* ((middle (save-excursion (re-search-forward "^---" end))) (other middle)) (while (re-search-forward "^\\(?:!.*\n\\)+" middle t) (smerge-refine-regions (match-beginning 0) (match-end 0) commit b7a98993789d18bc675798d49038982d5cf41683 Author: Paul Eggert Date: Mon Mar 25 08:47:57 2019 -0700 Fix some integer issues in regex-emacs Also, remove some duplicate comments related to thread.h. * src/regex-emacs.h (struct re_registers): * src/regex-emacs.c (SIGN_EXTEND_CHAR): Remove. (TALLOC, RETALLOC): Remove. All uses replaced by usual allocators, which check for integer overflow. (extract_number): Redo without using ‘unsigned’. (CHARSET_RANGE_TABLE_EXISTS_P): Clearly return a boolean. (print_fastmap, print_partial_compiled_pattern, CHECK_INFINITE_LOOP) (regex_compile, analyze_first, bcmp_translate, mutually_exclusive_p) (re_match_2_internal): Use bool for booleans. (print_fastmap, regex_compile, execute_charset): Prefer int to unsigned where either will do. (print_double_string): Prefer ptrdiff_t to ssize_t, since the latter can in theory be narrower than the former. Use fwrite instead of repeated putchar. (emacs_re_max_failures, fail_stack_type, compile_stack_type) (re_wctype_parse, regex_compile, re_search, re_search_2) (re_match_2, re_match_2_internal, re_compile_pattern): Prefer ptrdiff_t to size_t where either will do. (union fail_stack_elt, PUSH_FAILURE_REG, POP_FAILURE_REG_OR_COUNT): Make the integer an intptr_t, not long. (GET_BUFFER_SPACE, EXTEND_BUFFER, regex_compile): Use xpalloc to simplify allocation. (regex_compile): Check for integer overflow when calculating register numbers. * src/regex-emacs.c (re_set_registers, re_match_2_internal): * src/regex-emacs.h (struct re_registers, struct re_pattern_buffer): * src/search.c (Freplace_match): Prefer ptrdiff_t to unsigned where either will do. * src/regex-emacs.h (struct re_pattern_buffer): Prefer bool_bf to unsigned where either will do. diff --git a/src/eval.c b/src/eval.c index 09e8fdf4c2..49d6460e6e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -40,10 +40,6 @@ along with GNU Emacs. If not, see . */ # define CACHEABLE /* empty */ #endif -/* Chain of condition and catch handlers currently in effect. */ - -/* struct handler *handlerlist; */ - /* Non-nil means record all fset's and provide's, to be undone if the file being autoloaded is not fully loaded. They are recorded by being consed onto the front of Vautoload_queue: @@ -248,8 +244,6 @@ init_eval_once_for_pdumper (void) specpdl = specpdl_ptr = pdlvec + 1; } -/* static struct handler handlerlist_sentinel; */ - void init_eval (void) { diff --git a/src/lisp.h b/src/lisp.h index 2508e2b804..178eebed2a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3233,11 +3233,6 @@ union specbinding } bt; }; -/* These 3 are defined as macros in thread.h. */ -/* extern union specbinding *specpdl; */ -/* extern union specbinding *specpdl_ptr; */ -/* extern ptrdiff_t specpdl_size; */ - INLINE ptrdiff_t SPECPDL_INDEX (void) { diff --git a/src/regex-emacs.c b/src/regex-emacs.c index e7849157c8..7629492bcf 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -151,8 +151,6 @@ #define ISWORD(c) (SYNTAX (c) == Sword) -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) - /* Use alloca instead of malloc. This is because using malloc in re_search* or re_match* could cause memory leaks when C-g is used in Emacs (note that SAFE_ALLOCA could also call malloc, but does so @@ -182,10 +180,6 @@ ptrdiff_t emacs_re_safe_alloca = MAX_ALLOCA; #define FIRST_STRING_P(ptr) \ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) -/* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t))) -#define RETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof (t))) - #define BYTEWIDTH 8 /* In bits. */ /* Type of source-pattern and string chars. */ @@ -193,8 +187,8 @@ typedef const unsigned char re_char; static void re_compile_fastmap (struct re_pattern_buffer *); static ptrdiff_t re_match_2_internal (struct re_pattern_buffer *bufp, - re_char *string1, size_t size1, - re_char *string2, size_t size2, + re_char *string1, ptrdiff_t size1, + re_char *string2, ptrdiff_t size2, ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop); @@ -368,8 +362,8 @@ typedef enum static int extract_number (re_char *source) { - unsigned leading_byte = SIGN_EXTEND_CHAR (source[1]); - return (leading_byte << 8) + source[0]; + signed char leading_byte = source[1]; + return leading_byte * 256 + source[0]; } /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. @@ -416,7 +410,7 @@ extract_number_and_incr (re_char **source) #define CHARSET_BITMAP_SIZE(p) ((p)[1] & 0x7F) /* Nonzero if charset P has range table. */ -#define CHARSET_RANGE_TABLE_EXISTS_P(p) ((p)[1] & 0x80) +#define CHARSET_RANGE_TABLE_EXISTS_P(p) (((p)[1] & 0x80) != 0) /* Return the address of range table of charset P. But not the start of table itself, but the before where the number of ranges is @@ -460,18 +454,18 @@ static int regex_emacs_debug = -100000; static void print_fastmap (char *fastmap) { - unsigned was_a_range = 0; - unsigned i = 0; + bool was_a_range = false; + int i = 0; while (i < (1 << BYTEWIDTH)) { if (fastmap[i++]) { - was_a_range = 0; + was_a_range = false; putchar (i - 1); while (i < (1 << BYTEWIDTH) && fastmap[i]) { - was_a_range = 1; + was_a_range = true; i++; } if (was_a_range) @@ -545,10 +539,10 @@ print_partial_compiled_pattern (re_char *start, re_char *end) case charset: case charset_not: { - register int c, last = -100; - register int in_range = 0; + int c, last = -100; + bool in_range = false; int length = CHARSET_BITMAP_SIZE (p - 1); - int has_range_table = CHARSET_RANGE_TABLE_EXISTS_P (p - 1); + bool has_range_table = CHARSET_RANGE_TABLE_EXISTS_P (p - 1); fprintf (stderr, "/charset [%s", (re_opcode_t) *(p - 1) == charset_not ? "^" : ""); @@ -564,13 +558,13 @@ print_partial_compiled_pattern (re_char *start, re_char *end) if (last + 1 == c && ! in_range) { fprintf (stderr, "-"); - in_range = 1; + in_range = true; } /* Have we broken a range? */ else if (last + 1 != c && in_range) { fprintf (stderr, "%c", last); - in_range = 0; + in_range = false; } if (! in_range) @@ -739,7 +733,7 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) re_char *buffer = bufp->buffer; print_partial_compiled_pattern (buffer, buffer + bufp->used); - printf ("%zu bytes used/%zu bytes allocated.\n", + printf ("%tu bytes used/%tu bytes allocated.\n", bufp->used, bufp->allocated); if (bufp->fastmap_accurate && bufp->fastmap) @@ -748,7 +742,7 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) print_fastmap (bufp->fastmap); } - printf ("re_nsub: %zu\t", bufp->re_nsub); + printf ("re_nsub: %tu\t", bufp->re_nsub); printf ("regs_alloc: %d\t", bufp->regs_allocated); printf ("can_be_null: %d\t", bufp->can_be_null); fflush (stdout); @@ -757,25 +751,20 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) static void -print_double_string (re_char *where, re_char *string1, ssize_t size1, - re_char *string2, ssize_t size2) +print_double_string (re_char *where, re_char *string1, ptrdiff_t size1, + re_char *string2, ptrdiff_t size2) { - ssize_t this_char; - if (where == NULL) printf ("(null)"); else { if (FIRST_STRING_P (where)) { - for (this_char = where - string1; this_char < size1; this_char++) - putchar (string1[this_char]); - + fwrite_unlocked (where, 1, string1 + size1 - where, stdout); where = string2; } - for (this_char = where - string2; this_char < size2; this_char++) - putchar (string2[this_char]); + fwrite_unlocked (where, 1, string2 + size2 - where, stdout); } } @@ -872,13 +861,12 @@ enum { RE_NREGS = 30 }; whose default stack limit is 2mb. In order for a larger value to work reliably, you have to try to make it accord with the process stack limit. */ -size_t emacs_re_max_failures = 40000; +ptrdiff_t emacs_re_max_failures = 40000; union fail_stack_elt { re_char *pointer; - /* This should be the biggest 'int' that's no bigger than a pointer. */ - long integer; + intptr_t integer; }; typedef union fail_stack_elt fail_stack_elt_t; @@ -886,9 +874,9 @@ typedef union fail_stack_elt fail_stack_elt_t; typedef struct { fail_stack_elt_t *stack; - size_t size; - size_t avail; /* Offset of next open position. */ - size_t frame; /* Offset of the cur constructed frame. */ + ptrdiff_t size; + ptrdiff_t avail; /* Offset of next open position. */ + ptrdiff_t frame; /* Offset of the cur constructed frame. */ } fail_stack_type; #define FAIL_STACK_EMPTY() (fail_stack.frame == 0) @@ -967,17 +955,17 @@ typedef struct while (REMAINING_AVAIL_SLOTS <= space) { \ if (!GROW_FAIL_STACK (fail_stack)) \ return -2; \ - DEBUG_PRINT ("\n Doubled stack; size now: %zu\n", (fail_stack).size);\ - DEBUG_PRINT (" slots available: %zu\n", REMAINING_AVAIL_SLOTS);\ + DEBUG_PRINT ("\n Doubled stack; size now: %tu\n", fail_stack.size); \ + DEBUG_PRINT (" slots available: %tu\n", REMAINING_AVAIL_SLOTS);\ } /* Push register NUM onto the stack. */ #define PUSH_FAILURE_REG(num) \ do { \ char *destination; \ - long n = num; \ + intptr_t n = num; \ ENSURE_FAIL_STACK(3); \ - DEBUG_PRINT (" Push reg %ld (spanning %p -> %p)\n", \ + DEBUG_PRINT (" Push reg %"PRIdPTR" (spanning %p -> %p)\n", \ n, regstart[n], regend[n]); \ PUSH_FAILURE_POINTER (regstart[n]); \ PUSH_FAILURE_POINTER (regend[n]); \ @@ -1002,7 +990,7 @@ do { \ /* Pop a saved register off the stack. */ #define POP_FAILURE_REG_OR_COUNT() \ do { \ - long pfreg = POP_FAILURE_INT (); \ + intptr_t pfreg = POP_FAILURE_INT (); \ if (pfreg == -1) \ { \ /* It's a counter. */ \ @@ -1010,7 +998,7 @@ do { \ unsigned char *ptr = (unsigned char *) POP_FAILURE_POINTER (); \ pfreg = POP_FAILURE_INT (); \ STORE_NUMBER (ptr, pfreg); \ - DEBUG_PRINT (" Pop counter %p = %ld\n", ptr, pfreg); \ + DEBUG_PRINT (" Pop counter %p = %"PRIdPTR"\n", ptr, pfreg); \ } \ else \ { \ @@ -1034,7 +1022,7 @@ do { \ && FAILURE_PAT (failure) <= bufp->buffer + bufp->used); \ if (FAILURE_PAT (failure) == pat_cur) \ { \ - cycle = 1; \ + cycle = true; \ break; \ } \ DEBUG_PRINT (" Other pattern: %p\n", FAILURE_PAT (failure)); \ @@ -1057,14 +1045,14 @@ do { \ char *destination; \ DEBUG_STATEMENT (nfailure_points_pushed++); \ DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n"); \ - DEBUG_PRINT (" Before push, next avail: %zu\n", (fail_stack).avail); \ - DEBUG_PRINT (" size: %zu\n", (fail_stack).size);\ + DEBUG_PRINT (" Before push, next avail: %tu\n", fail_stack.avail); \ + DEBUG_PRINT (" size: %tu\n", fail_stack.size); \ \ ENSURE_FAIL_STACK (NUM_NONREG_ITEMS); \ \ DEBUG_PRINT ("\n"); \ \ - DEBUG_PRINT (" Push frame index: %zu\n", fail_stack.frame); \ + DEBUG_PRINT (" Push frame index: %tu\n", fail_stack.frame); \ PUSH_FAILURE_INT (fail_stack.frame); \ \ DEBUG_PRINT (" Push string %p: \"", string_place); \ @@ -1106,8 +1094,8 @@ do { \ \ /* Remove failure points and point to how many regs pushed. */ \ DEBUG_PRINT ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT (" Before pop, next avail: %zu\n", fail_stack.avail); \ - DEBUG_PRINT (" size: %zu\n", fail_stack.size); \ + DEBUG_PRINT (" Before pop, next avail: %tu\n", fail_stack.avail); \ + DEBUG_PRINT (" size: %tu\n", fail_stack.size); \ \ /* Pop the saved registers. */ \ while (fail_stack.frame < fail_stack.avail) \ @@ -1141,7 +1129,7 @@ do { \ /* Subroutine declarations and macros for regex_compile. */ -static reg_errcode_t regex_compile (re_char *pattern, size_t size, +static reg_errcode_t regex_compile (re_char *pattern, ptrdiff_t size, bool posix_backtracking, const char *whitespace_regexp, struct re_pattern_buffer *bufp); @@ -1155,7 +1143,7 @@ static bool at_begline_loc_p (re_char *pattern, re_char *p); static bool at_endline_loc_p (re_char *p, re_char *pend); static re_char *skip_one_char (re_char *p); static int analyze_first (re_char *p, re_char *pend, - char *fastmap, const int multibyte); + char *fastmap, bool multibyte); /* Fetch the next character in the uncompiled pattern, with no translation. */ @@ -1178,8 +1166,8 @@ static int analyze_first (re_char *p, re_char *pend, /* Ensure at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ - while ((size_t) (b - bufp->buffer + (n)) > bufp->allocated) \ - EXTEND_BUFFER () + if (bufp->buffer + bufp->allocated - b < (n)) \ + EXTEND_BUFFER ((n) - (bufp->buffer + bufp->allocated - b)) /* Ensure one more byte of buffer space and then add C to it. */ #define BUF_PUSH(c) \ @@ -1221,18 +1209,16 @@ static int analyze_first (re_char *p, re_char *pend, be too small, many things would have to change. */ # define MAX_BUF_SIZE (1 << 15) -/* Extend the buffer by twice its current size via realloc and +/* Extend the buffer by at least N bytes via realloc and reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it being larger than MAX_BUF_SIZE, then flag memory exhausted. */ -#define EXTEND_BUFFER() \ +#define EXTEND_BUFFER(n) \ do { \ + ptrdiff_t requested_extension = n; \ unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ + if (MAX_BUF_SIZE - bufp->allocated < requested_extension) \ return REG_ESIZE; \ - bufp->allocated <<= 1; \ - if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ ptrdiff_t b_off = b - old_buffer; \ ptrdiff_t begalt_off = begalt - old_buffer; \ bool fixup_alt_jump_set = !!fixup_alt_jump; \ @@ -1242,7 +1228,8 @@ static int analyze_first (re_char *p, re_char *pend, if (fixup_alt_jump_set) fixup_alt_jump_off = fixup_alt_jump - old_buffer; \ if (laststart_set) laststart_off = laststart - old_buffer; \ if (pending_exact_set) pending_exact_off = pending_exact - old_buffer; \ - RETALLOC (bufp->buffer, bufp->allocated, unsigned char); \ + bufp->buffer = xpalloc (bufp->buffer, &bufp->allocated, \ + requested_extension, MAX_BUF_SIZE, 1); \ unsigned char *new_buffer = bufp->buffer; \ b = new_buffer + b_off; \ begalt = new_buffer + begalt_off; \ @@ -1264,9 +1251,8 @@ typedef int regnum_t; /* Macros for the compile stack. */ -/* Since offsets can go either forwards or backwards, this type needs to - be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ typedef long pattern_offset_t; +verify (LONG_MIN <= -(MAX_BUF_SIZE - 1) && MAX_BUF_SIZE - 1 <= LONG_MAX); typedef struct { @@ -1280,8 +1266,8 @@ typedef struct typedef struct { compile_stack_elt_t *stack; - size_t size; - size_t avail; /* Offset of next open position. */ + ptrdiff_t size; + ptrdiff_t avail; /* Offset of next open position. */ } compile_stack_type; @@ -1499,7 +1485,7 @@ struct range_table_work_area The function can be used on ASCII and multibyte (UTF-8-encoded) strings. */ re_wctype_t -re_wctype_parse (const unsigned char **strp, unsigned limit) +re_wctype_parse (const unsigned char **strp, ptrdiff_t limit) { const char *beg = (const char *)*strp, *it; @@ -1677,13 +1663,13 @@ do { \ 'buffer' is the compiled pattern; 'syntax' is set to SYNTAX; 'used' is set to the length of the compiled pattern; - 'fastmap_accurate' is zero; + 'fastmap_accurate' is false; 're_nsub' is the number of subexpressions in PATTERN; The 'fastmap' field is neither examined nor set. */ static reg_errcode_t -regex_compile (re_char *pattern, size_t size, +regex_compile (re_char *pattern, ptrdiff_t size, bool posix_backtracking, const char *whitespace_regexp, struct re_pattern_buffer *bufp) @@ -1747,16 +1733,15 @@ regex_compile (re_char *pattern, size_t size, DEBUG_PRINT ("\nCompiling pattern: "); if (regex_emacs_debug > 0) { - size_t debug_count; - - for (debug_count = 0; debug_count < size; debug_count++) + for (ptrdiff_t debug_count = 0; debug_count < size; debug_count++) putchar (pattern[debug_count]); putchar ('\n'); } #endif /* Initialize the compile stack. */ - compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); + compile_stack.stack = xmalloc (INIT_COMPILE_STACK_SIZE + * sizeof *compile_stack.stack); compile_stack.size = INIT_COMPILE_STACK_SIZE; compile_stack.avail = 0; @@ -1764,8 +1749,8 @@ regex_compile (re_char *pattern, size_t size, range_table_work.allocated = 0; /* Initialize the pattern buffer. */ - bufp->fastmap_accurate = 0; - bufp->used_syntax = 0; + bufp->fastmap_accurate = false; + bufp->used_syntax = false; /* Set 'used' to zero, so that if we return an error, the pattern printer (for debugging) will think there's no pattern. We reset it @@ -1776,16 +1761,9 @@ regex_compile (re_char *pattern, size_t size, if (bufp->allocated == 0) { - if (bufp->buffer) - { /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ - RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); - } - else - { /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); - } + /* This loses if BUFP->buffer is bogus, but that is the user's + responsibility. */ + bufp->buffer = xrealloc (bufp->buffer, INIT_BUF_SIZE); bufp->allocated = INIT_BUF_SIZE; } @@ -1905,10 +1883,10 @@ regex_compile (re_char *pattern, size_t size, if (many_times_ok) { bool simple = skip_one_char (laststart) == b; - size_t startoffset = 0; + ptrdiff_t startoffset = 0; re_opcode_t ofj = /* Check if the loop can match the empty string. */ - (simple || !analyze_first (laststart, b, NULL, 0)) + (simple || !analyze_first (laststart, b, NULL, false)) ? on_failure_jump : on_failure_jump_loop; eassert (skip_one_char (laststart) <= b); @@ -1955,7 +1933,7 @@ regex_compile (re_char *pattern, size_t size, GET_BUFFER_SPACE (7); /* We might use less. */ if (many_times_ok) { - bool emptyp = analyze_first (laststart, b, NULL, 0); + bool emptyp = !!analyze_first (laststart, b, NULL, false); /* The non-greedy multiple match looks like a repeat..until: we only need a conditional jump @@ -2073,7 +2051,7 @@ regex_compile (re_char *pattern, size_t size, content of the syntax-table is not hardcoded in the range_table. SPACE and WORD are the two exceptions. */ if ((1 << cc) & ((1 << RECC_SPACE) | (1 << RECC_WORD))) - bufp->used_syntax = 1; + bufp->used_syntax = true; /* Repeat the loop. */ continue; @@ -2180,7 +2158,7 @@ regex_compile (re_char *pattern, size_t size, { case '(': { - int shy = 0; + bool shy = false; regnum_t regnum = 0; if (p+1 < pend) { @@ -2193,7 +2171,7 @@ regex_compile (re_char *pattern, size_t size, PATFETCH (c); switch (c) { - case ':': shy = 1; break; + case ':': shy = true; break; case '0': /* An explicitly specified regnum must start with non-0. */ @@ -2202,7 +2180,11 @@ regex_compile (re_char *pattern, size_t size, FALLTHROUGH; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - regnum = 10*regnum + (c - '0'); break; + if (INT_MULTIPLY_WRAPV (regnum, 10, ®num) + || INT_ADD_WRAPV (regnum, c - '0', + ®num)) + FREE_STACK_RETURN (REG_ESIZE); + break; default: /* Only (?:...) is supported right now. */ FREE_STACK_RETURN (REG_BADPAT); @@ -2215,7 +2197,7 @@ regex_compile (re_char *pattern, size_t size, regnum = ++bufp->re_nsub; else if (regnum) { /* It's actually not shy, but explicitly numbered. */ - shy = 0; + shy = false; if (regnum > bufp->re_nsub) bufp->re_nsub = regnum; else if (regnum > bufp->re_nsub @@ -2232,11 +2214,9 @@ regex_compile (re_char *pattern, size_t size, regnum = - bufp->re_nsub; if (COMPILE_STACK_FULL) - { - RETALLOC (compile_stack.stack, compile_stack.size << 1, - compile_stack_elt_t); - compile_stack.size <<= 1; - } + compile_stack.stack + = xpalloc (compile_stack.stack, &compile_stack.size, + 1, -1, sizeof *compile_stack.stack); /* These are the values to restore when we hit end of this group. They are all relative offsets, so that if the @@ -2393,9 +2373,8 @@ regex_compile (re_char *pattern, size_t size, else { /* If the upper bound is > 1, we need to insert more at the end of the loop. */ - unsigned int nbytes = (upper_bound < 0 ? 3 - : upper_bound > 1 ? 5 : 0); - unsigned int startoffset = 0; + int nbytes = upper_bound < 0 ? 3 : upper_bound > 1 ? 5 : 0; + int startoffset = 0; GET_BUFFER_SPACE (20); /* We might use less. */ @@ -2799,8 +2778,7 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) Return -1 if fastmap was not updated accurately. */ static int -analyze_first (re_char *p, re_char *pend, char *fastmap, - const int multibyte) +analyze_first (re_char *p, re_char *pend, char *fastmap, bool multibyte) { int j, k; bool not; @@ -3102,6 +3080,8 @@ re_compile_fastmap (struct re_pattern_buffer *bufp) eassert (fastmap && bufp->buffer); memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ + + /* FIXME: Is the following assignment correct even when ANALYSIS < 0? */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ analysis = analyze_first (bufp->buffer, bufp->buffer + bufp->used, @@ -3124,7 +3104,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp) void re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, - unsigned int num_regs, ptrdiff_t *starts, ptrdiff_t *ends) + ptrdiff_t num_regs, ptrdiff_t *starts, ptrdiff_t *ends) { if (num_regs) { @@ -3147,7 +3127,7 @@ re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, doesn't let you say where to stop matching. */ ptrdiff_t -re_search (struct re_pattern_buffer *bufp, const char *string, size_t size, +re_search (struct re_pattern_buffer *bufp, const char *string, ptrdiff_t size, ptrdiff_t startpos, ptrdiff_t range, struct re_registers *regs) { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, @@ -3184,8 +3164,8 @@ re_search (struct re_pattern_buffer *bufp, const char *string, size_t size, stack overflow). */ ptrdiff_t -re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, - const char *str2, size_t size2, +re_search_2 (struct re_pattern_buffer *bufp, const char *str1, ptrdiff_t size1, + const char *str2, ptrdiff_t size2, ptrdiff_t startpos, ptrdiff_t range, struct re_registers *regs, ptrdiff_t stop) { @@ -3194,7 +3174,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, re_char *string2 = (re_char *) str2; char *fastmap = bufp->fastmap; Lisp_Object translate = bufp->translate; - size_t total_size = size1 + size2; + ptrdiff_t total_size = size1 + size2; ptrdiff_t endpos = startpos + range; bool anchored_start; /* Nonzero if we are searching multibyte string. */ @@ -3418,10 +3398,8 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, /* Declarations and macros for re_match_2. */ -static int bcmp_translate (re_char *s1, re_char *s2, - ptrdiff_t len, - Lisp_Object translate, - const int multibyte); +static bool bcmp_translate (re_char *, re_char *, ptrdiff_t, + Lisp_Object, bool); /* This converts PTR, a pointer into one of the search strings 'string1' and 'string2' into an offset from the beginning of that string. */ @@ -3565,8 +3543,9 @@ skip_noops (re_char *p, re_char *pend) character (i.e. without any translations). UNIBYTE denotes whether c is unibyte or multibyte character. */ static bool -execute_charset (re_char **pp, unsigned c, unsigned corig, bool unibyte) +execute_charset (re_char **pp, int c, int corig, bool unibyte) { + eassume (0 <= c && 0 <= corig); re_char *p = *pp, *rtp = NULL; bool not = (re_opcode_t) *p == charset_not; @@ -3626,8 +3605,8 @@ execute_charset (re_char **pp, unsigned c, unsigned corig, bool unibyte) return not; } -/* Non-zero if "p1 matches something" implies "p2 fails". */ -static int +/* True if "p1 matches something" implies "p2 fails". */ +static bool mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, re_char *p2) { @@ -3660,7 +3639,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, if (skip_one_char (p1)) { DEBUG_PRINT (" End of pattern: fast loop.\n"); - return 1; + return true; } break; @@ -3676,7 +3655,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, if (c != RE_STRING_CHAR (p1 + 2, multibyte)) { DEBUG_PRINT (" '%c' != '%c' => fast loop.\n", c, p1[2]); - return 1; + return true; } } @@ -3686,14 +3665,14 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, if (!execute_charset (&p1, c, c, !multibyte || ASCII_CHAR_P (c))) { DEBUG_PRINT (" No match => fast loop.\n"); - return 1; + return true; } } else if ((re_opcode_t) *p1 == anychar && c == '\n') { DEBUG_PRINT (" . != \\n => fast loop.\n"); - return 1; + return true; } } break; @@ -3736,7 +3715,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, || idx == CHARSET_BITMAP_SIZE (p1)) { DEBUG_PRINT (" No match => fast loop.\n"); - return 1; + return true; } } else if ((re_opcode_t) *p1 == charset_not) @@ -3753,7 +3732,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, if (idx == p2[1]) { DEBUG_PRINT (" No match => fast loop.\n"); - return 1; + return true; } } } @@ -3807,7 +3786,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, } /* Safe default. */ - return 0; + return false; } @@ -3826,9 +3805,10 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1, matched substring. */ ptrdiff_t -re_match_2 (struct re_pattern_buffer *bufp, const char *string1, - size_t size1, const char *string2, size_t size2, ptrdiff_t pos, - struct re_registers *regs, ptrdiff_t stop) +re_match_2 (struct re_pattern_buffer *bufp, + char const *string1, ptrdiff_t size1, + char const *string2, ptrdiff_t size2, + ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop) { ptrdiff_t result; @@ -3847,13 +3827,13 @@ re_match_2 (struct re_pattern_buffer *bufp, const char *string1, /* This is a separate function so that we can force an alloca cleanup afterwards. */ static ptrdiff_t -re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, - size_t size1, re_char *string2, size_t size2, +re_match_2_internal (struct re_pattern_buffer *bufp, + re_char *string1, ptrdiff_t size1, + re_char *string2, ptrdiff_t size2, ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop) { /* General temporaries. */ int mcnt; - size_t reg; /* Just past the end of the corresponding string. */ re_char *end1, *end2; @@ -3893,13 +3873,14 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, scanning the strings. */ fail_stack_type fail_stack; #ifdef DEBUG_COMPILES_ARGUMENTS - unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; + ptrdiff_t nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes an element for register zero. */ - size_t num_regs = bufp->re_nsub + 1; + ptrdiff_t num_regs = bufp->re_nsub + 1; + eassume (0 < num_regs); /* Information on the contents of registers. These are pointers into the input strings; they record just what was matched (on this @@ -3914,7 +3895,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = false; + bool best_regs_set = false; re_char **best_regstart UNINIT, **best_regend UNINIT; /* Logically, this is 'best_regend[0]'. But we don't want to have to @@ -3929,7 +3910,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, #ifdef DEBUG_COMPILES_ARGUMENTS /* Counts the total number of registers pushed. */ - unsigned num_regs_pushed = 0; + ptrdiff_t num_regs_pushed = 0; #endif DEBUG_PRINT ("\n\nEntering re_match_2.\n"); @@ -3961,7 +3942,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, /* Initialize subexpression text positions to -1 to mark ones that no start_memory/stop_memory has been seen for. Also initialize the register information struct. */ - for (reg = 1; reg < num_regs; reg++) + for (ptrdiff_t reg = 1; reg < num_regs; reg++) regstart[reg] = regend[reg] = NULL; /* We move 'string1' into 'string2' if the latter's empty -- but not if @@ -4068,7 +4049,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, DEBUG_PRINT ("\nSAVING match as best so far.\n"); - for (reg = 1; reg < num_regs; reg++) + for (ptrdiff_t reg = 1; reg < num_regs; reg++) { best_regstart[reg] = regstart[reg]; best_regend[reg] = regend[reg]; @@ -4094,7 +4075,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, dend = ((d >= string1 && d <= end1) ? end_match_1 : end_match_2); - for (reg = 1; reg < num_regs; reg++) + for (ptrdiff_t reg = 1; reg < num_regs; reg++) { regstart[reg] = best_regstart[reg]; regend[reg] = best_regend[reg]; @@ -4113,9 +4094,10 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, { /* No. So allocate them with malloc. We need one extra element beyond 'num_regs' for the '-1' marker GNU code uses. */ - regs->num_regs = max (RE_NREGS, num_regs + 1); - regs->start = TALLOC (regs->num_regs, ptrdiff_t); - regs->end = TALLOC (regs->num_regs, ptrdiff_t); + ptrdiff_t n = max (RE_NREGS, num_regs + 1); + regs->start = xnmalloc (n, sizeof *regs->start); + regs->end = xnmalloc (n, sizeof *regs->end); + regs->num_regs = n; bufp->regs_allocated = REGS_REALLOCATE; } else if (bufp->regs_allocated == REGS_REALLOCATE) @@ -4124,9 +4106,11 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, leave it alone. */ if (regs->num_regs < num_regs + 1) { - regs->num_regs = num_regs + 1; - RETALLOC (regs->start, regs->num_regs, ptrdiff_t); - RETALLOC (regs->end, regs->num_regs, ptrdiff_t); + ptrdiff_t n = num_regs + 1; + regs->start + = xnrealloc (regs->start, n, sizeof *regs->start); + regs->end = xnrealloc (regs->end, n, sizeof *regs->end); + regs->num_regs = n; } } else @@ -4141,9 +4125,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, regs->end[0] = POINTER_TO_OFFSET (d); } - /* Go through the first 'min (num_regs, regs->num_regs)' - registers, since that is all we initialized. */ - for (reg = 1; reg < min (num_regs, regs->num_regs); reg++) + for (ptrdiff_t reg = 1; reg < num_regs; reg++) { if (REG_UNSET (regstart[reg]) || REG_UNSET (regend[reg])) regs->start[reg] = regs->end[reg] = -1; @@ -4159,14 +4141,14 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, we (re)allocated the registers, this is the case, because we always allocate enough to have at least one -1 at the end. */ - for (reg = num_regs; reg < regs->num_regs; reg++) + for (ptrdiff_t reg = num_regs; reg < regs->num_regs; reg++) regs->start[reg] = regs->end[reg] = -1; } - DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n", + DEBUG_PRINT ("%td failure points pushed, %td popped (%td remain).\n", nfailure_points_pushed, nfailure_points_popped, nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT ("%u registers pushed.\n", num_regs_pushed); + DEBUG_PRINT ("%td registers pushed.\n", num_regs_pushed); ptrdiff_t dcnt = POINTER_TO_OFFSET (d) - pos; @@ -4291,9 +4273,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, case charset: case charset_not: { - register unsigned int c, corig; - int len; - /* Whether matching against a unibyte character. */ bool unibyte_char = false; @@ -4301,7 +4280,9 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); PREFETCH (); - corig = c = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte); + int len; + int corig = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte); + int c = corig; if (target_multibyte) { int c1; @@ -4369,7 +4350,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, /* Strictly speaking, there should be code such as: eassert (REG_UNSET (regend[*p])); - PUSH_FAILURE_REGSTOP ((unsigned int)*p); + PUSH_FAILURE_REGSTOP (*p); But the only info to be pushed is regend[*p] and it is known to be UNSET, so there really isn't anything to push. @@ -4548,7 +4529,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, eassert ((re_opcode_t)p[-4] == no_op); { - int cycle = 0; + bool cycle = false; CHECK_INFINITE_LOOP (p - 4, d); if (!cycle) /* If there's a cycle, just continue without pushing @@ -4567,7 +4548,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, DEBUG_PRINT ("EXECUTING on_failure_jump_loop %d (to %p):\n", mcnt, p + mcnt); { - int cycle = 0; + bool cycle = false; CHECK_INFINITE_LOOP (p - 3, d); if (cycle) /* If there's a cycle, get out of the loop, as if the matching @@ -5025,12 +5006,12 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, /* Subroutine definitions for re_match_2. */ -/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN - bytes; nonzero otherwise. */ +/* Return true if TRANSLATE[S1] and TRANSLATE[S2] are not identical + for LEN bytes. */ -static int +static bool bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len, - Lisp_Object translate, int target_multibyte) + Lisp_Object translate, bool target_multibyte) { re_char *p1 = s1, *p2 = s2; re_char *p1_end = s1 + len; @@ -5048,15 +5029,12 @@ bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len, if (RE_TRANSLATE (translate, p1_ch) != RE_TRANSLATE (translate, p2_ch)) - return 1; + return true; p1 += p1_charlen, p2 += p2_charlen; } - if (p1 != p1_end || p2 != p2_end) - return 1; - - return 0; + return p1 != p1_end || p2 != p2_end; } /* Entry points for GNU code. */ @@ -5071,7 +5049,7 @@ bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len, We call regex_compile to do the actual compilation. */ const char * -re_compile_pattern (const char *pattern, size_t length, +re_compile_pattern (const char *pattern, ptrdiff_t length, bool posix_backtracking, const char *whitespace_regexp, struct re_pattern_buffer *bufp) { diff --git a/src/regex-emacs.h b/src/regex-emacs.h index 5a52135bcd..95f743dc2f 100644 --- a/src/regex-emacs.h +++ b/src/regex-emacs.h @@ -26,7 +26,7 @@ uses struct re_registers. */ struct re_registers { - unsigned num_regs; + ptrdiff_t num_regs; ptrdiff_t *start; ptrdiff_t *end; }; @@ -50,7 +50,7 @@ struct re_registers extern Lisp_Object re_match_object; /* Roughly the maximum number of failure points on the stack. */ -extern size_t emacs_re_max_failures; +extern ptrdiff_t emacs_re_max_failures; /* Amount of memory that we can safely stack allocate. */ extern ptrdiff_t emacs_re_safe_alloca; @@ -69,10 +69,10 @@ struct re_pattern_buffer unsigned char *buffer; /* Number of bytes to which 'buffer' points. */ - size_t allocated; + ptrdiff_t allocated; /* Number of bytes actually used in 'buffer'. */ - size_t used; + ptrdiff_t used; /* Charset of unibyte characters at compiling time. */ int charset_unibyte; @@ -89,13 +89,13 @@ struct re_pattern_buffer Lisp_Object translate; /* Number of subexpressions found by the compiler. */ - size_t re_nsub; + ptrdiff_t re_nsub; /* True if and only if this pattern can match the empty string. Well, in truth it's used only in 're_search_2', to see whether or not we should use the fastmap, so we don't set this absolutely perfectly; see 're_compile_fastmap'. */ - unsigned can_be_null : 1; + bool_bf can_be_null : 1; /* If REGS_UNALLOCATED, allocate space in the 'regs' structure for 'max (RE_NREGS, re_nsub + 1)' groups. @@ -105,19 +105,19 @@ struct re_pattern_buffer /* Set to false when 'regex_compile' compiles a pattern; set to true by 're_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; + bool_bf fastmap_accurate : 1; /* If true, the compilation of the pattern had to look up the syntax table, so the compiled pattern is valid for the current syntax table only. */ - unsigned used_syntax : 1; + bool_bf used_syntax : 1; /* If true, multi-byte form in the regexp pattern should be recognized as a multibyte character. */ - unsigned multibyte : 1; + bool_bf multibyte : 1; /* If true, multi-byte form in the target of match should be recognized as a multibyte character. */ - unsigned target_multibyte : 1; + bool_bf target_multibyte : 1; }; /* Declarations for routines. */ @@ -125,7 +125,7 @@ struct re_pattern_buffer /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global 're_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *pattern, size_t length, +extern const char *re_compile_pattern (const char *pattern, ptrdiff_t length, bool posix_backtracking, const char *whitespace_regexp, struct re_pattern_buffer *buffer); @@ -137,7 +137,7 @@ extern const char *re_compile_pattern (const char *pattern, size_t length, match, or -2 for an internal error. Also return register information in REGS (if REGS is non-null). */ extern ptrdiff_t re_search (struct re_pattern_buffer *buffer, - const char *string, size_t length, + const char *string, ptrdiff_t length, ptrdiff_t start, ptrdiff_t range, struct re_registers *regs); @@ -145,8 +145,8 @@ extern ptrdiff_t re_search (struct re_pattern_buffer *buffer, /* Like 're_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern ptrdiff_t re_search_2 (struct re_pattern_buffer *buffer, - const char *string1, size_t length1, - const char *string2, size_t length2, + const char *string1, ptrdiff_t length1, + const char *string2, ptrdiff_t length2, ptrdiff_t start, ptrdiff_t range, struct re_registers *regs, ptrdiff_t stop); @@ -155,8 +155,8 @@ extern ptrdiff_t re_search_2 (struct re_pattern_buffer *buffer, /* Like 're_search_2', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern ptrdiff_t re_match_2 (struct re_pattern_buffer *buffer, - const char *string1, size_t length1, - const char *string2, size_t length2, + const char *string1, ptrdiff_t length1, + const char *string2, ptrdiff_t length2, ptrdiff_t start, struct re_registers *regs, ptrdiff_t stop); @@ -175,7 +175,7 @@ extern ptrdiff_t re_match_2 (struct re_pattern_buffer *buffer, freeing the old data. */ extern void re_set_registers (struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, + ptrdiff_t num_regs, ptrdiff_t *starts, ptrdiff_t *ends); /* Character classes. */ @@ -192,6 +192,6 @@ typedef enum { RECC_ERROR = 0, extern bool re_iswctype (int ch, re_wctype_t cc); extern re_wctype_t re_wctype_parse (const unsigned char **strp, - unsigned limit); + ptrdiff_t limit); #endif /* EMACS_REGEX_H */ diff --git a/src/search.c b/src/search.c index a1e0b0976e..e55aa767f1 100644 --- a/src/search.c +++ b/src/search.c @@ -59,31 +59,6 @@ static struct regexp_cache searchbufs[REGEXP_CACHE_SIZE]; /* The head of the linked list; points to the most recently used buffer. */ static struct regexp_cache *searchbuf_head; - -/* Every call to re_search, etc., must pass &search_regs as the regs - argument unless you can show it is unnecessary (i.e., if re_search - is certainly going to be called again before region-around-match - can be called). - - Since the registers are now dynamically allocated, we need to make - sure not to refer to the Nth register before checking that it has - been allocated by checking search_regs.num_regs. - - The regex code keeps track of whether it has allocated the search - buffer using bits in the re_pattern_buffer. This means that whenever - you compile a new pattern, it completely forgets whether it has - allocated any registers, and will allocate new registers the next - time you call a searching or matching function. Therefore, we need - to call re_set_registers after compiling a new pattern or after - setting the match registers, so that the regex functions will be - able to free or re-allocate it properly. */ -/* static struct re_registers search_regs; */ - -/* The buffer in which the last search was performed, or - Qt if the last search was done in a string; - Qnil if no searching has been done yet. */ -/* static Lisp_Object last_thing_searched; */ - static void set_search_regs (ptrdiff_t, ptrdiff_t); static void save_search_regs (void); static EMACS_INT simple_search (EMACS_INT, unsigned char *, ptrdiff_t, @@ -2763,7 +2738,7 @@ since only regular expressions have distinguished subexpressions. */) error out since otherwise this will result in confusing bugs. */ ptrdiff_t sub_start = search_regs.start[sub]; ptrdiff_t sub_end = search_regs.end[sub]; - unsigned num_regs = search_regs.num_regs; + ptrdiff_t num_regs = search_regs.num_regs; newpoint = search_regs.start[sub] + SCHARS (newtext); /* Replace the old text with the new in the cleanest possible way. */ @@ -3079,12 +3054,6 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) return Qnil; } -/* If true the match data have been saved in saved_search_regs - during the execution of a sentinel or filter. */ -/* static bool search_regs_saved; */ -/* static struct re_registers saved_search_regs; */ -/* static Lisp_Object saved_last_thing_searched; */ - /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data if asynchronous code (filter or sentinel) is running. */ static void diff --git a/src/thread.h b/src/thread.h index cb7e60f21f..1856fddf4c 100644 --- a/src/thread.h +++ b/src/thread.h @@ -111,8 +111,8 @@ struct thread_state struct buffer *m_current_buffer; #define current_buffer (current_thread->m_current_buffer) - /* Every call to re_match_2, etc., must pass &search_regs as the regs - argument unless you can show it is unnecessary (i.e., if re_match_2 + /* Every call to re_search, etc., must pass &search_regs as the regs + argument unless you can show it is unnecessary (i.e., if re_search is certainly going to be called again before region-around-match can be called). commit 176ababa8cf57564cf9374c15ffdc14fa76be39f Author: Paul Eggert Date: Mon Mar 25 08:47:57 2019 -0700 * src/regex-emacs.c (regex_compile): Fix comments. diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 45b4f8107c..e7849157c8 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -1302,9 +1302,7 @@ struct range_table_work_area int bits; /* flag to record character classes */ }; -/* Make sure that WORK_AREA can hold more N multibyte characters. - This is used only in set_image_of_range and set_image_of_range_1. - It expects WORK_AREA to be a pointer. +/* Make sure that WORK_AREA can hold N more multibyte characters. If it can't get the space, it returns from the surrounding function. */ #define EXTEND_RANGE_TABLE(work_area, n) \ @@ -1732,7 +1730,7 @@ regex_compile (re_char *pattern, size_t size, /* Work area for range table of charset. */ struct range_table_work_area range_table_work; - /* If the object matched can contain multibyte characters. */ + /* If the regular expression is multibyte. */ bool multibyte = RE_MULTIBYTE_P (bufp); /* Nonzero if we have pushed down into a subpattern. */ commit 67c3a3af1d9e2582193d5ea33b6c190e79ad56e6 Author: João Távora Date: Mon Mar 25 14:50:20 2019 +0000 Avoid occasional confusion of Flymake C/C++ backend The regexp would sometimes match non-errors and create a diagnostic with nil severity, which would have consequences for the Flymake engine (these should eventually be addressed, too). * lisp/progmodes/flymake-cc.el (flymake-cc--make-diagnostics): Tighten regexp. diff --git a/lisp/progmodes/flymake-cc.el b/lisp/progmodes/flymake-cc.el index 1b449bd079..248c95a256 100644 --- a/lisp/progmodes/flymake-cc.el +++ b/lisp/progmodes/flymake-cc.el @@ -58,7 +58,9 @@ SOURCE." (cl-loop while (search-forward-regexp - "^\\(In file included from \\)?:\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?:\n?\\(.*\\): \\(.*\\)$" + (concat + "^\\(In file included from \\)?:\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)" + "?:[\n ]?\\(error\\|warning\\|note\\): \\(.*\\)$") nil t) for msg = (match-string 5) for (beg . end) = (flymake-diag-region commit 8cac2bf0419274ffe93a4c2704a305e6cd94ff39 Author: João Távora Date: Mon Mar 25 14:38:25 2019 +0000 Make bundled Flymake C backend work for C++, too * lisp/progmodes/flymake-cc.el (flymake-cc-use-special-make-target): Pass -x flag according to major-mode. diff --git a/lisp/progmodes/flymake-cc.el b/lisp/progmodes/flymake-cc.el index 524521d7db..1b449bd079 100644 --- a/lisp/progmodes/flymake-cc.el +++ b/lisp/progmodes/flymake-cc.el @@ -78,7 +78,11 @@ SOURCE." (defun flymake-cc-use-special-make-target () "Command for checking a file via a CHK_SOURCES Make target." (unless (executable-find "make") (error "Make not found")) - '("make" "check-syntax" "CHK_SOURCES=-x c -")) + `("make" + "check-syntax" + ,(format "CHK_SOURCES=-x %s -c -" + (cond ((derived-mode-p 'c++-mode) "c++") + (t "c"))))) (defvar-local flymake-cc--proc nil "Internal variable for `flymake-gcc'")