Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/buffer.h Mon Aug 13 11:33:40 2007 +0200 +++ b/src/buffer.h Mon Aug 13 11:35:02 2007 +0200 @@ -198,7 +198,7 @@ int modtime; /* the value of text->modiff at the last auto-save. */ - int auto_save_modified; + long auto_save_modified; /* The time at which we detected a failure to auto-save, Or -1 if we didn't have a failure. */ @@ -427,8 +427,8 @@ } while (0) #define DEC_CHARPTR(ptr) do { \ - CONST Bufbyte *dc_ptr1 = (ptr); \ - CONST Bufbyte *dc_ptr2 = dc_ptr1; \ + const Bufbyte *dc_ptr1 = (ptr); \ + const Bufbyte *dc_ptr2 = dc_ptr1; \ REAL_DEC_CHARPTR (dc_ptr2); \ assert (dc_ptr1 - dc_ptr2 == \ REP_BYTES_BY_FIRST_BYTE (*dc_ptr2)); \ @@ -470,9 +470,10 @@ /* section of internally-formatted text */ /* -------------------------------------------------------------- */ -INLINE CONST Bufbyte *charptr_n_addr (CONST Bufbyte *ptr, Charcount offset); -INLINE CONST Bufbyte * -charptr_n_addr (CONST Bufbyte *ptr, Charcount offset) +INLINE_HEADER const Bufbyte * +charptr_n_addr (const Bufbyte *ptr, Charcount offset); +INLINE_HEADER const Bufbyte * +charptr_n_addr (const Bufbyte *ptr, Charcount offset) { return ptr + charcount_to_bytecount (ptr, offset); } @@ -487,21 +488,21 @@ #ifdef MULE -Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr); +Emchar non_ascii_charptr_emchar (const Bufbyte *ptr); Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c); -Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2); +Bytecount non_ascii_charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2); -INLINE Emchar charptr_emchar (CONST Bufbyte *ptr); -INLINE Emchar -charptr_emchar (CONST Bufbyte *ptr) +INLINE_HEADER Emchar charptr_emchar (const Bufbyte *ptr); +INLINE_HEADER Emchar +charptr_emchar (const Bufbyte *ptr) { return BYTE_ASCII_P (*ptr) ? simple_charptr_emchar (ptr) : non_ascii_charptr_emchar (ptr); } -INLINE Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x); -INLINE Bytecount +INLINE_HEADER Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x); +INLINE_HEADER Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x) { return !CHAR_MULTIBYTE_P (x) ? @@ -509,9 +510,10 @@ non_ascii_set_charptr_emchar (ptr, x); } -INLINE Bytecount charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2); -INLINE Bytecount -charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2) +INLINE_HEADER Bytecount +charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2); +INLINE_HEADER Bytecount +charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2) { return BYTE_ASCII_P (*ptr) ? simple_charptr_copy_char (ptr, ptr2) : @@ -538,8 +540,8 @@ int non_ascii_valid_char_p (Emchar ch); -INLINE int valid_char_p (Emchar ch); -INLINE int +INLINE_HEADER int valid_char_p (Emchar ch); +INLINE_HEADER int valid_char_p (Emchar ch) { return ((unsigned int) (ch) <= 0xff) || non_ascii_valid_char_p (ch); @@ -557,8 +559,8 @@ #ifdef ERROR_CHECK_TYPECHECK -INLINE Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj); -INLINE Emchar +INLINE_HEADER Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj); +INLINE_HEADER Emchar XCHAR_OR_CHAR_INT (Lisp_Object obj) { assert (CHAR_OR_CHAR_INTP (obj)); @@ -622,8 +624,8 @@ /*----------------------------------------------------------------------*/ /* Convert the address of a byte in the buffer into a position. */ -INLINE Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr); -INLINE Bytind +INLINE_HEADER Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr); +INLINE_HEADER Bytind BI_BUF_PTR_BYTE_POS (struct buffer *buf, Bufbyte *ptr) { return (ptr - buf->text->beg + 1 @@ -635,8 +637,8 @@ bytind_to_bufpos (buf, BI_BUF_PTR_BYTE_POS (buf, ptr)) /* Address of byte at position POS in buffer. */ -INLINE Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos); -INLINE Bufbyte * +INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos); +INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS (struct buffer *buf, Bytind pos) { return (buf->text->beg + @@ -648,8 +650,8 @@ BI_BUF_BYTE_ADDRESS (buf, bufpos_to_bytind (buf, pos)) /* Address of byte before position POS in buffer. */ -INLINE Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos); -INLINE Bufbyte * +INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos); +INLINE_HEADER Bufbyte * BI_BUF_BYTE_ADDRESS_BEFORE (struct buffer *buf, Bytind pos) { return (buf->text->beg + @@ -664,8 +666,8 @@ /* Converting between byte indices and memory indices */ /*----------------------------------------------------------------------*/ -INLINE int valid_memind_p (struct buffer *buf, Memind x); -INLINE int +INLINE_HEADER int valid_memind_p (struct buffer *buf, Memind x); +INLINE_HEADER int valid_memind_p (struct buffer *buf, Memind x) { return ((x >= 1 && x <= (Memind) buf->text->gpt) || @@ -673,16 +675,16 @@ x <= (Memind) (buf->text->z + buf->text->gap_size))); } -INLINE Memind bytind_to_memind (struct buffer *buf, Bytind x); -INLINE Memind +INLINE_HEADER Memind bytind_to_memind (struct buffer *buf, Bytind x); +INLINE_HEADER Memind bytind_to_memind (struct buffer *buf, Bytind x) { return (Memind) ((x > buf->text->gpt) ? (x + buf->text->gap_size) : x); } -INLINE Bytind memind_to_bytind (struct buffer *buf, Memind x); -INLINE Bytind +INLINE_HEADER Bytind memind_to_bytind (struct buffer *buf, Memind x); +INLINE_HEADER Bytind memind_to_bytind (struct buffer *buf, Memind x) { #ifdef ERROR_CHECK_BUFPOS @@ -902,16 +904,16 @@ VALIDATE_BYTIND_BACKWARD (buf, x); \ } while (0) -INLINE Bytind prev_bytind (struct buffer *buf, Bytind x); -INLINE Bytind +INLINE_HEADER Bytind prev_bytind (struct buffer *buf, Bytind x); +INLINE_HEADER Bytind prev_bytind (struct buffer *buf, Bytind x) { DEC_BYTIND (buf, x); return x; } -INLINE Bytind next_bytind (struct buffer *buf, Bytind x); -INLINE Bytind +INLINE_HEADER Bytind next_bytind (struct buffer *buf, Bytind x); +INLINE_HEADER Bytind next_bytind (struct buffer *buf, Bytind x) { INC_BYTIND (buf, x); @@ -973,8 +975,8 @@ extern short three_to_one_table[]; -INLINE int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); -INLINE int +INLINE_HEADER int real_bufpos_to_bytind (struct buffer *buf, Bufpos x); +INLINE_HEADER int real_bufpos_to_bytind (struct buffer *buf, Bufpos x) { if (x >= buf->text->mule_bufmin && x <= buf->text->mule_bufmax) @@ -985,8 +987,8 @@ return bufpos_to_bytind_func (buf, x); } -INLINE int real_bytind_to_bufpos (struct buffer *buf, Bytind x); -INLINE int +INLINE_HEADER int real_bytind_to_bufpos (struct buffer *buf, Bytind x); +INLINE_HEADER int real_bytind_to_bufpos (struct buffer *buf, Bytind x) { if (x >= buf->text->mule_bytmin && x <= buf->text->mule_bytmax) @@ -1188,7 +1190,7 @@ /* WARNING: These use a static buffer. This can lead to disaster if these functions are not used *very* carefully. Another reason to only use - TO_EXTERNAL_FORMATf() and TO_INTERNAL_FORMAT(). */ + TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ void dfc_convert_to_external_format (dfc_conversion_type source_type, dfc_conversion_data *source, @@ -1267,16 +1269,17 @@ } while (0) /* Assign to the `sink' lvalue(s) using the converted data. */ +typedef union { char c; void *p; } *dfc_aliasing_voidpp; #define DFC_ALLOCA_USE_CONVERTED_DATA(sink) do { \ void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ - (DFC_CPP_CAR sink) = (unsigned char *) dfc_sink_ret; \ + ((dfc_aliasing_voidpp) &(DFC_CPP_CAR sink))->p = dfc_sink_ret; \ (DFC_CPP_CDR sink) = dfc_sink.data.len; \ } while (0) #define DFC_MALLOC_USE_CONVERTED_DATA(sink) do { \ void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 1); \ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \ - (DFC_CPP_CAR sink) = (unsigned char *) dfc_sink_ret; \ + ((dfc_aliasing_voidpp) &(DFC_CPP_CAR sink))->p = dfc_sink_ret; \ (DFC_CPP_CDR sink) = dfc_sink.data.len; \ } while (0) #define DFC_C_STRING_ALLOCA_USE_CONVERTED_DATA(sink) do { \ @@ -1303,6 +1306,30 @@ argument to TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ #define Qnative Qfile_name +#if defined (WIN32_NATIVE) || defined (CYGWIN) +/* #### kludge!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + Remove this as soon as my Mule code is integrated. */ +#define Qmswindows_tstr Qnative +#endif + +/* More stand-ins */ +#define Qcommand_argument_encoding Qnative +#define Qenvironment_variable_encoding Qnative + +/* Convenience macros for extremely common invocations */ +#define C_STRING_TO_EXTERNAL(in, out, coding_system) \ + TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) +#define C_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ + TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) +#define EXTERNAL_TO_C_STRING(in, out, coding_system) \ + TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) +#define EXTERNAL_TO_C_STRING_MALLOC(in, out, coding_system) \ + TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) +#define LISP_STRING_TO_EXTERNAL(in, out, coding_system) \ + TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_ALLOCA, out, coding_system) +#define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ + TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_MALLOC, out, coding_system) + /************************************************************************/ /* */ @@ -1568,17 +1595,17 @@ /* from insdel.c */ void set_buffer_point (struct buffer *buf, Bufpos pos, Bytind bipos); void find_charsets_in_bufbyte_string (unsigned char *charsets, - CONST Bufbyte *str, + const Bufbyte *str, Bytecount len); void find_charsets_in_emchar_string (unsigned char *charsets, - CONST Emchar *str, + const Emchar *str, Charcount len); -int bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len); -int emchar_string_displayed_columns (CONST Emchar *str, Charcount len); -void convert_bufbyte_string_into_emchar_dynarr (CONST Bufbyte *str, +int bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len); +int emchar_string_displayed_columns (const Emchar *str, Charcount len); +void convert_bufbyte_string_into_emchar_dynarr (const Bufbyte *str, Bytecount len, Emchar_dynarr *dyn); -Charcount convert_bufbyte_string_into_emchar_string (CONST Bufbyte *str, +Charcount convert_bufbyte_string_into_emchar_string (const Bufbyte *str, Bytecount len, Emchar *arr); void convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, @@ -1704,8 +1731,8 @@ TRT_TABLE_AS_STRING (buf->case_eqv_table) #endif -INLINE Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c); -INLINE Emchar +INLINE_HEADER Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c); +INLINE_HEADER Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c) { return IN_TRT_TABLE_DOMAIN (c) ? TRT_TABLE_CHAR_1 (trt, c) : c; @@ -1717,8 +1744,8 @@ /* 1 if CH is upper case. */ -INLINE int UPPERCASEP (struct buffer *buf, Emchar ch); -INLINE int +INLINE_HEADER int UPPERCASEP (struct buffer *buf, Emchar ch); +INLINE_HEADER int UPPERCASEP (struct buffer *buf, Emchar ch) { return DOWNCASE_TABLE_OF (buf, ch) != ch; @@ -1726,8 +1753,8 @@ /* 1 if CH is lower case. */ -INLINE int LOWERCASEP (struct buffer *buf, Emchar ch); -INLINE int +INLINE_HEADER int LOWERCASEP (struct buffer *buf, Emchar ch); +INLINE_HEADER int LOWERCASEP (struct buffer *buf, Emchar ch) { return (UPCASE_TABLE_OF (buf, ch) != ch && @@ -1736,8 +1763,8 @@ /* 1 if CH is neither upper nor lower case. */ -INLINE int NOCASEP (struct buffer *buf, Emchar ch); -INLINE int +INLINE_HEADER int NOCASEP (struct buffer *buf, Emchar ch); +INLINE_HEADER int NOCASEP (struct buffer *buf, Emchar ch) { return UPCASE_TABLE_OF (buf, ch) == ch; @@ -1745,8 +1772,8 @@ /* Upcase a character, or make no change if that cannot be done. */ -INLINE Emchar UPCASE (struct buffer *buf, Emchar ch); -INLINE Emchar +INLINE_HEADER Emchar UPCASE (struct buffer *buf, Emchar ch); +INLINE_HEADER Emchar UPCASE (struct buffer *buf, Emchar ch) { return (DOWNCASE_TABLE_OF (buf, ch) == ch) ? UPCASE_TABLE_OF (buf, ch) : ch;