diff options
| author | Kenichi Handa | 2003-09-08 12:53:41 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-09-08 12:53:41 +0000 |
| commit | 8f924df7df019cce90537647de2627581043b5c4 (patch) | |
| tree | 6c40bd05679425e710d6b2e5649eae3da5e40a52 /src/buffer.c | |
| parent | 463f5630a5e7cbe7f042bc1175d1fa1c4e98860f (diff) | |
| parent | 9d4807432a01f9b3cc519fcfa3ea92a70ffa7f43 (diff) | |
| download | emacs-8f924df7df019cce90537647de2627581043b5c4.tar.gz emacs-8f924df7df019cce90537647de2627581043b5c4.zip | |
*** empty log message ***
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/buffer.c b/src/buffer.c index 40ee3f071de..b7efdbe5504 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -45,7 +45,7 @@ extern int errno; | |||
| 45 | #include "window.h" | 45 | #include "window.h" |
| 46 | #include "commands.h" | 46 | #include "commands.h" |
| 47 | #include "buffer.h" | 47 | #include "buffer.h" |
| 48 | #include "charset.h" | 48 | #include "character.h" |
| 49 | #include "region-cache.h" | 49 | #include "region-cache.h" |
| 50 | #include "indent.h" | 50 | #include "indent.h" |
| 51 | #include "blockinput.h" | 51 | #include "blockinput.h" |
| @@ -186,6 +186,7 @@ static void free_buffer_text P_ ((struct buffer *b)); | |||
| 186 | static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *)); | 186 | static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *)); |
| 187 | static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT)); | 187 | static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT)); |
| 188 | 188 | ||
| 189 | extern char * emacs_strerror P_ ((int)); | ||
| 189 | 190 | ||
| 190 | /* For debugging; temporary. See set_buffer_internal. */ | 191 | /* For debugging; temporary. See set_buffer_internal. */ |
| 191 | /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ | 192 | /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ |
| @@ -2078,8 +2079,10 @@ DEFUN ("set-buffer-multibyte", Fset_buffer_multibyte, Sset_buffer_multibyte, | |||
| 2078 | doc: /* Set the multibyte flag of the current buffer to FLAG. | 2079 | doc: /* Set the multibyte flag of the current buffer to FLAG. |
| 2079 | If FLAG is t, this makes the buffer a multibyte buffer. | 2080 | If FLAG is t, this makes the buffer a multibyte buffer. |
| 2080 | If FLAG is nil, this makes the buffer a single-byte buffer. | 2081 | If FLAG is nil, this makes the buffer a single-byte buffer. |
| 2081 | The buffer contents remain unchanged as a sequence of bytes | 2082 | In these cases, the buffer contents remain unchanged as a sequence of |
| 2082 | but the contents viewed as characters do change. */) | 2083 | bytes but the contents viewed as characters do change. |
| 2084 | If FLAG is `to', this makes the buffer a multibyte buffer by changing | ||
| 2085 | all eight-bit bytes to eight-bit characters. */) | ||
| 2083 | (flag) | 2086 | (flag) |
| 2084 | Lisp_Object flag; | 2087 | Lisp_Object flag; |
| 2085 | { | 2088 | { |
| @@ -2149,11 +2152,11 @@ but the contents viewed as characters do change. */) | |||
| 2149 | p = GAP_END_ADDR; | 2152 | p = GAP_END_ADDR; |
| 2150 | stop = Z; | 2153 | stop = Z; |
| 2151 | } | 2154 | } |
| 2152 | if (MULTIBYTE_STR_AS_UNIBYTE_P (p, bytes)) | 2155 | if (ASCII_BYTE_P (*p)) |
| 2153 | p += bytes, pos += bytes; | 2156 | p++, pos++; |
| 2154 | else | 2157 | else if (CHAR_BYTE8_HEAD_P (*p)) |
| 2155 | { | 2158 | { |
| 2156 | c = STRING_CHAR (p, stop - pos); | 2159 | c = STRING_CHAR_AND_LENGTH (p, stop - pos, bytes); |
| 2157 | /* Delete all bytes for this 8-bit character but the | 2160 | /* Delete all bytes for this 8-bit character but the |
| 2158 | last one, and change the last one to the charcter | 2161 | last one, and change the last one to the charcter |
| 2159 | code. */ | 2162 | code. */ |
| @@ -2168,6 +2171,11 @@ but the contents viewed as characters do change. */) | |||
| 2168 | zv -= bytes; | 2171 | zv -= bytes; |
| 2169 | stop = Z; | 2172 | stop = Z; |
| 2170 | } | 2173 | } |
| 2174 | else | ||
| 2175 | { | ||
| 2176 | bytes = BYTES_BY_CHAR_HEAD (*p); | ||
| 2177 | p += bytes, pos += bytes; | ||
| 2178 | } | ||
| 2171 | } | 2179 | } |
| 2172 | if (narrowed) | 2180 | if (narrowed) |
| 2173 | Fnarrow_to_region (make_number (begv), make_number (zv)); | 2181 | Fnarrow_to_region (make_number (begv), make_number (zv)); |
| @@ -2176,13 +2184,14 @@ but the contents viewed as characters do change. */) | |||
| 2176 | { | 2184 | { |
| 2177 | int pt = PT; | 2185 | int pt = PT; |
| 2178 | int pos, stop; | 2186 | int pos, stop; |
| 2179 | unsigned char *p; | 2187 | unsigned char *p, *pend; |
| 2180 | 2188 | ||
| 2181 | /* Be sure not to have a multibyte sequence striding over the GAP. | 2189 | /* Be sure not to have a multibyte sequence striding over the GAP. |
| 2182 | Ex: We change this: "...abc\201 _GAP_ \241def..." | 2190 | Ex: We change this: "...abc\302 _GAP_ \241def..." |
| 2183 | to: "...abc _GAP_ \201\241def..." */ | 2191 | to: "...abc _GAP_ \302\241def..." */ |
| 2184 | 2192 | ||
| 2185 | if (GPT_BYTE > 1 && GPT_BYTE < Z_BYTE | 2193 | if (EQ (flag, Qt) |
| 2194 | && GPT_BYTE > 1 && GPT_BYTE < Z_BYTE | ||
| 2186 | && ! CHAR_HEAD_P (*(GAP_END_ADDR))) | 2195 | && ! CHAR_HEAD_P (*(GAP_END_ADDR))) |
| 2187 | { | 2196 | { |
| 2188 | unsigned char *p = GPT_ADDR - 1; | 2197 | unsigned char *p = GPT_ADDR - 1; |
| @@ -2201,6 +2210,7 @@ but the contents viewed as characters do change. */) | |||
| 2201 | pos = BEG; | 2210 | pos = BEG; |
| 2202 | stop = GPT; | 2211 | stop = GPT; |
| 2203 | p = BEG_ADDR; | 2212 | p = BEG_ADDR; |
| 2213 | pend = GPT_ADDR; | ||
| 2204 | while (1) | 2214 | while (1) |
| 2205 | { | 2215 | { |
| 2206 | int bytes; | 2216 | int bytes; |
| @@ -2210,16 +2220,21 @@ but the contents viewed as characters do change. */) | |||
| 2210 | if (pos == Z) | 2220 | if (pos == Z) |
| 2211 | break; | 2221 | break; |
| 2212 | p = GAP_END_ADDR; | 2222 | p = GAP_END_ADDR; |
| 2223 | pend = Z_ADDR; | ||
| 2213 | stop = Z; | 2224 | stop = Z; |
| 2214 | } | 2225 | } |
| 2215 | 2226 | ||
| 2216 | if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes)) | 2227 | if (ASCII_BYTE_P (*p)) |
| 2228 | p++, pos++; | ||
| 2229 | else if (EQ (flag, Qt) && (bytes = MULTIBYTE_LENGTH (p, pend)) > 0) | ||
| 2217 | p += bytes, pos += bytes; | 2230 | p += bytes, pos += bytes; |
| 2218 | else | 2231 | else |
| 2219 | { | 2232 | { |
| 2220 | unsigned char tmp[MAX_MULTIBYTE_LENGTH]; | 2233 | unsigned char tmp[MAX_MULTIBYTE_LENGTH]; |
| 2234 | int c; | ||
| 2221 | 2235 | ||
| 2222 | bytes = CHAR_STRING (*p, tmp); | 2236 | c = BYTE8_TO_CHAR (*p); |
| 2237 | bytes = CHAR_STRING (c, tmp); | ||
| 2223 | *p = tmp[0]; | 2238 | *p = tmp[0]; |
| 2224 | TEMP_SET_PT_BOTH (pos + 1, pos + 1); | 2239 | TEMP_SET_PT_BOTH (pos + 1, pos + 1); |
| 2225 | bytes--; | 2240 | bytes--; |
| @@ -2233,6 +2248,7 @@ but the contents viewed as characters do change. */) | |||
| 2233 | zv += bytes; | 2248 | zv += bytes; |
| 2234 | if (pos <= pt) | 2249 | if (pos <= pt) |
| 2235 | pt += bytes; | 2250 | pt += bytes; |
| 2251 | pend = Z_ADDR; | ||
| 2236 | stop = Z; | 2252 | stop = Z; |
| 2237 | } | 2253 | } |
| 2238 | } | 2254 | } |
| @@ -3741,15 +3757,13 @@ buffer. */) | |||
| 3741 | end = OVERLAY_END (overlay); | 3757 | end = OVERLAY_END (overlay); |
| 3742 | if (OVERLAY_POSITION (end) < b->overlay_center) | 3758 | if (OVERLAY_POSITION (end) < b->overlay_center) |
| 3743 | { | 3759 | { |
| 3744 | if (b->overlays_after) | 3760 | XOVERLAY (overlay)->next = b->overlays_after; |
| 3745 | XOVERLAY (overlay)->next = b->overlays_after; | 3761 | b->overlays_after = XOVERLAY (overlay); |
| 3746 | b->overlays_after = XOVERLAY (overlay); | ||
| 3747 | } | 3762 | } |
| 3748 | else | 3763 | else |
| 3749 | { | 3764 | { |
| 3750 | if (b->overlays_before) | 3765 | XOVERLAY (overlay)->next = b->overlays_before; |
| 3751 | XOVERLAY (overlay)->next = b->overlays_before; | 3766 | b->overlays_before = XOVERLAY (overlay); |
| 3752 | b->overlays_before = XOVERLAY (overlay); | ||
| 3753 | } | 3767 | } |
| 3754 | 3768 | ||
| 3755 | /* This puts it in the right list, and in the right order. */ | 3769 | /* This puts it in the right list, and in the right order. */ |