From 97db4061be5b7d6788a853fb737da060625bf804 Mon Sep 17 00:00:00 2001 From: tomo Date: Sat, 4 Sep 1999 08:30:38 +0000 Subject: [PATCH] New files. --- src/mb-1byte.h | 46 +++++++++++++++++++++++++++ src/mb-multibyte.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 src/mb-1byte.h create mode 100644 src/mb-multibyte.h diff --git a/src/mb-1byte.h b/src/mb-1byte.h new file mode 100644 index 0000000..44e9b19 --- /dev/null +++ b/src/mb-1byte.h @@ -0,0 +1,46 @@ +/* Header for 1-byte string representation. + Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. + Licensed to the Free Software Foundation. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Rewritten by MORIOKA Tomohiko . */ + +#ifndef _XEMACS_MB_1BYTE_H +#define _XEMACS_MB_1BYTE_H + +/* Maximum number of buffer bytes per Emacs character. */ +# define MAX_EMCHAR_LEN 1 + +/* ---------------------------------------------------------------------- */ +/* (A) For working with charptr's (pointers to internally-formatted text) */ +/* ---------------------------------------------------------------------- */ + +#define VALID_CHARPTR_P(ptr) 1 +#define VALIDATE_CHARPTR_BACKWARD(ptr) +#define VALIDATE_CHARPTR_FORWARD(ptr) + +/* -------------------------------------------------------------------- */ +/* (C) For retrieving or changing the character pointed to by a charptr */ +/* -------------------------------------------------------------------- */ + +#define charptr_emchar(ptr) ((Emchar) (ptr)[0]) +#define set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1) +#define charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1) + +#endif /* _XEMACS_MB_1BYTE_H */ diff --git a/src/mb-multibyte.h b/src/mb-multibyte.h new file mode 100644 index 0000000..69f137c --- /dev/null +++ b/src/mb-multibyte.h @@ -0,0 +1,89 @@ +/* Header for generic multibyte string representation. + Copyright (C) 1999 Electrotechnical Laboratory, JAPAN. + Licensed to the Free Software Foundation. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Rewritten by MORIOKA Tomohiko . */ + +#ifndef _XEMACS_MB_MULTIBYTE_H +#define _XEMACS_MB_MULTIBYTE_H + +/* ---------------------------------------------------------------------- */ +/* (A) For working with charptr's (pointers to internally-formatted text) */ +/* ---------------------------------------------------------------------- */ + +# define VALID_CHARPTR_P(ptr) BUFBYTE_FIRST_BYTE_P (* (unsigned char *) ptr) + +#define VALIDATE_CHARPTR_BACKWARD(ptr) do { \ + while (!VALID_CHARPTR_P (ptr)) ptr--; \ +} while (0) + +/* This needs to be trickier to avoid the possibility of running off + the end of the string. */ + +#define VALIDATE_CHARPTR_FORWARD(ptr) do { \ + Bufbyte *vcf_ptr = (ptr); \ + VALIDATE_CHARPTR_BACKWARD (vcf_ptr); \ + if (vcf_ptr != (ptr)) \ + { \ + (ptr) = vcf_ptr; \ + INC_CHARPTR (ptr); \ + } \ +} while (0) + +/* -------------------------------------------------------------------- */ +/* (C) For retrieving or changing the character pointed to by a charptr */ +/* -------------------------------------------------------------------- */ + +#define simple_charptr_emchar(ptr) ((Emchar) (ptr)[0]) +#define simple_set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1) +#define simple_charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1) + +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); + +INLINE Emchar charptr_emchar (CONST Bufbyte *ptr); +INLINE 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 +set_charptr_emchar (Bufbyte *ptr, Emchar x) +{ + return !CHAR_MULTIBYTE_P (x) ? + simple_set_charptr_emchar (ptr, x) : + 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) +{ + return BYTE_ASCII_P (*ptr) ? + simple_charptr_copy_char (ptr, ptr2) : + non_ascii_charptr_copy_char (ptr, ptr2); +} + +#endif /* _XEMACS_MB_MULTIBYTE_H */ -- 1.7.10.4