------------------------------------------------------------ revno: 117734 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2014-08-25 11:00:42 +0400 message: One more minor cleanup of font subsystem. * font.h (struct font_driver): Convert text_extents to return void because returned value is never actually used. * macfont.c (macfont_text_extents): * w32font.c (w32font_text_extents): * xftfont.c (xftfont_text_extents): Adjust to return void and assume that 'metrics' argument is always non-NULL. * ftfont.c (ftfont_text_extents): * xfont.c (xfont_text_extents): Likewise. Avoid redundant memset. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-25 05:44:57 +0000 +++ src/ChangeLog 2014-08-25 07:00:42 +0000 @@ -1,3 +1,15 @@ +2014-08-25 Dmitry Antipov + + One more minor cleanup of font subsystem. + * font.h (struct font_driver): Convert text_extents to + return void because returned value is never actually used. + * macfont.c (macfont_text_extents): + * w32font.c (w32font_text_extents): + * xftfont.c (xftfont_text_extents): Adjust to return void + and assume that 'metrics' argument is always non-NULL. + * ftfont.c (ftfont_text_extents): + * xfont.c (xfont_text_extents): Likewise. Avoid redundant memset. + 2014-08-25 Paul Eggert Minor cleanups of str_collate fix (Bug#18051). === modified file 'src/font.h' --- src/font.h 2014-07-09 23:35:31 +0000 +++ src/font.h 2014-08-25 07:00:42 +0000 @@ -570,9 +570,9 @@ /* Compute the total metrics of the NGLYPHS glyphs specified by the font FONT and the sequence of glyph codes CODE, and store the result in METRICS. */ - int (*text_extents) (struct font *font, - unsigned *code, int nglyphs, - struct font_metrics *metrics); + void (*text_extents) (struct font *font, + unsigned *code, int nglyphs, + struct font_metrics *metrics); #ifdef HAVE_WINDOW_SYSTEM === modified file 'src/ftfont.c' --- src/ftfont.c 2014-07-09 06:25:35 +0000 +++ src/ftfont.c 2014-08-25 07:00:42 +0000 @@ -499,8 +499,8 @@ static void ftfont_close (struct font *); static int ftfont_has_char (Lisp_Object, int); static unsigned ftfont_encode_char (struct font *, int); -static int ftfont_text_extents (struct font *, unsigned *, int, - struct font_metrics *); +static void ftfont_text_extents (struct font *, unsigned *, int, + struct font_metrics *); static int ftfont_get_bitmap (struct font *, unsigned, struct font_bitmap *, int); static int ftfont_anchor_point (struct font *, unsigned, int, @@ -1371,19 +1371,18 @@ return (code > 0 ? code : FONT_INVALID_CODE); } -static int -ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) +static void +ftfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; - int width = 0; - int i; + int i, width = 0; bool first; if (ftfont_info->ft_size != ft_face->size) FT_Activate_Size (ftfont_info->ft_size); - if (metrics) - memset (metrics, 0, sizeof (struct font_metrics)); + for (i = 0, first = 1; i < nglyphs; i++) { if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) @@ -1392,39 +1391,28 @@ if (first) { - if (metrics) - { - metrics->lbearing = m->horiBearingX >> 6; - metrics->rbearing = (m->horiBearingX + m->width) >> 6; - metrics->ascent = m->horiBearingY >> 6; - metrics->descent = (m->height - m->horiBearingY) >> 6; - } + metrics->lbearing = m->horiBearingX >> 6; + metrics->rbearing = (m->horiBearingX + m->width) >> 6; + metrics->ascent = m->horiBearingY >> 6; + metrics->descent = (m->height - m->horiBearingY) >> 6; first = 0; } - if (metrics) - { - if (metrics->lbearing > width + (m->horiBearingX >> 6)) - metrics->lbearing = width + (m->horiBearingX >> 6); - if (metrics->rbearing - < width + ((m->horiBearingX + m->width) >> 6)) - metrics->rbearing - = width + ((m->horiBearingX + m->width) >> 6); - if (metrics->ascent < (m->horiBearingY >> 6)) - metrics->ascent = m->horiBearingY >> 6; - if (metrics->descent > ((m->height - m->horiBearingY) >> 6)) - metrics->descent = (m->height - m->horiBearingY) >> 6; - } + if (metrics->lbearing > width + (m->horiBearingX >> 6)) + metrics->lbearing = width + (m->horiBearingX >> 6); + if (metrics->rbearing + < width + ((m->horiBearingX + m->width) >> 6)) + metrics->rbearing + = width + ((m->horiBearingX + m->width) >> 6); + if (metrics->ascent < (m->horiBearingY >> 6)) + metrics->ascent = m->horiBearingY >> 6; + if (metrics->descent > ((m->height - m->horiBearingY) >> 6)) + metrics->descent = (m->height - m->horiBearingY) >> 6; width += m->horiAdvance >> 6; } else - { - width += font->space_width; - } + width += font->space_width; } - if (metrics) - metrics->width = width; - - return width; + metrics->width = width; } static int === modified file 'src/macfont.m' --- src/macfont.m 2014-07-21 06:03:08 +0000 +++ src/macfont.m 2014-08-25 07:00:42 +0000 @@ -1553,8 +1553,8 @@ static void macfont_close (struct font *); static int macfont_has_char (Lisp_Object, int); static unsigned macfont_encode_char (struct font *, int); -static int macfont_text_extents (struct font *, unsigned int *, int, - struct font_metrics *); +static void macfont_text_extents (struct font *, unsigned int *, int, + struct font_metrics *); static int macfont_draw (struct glyph_string *, int, int, int, int, bool); static Lisp_Object macfont_shape (Lisp_Object); static int macfont_variation_glyphs (struct font *, int c, @@ -2653,9 +2653,9 @@ return glyph != kCGFontIndexInvalid ? glyph : FONT_INVALID_CODE; } -static int -macfont_text_extents (struct font *font, unsigned int *code, int nglyphs, - struct font_metrics *metrics) +static void +macfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics) { int width, i; @@ -2664,28 +2664,21 @@ for (i = 1; i < nglyphs; i++) { struct font_metrics m; - int w = macfont_glyph_extents (font, code[i], metrics ? &m : NULL, - NULL, 0); + int w = macfont_glyph_extents (font, code[i], &m, NULL, 0); - if (metrics) - { - if (width + m.lbearing < metrics->lbearing) - metrics->lbearing = width + m.lbearing; - if (width + m.rbearing > metrics->rbearing) - metrics->rbearing = width + m.rbearing; - if (m.ascent > metrics->ascent) - metrics->ascent = m.ascent; - if (m.descent > metrics->descent) - metrics->descent = m.descent; - } + if (width + m.lbearing < metrics->lbearing) + metrics->lbearing = width + m.lbearing; + if (width + m.rbearing > metrics->rbearing) + metrics->rbearing = width + m.rbearing; + if (m.ascent > metrics->ascent) + metrics->ascent = m.ascent; + if (m.descent > metrics->descent) + metrics->descent = m.descent; width += w; } unblock_input (); - if (metrics) - metrics->width = width; - - return width; + metrics->width = width; } static int === modified file 'src/nsfont.m' --- src/nsfont.m 2014-07-09 06:25:35 +0000 +++ src/nsfont.m 2014-08-25 07:00:42 +0000 @@ -627,8 +627,8 @@ static void nsfont_close (struct font *font); static int nsfont_has_char (Lisp_Object entity, int c); static unsigned int nsfont_encode_char (struct font *font, int c); -static int nsfont_text_extents (struct font *font, unsigned int *code, - int nglyphs, struct font_metrics *metrics); +static void nsfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics); static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, bool with_background); @@ -988,9 +988,9 @@ /* Perform the size computation of glyphs of FONT and fill in members of METRICS. The glyphs are specified by their glyph codes in CODE (length NGLYPHS). */ -static int -nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs, - struct font_metrics *metrics) +static void +nsfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics) { struct nsfont_info *font_info = (struct nsfont_info *)font; struct font_metrics *pcm; @@ -1000,7 +1000,7 @@ memset (metrics, 0, sizeof (struct font_metrics)); - for (i =0; iwidth = totalWidth; - - return totalWidth; /* not specified in doc, but xfont.c does it */ } === modified file 'src/w32font.c' --- src/w32font.c 2014-07-09 06:25:35 +0000 +++ src/w32font.c 2014-08-25 07:00:42 +0000 @@ -473,7 +473,7 @@ of METRICS. The glyphs are specified by their glyph codes in CODE (length NGLYPHS). Apparently metrics can be NULL, in this case just return the overall width. */ -int +void w32font_text_extents (struct font *font, unsigned *code, int nglyphs, struct font_metrics *metrics) { @@ -487,84 +487,80 @@ struct w32font_info *w32_font = (struct w32font_info *) font; - if (metrics) + memset (metrics, 0, sizeof (struct font_metrics)); + metrics->ascent = font->ascent; + metrics->descent = font->descent; + + for (i = 0; i < nglyphs; i++) { - memset (metrics, 0, sizeof (struct font_metrics)); - metrics->ascent = font->ascent; - metrics->descent = font->descent; - - for (i = 0; i < nglyphs; i++) - { - struct w32_metric_cache *char_metric; - int block = *(code + i) / CACHE_BLOCKSIZE; - int pos_in_block = *(code + i) % CACHE_BLOCKSIZE; - - if (block >= w32_font->n_cache_blocks) - { - if (!w32_font->cached_metrics) - w32_font->cached_metrics - = xmalloc ((block + 1) - * sizeof (struct w32_metric_cache *)); - else - w32_font->cached_metrics - = xrealloc (w32_font->cached_metrics, - (block + 1) - * sizeof (struct w32_metric_cache *)); - memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0, - ((block + 1 - w32_font->n_cache_blocks) - * sizeof (struct w32_metric_cache *))); - w32_font->n_cache_blocks = block + 1; - } - - if (!w32_font->cached_metrics[block]) - { - w32_font->cached_metrics[block] - = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); - } - - char_metric = w32_font->cached_metrics[block] + pos_in_block; - - if (char_metric->status == W32METRIC_NO_ATTEMPT) - { - if (dc == NULL) - { - /* TODO: Frames can come and go, and their fonts - outlive them. So we can't cache the frame in the - font structure. Use selected_frame until the API - is updated to pass in a frame. */ - f = XFRAME (selected_frame); - - dc = get_frame_dc (f); - old_font = SelectObject (dc, w32_font->hfont); - } - compute_metrics (dc, w32_font, *(code + i), char_metric); - } - - if (char_metric->status == W32METRIC_SUCCESS) - { - metrics->lbearing = min (metrics->lbearing, - metrics->width + char_metric->lbearing); - metrics->rbearing = max (metrics->rbearing, - metrics->width + char_metric->rbearing); - metrics->width += char_metric->width; - } + struct w32_metric_cache *char_metric; + int block = *(code + i) / CACHE_BLOCKSIZE; + int pos_in_block = *(code + i) % CACHE_BLOCKSIZE; + + if (block >= w32_font->n_cache_blocks) + { + if (!w32_font->cached_metrics) + w32_font->cached_metrics + = xmalloc ((block + 1) + * sizeof (struct w32_metric_cache *)); else - /* If we couldn't get metrics for a char, - use alternative method. */ - break; - } - /* If we got through everything, return. */ - if (i == nglyphs) - { - if (dc != NULL) - { - /* Restore state and release DC. */ - SelectObject (dc, old_font); - release_frame_dc (f, dc); - } - - return metrics->width; - } + w32_font->cached_metrics + = xrealloc (w32_font->cached_metrics, + (block + 1) + * sizeof (struct w32_metric_cache *)); + memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0, + ((block + 1 - w32_font->n_cache_blocks) + * sizeof (struct w32_metric_cache *))); + w32_font->n_cache_blocks = block + 1; + } + + if (!w32_font->cached_metrics[block]) + { + w32_font->cached_metrics[block] + = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); + } + + char_metric = w32_font->cached_metrics[block] + pos_in_block; + + if (char_metric->status == W32METRIC_NO_ATTEMPT) + { + if (dc == NULL) + { + /* TODO: Frames can come and go, and their fonts + outlive them. So we can't cache the frame in the + font structure. Use selected_frame until the API + is updated to pass in a frame. */ + f = XFRAME (selected_frame); + + dc = get_frame_dc (f); + old_font = SelectObject (dc, w32_font->hfont); + } + compute_metrics (dc, w32_font, *(code + i), char_metric); + } + + if (char_metric->status == W32METRIC_SUCCESS) + { + metrics->lbearing = min (metrics->lbearing, + metrics->width + char_metric->lbearing); + metrics->rbearing = max (metrics->rbearing, + metrics->width + char_metric->rbearing); + metrics->width += char_metric->width; + } + else + /* If we couldn't get metrics for a char, + use alternative method. */ + break; + } + /* If we got through everything, return. */ + if (i == nglyphs) + { + if (dc != NULL) + { + /* Restore state and release DC. */ + SelectObject (dc, old_font); + release_frame_dc (f, dc); + } + return; } /* For non-truetype fonts, GetGlyphOutlineW is not supported, so @@ -620,18 +616,13 @@ } /* Give our best estimate of the metrics, based on what we know. */ - if (metrics) - { - metrics->width = total_width - w32_font->metrics.tmOverhang; - metrics->lbearing = 0; - metrics->rbearing = total_width; - } + metrics->width = total_width - w32_font->metrics.tmOverhang; + metrics->lbearing = 0; + metrics->rbearing = total_width; /* Restore state and release DC. */ SelectObject (dc, old_font); release_frame_dc (f, dc); - - return total_width; } /* w32 implementation of draw for font backend. === modified file 'src/w32font.h' --- src/w32font.h 2014-01-01 07:43:34 +0000 +++ src/w32font.h 2014-08-25 07:00:42 +0000 @@ -74,8 +74,8 @@ int pixel_size, Lisp_Object font_object); void w32font_close (struct font *font); int w32font_has_char (Lisp_Object entity, int c); -int w32font_text_extents (struct font *font, unsigned *code, int nglyphs, - struct font_metrics *metrics); +void w32font_text_extents (struct font *font, unsigned *code, int nglyphs, + struct font_metrics *metrics); int w32font_draw (struct glyph_string *s, int from, int to, int x, int y, bool with_background); === modified file 'src/w32uniscribe.c' --- src/w32uniscribe.c 2014-07-09 06:25:35 +0000 +++ src/w32uniscribe.c 2014-08-25 07:00:42 +0000 @@ -591,8 +591,8 @@ Lisp_Object uniscribe_get_cache (Lisp_Object frame); void uniscribe_free_entity (Lisp_Object font_entity); int uniscribe_has_char (Lisp_Object entity, int c); - int uniscribe_text_extents (struct font *font, unsigned *code, - int nglyphs, struct font_metrics *metrics); + void uniscribe_text_extents (struct font *font, unsigned *code, + int nglyphs, struct font_metrics *metrics); int uniscribe_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background); === modified file 'src/xfont.c' --- src/xfont.c 2014-07-09 06:25:35 +0000 +++ src/xfont.c 2014-08-25 07:00:42 +0000 @@ -124,8 +124,8 @@ static void xfont_prepare_face (struct frame *, struct face *); static int xfont_has_char (Lisp_Object, int); static unsigned xfont_encode_char (struct font *, int); -static int xfont_text_extents (struct font *, unsigned *, int, - struct font_metrics *); +static void xfont_text_extents (struct font *, unsigned *, int, + struct font_metrics *); static int xfont_draw (struct glyph_string *, int, int, int, int, bool); static int xfont_check (struct frame *, struct font *); @@ -975,15 +975,14 @@ return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE); } -static int -xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) +static void +xfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics) { XFontStruct *xfont = ((struct xfont_info *) font)->xfont; - int width = 0; - int i, first; + int i, width = 0; + bool first; - if (metrics) - memset (metrics, 0, sizeof (struct font_metrics)); for (i = 0, first = 1; i < nglyphs; i++) { XChar2b char2b; @@ -997,34 +996,27 @@ continue; if (first) { - if (metrics) - { - metrics->lbearing = pcm->lbearing; - metrics->rbearing = pcm->rbearing; - metrics->ascent = pcm->ascent; - metrics->descent = pcm->descent; - } + metrics->lbearing = pcm->lbearing; + metrics->rbearing = pcm->rbearing; + metrics->ascent = pcm->ascent; + metrics->descent = pcm->descent; first = 0; } else { - if (metrics) - { - if (metrics->lbearing > width + pcm->lbearing) - metrics->lbearing = width + pcm->lbearing; - if (metrics->rbearing < width + pcm->rbearing) - metrics->rbearing = width + pcm->rbearing; - if (metrics->ascent < pcm->ascent) - metrics->ascent = pcm->ascent; - if (metrics->descent < pcm->descent) - metrics->descent = pcm->descent; - } + if (metrics->lbearing > width + pcm->lbearing) + metrics->lbearing = width + pcm->lbearing; + if (metrics->rbearing < width + pcm->rbearing) + metrics->rbearing = width + pcm->rbearing; + if (metrics->ascent < pcm->ascent) + metrics->ascent = pcm->ascent; + if (metrics->descent < pcm->descent) + metrics->descent = pcm->descent; } width += pcm->width; } - if (metrics) - metrics->width = width; - return width; + + metrics->width = width; } static int === modified file 'src/xftfont.c' --- src/xftfont.c 2014-07-09 06:25:35 +0000 +++ src/xftfont.c 2014-08-25 07:00:42 +0000 @@ -557,8 +557,9 @@ return (code ? code : FONT_INVALID_CODE); } -static int -xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) +static void +xftfont_text_extents (struct font *font, unsigned int *code, + int nglyphs, struct font_metrics *metrics) { struct xftfont_info *xftfont_info = (struct xftfont_info *) font; XGlyphInfo extents; @@ -567,15 +568,12 @@ XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs, &extents); unblock_input (); - if (metrics) - { - metrics->lbearing = - extents.x; - metrics->rbearing = - extents.x + extents.width; - metrics->width = extents.xOff; - metrics->ascent = extents.y; - metrics->descent = extents.height - extents.y; - } - return extents.xOff; + + metrics->lbearing = - extents.x; + metrics->rbearing = - extents.x + extents.width; + metrics->width = extents.xOff; + metrics->ascent = extents.y; + metrics->descent = extents.height - extents.y; } static XftDraw * ------------------------------------------------------------ revno: 117733 fixes bug: http://debbugs.gnu.org/18051 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-08-24 22:44:57 -0700 message: Minor cleanups of str_collate fix. * fns.c (str_collate): Move decl from here ... * lisp.h (str_collate): ... to here. * sysdep.c (str_collate): Prune away some of the forest of ifdefs. Remove unnecessary casts. Use SAFE_NALLOCA to avoid potential problems with integer overflow. Don't assume setlocale succeeds. Remove unnecessary test before restoring locale via setlocale, and free the copied setlocale string when done with it. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-24 15:40:07 +0000 +++ src/ChangeLog 2014-08-25 05:44:57 +0000 @@ -1,3 +1,15 @@ +2014-08-25 Paul Eggert + + Minor cleanups of str_collate fix (Bug#18051). + * fns.c (str_collate): Move decl from here ... + * lisp.h (str_collate): ... to here. + * sysdep.c (str_collate): Prune away some of the forest of ifdefs. + Remove unnecessary casts. Use SAFE_NALLOCA to avoid + potential problems with integer overflow. Don't assume + setlocale succeeds. Remove unnecessary test before restoring + locale via setlocale, and free the copied setlocale string + when done with it. + 2014-08-24 Michael Albinus * fns.c (Fstring_collate_lessp, Fstring_collate_equalp): New DEFUNs. === modified file 'src/fns.c' --- src/fns.c 2014-08-24 15:40:07 +0000 +++ src/fns.c 2014-08-25 05:44:57 +0000 @@ -344,11 +344,6 @@ return i1 < SCHARS (s2) ? Qt : Qnil; } -#ifdef __STDC_ISO_10646__ -/* Defined in sysdep.c. */ -extern ptrdiff_t str_collate (Lisp_Object, Lisp_Object); -#endif /* __STDC_ISO_10646__ */ - DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, 2, 0, doc: /* Return t if first arg string is less than second in collation order. === modified file 'src/lisp.h' --- src/lisp.h 2014-07-28 06:28:15 +0000 +++ src/lisp.h 2014-08-25 05:44:57 +0000 @@ -4295,6 +4295,7 @@ extern void unlock_file (Lisp_Object); extern void unlock_buffer (struct buffer *); extern void syms_of_filelock (void); +extern ptrdiff_t str_collate (Lisp_Object, Lisp_Object); /* Defined in sound.c. */ extern void syms_of_sound (void); === modified file 'src/sysdep.c' --- src/sysdep.c 2014-08-24 15:40:07 +0000 +++ src/sysdep.c 2014-08-25 05:44:57 +0000 @@ -3517,56 +3517,61 @@ /* Wide character string collation. */ #ifdef __STDC_ISO_10646__ -#include +# include -#if defined (HAVE_USELOCALE) || defined (HAVE_SETLOCALE) -#include -#endif /* HAVE_USELOCALE || HAVE_SETLOCALE */ +# if defined HAVE_USELOCALE || defined HAVE_SETLOCALE +# include +# endif +# ifndef HAVE_SETLOCALE +# define setlocale(category, locale) ((char *) 0) +# endif ptrdiff_t str_collate (Lisp_Object s1, Lisp_Object s2) { - register ptrdiff_t res, len, i, i_byte; + ptrdiff_t res, len, i, i_byte; wchar_t *p1, *p2; Lisp_Object lc_collate; -#ifdef HAVE_USELOCALE - locale_t loc = (locale_t) 0, oldloc = (locale_t) 0; -#elif defined (HAVE_SETLOCALE) +# ifdef HAVE_USELOCALE + locale_t loc = 0, oldloc = 0; +# else char *oldloc = NULL; -#endif /* HAVE_USELOCALE */ +# endif USE_SAFE_ALLOCA; /* Convert byte stream to code points. */ len = SCHARS (s1); i = i_byte = 0; - p1 = (wchar_t *) SAFE_ALLOCA ((len+1) * (sizeof *p1)); + SAFE_NALLOCA (p1, 1, len + 1); while (i < len) FETCH_STRING_CHAR_ADVANCE (*(p1+i-1), s1, i, i_byte); *(p1+len) = 0; len = SCHARS (s2); i = i_byte = 0; - p2 = (wchar_t *) SAFE_ALLOCA ((len+1) * (sizeof *p2)); + SAFE_NALLOCA (p2, 1, len + 1); while (i < len) FETCH_STRING_CHAR_ADVANCE (*(p2+i-1), s2, i, i_byte); *(p2+len) = 0; -#if defined (HAVE_USELOCALE) || defined (HAVE_SETLOCALE) /* Create a new locale object, and set it. */ lc_collate = Fgetenv_internal (build_string ("LC_COLLATE"), Vprocess_environment); -#ifdef HAVE_USELOCALE - if (STRINGP (lc_collate) - && (loc = newlocale (LC_COLLATE_MASK, SSDATA (lc_collate), (locale_t) 0))) - oldloc = uselocale (loc); -#elif defined (HAVE_SETLOCALE) if (STRINGP (lc_collate)) { - oldloc = xstrdup (setlocale (LC_COLLATE, NULL)); - setlocale (LC_COLLATE, SSDATA (lc_collate)); +#ifdef HAVE_USELOCALE + loc = newlocale (LC_COLLATE_MASK, SSDATA (lc_collate), 0); + if (loc) + oldloc = uselocale (loc); +#else + oldloc = setlocale (LC_COLLATE, NULL); + if (oldloc) + { + oldloc = xstrdup (oldloc); + setlocale (LC_COLLATE, SSDATA (lc_collate)); + } +#endif } -#endif /* HAVE_USELOCALE */ -#endif /* HAVE_USELOCALE || HAVE_SETLOCALE */ res = wcscoll (p1, p2); @@ -3576,11 +3581,11 @@ freelocale (loc); if (oldloc) uselocale (oldloc); -#elif defined (HAVE_SETLOCALE) +#else /* Restore the original locale. */ - if (oldloc) - setlocale (LC_COLLATE, oldloc); -#endif /* HAVE_USELOCALE */ + setlocale (LC_COLLATE, oldloc); + xfree (oldloc); +#endif /* Return result. */ SAFE_FREE (); ------------------------------------------------------------ revno: 117732 fixes bug: http://debbugs.gnu.org/18253 committer: Christoph Scholtes branch nick: trunk timestamp: Sun 2014-08-24 21:16:36 -0600 message: Fix docstring of `remq' * lisp/subr.el (remq): Fix docstring. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-25 02:36:45 +0000 +++ lisp/ChangeLog 2014-08-25 03:16:36 +0000 @@ -1,5 +1,9 @@ 2014-08-25 Christoph Scholtes + * subr.el (remq): Fix docstring (Bug#18253). + +2014-08-25 Christoph Scholtes + * replace.el (query-replace): Fix typo in docstring (Bug#18320). 2014-08-24 Alan Mackenzie === modified file 'lisp/subr.el' --- lisp/subr.el 2014-08-15 04:34:06 +0000 +++ lisp/subr.el 2014-08-25 03:16:36 +0000 @@ -565,7 +565,7 @@ (delete elt (copy-sequence seq)))) (defun remq (elt list) - "Return LIST with all occurrences of ELT removed. + "Return a copy of LIST with all occurrences of ELT removed. The comparison is done with `eq'. Contrary to `delq', this does not use side-effects, and the argument LIST is not modified." (while (and (eq elt (car list)) (setq list (cdr list)))) ------------------------------------------------------------ revno: 117731 fixes bug: http://debbugs.gnu.org/18320 committer: Christoph Scholtes branch nick: trunk timestamp: Sun 2014-08-24 20:36:45 -0600 message: * lisp/replace.el (query-replace): Fix typo in docstring. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-24 20:50:11 +0000 +++ lisp/ChangeLog 2014-08-25 02:36:45 +0000 @@ -1,3 +1,7 @@ +2014-08-25 Christoph Scholtes + + * replace.el (query-replace): Fix typo in docstring (Bug#18320). + 2014-08-24 Alan Mackenzie Handle C++11's "auto" and "decltype" constructions. === modified file 'lisp/replace.el' --- lisp/replace.el 2014-03-22 22:12:52 +0000 +++ lisp/replace.el 2014-08-25 02:36:45 +0000 @@ -266,7 +266,7 @@ Fourth and fifth arg START and END specify the region to operate on. -To customize possible responses, change the \"bindings\" in `query-replace-map'." +To customize possible responses, change the bindings in `query-replace-map'." (interactive (let ((common (query-replace-read-args ------------------------------------------------------------ revno: 117730 fixes bug: http://debbugs.gnu.org/18323 author: Christoph Scholtes committer: Christoph Scholtes branch nick: trunk timestamp: Sun 2014-08-24 20:29:58 -0600 message: Remove reference to obsolete configure scripts * INSTALL.REPO: Remove reference to obsolete configure scripts on non-Posix platforms. diff: === modified file 'ChangeLog' --- ChangeLog 2014-08-24 15:40:07 +0000 +++ ChangeLog 2014-08-25 02:29:58 +0000 @@ -1,3 +1,8 @@ +2014-08-25 Christoph Scholtes + + * INSTALL.REPO: Remove reference to obsolete configure scripts + on non-Posix platforms (Bug#18323). + 2014-08-24 Michael Albinus * configure.ac: Check also for the uselocale function. (Bug#18051) === modified file 'INSTALL.REPO' --- INSTALL.REPO 2014-05-16 15:49:13 +0000 +++ INSTALL.REPO 2014-08-25 02:29:58 +0000 @@ -52,11 +52,6 @@ If CPU time is not an issue, 'make bootstrap' is the most thorough way to rebuild, and avoid any spurious problems. -Users of non-Posix systems (MS-Windows, etc.) should run the -platform-specific configuration scripts ('nt/configure.bat', -'config.bat', etc.) before 'make'; the rest of the procedure is -applicable to those systems as well. - Because the repository version of Emacs is a work in progress, it will sometimes fail to build. Please wait a day or so (and check the archives of the emacs-buildstatus, emacs-devel, and bug-gnu-emacs ------------------------------------------------------------ revno: 117729 committer: Alan Mackenzie branch nick: trunk timestamp: Sun 2014-08-24 20:50:11 +0000 message: Handle C++11's "auto" and "decltype" constructions. cc-engine.el (c-forward-type): Enhance to recognise and return 'decltype. (c-forward-decl-or-cast-1): New let variables backup-kwd-sym, prev-kwd-sym, new-style-auto. Enhance to handle the new "auto" keyword. cc-fonts.el (c-font-lock-declarations): Handle the "decltype" keyword. (c-font-lock-c++-new): Handle "decltype" constructions. cc-langs.el (c-auto-ops, c-auto-ops-re): New c-lang-defconsts/defvars. (c-haskell-op, c-haskell-op-re): New c-lang-defconsts/defvars. (c-typeof-kwds, c-typeof-key): New c-lang-defconsts/defvars. (c-typeless-decl-kwds): Append "auto" onto the C++ value. (c-not-decl-init-keywords): Also exclude c-typeof-kwds from value. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-24 20:38:11 +0000 +++ lisp/ChangeLog 2014-08-24 20:50:11 +0000 @@ -1,5 +1,21 @@ 2014-08-24 Alan Mackenzie + Handle C++11's "auto" and "decltype" constructions. + * progmodes/cc-engine.el (c-forward-type): Enhance to recognise + and return 'decltype. + (c-forward-decl-or-cast-1): New let variables backup-kwd-sym, + prev-kwd-sym, new-style-auto. Enhance to handle the new "auto" + keyword. + * progmodes/cc-fonts.el (c-font-lock-declarations): Handle the + "decltype" keyword. + (c-font-lock-c++-new): Handle "decltype" constructions. + * progmodes/cc-langs.el (c-auto-ops, c-auto-ops-re): New + c-lang-defconsts/defvars. + (c-haskell-op, c-haskell-op-re): New c-lang-defconsts/defvars. + (c-typeof-kwds, c-typeof-key): New c-lang-defconsts/defvars. + (c-typeless-decl-kwds): Append "auto" onto the C++ value. + (c-not-decl-init-keywords): Also exclude c-typeof-kwds from value. + Make ">>" act as double template ender in C++ Mode. * progmodes/cc-langs.el (c->-op-cont-tokens): New lang-const split off from c->-op-cont-re. === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2014-08-24 20:38:11 +0000 +++ lisp/progmodes/cc-engine.el 2014-08-24 20:50:11 +0000 @@ -6286,7 +6286,8 @@ ;; `*-font-lock-extra-types'); ;; o - 'prefix if it's a known prefix of a type; ;; o - 'found if it's a type that matches one in `c-found-types'; - ;; o - 'maybe if it's an identifier that might be a type; or + ;; o - 'maybe if it's an identfier that might be a type; + ;; o - 'decltype if it's a decltype(variable) declaration; - or ;; o - nil if it can't be a type (the point isn't moved then). ;; ;; The point is assumed to be at the beginning of a token. @@ -6316,6 +6317,16 @@ (setq res 'prefix))) (cond + ((looking-at c-typeof-key) ; e.g. C++'s "decltype". + (goto-char (match-end 1)) + (c-forward-syntactic-ws) + (setq res (and (eq (char-after) ?\() + (c-safe (c-forward-sexp)) + 'decltype)) + (if res + (c-forward-syntactic-ws) + (goto-char start))) + ((looking-at c-type-prefix-key) ; e.g. "struct", "class", but NOT ; "typedef". (goto-char (match-end 1)) @@ -6442,7 +6453,7 @@ ;; of these alter the classification of the found type, since ;; these operators typically are allowed in normal expressions ;; too. - (when c-opt-type-suffix-key + (when c-opt-type-suffix-key ; e.g. "..." (while (looking-at c-opt-type-suffix-key) (goto-char (match-end 1)) (c-forward-syntactic-ws))) @@ -6654,6 +6665,13 @@ ;; Foo::Foo (int b) : Base (b) {} ;; car ^ ^ point ;; + ;; auto foo = 5; + ;; car ^ ^ point + ;; auto cplusplus_11 (int a, char *b) -> decltype (bar): + ;; car ^ ^ point + ;; + ;; + ;; ;; The cdr of the return value is non-nil when a ;; `c-typedef-decl-kwds' specifier is found in the declaration. ;; Specifically it is a dotted pair (A . B) where B is t when a @@ -6719,6 +6737,10 @@ ;; If `backup-at-type' is nil then the other variables have ;; undefined values. backup-at-type backup-type-start backup-id-start + ;; This stores `kwd-sym' of the symbol before the current one. + ;; This is needed to distinguish the C++11 version of "auto" from + ;; the pre C++11 meaning. + backup-kwd-sym ;; Set if we've found a specifier (apart from "typedef") that makes ;; the defined identifier(s) types. at-type-decl @@ -6727,6 +6749,10 @@ ;; Set if we've found a specifier that can start a declaration ;; where there's no type. maybe-typeless + ;; Save the value of kwd-sym between loops of the "Check for a + ;; type" loop. Needed to distinguish a C++11 "auto" from a pre + ;; C++11 one. + prev-kwd-sym ;; If a specifier is found that also can be a type prefix, ;; these flags are set instead of those above. If we need to ;; back up an identifier, they are copied to the real flag @@ -6744,6 +6770,8 @@ backup-if-not-cast ;; For casts, the return position. cast-end + ;; Have we got a new-style C++11 "auto"? + new-style-auto ;; Save `c-record-type-identifiers' and ;; `c-record-ref-identifiers' since ranges are recorded ;; speculatively and should be thrown away if it turns out @@ -6762,11 +6790,12 @@ (let* ((start (point)) kwd-sym kwd-clause-end found-type) ;; Look for a specifier keyword clause. - (when (or (looking-at c-prefix-spec-kwds-re) + (when (or (looking-at c-prefix-spec-kwds-re) ;FIXME!!! includes auto (and (c-major-mode-is 'java-mode) (looking-at "@[A-Za-z0-9]+"))) - (if (looking-at c-typedef-key) - (setq at-typedef t)) + (save-match-data + (if (looking-at c-typedef-key) + (setq at-typedef t))) (setq kwd-sym (c-keyword-sym (match-string 1))) (save-excursion (c-forward-keyword-clause 1) @@ -6774,6 +6803,12 @@ (when (setq found-type (c-forward-type t)) ; brace-block-too ;; Found a known or possible type or a prefix of a known type. + (when (and (c-major-mode-is 'c++-mode) ; C++11 style "auto"? + (eq prev-kwd-sym (c-keyword-sym "auto")) + (looking-at "[=(]")) ; FIXME!!! proper regexp. + (setq new-style-auto t) + (setq found-type nil) + (goto-char start)) ; position of foo in "auto foo" (when at-type ;; Got two identifiers with nothing but whitespace @@ -6792,6 +6827,7 @@ (setq backup-at-type at-type backup-type-start type-start backup-id-start id-start + backup-kwd-sym kwd-sym at-type found-type type-start start id-start (point) @@ -6847,6 +6883,7 @@ ;; specifier keyword and we know we're in a ;; declaration. (setq at-decl-or-cast t) + (setq prev-kwd-sym kwd-sym) (goto-char kwd-clause-end)))) @@ -7038,15 +7075,26 @@ (c-forward-syntactic-ws)) - (when (and (or maybe-typeless backup-maybe-typeless) - (not got-identifier) - (not got-prefix) - at-type) + (when (or (and new-style-auto + (looking-at c-auto-ops-re)) + (and (or maybe-typeless backup-maybe-typeless) + (not got-identifier) + (not got-prefix) + at-type)) ;; Have found no identifier but `c-typeless-decl-kwds' has ;; matched so we know we're inside a declaration. The ;; preceding type must be the identifier instead. (c-fdoc-shift-type-backward)) + ;; Prepare the "-> type;" for fontification later on. + (when (and new-style-auto + (looking-at c-haskell-op-re)) + (save-excursion + (goto-char (match-end 0)) + (c-forward-syntactic-ws) + (setq type-start (point)) + (setq at-type (c-forward-type)))) + (setq at-decl-or-cast (catch 'at-decl-or-cast @@ -7371,6 +7419,7 @@ ;; is a declaration. Now we're being more defensive and prefer to ;; highlight things like "foo (bar);" as a declaration only if we're ;; inside an arglist that contains declarations. + ;; CASE 19 (eq context 'decl)))) ;; The point is now after the type decl expression. @@ -7460,6 +7509,8 @@ ;; interactive refontification. (c-put-c-type-property (point) 'c-decl-arg-start)) + ;; Record the type's coordinates in `c-record-type-identifiers' for + ;; later fontification. (when (and c-record-type-identifiers at-type ;; (not (eq at-type t)) ;; There seems no reason to exclude a token from ;; fontification just because it's "a known type that can't === modified file 'lisp/progmodes/cc-fonts.el' --- lisp/progmodes/cc-fonts.el 2014-08-23 11:02:20 +0000 +++ lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000 @@ -1306,14 +1306,15 @@ (cond ((not (memq (char-before match-pos) '(?\( ?, ?\[ ?<))) (setq context nil c-restricted-<>-arglists nil)) - ;; A control flow expression + ;; A control flow expression or a decltype ((and (eq (char-before match-pos) ?\() (save-excursion (goto-char match-pos) (backward-char) (c-backward-token-2) (or (looking-at c-block-stmt-2-key) - (looking-at c-block-stmt-1-2-key)))) + (looking-at c-block-stmt-1-2-key) + (looking-at c-typeof-key)))) (setq context nil c-restricted-<>-arglists t)) ;; Near BOB. @@ -1513,7 +1514,7 @@ (goto-char (match-end 0)) (c-forward-syntactic-ws)) ;; At a real declaration? - (if (memq (c-forward-type t) '(t known found)) + (if (memq (c-forward-type t) '(t known found decltype)) (progn (c-font-lock-declarators limit t is-typedef) nil) @@ -2130,7 +2131,7 @@ ;; Got two parenthesized expressions, so we have to look ;; closer at them to decide which is the type. No need to ;; handle `c-record-ref-identifiers' since all references - ;; has already been handled by other fontification rules. + ;; have already been handled by other fontification rules. (let (expr1-res expr2-res) (goto-char expr1-pos) @@ -2165,6 +2166,9 @@ ;; unusual than an initializer. (cond ((memq expr1-res '(t known prefix))) ((memq expr2-res '(t known prefix))) + ;; Presumably 'decltype's will be fontified elsewhere. + ((eq expr1-res 'decltype)) + ((eq expr2-res 'decltype)) ((eq expr1-res 'found) (let ((c-promote-possible-types t)) (goto-char expr1-pos) === modified file 'lisp/progmodes/cc-langs.el' --- lisp/progmodes/cc-langs.el 2014-08-24 20:38:11 +0000 +++ lisp/progmodes/cc-langs.el 2014-08-24 20:50:11 +0000 @@ -940,10 +940,13 @@ often are described as postfix operators are considered binary here, since CC Mode treats every identifier as an expression." - ;; There's currently no code in CC Mode that exploit all the info + ;; There's currently no code in CC Mode that exploits all the info ;; in this variable; precedence, associativity etc are present as a ;; preparation for future work. + ;; FIXME!!! C++11's "auto" operators "=" and "->" need to go in here + ;; somewhere. 2012-03-24. + t `(;; Preprocessor. ,@(when (c-lang-const c-opt-cpp-prefix) `((prefix "#" @@ -1266,6 +1269,21 @@ (c-lang-defvar c-stmt-delim-chars-with-comma (c-lang-const c-stmt-delim-chars-with-comma)) +(c-lang-defconst c-auto-ops + ;; Ops which signal C++11's new auto uses. + t nil + c++ '("=" "->")) +(c-lang-defconst c-auto-ops-re + t (c-make-keywords-re nil (c-lang-const c-auto-ops))) +(c-lang-defvar c-auto-ops-re (c-lang-const c-auto-ops-re)) + +(c-lang-defconst c-haskell-op + ;; Op used in the new C++11 auto function definition, indicating type. + t nil + c++ '("->")) +(c-lang-defconst c-haskell-op-re + t (c-make-keywords-re nil (c-lang-const c-haskell-op))) +(c-lang-defvar c-haskell-op-re (c-lang-const c-haskell-op-re)) ;;; Syntactic whitespace. @@ -1673,6 +1691,18 @@ t (c-make-keywords-re t (c-lang-const c-typedef-kwds))) (c-lang-defvar c-typedef-key (c-lang-const c-typedef-key)) +(c-lang-defconst c-typeof-kwds + "Keywords followed by a parenthesized expression, which stands for +the type of that expression." + t nil + c '("typeof") ; longstanding GNU C(++) extension. + c++ '("decltype" "typeof")) + +(c-lang-defconst c-typeof-key + ;; Adorned regexp matching `c-typeof-kwds'. + t (c-make-keywords-re t (c-lang-const c-typeof-kwds))) +(c-lang-defvar c-typeof-key (c-lang-const c-typeof-key)) + (c-lang-defconst c-type-prefix-kwds "Keywords where the following name - if any - is a type name, and where the keyword together with the symbol works as a type in @@ -1856,6 +1886,7 @@ ;; {...}"). t (append (c-lang-const c-class-decl-kwds) (c-lang-const c-brace-list-decl-kwds)) + c++ (append (c-lang-const c-typeless-decl-kwds) '("auto")) ; C++11. ;; Note: "manages" for CORBA CIDL clashes with its presence on ;; `c-type-list-kwds' for IDL. idl (append (c-lang-const c-typeless-decl-kwds) @@ -2005,7 +2036,8 @@ t (c-make-keywords-re t (set-difference (c-lang-const c-keywords) (append (c-lang-const c-type-start-kwds) - (c-lang-const c-prefix-spec-kwds)) + (c-lang-const c-prefix-spec-kwds) + (c-lang-const c-typeof-kwds)) :test 'string-equal))) (c-lang-defvar c-not-decl-init-keywords (c-lang-const c-not-decl-init-keywords)) ------------------------------------------------------------ revno: 117728 committer: Alan Mackenzie branch nick: trunk timestamp: Sun 2014-08-24 20:38:11 +0000 message: Make ">>" act as double template ender in C++ Mode. cc-langs.el (c->-op-cont-tokens): New lang-const split off from c->-op-cont-re. (c->-op-cont-tokens): Change to use the above. (c->-op-without->-cont-regexp): New lang-const. cc-engine.el (c-forward-<>-arglist-recur): Use c->-op-without->-cont-regexp in place of c->-op-cont-tokens. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-23 11:02:20 +0000 +++ lisp/ChangeLog 2014-08-24 20:38:11 +0000 @@ -1,3 +1,14 @@ +2014-08-24 Alan Mackenzie + + Make ">>" act as double template ender in C++ Mode. + * progmodes/cc-langs.el (c->-op-cont-tokens): New lang-const split + off from c->-op-cont-re. + (c->-op-cont-tokens): Change to use the above. + (c->-op-without->-cont-regexp): New lang-const. + * progmodes/cc-engine.el (c-forward-<>-arglist-recur): Use + c->-op-without->-cont-regexp in place of c->-op-cont-tokens. + + 2014-08-23 Alan Mackenzie * progmodes/cc-fonts.el (c-font-lock-declarators): Fix infinite === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2014-08-02 18:52:48 +0000 +++ lisp/progmodes/cc-engine.el 2014-08-24 20:38:11 +0000 @@ -5944,7 +5944,7 @@ ;; Either an operator starting with '>' or the end of ;; the angle bracket arglist. - (if (looking-at c->-op-cont-regexp) + (if (looking-at c->-op-without->-cont-regexp) (progn (goto-char (match-end 0)) t) ; Continue the loop. === modified file 'lisp/progmodes/cc-langs.el' --- lisp/progmodes/cc-langs.el 2014-07-14 23:58:52 +0000 +++ lisp/progmodes/cc-langs.el 2014-08-24 20:38:11 +0000 @@ -1217,22 +1217,41 @@ (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) +(c-lang-defconst c->-op-cont-tokens + ;; A list of second and subsequent characters of all multicharacter tokens + ;; that begin with ">". + t (c-filter-ops (c-lang-const c-all-op-syntax-tokens) + t + "\\`>." + (lambda (op) (substring op 1))) + java (c-filter-ops (c-lang-const c-all-op-syntax-tokens) + t + "\\`>[^>]\\|\\`>>[^>]" + (lambda (op) (substring op 1)))) + (c-lang-defconst c->-op-cont-regexp ;; Regexp matching the second and subsequent characters of all ;; multicharacter tokens that begin with ">". - t (c-make-keywords-re nil - (c-filter-ops (c-lang-const c-all-op-syntax-tokens) - t - "\\`>." - (lambda (op) (substring op 1)))) - java (c-make-keywords-re nil - (c-filter-ops (c-lang-const c-all-op-syntax-tokens) - t - "\\`>[^>]\\|\\`>>[^>]" - (lambda (op) (substring op 1))))) + t (c-make-keywords-re nil (c-lang-const c->-op-cont-tokens))) (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp)) +(c-lang-defconst c->-op-without->-cont-regexp + ;; Regexp matching the second and subsequent characters of all + ;; multicharacter tokens that begin with ">" except for those beginning with + ;; ">>". + t (c-make-keywords-re nil + (set-difference + (c-lang-const c->-op-cont-tokens) + (c-filter-ops (c-lang-const c-all-op-syntax-tokens) + t + "\\`>>" + (lambda (op) (substring op 1))) + :test 'string-equal))) + +(c-lang-defvar c->-op-without->-cont-regexp + (c-lang-const c->-op-without->-cont-regexp)) + (c-lang-defconst c-stmt-delim-chars ;; The characters that should be considered to bound statements. To ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to ------------------------------------------------------------ revno: 117727 committer: Michael Albinus branch nick: trunk timestamp: Sun 2014-08-24 17:47:06 +0200 message: Mention the new functions `string-collate-lessp' and `string-collate-equalp'. diff: === modified file 'etc/NEWS' --- etc/NEWS 2014-07-28 09:39:09 +0000 +++ etc/NEWS 2014-08-24 15:47:06 +0000 @@ -66,6 +66,12 @@ hiding character but the default `.' can be used by let-binding the variable `read-hide-char'. +** The new functions `string-collate-lessp' and `string-collate-equalp' +preserve the collation order as defined by the system's locale(1) +environment. For the time being this is implemented for POSIX systems +only, for other systems they fall back to their counterparts +`string-lessp' and `string-equal'. + * Editing Changes in Emacs 24.5 ------------------------------------------------------------ revno: 117726 fixes bug: http://debbugs.gnu.org/18051 committer: Michael Albinus branch nick: trunk timestamp: Sun 2014-08-24 17:40:07 +0200 message: Add string collation. * configure.ac: Check also for the uselocale function. * src/fns.c (Fstring_collate_lessp, Fstring_collate_equalp): New DEFUNs. * src/sysdep.c (str_collate): New function. (Bug#18051) diff: === modified file 'ChangeLog' --- ChangeLog 2014-08-23 08:48:30 +0000 +++ ChangeLog 2014-08-24 15:40:07 +0000 @@ -1,3 +1,7 @@ +2014-08-24 Michael Albinus + + * configure.ac: Check also for the uselocale function. (Bug#18051) + 2014-08-23 Karol Ostrovsky (tiny change) * configure.ac: Accept "*-mingw*", not just "*-mingw32", as === modified file 'configure.ac' --- configure.ac 2014-08-23 09:14:13 +0000 +++ configure.ac 2014-08-24 15:40:07 +0000 @@ -3553,7 +3553,7 @@ AC_CHECK_FUNCS(accept4 fchdir gethostname \ getrusage get_current_dir_name \ lrand48 random rint \ -select getpagesize setlocale \ +select getpagesize setlocale uselocale \ getrlimit setrlimit shutdown getaddrinfo \ pthread_sigmask strsignal setitimer \ sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-23 08:48:30 +0000 +++ src/ChangeLog 2014-08-24 15:40:07 +0000 @@ -1,3 +1,9 @@ +2014-08-24 Michael Albinus + + * fns.c (Fstring_collate_lessp, Fstring_collate_equalp): New DEFUNs. + + * sysdep.c (str_collate): New function. (Bug#18051) + 2014-08-23 Karol Ostrovsky (tiny change) * Makefile.in (emacs$(EXEEXT)): Retry deletion of bootstrap-emacs === modified file 'src/fns.c' --- src/fns.c 2014-08-02 15:56:18 +0000 +++ src/fns.c 2014-08-24 15:40:07 +0000 @@ -40,7 +40,7 @@ #include "xterm.h" #endif -Lisp_Object Qstring_lessp; +Lisp_Object Qstring_lessp, Qstring_collate_lessp, Qstring_collate_equalp; static Lisp_Object Qprovide, Qrequire; static Lisp_Object Qyes_or_no_p_history; Lisp_Object Qcursor_in_echo_area; @@ -343,6 +343,84 @@ } return i1 < SCHARS (s2) ? Qt : Qnil; } + +#ifdef __STDC_ISO_10646__ +/* Defined in sysdep.c. */ +extern ptrdiff_t str_collate (Lisp_Object, Lisp_Object); +#endif /* __STDC_ISO_10646__ */ + +DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, 2, 0, + doc: /* Return t if first arg string is less than second in collation order. + +Case is significant. Symbols are also allowed; their print names are +used instead. + +This function obeys the conventions for collation order in your +locale settings. For example, punctuation and whitespace characters +are considered less significant for sorting. + +\(sort '\("11" "12" "1 1" "1 2" "1.1" "1.2") 'string-collate-lessp) + => \("11" "1 1" "1.1" "12" "1 2" "1.2") + +If your system does not support a locale environment, this function +behaves like `string-lessp'. + +If the environment variable \"LC_COLLATE\" is set in `process-environment', +it overrides the setting of your current locale. */) + (Lisp_Object s1, Lisp_Object s2) +{ +#ifdef __STDC_ISO_10646__ + /* Check parameters. */ + if (SYMBOLP (s1)) + s1 = SYMBOL_NAME (s1); + if (SYMBOLP (s2)) + s2 = SYMBOL_NAME (s2); + CHECK_STRING (s1); + CHECK_STRING (s2); + + return (str_collate (s1, s2) < 0) ? Qt : Qnil; + +#else + return Fstring_lessp (s1, s2); +#endif /* __STDC_ISO_10646__ */ +} + +DEFUN ("string-collate-equalp", Fstring_collate_equalp, Sstring_collate_equalp, 2, 2, 0, + doc: /* Return t if two strings have identical contents. + +Case is significant. Symbols are also allowed; their print names are +used instead. + +This function obeys the conventions for collation order in your locale +settings. For example, characters with different coding points but +the same meaning are considered as equal, like different grave accent +unicode characters. + +\(string-collate-equalp \(string ?\\uFF40) \(string ?\\u1FEF)) + => t + +If your system does not support a locale environment, this function +behaves like `string-equal'. + +If the environment variable \"LC_COLLATE\" is set in `process-environment', +it overrides the setting of your current locale. */) + (Lisp_Object s1, Lisp_Object s2) +{ +#ifdef __STDC_ISO_10646__ + /* Check parameters. */ + if (SYMBOLP (s1)) + s1 = SYMBOL_NAME (s1); + if (SYMBOLP (s2)) + s2 = SYMBOL_NAME (s2); + CHECK_STRING (s1); + CHECK_STRING (s2); + + return (str_collate (s1, s2) == 0) ? Qt : Qnil; + +#else + return Fstring_equal (s1, s2); +#endif /* __STDC_ISO_10646__ */ +} static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, enum Lisp_Type target_type, bool last_special); @@ -4919,6 +4997,8 @@ defsubr (&Sdefine_hash_table_test); DEFSYM (Qstring_lessp, "string-lessp"); + DEFSYM (Qstring_collate_lessp, "string-collate-lessp"); + DEFSYM (Qstring_collate_equalp, "string-collate-equalp"); DEFSYM (Qprovide, "provide"); DEFSYM (Qrequire, "require"); DEFSYM (Qyes_or_no_p_history, "yes-or-no-p-history"); @@ -4972,6 +5052,8 @@ defsubr (&Sstring_equal); defsubr (&Scompare_strings); defsubr (&Sstring_lessp); + defsubr (&Sstring_collate_lessp); + defsubr (&Sstring_collate_equalp); defsubr (&Sappend); defsubr (&Sconcat); defsubr (&Svconcat); === modified file 'src/sysdep.c' --- src/sysdep.c 2014-07-14 19:23:18 +0000 +++ src/sysdep.c 2014-08-24 15:40:07 +0000 @@ -3513,3 +3513,77 @@ } #endif /* !defined (WINDOWSNT) */ + +/* Wide character string collation. */ + +#ifdef __STDC_ISO_10646__ +#include + +#if defined (HAVE_USELOCALE) || defined (HAVE_SETLOCALE) +#include +#endif /* HAVE_USELOCALE || HAVE_SETLOCALE */ + +ptrdiff_t +str_collate (Lisp_Object s1, Lisp_Object s2) +{ + register ptrdiff_t res, len, i, i_byte; + wchar_t *p1, *p2; + Lisp_Object lc_collate; +#ifdef HAVE_USELOCALE + locale_t loc = (locale_t) 0, oldloc = (locale_t) 0; +#elif defined (HAVE_SETLOCALE) + char *oldloc = NULL; +#endif /* HAVE_USELOCALE */ + + USE_SAFE_ALLOCA; + + /* Convert byte stream to code points. */ + len = SCHARS (s1); i = i_byte = 0; + p1 = (wchar_t *) SAFE_ALLOCA ((len+1) * (sizeof *p1)); + while (i < len) + FETCH_STRING_CHAR_ADVANCE (*(p1+i-1), s1, i, i_byte); + *(p1+len) = 0; + + len = SCHARS (s2); i = i_byte = 0; + p2 = (wchar_t *) SAFE_ALLOCA ((len+1) * (sizeof *p2)); + while (i < len) + FETCH_STRING_CHAR_ADVANCE (*(p2+i-1), s2, i, i_byte); + *(p2+len) = 0; + +#if defined (HAVE_USELOCALE) || defined (HAVE_SETLOCALE) + /* Create a new locale object, and set it. */ + lc_collate = + Fgetenv_internal (build_string ("LC_COLLATE"), Vprocess_environment); + +#ifdef HAVE_USELOCALE + if (STRINGP (lc_collate) + && (loc = newlocale (LC_COLLATE_MASK, SSDATA (lc_collate), (locale_t) 0))) + oldloc = uselocale (loc); +#elif defined (HAVE_SETLOCALE) + if (STRINGP (lc_collate)) + { + oldloc = xstrdup (setlocale (LC_COLLATE, NULL)); + setlocale (LC_COLLATE, SSDATA (lc_collate)); + } +#endif /* HAVE_USELOCALE */ +#endif /* HAVE_USELOCALE || HAVE_SETLOCALE */ + + res = wcscoll (p1, p2); + +#ifdef HAVE_USELOCALE + /* Free the locale object, and reset. */ + if (loc) + freelocale (loc); + if (oldloc) + uselocale (oldloc); +#elif defined (HAVE_SETLOCALE) + /* Restore the original locale. */ + if (oldloc) + setlocale (LC_COLLATE, oldloc); +#endif /* HAVE_USELOCALE */ + + /* Return result. */ + SAFE_FREE (); + return res; +} +#endif /* __STDC_ISO_10646__ */ ------------------------------------------------------------ revno: 117725 committer: Alan Mackenzie branch nick: trunk timestamp: Sat 2014-08-23 11:02:20 +0000 message: progmodes/cc-fonts.el (c-font-lock-declarators): Fix infinite loop, bug #18306. The bug was introduced on 2014-08-02. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-21 15:07:13 +0000 +++ lisp/ChangeLog 2014-08-23 11:02:20 +0000 @@ -1,3 +1,8 @@ +2014-08-23 Alan Mackenzie + + * progmodes/cc-fonts.el (c-font-lock-declarators): Fix infinite + loop, bug #18306. The bug was introduced on 2014-08-02. + 2014-08-21 Eli Zaretskii * textmodes/texnfo-upd.el (texinfo-specific-section-type): Don't === modified file 'lisp/progmodes/cc-fonts.el' --- lisp/progmodes/cc-fonts.el 2014-08-09 20:54:04 +0000 +++ lisp/progmodes/cc-fonts.el 2014-08-23 11:02:20 +0000 @@ -1116,14 +1116,11 @@ ;; initializing brace lists. (let (found) (while - (and (setq found - (c-syntactic-re-search-forward - "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t)) - (eq (char-before) ?\[)) - (backward-char) - (c-safe (c-forward-sexp 1)) - (setq found nil) - (setq brackets-after-id t)) + (and (setq found (c-syntactic-re-search-forward + "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t)) + (eq (char-before) ?\[) + (c-go-up-list-forward)) + (setq brackets-after-id t)) found)) (setq next-pos (match-beginning 0)