diff options
Diffstat (limited to 'src/casefiddle.c')
| -rw-r--r-- | src/casefiddle.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c index 30bb457b17d..b6551618b2f 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -33,9 +33,7 @@ enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; | |||
| 33 | Lisp_Object Qidentity; | 33 | Lisp_Object Qidentity; |
| 34 | 34 | ||
| 35 | Lisp_Object | 35 | Lisp_Object |
| 36 | casify_object (flag, obj) | 36 | casify_object (enum case_action flag, Lisp_Object obj) |
| 37 | enum case_action flag; | ||
| 38 | Lisp_Object obj; | ||
| 39 | { | 37 | { |
| 40 | register int c, c1; | 38 | register int c, c1; |
| 41 | register int inword = flag == CASE_DOWN; | 39 | register int inword = flag == CASE_DOWN; |
| @@ -130,7 +128,7 @@ casify_object (flag, obj) | |||
| 130 | unsigned char *old_dst = dst; | 128 | unsigned char *old_dst = dst; |
| 131 | o_size += o_size; /* Probably overkill, but extremely rare. */ | 129 | o_size += o_size; /* Probably overkill, but extremely rare. */ |
| 132 | SAFE_ALLOCA (dst, void *, o_size); | 130 | SAFE_ALLOCA (dst, void *, o_size); |
| 133 | bcopy (old_dst, dst, o - old_dst); | 131 | memcpy (dst, old_dst, o - old_dst); |
| 134 | o = dst + (o - old_dst); | 132 | o = dst + (o - old_dst); |
| 135 | } | 133 | } |
| 136 | c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len); | 134 | c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len); |
| @@ -155,8 +153,7 @@ DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0, | |||
| 155 | The argument may be a character or string. The result has the same type. | 153 | The argument may be a character or string. The result has the same type. |
| 156 | The argument object is not altered--the value is a copy. | 154 | The argument object is not altered--the value is a copy. |
| 157 | See also `capitalize', `downcase' and `upcase-initials'. */) | 155 | See also `capitalize', `downcase' and `upcase-initials'. */) |
| 158 | (obj) | 156 | (Lisp_Object obj) |
| 159 | Lisp_Object obj; | ||
| 160 | { | 157 | { |
| 161 | return casify_object (CASE_UP, obj); | 158 | return casify_object (CASE_UP, obj); |
| 162 | } | 159 | } |
| @@ -165,8 +162,7 @@ DEFUN ("downcase", Fdowncase, Sdowncase, 1, 1, 0, | |||
| 165 | doc: /* Convert argument to lower case and return that. | 162 | doc: /* Convert argument to lower case and return that. |
| 166 | The argument may be a character or string. The result has the same type. | 163 | The argument may be a character or string. The result has the same type. |
| 167 | The argument object is not altered--the value is a copy. */) | 164 | The argument object is not altered--the value is a copy. */) |
| 168 | (obj) | 165 | (Lisp_Object obj) |
| 169 | Lisp_Object obj; | ||
| 170 | { | 166 | { |
| 171 | return casify_object (CASE_DOWN, obj); | 167 | return casify_object (CASE_DOWN, obj); |
| 172 | } | 168 | } |
| @@ -177,8 +173,7 @@ This means that each word's first character is upper case | |||
| 177 | and the rest is lower case. | 173 | and the rest is lower case. |
| 178 | The argument may be a character or string. The result has the same type. | 174 | The argument may be a character or string. The result has the same type. |
| 179 | The argument object is not altered--the value is a copy. */) | 175 | The argument object is not altered--the value is a copy. */) |
| 180 | (obj) | 176 | (Lisp_Object obj) |
| 181 | Lisp_Object obj; | ||
| 182 | { | 177 | { |
| 183 | return casify_object (CASE_CAPITALIZE, obj); | 178 | return casify_object (CASE_CAPITALIZE, obj); |
| 184 | } | 179 | } |
| @@ -190,8 +185,7 @@ DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 1, 0, | |||
| 190 | Do not change the other letters of each word. | 185 | Do not change the other letters of each word. |
| 191 | The argument may be a character or string. The result has the same type. | 186 | The argument may be a character or string. The result has the same type. |
| 192 | The argument object is not altered--the value is a copy. */) | 187 | The argument object is not altered--the value is a copy. */) |
| 193 | (obj) | 188 | (Lisp_Object obj) |
| 194 | Lisp_Object obj; | ||
| 195 | { | 189 | { |
| 196 | return casify_object (CASE_CAPITALIZE_UP, obj); | 190 | return casify_object (CASE_CAPITALIZE_UP, obj); |
| 197 | } | 191 | } |
| @@ -200,9 +194,7 @@ The argument object is not altered--the value is a copy. */) | |||
| 200 | b and e specify range of buffer to operate on. */ | 194 | b and e specify range of buffer to operate on. */ |
| 201 | 195 | ||
| 202 | void | 196 | void |
| 203 | casify_region (flag, b, e) | 197 | casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) |
| 204 | enum case_action flag; | ||
| 205 | Lisp_Object b, e; | ||
| 206 | { | 198 | { |
| 207 | register int c; | 199 | register int c; |
| 208 | register int inword = flag == CASE_DOWN; | 200 | register int inword = flag == CASE_DOWN; |
| @@ -229,6 +221,8 @@ casify_region (flag, b, e) | |||
| 229 | start_byte = CHAR_TO_BYTE (start); | 221 | start_byte = CHAR_TO_BYTE (start); |
| 230 | end_byte = CHAR_TO_BYTE (end); | 222 | end_byte = CHAR_TO_BYTE (end); |
| 231 | 223 | ||
| 224 | SETUP_BUFFER_SYNTAX_TABLE(); /* For syntax_prefix_flag_p. */ | ||
| 225 | |||
| 232 | while (start < end) | 226 | while (start < end) |
| 233 | { | 227 | { |
| 234 | int c2, len; | 228 | int c2, len; |
| @@ -251,7 +245,8 @@ casify_region (flag, b, e) | |||
| 251 | && (!inword || flag != CASE_CAPITALIZE_UP)) | 245 | && (!inword || flag != CASE_CAPITALIZE_UP)) |
| 252 | c = UPCASE1 (c); | 246 | c = UPCASE1 (c); |
| 253 | if ((int) flag >= (int) CASE_CAPITALIZE) | 247 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 254 | inword = ((SYNTAX (c) == Sword) && (inword || !SYNTAX_PREFIX (c))); | 248 | inword = ((SYNTAX (c) == Sword) |
| 249 | && (inword || !syntax_prefix_flag_p (c))); | ||
| 255 | if (c != c2) | 250 | if (c != c2) |
| 256 | { | 251 | { |
| 257 | last = start; | 252 | last = start; |
| @@ -310,8 +305,7 @@ These arguments specify the starting and ending character numbers of | |||
| 310 | the region to operate on. When used as a command, the text between | 305 | the region to operate on. When used as a command, the text between |
| 311 | point and the mark is operated on. | 306 | point and the mark is operated on. |
| 312 | See also `capitalize-region'. */) | 307 | See also `capitalize-region'. */) |
| 313 | (beg, end) | 308 | (Lisp_Object beg, Lisp_Object end) |
| 314 | Lisp_Object beg, end; | ||
| 315 | { | 309 | { |
| 316 | casify_region (CASE_UP, beg, end); | 310 | casify_region (CASE_UP, beg, end); |
| 317 | return Qnil; | 311 | return Qnil; |
| @@ -322,8 +316,7 @@ DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r", | |||
| 322 | These arguments specify the starting and ending character numbers of | 316 | These arguments specify the starting and ending character numbers of |
| 323 | the region to operate on. When used as a command, the text between | 317 | the region to operate on. When used as a command, the text between |
| 324 | point and the mark is operated on. */) | 318 | point and the mark is operated on. */) |
| 325 | (beg, end) | 319 | (Lisp_Object beg, Lisp_Object end) |
| 326 | Lisp_Object beg, end; | ||
| 327 | { | 320 | { |
| 328 | casify_region (CASE_DOWN, beg, end); | 321 | casify_region (CASE_DOWN, beg, end); |
| 329 | return Qnil; | 322 | return Qnil; |
| @@ -335,8 +328,7 @@ Capitalized form means each word's first character is upper case | |||
| 335 | and the rest of it is lower case. | 328 | and the rest of it is lower case. |
| 336 | In programs, give two arguments, the starting and ending | 329 | In programs, give two arguments, the starting and ending |
| 337 | character positions to operate on. */) | 330 | character positions to operate on. */) |
| 338 | (beg, end) | 331 | (Lisp_Object beg, Lisp_Object end) |
| 339 | Lisp_Object beg, end; | ||
| 340 | { | 332 | { |
| 341 | casify_region (CASE_CAPITALIZE, beg, end); | 333 | casify_region (CASE_CAPITALIZE, beg, end); |
| 342 | return Qnil; | 334 | return Qnil; |
| @@ -350,17 +342,14 @@ DEFUN ("upcase-initials-region", Fupcase_initials_region, | |||
| 350 | Subsequent letters of each word are not changed. | 342 | Subsequent letters of each word are not changed. |
| 351 | In programs, give two arguments, the starting and ending | 343 | In programs, give two arguments, the starting and ending |
| 352 | character positions to operate on. */) | 344 | character positions to operate on. */) |
| 353 | (beg, end) | 345 | (Lisp_Object beg, Lisp_Object end) |
| 354 | Lisp_Object beg, end; | ||
| 355 | { | 346 | { |
| 356 | casify_region (CASE_CAPITALIZE_UP, beg, end); | 347 | casify_region (CASE_CAPITALIZE_UP, beg, end); |
| 357 | return Qnil; | 348 | return Qnil; |
| 358 | } | 349 | } |
| 359 | 350 | ||
| 360 | static Lisp_Object | 351 | static Lisp_Object |
| 361 | operate_on_word (arg, newpoint) | 352 | operate_on_word (Lisp_Object arg, EMACS_INT *newpoint) |
| 362 | Lisp_Object arg; | ||
| 363 | EMACS_INT *newpoint; | ||
| 364 | { | 353 | { |
| 365 | Lisp_Object val; | 354 | Lisp_Object val; |
| 366 | int farend; | 355 | int farend; |
| @@ -382,8 +371,7 @@ DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 1, "p", | |||
| 382 | doc: /* Convert following word (or ARG words) to upper case, moving over. | 371 | doc: /* Convert following word (or ARG words) to upper case, moving over. |
| 383 | With negative argument, convert previous words but do not move. | 372 | With negative argument, convert previous words but do not move. |
| 384 | See also `capitalize-word'. */) | 373 | See also `capitalize-word'. */) |
| 385 | (arg) | 374 | (Lisp_Object arg) |
| 386 | Lisp_Object arg; | ||
| 387 | { | 375 | { |
| 388 | Lisp_Object beg, end; | 376 | Lisp_Object beg, end; |
| 389 | EMACS_INT newpoint; | 377 | EMACS_INT newpoint; |
| @@ -397,8 +385,7 @@ See also `capitalize-word'. */) | |||
| 397 | DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 1, "p", | 385 | DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 1, "p", |
| 398 | doc: /* Convert following word (or ARG words) to lower case, moving over. | 386 | doc: /* Convert following word (or ARG words) to lower case, moving over. |
| 399 | With negative argument, convert previous words but do not move. */) | 387 | With negative argument, convert previous words but do not move. */) |
| 400 | (arg) | 388 | (Lisp_Object arg) |
| 401 | Lisp_Object arg; | ||
| 402 | { | 389 | { |
| 403 | Lisp_Object beg, end; | 390 | Lisp_Object beg, end; |
| 404 | EMACS_INT newpoint; | 391 | EMACS_INT newpoint; |
| @@ -414,8 +401,7 @@ DEFUN ("capitalize-word", Fcapitalize_word, Scapitalize_word, 1, 1, "p", | |||
| 414 | This gives the word(s) a first character in upper case | 401 | This gives the word(s) a first character in upper case |
| 415 | and the rest lower case. | 402 | and the rest lower case. |
| 416 | With negative argument, capitalize previous words but do not move. */) | 403 | With negative argument, capitalize previous words but do not move. */) |
| 417 | (arg) | 404 | (Lisp_Object arg) |
| 418 | Lisp_Object arg; | ||
| 419 | { | 405 | { |
| 420 | Lisp_Object beg, end; | 406 | Lisp_Object beg, end; |
| 421 | EMACS_INT newpoint; | 407 | EMACS_INT newpoint; |
| @@ -427,7 +413,7 @@ With negative argument, capitalize previous words but do not move. */) | |||
| 427 | } | 413 | } |
| 428 | 414 | ||
| 429 | void | 415 | void |
| 430 | syms_of_casefiddle () | 416 | syms_of_casefiddle (void) |
| 431 | { | 417 | { |
| 432 | Qidentity = intern_c_string ("identity"); | 418 | Qidentity = intern_c_string ("identity"); |
| 433 | staticpro (&Qidentity); | 419 | staticpro (&Qidentity); |
| @@ -445,7 +431,7 @@ syms_of_casefiddle () | |||
| 445 | } | 431 | } |
| 446 | 432 | ||
| 447 | void | 433 | void |
| 448 | keys_of_casefiddle () | 434 | keys_of_casefiddle (void) |
| 449 | { | 435 | { |
| 450 | initial_define_key (control_x_map, Ctl('U'), "upcase-region"); | 436 | initial_define_key (control_x_map, Ctl('U'), "upcase-region"); |
| 451 | Fput (intern ("upcase-region"), Qdisabled, Qt); | 437 | Fput (intern ("upcase-region"), Qdisabled, Qt); |