Mercurial > emacs
comparison src/buffer.c @ 88354:8a0cda2f3c85
Include "character.h" instead of "charset.h", don't include
"coding.h".
(Fset_buffer_multibyte): Adjuted for UTF-8.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Fri, 01 Mar 2002 01:07:51 +0000 |
| parents | 7c5115d286df |
| children | 4e78ee207f40 |
comparison
equal
deleted
inserted
replaced
| 88353:8e996bb689ca | 88354:8a0cda2f3c85 |
|---|---|
| 43 #include "lisp.h" | 43 #include "lisp.h" |
| 44 #include "intervals.h" | 44 #include "intervals.h" |
| 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" |
| 52 #include "keyboard.h" | 52 #include "keyboard.h" |
| 53 #include "keymap.h" | 53 #include "keymap.h" |
| 2083 if (pos == Z) | 2083 if (pos == Z) |
| 2084 break; | 2084 break; |
| 2085 p = GAP_END_ADDR; | 2085 p = GAP_END_ADDR; |
| 2086 stop = Z; | 2086 stop = Z; |
| 2087 } | 2087 } |
| 2088 if (MULTIBYTE_STR_AS_UNIBYTE_P (p, bytes)) | 2088 if (ASCII_BYTE_P (*p)) |
| 2089 p += bytes, pos += bytes; | 2089 p++, pos++; |
| 2090 else | 2090 else if (CHAR_BYTE8_HEAD_P (*p)) |
| 2091 { | 2091 { |
| 2092 c = STRING_CHAR (p, stop - pos); | 2092 c = STRING_CHAR (p, stop - pos); |
| 2093 /* Delete all bytes for this 8-bit character but the | 2093 /* Delete all bytes for this 8-bit character but the |
| 2094 last one, and change the last one to the charcter | 2094 last one, and change the last one to the charcter |
| 2095 code. */ | 2095 code. */ |
| 2102 begv -= bytes; | 2102 begv -= bytes; |
| 2103 if (zv > pos) | 2103 if (zv > pos) |
| 2104 zv -= bytes; | 2104 zv -= bytes; |
| 2105 stop = Z; | 2105 stop = Z; |
| 2106 } | 2106 } |
| 2107 else | |
| 2108 { | |
| 2109 bytes = BYTES_BY_CHAR_HEAD (*p); | |
| 2110 p += bytes, pos += bytes; | |
| 2111 } | |
| 2107 } | 2112 } |
| 2108 if (narrowed) | 2113 if (narrowed) |
| 2109 Fnarrow_to_region (make_number (begv), make_number (zv)); | 2114 Fnarrow_to_region (make_number (begv), make_number (zv)); |
| 2110 } | 2115 } |
| 2111 else | 2116 else |
| 2112 { | 2117 { |
| 2113 int pt = PT; | 2118 int pt = PT; |
| 2114 int pos, stop; | 2119 int pos, stop; |
| 2115 unsigned char *p; | 2120 unsigned char *p, *pend; |
| 2116 | 2121 |
| 2117 /* Be sure not to have a multibyte sequence striding over the GAP. | 2122 /* Be sure not to have a multibyte sequence striding over the GAP. |
| 2118 Ex: We change this: "...abc\201 _GAP_ \241def..." | 2123 Ex: We change this: "...abc\302 _GAP_ \241def..." |
| 2119 to: "...abc _GAP_ \201\241def..." */ | 2124 to: "...abc _GAP_ \302\241def..." */ |
| 2120 | 2125 |
| 2121 if (GPT_BYTE > 1 && GPT_BYTE < Z_BYTE | 2126 if (GPT_BYTE > 1 && GPT_BYTE < Z_BYTE |
| 2122 && ! CHAR_HEAD_P (*(GAP_END_ADDR))) | 2127 && ! CHAR_HEAD_P (*(GAP_END_ADDR))) |
| 2123 { | 2128 { |
| 2124 unsigned char *p = GPT_ADDR - 1; | 2129 unsigned char *p = GPT_ADDR - 1; |
| 2135 /* Make the buffer contents valid as multibyte by converting | 2140 /* Make the buffer contents valid as multibyte by converting |
| 2136 8-bit characters to multibyte form. */ | 2141 8-bit characters to multibyte form. */ |
| 2137 pos = BEG; | 2142 pos = BEG; |
| 2138 stop = GPT; | 2143 stop = GPT; |
| 2139 p = BEG_ADDR; | 2144 p = BEG_ADDR; |
| 2145 pend = GPT_ADDR; | |
| 2140 while (1) | 2146 while (1) |
| 2141 { | 2147 { |
| 2142 int bytes; | 2148 int bytes; |
| 2143 | 2149 |
| 2144 if (pos == stop) | 2150 if (pos == stop) |
| 2145 { | 2151 { |
| 2146 if (pos == Z) | 2152 if (pos == Z) |
| 2147 break; | 2153 break; |
| 2148 p = GAP_END_ADDR; | 2154 p = GAP_END_ADDR; |
| 2155 pend = Z_ADDR; | |
| 2149 stop = Z; | 2156 stop = Z; |
| 2150 } | 2157 } |
| 2151 | 2158 |
| 2152 if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes)) | 2159 if ((bytes = MULTIBYTE_LENGTH (p, pend)) > 0) |
| 2153 p += bytes, pos += bytes; | 2160 p += bytes, pos += bytes; |
| 2154 else | 2161 else |
| 2155 { | 2162 { |
| 2156 unsigned char tmp[MAX_MULTIBYTE_LENGTH]; | 2163 unsigned char tmp[MAX_MULTIBYTE_LENGTH]; |
| 2157 | 2164 |
| 4258 #include <errno.h> | 4265 #include <errno.h> |
| 4259 | 4266 |
| 4260 #if MAP_ANON == 0 | 4267 #if MAP_ANON == 0 |
| 4261 #include <fcntl.h> | 4268 #include <fcntl.h> |
| 4262 #endif | 4269 #endif |
| 4263 | |
| 4264 #include "coding.h" | |
| 4265 | 4270 |
| 4266 | 4271 |
| 4267 /* Memory is allocated in regions which are mapped using mmap(2). | 4272 /* Memory is allocated in regions which are mapped using mmap(2). |
| 4268 The current implementation lets the system select mapped | 4273 The current implementation lets the system select mapped |
| 4269 addresses; we're not using MAP_FIXED in general, except when | 4274 addresses; we're not using MAP_FIXED in general, except when |
