X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6d0703a01df1ece3fd9ba2a927913d1bcf10d549..9bf31d1d3f35880c652f76509d1e27d33e454121:/src/editfns.c diff --git a/src/editfns.c b/src/editfns.c index 6b0996d65e..0c01c748d2 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -216,6 +216,7 @@ tzlookup (Lisp_Object zone, bool settz) { block_input (); emacs_setenv_TZ (zone_string); + tzset (); timezone_t old_tz = local_tz; local_tz = new_tz; tzfree (old_tz); @@ -2176,17 +2177,16 @@ usage: (decode-time &optional TIME ZONE) */) } /* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that - the result is representable as an int. Assume OFFSET is small and - nonnegative. */ + the result is representable as an int. */ static int check_tm_member (Lisp_Object obj, int offset) { - EMACS_INT n; CHECK_NUMBER (obj); - n = XINT (obj); - if (! (INT_MIN + offset <= n && n - offset <= INT_MAX)) + EMACS_INT n = XINT (obj); + int result; + if (INT_SUBTRACT_WRAPV (n, offset, &result)) time_overflow (); - return n - offset; + return result; } DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, @@ -2459,23 +2459,24 @@ emacs_setenv_TZ (const char *tzstring) tzval[tzeqlen] = 0; } - if (new_tzvalbuf -#ifdef WINDOWSNT - /* MS-Windows implementation of 'putenv' copies the argument - string into a block it allocates, so modifying tzval string - does not change the environment. OTOH, the other threads run - by Emacs on MS-Windows never call 'xputenv' or 'putenv' or - 'unsetenv', so the original cause for the dicey in-place - modification technique doesn't exist there in the first - place. */ - || 1 + +#ifndef WINDOWSNT + /* Modifying *TZVAL merely requires calling tzset (which is the + caller's responsibility). However, modifying TZVAL requires + calling putenv; although this is not thread-safe, in practice this + runs only on startup when there is only one thread. */ + bool need_putenv = new_tzvalbuf; +#else + /* MS-Windows 'putenv' copies the argument string into a block it + allocates, so modifying *TZVAL will not change the environment. + However, the other threads run by Emacs on MS-Windows never call + 'xputenv' or 'putenv' or 'unsetenv', so the original cause for the + dicey in-place modification technique doesn't exist there in the + first place. */ + bool need_putenv = true; #endif - ) - { - /* Although this is not thread-safe, in practice this runs only - on startup when there is only one thread. */ - xputenv (tzval); - } + if (need_putenv) + xputenv (tzval); return 0; } @@ -3363,7 +3364,7 @@ It returns the number of characters changed. */) ptrdiff_t size; /* Size of translate table. */ ptrdiff_t pos, pos_byte, end_pos; bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); - bool string_multibyte IF_LINT (= 0); + bool string_multibyte UNINIT; validate_region (&start, &end); if (CHAR_TABLE_P (table)) @@ -3884,6 +3885,9 @@ precision specifier says how many decimal places to show; if zero, the decimal point itself is omitted. For %s and %S, the precision specifier truncates the string to the given width. +Text properties, if any, are copied from the format-string to the +produced text. + usage: (format STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { @@ -3918,7 +3922,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) ptrdiff_t bufsize = sizeof initial_buffer; ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1; char *p; - ptrdiff_t buf_save_value_index IF_LINT (= 0); + ptrdiff_t buf_save_value_index UNINIT; char *format, *end; ptrdiff_t nchars; /* When we make a multibyte string, we must pay attention to the @@ -4171,6 +4175,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) convbytes += padding; if (convbytes <= buf + bufsize - p) { + info[n].start = nchars; if (! minus_flag) { memset (p, ' ', padding); @@ -4189,9 +4194,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) nbytes, STRING_MULTIBYTE (args[n]), multibyte); - info[n].start = nchars; nchars += nchars_string; - info[n].end = nchars; if (minus_flag) { @@ -4199,6 +4202,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) p += padding; nchars += padding; } + info[n].end = nchars; /* If this argument has text properties, record where in the result string it appears. */ @@ -4416,6 +4420,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) exponent_bytes = src + sprintf_bytes - e; } + info[n].start = nchars; if (! minus_flag) { memset (p, ' ', padding); @@ -4438,9 +4443,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) memcpy (p, src, exponent_bytes); p += exponent_bytes; - info[n].start = nchars; nchars += leading_zeros + sprintf_bytes + trailing_zeros; - info[n].end = nchars; if (minus_flag) { @@ -4448,6 +4451,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) p += padding; nchars += padding; } + info[n].end = nchars; continue; }