diff options
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 302 |
1 files changed, 142 insertions, 160 deletions
diff --git a/src/editfns.c b/src/editfns.c index 8122ffdd0d4..7d179c8566a 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -78,6 +78,15 @@ Lisp_Object Qfield; | |||
| 78 | 78 | ||
| 79 | static Lisp_Object Qboundary; | 79 | static Lisp_Object Qboundary; |
| 80 | 80 | ||
| 81 | /* The startup value of the TZ environment variable so it can be | ||
| 82 | restored if the user calls set-time-zone-rule with a nil | ||
| 83 | argument. If null, the TZ environment variable was unset. */ | ||
| 84 | static char const *initial_tz; | ||
| 85 | |||
| 86 | /* True if the static variable tzvalbuf (defined in | ||
| 87 | set_time_zone_rule) is part of 'environ'. */ | ||
| 88 | static bool tzvalbuf_in_environ; | ||
| 89 | |||
| 81 | 90 | ||
| 82 | void | 91 | void |
| 83 | init_editfns (void) | 92 | init_editfns (void) |
| @@ -96,6 +105,9 @@ init_editfns (void) | |||
| 96 | return; | 105 | return; |
| 97 | #endif /* not CANNOT_DUMP */ | 106 | #endif /* not CANNOT_DUMP */ |
| 98 | 107 | ||
| 108 | initial_tz = getenv ("TZ"); | ||
| 109 | tzvalbuf_in_environ = 0; | ||
| 110 | |||
| 99 | pw = getpwuid (getuid ()); | 111 | pw = getpwuid (getuid ()); |
| 100 | #ifdef MSDOS | 112 | #ifdef MSDOS |
| 101 | /* We let the real user name default to "root" because that's quite | 113 | /* We let the real user name default to "root" because that's quite |
| @@ -813,38 +825,43 @@ This function does not move point. */) | |||
| 813 | Qnil, Qt, Qnil); | 825 | Qnil, Qt, Qnil); |
| 814 | } | 826 | } |
| 815 | 827 | ||
| 816 | 828 | /* Save current buffer state for `save-excursion' special form. | |
| 829 | We (ab)use Lisp_Misc_Save_Value to allow explicit free and so | ||
| 830 | offload some work from GC. */ | ||
| 831 | |||
| 817 | Lisp_Object | 832 | Lisp_Object |
| 818 | save_excursion_save (void) | 833 | save_excursion_save (void) |
| 819 | { | 834 | { |
| 820 | bool visible = (XBUFFER (XWINDOW (selected_window)->buffer) | 835 | Lisp_Object save, *data = xmalloc (word_size * 4); |
| 821 | == current_buffer); | 836 | |
| 837 | data[0] = Fpoint_marker (); | ||
| 822 | /* Do not copy the mark if it points to nowhere. */ | 838 | /* Do not copy the mark if it points to nowhere. */ |
| 823 | Lisp_Object mark = (XMARKER (BVAR (current_buffer, mark))->buffer | 839 | data[1] = (XMARKER (BVAR (current_buffer, mark))->buffer |
| 824 | ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) | 840 | ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) |
| 825 | : Qnil); | 841 | : Qnil); |
| 826 | 842 | /* Selected window if current buffer is shown in it, nil otherwise. */ | |
| 827 | return Fcons (Fpoint_marker (), | 843 | data[2] = ((XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) |
| 828 | Fcons (mark, | 844 | ? selected_window : Qnil); |
| 829 | Fcons (visible ? Qt : Qnil, | 845 | data[3] = BVAR (current_buffer, mark_active); |
| 830 | Fcons (BVAR (current_buffer, mark_active), | 846 | |
| 831 | selected_window)))); | 847 | save = make_save_value (data, 4); |
| 848 | XSAVE_VALUE (save)->dogc = 1; | ||
| 849 | return save; | ||
| 832 | } | 850 | } |
| 833 | 851 | ||
| 852 | /* Restore saved buffer before leaving `save-excursion' special form. */ | ||
| 853 | |||
| 834 | Lisp_Object | 854 | Lisp_Object |
| 835 | save_excursion_restore (Lisp_Object info) | 855 | save_excursion_restore (Lisp_Object info) |
| 836 | { | 856 | { |
| 837 | Lisp_Object tem, tem1, omark, nmark; | 857 | Lisp_Object tem, tem1, omark, nmark, *data = XSAVE_VALUE (info)->pointer; |
| 838 | struct gcpro gcpro1, gcpro2, gcpro3; | 858 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 839 | bool visible_p; | ||
| 840 | 859 | ||
| 841 | tem = Fmarker_buffer (XCAR (info)); | 860 | tem = Fmarker_buffer (data[0]); |
| 842 | /* If buffer being returned to is now deleted, avoid error */ | 861 | /* If we're unwinding to top level, saved buffer may be deleted. This |
| 843 | /* Otherwise could get error here while unwinding to top level | 862 | means that all of its markers are unchained and so tem is nil. */ |
| 844 | and crash */ | ||
| 845 | /* In that case, Fmarker_buffer returns nil now. */ | ||
| 846 | if (NILP (tem)) | 863 | if (NILP (tem)) |
| 847 | return Qnil; | 864 | goto out; |
| 848 | 865 | ||
| 849 | omark = nmark = Qnil; | 866 | omark = nmark = Qnil; |
| 850 | GCPRO3 (info, omark, nmark); | 867 | GCPRO3 (info, omark, nmark); |
| @@ -852,13 +869,12 @@ save_excursion_restore (Lisp_Object info) | |||
| 852 | Fset_buffer (tem); | 869 | Fset_buffer (tem); |
| 853 | 870 | ||
| 854 | /* Point marker. */ | 871 | /* Point marker. */ |
| 855 | tem = XCAR (info); | 872 | tem = data[0]; |
| 856 | Fgoto_char (tem); | 873 | Fgoto_char (tem); |
| 857 | unchain_marker (XMARKER (tem)); | 874 | unchain_marker (XMARKER (tem)); |
| 858 | 875 | ||
| 859 | /* Mark marker. */ | 876 | /* Mark marker. */ |
| 860 | info = XCDR (info); | 877 | tem = data[1]; |
| 861 | tem = XCAR (info); | ||
| 862 | omark = Fmarker_position (BVAR (current_buffer, mark)); | 878 | omark = Fmarker_position (BVAR (current_buffer, mark)); |
| 863 | if (NILP (tem)) | 879 | if (NILP (tem)) |
| 864 | unchain_marker (XMARKER (BVAR (current_buffer, mark))); | 880 | unchain_marker (XMARKER (BVAR (current_buffer, mark))); |
| @@ -869,23 +885,8 @@ save_excursion_restore (Lisp_Object info) | |||
| 869 | unchain_marker (XMARKER (tem)); | 885 | unchain_marker (XMARKER (tem)); |
| 870 | } | 886 | } |
| 871 | 887 | ||
| 872 | /* visible */ | 888 | /* Mark active. */ |
| 873 | info = XCDR (info); | 889 | tem = data[3]; |
| 874 | visible_p = !NILP (XCAR (info)); | ||
| 875 | |||
| 876 | #if 0 /* We used to make the current buffer visible in the selected window | ||
| 877 | if that was true previously. That avoids some anomalies. | ||
| 878 | But it creates others, and it wasn't documented, and it is simpler | ||
| 879 | and cleaner never to alter the window/buffer connections. */ | ||
| 880 | tem1 = Fcar (tem); | ||
| 881 | if (!NILP (tem1) | ||
| 882 | && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) | ||
| 883 | Fswitch_to_buffer (Fcurrent_buffer (), Qnil); | ||
| 884 | #endif /* 0 */ | ||
| 885 | |||
| 886 | /* Mark active */ | ||
| 887 | info = XCDR (info); | ||
| 888 | tem = XCAR (info); | ||
| 889 | tem1 = BVAR (current_buffer, mark_active); | 890 | tem1 = BVAR (current_buffer, mark_active); |
| 890 | bset_mark_active (current_buffer, tem); | 891 | bset_mark_active (current_buffer, tem); |
| 891 | 892 | ||
| @@ -909,8 +910,8 @@ save_excursion_restore (Lisp_Object info) | |||
| 909 | /* If buffer was visible in a window, and a different window was | 910 | /* If buffer was visible in a window, and a different window was |
| 910 | selected, and the old selected window is still showing this | 911 | selected, and the old selected window is still showing this |
| 911 | buffer, restore point in that window. */ | 912 | buffer, restore point in that window. */ |
| 912 | tem = XCDR (info); | 913 | tem = data[2]; |
| 913 | if (visible_p | 914 | if (WINDOWP (tem) |
| 914 | && !EQ (tem, selected_window) | 915 | && !EQ (tem, selected_window) |
| 915 | && (tem1 = XWINDOW (tem)->buffer, | 916 | && (tem1 = XWINDOW (tem)->buffer, |
| 916 | (/* Window is live... */ | 917 | (/* Window is live... */ |
| @@ -920,6 +921,10 @@ save_excursion_restore (Lisp_Object info) | |||
| 920 | Fset_window_point (tem, make_number (PT)); | 921 | Fset_window_point (tem, make_number (PT)); |
| 921 | 922 | ||
| 922 | UNGCPRO; | 923 | UNGCPRO; |
| 924 | |||
| 925 | out: | ||
| 926 | |||
| 927 | free_save_value (info); | ||
| 923 | return Qnil; | 928 | return Qnil; |
| 924 | } | 929 | } |
| 925 | 930 | ||
| @@ -1907,9 +1912,11 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1907 | } | 1912 | } |
| 1908 | else | 1913 | else |
| 1909 | { | 1914 | { |
| 1910 | char tzbuf[100]; | 1915 | static char const tzbuf_format[] = "XXX%s%"pI"d:%02d:%02d"; |
| 1916 | char tzbuf[sizeof tzbuf_format + INT_STRLEN_BOUND (EMACS_INT)]; | ||
| 1917 | char *old_tzstring; | ||
| 1911 | const char *tzstring; | 1918 | const char *tzstring; |
| 1912 | char **oldenv = environ, **newenv; | 1919 | USE_SAFE_ALLOCA; |
| 1913 | 1920 | ||
| 1914 | if (EQ (zone, Qt)) | 1921 | if (EQ (zone, Qt)) |
| 1915 | tzstring = "UTC0"; | 1922 | tzstring = "UTC0"; |
| @@ -1921,13 +1928,20 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1921 | EMACS_INT zone_hr = abszone / (60*60); | 1928 | EMACS_INT zone_hr = abszone / (60*60); |
| 1922 | int zone_min = (abszone/60) % 60; | 1929 | int zone_min = (abszone/60) % 60; |
| 1923 | int zone_sec = abszone % 60; | 1930 | int zone_sec = abszone % 60; |
| 1924 | sprintf (tzbuf, "XXX%s%"pI"d:%02d:%02d", "-" + (XINT (zone) < 0), | 1931 | sprintf (tzbuf, tzbuf_format, "-" + (XINT (zone) < 0), |
| 1925 | zone_hr, zone_min, zone_sec); | 1932 | zone_hr, zone_min, zone_sec); |
| 1926 | tzstring = tzbuf; | 1933 | tzstring = tzbuf; |
| 1927 | } | 1934 | } |
| 1928 | else | 1935 | else |
| 1929 | error ("Invalid time zone specification"); | 1936 | error ("Invalid time zone specification"); |
| 1930 | 1937 | ||
| 1938 | old_tzstring = getenv ("TZ"); | ||
| 1939 | if (old_tzstring) | ||
| 1940 | { | ||
| 1941 | char *buf = SAFE_ALLOCA (strlen (old_tzstring) + 1); | ||
| 1942 | old_tzstring = strcpy (buf, old_tzstring); | ||
| 1943 | } | ||
| 1944 | |||
| 1931 | block_input (); | 1945 | block_input (); |
| 1932 | 1946 | ||
| 1933 | /* Set TZ before calling mktime; merely adjusting mktime's returned | 1947 | /* Set TZ before calling mktime; merely adjusting mktime's returned |
| @@ -1936,15 +1950,12 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1936 | 1950 | ||
| 1937 | value = mktime (&tm); | 1951 | value = mktime (&tm); |
| 1938 | 1952 | ||
| 1939 | /* Restore TZ to previous value. */ | 1953 | set_time_zone_rule (old_tzstring); |
| 1940 | newenv = environ; | ||
| 1941 | environ = oldenv; | ||
| 1942 | #ifdef LOCALTIME_CACHE | 1954 | #ifdef LOCALTIME_CACHE |
| 1943 | tzset (); | 1955 | tzset (); |
| 1944 | #endif | 1956 | #endif |
| 1945 | unblock_input (); | 1957 | unblock_input (); |
| 1946 | 1958 | SAFE_FREE (); | |
| 1947 | xfree (newenv); | ||
| 1948 | } | 1959 | } |
| 1949 | 1960 | ||
| 1950 | if (value == (time_t) -1) | 1961 | if (value == (time_t) -1) |
| @@ -2074,16 +2085,6 @@ the data it can't find. */) | |||
| 2074 | return list2 (zone_offset, zone_name); | 2085 | return list2 (zone_offset, zone_name); |
| 2075 | } | 2086 | } |
| 2076 | 2087 | ||
| 2077 | /* This holds the value of `environ' produced by the previous | ||
| 2078 | call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule | ||
| 2079 | has never been called. */ | ||
| 2080 | static char **environbuf; | ||
| 2081 | |||
| 2082 | /* This holds the startup value of the TZ environment variable so it | ||
| 2083 | can be restored if the user calls set-time-zone-rule with a nil | ||
| 2084 | argument. */ | ||
| 2085 | static char *initial_tz; | ||
| 2086 | |||
| 2087 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, | 2088 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, |
| 2088 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. | 2089 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. |
| 2089 | If TZ is nil, use implementation-defined default time zone information. | 2090 | If TZ is nil, use implementation-defined default time zone information. |
| @@ -2096,18 +2097,10 @@ only the former. */) | |||
| 2096 | (Lisp_Object tz) | 2097 | (Lisp_Object tz) |
| 2097 | { | 2098 | { |
| 2098 | const char *tzstring; | 2099 | const char *tzstring; |
| 2099 | char **old_environbuf; | ||
| 2100 | 2100 | ||
| 2101 | if (! (NILP (tz) || EQ (tz, Qt))) | 2101 | if (! (NILP (tz) || EQ (tz, Qt))) |
| 2102 | CHECK_STRING (tz); | 2102 | CHECK_STRING (tz); |
| 2103 | 2103 | ||
| 2104 | block_input (); | ||
| 2105 | |||
| 2106 | /* When called for the first time, save the original TZ. */ | ||
| 2107 | old_environbuf = environbuf; | ||
| 2108 | if (!old_environbuf) | ||
| 2109 | initial_tz = (char *) getenv ("TZ"); | ||
| 2110 | |||
| 2111 | if (NILP (tz)) | 2104 | if (NILP (tz)) |
| 2112 | tzstring = initial_tz; | 2105 | tzstring = initial_tz; |
| 2113 | else if (EQ (tz, Qt)) | 2106 | else if (EQ (tz, Qt)) |
| @@ -2115,106 +2108,97 @@ only the former. */) | |||
| 2115 | else | 2108 | else |
| 2116 | tzstring = SSDATA (tz); | 2109 | tzstring = SSDATA (tz); |
| 2117 | 2110 | ||
| 2111 | block_input (); | ||
| 2118 | set_time_zone_rule (tzstring); | 2112 | set_time_zone_rule (tzstring); |
| 2119 | environbuf = environ; | ||
| 2120 | |||
| 2121 | unblock_input (); | 2113 | unblock_input (); |
| 2122 | 2114 | ||
| 2123 | xfree (old_environbuf); | ||
| 2124 | return Qnil; | 2115 | return Qnil; |
| 2125 | } | 2116 | } |
| 2126 | 2117 | ||
| 2127 | #ifdef LOCALTIME_CACHE | ||
| 2128 | |||
| 2129 | /* These two values are known to load tz files in buggy implementations, | ||
| 2130 | i.e. Solaris 1 executables running under either Solaris 1 or Solaris 2. | ||
| 2131 | Their values shouldn't matter in non-buggy implementations. | ||
| 2132 | We don't use string literals for these strings, | ||
| 2133 | since if a string in the environment is in readonly | ||
| 2134 | storage, it runs afoul of bugs in SVR4 and Solaris 2.3. | ||
| 2135 | See Sun bugs 1113095 and 1114114, ``Timezone routines | ||
| 2136 | improperly modify environment''. */ | ||
| 2137 | |||
| 2138 | static char set_time_zone_rule_tz1[] = "TZ=GMT+0"; | ||
| 2139 | static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; | ||
| 2140 | |||
| 2141 | #endif | ||
| 2142 | |||
| 2143 | /* Set the local time zone rule to TZSTRING. | 2118 | /* Set the local time zone rule to TZSTRING. |
| 2144 | This allocates memory into `environ', which it is the caller's | 2119 | |
| 2145 | responsibility to free. */ | 2120 | This function is not thread-safe, partly because putenv, unsetenv |
| 2121 | and tzset are not, and partly because of the static storage it | ||
| 2122 | updates. Other threads that invoke localtime etc. may be adversely | ||
| 2123 | affected while this function is executing. */ | ||
| 2146 | 2124 | ||
| 2147 | void | 2125 | void |
| 2148 | set_time_zone_rule (const char *tzstring) | 2126 | set_time_zone_rule (const char *tzstring) |
| 2149 | { | 2127 | { |
| 2150 | ptrdiff_t envptrs; | 2128 | /* A buffer holding a string of the form "TZ=value", intended |
| 2151 | char **from, **to, **newenv; | 2129 | to be part of the environment. */ |
| 2130 | static char *tzvalbuf; | ||
| 2131 | static ptrdiff_t tzvalbufsize; | ||
| 2152 | 2132 | ||
| 2153 | /* Make the ENVIRON vector longer with room for TZSTRING. */ | 2133 | int tzeqlen = sizeof "TZ=" - 1; |
| 2154 | for (from = environ; *from; from++) | 2134 | |
| 2155 | continue; | 2135 | #ifdef LOCALTIME_CACHE |
| 2156 | envptrs = from - environ + 2; | 2136 | /* These two values are known to load tz files in buggy implementations, |
| 2157 | newenv = to = xmalloc (envptrs * sizeof *newenv | 2137 | i.e., Solaris 1 executables running under either Solaris 1 or Solaris 2. |
| 2158 | + (tzstring ? strlen (tzstring) + 4 : 0)); | 2138 | Their values shouldn't matter in non-buggy implementations. |
| 2139 | We don't use string literals for these strings, | ||
| 2140 | since if a string in the environment is in readonly | ||
| 2141 | storage, it runs afoul of bugs in SVR4 and Solaris 2.3. | ||
| 2142 | See Sun bugs 1113095 and 1114114, ``Timezone routines | ||
| 2143 | improperly modify environment''. */ | ||
| 2144 | |||
| 2145 | static char set_time_zone_rule_tz[][sizeof "TZ=GMT+0"] | ||
| 2146 | = { "TZ=GMT+0", "TZ=GMT+1" }; | ||
| 2147 | |||
| 2148 | /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like | ||
| 2149 | "US/Pacific" that loads a tz file, then changes to a value like | ||
| 2150 | "XXX0" that does not load a tz file, and then changes back to | ||
| 2151 | its original value, the last change is (incorrectly) ignored. | ||
| 2152 | Also, if TZ changes twice in succession to values that do | ||
| 2153 | not load a tz file, tzset can dump core (see Sun bug#1225179). | ||
| 2154 | The following code works around these bugs. */ | ||
| 2159 | 2155 | ||
| 2160 | /* Add TZSTRING to the end of environ, as a value for TZ. */ | ||
| 2161 | if (tzstring) | 2156 | if (tzstring) |
| 2162 | { | 2157 | { |
| 2163 | char *t = (char *) (to + envptrs); | 2158 | /* Temporarily set TZ to a value that loads a tz file |
| 2164 | strcpy (t, "TZ="); | 2159 | and that differs from tzstring. */ |
| 2165 | strcat (t, tzstring); | 2160 | bool eq0 = strcmp (tzstring, set_time_zone_rule_tz[0] + tzeqlen) == 0; |
| 2166 | *to++ = t; | 2161 | xputenv (set_time_zone_rule_tz[eq0]); |
| 2167 | } | 2162 | } |
| 2163 | else | ||
| 2164 | { | ||
| 2165 | /* The implied tzstring is unknown, so temporarily set TZ to | ||
| 2166 | two different values that each load a tz file. */ | ||
| 2167 | xputenv (set_time_zone_rule_tz[0]); | ||
| 2168 | tzset (); | ||
| 2169 | xputenv (set_time_zone_rule_tz[1]); | ||
| 2170 | } | ||
| 2171 | tzset (); | ||
| 2172 | #endif | ||
| 2168 | 2173 | ||
| 2169 | /* Copy the old environ vector elements into NEWENV, | 2174 | if (!tzstring) |
| 2170 | but don't copy the TZ variable. | 2175 | { |
| 2171 | So we have only one definition of TZ, which came from TZSTRING. */ | 2176 | unsetenv ("TZ"); |
| 2172 | for (from = environ; *from; from++) | 2177 | tzvalbuf_in_environ = 0; |
| 2173 | if (strncmp (*from, "TZ=", 3) != 0) | 2178 | } |
| 2174 | *to++ = *from; | 2179 | else |
| 2175 | *to = 0; | 2180 | { |
| 2176 | 2181 | ptrdiff_t tzstringlen = strlen (tzstring); | |
| 2177 | environ = newenv; | ||
| 2178 | 2182 | ||
| 2179 | /* If we do have a TZSTRING, NEWENV points to the vector slot where | 2183 | if (tzvalbufsize <= tzeqlen + tzstringlen) |
| 2180 | the TZ variable is stored. If we do not have a TZSTRING, | 2184 | { |
| 2181 | TO points to the vector slot which has the terminating null. */ | 2185 | unsetenv ("TZ"); |
| 2186 | tzvalbuf_in_environ = 0; | ||
| 2187 | tzvalbuf = xpalloc (tzvalbuf, &tzvalbufsize, | ||
| 2188 | tzeqlen + tzstringlen - tzvalbufsize + 1, -1, 1); | ||
| 2189 | memcpy (tzvalbuf, "TZ=", tzeqlen); | ||
| 2190 | } | ||
| 2182 | 2191 | ||
| 2183 | #ifdef LOCALTIME_CACHE | 2192 | strcpy (tzvalbuf + tzeqlen, tzstring); |
| 2184 | { | ||
| 2185 | /* In SunOS 4.1.3_U1 and 4.1.4, if TZ has a value like | ||
| 2186 | "US/Pacific" that loads a tz file, then changes to a value like | ||
| 2187 | "XXX0" that does not load a tz file, and then changes back to | ||
| 2188 | its original value, the last change is (incorrectly) ignored. | ||
| 2189 | Also, if TZ changes twice in succession to values that do | ||
| 2190 | not load a tz file, tzset can dump core (see Sun bug#1225179). | ||
| 2191 | The following code works around these bugs. */ | ||
| 2192 | |||
| 2193 | if (tzstring) | ||
| 2194 | { | ||
| 2195 | /* Temporarily set TZ to a value that loads a tz file | ||
| 2196 | and that differs from tzstring. */ | ||
| 2197 | char *tz = *newenv; | ||
| 2198 | *newenv = (strcmp (tzstring, set_time_zone_rule_tz1 + 3) == 0 | ||
| 2199 | ? set_time_zone_rule_tz2 : set_time_zone_rule_tz1); | ||
| 2200 | tzset (); | ||
| 2201 | *newenv = tz; | ||
| 2202 | } | ||
| 2203 | else | ||
| 2204 | { | ||
| 2205 | /* The implied tzstring is unknown, so temporarily set TZ to | ||
| 2206 | two different values that each load a tz file. */ | ||
| 2207 | *to = set_time_zone_rule_tz1; | ||
| 2208 | to[1] = 0; | ||
| 2209 | tzset (); | ||
| 2210 | *to = set_time_zone_rule_tz2; | ||
| 2211 | tzset (); | ||
| 2212 | *to = 0; | ||
| 2213 | } | ||
| 2214 | 2193 | ||
| 2215 | /* Now TZ has the desired value, and tzset can be invoked safely. */ | 2194 | if (!tzvalbuf_in_environ) |
| 2216 | } | 2195 | { |
| 2196 | xputenv (tzvalbuf); | ||
| 2197 | tzvalbuf_in_environ = 1; | ||
| 2198 | } | ||
| 2199 | } | ||
| 2217 | 2200 | ||
| 2201 | #ifdef LOCALTIME_CACHE | ||
| 2218 | tzset (); | 2202 | tzset (); |
| 2219 | #endif | 2203 | #endif |
| 2220 | } | 2204 | } |
| @@ -2358,9 +2342,10 @@ usage: (insert-before-markers-and-inherit &rest ARGS) */) | |||
| 2358 | } | 2342 | } |
| 2359 | 2343 | ||
| 2360 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, | 2344 | DEFUN ("insert-char", Finsert_char, Sinsert_char, 1, 3, |
| 2361 | "(list (read-char-by-name \"Insert character (Unicode name or hex): \")\ | 2345 | "(list (or (read-char-by-name \"Insert character (Unicode name or hex): \")\ |
| 2362 | (prefix-numeric-value current-prefix-arg)\ | 2346 | (error \"You did not specify a valid character\"))\ |
| 2363 | t))", | 2347 | (prefix-numeric-value current-prefix-arg)\ |
| 2348 | t))", | ||
| 2364 | doc: /* Insert COUNT copies of CHARACTER. | 2349 | doc: /* Insert COUNT copies of CHARACTER. |
| 2365 | Interactively, prompt for CHARACTER. You can specify CHARACTER in one | 2350 | Interactively, prompt for CHARACTER. You can specify CHARACTER in one |
| 2366 | of these ways: | 2351 | of these ways: |
| @@ -2929,7 +2914,7 @@ Both characters must have the same length of multi-byte form. */) | |||
| 2929 | else if (!changed) | 2914 | else if (!changed) |
| 2930 | { | 2915 | { |
| 2931 | changed = -1; | 2916 | changed = -1; |
| 2932 | modify_region (current_buffer, pos, XINT (end), 0); | 2917 | modify_region_1 (pos, XINT (end), false); |
| 2933 | 2918 | ||
| 2934 | if (! NILP (noundo)) | 2919 | if (! NILP (noundo)) |
| 2935 | { | 2920 | { |
| @@ -3105,7 +3090,7 @@ It returns the number of characters changed. */) | |||
| 3105 | pos = XINT (start); | 3090 | pos = XINT (start); |
| 3106 | pos_byte = CHAR_TO_BYTE (pos); | 3091 | pos_byte = CHAR_TO_BYTE (pos); |
| 3107 | end_pos = XINT (end); | 3092 | end_pos = XINT (end); |
| 3108 | modify_region (current_buffer, pos, end_pos, 0); | 3093 | modify_region_1 (pos, end_pos, false); |
| 3109 | 3094 | ||
| 3110 | cnt = 0; | 3095 | cnt = 0; |
| 3111 | for (; pos < end_pos; ) | 3096 | for (; pos < end_pos; ) |
| @@ -4629,7 +4614,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4629 | 4614 | ||
| 4630 | if (end1 == start2) /* adjacent regions */ | 4615 | if (end1 == start2) /* adjacent regions */ |
| 4631 | { | 4616 | { |
| 4632 | modify_region (current_buffer, start1, end2, 0); | 4617 | modify_region_1 (start1, end2, false); |
| 4633 | record_change (start1, len1 + len2); | 4618 | record_change (start1, len1 + len2); |
| 4634 | 4619 | ||
| 4635 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4620 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| @@ -4688,8 +4673,8 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4688 | { | 4673 | { |
| 4689 | USE_SAFE_ALLOCA; | 4674 | USE_SAFE_ALLOCA; |
| 4690 | 4675 | ||
| 4691 | modify_region (current_buffer, start1, end1, 0); | 4676 | modify_region_1 (start1, end1, false); |
| 4692 | modify_region (current_buffer, start2, end2, 0); | 4677 | modify_region_1 (start2, end2, false); |
| 4693 | record_change (start1, len1); | 4678 | record_change (start1, len1); |
| 4694 | record_change (start2, len2); | 4679 | record_change (start2, len2); |
| 4695 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4680 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| @@ -4722,7 +4707,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4722 | { | 4707 | { |
| 4723 | USE_SAFE_ALLOCA; | 4708 | USE_SAFE_ALLOCA; |
| 4724 | 4709 | ||
| 4725 | modify_region (current_buffer, start1, end2, 0); | 4710 | modify_region_1 (start1, end2, false); |
| 4726 | record_change (start1, (end2 - start1)); | 4711 | record_change (start1, (end2 - start1)); |
| 4727 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4712 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| 4728 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); | 4713 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
| @@ -4755,7 +4740,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4755 | USE_SAFE_ALLOCA; | 4740 | USE_SAFE_ALLOCA; |
| 4756 | 4741 | ||
| 4757 | record_change (start1, (end2 - start1)); | 4742 | record_change (start1, (end2 - start1)); |
| 4758 | modify_region (current_buffer, start1, end2, 0); | 4743 | modify_region_1 (start1, end2, false); |
| 4759 | 4744 | ||
| 4760 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4745 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| 4761 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); | 4746 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
| @@ -4806,9 +4791,6 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4806 | void | 4791 | void |
| 4807 | syms_of_editfns (void) | 4792 | syms_of_editfns (void) |
| 4808 | { | 4793 | { |
| 4809 | environbuf = 0; | ||
| 4810 | initial_tz = 0; | ||
| 4811 | |||
| 4812 | DEFSYM (Qbuffer_access_fontify_functions, "buffer-access-fontify-functions"); | 4794 | DEFSYM (Qbuffer_access_fontify_functions, "buffer-access-fontify-functions"); |
| 4813 | 4795 | ||
| 4814 | DEFVAR_LISP ("inhibit-field-text-motion", Vinhibit_field_text_motion, | 4796 | DEFVAR_LISP ("inhibit-field-text-motion", Vinhibit_field_text_motion, |