comparison src/buffer.h @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 9ee227acff29
children 131b0175ea99
comparison
equal deleted inserted replaced
15:ad457d5f7d04 16:0293115a14e9
29 Ben Wing: almost completely rewritten for Mule, 19.12. 29 Ben Wing: almost completely rewritten for Mule, 19.12.
30 */ 30 */
31 31
32 #ifndef _XEMACS_BUFFER_H_ 32 #ifndef _XEMACS_BUFFER_H_
33 #define _XEMACS_BUFFER_H_ 33 #define _XEMACS_BUFFER_H_
34
34 35
35 /************************************************************************/ 36 /************************************************************************/
36 /* */ 37 /* */
37 /* definition of Lisp buffer object */ 38 /* definition of Lisp buffer object */
38 /* */ 39 /* */
381 382
382 /* ---------------------------------------------------------------------- */ 383 /* ---------------------------------------------------------------------- */
383 /* (A) For working with charptr's (pointers to internally-formatted text) */ 384 /* (A) For working with charptr's (pointers to internally-formatted text) */
384 /* ---------------------------------------------------------------------- */ 385 /* ---------------------------------------------------------------------- */
385 386
386 #define VALID_CHARPTR_P(ptr) 1 387 # define VALID_CHARPTR_P(ptr) 1
387 388
388 #ifdef ERROR_CHECK_BUFPOS 389 #ifdef ERROR_CHECK_BUFPOS
389 # define ASSERT_VALID_CHARPTR(ptr) assert (VALID_CHARPTR_P (ptr)) 390 # define ASSERT_VALID_CHARPTR(ptr) assert (VALID_CHARPTR_P (ptr))
390 #else 391 #else
391 # define ASSERT_VALID_CHARPTR(ptr) 392 # define ASSERT_VALID_CHARPTR(ptr)
508 else if (CHAR_INTP (x)) \ 509 else if (CHAR_INTP (x)) \
509 x = make_char (XINT (x)); \ 510 x = make_char (XINT (x)); \
510 else \ 511 else \
511 x = wrong_type_argument (Qcharacterp, x); } while (0) 512 x = wrong_type_argument (Qcharacterp, x); } while (0)
512 513
513 #define MAX_EMCHAR_LEN 1 514 # define MAX_EMCHAR_LEN 1
514 515
515 516
516 /*----------------------------------------------------------------------*/ 517 /*----------------------------------------------------------------------*/
517 /* Accessor macros for important positions in a buffer */ 518 /* Accessor macros for important positions in a buffer */
518 /*----------------------------------------------------------------------*/ 519 /*----------------------------------------------------------------------*/
759 760
760 /*----------------------------------------------------------------------*/ 761 /*----------------------------------------------------------------------*/
761 /* working with byte indices */ 762 /* working with byte indices */
762 /*----------------------------------------------------------------------*/ 763 /*----------------------------------------------------------------------*/
763 764
764 #define VALID_BYTIND_P(buf, x) 1 765 # define VALID_BYTIND_P(buf, x) 1
765 766
766 #ifdef ERROR_CHECK_BUFPOS 767 #ifdef ERROR_CHECK_BUFPOS
767 768
768 # define ASSERT_VALID_BYTIND_UNSAFE(buf, x) do \ 769 # define ASSERT_VALID_BYTIND_UNSAFE(buf, x) do \
769 { \ 770 { \
789 # define ASSERT_VALID_BYTIND_BACKWARD_UNSAFE(buf, x) 790 # define ASSERT_VALID_BYTIND_BACKWARD_UNSAFE(buf, x)
790 # define ASSERT_VALID_BYTIND_FORWARD_UNSAFE(buf, x) 791 # define ASSERT_VALID_BYTIND_FORWARD_UNSAFE(buf, x)
791 792
792 #endif /* not ERROR_CHECK_BUFPOS */ 793 #endif /* not ERROR_CHECK_BUFPOS */
793 794
794 #define VALIDATE_BYTIND_BACKWARD(buf, x) 795 # define VALIDATE_BYTIND_BACKWARD(buf, x)
795 796
796 #define VALIDATE_BYTIND_FORWARD(buf, x) 797 # define VALIDATE_BYTIND_FORWARD(buf, x)
797 798
798 /* Note that in the simplest case (no MULE, no ERROR_CHECK_BUFPOS), 799 /* Note that in the simplest case (no MULE, no ERROR_CHECK_BUFPOS),
799 this crap reduces down to simply (x)++. */ 800 this crap reduces down to simply (x)++. */
800 801
801 #define INC_BYTIND(buf, x) do \ 802 #define INC_BYTIND(buf, x) do \
843 844
844 /*----------------------------------------------------------------------*/ 845 /*----------------------------------------------------------------------*/
845 /* Converting between buffer positions and byte indices */ 846 /* Converting between buffer positions and byte indices */
846 /*----------------------------------------------------------------------*/ 847 /*----------------------------------------------------------------------*/
847 848
848 #define real_bufpos_to_bytind(buf, x) ((Bytind) x) 849 # define real_bufpos_to_bytind(buf, x) ((Bytind) x)
849 #define real_bytind_to_bufpos(buf, x) ((Bufpos) x) 850 # define real_bytind_to_bufpos(buf, x) ((Bufpos) x)
850 851
851 #ifdef ERROR_CHECK_BUFPOS 852 #ifdef ERROR_CHECK_BUFPOS
852 853
853 Bytind bufpos_to_bytind (struct buffer *buf, Bufpos x); 854 Bytind bufpos_to_bytind (struct buffer *buf, Bufpos x);
854 Bufpos bytind_to_bufpos (struct buffer *buf, Bytind x); 855 Bufpos bytind_to_bufpos (struct buffer *buf, Bytind x);
1070 struct Lisp_String *__gseda_s__ = XSTRING (s); \ 1071 struct Lisp_String *__gseda_s__ = XSTRING (s); \
1071 \ 1072 \
1072 __gseda_ptr__ = convert_to_external_format (string_data (__gseda_s__), \ 1073 __gseda_ptr__ = convert_to_external_format (string_data (__gseda_s__), \
1073 string_length (__gseda_s__), \ 1074 string_length (__gseda_s__), \
1074 &__gseda_len__, fmt); \ 1075 &__gseda_len__, fmt); \
1075 (stick_value_here) = alloca (1 + __gseda_len__); \ 1076 (stick_value_here) = (CONST Extbyte *) alloca (1 + __gseda_len__); \
1076 memcpy ((Extbyte *) stick_value_here, __gseda_ptr__, 1 + __gseda_len__); \ 1077 memcpy ((Extbyte *) stick_value_here, __gseda_ptr__, 1 + __gseda_len__); \
1077 (stick_len_here) = __gseda_len__; \ 1078 (stick_len_here) = __gseda_len__; \
1078 } while (0) 1079 } while (0)
1079 1080
1080 1081
1450 /* The _1 macros are named as such because they assume that you have 1451 /* The _1 macros are named as such because they assume that you have
1451 already guaranteed that the character values are all in the range 1452 already guaranteed that the character values are all in the range
1452 0 - 255. Bad lossage will happen otherwise. */ 1453 0 - 255. Bad lossage will happen otherwise. */
1453 1454
1454 # define MAKE_TRT_TABLE() Fmake_string (make_int (256), make_char (0)) 1455 # define MAKE_TRT_TABLE() Fmake_string (make_int (256), make_char (0))
1455 # define TRT_TABLE_AS_STRING(table) string_data (XSTRING (table)) 1456 # define TRT_TABLE_AS_STRING(table) XSTRING_DATA (table)
1456 # define TRT_TABLE_CHAR_1(table, ch) \ 1457 # define TRT_TABLE_CHAR_1(table, ch) \
1457 string_char (XSTRING (table), (Charcount) ch) 1458 string_char (XSTRING (table), (Charcount) ch)
1458 # define SET_TRT_TABLE_CHAR_1(table, ch1, ch2) \ 1459 # define SET_TRT_TABLE_CHAR_1(table, ch1, ch2) \
1459 set_string_char (XSTRING (table), (Charcount) ch1, ch2) 1460 set_string_char (XSTRING (table), (Charcount) ch1, ch2)
1460 1461