Mercurial > hg > xemacs-beta
comparison src/buffer.h @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
196 0 means visited file modtime unknown; in no case complain | 196 0 means visited file modtime unknown; in no case complain |
197 about any mismatch on next save attempt. */ | 197 about any mismatch on next save attempt. */ |
198 int modtime; | 198 int modtime; |
199 | 199 |
200 /* the value of text->modiff at the last auto-save. */ | 200 /* the value of text->modiff at the last auto-save. */ |
201 int auto_save_modified; | 201 long auto_save_modified; |
202 | 202 |
203 /* The time at which we detected a failure to auto-save, | 203 /* The time at which we detected a failure to auto-save, |
204 Or -1 if we didn't have a failure. */ | 204 Or -1 if we didn't have a failure. */ |
205 int auto_save_failure_time; | 205 int auto_save_failure_time; |
206 | 206 |
425 ASSERT_VALID_CHARPTR (ptr); \ | 425 ASSERT_VALID_CHARPTR (ptr); \ |
426 REAL_INC_CHARBYTIND (ptr,pos); \ | 426 REAL_INC_CHARBYTIND (ptr,pos); \ |
427 } while (0) | 427 } while (0) |
428 | 428 |
429 #define DEC_CHARPTR(ptr) do { \ | 429 #define DEC_CHARPTR(ptr) do { \ |
430 CONST Bufbyte *dc_ptr1 = (ptr); \ | 430 const Bufbyte *dc_ptr1 = (ptr); \ |
431 CONST Bufbyte *dc_ptr2 = dc_ptr1; \ | 431 const Bufbyte *dc_ptr2 = dc_ptr1; \ |
432 REAL_DEC_CHARPTR (dc_ptr2); \ | 432 REAL_DEC_CHARPTR (dc_ptr2); \ |
433 assert (dc_ptr1 - dc_ptr2 == \ | 433 assert (dc_ptr1 - dc_ptr2 == \ |
434 REP_BYTES_BY_FIRST_BYTE (*dc_ptr2)); \ | 434 REP_BYTES_BY_FIRST_BYTE (*dc_ptr2)); \ |
435 (ptr) = dc_ptr2; \ | 435 (ptr) = dc_ptr2; \ |
436 } while (0) | 436 } while (0) |
468 /* -------------------------------------------------------------- */ | 468 /* -------------------------------------------------------------- */ |
469 /* (B) For working with the length (in bytes and characters) of a */ | 469 /* (B) For working with the length (in bytes and characters) of a */ |
470 /* section of internally-formatted text */ | 470 /* section of internally-formatted text */ |
471 /* -------------------------------------------------------------- */ | 471 /* -------------------------------------------------------------- */ |
472 | 472 |
473 INLINE CONST Bufbyte *charptr_n_addr (CONST Bufbyte *ptr, Charcount offset); | 473 INLINE_HEADER const Bufbyte * |
474 INLINE CONST Bufbyte * | 474 charptr_n_addr (const Bufbyte *ptr, Charcount offset); |
475 charptr_n_addr (CONST Bufbyte *ptr, Charcount offset) | 475 INLINE_HEADER const Bufbyte * |
476 charptr_n_addr (const Bufbyte *ptr, Charcount offset) | |
476 { | 477 { |
477 return ptr + charcount_to_bytecount (ptr, offset); | 478 return ptr + charcount_to_bytecount (ptr, offset); |
478 } | 479 } |
479 | 480 |
480 /* -------------------------------------------------------------------- */ | 481 /* -------------------------------------------------------------------- */ |
485 #define simple_set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1) | 486 #define simple_set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1) |
486 #define simple_charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1) | 487 #define simple_charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1) |
487 | 488 |
488 #ifdef MULE | 489 #ifdef MULE |
489 | 490 |
490 Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr); | 491 Emchar non_ascii_charptr_emchar (const Bufbyte *ptr); |
491 Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c); | 492 Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c); |
492 Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2); | 493 Bytecount non_ascii_charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2); |
493 | 494 |
494 INLINE Emchar charptr_emchar (CONST Bufbyte *ptr); | 495 INLINE_HEADER Emchar charptr_emchar (const Bufbyte *ptr); |
495 INLINE Emchar | 496 INLINE_HEADER Emchar |
496 charptr_emchar (CONST Bufbyte *ptr) | 497 charptr_emchar (const Bufbyte *ptr) |
497 { | 498 { |
498 return BYTE_ASCII_P (*ptr) ? | 499 return BYTE_ASCII_P (*ptr) ? |
499 simple_charptr_emchar (ptr) : | 500 simple_charptr_emchar (ptr) : |
500 non_ascii_charptr_emchar (ptr); | 501 non_ascii_charptr_emchar (ptr); |
501 } | 502 } |
502 | 503 |
503 INLINE Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x); | 504 INLINE_HEADER Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x); |
504 INLINE Bytecount | 505 INLINE_HEADER Bytecount |
505 set_charptr_emchar (Bufbyte *ptr, Emchar x) | 506 set_charptr_emchar (Bufbyte *ptr, Emchar x) |
506 { | 507 { |
507 return !CHAR_MULTIBYTE_P (x) ? | 508 return !CHAR_MULTIBYTE_P (x) ? |
508 simple_set_charptr_emchar (ptr, x) : | 509 simple_set_charptr_emchar (ptr, x) : |
509 non_ascii_set_charptr_emchar (ptr, x); | 510 non_ascii_set_charptr_emchar (ptr, x); |
510 } | 511 } |
511 | 512 |
512 INLINE Bytecount charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2); | 513 INLINE_HEADER Bytecount |
513 INLINE Bytecount | 514 charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2); |
514 charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2) | 515 INLINE_HEADER Bytecount |
516 charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2) | |
515 { | 517 { |
516 return BYTE_ASCII_P (*ptr) ? | 518 return BYTE_ASCII_P (*ptr) ? |
517 simple_charptr_copy_char (ptr, ptr2) : | 519 simple_charptr_copy_char (ptr, ptr2) : |
518 non_ascii_charptr_copy_char (ptr, ptr2); | 520 non_ascii_charptr_copy_char (ptr, ptr2); |
519 } | 521 } |
536 | 538 |
537 #ifdef MULE | 539 #ifdef MULE |
538 | 540 |
539 int non_ascii_valid_char_p (Emchar ch); | 541 int non_ascii_valid_char_p (Emchar ch); |
540 | 542 |
541 INLINE int valid_char_p (Emchar ch); | 543 INLINE_HEADER int valid_char_p (Emchar ch); |
542 INLINE int | 544 INLINE_HEADER int |
543 valid_char_p (Emchar ch) | 545 valid_char_p (Emchar ch) |
544 { | 546 { |
545 return ((unsigned int) (ch) <= 0xff) || non_ascii_valid_char_p (ch); | 547 return ((unsigned int) (ch) <= 0xff) || non_ascii_valid_char_p (ch); |
546 } | 548 } |
547 | 549 |
555 | 557 |
556 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) | 558 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) |
557 | 559 |
558 #ifdef ERROR_CHECK_TYPECHECK | 560 #ifdef ERROR_CHECK_TYPECHECK |
559 | 561 |
560 INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj); | 562 INLINE_HEADER Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj); |
561 INLINE Emchar | 563 INLINE_HEADER Emchar |
562 XCHAR_OR_CHAR_INT (Lisp_Object obj) | 564 XCHAR_OR_CHAR_INT (Lisp_Object obj) |
563 { | 565 { |
564 assert (CHAR_OR_CHAR_INTP (obj)); | 566 assert (CHAR_OR_CHAR_INTP (obj)); |
565 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | 567 return CHARP (obj) ? XCHAR (obj) : XINT (obj); |
566 } | 568 } |
620 /*----------------------------------------------------------------------*/ | 622 /*----------------------------------------------------------------------*/ |
621 /* Converting between positions and addresses */ | 623 /* Converting between positions and addresses */ |
622 /*----------------------------------------------------------------------*/ | 624 /*----------------------------------------------------------------------*/ |
623 | 625 |
624 /* Convert the address of a byte in the buffer into a position. */ | 626 /* Convert the address of a byte in the buffer into a position. */ |
625 INLINE Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr); | 627 INLINE_HEADER Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr); |
626 INLINE Bytind | 628 INLINE_HEADER Bytind |
627 BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr) | 629 BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr) |
628 { | 630 { |
629 return (ptr - buf->text->beg + 1 | 631 return (ptr - buf->text->beg + 1 |
630 - ((ptr - buf->text->beg + 1) > buf->text->gpt | 632 - ((ptr - buf->text->beg + 1) > buf->text->gpt |
631 ? buf->text->gap_size : 0)); | 633 ? buf->text->gap_size : 0)); |
633 | 635 |
634 #define BUF_PTR_BYTE_POS(buf, ptr) \ | 636 #define BUF_PTR_BYTE_POS(buf, ptr) \ |
635 bytind_to_bufpos (buf, BI_BUF_PTR_BYTE_POS (buf, ptr)) | 637 bytind_to_bufpos (buf, BI_BUF_PTR_BYTE_POS (buf, ptr)) |
636 | 638 |
637 /* Address of byte at position POS in buffer. */ | 639 /* Address of byte at position POS in buffer. */ |
638 INLINE Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos); | 640 INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos); |
639 INLINE Bufbyte * | 641 INLINE_HEADER Bufbyte * |
640 BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos) | 642 BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos) |
641 { | 643 { |
642 return (buf->text->beg + | 644 return (buf->text->beg + |
643 ((pos >= buf->text->gpt ? (pos + buf->text->gap_size) : pos) | 645 ((pos >= buf->text->gpt ? (pos + buf->text->gap_size) : pos) |
644 - 1)); | 646 - 1)); |
646 | 648 |
647 #define BUF_BYTE_ADDRESS(buf, pos) \ | 649 #define BUF_BYTE_ADDRESS(buf, pos) \ |
648 BI_BUF_BYTE_ADDRESS (buf, bufpos_to_bytind (buf, pos)) | 650 BI_BUF_BYTE_ADDRESS (buf, bufpos_to_bytind (buf, pos)) |
649 | 651 |
650 /* Address of byte before position POS in buffer. */ | 652 /* Address of byte before position POS in buffer. */ |
651 INLINE Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos); | 653 INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos); |
652 INLINE Bufbyte * | 654 INLINE_HEADER Bufbyte * |
653 BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos) | 655 BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos) |
654 { | 656 { |
655 return (buf->text->beg + | 657 return (buf->text->beg + |
656 ((pos > buf->text->gpt ? (pos + buf->text->gap_size) : pos) | 658 ((pos > buf->text->gpt ? (pos + buf->text->gap_size) : pos) |
657 - 2)); | 659 - 2)); |
662 | 664 |
663 /*----------------------------------------------------------------------*/ | 665 /*----------------------------------------------------------------------*/ |
664 /* Converting between byte indices and memory indices */ | 666 /* Converting between byte indices and memory indices */ |
665 /*----------------------------------------------------------------------*/ | 667 /*----------------------------------------------------------------------*/ |
666 | 668 |
667 INLINE int valid_memind_p (struct buffer *buf, Memind x); | 669 INLINE_HEADER int valid_memind_p (struct buffer *buf, Memind x); |
668 INLINE int | 670 INLINE_HEADER int |
669 valid_memind_p (struct buffer *buf, Memind x) | 671 valid_memind_p (struct buffer *buf, Memind x) |
670 { | 672 { |
671 return ((x >= 1 && x <= (Memind) buf->text->gpt) || | 673 return ((x >= 1 && x <= (Memind) buf->text->gpt) || |
672 (x > (Memind) (buf->text->gpt + buf->text->gap_size) && | 674 (x > (Memind) (buf->text->gpt + buf->text->gap_size) && |
673 x <= (Memind) (buf->text->z + buf->text->gap_size))); | 675 x <= (Memind) (buf->text->z + buf->text->gap_size))); |
674 } | 676 } |
675 | 677 |
676 INLINE Memind bytind_to_memind (struct buffer *buf, Bytind x); | 678 INLINE_HEADER Memind bytind_to_memind (struct buffer *buf, Bytind x); |
677 INLINE Memind | 679 INLINE_HEADER Memind |
678 bytind_to_memind (struct buffer *buf, Bytind x) | 680 bytind_to_memind (struct buffer *buf, Bytind x) |
679 { | 681 { |
680 return (Memind) ((x > buf->text->gpt) ? (x + buf->text->gap_size) : x); | 682 return (Memind) ((x > buf->text->gpt) ? (x + buf->text->gap_size) : x); |
681 } | 683 } |
682 | 684 |
683 | 685 |
684 INLINE Bytind memind_to_bytind (struct buffer *buf, Memind x); | 686 INLINE_HEADER Bytind memind_to_bytind (struct buffer *buf, Memind x); |
685 INLINE Bytind | 687 INLINE_HEADER Bytind |
686 memind_to_bytind (struct buffer *buf, Memind x) | 688 memind_to_bytind (struct buffer *buf, Memind x) |
687 { | 689 { |
688 #ifdef ERROR_CHECK_BUFPOS | 690 #ifdef ERROR_CHECK_BUFPOS |
689 assert (valid_memind_p (buf, x)); | 691 assert (valid_memind_p (buf, x)); |
690 #endif | 692 #endif |
900 the correct side of the gap */ \ | 902 the correct side of the gap */ \ |
901 (x)--; \ | 903 (x)--; \ |
902 VALIDATE_BYTIND_BACKWARD (buf, x); \ | 904 VALIDATE_BYTIND_BACKWARD (buf, x); \ |
903 } while (0) | 905 } while (0) |
904 | 906 |
905 INLINE Bytind prev_bytind (struct buffer *buf, Bytind x); | 907 INLINE_HEADER Bytind prev_bytind (struct buffer *buf, Bytind x); |
906 INLINE Bytind | 908 INLINE_HEADER Bytind |
907 prev_bytind (struct buffer *buf, Bytind x) | 909 prev_bytind (struct buffer *buf, Bytind x) |
908 { | 910 { |
909 DEC_BYTIND (buf, x); | 911 DEC_BYTIND (buf, x); |
910 return x; | 912 return x; |
911 } | 913 } |
912 | 914 |
913 INLINE Bytind next_bytind (struct buffer *buf, Bytind x); | 915 INLINE_HEADER Bytind next_bytind (struct buffer *buf, Bytind x); |
914 INLINE Bytind | 916 INLINE_HEADER Bytind |
915 next_bytind (struct buffer *buf, Bytind x) | 917 next_bytind (struct buffer *buf, Bytind x) |
916 { | 918 { |
917 INC_BYTIND (buf, x); | 919 INC_BYTIND (buf, x); |
918 return x; | 920 return x; |
919 } | 921 } |
971 64K for width-three characters. | 973 64K for width-three characters. |
972 */ | 974 */ |
973 | 975 |
974 extern short three_to_one_table[]; | 976 extern short three_to_one_table[]; |
975 | 977 |
976 INLINE int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); | 978 INLINE_HEADER int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); |
977 INLINE int | 979 INLINE_HEADER int |
978 real_bufpos_to_bytind (struct buffer *buf, Bufpos x) | 980 real_bufpos_to_bytind (struct buffer *buf, Bufpos x) |
979 { | 981 { |
980 if (x >= buf->text->mule_bufmin && x <= buf->text->mule_bufmax) | 982 if (x >= buf->text->mule_bufmin && x <= buf->text->mule_bufmax) |
981 return (buf->text->mule_bytmin + | 983 return (buf->text->mule_bytmin + |
982 ((x - buf->text->mule_bufmin) << buf->text->mule_shifter) + | 984 ((x - buf->text->mule_bufmin) << buf->text->mule_shifter) + |
983 (buf->text->mule_three_p ? (x - buf->text->mule_bufmin) : 0)); | 985 (buf->text->mule_three_p ? (x - buf->text->mule_bufmin) : 0)); |
984 else | 986 else |
985 return bufpos_to_bytind_func (buf, x); | 987 return bufpos_to_bytind_func (buf, x); |
986 } | 988 } |
987 | 989 |
988 INLINE int real_bytind_to_bufpos (struct buffer *buf, Bytind x); | 990 INLINE_HEADER int real_bytind_to_bufpos (struct buffer *buf, Bytind x); |
989 INLINE int | 991 INLINE_HEADER int |
990 real_bytind_to_bufpos (struct buffer *buf, Bytind x) | 992 real_bytind_to_bufpos (struct buffer *buf, Bytind x) |
991 { | 993 { |
992 if (x >= buf->text->mule_bytmin && x <= buf->text->mule_bytmax) | 994 if (x >= buf->text->mule_bytmin && x <= buf->text->mule_bytmax) |
993 return (buf->text->mule_bufmin + | 995 return (buf->text->mule_bufmin + |
994 ((buf->text->mule_three_p | 996 ((buf->text->mule_three_p |
1186 }; | 1188 }; |
1187 typedef enum dfc_conversion_type dfc_conversion_type; | 1189 typedef enum dfc_conversion_type dfc_conversion_type; |
1188 | 1190 |
1189 /* WARNING: These use a static buffer. This can lead to disaster if | 1191 /* WARNING: These use a static buffer. This can lead to disaster if |
1190 these functions are not used *very* carefully. Another reason to only use | 1192 these functions are not used *very* carefully. Another reason to only use |
1191 TO_EXTERNAL_FORMATf() and TO_INTERNAL_FORMAT(). */ | 1193 TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ |
1192 void | 1194 void |
1193 dfc_convert_to_external_format (dfc_conversion_type source_type, | 1195 dfc_convert_to_external_format (dfc_conversion_type source_type, |
1194 dfc_conversion_data *source, | 1196 dfc_conversion_data *source, |
1195 #ifdef FILE_CODING | 1197 #ifdef FILE_CODING |
1196 Lisp_Object coding_system, | 1198 Lisp_Object coding_system, |
1265 (dfc_slbta, BUF_PT (dfc_slbta), 0); \ | 1267 (dfc_slbta, BUF_PT (dfc_slbta), 0); \ |
1266 dfc_simplified_sink_type = DFC_TYPE_LISP_LSTREAM; \ | 1268 dfc_simplified_sink_type = DFC_TYPE_LISP_LSTREAM; \ |
1267 } while (0) | 1269 } while (0) |
1268 | 1270 |
1269 /* Assign to the `sink' lvalue(s) using the converted data. */ | 1271 /* Assign to the `sink' lvalue(s) using the converted data. */ |
1272 typedef union { char c; void *p; } *dfc_aliasing_voidpp; | |
1270 #define DFC_ALLOCA_USE_CONVERTED_DATA(sink) do { \ | 1273 #define DFC_ALLOCA_USE_CONVERTED_DATA(sink) do { \ |
1271 void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \ | 1274 void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \ |
1272 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ | 1275 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ |
1273 (DFC_CPP_CAR sink) = (unsigned char *) dfc_sink_ret; \ | 1276 ((dfc_aliasing_voidpp) &(DFC_CPP_CAR sink))->p = dfc_sink_ret; \ |
1274 (DFC_CPP_CDR sink) = dfc_sink.data.len; \ | 1277 (DFC_CPP_CDR sink) = dfc_sink.data.len; \ |
1275 } while (0) | 1278 } while (0) |
1276 #define DFC_MALLOC_USE_CONVERTED_DATA(sink) do { \ | 1279 #define DFC_MALLOC_USE_CONVERTED_DATA(sink) do { \ |
1277 void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 1); \ | 1280 void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 1); \ |
1278 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ | 1281 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ |
1279 (DFC_CPP_CAR sink) = (unsigned char *) dfc_sink_ret; \ | 1282 ((dfc_aliasing_voidpp) &(DFC_CPP_CAR sink))->p = dfc_sink_ret; \ |
1280 (DFC_CPP_CDR sink) = dfc_sink.data.len; \ | 1283 (DFC_CPP_CDR sink) = dfc_sink.data.len; \ |
1281 } while (0) | 1284 } while (0) |
1282 #define DFC_C_STRING_ALLOCA_USE_CONVERTED_DATA(sink) do { \ | 1285 #define DFC_C_STRING_ALLOCA_USE_CONVERTED_DATA(sink) do { \ |
1283 void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \ | 1286 void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \ |
1284 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ | 1287 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ |
1300 /* Someday we might want to distinguish between Qnative and Qfile_name | 1303 /* Someday we might want to distinguish between Qnative and Qfile_name |
1301 by using coding-system aliases, but for now it suffices to have | 1304 by using coding-system aliases, but for now it suffices to have |
1302 these be identical. Qnative can be used as the coding_system | 1305 these be identical. Qnative can be used as the coding_system |
1303 argument to TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ | 1306 argument to TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ |
1304 #define Qnative Qfile_name | 1307 #define Qnative Qfile_name |
1308 | |
1309 #if defined (WIN32_NATIVE) || defined (CYGWIN) | |
1310 /* #### kludge!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
1311 Remove this as soon as my Mule code is integrated. */ | |
1312 #define Qmswindows_tstr Qnative | |
1313 #endif | |
1314 | |
1315 /* More stand-ins */ | |
1316 #define Qcommand_argument_encoding Qnative | |
1317 #define Qenvironment_variable_encoding Qnative | |
1318 | |
1319 /* Convenience macros for extremely common invocations */ | |
1320 #define C_STRING_TO_EXTERNAL(in, out, coding_system) \ | |
1321 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) | |
1322 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ | |
1323 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) | |
1324 #define EXTERNAL_TO_C_STRING(in, out, coding_system) \ | |
1325 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) | |
1326 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, coding_system) \ | |
1327 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) | |
1328 #define LISP_STRING_TO_EXTERNAL(in, out, coding_system) \ | |
1329 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_ALLOCA, out, coding_system) | |
1330 #define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ | |
1331 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_MALLOC, out, coding_system) | |
1305 | 1332 |
1306 | 1333 |
1307 /************************************************************************/ | 1334 /************************************************************************/ |
1308 /* */ | 1335 /* */ |
1309 /* fake charset functions */ | 1336 /* fake charset functions */ |
1566 int beginning_of_line_p (struct buffer *b, Bufpos pt); | 1593 int beginning_of_line_p (struct buffer *b, Bufpos pt); |
1567 | 1594 |
1568 /* from insdel.c */ | 1595 /* from insdel.c */ |
1569 void set_buffer_point (struct buffer *buf, Bufpos pos, Bytind bipos); | 1596 void set_buffer_point (struct buffer *buf, Bufpos pos, Bytind bipos); |
1570 void find_charsets_in_bufbyte_string (unsigned char *charsets, | 1597 void find_charsets_in_bufbyte_string (unsigned char *charsets, |
1571 CONST Bufbyte *str, | 1598 const Bufbyte *str, |
1572 Bytecount len); | 1599 Bytecount len); |
1573 void find_charsets_in_emchar_string (unsigned char *charsets, | 1600 void find_charsets_in_emchar_string (unsigned char *charsets, |
1574 CONST Emchar *str, | 1601 const Emchar *str, |
1575 Charcount len); | 1602 Charcount len); |
1576 int bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len); | 1603 int bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len); |
1577 int emchar_string_displayed_columns (CONST Emchar *str, Charcount len); | 1604 int emchar_string_displayed_columns (const Emchar *str, Charcount len); |
1578 void convert_bufbyte_string_into_emchar_dynarr (CONST Bufbyte *str, | 1605 void convert_bufbyte_string_into_emchar_dynarr (const Bufbyte *str, |
1579 Bytecount len, | 1606 Bytecount len, |
1580 Emchar_dynarr *dyn); | 1607 Emchar_dynarr *dyn); |
1581 Charcount convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str, | 1608 Charcount convert_bufbyte_string_into_emchar_string (const Bufbyte *str, |
1582 Bytecount len, | 1609 Bytecount len, |
1583 Emchar *arr); | 1610 Emchar *arr); |
1584 void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, | 1611 void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, |
1585 Bufbyte_dynarr *dyn); | 1612 Bufbyte_dynarr *dyn); |
1586 Bufbyte *convert_emchar_string_into_malloced_string (Emchar *arr, int nels, | 1613 Bufbyte *convert_emchar_string_into_malloced_string (Emchar *arr, int nels, |
1702 TRT_TABLE_AS_STRING (buf->case_canon_table) | 1729 TRT_TABLE_AS_STRING (buf->case_canon_table) |
1703 #define MIRROR_EQV_TABLE_AS_STRING(buf) \ | 1730 #define MIRROR_EQV_TABLE_AS_STRING(buf) \ |
1704 TRT_TABLE_AS_STRING (buf->case_eqv_table) | 1731 TRT_TABLE_AS_STRING (buf->case_eqv_table) |
1705 #endif | 1732 #endif |
1706 | 1733 |
1707 INLINE Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c); | 1734 INLINE_HEADER Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c); |
1708 INLINE Emchar | 1735 INLINE_HEADER Emchar |
1709 TRT_TABLE_OF (Lisp_Object trt, Emchar c) | 1736 TRT_TABLE_OF (Lisp_Object trt, Emchar c) |
1710 { | 1737 { |
1711 return IN_TRT_TABLE_DOMAIN (c) ? TRT_TABLE_CHAR_1 (trt, c) : c; | 1738 return IN_TRT_TABLE_DOMAIN (c) ? TRT_TABLE_CHAR_1 (trt, c) : c; |
1712 } | 1739 } |
1713 | 1740 |
1715 #define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->downcase_table, c) | 1742 #define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->downcase_table, c) |
1716 #define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->upcase_table, c) | 1743 #define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->upcase_table, c) |
1717 | 1744 |
1718 /* 1 if CH is upper case. */ | 1745 /* 1 if CH is upper case. */ |
1719 | 1746 |
1720 INLINE int UPPERCASEP (struct buffer *buf, Emchar ch); | 1747 INLINE_HEADER int UPPERCASEP (struct buffer *buf, Emchar ch); |
1721 INLINE int | 1748 INLINE_HEADER int |
1722 UPPERCASEP (struct buffer *buf, Emchar ch) | 1749 UPPERCASEP (struct buffer *buf, Emchar ch) |
1723 { | 1750 { |
1724 return DOWNCASE_TABLE_OF (buf, ch) != ch; | 1751 return DOWNCASE_TABLE_OF (buf, ch) != ch; |
1725 } | 1752 } |
1726 | 1753 |
1727 /* 1 if CH is lower case. */ | 1754 /* 1 if CH is lower case. */ |
1728 | 1755 |
1729 INLINE int LOWERCASEP (struct buffer *buf, Emchar ch); | 1756 INLINE_HEADER int LOWERCASEP (struct buffer *buf, Emchar ch); |
1730 INLINE int | 1757 INLINE_HEADER int |
1731 LOWERCASEP (struct buffer *buf, Emchar ch) | 1758 LOWERCASEP (struct buffer *buf, Emchar ch) |
1732 { | 1759 { |
1733 return (UPCASE_TABLE_OF (buf, ch) != ch && | 1760 return (UPCASE_TABLE_OF (buf, ch) != ch && |
1734 DOWNCASE_TABLE_OF (buf, ch) == ch); | 1761 DOWNCASE_TABLE_OF (buf, ch) == ch); |
1735 } | 1762 } |
1736 | 1763 |
1737 /* 1 if CH is neither upper nor lower case. */ | 1764 /* 1 if CH is neither upper nor lower case. */ |
1738 | 1765 |
1739 INLINE int NOCASEP (struct buffer *buf, Emchar ch); | 1766 INLINE_HEADER int NOCASEP (struct buffer *buf, Emchar ch); |
1740 INLINE int | 1767 INLINE_HEADER int |
1741 NOCASEP (struct buffer *buf, Emchar ch) | 1768 NOCASEP (struct buffer *buf, Emchar ch) |
1742 { | 1769 { |
1743 return UPCASE_TABLE_OF (buf, ch) == ch; | 1770 return UPCASE_TABLE_OF (buf, ch) == ch; |
1744 } | 1771 } |
1745 | 1772 |
1746 /* Upcase a character, or make no change if that cannot be done. */ | 1773 /* Upcase a character, or make no change if that cannot be done. */ |
1747 | 1774 |
1748 INLINE Emchar UPCASE (struct buffer *buf, Emchar ch); | 1775 INLINE_HEADER Emchar UPCASE (struct buffer *buf, Emchar ch); |
1749 INLINE Emchar | 1776 INLINE_HEADER Emchar |
1750 UPCASE (struct buffer *buf, Emchar ch) | 1777 UPCASE (struct buffer *buf, Emchar ch) |
1751 { | 1778 { |
1752 return (DOWNCASE_TABLE_OF (buf, ch) == ch) ? UPCASE_TABLE_OF (buf, ch) : ch; | 1779 return (DOWNCASE_TABLE_OF (buf, ch) == ch) ? UPCASE_TABLE_OF (buf, ch) : ch; |
1753 } | 1780 } |
1754 | 1781 |