I am close to having this done, but it will take a bit longer, perhaps another
week, or two at the most.
I have done a lot of work, and am enclosing a patch showing what I've done.
Yoshiki, please don't pressure me to have this done sooner; I can only work as
fast as my hands will allow me, and they are hurting a lot now.
--
Ben
In order to save my hands, I am cutting back on my mail. I also write
as succinctly as possible -- please don't be offended. If you send me
mail, you _will_ get a response, but please be patient, especially for
XEmacs-related mail. If you need an immediate response and it is not
apparent in your message, please say so. Thanks for your understanding.
See also
http://www.666.com/ben/typing.html.
? config.h
? new
? lib-src/hexl.pdb
? lib-src/i.pdb
? lib-src/make-docfile.pdb
? lib-src/mmencode.pdb
? lib-src/movemail.pdb
? lib-src/run.res
? lib-src/sorted-doc.pdb
? lib-src/vc50.pdb
? lib-src/wakeup.pdb
? nt/obj
? src/coding-slots.h
? src/file-coding.c.save
? src/runxemacs.pdb
? src/syswindows.h
? src/temacs.bsc
? src/temacs.map
? src/win32.c
Index: configure.in
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/configure.in,v
retrieving revision 1.111.2.98
diff -u -r1.111.2.98 configure.in
--- configure.in 2000/04/14 16:15:27 1.111.2.98
+++ configure.in 2000/04/30 09:04:55
@@ -496,7 +496,6 @@
with_toolbars | \
with_tty | \
with_xfs | \
- with_i18n3 | \
with_mule | \
with_file_coding| \
with_canna | \
@@ -4461,7 +4460,6 @@
elif test "$with_debug_malloc" = "yes"; then
AC_DEFINE(USE_DEBUG_MALLOC)
AC_DEFINE(USE_SYSTEM_MALLOC)
fi
-test "$with_i18n3" = "yes" && AC_DEFINE(I18N3)
test "$GCC" = "yes" && AC_DEFINE(USE_GCC)
test "$external_widget" = "yes" &&
AC_DEFINE(EXTERNAL_WIDGET)
test "$no_doc_file" = "yes" && AC_DEFINE(NO_DOC_FILE)
@@ -4659,7 +4657,6 @@
echo " Compiling in support for the WNN input method on Mule."
test "$with_wnn6" = yes && echo " - Using WNN version
6."
fi
-test "$with_i18n3" = yes && echo " Compiling in support for I18N
level 3 (doesn't currently work)."
echo "
Mail:"
Index: lisp/msw-font-menu.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/Attic/msw-font-menu.el,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 msw-font-menu.el
--- msw-font-menu.el 1999/05/30 23:07:50 1.1.2.1
+++ msw-font-menu.el 2000/04/30 09:05:00
@@ -64,9 +64,7 @@
when they are selected for the first time. If you add fonts to your system,
or if you change your font path, you can call this to re-initialize the menus."
(unless mswindows-font-regexp-ascii
- (setq mswindows-font-regexp-ascii (if (featurep 'mule)
- (charset-registry 'ascii)
- "Western")))
+ (setq mswindows-font-regexp-ascii "Western"))
(setq mswindows-font-menu-registry-encoding (if (featurep 'mule) ""
"Western"))
(let ((case-fold-search t)
family size weight entry
Index: lisp/mule/arabic.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/arabic.el,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 arabic.el
--- arabic.el 1999/02/17 14:01:55 1.4.2.1
+++ arabic.el 2000/04/30 09:05:00
@@ -55,6 +55,16 @@
direction r2l
))
+(make-coding-system 'iso-8859-6 'iso2022
+ "MIME ISO-8859-6"
+ '(charset-g0 ascii
+ charset-g1 arabic-iso8859-6
+ charset-g2 t
+ charset-g3 t
+ no-iso6429 t
+ mnemonic "MIME/Arbc"
+ ))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ARABIC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Index: lisp/mule/chinese.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/chinese.el,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 chinese.el
--- chinese.el 1999/07/22 06:19:46 1.4.2.2
+++ chinese.el 2000/04/30 09:05:00
@@ -209,6 +209,9 @@
(charset chinese-gb2312 sisheng)
(coding-system cn-gb-2312 iso-2022-7bit hz-gb-2312)
(coding-priority cn-gb-2312 big5 iso-2022-7bit)
+ (locale . ((running-mswindows-any) "chinese-simplified"
+ t ("zho_CN" "zh_CN" "chi_CN" "zho"
"zh" "chi"))
+ (mswindows-locale . ("CHINESE" "CHINESE_SIMPLIFIED"))
(input-method . "chinese-py-punct")
(features china-util)
(sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B")
@@ -262,6 +265,9 @@
"Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2)
(coding-system big5 iso-2022-7bit)
(coding-priority big5 cn-gb-2312 iso-2022-7bit)
+ (locale . ((running-mswindows-any) "chinese-traditional"
+ t ("zho_TW" "zh_TW" "chi_TW" "zho"
"zh" "chi"))
+ (mswindows-locale . ("CHINESE" "CHINESE_TRADITIONAL"))
(input-method . "chinese-py-punct-b5")
(features china-util)
(sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B,
$(0+$)p(B")
Index: lisp/mule/english.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/english.el,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 english.el
--- english.el 2000/01/26 11:36:43 1.1.2.3
+++ english.el 2000/04/30 09:05:00
@@ -38,6 +38,9 @@
(set-language-info-alist
"English" '((tutorial . "TUTORIAL")
+ (locale . ((running-mswindows-any) "english"
+ t "en"))
+ (mswindows-locale . ("ENGLISH"))
(charset ascii)
(sample-text . "Hello!, Hi!, How are you?")
(documentation . "\
Index: lisp/mule/european.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/european.el,v
retrieving revision 1.3.2.5
diff -u -r1.3.2.5 european.el
--- european.el 2000/02/07 07:59:17 1.3.2.5
+++ european.el 2000/04/30 09:05:00
@@ -247,6 +247,10 @@
"Czech" '((charset ascii latin-iso8859-2)
(coding-system iso-8859-2)
(coding-priority iso-8859-2)
+ (locale . ((running-mswindows-any) "czech"
+ t ("csy" "cs" "cz"))
+ (mswindows-locale . ("CZECH"))
+ (input-method . "latin-2-postfix")
(tutorial . "TUTORIAL.cs")
(sample-text . "P,Bx(Bejeme v,Ba(Bm hezk,B}(B den!")
(documentation . t))
@@ -380,6 +384,9 @@
(charset ascii latin-iso8859-1)
(coding-system iso-8859-1)
(coding-priority iso-8859-1)
+ (locale . ((running-mswindows-any) "german"
+ t "de"))
+ (mswindows-locale . ("GERMAN"))
(input-method . "german-postfix")
(sample-text . "\
German (Deutsch Nord) Guten Tag
@@ -398,6 +405,9 @@
"Slovenian" '((charset . (ascii latin-iso8859-2))
(coding-system . (iso-8859-2))
(coding-priority . (iso-8859-2))
+ (locale . ((running-mswindows-any) "slovenian"
+ t "sl"))
+ (mswindows-locale . ("SLOVENIAN"))
(input-method . "latin-2-postfix")
(tutorial . "TUTORIAL.sl")
(sample-text . ",B.(Belimo vam uspe,B9(Ben dan!")
Index: lisp/mule/japanese.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/japanese.el,v
retrieving revision 1.3.2.3
diff -u -r1.3.2.3 japanese.el
--- japanese.el 1999/07/26 07:44:11 1.3.2.3
+++ japanese.el 2000/04/30 09:05:00
@@ -256,6 +256,9 @@
shift_jis iso-2022-jp-2)
(coding-priority iso-2022-jp euc-jp
shift_jis iso-2022-jp-2)
+ (locale . ((running-mswindows-any) "japanese"
+ t ("jpn" "ja")))
+ (mswindows-locale . ("JAPANESE"))
;; (input-method . "japanese")
(features japan-util)
(sample-text . "Japanese ($BF|K\8l(B) $B$3$s$K$A$O(B, )IºÝÆÁÊ")-A
Index: lisp/mule/korean.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/korean.el,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 korean.el
--- korean.el 1999/07/22 06:19:47 1.3.2.2
+++ korean.el 2000/04/30 09:05:00
@@ -114,6 +114,9 @@
(charset korean-ksc5601)
(coding-system euc-kr iso-2022-kr)
(coding-priority euc-kr iso-2022-kr)
+ (locale . ((running-mswindows-any) "korean"
+ t ("kor" "ko")))
+ (mswindows-locale . ("KOREAN"))
(input-method . "korean-hangul")
(features korea-util)
(sample-text . "Hangul ($(CGQ1[(B) $(C>H3gGO<<?d(B,
$(C>H3gGO=J4O1n(B")
Index: lisp/mule/mule-cmds.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/mule-cmds.el,v
retrieving revision 1.11.2.9
diff -u -r1.11.2.9 mule-cmds.el
--- mule-cmds.el 2000/03/22 03:40:06 1.11.2.9
+++ mule-cmds.el 2000/04/30 09:05:02
@@ -1155,6 +1155,23 @@
(setq current-language-environment language-name)
(set-language-environment-coding-systems language-name default-eol-type))
+
+ (let ((locale (get-language-info language-name 'locale)))
+ (while locale
+ (let ((expr (pop locale))
+ (locs (pop locale)))
+ (if (eval expr)
+ (or (listp locs) (setq locs (list locs)))
+ (dolist (loc locs)
+ (let ((curloc (set-current-locale loc)))
+ (if (and curloc (string-match loc curloc))
+ (return nil))))))))
+
+ (if (fboundp 'mswindows-set-current-locale)
+ (let ((locale (get-language-info language-name 'mswindows-locale)))
+ (or (listp locale) (setq locale (list locale)))
+ (mswindows-set-current-locale (first locale) (second locale))))
+
(let ((input-method (get-language-info language-name 'input-method)))
(when input-method
(setq default-input-method input-method)
Index: lisp/mule/mule-init.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/mule-init.el,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 mule-init.el
--- mule-init.el 2000/01/26 11:36:43 1.12.2.2
+++ mule-init.el 2000/04/30 09:05:02
@@ -83,6 +83,25 @@
It the value of the environment variable LANG matches the regexp REGEXP,
then `set-language-environment' is called with LANGUAGE-ENVIRONMENT.")
+(if (fboundp 'set-mswindows-code-page-mapping)
+ (progn
+ (set-mswindows-code-page-mapping 936 'cn-gb-2312)
+ (set-mswindows-code-page-mapping 949 'euc-kr)
+ (set-mswindows-code-page-mapping 932 'shift_jis)
+ (set-mswindows-code-page-mapping 936 'cn-gb-2312)
+ (set-mswindows-code-page-mapping 950 'big5)
+ (set-mswindows-code-page-mapping 1250 'iso-8859-2)
+ ;(set-mswindows-code-page-mapping 1251 'windows-1251)
+ (set-mswindows-code-page-mapping 1252 'iso-8859-1)
+ (set-mswindows-code-page-mapping 1253 'iso-8859-7)
+ (set-mswindows-code-page-mapping 1254 'iso-8859-9)
+ (set-mswindows-code-page-mapping 1255 'iso-8859-8)
+ (set-mswindows-code-page-mapping 1256 'iso-8859-6)
+ ;(set-mswindows-code-page-mapping 1257 'windows-1257)
+ ))
+
+
+
(defun init-mule ()
"Initialize MULE environment at startup. Don't call this."
(let ((lang (or (getenv "LC_ALL") (getenv "LC_MESSAGES") (getenv
"LANG"))))
Index: lisp/mule/vietnamese.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/mule/Attic/vietnamese.el,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 vietnamese.el
--- vietnamese.el 2000/01/26 11:36:43 1.2.2.4
+++ vietnamese.el 2000/04/30 09:05:03
@@ -285,6 +285,9 @@
"Vietnamese" '((charset vietnamese-viscii-lower vietnamese-viscii-upper)
(coding-system viscii vscii viqr)
(coding-priority viscii)
+ (locale . ((running-mswindows-any) "vietnamese"
+ t "vi"))
+ (mswindows-locale . ("VIETNAMESE"))
(input-method . "vietnamese-viqr")
(features viet-util)
(sample-text . "Vietnamese (Ti,1*(Bng Vi,1.(Bt) Ch,1`(Bo b,1U(Bn")
Index: nt/config.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/nt/config.h,v
retrieving revision 1.19.2.10
diff -u -r1.19.2.10 config.h
--- config.h 2000/03/27 11:59:05 1.19.2.10
+++ config.h 2000/04/30 09:05:06
@@ -370,20 +370,6 @@
it to be able to override any changes in them. */
#undef RAW_PURESIZE
-/* Define this if you want level 2 internationalization compliance
- (localized collation and formatting). Generally this should be
- defined, unless your system doesn't have the strcoll() and
- setlocale() library routines. This really should be (NOT! -mrb)
- defined in the appropriate s/ or m/ file. */
-#undef I18N2
-
-/* Define this if you want level 3 internationalization compliance
- (localized messaging). This will cause a small runtime performance
- penalty, as the strings are read from the message catalog(s).
- For this you need the gettext() and dgetext() library routines.
- WARNING, this code is under construction. */
-#undef I18N3
-
/* Compile in support for CDE (Common Desktop Environment) drag and drop?
Requires libDtSvc, which typically must be present at runtime. */
#undef HAVE_CDE
@@ -559,6 +545,17 @@
#define ENCAPSULATE_OPEN
#define ENCAPSULATE_FOPEN
#define ENCAPSULATE_MKDIR
+
+#ifdef MULE
+# define ENCAPSULATE_CHDIR
+# define ENCAPSULATE_RMDIR
+# define ENCAPSULATE_ACCESS
+# define ENCAPSULATE_CHMOD
+# define ENCAPSULATE_CREAT
+# define ENCAPSULATE_RENAME
+# define ENCAPSULATE_UNLINK
+# define ENCAPSULATE_EXECVP
+#endif /* MULE */
#if defined (WIN32) && defined (USE_IME)
#define HAVE_FEP
Index: src/EmacsFrame.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/EmacsFrame.c,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 EmacsFrame.c
--- EmacsFrame.c 2000/02/07 07:59:40 1.16.2.3
+++ EmacsFrame.c 2000/04/30 09:05:11
@@ -156,13 +156,8 @@
XtRInt, sizeof (int),
offset (interline), XtRImmediate, (XtPointer)0 },
{
-#ifdef I18N4
- XtNfontSet, XtCFontSet,
- XtRFontSet, sizeof (XFontSet),
-#else
XtNfont, XtCFont,
XtRFontStruct, sizeof (XFontStruct *),
-#endif
offset(font), XtRImmediate, (XtPointer)0
},
{ XtNforeground, XtCForeground,
@@ -330,11 +325,6 @@
LeaveWindowMask |
EnterWindowMask;
-
-#ifdef I18N4
- /* Make sure that events wanted by the input method are selected. */
- attrs->event_mask |= input_method_event_mask;
-#endif
*mask |= CWEventMask;
Index: src/buffer.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/buffer.c,v
retrieving revision 1.36.2.28
diff -u -r1.36.2.28 buffer.c
--- buffer.c 2000/03/09 09:58:58 1.36.2.28
+++ buffer.c 2000/04/30 09:05:12
@@ -2009,7 +2009,9 @@
if (sink_type != DFC_TYPE_LISP_LSTREAM)
{
sink->data.len = Dynarr_length (conversion_out_dynarr);
+ /* double zero-extend because we may be dealing with Unicode data */
Dynarr_add (conversion_out_dynarr, 0);
+ Dynarr_add (conversion_out_dynarr, 0);
sink->data.ptr = Dynarr_atp (conversion_out_dynarr, 0);
}
}
@@ -2152,6 +2154,41 @@
}
+/***************************************************************************/
+/* Eistring helper functions */
+/***************************************************************************/
+
+int
+eistr_casefiddle_1 (Bufbyte *olddata, Bytecount len, Bufbyte *newdata,
+ int downp)
+{
+ Bufbyte *endp = olddata + len;
+ Bufbyte *newp = newdata;
+ int changedp = 0;
+
+ while (olddata < endp)
+ {
+ Emchar c = charptr_emchar (olddata);
+ Emchar newc;
+
+ if (downp)
+ newc = DOWNCASE (0, c);
+ else
+ newc = UPCASE (0, c);
+
+ if (c != newc)
+ changedp = 1;
+
+ newp += set_charptr_emchar (newp, newc);
+ INC_CHARPTR (olddata);
+ }
+
+ *newp = '\0';
+
+ return changedp ? newp - newdata : 0;
+}
+
+
void
syms_of_buffer (void)
{
Index: src/buffer.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/buffer.h,v
retrieving revision 1.13.2.19
diff -u -r1.13.2.19 buffer.h
--- buffer.h 2000/04/06 07:05:42 1.13.2.19
+++ buffer.h 2000/04/30 09:05:13
@@ -379,6 +379,202 @@
MAX_EMCHAR_LEN:
Maximum number of buffer bytes per Emacs character.
+ (E) For working with Eistrings:
+ -------------------------------
+
+ NOTE: An Eistring is a structure that makes it easy to work with
+ internally-formatted strings of data. It provides operations similar
+ in feel to the standard strcpy(), strcat(), strlen(), etc., but
+
+ (a) it is Mule-correct
+ (b) it does dynamic allocation so you never have to worry about size
+ restrictions (and all allocation is stack-local using alloca(), so
+ there is no need to explicitly clean up)
+ (c) it knows its own length, so it does not suffer from standard null
+ byte brain-damage
+ (d) it provides a much more powerful set of operations and knows about
+ all the standard places where string data might reside: Lisp_Objects,
+ other Eistrings, char * data with or without an explicit length, etc.
+ (e) it provides easy operations to convert to/from externally-formatted
+ data, and is much easier to use than the standard TO_INTERNAL_FORMAT
+ and TO_EXTERNAL_FORMAT macros.
+
+ The idea is to make it as easy to write Mule-correct string manipulation
+ code as it is to write normal string manipulation code. We also make
+ the API sufficiently general that it can handle multiple internal data
+ formats (e.g. some fixed-width optimizing formats and a default variable
+ width format) and allows for *ANY* data format we might choose in the
+ future for the default format, including UCS2. (In other words, we can't
+ assume that the internal format is ASCII-compatible and we can't assume
+ it doesn't have embedded null bytes.) All of this is hidden from the
+ user.
+
+ #### It is really too bad that we don't have a real object-oriented
+ language, or at least a language with polymorphism!
+
+ Eistring (name):
+ Declare a new Eistring. This is a standard local variable declaration
+ and can go anywhere in the variable declaration section, but note that
+ you *MUST* supply the parens.
+
+ ----- Initialization -----
+
+ eicpy_* (eistr, ...):
+ Initialize the Eistring from somewhere:
+
+ eicpy_ei (eistr, eistr2):
+ ... from another Eistring
+ eicpy_str (eistr, lisp_string):
+ ... from a Lisp_Object string
+ eicpy_str_off (eistr, lisp_string, charpos, charlen):
+ ... from a section of a Lisp_Object string
+ eicpy_str_off_byte (eistr, lisp_string, bytepos, bytelen):
+ ... from a section of a Lisp_Object string, with offset and length
+ specified in bytes rather than chars
+ eicpy_buf (eistr, lisp_buf, charpos, charlen):
+ ... from a Lisp_Object buffer
+ eicpy_buf_byte (eistr, lisp_buf, bytepos, bytelen):
+ ... from a Lisp_Object buffer, with offset and length specified in
+ bytes rather than chars
+ eicpy_raw (eistr, intdata, intlen, intfmt):
+ ... from raw internal-format data in the specified format
+ eicpy_c (eistr, c_string):
+ ... from an ASCII null-terminated string. Non-ASCII characters in
+ the string are *ILLEGAL* (read abort() with error-checking defined).
+ eicpy_c_len (eistr, c_string, len):
+ ... from an ASCII string, with length specified. Non-ASCII characters
+ in the string are *ILLEGAL* (read abort() with error-checking defined).
+ eicpy_ext (eistr, extdata, coding_system):
+ ... from external null-terminated data, with coding system specified.
+ eicpy_ext_len (eistr, extdata, extlen, coding_system):
+ ... from external data, with length and coding system specified.
+ eicpy_lstream (eistr, lstream):
+ ... from an lstream; reads data till eof. Data must be in default
+ internal format; otherwise, interpose a decoding lstream.
+
+ ----- Getting the data out of the Eistring -----
+
+ eirawdata (eistr):
+ eimake_string (eistr):
+ eimake_string_sect (eistr, charpos, charlen):
+ eimake_string_sect_byte (eistr, bytepos, bytelen):
+ eicpyout_raw_alloca (eistr, intfmt, intlen_out):
+ eicpyout_raw_malloc (eistr, intfmt, intlen_out):
+ eicpyout_c_alloca (eistr):
+ eicpyout_c_malloc (eistr):
+ eicpyout_c_len_alloca (eistr, len_out):
+ eicpyout_c_len_malloc (eistr, len_out):
+
+ ----- Moving to the heap -----
+
+ eito_malloc (eistr):
+ eifree (eistr):
+ eito_alloca (eistr):
+
+ ----- Retrieving the length -----
+
+ eilen (eistr):
+ eilen_byte (eistr):
+
+ ----- Working with positions -----
+
+ eicharpos_to_bytepos (eistr, charpos):
+ eibytepos_to_charpos (eistr, bytepos):
+
+ ----- Getting the character at a position -----
+
+ eiref (eistr, charpos):
+ eiref_byte (eistr, bytepos):
+
+ ----- Concatenation -----
+
+ eicat_* (eistr, ...):
+ Concatenate onto the end of the Eistring, with data coming from the
+ same places as above. (All functions that take string sources allow
+ only two possibilities: Another Eistring and a simple C string.
+ In the general case, create another Eistring from the source.)
+
+ eicat_ei (eistr, eistr2):
+ eicat_c (eistr, c_string):
+
+ ----- Replacement -----
+
+ eisub_* (eistr, charoff, charlen, ...):
+ eisub_*_byte (eistr, byteoff, bytelen, ...):
+ Replace a section of the Eistring.
+
+ eisub_ei (eistr, charoff, charlen, eistr2):
+ eisub_ei_byte (eistr, byteoff, bytelen, eistr2):
+
+ eisub_c (eistr, charoff, charlen, c_string):
+ eisub_c_byte (eistr, byteoff, bytelen, c_string):
+
+ ----- Converting to an external format -----
+
+ eito_external (eistr, coding_system):
+ eiextdata (eistr):
+ eiextlen (eistr):
+
+ ----- Searching in the Eistring for a character -----
+
+ eichr (eistr, chr):
+ eichr_byte (eistr, chr):
+ eichr_off (eistr, chr, charpos):
+ eichr_off_byte (eistr, chr, bytepos):
+ eirchr (eistr, chr):
+ eirchr_byte (eistr, chr):
+ eirchr_off (eistr, chr, charpos):
+ eirchr_off_byte (eistr, chr, bytepos):
+
+ ----- Searching in the Eistring for a string -----
+
+ eistr_ei (eistr, eistr2):
+ eistr_ei_byte (eistr, eistr2):
+ eistr_ei_off (eistr, eistr2, charpos):
+ eistr_ei_off_byte (eistr, eistr2, bytepos):
+ eirstr_ei (eistr, eistr2):
+ eirstr_ei_byte (eistr, eistr2):
+ eirstr_ei_off (eistr, eistr2, charpos):
+ eirstr_ei_off_byte (eistr, eistr2, bytepos):
+
+ eistr_c (eistr, c_string):
+ eistr_c_byte (eistr, c_string):
+ eistr_c_off (eistr, c_string, charpos):
+ eistr_c_off_byte (eistr, c_string, bytepos):
+ eirstr_c (eistr, c_string):
+ eirstr_c_byte (eistr, c_string):
+ eirstr_c_off (eistr, c_string, charpos):
+ eirstr_c_off_byte (eistr, c_string, bytepos):
+
+ ----- Comparison -----
+
+ eicmp_* (eistr, ...):
+ eicmp_off_* (eistr, charoff, charlen, ...):
+ eicmp_off_*_byte (eistr, byteoff, bytelen, ...):
+ eicasecmp_* (eistr, ...):
+ eicasecmp_off_* (eistr, charoff, charlen, ...):
+ eicasecmp_off_*_byte (eistr, byteoff, bytelen, ...):
+ Compare the Eistring with the other data. Return value same as
+ from strcmp.
+
+ eicmp_ei (eistr, eistr2):
+ eicmp_off_ei (eistr, charoff, charlen, eistr2):
+ eicmp_off_ei_byte (eistr, byteoff, bytelen, eistr2):
+ eicasecmp_ei (eistr, eistr2):
+ eicasecmp_off_ei (eistr, charoff, charlen, eistr2):
+ eicasecmp_off_ei_byte (eistr, byteoff, bytelen, eistr2):
+
+ eicmp_c (eistr, c_string):
+ eicmp_off_c (eistr, charoff, charlen, c_string):
+ eicmp_off_c_byte (eistr, byteoff, bytelen, c_string):
+ eicasecmp_c (eistr, c_string):
+ eicasecmp_off_c (eistr, charoff, charlen, c_string):
+ eicasecmp_off_c_byte (eistr, byteoff, bytelen, c_string):
+
+ ----- Case-changing the Eistring -----
+
+ eilwr (eistr):
+ eiupr (eistr):
*/
@@ -588,6 +784,325 @@
# define MAX_EMCHAR_LEN 1
#endif
+/* ------------------------------ */
+/* (E) For working with Eistrings */
+/* ------------------------------ */
+
+/* Note: Unfortunately, we have to write most of the Eistring functions as
+ macros, because of the use of alloca(). The principle used below to assure
+ no conflict in local variables is to prefix all local variables with "ei"
+ plus a number, which should be unique among macros. In practice, when
+ finding a new number, use one greater than all existing numbers. */
+
+typedef struct
+{
+ void *data;
+ Bytecount max_size_allocated;
+ Bytecount bytelen;
+ Charcount charlen;
+ int mallocp;
+
+ void *extdata;
+ Extcount extlen;
+} Eistring_;
+
+Eistring_ the_eistring_zero_init;
+
+#define Eistring(name) Eistring_ name = the_eistring_zero_init
+
+/* ----- Initialization ----- */
+
+/* Make sure we can hold BYTELEN bytes plus a zero terminator.
+ Preserve existing data as much as possible. */
+
+#define EI_ALLOC_(ei, charlen, bytelen) \
+do { \
+ int ei1oldeibytelen = (ei).bytelen; \
+ int ei1newbytelen = bytelen; \
+ int ei1newcharlen = charlen; \
+ \
+ (ei).charlen = ei1newcharlen; \
+ (ei).bytelen = ei1newbytelen; \
+ \
+ if (ei1oldeibytelen != (ei).bytelen) \
+ { \
+ if ((ei).mallocp) \
+ /* xrealloc always preserves existing data as much as possible */ \
+ (ei).data = xrealloc ((ei).data, (ei).bytelen + 1); \
+ else if ((ei).bytelen + 1 > (ei).max_size_allocated) \
+ { \
+ /* We don't have realloc, so just use the existing allocation \
+ if it's big enough; but remember how big it really is. */ \
+ void *ei1oldeidata = (ei).data; \
+ (ei).max_size_allocated = (ei).bytelen + 1; \
+ (ei).data = alloca ((ei).max_size_allocated); \
+ memcpy ((ei).data, ei1oldeidata, ei1oldeibytelen); \
+ } \
+ ((char *) (ei).data)[(ei).bytelen] = '\0'; \
+ } \
+} while (0)
+
+#define EI_ALLOC_AND_COPY_(ei, data, charlen, bytelen) \
+do { \
+ EI_ALLOC_ (ei, charlen, bytelen); \
+ memcpy ((ei).data, data, (ei).bytelen); \
+} while (0)
+
+#define eicpy_ei(ei, eicpy) \
+do { \
+ Eistring_ *ei2 = &(eicpy); \
+ EI_ALLOC_AND_COPY_ (ei, ei2->data, ei2->charlen, ei2->bytelen); \
+} while (0)
+
+#define eicpy_str(ei, lisp_string) \
+do { \
+ Lisp_Object ei3 = (lisp_string); \
+ EI_ALLOC_AND_COPY_ (ei, XSTRING_DATA (ei3), XSTRING_CHAR_LENGTH (ei3), \
+ XSTRING_LENGTH (ei3)); \
+} while (0)
+
+#ifdef ERROR_CHECK_BUFPOS
+#define EI_ASSERT_ASCII_(ptr, len) \
+do { \
+ int ei5; \
+ \
+ /* we use PTR and LEN multiply; we assume the callers have macro-protected \
+ them. */ \
+ for (ei5 = 0; ei5 < len; ei5++) \
+ assert (ptr[ei5] >= 0x20 && ptr[ei5] < 0x7F); \
+} while (0)
+#else
+#define EI_ASSERT_ASCII_(ptr, len)
+#endif
+
+#define eicpy_c(ei, c_string) \
+do { \
+ char *ei4 = (char *) (c_string); \
+ \
+ EI_ASSERT_ASCII_ (ei4, strlen (ei4)); \
+ eicpy_ext (ei, ei4c, Qbinary); \
+} while (0)
+
+#define eicpy_c_len(ei, c_string, c_len) \
+do { \
+ char *ei6 = (char *) (c_string); \
+ int ei6len = (c_len); \
+ \
+ EI_ASSERT_ASCII_ (ei6, ei6len); \
+ eicpy_ext_len (ei, ei6, ei6len, Qbinary); \
+} while (0)
+
+#define eicpy_ext_len(ei, extdata, extlen, coding_system) \
+do { \
+ char *ei7 = (char *) (extdata); \
+ int ei7len = (extlen); \
+ \
+ TO_INTERNAL_FORMAT (DATA, (ei7, ei7len), \
+ ALLOCA, ((ei).data, (ei).bytelen), \
+ coding_system); \
+ (ei).max_size_allocated = (ei).bytelen + 1; \
+ (ei).charlen = bytecount_to_charcount ((ei).data, (ei).bytelen); \
+} while (0)
+
+#define eicpy_ext(ei, extdata, coding_system) \
+do { \
+ char *ei8 = (char *) (extdata); \
+ \
+ eicpy_ext_len (ei, ei8, strlen (ei8), coding_system); \
+} while (0)
+
+/*
+ eicpy_str_off (eistr, lisp_string, charpos, charlen):
+ ... from a section of a Lisp_Object string
+ eicpy_str_off_byte (eistr, lisp_string, bytepos, bytelen):
+ ... from a section of a Lisp_Object string, with offset and length
+ specified in bytes rather than chars
+ eicpy_buf (eistr, lisp_buf, charpos, charlen):
+ ... from a Lisp_Object buffer
+ eicpy_buf_byte (eistr, lisp_buf, bytepos, bytelen):
+ ... from a Lisp_Object buffer, with offset and length specified in
+ bytes rather than chars
+ eicpy_raw (eistr, intdata, intlen, intfmt):
+ ... from raw internal-format data in the specified format
+ eicpy_lstream (eistr, lstream):
+ ... from an lstream; reads data till eof. Data must be in default
+ internal format; otherwise, interpose a decoding lstream.
+*/
+
+/* ----- Getting the data out of the Eistring ----- */
+
+#define eirawdata(ei) ((ei).data)
+
+/*
+ eimake_string (eistr):
+ eimake_string_sect (eistr, charpos, charlen):
+ eimake_string_sect_byte (eistr, bytepos, bytelen):
+ eicpyout_raw_alloca (eistr, intfmt, intlen_out):
+ eicpyout_raw_malloc (eistr, intfmt, intlen_out):
+ eicpyout_c_alloca (eistr):
+ eicpyout_c_malloc (eistr):
+ eicpyout_c_len_alloca (eistr, len_out):
+ eicpyout_c_len_malloc (eistr, len_out):
+*/
+
+/* ----- Moving to the heap ----- */
+
+/*
+ eito_malloc (eistr):
+ eifree (eistr):
+ eito_alloca (eistr):
+*/
+
+/* ----- Retrieving the length ----- */
+
+#define eilen(ei) ((ei).charlen)
+#define eilen_byte(ei) ((ei).bytelen)
+
+/* ----- Working with positions ----- */
+
+#define eicharpos_to_bytepos(ei, charpos) \
+ charcount_to_bytecount ((ei).data, charpos)
+#define eibytepos_to_charpos(ei, bytepos) \
+ bytecount_to_charcount ((ei).data, bytepos)
+
+/* ----- Getting the character at a position ----- */
+
+#define eiref(ei, charpos) charptr_emchar_n ((ei).data, charpos)
+#define eiref_byte(ei, bytepos) \
+ charptr_emchar ((char *) ((ei).data) + (bytepos))
+
+/* ----- Concatenation ----- */
+
+#define eicat_ei(ei, ei2) \
+do { \
+ Eistring__ *ei9 = &(ei2); \
+ int ei9oldeibytelen = (ei).bytelen; \
+ EI_ALLOC_ (ei, (ei).charlen + ei9->charlen, \
+ (ei).bytelen + ei9->bytelen); \
+ memcpy ((char *) (ei).data + ei9oldeibytelen, ei9->data, \
+ ei9->bytelen); \
+} while (0)
+
+#define eicat_c(ei, c_string) \
+do { \
+ Eistring (ei10); \
+ \
+ eicpy_c (ei10, c_string); \
+ eicat_ei (ei, ei10); \
+} while (0)
+
+/* ----- Replacement ----- */
+
+/*
+ eisub_* (eistr, charoff, charlen, ...):
+ eisub_*_byte (eistr, byteoff, bytelen, ...):
+ Replace a section of the Eistring.
+
+ eisub_ei (eistr, charoff, charlen, eistr2):
+ eisub_ei_byte (eistr, byteoff, bytelen, eistr2):
+
+ eisub_c (eistr, charoff, charlen, c_string):
+ eisub_c_byte (eistr, byteoff, bytelen, c_string):
+*/
+
+/* ----- Converting to an external format ----- */
+
+#define eito_external(ei, coding_system) \
+do { \
+ TO_EXTERNAL_FORMAT (DATA, ((ei).data, (ei).bytelen), \
+ ALLOCA, ((ei).extdata, (ei).extlen), \
+ coding_system); \
+} while (0)
+
+#define eiextdata(ei) ((ei).extdata)
+#define eiextlen(ei) ((ei).extlen)
+
+/* ----- Searching in the Eistring for a character ----- */
+
+/*
+ eichr (eistr, chr):
+ eichr_byte (eistr, chr):
+ eichr_off (eistr, chr, charpos):
+ eichr_off_byte (eistr, chr, bytepos):
+ eirchr (eistr, chr):
+ eirchr_byte (eistr, chr):
+ eirchr_off (eistr, chr, charpos):
+ eirchr_off_byte (eistr, chr, bytepos):
+*/
+
+/* ----- Searching in the Eistring for a string ----- */
+
+/*
+ eistr_ei (eistr, eistr2):
+ eistr_ei_byte (eistr, eistr2):
+ eistr_ei_off (eistr, eistr2, charpos):
+ eistr_ei_off_byte (eistr, eistr2, bytepos):
+ eirstr_ei (eistr, eistr2):
+ eirstr_ei_byte (eistr, eistr2):
+ eirstr_ei_off (eistr, eistr2, charpos):
+ eirstr_ei_off_byte (eistr, eistr2, bytepos):
+
+ eistr_c (eistr, c_string):
+ eistr_c_byte (eistr, c_string):
+ eistr_c_off (eistr, c_string, charpos):
+ eistr_c_off_byte (eistr, c_string, bytepos):
+ eirstr_c (eistr, c_string):
+ eirstr_c_byte (eistr, c_string):
+ eirstr_c_off (eistr, c_string, charpos):
+ eirstr_c_off_byte (eistr, c_string, bytepos):
+*/
+
+/* ----- Comparison ----- */
+
+/*
+ eicmp_* (eistr, ...):
+ eicmp_off_* (eistr, charoff, charlen, ...):
+ eicmp_off_*_byte (eistr, byteoff, bytelen, ...):
+ eicasecmp_* (eistr, ...):
+ eicasecmp_off_* (eistr, charoff, charlen, ...):
+ eicasecmp_off_*_byte (eistr, byteoff, bytelen, ...):
+ Compare the Eistring with the other data. Return value same as
+ from strcmp.
+
+ eicmp_ei (eistr, eistr2):
+ eicmp_off_ei (eistr, charoff, charlen, eistr2):
+ eicmp_off_ei_byte (eistr, byteoff, bytelen, eistr2):
+ eicasecmp_ei (eistr, eistr2):
+ eicasecmp_off_ei (eistr, charoff, charlen, eistr2):
+ eicasecmp_off_ei_byte (eistr, byteoff, bytelen, eistr2):
+
+ eicmp_c (eistr, c_string):
+ eicmp_off_c (eistr, charoff, charlen, c_string):
+ eicmp_off_c_byte (eistr, byteoff, bytelen, c_string):
+ eicasecmp_c (eistr, c_string):
+ eicasecmp_off_c (eistr, charoff, charlen, c_string):
+ eicasecmp_off_c_byte (eistr, byteoff, bytelen, c_string):
+*/
+
+/* ----- Case-changing the Eistring ----- */
+
+int eistr_casefiddle_1 (Bufbyte *olddata, Bytecount len, Bufbyte *newdata,
+ int downp);
+
+#define EI_CASECHANGE_(ei, downp) \
+do { \
+ int ei11new_allocmax = (ei).charlen * MAX_EMCHAR_LEN + 1; \
+ Bufbyte *ei11storage = alloca_array (Bufbyte, ei11new_allocmax); \
+ int ei11newlen = eistr_casefiddle_1 ((ei).data, (ei).bytelen, \
+ ei11storage, downp); \
+ \
+ if (ei11newlen) \
+ { \
+ (ei).max_size_allocated = ei11new_allocmax; \
+ (ei).data = ei11storage; \
+ (ei).bytelen = ei11newlen; \
+ /* charlen is the same. */ \
+ } \
+} while (0)
+
+#define eilwr(ei) EI_CASECHANGE_ (ei, 1)
+#define eiupr(ei) EI_CASECHANGE_ (ei, 0)
+
/*----------------------------------------------------------------------*/
/* Accessor macros for important positions in a buffer */
@@ -1190,7 +1705,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,
@@ -1269,27 +1784,28 @@
} while (0)
/* Assign to the `sink' lvalue(s) using the converted data. */
+/* + 2 because we double zero-extended to account for Unicode conversion */
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); \
+ void * dfc_sink_ret = alloca (dfc_sink.data.len + 2); \
+ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \
((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); \
+ void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 2); \
+ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \
((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 { \
- void * dfc_sink_ret = alloca (dfc_sink.data.len + 1); \
- memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 1); \
+ void * dfc_sink_ret = alloca (dfc_sink.data.len + 2); \
+ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \
(sink) = (char *) dfc_sink_ret; \
} while (0)
#define DFC_C_STRING_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); \
+ void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 2); \
+ memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \
(sink) = (char *) dfc_sink_ret; \
} while (0)
#define DFC_LISP_STRING_USE_CONVERTED_DATA(sink) \
@@ -1687,24 +2203,42 @@
# define IN_TRT_TABLE_DOMAIN(c) (((EMACS_UINT) (c)) <= 255)
+#define BUFFER_DOWNCASE_TABLE(buf) \
+ ((buf) ? (buf)->downcase_table : Vascii_downcase_table)
+#define BUFFER_UPCASE_TABLE(buf) \
+ ((buf) ? (buf)->upcase_table : Vascii_upcase_table)
+#define BUFFER_CANON_TABLE(buf) \
+ ((buf) ? (buf)->canon_table : Vascii_canon_table)
+#define BUFFER_EQV_TABLE(buf) \
+ ((buf) ? (buf)->eqv_table : Vascii_eqv_table)
+
+#define BUFFER_MIRROR_DOWNCASE_TABLE(buf) \
+ ((buf) ? (buf)->mirror_downcase_table : Vmirror_ascii_downcase_table)
+#define BUFFER_MIRROR_UPCASE_TABLE(buf) \
+ ((buf) ? (buf)->mirror_upcase_table : Vmirror_ascii_upcase_table)
+#define BUFFER_MIRROR_CANON_TABLE(buf) \
+ ((buf) ? (buf)->mirror_canon_table : Vmirror_ascii_canon_table)
+#define BUFFER_MIRROR_EQV_TABLE(buf) \
+ ((buf) ? (buf)->mirror_eqv_table : Vmirror_ascii_eqv_table)
+
#ifdef MULE
#define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_downcase_table)
+ MIRROR_TRT_TABLE_AS_STRING (BUFFER_MIRROR_DOWNCASE_TABLE (buf))
#define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_upcase_table)
+ MIRROR_TRT_TABLE_AS_STRING (BUFFER_MIRROR_UPCASE_TABLE (buf))
#define MIRROR_CANON_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_canon_table)
+ MIRROR_TRT_TABLE_AS_STRING (BUFFER_MIRROR_CANON_TABLE (buf))
#define MIRROR_EQV_TABLE_AS_STRING(buf) \
- MIRROR_TRT_TABLE_AS_STRING (buf->mirror_case_eqv_table)
+ MIRROR_TRT_TABLE_AS_STRING (BUFFER_MIRROR_EQV_TABLE (buf))
#else
#define MIRROR_DOWNCASE_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->downcase_table)
+ TRT_TABLE_AS_STRING (BUFFER_DOWNCASE_TABLE (buf))
#define MIRROR_UPCASE_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->upcase_table)
+ TRT_TABLE_AS_STRING (BUFFER_UPCASE_TABLE (buf))
#define MIRROR_CANON_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->case_canon_table)
+ TRT_TABLE_AS_STRING (BUFFER_CANON_TABLE (buf))
#define MIRROR_EQV_TABLE_AS_STRING(buf) \
- TRT_TABLE_AS_STRING (buf->case_eqv_table)
+ TRT_TABLE_AS_STRING (BUFFER_EQV_TABLE (buf))
#endif
INLINE_HEADER Emchar TRT_TABLE_OF (Lisp_Object trt, Emchar c);
@@ -1715,8 +2249,8 @@
}
/* Macros used below. */
-#define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->downcase_table, c)
-#define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (buf->upcase_table, c)
+#define DOWNCASE_TABLE_OF(buf, c) TRT_TABLE_OF (BUFFER_DOWNCASE_TABLE (buf), c)
+#define UPCASE_TABLE_OF(buf, c) TRT_TABLE_OF (BUFFER_UPCASE_TABLE (buf), c)
/* 1 if CH is upper case. */
Index: src/casefiddle.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/casefiddle.c,v
retrieving revision 1.7.2.3
diff -u -r1.7.2.3 casefiddle.c
--- casefiddle.c 2000/02/07 07:59:19 1.7.2.3
+++ casefiddle.c 2000/04/30 09:05:14
@@ -52,9 +52,10 @@
alloca_array (Bufbyte, XSTRING_LENGTH (obj) * MAX_EMCHAR_LEN);
Bufbyte *newp = storage;
Bufbyte *oldp = XSTRING_DATA (obj);
+ Bufbyte *endp = oldp + XSTRING_LENGTH (obj);
int wordp = 0, wordp_prev;
- while (*oldp)
+ while (oldp < endp)
{
Emchar c = charptr_emchar (oldp);
switch (flag)
Index: src/config.h.in
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/config.h.in,v
retrieving revision 1.49.2.34
diff -u -r1.49.2.34 config.h.in
--- config.h.in 2000/03/27 19:54:49 1.49.2.34
+++ config.h.in 2000/04/30 09:05:14
@@ -525,20 +525,6 @@
#undef USE_GCC
#undef USE_LCC
-/* Define this if you want level 2 internationalization compliance
- (localized collation and formatting). Generally this should be
- defined, unless your system doesn't have the strcoll() and
- setlocale() library routines. This really should be (NOT! -mrb)
- defined in the appropriate s/ or m/ file. */
-#undef I18N2
-
-/* Define this if you want level 3 internationalization compliance
- (localized messaging). This will cause a small runtime performance
- penalty, as the strings are read from the message catalog(s).
- For this you need the gettext() and dgetext() library routines.
- WARNING, this code is under construction. */
-#undef I18N3
-
/* Compile in support for CDE (Common Desktop Environment) drag and drop?
Requires libDtSvc, which typically must be present at runtime. */
#undef HAVE_CDE
Index: src/console-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/console-msw.c,v
retrieving revision 1.4.2.7
diff -u -r1.4.2.7 console-msw.c
--- console-msw.c 2000/03/13 07:27:51 1.4.2.7
+++ console-msw.c 2000/04/30 09:05:14
@@ -190,14 +190,6 @@
return WriteConsole (msw_console_buffer, str, len, &num_written, NULL);
}
-/* Determine if running on Windows 9x and not NT */
-int
-msw_windows9x_p (void)
-{
- return GetVersion () & 0x80000000;
-}
-
-
#ifdef DEBUG_XEMACS
/*
Index: src/console-msw.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/console-msw.h,v
retrieving revision 1.22.2.19
diff -u -r1.22.2.19 console-msw.h
--- console-msw.h 2000/03/13 07:27:51 1.22.2.19
+++ console-msw.h 2000/04/30 09:05:14
@@ -345,6 +345,6 @@
Lisp_Object mswindows_handle_gui_wm_command (struct frame* f,
HWND ctrl, LPARAM id);
-int msw_windows9x_p (void);
+extern int mswindows_windows9x_p;
#endif /* INCLUDED_console_msw_h_ */
Index: src/console.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/console.h,v
retrieving revision 1.22.2.23
diff -u -r1.22.2.23 console.h
--- console.h 2000/02/26 11:39:48 1.22.2.23
+++ console.h 2000/04/30 09:05:15
@@ -170,6 +170,8 @@
int start_pixpos, int width, face_index findex,
int cursor, int cursor_start, int cursor_width,
int cursor_height);
+ int (*font_width_method) (Lisp_Font_Instance *, Lisp_Object charset);
+
/* color methods */
int (*initialize_color_instance_method) (Lisp_Color_Instance *,
Lisp_Object name,
Index: src/device-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/device-msw.c,v
retrieving revision 1.20.2.16
diff -u -r1.20.2.16 device-msw.c
--- device-msw.c 2000/03/13 07:27:52 1.20.2.16
+++ device-msw.c 2000/04/30 09:05:15
@@ -354,19 +354,19 @@
static void
msprinter_init_device (struct device *d, Lisp_Object props)
{
- char* printer_name;
+ LPTSTR printer_name;
DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
CHECK_STRING (DEVICE_CONNECTION (d));
TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d),
- C_STRING_ALLOCA, printer_name,
- Qctext);
+ C_STRING_MALLOC, printer_name,
+ Qmswindows_tstr);
d->device_data = xnew_and_zero (struct msprinter_device);
- DEVICE_MSPRINTER_NAME(d) = xstrdup (printer_name);
+ DEVICE_MSPRINTER_NAME(d) = printer_name;
if (!OpenPrinter (printer_name, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
{
Index: src/dialog-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/dialog-msw.c,v
retrieving revision 1.5.2.5
diff -u -r1.5.2.5 dialog-msw.c
--- dialog-msw.c 2000/03/13 07:27:52 1.5.2.5
+++ dialog-msw.c 2000/04/30 09:05:15
@@ -153,40 +153,17 @@
/* Helper function which converts the supplied string STRING into Unicode and
pushes it at the end of DYNARR */
static void
-push_lisp_string_as_unicode (unsigned_char_dynarr* dynarr, Lisp_Object string)
+push_lisp_string_as_unicode (unsigned_char_dynarr *dynarr, Lisp_Object string)
{
- Extbyte *mbcs_string;
- Charcount length = XSTRING_CHAR_LENGTH (string);
- LPWSTR uni_string;
+ int length;
+ Extbyte *uni_string;
TO_EXTERNAL_FORMAT (LISP_STRING, string,
- C_STRING_ALLOCA, mbcs_string,
- Qnative);
- uni_string = alloca_array (WCHAR, length + 1);
- length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
- uni_string, sizeof(WCHAR) * (length + 1));
- Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length);
+ ALLOCA, (uni_string, length),
+ Qmswindows_unicode);
+ Dynarr_add_many (dynarr, uni_string, length);
}
-/* Helper function which converts the supplied string STRING into Unicode and
- pushes it at the end of DYNARR */
-static void
-push_bufbyte_string_as_unicode (unsigned_char_dynarr* dynarr, Bufbyte *string,
- Bytecount len)
-{
- Extbyte *mbcs_string;
- Charcount length = bytecount_to_charcount (string, len);
- LPWSTR uni_string;
-
- TO_EXTERNAL_FORMAT (C_STRING, string,
- C_STRING_ALLOCA, mbcs_string,
- Qnative);
- uni_string = alloca_array (WCHAR, length + 1);
- length = MultiByteToWideChar (CP_ACP, 0, mbcs_string, -1,
- uni_string, sizeof(WCHAR) * (length + 1));
- Dynarr_add_many (dynarr, uni_string, sizeof(WCHAR) * length);
-}
-
/* Given button TEXT, return button width in DLU */
static unsigned int
button_width (Lisp_Object text)
@@ -382,19 +359,12 @@
/* Next thing to add is control text, as Unicode string */
{
- Lisp_Object ctext = pgui_item->name;
Emchar accel_unused;
- Bufbyte *trans = (Bufbyte *) alloca (2 * XSTRING_LENGTH (ctext) + 3);
- Bytecount translen;
- memcpy (trans, XSTRING_DATA (ctext), XSTRING_LENGTH (ctext) + 1);
- translen =
- msw_translate_menu_or_dialog_item (trans,
- XSTRING_LENGTH (ctext),
- 2 * XSTRING_LENGTH (ctext) + 3,
- &accel_unused,
- ctext);
- push_bufbyte_string_as_unicode (template, trans, translen);
+ push_lisp_string_as_unicode
+ (template,
+ msw_translate_menu_or_dialog_item
+ (pgui_item->name, &accel_unused));
}
/* Specify 0 length creation data. */
Index: src/dired-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/dired-msw.c,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 dired-msw.c
--- dired-msw.c 2000/01/24 07:36:20 1.4.2.3
+++ dired-msw.c 2000/04/30 09:05:15
@@ -64,9 +64,9 @@
* Set INDENT_LISTING to non-zero if the inserted text should be shifted
* over by two spaces.
*/
-#define INDENT_LISTING 0
+#define INDENT_LISTING 0
-#define ROUND_FILE_SIZES 4096
+#define ROUND_FILE_SIZES 4096
#include <config.h>
@@ -82,24 +82,26 @@
#include <limits.h>
#include <time.h>
-#include <winsock.h> /* To make nt.h happy */
-#include "nt.h" /* For prototypes */
+#include <winsock.h> /* To make nt.h happy */
+#include "nt.h" /* For prototypes */
#if ROUND_FILE_SIZES > 0
-#include <math.h> /* for floor() */
+#include <math.h> /* for floor() */
#endif
+#include <tchar.h>
static int mswindows_ls_sort_case_insensitive;
static int mswindows_ls_round_file_size;
-Lisp_Object Qmswindows_insert_directory;
+Lisp_Object Qmswindows_insert_directory;
-extern Lisp_Object Vmswindows_downcase_file_names; /* in device-msw.c */
+extern Lisp_Object Vmswindows_downcase_file_names; /* in device-msw.c */
-enum mswindows_sortby {
+enum mswindows_sortby
+{
MSWINDOWS_SORT_BY_NAME,
MSWINDOWS_SORT_BY_NAME_NOCASE,
MSWINDOWS_SORT_BY_MOD_DATE,
@@ -107,8 +109,8 @@
};
-static enum mswindows_sortby mswindows_sort_method;
-static int mswindows_reverse_sort;
+static enum mswindows_sortby mswindows_sort_method;
+static int mswindows_reverse_sort;
#define CMPDWORDS(t1a, t1b, t2a, t2b) \
@@ -119,28 +121,28 @@
static int
mswindows_ls_sort_fcn (const void *elem1, const void *elem2)
{
- WIN32_FIND_DATA *e1, *e2;
- int status;
+ WIN32_FIND_DATA *e1, *e2;
+ int status;
e1 = *(WIN32_FIND_DATA **)elem1;
e2 = *(WIN32_FIND_DATA **)elem2;
switch (mswindows_sort_method)
{
case MSWINDOWS_SORT_BY_NAME:
- status = strcmp(e1->cFileName, e2->cFileName);
+ status = _tcscmp (e1->cFileName, e2->cFileName);
break;
case MSWINDOWS_SORT_BY_NAME_NOCASE:
- status = _stricmp(e1->cFileName, e2->cFileName);
+ status = _tcsicmp (e1->cFileName, e2->cFileName);
break;
case MSWINDOWS_SORT_BY_MOD_DATE:
- status = CMPDWORDS(e1->ftLastWriteTime.dwHighDateTime,
- e1->ftLastWriteTime.dwLowDateTime,
- e2->ftLastWriteTime.dwHighDateTime,
- e2->ftLastWriteTime.dwLowDateTime);
+ status = CMPDWORDS (e1->ftLastWriteTime.dwHighDateTime,
+ e1->ftLastWriteTime.dwLowDateTime,
+ e2->ftLastWriteTime.dwHighDateTime,
+ e2->ftLastWriteTime.dwLowDateTime);
break;
case MSWINDOWS_SORT_BY_SIZE:
- status = CMPDWORDS(e1->nFileSizeHigh, e1->nFileSizeLow,
- e2->nFileSizeHigh, e2->nFileSizeLow);
+ status = CMPDWORDS (e1->nFileSizeHigh, e1->nFileSizeLow,
+ e2->nFileSizeHigh, e2->nFileSizeLow);
break;
default:
status = 0;
@@ -160,20 +162,20 @@
{
mswindows_sort_method = sort_by;
mswindows_reverse_sort = reverse;
- qsort(files, nfiles, sizeof(WIN32_FIND_DATA *), mswindows_ls_sort_fcn);
+ qsort (files, nfiles, sizeof (WIN32_FIND_DATA *), mswindows_ls_sort_fcn);
}
static WIN32_FIND_DATA *
-mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
+mswindows_get_files (Lisp_Object dirfile, int nowild, Lisp_Object pattern,
int hide_dot, int hide_system, int *nfiles)
{
- WIN32_FIND_DATA *files;
- int array_size;
- struct re_pattern_buffer *bufp = NULL;
- int findex, len;
- char win32pattern[MAXNAMLEN+3];
- HANDLE fh;
+ WIN32_FIND_DATA *files;
+ int array_size;
+ struct re_pattern_buffer *bufp = NULL;
+ int findex;
+ Eistring (win32pattern);
+ HANDLE fh;
/*
* Much of the following code and comments were taken from dired.c.
@@ -183,7 +185,7 @@
array_size = *nfiles = 0;
while (1)
{
- if (!NILP(pattern))
+ if (!NILP (pattern))
{
/* PATTERN might be a flawed regular expression. Rather than
catching and signalling our own errors, we just call
@@ -194,18 +196,19 @@
which might compile a new regexp until we're done with the loop! */
/* Initialize file info array */
- array_size = 100; /* initial size */
- files = xmalloc(array_size * sizeof (WIN32_FIND_DATA));
+ array_size = 100; /* initial size */
+ files = xnew_array (WIN32_FIND_DATA, array_size);
/* for Win32, we need to insure that the pathname ends with "\*". */
- strcpy (win32pattern, dirfile);
+ eicpy_str (win32pattern, dirfile);
if (!nowild)
{
- len = strlen (win32pattern) - 1;
- if (!IS_DIRECTORY_SEP (win32pattern[len]))
- strcat (win32pattern, "\\");
- strcat (win32pattern, "*");
+ Charcount len = eilen (win32pattern) - 1;
+ if (!IS_DIRECTORY_SEP (eiref (win32pattern, len)))
+ eicat_c (win32pattern, "\\");
+ eicat_c (win32pattern, "*");
}
+ eito_external (win32pattern, Qmswindows_tstr);
/*
* Here, we use FindFirstFile()/FindNextFile() instead of opendir(),
@@ -218,55 +221,55 @@
while (1)
{
- int len;
- char *filename;
- int result;
+ Bytecount len;
+ Eistring (filename);
+ int result;
if (fh == INVALID_HANDLE_VALUE)
{
- fh = FindFirstFile(win32pattern, &files[findex]);
+ fh = FindFirstFile (eiextdata (win32pattern), &files[findex]);
if (fh == INVALID_HANDLE_VALUE)
{
report_file_error ("Opening directory",
- list1(build_string(dirfile)));
+ list1 (dirfile));
}
}
else
{
- if (!FindNextFile(fh, &files[findex]))
+ if (!FindNextFile (fh, &files[findex]))
{
- if (GetLastError() == ERROR_NO_MORE_FILES)
+ if (GetLastError () == ERROR_NO_MORE_FILES)
{
break;
}
- FindClose(fh);
+ FindClose (fh);
report_file_error ("Reading directory",
- list1(build_string(dirfile)));
+ list1 (dirfile));
}
}
- filename = files[findex].cFileName;
- if (!NILP(Vmswindows_downcase_file_names))
- {
- strlwr(filename);
- }
- len = strlen(filename);
- result = (NILP(pattern)
- || (0 <= re_search (bufp, filename,
+ eicpy_ext (filename, files[findex].cFileName, Qmswindows_tstr);
+
+ if (!NILP (Vmswindows_downcase_file_names))
+ {
+ eilwr (filename);
+ }
+ len = eilen (filename);
+ result = (NILP (pattern)
+ || (0 <= re_search (bufp, eirawdata (filename),
len, 0, len, 0)));
if (result)
{
- if ( ! (filename[0] == '.' &&
- ((hide_system && (filename[1] == '\0' ||
- (filename[1] == '.' &&
- filename[2] == '\0'))) ||
+ if ( ! (eiref (filename, 0) == '.' &&
+ ((hide_system && (eiref (filename, 1) == '\0' ||
+ (eiref (filename, 1) == '.' &&
+ eiref (filename, 2) == '\0'))) ||
hide_dot)))
{
if (++findex >= array_size)
{
array_size = findex * 2;
- files = xrealloc(files,
- array_size * sizeof(WIN32_FIND_DATA));
+ XREALLOC_ARRAY (files, WIN32_FIND_DATA, array_size);
}
}
}
@@ -282,99 +285,109 @@
}
-static void
-mswindows_format_file (WIN32_FIND_DATA *file, char *buf, int display_size,
+static Lisp_Object
+mswindows_format_file (WIN32_FIND_DATA *file, int display_size,
int add_newline)
{
- char *cptr;
- int len;
- Lisp_Object luser;
- double file_size;
-
- len = strlen(file->cFileName);
+#if 0
+ Lisp_Object luser;
+ double file_size;
+ Eistring (puta);
+ Bufbyte *unxstlenam;
+ Bytecount unxlen;
+ char buf[666];
+ int extlen = _tcslen (file->cFileName);
+
+ TO_INTERNAL_FORMAT (DATA, (file->cFileName,
+ sizeof (_TCHAR) * extlen),
+ ALLOCA, (unxstlenam, unxlen),
+ Qmswindows_tstr);
file_size =
file->nFileSizeHigh * (double)UINT_MAX + file->nFileSizeLow;
- cptr = buf;
+ Eicpy_c (puta, "");
#if INDENT_LISTING
- *cptr++ = ' ';
- *cptr++ = ' ';
+ Eicat_c (puta, " ");
#endif
if (display_size)
{
- sprintf(cptr, "%6d ", (int)((file_size + 1023.) / 1024.));
- cptr += 7;
+ sprintf (buf, "%6d ", (int)((file_size + 1023.) / 1024.));
+ Eicat_c (puta, buf);
}
if (file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ Eicat_c (puta, "d");
+ else
+ Eicat_c (puta, "-");
+ buf[0] = buf[3] = buf[6] = 'r';
+ if (file->dwFileAttributes & FILE_ATTRIBUTE_READONLY)
{
- *cptr++ = 'd';
- } else {
- *cptr++ = '-';
+ buf[1] = buf[4] = buf[7] = '-';
}
- cptr[0] = cptr[3] = cptr[6] = 'r';
- if (file->dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ else
{
- cptr[1] = cptr[4] = cptr[7] = '-';
- } else {
- cptr[1] = cptr[4] = cptr[7] = 'w';
+ buf[1] = buf[4] = buf[7] = 'w';
}
if ((file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
- (len > 4 &&
- (_stricmp(&file->cFileName[len - 4], ".exe") == 0
- || _stricmp(&file->cFileName[len - 4], ".com") == 0
- || _stricmp(&file->cFileName[len - 4], ".bat") == 0
+ (extlen > 4 &&
+ (_tcsicmp (&file->cFilename[extlen - 4], TEXT (".exe")) == 0
+ || _tcsicmp (&file->cFileName[extlen - 4], TEXT (".com")) == 0
+ || _tcsicmp (&file->cFileName[extlen - 4], TEXT (".bat")) == 0
#if 0
- || _stricmp(&file->cFileName[len - 4], ".pif") == 0
+ || _tcsicmp (&file->cFileName[extlen - 4], TEXT (".pif")) == 0
#endif
)))
{
- cptr[2] = cptr[5] = cptr[8] = 'x';
- } else {
- cptr[2] = cptr[5] = cptr[8] = '-';
+ buf[2] = buf[5] = buf[8] = 'x';
}
- cptr += 9;
+ else
+ {
+ buf[2] = buf[5] = buf[8] = '-';
+ }
+ buf[9] = '\0';
+ Eicat_c (puta, buf);
if (file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ Eicat_c (puta, " 2 ");
+ else
+ Eicat_c (puta, " 1 ");
+ luser = Fuser_login_name (Qnil);
+ if (!STRINGP (luser))
+ sprintf (cptr, "%-9d", 0);
+ else
{
- strcpy(cptr, " 2 ");
- } else {
- strcpy(cptr, " 1 ");
- }
- cptr += 5;
- luser = Fuser_login_name(Qnil);
- if (!STRINGP(luser))
- {
- sprintf(cptr, "%-9d", 0);
- } else {
- char *str;
+ char *str;
- str = XSTRING_DATA(luser);
- sprintf(cptr, "%-8s ", str);
+ str = XSTRING_DATA (luser);
+ sprintf (cptr, "%-8s ", str);
}
while (*cptr)
{
++cptr;
}
- sprintf(cptr, "%-8d ", getgid());
+ sprintf (cptr, "%-8d ", getgid ());
cptr += 9;
if (file_size > 99999999.0)
{
file_size = (file_size + 1023.0) / 1024.;
if (file_size > 999999.0)
+ {
+ sprintf (cptr, "%6.0fMB ", (file_size + 1023.0) / 1024.);
+ }
+ else
{
- sprintf(cptr, "%6.0fMB ", (file_size + 1023.0) / 1024.);
- } else {
- sprintf(cptr, "%6.0fKB ", file_size);
+ sprintf (cptr, "%6.0fKB ", file_size);
}
- } else {
- sprintf(cptr, "%8.0f ", file_size);
+ }
+ else
+ {
+ sprintf (cptr, "%8.0f ", file_size);
}
while (*cptr)
{
++cptr;
}
{
- time_t t, now;
- char *ctimebuf;
- extern char *sys_ctime(const time_t *t); /* in nt.c */
+ time_t t, now;
+ char *ctimebuf;
+ extern char *sys_ctime (const time_t *t); /* in nt.c */
if (
#if 0
@@ -382,39 +395,38 @@
* This doesn't work.
* This code should be correct ...
*/
- FileTimeToLocalFileTime(&file->ftLastWriteTime, &localtime) &&
- ((t = convert_time(localtime)) != 0) &&
+ FileTimeToLocalFileTime (&file->ftLastWriteTime, &localtime) &&
+ ((t = convert_time (localtime)) != 0) &&
#else
/*
* But this code "works" ...
*/
- ((t = convert_time(file->ftLastWriteTime)) != 0) &&
+ ((t = convert_time (file->ftLastWriteTime)) != 0) &&
#endif
- ((ctimebuf = sys_ctime(&t)) != NULL))
+ ((ctimebuf = sys_ctime (&t)) != NULL))
{
- memcpy(cptr, &ctimebuf[4], 7);
- now = time(NULL);
+ memcpy (cptr, &ctimebuf[4], 7);
+ now = time (NULL);
if (now - t > (365. / 2.0) * 86400.)
{
/* more than 6 months */
cptr[7] = ' ';
- memcpy(&cptr[8], &ctimebuf[20], 4);
- } else {
+ memcpy (&cptr[8], &ctimebuf[20], 4);
+ }
+ else
+ {
/* less than 6 months */
- memcpy(&cptr[7], &ctimebuf[11], 5);
+ memcpy (&cptr[7], &ctimebuf[11], 5);
}
cptr += 12;
*cptr++ = ' ';
}
}
+ Eicat_ei ();
if (add_newline)
- {
- sprintf(cptr, "%s\n", file->cFileName);
- }
- else
- {
- strcpy(cptr, file->cFileName);
- }
+ Eicat_c (puta, "\n");
+#endif
+ return Qnil;
}
@@ -428,21 +440,18 @@
*/
(file, switches, wildcard, full_directory_p))
{
- Lisp_Object result, handler, wildpat, fns, basename;
- char *filename;
- char *switchstr;
- int len, nfiles, i;
- int hide_system, hide_dot, reverse, display_size;
- WIN32_FIND_DATA *files, **sorted_files;
- enum mswindows_sortby sort_by;
- char fmtbuf[MAXNAMLEN+100]; /* larger than necessary */
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+ Lisp_Object result, handler, wildpat, fns, basename;
+ int nfiles, i;
+ int hide_system, hide_dot, reverse, display_size;
+ WIN32_FIND_DATA *files, **sorted_files;
+ enum mswindows_sortby sort_by;
+ struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
result = Qnil;
wildpat = Qnil;
fns = Qnil;
basename = Qnil;
- GCPRO5(result, file, wildpat, fns, basename);
+ GCPRO5 (result, file, wildpat, fns, basename);
sorted_files = NULL;
switchstr = NULL;
hide_system = 1;
@@ -456,22 +465,24 @@
while (1)
{
handler = Ffind_file_name_handler (file, Qmswindows_insert_directory);
- if (!NILP(handler))
+ if (!NILP (handler))
{
- result = call5(handler, Qmswindows_insert_directory, file, switches,
- wildcard, full_directory_p);
+ result = call5 (handler, Qmswindows_insert_directory, file, switches,
+ wildcard, full_directory_p);
break;
}
CHECK_STRING (file);
- if (!NILP(switches))
+ if (!NILP (switches))
{
- char *cptr;
+ Bufbyte *cptr, *cptr_end;
CHECK_STRING (switches);
- switchstr = XSTRING_DATA(switches);
- for (cptr = switchstr; *cptr; ++cptr)
+ cptr = XSTRING_DATA (switches);
+ cptr_end = cptr + XSTRING_LENGTH (switches);
+ while (cptr < cptr_end)
{
- switch (*cptr)
+ Emchar ch = charptr_emchar (cptr);
+ switch (ch)
{
case 'A':
hide_dot = 0;
@@ -493,6 +504,7 @@
sort_by = MSWINDOWS_SORT_BY_MOD_DATE;
break;
}
+ INC_CHARPTR (cptr);
}
}
@@ -502,43 +514,47 @@
* because it makes us think there is no wildcard, only a
* directory name.
*/
- if (!NILP(Fstring_match(build_string("[[?*]"), file, Qnil, Qnil)))
+ if (!NILP (Fstring_match (build_string ("[[?*]"), file, Qnil, Qnil)))
{
+ Bytecount namelen = XSTRING_LENGTH (file);
+ Bufbyte *filename = (Bufbyte *) alloca (namelen);
+ memcpy (filename, XSTRING_DATA (file), namelen);
wildcard = Qt;
- filename = XSTRING_DATA(file);
- len = strlen(filename);
- if (len > 0 && (filename[len - 1] == '\\' ||
- filename[len - 1] == '/'))
+ if (namelen > 0)
{
- filename[len - 1] = '\0';
+ Bufbyte *endptr = filename + namelen;
+ DEC_CHARPTR (endptr);
+ if (charptr_emchar (endptr) == '\\'
+ || charptr_emchar (endptr) == '/')
+ namelen = endptr - filename;
}
- file = build_string(filename);
+ file = make_string (filename, namelen);
}
- if (!NILP(wildcard))
+ if (!NILP (wildcard))
{
- Lisp_Object newfile;
+ Lisp_Object newfile;
- basename = Ffile_name_nondirectory(file);
- fns = intern("wildcard-to-regexp");
- wildpat = call1(fns, basename);
- newfile = Ffile_name_directory(file);
- if (NILP(newfile))
+ basename = Ffile_name_nondirectory (file);
+ fns = intern ("wildcard-to-regexp");
+ wildpat = call1 (fns, basename);
+ newfile = Ffile_name_directory (file);
+ if (NILP (newfile))
{
- /* Ffile_name_directory() can GC */
- newfile = Ffile_name_directory(Fexpand_file_name(file, Qnil));
+ /* Ffile_name_directory () can GC */
+ newfile = Ffile_name_directory (Fexpand_file_name (file, Qnil));
}
file = newfile;
}
- if (!NILP(wildcard) || !NILP(full_directory_p))
+ if (!NILP (wildcard) || !NILP (full_directory_p))
{
- CHECK_STRING(file);
- if (!NILP(wildpat))
+ CHECK_STRING (file);
+ if (!NILP (wildpat))
{
- CHECK_STRING(wildpat);
+ CHECK_STRING (wildpat);
}
- files = mswindows_get_files(XSTRING_DATA(file), FALSE, wildpat,
- hide_dot, hide_system, &nfiles);
+ files = mswindows_get_files (file, FALSE, wildpat,
+ hide_dot, hide_system, &nfiles);
if (files == NULL || nfiles == 0)
{
break;
@@ -546,10 +562,10 @@
}
else
{
- files = mswindows_get_files(XSTRING_DATA(file), TRUE, wildpat,
- hide_dot, hide_system, &nfiles);
+ files = mswindows_get_files (file, TRUE, wildpat,
+ hide_dot, hide_system, &nfiles);
}
- if ((sorted_files = xmalloc(nfiles * sizeof(WIN32_FIND_DATA *)))
+ if ((sorted_files = xmalloc (nfiles * sizeof (WIN32_FIND_DATA *)))
== NULL)
{
break;
@@ -560,9 +576,9 @@
}
if (nfiles > 1)
{
- mswindows_sort_files(sorted_files, nfiles, sort_by, reverse);
+ mswindows_sort_files (sorted_files, nfiles, sort_by, reverse);
}
- if (!NILP(wildcard) || !NILP(full_directory_p))
+ if (!NILP (wildcard) || !NILP (full_directory_p))
{
/*
* By using doubles, we can handle files up to 2^53 bytes in
@@ -573,12 +589,12 @@
* Hopefully, we won't have to handle these file sizes anytime
* soon.
*/
- double total_size, file_size, block_size;
+ double total_size, file_size, block_size;
if ((block_size = mswindows_ls_round_file_size) <= 0)
- {
+ {
block_size = 0;
- }
+ }
total_size = 0;
for (i = 0; i < nfiles; ++i)
{
@@ -586,35 +602,40 @@
sorted_files[i]->nFileSizeHigh * (double)UINT_MAX +
sorted_files[i]->nFileSizeLow;
if (block_size > 0)
- {
+ {
/*
* Round file_size up to the next nearest block size.
*/
file_size =
- floor((file_size + block_size - 1) / block_size)
- * block_size;
- }
+ floor ((file_size + block_size - 1) / block_size)
+ * block_size;
+ }
/* Here, we round to the nearest 1K */
- total_size += floor((file_size + 512.) / 1024.);
+ total_size += floor ((file_size + 512.) / 1024.);
}
- sprintf(fmtbuf,
+ {
+ char tempbuf[666];
+
+ sprintf (tempbuf,
#if INDENT_LISTING
- /* ANSI C compilers auto-concatenate adjacent strings */
- " "
+ /* ANSI C compilers auto-concatenate adjacent strings */
+ " "
#endif
- "total %.0f\n", total_size);
- buffer_insert1(current_buffer, build_string(fmtbuf));
+ "total %.0f\n", total_size);
+ buffer_insert1 (current_buffer, build_string (tempbuf));
+ }
}
for (i = 0; i < nfiles; ++i)
{
- mswindows_format_file(sorted_files[i], fmtbuf, display_size, TRUE);
- buffer_insert1(current_buffer, build_string(fmtbuf));
+ Lisp_Object fmtfile =
+ mswindows_format_file (sorted_files[i], display_size, TRUE);
+ buffer_insert1 (current_buffer, fmtfile);
}
break;
}
if (sorted_files)
{
- xfree(sorted_files);
+ xfree (sorted_files);
}
UNGCPRO;
return (result);
Index: src/dynarr.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/dynarr.c,v
retrieving revision 1.3.2.6
diff -u -r1.3.2.6 dynarr.c
--- dynarr.c 2000/02/16 02:06:51 1.3.2.6
+++ dynarr.c 2000/04/30 09:05:15
@@ -65,15 +65,20 @@
Dynarr_add_many(d, base, len)
[MACRO] Add LEN elements to the end of the dynamic array. The elements
- should be contiguous in memory, starting at BASE.
+ should be contiguous in memory, starting at BASE. If BASE if NULL,
+ just make space for the elements; don't actually add them.
Dynarr_insert_many_at_start(d, base, len)
[MACRO] Append LEN elements to the beginning of the dynamic array.
The elements should be contiguous in memory, starting at BASE.
+ If BASE if NULL, just make space for the elements; don't actually
+ add them.
Dynarr_insert_many(d, base, len, start)
Insert LEN elements to the dynamic array starting at position
START. The elements should be contiguous in memory, starting at BASE.
+ If BASE if NULL, just make space for the elements; don't actually
+ add them.
int Dynarr_length(d)
[MACRO] Return the number of elements currently in a dynamic array.
@@ -174,7 +179,8 @@
(char *) dy->base + start*dy->elsize,
(dy->cur - start)*dy->elsize);
}
- memcpy ((char *) dy->base + start*dy->elsize, el, len*dy->elsize);
+ if (el)
+ memcpy ((char *) dy->base + start*dy->elsize, el, len*dy->elsize);
dy->cur += len;
if (dy->cur > dy->largest)
Index: src/editfns.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/editfns.c,v
retrieving revision 1.22.2.16
diff -u -r1.22.2.16 editfns.c
--- editfns.c 2000/03/13 07:27:52 1.22.2.16
+++ editfns.c 2000/04/30 09:05:16
@@ -802,8 +802,7 @@
memcpy (r, p, q - p);
r[q - p] = 0;
strcat (r, (char *) XSTRING_DATA (user_name));
- /* #### current_buffer dependency! */
- r[q - p] = UPCASE (current_buffer, r[q - p]);
+ r[q - p] = UPCASE (0, r[q - p]);
strcat (r, q + 1);
tem = build_string (r);
}
Index: src/emacs.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/emacs.c,v
retrieving revision 1.82.2.60
diff -u -r1.82.2.60 emacs.c
--- emacs.c 2000/03/27 11:59:11 1.82.2.60
+++ emacs.c 2000/04/30 09:05:17
@@ -61,8 +61,7 @@
#include "sysdll.h"
#endif
-#if defined (HAVE_LOCALE_H) && \
- (defined (I18N2) || defined (I18N3) || defined (I18N4))
+#if defined (HAVE_LOCALE_H) && defined (I18N3)
#include <locale.h>
#endif
@@ -416,21 +415,6 @@
}
-#ifdef I18N4
- /* #### - don't know why I18N4 on SunOS/JLE
- can't deal with this. It's a potential
- bug that needs to be looked at. */
-# undef RUN_TIME_REMAP
-#endif
-
-#if defined (MULE) && defined (MSDOS) && defined (EMX)
-/* Setup all of files be input/output'ed with binary translation mode. */
-asm (" .text");
-asm ("L_setbinmode:");
-asm (" movl $1, __fmode_bin");
-asm (" ret");
-asm (" .stabs \"___CTOR_LIST__\", 23, 0, 0, L_setbinmode");
-#endif
/* Test whether the next argument in ARGV matches SSTR or a prefix of
LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
@@ -806,6 +790,10 @@
init_intl_very_early (); /* set up the locale and domain for gettext and
such. */
+#ifdef WINDOWSNT
+ init_win32_very_early ();
+#endif
+
/* Now initialize the Lisp engine and the like. Done only during
dumping. No dependence on anything that may be in the user's
environment when the dumped XEmacs is run.
@@ -1509,6 +1497,14 @@
initialized above, and dependencies between one complex_vars_()
function and another. */
+#ifdef MULE
+ /* These two depend on hash tables and various variables declared
+ earlier. The second may also depend on the first. */
+ complex_vars_of_mule_charset ();
+#endif
+#ifdef FILE_CODING
+ complex_vars_of_file_coding ();
+#endif
/* Calls Fmake_range_table(). */
complex_vars_of_regex ();
/* Calls Fmake_range_table(). */
@@ -1520,15 +1516,6 @@
/* Depends on hash tables and specifiers. */
complex_vars_of_faces ();
-#ifdef MULE
- /* These two depend on hash tables and various variables declared
- earlier. The second may also depend on the first. */
- complex_vars_of_mule_charset ();
-#endif
-#ifdef FILE_CODING
- complex_vars_of_file_coding ();
-#endif
-
/* This calls allocate_glyph(), which creates specifiers
and also relies on a variable (Vthe_nothing_vector) initialized
above. It also calls make_ext_string(), which under Mule
@@ -1725,8 +1712,9 @@
if (initialized)
{
- /* Stuff that needs to be reset at run time. Order below should
- not matter. */
+ /* Stuff that needs to be reset at run time. */
+ reinit_file_coding (); /* Do this first to make sure we can handle
+ external conversion */
reinit_alloc ();
reinit_eval ();
#ifdef MULE_REGEXP
Index: src/event-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/event-msw.c,v
retrieving revision 1.38.2.42
diff -u -r1.38.2.42 event-msw.c
--- event-msw.c 2000/03/22 01:59:00 1.38.2.42
+++ event-msw.c 2000/04/30 09:05:19
@@ -1552,6 +1552,7 @@
return (HDDEDATA)NULL;
case XTYP_EXECUTE:
+ /* !!#### needs Mule work */
if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
{
DWORD len = DdeGetData (hdata, NULL, 0, 0);
@@ -2082,11 +2083,11 @@
if (!NILP(btext))
{
- /* I think this is safe since the text will only go away
- when the toolbar does...*/
+ /* #### This is probably a memory leak.
+ Need to rethink. */
TO_EXTERNAL_FORMAT (LISP_STRING, btext,
- C_STRING_ALLOCA, tttext->lpszText,
- Qnative);
+ C_STRING_MALLOC, tttext->lpszText,
+ Qmswindows_tstr);
}
#endif
}
@@ -2416,10 +2417,8 @@
#ifdef HAVE_DRAGNDROP
case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
{
- UINT filecount, i, len;
+ UINT filecount, i;
POINT point;
- char* filename;
- char* fname;
Lisp_Object l_dndlist = Qnil, l_item = Qnil;
struct gcpro gcpro1, gcpro2, gcpro3;
@@ -2444,42 +2443,57 @@
filecount = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0);
for (i=0; i<filecount; i++)
{
- len = DragQueryFile ((HDROP) wParam, i, NULL, 0);
+ Bufbyte *fname;
+ Extbyte *fname_ext;
+ Bytecount fnamelen;
+ Charcount len = DragQueryFile ((HDROP) wParam, i, NULL, 0);
/* The URLs that we make here aren't correct according to section
* 3.10 of rfc1738 because they're missing the //<host>/ part and
* because they may contain reserved characters. But that's OK -
* they just need to be good enough to keep dragdrop.el happy. */
- fname = (char *)xmalloc (len+1);
- DragQueryFile ((HANDLE) wParam, i, fname, len+1);
+ fname_ext = (Extbyte *) alloca ((len + 1) * TCHAR_SIZE);
+ DragQueryFile ((HANDLE) wParam, i, fname_ext, len + 1);
+ TO_INTERNAL_FORMAT (DATA, (fname_ext, len * TCHAR_SIZE),
+ DATA, (fname, fnamelen),
+ Qmswindows_tstr);
+
/* May be a shell link aka "shortcut" - replace fname if so */
#if !(defined(__CYGWIN32__) || defined(__MINGW32__))
/* cygwin doesn't define this COM stuff */
- if (!stricmp (fname + strlen (fname) - 4, ".LNK"))
+ /* #### Mule-ASCII assumption */
+ if (!stricmp (fname + fnamelen - 4, ".LNK"))
{
IShellLink* psl;
if (CoCreateInstance (&CLSID_ShellLink, NULL,
- CLSCTX_INPROC_SERVER, &IID_IShellLink, &psl) == S_OK)
+ CLSCTX_INPROC_SERVER, &IID_IShellLink,
+ &psl) == S_OK)
{
IPersistFile* ppf;
if (psl->lpVtbl->QueryInterface (psl, &IID_IPersistFile,
&ppf) == S_OK)
{
- WORD wsz[MAX_PATH];
+ Extbyte *fname_unicode;
WIN32_FIND_DATA wfd;
- LPSTR resolved = (char *) xmalloc (MAX_PATH+1);
-
- MultiByteToWideChar (CP_ACP,0, fname, -1, wsz, MAX_PATH);
+ LPSTR resolved = (char *) alloca (MAX_PATH+1);
- if ((ppf->lpVtbl->Load (ppf, wsz, STGM_READ) == S_OK) &&
- (psl->lpVtbl->GetPath (psl, resolved, MAX_PATH,
- &wfd, 0)==S_OK))
+ TO_EXTERNAL_FORMAT (DATA, (fname, fnamelen),
+ C_STRING_ALLOCA,
+ fname_unicode,
+ Qmswindows_unicode);
+
+ if ((ppf->lpVtbl->Load (ppf, wsz, STGM_READ) == S_OK)
+ && (psl->lpVtbl->GetPath (psl, resolved, MAX_PATH,
+ &wfd, 0)==S_OK))
{
- xfree (fname);
- fname = resolved;
- len = strlen (fname);
+ /* #### FUCKME! What's the encoding of this
+ file, and how do I get the Unicode version?
+ Is the file also in wfd.cFileName? */
+ TO_INTERNAL_FORMAT (C_STRING_DATA, resolved,
+ DATA, (fname, fnamelen),
+ Qmswindows_multibyte);
}
ppf->lpVtbl->Release (ppf);
@@ -2490,20 +2504,17 @@
}
#endif
-#ifdef __CYGWIN32__
- filename = xmalloc (cygwin32_win32_to_posix_path_list_buf_size (fname) + 5);
- strcpy (filename, "file:");
- cygwin32_win32_to_posix_path_list (fname, filename+5);
-#else
- filename = (char *)xmalloc (len+6);
- strcat (strcpy (filename, "file:"), fname);
- dostounix_filename (filename+5);
-#endif
- xfree (fname);
- l_item = make_string (filename, strlen (filename));
- l_dndlist = Fcons (l_item, l_dndlist);
- xfree (filename);
+ fname = fuck_with_dos_filename (fname, fnamelen, &fnamelen);
+ {
+ Bufbyte *pseudo_url = (Bufbyte *) alloca (fnamelen + 5);
+ strncpy (pseudo_url, "file:", 5);/* #### Mule-ASCII assumption */
+ memcpy (pseudo_url + 5, fname, fnamelen);
+ xfree (fname);
+ l_item = make_string (pseudo_url, fnamelen + 5);
+ l_dndlist = Fcons (l_item, l_dndlist);
+ }
}
+
DragFinish ((HDROP) wParam);
event->event.misc.object = Fcons (Qdragdrop_URL, l_dndlist);
Index: src/faces.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/faces.c,v
retrieving revision 1.25.2.15
diff -u -r1.25.2.15 faces.c
--- faces.c 2000/04/05 12:59:40 1.25.2.15
+++ faces.c 2000/04/30 09:05:20
@@ -1926,6 +1926,12 @@
inst_list);
#endif /* HAVE_TTY */
#ifdef HAVE_MS_WINDOWS
+#ifdef MULE
+ inst_list = Fcons (Fcons (list1 (Qmswindows),
+ build_string ("::14::")), inst_list);
+ inst_list = Fcons (Fcons (list1 (Qmswindows),
+ build_string ("::10::")), inst_list);
+#endif /* MULE */
/* Fixedsys does not exist for printers */
inst_list = Fcons (Fcons (list1 (Qmsprinter),
build_string ("Courier:Regular:10::Western")), inst_list);
Index: src/file-coding.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/file-coding.c,v
retrieving revision 1.7.2.40
diff -u -r1.7.2.40 file-coding.c
--- file-coding.c 2000/04/03 08:01:27 1.7.2.40
+++ file-coding.c 2000/04/30 09:05:22
@@ -48,9 +48,13 @@
/* Table of symbols identifying each coding category. */
Lisp_Object coding_category_symbol[CODING_CATEGORY_LAST + 1];
+#ifdef HAVE_WIN32
+Lisp_Object Vmswindows_code_page_table;
+#endif
-struct file_coding_dump {
+struct file_coding_dump
+{
/* Coding system currently associated with each coding category. */
Lisp_Object coding_category_system[CODING_CATEGORY_LAST + 1];
@@ -63,15 +67,20 @@
#endif
} *fcd;
-static const struct lrecord_description fcd_description_1[] = {
- { XD_LISP_OBJECT_ARRAY, offsetof (struct file_coding_dump, coding_category_system),
CODING_CATEGORY_LAST + 1 },
+static const struct lrecord_description fcd_description_1[] =
+{
+ { XD_LISP_OBJECT_ARRAY,
+ offsetof (struct file_coding_dump,
+ coding_category_system), CODING_CATEGORY_LAST + 1 },
#ifdef MULE
- { XD_LISP_OBJECT_ARRAY, offsetof (struct file_coding_dump, ucs_to_mule_table), 65536
},
+ { XD_LISP_OBJECT_ARRAY,
+ offsetof (struct file_coding_dump, ucs_to_mule_table), 65536 },
#endif
{ XD_END }
};
-static const struct struct_description fcd_description = {
+static const struct struct_description fcd_description =
+{
sizeof (struct file_coding_dump),
fcd_description_1
};
@@ -80,8 +89,7 @@
Lisp_Object Qcoding_systemp;
-Lisp_Object Qraw_text, Qno_conversion, Qccl, Qiso2022;
-/* Qinternal in general.c */
+Lisp_Object Qraw_text;
Lisp_Object Qmnemonic, Qeol_type;
Lisp_Object Qcr, Qcrlf, Qlf;
@@ -89,9 +97,8 @@
Lisp_Object Qpost_read_conversion;
Lisp_Object Qpre_write_conversion;
+
#ifdef MULE
-Lisp_Object Qucs4, Qutf8;
-Lisp_Object Qbig5, Qshift_jis;
Lisp_Object Qcharset_g0, Qcharset_g1, Qcharset_g2, Qcharset_g3;
Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output;
Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output;
@@ -175,65 +182,33 @@
EXFUN (Fcopy_coding_system, 2);
#ifdef MULE
struct detection_state;
-static int detect_coding_sjis (struct detection_state *st,
- const unsigned char *src,
- unsigned int n);
-static void decode_coding_sjis (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst,
- unsigned int n);
-static void encode_coding_sjis (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst,
- unsigned int n);
-static int detect_coding_big5 (struct detection_state *st,
- const unsigned char *src,
- unsigned int n);
-static void decode_coding_big5 (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static void encode_coding_big5 (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static int detect_coding_ucs4 (struct detection_state *st,
- const unsigned char *src,
- unsigned int n);
-static void decode_coding_ucs4 (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static void encode_coding_ucs4 (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static int detect_coding_utf8 (struct detection_state *st,
- const unsigned char *src,
- unsigned int n);
-static void decode_coding_utf8 (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static void encode_coding_utf8 (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
+
+#define SLOT(slot) \
+static int detect_coding_##slot (struct detection_state *st, \
+ const unsigned char *src, \
+ unsigned int n); \
+static void decode_coding_##slot (struct decoding_stream *str, \
+ const unsigned char *src, \
+ unsigned_char_dynarr *dst, unsigned int n); \
+static void encode_coding_##slot (struct encoding_stream *str, \
+ const unsigned char *src, \
+ unsigned_char_dynarr *dst, unsigned int n);
+#include "coding-slots.h"
+#undef SLOT
static int postprocess_iso2022_mask (int mask);
static void reset_iso2022 (Lisp_Object coding_system,
struct iso2022_decoder *iso);
-static int detect_coding_iso2022 (struct detection_state *st,
- const unsigned char *src,
- unsigned int n);
-static void decode_coding_iso2022 (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-static void encode_coding_iso2022 (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n);
-#endif /* MULE */
-static void decode_coding_no_conversion (Lstream *decoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst,
- unsigned int n);
-static void encode_coding_no_conversion (Lstream *encoding,
- const unsigned char *src,
- unsigned_char_dynarr *dst,
- unsigned int n);
+
+static void iso2022_marker (Lisp_Coding_System *codesys);
+static void iso2022_finalizer (Lisp_Coding_System *c);
+static int iso2022_parse_creation_properties (Lisp_Coding_System *codesys,
+ Lisp_Object key,
+ Lisp_Object value);
+static void iso2022_decoding_closer (struct decoding_stream *str);
+
+static void chain_encoding_closer (struct encoding_stream *str);
+static void chain_decoding_closer (struct encoding_stream *str);
+
static void mule_decode (Lstream *decoding, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n);
static void mule_encode (Lstream *encoding, const unsigned char *src,
@@ -290,29 +265,37 @@
static void finalize_coding_system (void *header, int for_disksave);
#ifdef MULE
-static const struct lrecord_description ccs_description_1[] = {
+static const struct lrecord_description ccs_description_1[] =
+{
{ XD_LISP_OBJECT, offsetof (charset_conversion_spec, from_charset) },
{ XD_LISP_OBJECT, offsetof (charset_conversion_spec, to_charset) },
{ XD_END }
};
-static const struct struct_description ccs_description = {
+static const struct struct_description ccs_description =
+{
sizeof (charset_conversion_spec),
ccs_description_1
};
-static const struct lrecord_description ccsd_description_1[] = {
+static const struct lrecord_description ccsd_description_1[] =
+{
XD_DYNARR_DESC (charset_conversion_spec_dynarr, &ccs_description),
{ XD_END }
};
-static const struct struct_description ccsd_description = {
+static const struct struct_description ccsd_description =
+{
sizeof (charset_conversion_spec_dynarr),
ccsd_description_1
};
#endif
-static const struct lrecord_description coding_system_description[] = {
+static const struct lrecord_description coding_system_description[] =
+{
+ { XD_INT, offsetof (Lisp_Coding_System, chain.count) },
+ { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Coding_System,
+ chain.chain), XD_INDIRECT (0, 0) },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, name) },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, doc_string) },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, mnemonic) },
@@ -322,9 +305,12 @@
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, eol_crlf) },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, eol_cr) },
#ifdef MULE
- { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Coding_System, iso2022.initial_charset), 4 },
- { XD_STRUCT_PTR, offsetof (Lisp_Coding_System, iso2022.input_conv), 1,
&ccsd_description },
- { XD_STRUCT_PTR, offsetof (Lisp_Coding_System, iso2022.output_conv), 1,
&ccsd_description },
+ { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Coding_System,
+ iso2022.initial_charset), 4 },
+ { XD_STRUCT_PTR, offsetof (Lisp_Coding_System, iso2022.input_conv),
+ 1, &ccsd_description },
+ { XD_STRUCT_PTR, offsetof (Lisp_Coding_System, iso2022.output_conv),
+ 1, &ccsd_description },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, ccl.decode) },
{ XD_LISP_OBJECT, offsetof (Lisp_Coding_System, ccl.encode) },
#endif
@@ -337,6 +323,22 @@
0, 0, coding_system_description,
Lisp_Coding_System);
+static void
+ccl_marker (Lisp_Coding_System *codesys)
+{
+ mark_object (CODING_SYSTEM_CCL_DECODE (codesys));
+ mark_object (CODING_SYSTEM_CCL_ENCODE (codesys));
+}
+
+static void
+chain_marker (Lisp_Coding_System *codesys)
+{
+ int i;
+
+ for (i = 0; i < CODING_SYSTEM_CHAIN_COUNT (codesys); i++)
+ mark_object (CODING_SYSTEM_CHAIN_CHAIN (codesys)[i]);
+}
+
static Lisp_Object
mark_coding_system (Lisp_Object obj)
{
@@ -352,37 +354,19 @@
switch (CODING_SYSTEM_TYPE (codesys))
{
#ifdef MULE
- int i;
case CODESYS_ISO2022:
- for (i = 0; i < 4; i++)
- mark_object (CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i));
- if (codesys->iso2022.input_conv)
- {
- for (i = 0; i < Dynarr_length (codesys->iso2022.input_conv); i++)
- {
- struct charset_conversion_spec *ccs =
- Dynarr_atp (codesys->iso2022.input_conv, i);
- mark_object (ccs->from_charset);
- mark_object (ccs->to_charset);
- }
- }
- if (codesys->iso2022.output_conv)
- {
- for (i = 0; i < Dynarr_length (codesys->iso2022.output_conv); i++)
- {
- struct charset_conversion_spec *ccs =
- Dynarr_atp (codesys->iso2022.output_conv, i);
- mark_object (ccs->from_charset);
- mark_object (ccs->to_charset);
- }
- }
+ iso2022_marker (codesys);
break;
case CODESYS_CCL:
- mark_object (CODING_SYSTEM_CCL_DECODE (codesys));
- mark_object (CODING_SYSTEM_CCL_ENCODE (codesys));
+ ccl_marker (codesys);
break;
#endif /* MULE */
+
+ case CODESYS_CHAIN:
+ chain_marker (codesys);
+ break;
+
default:
break;
}
@@ -406,6 +390,14 @@
}
static void
+chain_finalizer (Lisp_Coding_System *c)
+{
+ if (CODING_SYSTEM_CHAIN_CHAIN (c))
+ xfree (CODING_SYSTEM_CHAIN_CHAIN (c));
+ CODING_SYSTEM_CHAIN_CHAIN (c) = 0;
+}
+
+static void
finalize_coding_system (void *header, int for_disksave)
{
Lisp_Coding_System *c = (Lisp_Coding_System *) header;
@@ -418,18 +410,12 @@
{
#ifdef MULE
case CODESYS_ISO2022:
- if (c->iso2022.input_conv)
- {
- Dynarr_free (c->iso2022.input_conv);
- c->iso2022.input_conv = 0;
- }
- if (c->iso2022.output_conv)
- {
- Dynarr_free (c->iso2022.output_conv);
- c->iso2022.output_conv = 0;
- }
+ iso2022_finalizer (c);
break;
#endif /* MULE */
+ case CODESYS_CHAIN:
+ chain_finalizer (c);
+ break;
default:
break;
}
@@ -488,17 +474,17 @@
XSTRING_DATA (CODING_SYSTEM_MNEMONIC (codesys)), mlen);
}
-#define DEFINE_SUB_CODESYS(op_sys, op_sys_abbr, Type) do { \
- strcpy (codesys_name + len, "-" op_sys); \
- if (mlen != -1) \
- strcpy (codesys_mnemonic + mlen, op_sys_abbr); \
- codesys_name_sym = intern (codesys_name); \
- sub_codesys_obj = Fcopy_coding_system (codesys_obj, codesys_name_sym); \
- XCODING_SYSTEM_EOL_TYPE (sub_codesys_obj) = Type; \
- if (mlen != -1) \
- XCODING_SYSTEM_MNEMONIC(sub_codesys_obj) = \
- build_string (codesys_mnemonic); \
- CODING_SYSTEM_##Type (codesys) = sub_codesys_obj; \
+#define DEFINE_SUB_CODESYS(op_sys, op_sys_abbr, Type) do { \
+ strcpy (codesys_name + len, "-" op_sys); \
+ if (mlen != -1) \
+ strcpy (codesys_mnemonic + mlen, op_sys_abbr); \
+ codesys_name_sym = intern (codesys_name); \
+ sub_codesys_obj = Fcopy_coding_system (codesys_obj, codesys_name_sym); \
+ XCODING_SYSTEM_EOL_TYPE (sub_codesys_obj) = Type; \
+ if (mlen != -1) \
+ XCODING_SYSTEM_MNEMONIC(sub_codesys_obj) = \
+ build_string (codesys_mnemonic); \
+ CODING_SYSTEM_##Type (codesys) = sub_codesys_obj; \
} while (0)
DEFINE_SUB_CODESYS("unix", "", EOL_LF);
@@ -553,7 +539,8 @@
coding_system_or_name =
Fgethash (coding_system_or_name, Vcoding_system_hash_table, Qnil);
- if (CODING_SYSTEMP (coding_system_or_name) || NILP (coding_system_or_name))
+ if (CODING_SYSTEMP (coding_system_or_name)
+ || NILP (coding_system_or_name))
return coding_system_or_name;
}
}
@@ -706,8 +693,57 @@
return Fnreverse (result);
}
+static int
+ccl_parse_creation_properties (Lisp_Coding_System *codesys, Lisp_Object key,
+ Lisp_Object value)
+{
+ if (EQ (key, Qdecode))
+ {
+ CHECK_VECTOR (value);
+ CODING_SYSTEM_CCL_DECODE (codesys) = value;
+ }
+ else if (EQ (key, Qencode))
+ {
+ CHECK_VECTOR (value);
+ CODING_SYSTEM_CCL_ENCODE (codesys) = value;
+ }
+ else
+ return 1;
+ return 0;
+}
+
#endif /* MULE */
+static int
+chain_parse_creation_properties (Lisp_Coding_System *codesys, Lisp_Object key,
+ Lisp_Object value)
+{
+ if (EQ (key, Qlist))
+ {
+ Lisp_Object tail;
+ int count = 0;
+
+ EXTERNAL_LIST_LOOP (tail, value)
+ {
+ Fget_coding_system (XCAR (tail));
+ count++;
+ }
+
+ CODING_SYSTEM_CHAIN_CHAIN (codesys) = xnew_array (Lisp_Object, count);
+
+ count = 0;
+ EXTERNAL_LIST_LOOP (tail, value)
+ {
+ CODING_SYSTEM_CHAIN_CHAIN (codesys)[count] =
+ Fget_coding_system (XCAR (tail));
+ count++;
+ }
+ }
+ else
+ return 1;
+ return 0;
+}
+
DEFUN ("make-coding-system", Fmake_coding_system, 2, 4, 0, /*
Register symbol NAME as a coding system.
@@ -716,6 +752,9 @@
nil or 'undecided
Automatic conversion. XEmacs attempts to detect the coding system
used in the file.
+'chain
+ Chain two or more coding systems together to make a combination coding
+ system.
'no-conversion
No conversion. Use this for binary files and such. On output,
graphic characters that are not in ASCII or Latin-1 will be
@@ -727,6 +766,15 @@
ISO 10646 UCS-4 encoding.
'utf-8
ISO 10646 UTF-8 encoding.
+'mswindows-multibyte-to-unicode
+ (MS Windows only) Converts from Windows Multibyte to Windows Unicode
+ upon encoding, and the other way upon decoding.
+'mswindows-multibyte
+ (MS Windows only) Multibyte encoding used in MS Windows API calls.
+'mswindows-tstr
+ (MS Windows only) Correct encoding used in MS Windows API calls.
+ This maps to either `mswindows-unicode' or `mswindows-multibyte',
+ depending on whether the UNICODE preprocessor constant is defined.
'iso2022
Any ISO2022-compliant encoding. Among other things, this includes
JIS (the Japanese encoding commonly used for e-mail), EUC (the
@@ -878,6 +926,13 @@
'encode
CCL program used for encoding (converting to external format).
+
+
+The following additional property is recognized (and required)
+if TYPE is 'chain:
+
+'list
+ List of coding systems to be chained together, in encoding order.
*/
(name, type, doc_string, props))
{
@@ -887,20 +942,11 @@
int need_to_setup_eol_systems = 1;
/* Convert type to constant */
- if (NILP (type) || EQ (type, Qundecided))
- { ty = CODESYS_AUTODETECT; }
-#ifdef MULE
- else if (EQ (type, Qshift_jis)) { ty = CODESYS_SHIFT_JIS; }
- else if (EQ (type, Qiso2022)) { ty = CODESYS_ISO2022; }
- else if (EQ (type, Qbig5)) { ty = CODESYS_BIG5; }
- else if (EQ (type, Qucs4)) { ty = CODESYS_UCS4; }
- else if (EQ (type, Qutf8)) { ty = CODESYS_UTF8; }
- else if (EQ (type, Qccl)) { ty = CODESYS_CCL; }
-#endif
- else if (EQ (type, Qno_conversion)) { ty = CODESYS_NO_CONVERSION; }
-#ifdef DEBUG_XEMACS
- else if (EQ (type, Qinternal)) { ty = CODESYS_INTERNAL; }
-#endif
+ if (NILP (type) || EQ (type, Qundecided)) ty = CODESYS_AUTODETECT;
+#define SLOT(slot) \
+ else if (EQ (type, Q##slot)) ty = CODESYS##slot;
+#include "coding-slots.h"
+#undef SLOT
else
signal_simple_error ("Invalid coding system type", type);
@@ -916,6 +962,8 @@
EXTERNAL_PROPERTY_LIST_LOOP (rest, key, value, props)
{
+ int err = 0;
+
if (EQ (key, Qmnemonic))
{
if (!NILP (value))
@@ -931,73 +979,22 @@
CODING_SYSTEM_EOL_TYPE (codesys) = symbol_to_eol_type (value);
}
- else if (EQ (key, Qpost_read_conversion)) CODING_SYSTEM_POST_READ_CONVERSION
(codesys) = value;
- else if (EQ (key, Qpre_write_conversion)) CODING_SYSTEM_PRE_WRITE_CONVERSION
(codesys) = value;
+ else if (EQ (key, Qpost_read_conversion))
+ CODING_SYSTEM_POST_READ_CONVERSION (codesys) = value;
+ else if (EQ (key, Qpre_write_conversion))
+ CODING_SYSTEM_PRE_WRITE_CONVERSION (codesys) = value;
#ifdef MULE
else if (ty == CODESYS_ISO2022)
- {
-#define FROB_INITIAL_CHARSET(charset_num) \
- CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, charset_num) = \
- ((EQ (value, Qt) || EQ (value, Qnil)) ? value : Fget_charset (value))
-
- if (EQ (key, Qcharset_g0)) FROB_INITIAL_CHARSET (0);
- else if (EQ (key, Qcharset_g1)) FROB_INITIAL_CHARSET (1);
- else if (EQ (key, Qcharset_g2)) FROB_INITIAL_CHARSET (2);
- else if (EQ (key, Qcharset_g3)) FROB_INITIAL_CHARSET (3);
-
-#define FROB_FORCE_CHARSET(charset_num) \
- CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (codesys, charset_num) = !NILP (value)
-
- else if (EQ (key, Qforce_g0_on_output)) FROB_FORCE_CHARSET (0);
- else if (EQ (key, Qforce_g1_on_output)) FROB_FORCE_CHARSET (1);
- else if (EQ (key, Qforce_g2_on_output)) FROB_FORCE_CHARSET (2);
- else if (EQ (key, Qforce_g3_on_output)) FROB_FORCE_CHARSET (3);
-
-#define FROB_BOOLEAN_PROPERTY(prop) \
- CODING_SYSTEM_ISO2022_##prop (codesys) = !NILP (value)
-
- else if (EQ (key, Qshort)) FROB_BOOLEAN_PROPERTY (SHORT);
- else if (EQ (key, Qno_ascii_eol)) FROB_BOOLEAN_PROPERTY (NO_ASCII_EOL);
- else if (EQ (key, Qno_ascii_cntl)) FROB_BOOLEAN_PROPERTY (NO_ASCII_CNTL);
- else if (EQ (key, Qseven)) FROB_BOOLEAN_PROPERTY (SEVEN);
- else if (EQ (key, Qlock_shift)) FROB_BOOLEAN_PROPERTY (LOCK_SHIFT);
- else if (EQ (key, Qno_iso6429)) FROB_BOOLEAN_PROPERTY (NO_ISO6429);
- else if (EQ (key, Qescape_quoted)) FROB_BOOLEAN_PROPERTY (ESCAPE_QUOTED);
-
- else if (EQ (key, Qinput_charset_conversion))
- {
- codesys->iso2022.input_conv =
- Dynarr_new (charset_conversion_spec);
- parse_charset_conversion_specs (codesys->iso2022.input_conv,
- value);
- }
- else if (EQ (key, Qoutput_charset_conversion))
- {
- codesys->iso2022.output_conv =
- Dynarr_new (charset_conversion_spec);
- parse_charset_conversion_specs (codesys->iso2022.output_conv,
- value);
- }
- else
- signal_simple_error ("Unrecognized property", key);
- }
- else if (EQ (type, Qccl))
- {
- if (EQ (key, Qdecode))
- {
- CHECK_VECTOR (value);
- CODING_SYSTEM_CCL_DECODE (codesys) = value;
- }
- else if (EQ (key, Qencode))
- {
- CHECK_VECTOR (value);
- CODING_SYSTEM_CCL_ENCODE (codesys) = value;
- }
- else
- signal_simple_error ("Unrecognized property", key);
- }
-#endif /* MULE */
+ err = iso2022_parse_creation_properties (codesys, key, value);
+ else if (ty == CODESYS_CCL)
+ err = ccl_parse_creation_properties (codesys, key, value);
+#endif
+ else if (ty == CODESYS_CHAIN)
+ err = chain_parse_creation_properties (codesys, key, value);
else
+ err = 1;
+
+ if (err)
signal_simple_error ("Unrecognized property", key);
}
@@ -1042,7 +1039,8 @@
return new_coding_system;
}
-DEFUN ("coding-system-canonical-name-p", Fcoding_system_canonical_name_p, 1, 1,
0, /*
+DEFUN ("coding-system-canonical-name-p", Fcoding_system_canonical_name_p,
+ 1, 1, 0, /*
Return t if OBJECT names a coding system, and is not a coding system alias.
*/
(object))
@@ -1258,18 +1256,10 @@
{
default: abort ();
case CODESYS_AUTODETECT: return Qundecided;
-#ifdef MULE
- case CODESYS_SHIFT_JIS: return Qshift_jis;
- case CODESYS_ISO2022: return Qiso2022;
- case CODESYS_BIG5: return Qbig5;
- case CODESYS_UCS4: return Qucs4;
- case CODESYS_UTF8: return Qutf8;
- case CODESYS_CCL: return Qccl;
-#endif
- case CODESYS_NO_CONVERSION: return Qno_conversion;
-#ifdef DEBUG_XEMACS
- case CODESYS_INTERNAL: return Qinternal;
-#endif
+#define SLOT(slot) \
+ case CODESYS##slot: return Q##slot;
+#include "coding-slots.h"
+#undef SLOT
}
}
@@ -1548,6 +1538,13 @@
eol_type_t eol_type;
int seen_non_ascii;
int mask;
+
+ struct
+ {
+ int mask;
+ }
+ no_conversion;
+
#ifdef MULE
struct
{
@@ -1566,8 +1563,17 @@
struct
{
int mask;
+ int byteno;
+ int prev_char;
+ int text, rev_text;
+ }
+ utf16;
+
+ struct
+ {
+ int mask;
int in_byte;
- }
+ }
ucs4;
struct
@@ -1587,7 +1593,30 @@
unsigned int saw_single_shift:1;
}
iso2022;
+
+ struct
+ {
+ int mask;
+ }
+ ccl;
+#endif
+
+#ifdef DEBUG_XEMACS
+ struct
+ {
+ int mask;
+ }
+ internal;
+#endif
+
+#ifdef HAVE_WIN32
+ struct
+ {
+ int mask;
+ }
+ mswindows_multibyte;
#endif
+
struct
{
int seen_anything;
@@ -1691,13 +1720,10 @@
if ((c < 0x20 && !acceptable_control_char_p (c)) || c >= 0x80)
{
st->seen_non_ascii = 1;
-#ifdef MULE
- st->shift_jis.mask = ~0;
- st->big5.mask = ~0;
- st->ucs4.mask = ~0;
- st->utf8.mask = ~0;
- st->iso2022.mask = ~0;
-#endif
+#define SLOT(slot) \
+ st->slot.mask = ~0;
+#include "coding-slots.h"
+#undef SLOT
break;
}
}
@@ -1706,21 +1732,23 @@
if (!n)
return 0;
#ifdef MULE
- if (!mask_has_at_most_one_bit_p (st->iso2022.mask))
- st->iso2022.mask = detect_coding_iso2022 (st, src, n);
- if (!mask_has_at_most_one_bit_p (st->shift_jis.mask))
- st->shift_jis.mask = detect_coding_sjis (st, src, n);
- if (!mask_has_at_most_one_bit_p (st->big5.mask))
- st->big5.mask = detect_coding_big5 (st, src, n);
- if (!mask_has_at_most_one_bit_p (st->utf8.mask))
- st->utf8.mask = detect_coding_utf8 (st, src, n);
- if (!mask_has_at_most_one_bit_p (st->ucs4.mask))
- st->ucs4.mask = detect_coding_ucs4 (st, src, n);
+ /* #### this algorithm stops too soon. it should continue running
+ the detection mechanisms of all coding system types as long as
+ there is any room for doubt. */
+#define SLOT(slot) \
+ if (!mask_has_at_most_one_bit_p (st->slot.mask))
+ st->slot.mask = detect_coding_##slot (st, src, n);
+#include "coding-slots.h"
+#undef SLOT
st->mask
- = st->iso2022.mask | st->shift_jis.mask | st->big5.mask
- | st->utf8.mask | st->ucs4.mask;
-#endif
+ = 0
+#define SLOT(slot) \
+ | st->slot.mask
+#include "coding-slots.h"
+#undef SLOT
+ ;
+
{
int retval = mask_has_at_most_one_bit_p (st->mask);
st->mask |= CODING_CATEGORY_NO_CONVERSION_MASK;
@@ -1911,6 +1939,28 @@
Lstream_rewind (stream);
}
+/* do any necessary runtime conversion on the coding system. */
+static Lisp_Object
+canonicalize_coding_system (Lisp_Object codesys)
+{
+ /* #### should be a coding system method */
+#ifdef HAVE_WIN32
+ if (EQ (XCODING_SYSTEM_TYPE (codesys), Qmswindows_multibyte))
+ {
+ int cp = mswindows_current_codepage ();
+ Lisp_Object cs =
+ Fgethash (make_int (cp), Vmswindows_code_page_table, Qnil);
+
+ if (NILP (cs))
+ cs = Fget_coding_system (Qbinary);
+
+ return cs;
+ }
+#endif
+
+ return codesys;
+}
+
DEFUN ("detect-coding-region", Fdetect_coding_region, 2, 3, 0, /*
Detect coding system of the text in the region between START and END.
Returned a list of possible coding systems ordered by priority.
@@ -1931,7 +1981,8 @@
get_buffer_range_char (buf, start, end, &b, &e, 0);
lb_instream = make_lisp_buffer_input_stream (buf, b, e, 0);
lb_istr = XLSTREAM (lb_instream);
- instream = make_encoding_input_stream (lb_istr, Fget_coding_system (Qbinary));
+ instream = make_encoding_input_stream
+ (lb_istr, Fget_coding_system (Qbinary));
istr = XLSTREAM (instream);
GCPRO2 (instream, lb_instream);
xzero (decst);
@@ -1940,7 +1991,8 @@
while (1)
{
unsigned char random_buffer[4096];
- ssize_t nread = Lstream_read (istr, random_buffer, sizeof (random_buffer));
+ ssize_t nread =
+ Lstream_read (istr, random_buffer, sizeof (random_buffer));
if (!nread)
break;
@@ -2104,6 +2156,23 @@
/* counter for UTF-8 or UCS-4 */
unsigned char counter;
#endif
+
+ struct
+ {
+ int initted;
+ /* Lstreams for chain coding system */
+ Lisp_Object *lstreams;
+ int lstream_count;
+ } chain;
+
+#ifdef HAVE_WIN32
+ struct
+ {
+ int partial_byte;
+ int partial_byte_present;
+ } mswindows_multibyte_to_unicode;
+#endif
+
struct detection_state decst;
};
@@ -2126,6 +2195,7 @@
{
Lstream *str = DECODING_STREAM_DATA (XLSTREAM (stream))->other_end;
Lisp_Object str_obj;
+ int i;
/* We do not need to mark the coding systems or charsets stored
within the stream because they are stored in a global list
@@ -2133,6 +2203,10 @@
XSETLSTREAM (str_obj, str);
mark_object (str_obj);
+
+ for (i = 0; i < chain.lstream_count; i++)
+ mark_object (str->chain.lstreams[i]);
+
if (str->imp->marker)
return (str->imp->marker) (str_obj);
else
@@ -2276,20 +2350,24 @@
static int
decoding_closer (Lstream *stream)
{
+ int err;
+
struct decoding_stream *str = DECODING_STREAM_DATA (stream);
if (stream->flags & LSTREAM_FL_WRITE)
{
str->flags |= CODING_STATE_END;
decoding_writer (stream, 0, 0);
}
+ err = Lstream_close (str->other_end);
Dynarr_free (str->runoff);
+
+ if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CHAIN)
+ chain_decoding_closer (str);
#ifdef MULE
-#ifdef ENABLE_COMPOSITE_CHARS
- if (str->iso2022.composite_chars)
- Dynarr_free (str->iso2022.composite_chars);
-#endif
-#endif
- return Lstream_close (str->other_end);
+ if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_ISO2022)
+ iso2022_decoding_closer (str);
+#ifdef MULE
+ return err;
}
Lisp_Object
@@ -2328,6 +2406,8 @@
struct decoding_stream *str = DECODING_STREAM_DATA (lstr);
Lisp_Object obj;
+ codesys = canonicalize_coding_system (codesys);
+
xzero (*str);
str->other_end = stream;
str->runoff = (unsigned_char_dynarr *) Dynarr_new (unsigned_char);
@@ -2404,38 +2484,19 @@
switch (CODING_SYSTEM_TYPE (str->codesys))
{
-#ifdef DEBUG_XEMACS
- case CODESYS_INTERNAL:
- Dynarr_add_many (dst, src, n);
- break;
-#endif
case CODESYS_AUTODETECT:
/* If we got this far and still haven't decided on the coding
system, then do no conversion. */
- case CODESYS_NO_CONVERSION:
decode_coding_no_conversion (decoding, src, dst, n);
- break;
-#ifdef MULE
- case CODESYS_SHIFT_JIS:
- decode_coding_sjis (decoding, src, dst, n);
- break;
- case CODESYS_BIG5:
- decode_coding_big5 (decoding, src, dst, n);
- break;
- case CODESYS_UCS4:
- decode_coding_ucs4 (decoding, src, dst, n);
- break;
- case CODESYS_UTF8:
- decode_coding_utf8 (decoding, src, dst, n);
- break;
- case CODESYS_CCL:
- str->ccl.last_block = str->flags & CODING_STATE_END;
- ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_DECODING);
break;
- case CODESYS_ISO2022:
- decode_coding_iso2022 (decoding, src, dst, n);
+
+#define SLOT(slot) \
+ case CODESYS_##slot:
+ decode_coding_##slot (decoding, src, dst, n);
break;
-#endif /* MULE */
+#include "coding-slots.h"
+#undef SLOT
+
default:
abort ();
}
@@ -2568,9 +2629,26 @@
used by the CCL encoder. */
struct ccl_program ccl;
#endif /* MULE */
+
+ struct
+ {
+ int initted;
+ /* Lstreams for chain coding system */
+ Lisp_Object *lstreams;
+ int lstream_count;
+ } chain;
+
+#ifdef HAVE_WIN32
+ struct
+ {
+ int partial_byte;
+ int partial_byte_present;
+ } mswindows_multibyte_to_unicode;
+#endif
};
-static ssize_t encoding_reader (Lstream *stream, unsigned char *data, size_t size);
+static ssize_t encoding_reader (Lstream *stream, unsigned char *data,
+ size_t size);
static ssize_t encoding_writer (Lstream *stream, const unsigned char *data,
size_t size);
static int encoding_rewinder (Lstream *stream);
@@ -2595,6 +2673,10 @@
XSETLSTREAM (str_obj, str);
mark_object (str_obj);
+
+ for (i = 0; i < chain.lstream_count; i++)
+ mark_object (str->chain.lstreams[i]);
+
if (str->imp->marker)
return (str->imp->marker) (str_obj);
else
@@ -2747,14 +2829,20 @@
static int
encoding_closer (Lstream *stream)
{
+ int err;
+
struct encoding_stream *str = ENCODING_STREAM_DATA (stream);
if (stream->flags & LSTREAM_FL_WRITE)
{
str->flags |= CODING_STATE_END;
encoding_writer (stream, 0, 0);
}
+ err = Lstream_close (str->other_end);
Dynarr_free (str->runoff);
- return Lstream_close (str->other_end);
+
+ if (CODING_SYSTEM_TYPE (str->codesys) == CODESYS_CHAIN)
+ chain_encoding_closer (str);
+ return err;
}
Lisp_Object
@@ -2784,6 +2872,8 @@
struct encoding_stream *str = ENCODING_STREAM_DATA (lstr);
Lisp_Object obj;
+ codesys = canonicalize_coding_system (codesys);
+
xzero (*str);
str->runoff = Dynarr_new (unsigned_char);
str->other_end = stream;
@@ -2816,38 +2906,17 @@
switch (CODING_SYSTEM_TYPE (str->codesys))
{
-#ifdef DEBUG_XEMACS
- case CODESYS_INTERNAL:
- Dynarr_add_many (dst, src, n);
- break;
-#endif
case CODESYS_AUTODETECT:
/* If we got this far and still haven't decided on the coding
system, then do no conversion. */
- case CODESYS_NO_CONVERSION:
encode_coding_no_conversion (encoding, src, dst, n);
- break;
-#ifdef MULE
- case CODESYS_SHIFT_JIS:
- encode_coding_sjis (encoding, src, dst, n);
- break;
- case CODESYS_BIG5:
- encode_coding_big5 (encoding, src, dst, n);
break;
- case CODESYS_UCS4:
- encode_coding_ucs4 (encoding, src, dst, n);
- break;
- case CODESYS_UTF8:
- encode_coding_utf8 (encoding, src, dst, n);
- break;
- case CODESYS_CCL:
- str->ccl.last_block = str->flags & CODING_STATE_END;
- ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_ENCODING);
- break;
- case CODESYS_ISO2022:
- encode_coding_iso2022 (encoding, src, dst, n);
- break;
-#endif /* MULE */
+
+#define SLOT(slot) \
+ encode_coding_##slot (encoding, src, dst, n);
+#include "coding-slots.h"
+#undef SLOT
+
default:
abort ();
}
@@ -2944,19 +3013,19 @@
/* Is this the first byte of a Shift-JIS two-byte char? */
-#define BYTE_SJIS_TWO_BYTE_1_P(c) \
+#define BYTE_SHIFT_JIS_TWO_BYTE_1_P(c) \
(((c) >= 0x81 && (c) <= 0x9F) || ((c) >= 0xE0 && (c) <=
0xEF))
/* Is this the second byte of a Shift-JIS two-byte char? */
-#define BYTE_SJIS_TWO_BYTE_2_P(c) \
+#define BYTE_SHIFT_JIS_TWO_BYTE_2_P(c) \
(((c) >= 0x40 && (c) <= 0x7E) || ((c) >= 0x80 && (c) <=
0xFC))
-#define BYTE_SJIS_KATAKANA_P(c) \
+#define BYTE_SHIFT_JIS_KATAKANA_P(c) \
((c) >= 0xA1 && (c) <= 0xDF)
static int
-detect_coding_sjis (struct detection_state *st, const unsigned char *src,
+detect_coding_shift_jis (struct detection_state *st, const unsigned char *src,
unsigned int n)
{
int c;
@@ -2981,11 +3050,10 @@
/* Convert Shift-JIS data to internal format. */
static void
-decode_coding_sjis (Lstream *decoding, const unsigned char *src,
+decode_coding_shift_jis (struct decoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = str->eol_type;
@@ -2997,12 +3065,12 @@
if (ch)
{
/* Previous character was first byte of Shift-JIS Kanji char. */
- if (BYTE_SJIS_TWO_BYTE_2_P (c))
+ if (BYTE_SHIFT_JIS_TWO_BYTE_2_P (c))
{
unsigned char e1, e2;
Dynarr_add (dst, LEADING_BYTE_JAPANESE_JISX0208);
- DECODE_SJIS (ch, c, e1, e2);
+ DECODE_SHIFT_JIS (ch, c, e1, e2);
Dynarr_add (dst, e1);
Dynarr_add (dst, e2);
}
@@ -3016,9 +3084,9 @@
else
{
DECODE_HANDLE_EOL_TYPE (eol_type, c, flags, dst);
- if (BYTE_SJIS_TWO_BYTE_1_P (c))
+ if (BYTE_SHIFT_JIS_TWO_BYTE_1_P (c))
ch = c;
- else if (BYTE_SJIS_KATAKANA_P (c))
+ else if (BYTE_SHIFT_JIS_KATAKANA_P (c))
{
Dynarr_add (dst, LEADING_BYTE_KATAKANA_JISX0201);
Dynarr_add (dst, c);
@@ -3038,11 +3106,10 @@
/* Convert internally-formatted data to Shift-JIS. */
static void
-encode_coding_sjis (Lstream *encoding, const unsigned char *src,
+encode_coding_shift_jis (struct encoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
@@ -3080,7 +3147,7 @@
else
{
unsigned char j1, j2;
- ENCODE_SJIS (ch, c, j1, j2);
+ ENCODE_SHIFT_JIS (ch, c, j1, j2);
Dynarr_add (dst, j1);
Dynarr_add (dst, j2);
ch = 0;
@@ -3106,10 +3173,10 @@
CHECK_INT (XCDR (code));
s1 = XINT (XCAR (code));
s2 = XINT (XCDR (code));
- if (BYTE_SJIS_TWO_BYTE_1_P (s1) &&
- BYTE_SJIS_TWO_BYTE_2_P (s2))
+ if (BYTE_SHIFT_JIS_TWO_BYTE_1_P (s1) &&
+ BYTE_SHIFT_JIS_TWO_BYTE_2_P (s2))
{
- DECODE_SJIS (s1, s2, c1, c2);
+ DECODE_SHIFT_JIS (s1, s2, c1, c2);
return make_char (MAKE_CHAR (Vcharset_japanese_jisx0208,
c1 & 0x7F, c2 & 0x7F));
}
@@ -3130,7 +3197,7 @@
BREAKUP_CHAR (XCHAR (ch), charset, c1, c2);
if (EQ (charset, Vcharset_japanese_jisx0208))
{
- ENCODE_SJIS (c1 | 0x80, c2 | 0x80, s1, s2);
+ ENCODE_SHIFT_JIS (c1 | 0x80, c2 | 0x80, s1, s2);
return Fcons (make_int (s1), make_int (s2));
}
else
@@ -3268,11 +3335,10 @@
/* Convert Big5 data to internal format. */
static void
-decode_coding_big5 (Lstream *decoding, const unsigned char *src,
+decode_coding_big5 (struct decoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = str->eol_type;
@@ -3318,11 +3384,10 @@
/* Convert internally-formatted data to Big5. */
static void
-encode_coding_big5 (Lstream *encoding, const unsigned char *src,
+encode_coding_big5 (struct encoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
@@ -3429,7 +3494,7 @@
/************************************************************************/
-/* UCS-4 methods */
+/* UCS-2 and UCS-4 methods */
/* */
/* UCS-4 character codes are implemented as nonnegative integers. */
/* */
@@ -3511,7 +3576,7 @@
return Fget_char_table (character, mule_to_ucs_table);
}
-/* Decode a UCS-4 character into a buffer. If the lookup fails, use
+/* Decode a UCS-2 or UCS-4 character into a buffer. If the lookup fails, use
<GETA MARK> (U+3013) of JIS X 0208, which means correct character
is not found, instead.
#### do something more appropriate (use blob?)
@@ -3541,8 +3606,8 @@
}
static unsigned long
-mule_char_to_ucs4 (Lisp_Object charset,
- unsigned char h, unsigned char l)
+mule_char_to_ucs2_or_4 (Lisp_Object charset, unsigned char h, unsigned char l,
+ int four_p)
{
Lisp_Object code
= Fget_char_table (make_char (MAKE_CHAR (charset, h & 127, l & 127)),
@@ -3552,8 +3617,9 @@
{
return XINT (code);
}
- else if ( (XCHARSET_DIMENSION (charset) == 2) &&
- (XCHARSET_CHARS (charset) == 94) )
+ else if (four_p &&
+ XCHARSET_DIMENSION (charset) == 2 &&
+ XCHARSET_CHARS (charset) == 94)
{
unsigned char final = XCHARSET_FINAL (charset);
@@ -3577,13 +3643,32 @@
encode_ucs4 (Lisp_Object charset,
unsigned char h, unsigned char l, unsigned_char_dynarr *dst)
{
- unsigned long code = mule_char_to_ucs4 (charset, h, l);
+ unsigned long code = mule_char_to_ucs2_or_4 (charset, h, l, 1);
Dynarr_add (dst, code >> 24);
Dynarr_add (dst, (code >> 16) & 255);
Dynarr_add (dst, (code >> 8) & 255);
Dynarr_add (dst, code & 255);
}
+static void
+encode_utf16 (Lisp_Object charset,
+ unsigned char h, unsigned char l, unsigned_char_dynarr *dst)
+{
+ unsigned long code = mule_char_to_ucs2_or_4 (charset, h, l, 0);
+ Dynarr_add (dst, (code >> 8) & 255);
+ Dynarr_add (dst, code & 255);
+}
+
+static void
+encode_ucs2_or_4 (Lisp_Object charset, unsigned char h, unsigned char l,
+ unsigned_char_dynarr *dst, int four_p)
+{
+ if (four_p)
+ encode_ucs4 (charset, h, l, dst);
+ else
+ encode_ucs2 (charset, h, l, dst);
+}
+
static int
detect_coding_ucs4 (struct detection_state *st, const unsigned char *src,
unsigned int n)
@@ -3609,11 +3694,57 @@
return CODING_CATEGORY_UCS4_MASK;
}
+static int
+detect_coding_utf16 (struct detection_state *st, const unsigned char *src,
+ unsigned int n)
+{
+ while (n--)
+ {
+ int c = *src++;
+ int prevc == st->utf16.prev_char;
+ if (st->utf16.byteno == 1 && c == 0xFF && prevc == 0xFE)
+ return CODING_CATEGORY_UTF16_MASK;
+ else if (st->utf16.byteno == 1 && c == 0xFE && prevc == 0xFF)
+ return CODING_CATEGORY_UTF16_BYTE_REVERSED_MASK;
+
+ if (st->utf16.byteno & 1)
+ {
+ if (c == 0xFF && prevc == 0xFF)
+ return 0;
+ if (prevc == 0
+ && (c == '\r' || c == '\n'
+ || (c >= 0x20 && c <= 0x7E)))
+ st->utf16.text++;
+ if (c == 0
+ && (prevc == '\r' || prevc == '\n'
+ || (prevc >= 0x20 && prevc <= 0x7E)))
+ st->utf16.rev_text++;
+ if (prevc == 0x20 && (c == 0x28 || c == 0x29))
+ st->utf16.text++;
+ if (c == 0x20 && (prevc == 0x28 || prevc == 0x29))
+ st->utf16.rev_text++;
+
+ if (st->utf16.text >= 10
+ && (st->utf16.rev_text == 0
+ || st->utf16.text / st->utf16.rev_text >= 10))
+ return CODING_CATEGORY_UTF16_MASK;
+ if (st->utf16.rev_text >= 10
+ && (st->utf16.text == 0
+ || st->utf16.rev_text / st->utf16.text >= 10))
+ return CODING_CATEGORY_UTF16_BYTE_REVERSED_MASK;
+ }
+
+ st->utf16.byteno++;
+ st->utf16.prev_char = c;
+ }
+
+ return 0;
+}
+
static void
-decode_coding_ucs4 (Lstream *decoding, const unsigned char *src,
- unsigned_char_dynarr *dst, unsigned int n)
+decode_coding_ucs2_or_4 (struct decoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n, int four_p)
{
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
unsigned char counter = str->counter;
@@ -3625,7 +3756,10 @@
{
case 0:
ch = c;
- counter = 3;
+ if (four_p)
+ counter = 3;
+ else
+ counter = 1;
break;
case 1:
decode_ucs4 ( ( ch << 8 ) | c, dst);
@@ -3646,13 +3780,31 @@
}
static void
-encode_coding_ucs4 (Lstream *encoding, const unsigned char *src,
+decode_coding_ucs4 (struct decoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
- unsigned int flags = str->flags;
- unsigned int ch = str->ch;
- unsigned char char_boundary = str->iso2022.current_char_boundary;
+ decode_coding_ucs2_or_4 (str, src, dst, n, 1);
+}
+
+static void
+decode_coding_utf16 (struct decoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+#ifdef HAVE_WIN32
+ /* #### HACK. once we implement real unicode conversion with our own
+ translation tables, we should actually do the opposite transformation
+ and implement mswindows-multibyte using unicode. */
+
+ decode_coding_ucs2_or_4 (str, src, dst, n, 0);
+}
+
+static void
+encode_coding_ucs2_or_4 (struct encoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n, int four_p)
+{
+ unsigned int flags = str->flags;
+ unsigned int ch = str->ch;
+ unsigned char char_boundary = str->iso2022.current_char_boundary;
Lisp_Object charset = str->iso2022.current_charset;
#ifdef ENABLE_COMPOSITE_CHARS
@@ -3672,7 +3824,7 @@
if (BYTE_ASCII_P (c))
{ /* Processing ASCII character */
ch = 0;
- encode_ucs4 (Vcharset_ascii, c, 0, dst);
+ encode_ucs2_or_4 (Vcharset_ascii, c, 0, dst, four_p);
char_boundary = 1;
}
else if (BUFBYTE_LEADING_BYTE_P (c) || BUFBYTE_LEADING_BYTE_P (ch))
@@ -3688,19 +3840,19 @@
char_boundary = 1;
if (EQ (charset, Vcharset_control_1))
{
- encode_ucs4 (Vcharset_control_1, c, 0, dst);
+ encode_ucs2_or_4 (Vcharset_control_1, c, 0, dst, four_p);
}
else
{
switch (XCHARSET_REP_BYTES (charset))
{
case 2:
- encode_ucs4 (charset, c, 0, dst);
+ encode_ucs2_or_4 (charset, c, 0, dst, four_p);
break;
case 3:
if (XCHARSET_PRIVATE_P (charset))
{
- encode_ucs4 (charset, c, 0, dst);
+ encode_ucs2_or_4 (charset, c, 0, dst, four_p);
ch = 0;
}
else if (ch)
@@ -3712,9 +3864,12 @@
{
/* #### Bother! We don't know how to
handle this yet. */
+ if (four_p)
+ {
+ Dynarr_add (dst, 0);
+ Dynarr_add (dst, 0);
+ }
Dynarr_add (dst, 0);
- Dynarr_add (dst, 0);
- Dynarr_add (dst, 0);
Dynarr_add (dst, '~');
}
else
@@ -3732,7 +3887,7 @@
else
#endif /* ENABLE_COMPOSITE_CHARS */
{
- encode_ucs4(charset, ch, c, dst);
+ encode_ucs2_or_4 (charset, ch, c, dst, four_p);
}
ch = 0;
}
@@ -3745,7 +3900,7 @@
case 4:
if (ch)
{
- encode_ucs4 (charset, ch, c, dst);
+ encode_ucs2_or_4 (charset, ch, c, dst, four_p);
ch = 0;
}
else
@@ -3779,6 +3934,20 @@
/* Verbum caro factum est! */
}
+static void
+encode_coding_ucs4 (struct encoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ encode_coding_ucs2_or_4 (str, src, dst, n, 1);
+}
+
+static void
+encode_coding_utf16 (struct encoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ encode_coding_ucs2_or_4 (str, src, dst, n, 0);
+}
+
/************************************************************************/
/* UTF-8 methods */
@@ -3820,10 +3989,9 @@
}
static void
-decode_coding_utf8 (Lstream *decoding, const unsigned char *src,
+decode_coding_utf8 (struct decoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = str->eol_type;
@@ -3891,7 +4059,7 @@
encode_utf8 (Lisp_Object charset,
unsigned char h, unsigned char l, unsigned_char_dynarr *dst)
{
- unsigned long code = mule_char_to_ucs4 (charset, h, l);
+ unsigned long code = mule_char_to_ucs2_or_4 (charset, h, l, 1);
if ( code <= 0x7f )
{
Dynarr_add (dst, code);
@@ -3934,10 +4102,9 @@
}
static void
-encode_coding_utf8 (Lstream *encoding, const unsigned char *src,
+encode_coding_utf8 (struct encoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
@@ -4843,10 +5010,9 @@
/* Convert ISO2022-format data to internal format. */
static void
-decode_coding_iso2022 (Lstream *decoding, const unsigned char *src,
+decode_coding_iso2022 (struct decoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = str->eol_type;
@@ -5169,12 +5335,11 @@
/* Convert internally-formatted data to ISO2022 format. */
static void
-encode_coding_iso2022 (Lstream *encoding, const unsigned char *src,
+encode_coding_iso2022 (struct encoding_stream *str, const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char charmask, c;
unsigned char char_boundary;
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
Lisp_Coding_System *codesys = str->codesys;
@@ -5468,21 +5633,537 @@
/* Verbum caro factum est! */
}
+
+static void
+iso2022_marker (Lisp_Coding_System *codesys)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ mark_object (CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i));
+ if (codesys->iso2022.input_conv)
+ {
+ for (i = 0; i < Dynarr_length (codesys->iso2022.input_conv); i++)
+ {
+ struct charset_conversion_spec *ccs =
+ Dynarr_atp (codesys->iso2022.input_conv, i);
+ mark_object (ccs->from_charset);
+ mark_object (ccs->to_charset);
+ }
+ }
+ if (codesys->iso2022.output_conv)
+ {
+ for (i = 0; i < Dynarr_length (codesys->iso2022.output_conv); i++)
+ {
+ struct charset_conversion_spec *ccs =
+ Dynarr_atp (codesys->iso2022.output_conv, i);
+ mark_object (ccs->from_charset);
+ mark_object (ccs->to_charset);
+ }
+ }
+}
+
+static void
+iso2022_finalizer (Lisp_Coding_System *c)
+{
+ if (c->iso2022.input_conv)
+ {
+ Dynarr_free (c->iso2022.input_conv);
+ c->iso2022.input_conv = 0;
+ }
+ if (c->iso2022.output_conv)
+ {
+ Dynarr_free (c->iso2022.output_conv);
+ c->iso2022.output_conv = 0;
+ }
+}
+
+static int
+iso2022_parse_creation_properties (Lisp_Coding_System *codesys,
+ Lisp_Object key,
+ Lisp_Object value)
+{
+#define FROB_INITIAL_CHARSET(charset_num) \
+ CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, charset_num) = \
+ ((EQ (value, Qt) || EQ (value, Qnil)) ? value : Fget_charset (value))
+
+ if (EQ (key, Qcharset_g0)) FROB_INITIAL_CHARSET (0);
+ else if (EQ (key, Qcharset_g1)) FROB_INITIAL_CHARSET (1);
+ else if (EQ (key, Qcharset_g2)) FROB_INITIAL_CHARSET (2);
+ else if (EQ (key, Qcharset_g3)) FROB_INITIAL_CHARSET (3);
+
+#define FROB_FORCE_CHARSET(charset_num) \
+ CODING_SYSTEM_ISO2022_FORCE_CHARSET_ON_OUTPUT (codesys, charset_num) = \
+ !NILP (value)
+
+ else if (EQ (key, Qforce_g0_on_output)) FROB_FORCE_CHARSET (0);
+ else if (EQ (key, Qforce_g1_on_output)) FROB_FORCE_CHARSET (1);
+ else if (EQ (key, Qforce_g2_on_output)) FROB_FORCE_CHARSET (2);
+ else if (EQ (key, Qforce_g3_on_output)) FROB_FORCE_CHARSET (3);
+
+#define FROB_BOOLEAN_PROPERTY(prop) \
+ CODING_SYSTEM_ISO2022_##prop (codesys) = !NILP (value)
+
+ else if (EQ (key, Qshort)) FROB_BOOLEAN_PROPERTY (SHORT);
+ else if (EQ (key, Qno_ascii_eol)) FROB_BOOLEAN_PROPERTY (NO_ASCII_EOL);
+ else if (EQ (key, Qno_ascii_cntl)) FROB_BOOLEAN_PROPERTY (NO_ASCII_CNTL);
+ else if (EQ (key, Qseven)) FROB_BOOLEAN_PROPERTY (SEVEN);
+ else if (EQ (key, Qlock_shift)) FROB_BOOLEAN_PROPERTY (LOCK_SHIFT);
+ else if (EQ (key, Qno_iso6429)) FROB_BOOLEAN_PROPERTY (NO_ISO6429);
+ else if (EQ (key, Qescape_quoted)) FROB_BOOLEAN_PROPERTY (ESCAPE_QUOTED);
+
+ else if (EQ (key, Qinput_charset_conversion))
+ {
+ codesys->iso2022.input_conv =
+ Dynarr_new (charset_conversion_spec);
+ parse_charset_conversion_specs (codesys->iso2022.input_conv,
+ value);
+ }
+ else if (EQ (key, Qoutput_charset_conversion))
+ {
+ codesys->iso2022.output_conv =
+ Dynarr_new (charset_conversion_spec);
+ parse_charset_conversion_specs (codesys->iso2022.output_conv,
+ value);
+ }
+ else
+ return 1;
+
+ return 0;
+}
+
+static void
+iso2022_decoding_closer (struct decoding_stream *str)
+{
+#ifdef ENABLE_COMPOSITE_CHARS
+ if (str->iso2022.composite_chars)
+ Dynarr_free (str->iso2022.composite_chars);
+#endif
+}
+
+
+/************************************************************************/
+/* CCL methods */
+/************************************************************************/
+
+static int
+detect_coding_ccl (struct detection_state *st, const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
+/* Convert Ccl data to internal format. */
+
+static void
+decode_coding_ccl (struct decoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ str->ccl.last_block = str->flags & CODING_STATE_END;
+ ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_DECODING);
+}
+
+/* Convert internally-formatted data to Ccl. */
+
+static void
+encode_coding_ccl (struct encoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ str->ccl.last_block = str->flags & CODING_STATE_END;
+ ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_ENCODING);
+}
+
#endif /* MULE */
+
+
+
+#ifdef DEBUG_XEMACS
+
+/************************************************************************/
+/* Internal methods */
+/************************************************************************/
+
+static int
+detect_coding_internal (struct detection_state *st, const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
+/* Convert Internal data to internal format. */
+
+static void
+decode_coding_internal (struct decoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ Dynarr_add_many (dst, src, n);
+}
+
+/* Convert internally-formatted data to Internal. */
+
+static void
+encode_coding_internal (struct encoding_stream *str, const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ Dynarr_add_many (dst, src, n);
+}
+
+#endif /* DEBUG_XEMACS */
+
+
+
+#ifdef HAVE_WIN32
+
+/************************************************************************/
+/* MS Windows Multibyte methods */
+/************************************************************************/
+
+DEFUN ("set-mswindows-code-page-mapping", Fset_mswindows_code_page_mapping,
+ 2, 2, 0, /*
+Set the coding system corresponding to an MS Windows code page.
+CODE-PAGE should be a positive integer. CODING-SYSTEM should be a
+coding system.
+
+#### This function will go away entirely once full Unicode support is present.
+Currently defined Windows code pages include:
+
+037 EBCDIC
+437 MS-DOS United States
+500 EBCDIC "500V1"
+708 Arabic (ASMO 708)
+709 Arabic (ASMO 449+, BCON V4)
+710 Arabic (Transparent Arabic)
+720 Arabic (Transparent ASMO)
+737 Greek (formerly 437G)
+775 Baltic
+850 MS-DOS Multilingual (Latin I)
+852 MS-DOS Slavic (Latin II)
+855 IBM Cyrillic (primarily Russian)
+857 IBM Turkish
+860 MS-DOS Portuguese
+861 MS-DOS Icelandic
+862 Hebrew
+863 MS-DOS Canadian-French
+864 Arabic
+865 MS-DOS Nordic
+866 MS-DOS Russian
+869 IBM Modern Greek
+874 Thai
+875 EBCDIC
+932 Japan
+936 Chinese (PRC, Singapore)
+949 Korean
+950 Chinese (Taiwan, Hong Kong)
+1026 EBCDIC
+1200 Unicode (BMP of ISO 10646)
+1250 Windows 3.1 Eastern European
+1251 Windows 3.1 Cyrillic
+1252 Windows 3.1 US (ANSI)
+1253 Windows 3.1 Greek
+1254 Windows 3.1 Turkish
+1255 Hebrew
+1256 Arabic
+1257 Baltic
+1361 Korean (Johab)
+10000 Macintosh Roman
+10001 Macintosh Japanese
+10006 Macintosh Greek I
+10007 Macintosh Cyrillic
+10029 Macintosh Latin 2
+10079 Macintosh Icelandic
+10081 Macintosh Turkish
+*/
+ (code_page, coding_system))
+{
+ CHECK_NATNUM (code_page);
+ coding_system = Fget_coding_system (coding_system);
+ Fputhash (code_page, coding_system, Vmswindows_code_page_table);
+ return Qnil;
+}
+
+DEFUN ("mswindows-code-page-mapping", Fmswindows_code_page_mapping,
+ 1, 1, 0, /*
+Return the coding system corresponding to an MS Windows code page.
+CODE-PAGE should be a positive integer. The return value is either
+a coding system, or nil if no coding system has been set with
+`set-mswindows-code-page-mapping'.
+*/
+ (code_page))
+{
+ CHECK_NATNUM (code_page);
+ return Fgethash (code_page, Vmswindows_code_page_table, Qnil);
+}
+
+static int
+detect_coding_mswindows_multibyte_to_unicode (struct detection_state *st,
+ const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
+/* Convert Unicode to MS Windows multibyte. */
+
+static void
+decode_coding_mswindows_multibyte_to_unicode (struct decoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst,
+ unsigned int n)
+{
+ unsigned_char *new_src = src;
+ int cp = mswindows_current_codepage ();
+
+ if (str->mswindows_multibyte_to_unicode.partial_byte_present)
+ {
+ new_src = alloca_array (src, n + 1);
+ memcpy (new_src + 1, src, n);
+ new_src[0] =
+ (unsigned char) str->mswindows_multibyte_to_unicode.partial_byte;
+ n++;
+ }
+
+ if (n & 1)
+ {
+ /* a char is split across the boundary */
+ str->mswindows_multibyte_to_unicode.partial_byte = new_src[n - 1];
+ str->mswindows_multibyte_to_unicode.partial_byte_present = 1;
+ n--;
+ }
+ else
+ str->mswindows_multibyte_to_unicode.partial_byte_present = 0;
+
+ {
+ int nout = WideCharToMultiByte (cp, WC_COMPOSITECHECK, new_src, n, 0, 0);
+ void *outp = Dynarr_atp (dst, Dynarr_length (dst));
+ Dynarr_add_many (dst, 0, nout);
+ WideCharToMultiByte (cp, WC_COMPOSITECHECK, new_src, n / sizeof (WCHAR),
+ (LPSTR) outp, nout, "~", 0);
+ }
+}
+
+/* Convert MS Windows multibyte to Unicode. */
+
+static void
+encode_coding_mswindows_multibyte_to_unicode (struct encoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst,
+ unsigned int n)
+{
+ unsigned_char *new_src = src;
+ int i;
+ int cp = mswindows_current_codepage ();
+
+ if (str->mswindows_multibyte_to_unicode.partial_byte_present)
+ {
+ new_src = alloca_array (src, n + 1);
+ memcpy (new_src + 1, src, n);
+ new_src[0] =
+ (unsigned char) str->mswindows_multibyte_to_unicode.partial_byte;
+ n++;
+ }
+
+ for (i = n - 1; i >= 0; i--)
+ {
+ if (!IsDBCSLeadByteEx (cp, new_src[i]))
+ break;
+ }
+
+ i++;
+
+ for (; i < n; i++)
+ {
+ if (IsDBCSLeadByteEx (cp, new_src[i]))
+ i++;
+ }
+
+ if (i > n)
+ {
+ /* a char is split across the boundary */
+ str->mswindows_multibyte_to_unicode.partial_byte = new_src[n - 1];
+ str->mswindows_multibyte_to_unicode.partial_byte_present = 1;
+ n--;
+ }
+ else
+ str->mswindows_multibyte_to_unicode.partial_byte_present = 0;
+
+ {
+ int nout = MultiByteToWideChar (cp, 0, new_src, n, 0, 0);
+ void *outp = Dynarr_atp (dst, Dynarr_length (dst));
+ Dynarr_add_many (dst, 0, nout * sizeof (WCHAR));
+ MultiByteToWideChar (cp, 0, new_src, n, (LPWSTR) outp, nout);
+ }
+}
+
+
+static int
+detect_coding_mswindows_multibyte (struct detection_state *st,
+ const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
+/* Convert Mswindows_Multibyte data to internal format. */
+
+static void
+decode_coding_mswindows_multibyte (struct decoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ /* should never be called; is preprocessed away in
+ canonicalize_coding_system() */
+ abort ();
+}
+
+/* Convert internally-formatted data to Mswindows_Multibyte. */
+
+static void
+encode_coding_mswindows_multibyte (struct encoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ /* should never be called; is preprocessed away in
+ canonicalize_coding_system() */
+ abort ();
+}
+
+#endif /* HAVE_WIN32 */
+
+
+/************************************************************************/
+/* Chain methods */
+/************************************************************************/
+
+
+static int
+detect_coding_chain (struct detection_state *st,
+ const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
+/* Convert Chain data to internal format. */
+
+static void
+decode_coding_chain (struct decoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ if (!str->chain.initted)
+ {
+ int i;
+ Lisp_Object lstream_out;
+ int chains = CODING_SYSTEM_CHAIN_COUNT (str->codesys);
+
+ str->chain.lstream_count = chains + 1;
+ str->chain.lstreams = xnew_array (Lisp_Object, str->chain.lstream_count);
+
+ lstream_out = make_dynarr_output_stream (dst);
+ Lstream_set_buffering (XLSTREAM (lstream_out), LSTREAM_UNBUFFERED);
+ str->chain.lstreams[str->chain.lstream_count - 1] = lstream_out;
+
+ for (i = chains - 1; i >= 0; i--)
+ {
+ str->chain.lstreams[i] =
+ make_encoding_output_stream
+ (XLSTREAM (lstream_out),
+ /* note the array index below; it's backwards, the only thing
+ different from the code in encode_coding_chain */
+ CODING_SYSTEM_CHAIN_CHAIN (str->codesys)[chains - (i + 1)]);
+ lstream_out = str->chain.lstreams[i];
+ Lstream_set_buffering (XLSTREAM (lstream_out), LSTREAM_UNBUFFERED);
+ }
+ str->chain.initted = 1;
+ }
+
+ Lstream_write (XLSTREAM (str->chain.lstreams[0]), src, n);
+}
+
+/* Convert internally-formatted data to Chain. */
+
+static void
+encode_coding_chain (struct encoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n)
+{
+ if (!str->chain.initted)
+ {
+ int i;
+ Lisp_Object lstream_out;
+ int chains = CODING_SYSTEM_CHAIN_COUNT (str->codesys);
+
+ str->chain.lstream_count = chains + 1;
+ str->chain.lstreams = xnew_array (Lisp_Object, str->chain.lstream_count);
+
+ lstream_out = make_dynarr_output_stream (dst);
+ Lstream_set_buffering (XLSTREAM (lstream_out), LSTREAM_UNBUFFERED);
+ str->chain.lstreams[str->chain.lstream_count - 1] = lstream_out;
+
+ for (i = chains - 1; i >= 0; i--)
+ {
+ str->chain.lstreams[i] =
+ make_encoding_output_stream
+ (XLSTREAM (lstream_out),
+ CODING_SYSTEM_CHAIN_CHAIN (str->codesys)[i]);
+ lstream_out = str->chain.lstreams[i];
+ Lstream_set_buffering (XLSTREAM (lstream_out), LSTREAM_UNBUFFERED);
+ }
+ str->chain.initted = 1;
+ }
+
+ Lstream_write (XLSTREAM (str->chain.lstreams[0]), src, n);
+}
+
+static void
+chain_closer_1 (Lisp_Object **lstreams, int lstream_count)
+{
+ int i;
+
+ if (*lstreams)
+ {
+ for (i = 0; i < lstream_count; i++)
+ Lstream_delete ((*lstreams)[i]);
+ }
+
+ xfree (*lstreams);
+ *lstreams = 0;
+}
+
+static void
+chain_encoding_closer (struct encoding_stream *str)
+{
+ chain_closer_1 (&str->chain.lstreams, str->chain.lstream_count);
+}
+
+static void
+chain_decoding_closer (struct encoding_stream *str)
+{
+ chain_closer_1 (&str->chain.lstreams, str->chain.lstream_count);
+}
+
/************************************************************************/
/* No-conversion methods */
/************************************************************************/
+static int
+detect_coding_no_conversion (struct detection_state *st,
+ const unsigned char *src,
+ unsigned int n)
+{
+ return 0;
+}
+
/* This is used when reading in "binary" files -- i.e. files that may
contain all 256 possible byte values and that are not to be
interpreted as being in any particular decoding. */
static void
-decode_coding_no_conversion (Lstream *decoding, const unsigned char *src,
+decode_coding_no_conversion (struct decoding_stream *str,
+ const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct decoding_stream *str = DECODING_STREAM_DATA (decoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = str->eol_type;
@@ -5503,11 +6184,11 @@
}
static void
-encode_coding_no_conversion (Lstream *encoding, const unsigned char *src,
+encode_coding_no_conversion (struct encoding_stream *str,
+ const unsigned char *src,
unsigned_char_dynarr *dst, unsigned int n)
{
unsigned char c;
- struct encoding_stream *str = ENCODING_STREAM_DATA (encoding);
unsigned int flags = str->flags;
unsigned int ch = str->ch;
eol_type_t eol_type = CODING_SYSTEM_EOL_TYPE (str->codesys);
@@ -5567,8 +6248,7 @@
{
INIT_LRECORD_IMPLEMENTATION (coding_system);
- deferror (&Qcoding_system_error, "coding-system-error",
- "Coding-system error", Qio_error);
+ DEFERROR_STANDARD (Qcoding_system_error, Qio_error);
DEFSUBR (Fcoding_system_p);
DEFSUBR (Ffind_coding_system);
@@ -5609,17 +6289,29 @@
DEFSUBR (Fset_char_ucs);
DEFSUBR (Fchar_ucs);
#endif /* MULE */
+#ifdef HAVE_WIN32
+ DEFSUBR (Fset_mswindows_code_page_mapping);
+ DEFSUBR (Fmswindows_code_page_mapping);
+#endif /* HAVE_WIN32 */
defsymbol (&Qcoding_systemp, "coding-system-p");
defsymbol (&Qno_conversion, "no-conversion");
defsymbol (&Qraw_text, "raw-text");
#ifdef MULE
defsymbol (&Qbig5, "big5");
defsymbol (&Qshift_jis, "shift-jis");
- defsymbol (&Qucs4, "ucs-4");
- defsymbol (&Qutf8, "utf-8");
+ defsymbol (&Qucs4, "ucs4");
+ defsymbol (&Qutf16, "utf16");
+ defsymbol (&Qutf8, "utf8");
defsymbol (&Qccl, "ccl");
defsymbol (&Qiso2022, "iso2022");
#endif /* MULE */
+#ifdef HAVE_WIN32
+ defsymbol (&Qmswindows_tstr, "mswindows-tstr");
+ defsymbol (&Qmswindows_multibyte, "mswindows-multibyte");
+ defsymbol (&Qmswindows_unicode, "mswindows-unicode");
+#endif
+ defsymbol (&Qchain, "chain");
+
defsymbol (&Qmnemonic, "mnemonic");
defsymbol (&Qeol_type, "eol-type");
defsymbol (&Qpost_read_conversion, "post-read-conversion");
@@ -5644,6 +6336,8 @@
defsymbol (&Qinput_charset_conversion, "input-charset-conversion");
defsymbol (&Qoutput_charset_conversion, "output-charset-conversion");
+ defsymbol (&Qinternal, "internal");
+
defsymbol (&Qshort, "short");
defsymbol (&Qno_ascii_eol, "no-ascii-eol");
defsymbol (&Qno_ascii_cntl, "no-ascii-cntl");
@@ -5659,6 +6353,10 @@
"shift-jis");
defsymbol (&coding_category_symbol[CODING_CATEGORY_BIG5],
"big5");
+ defsymbol (&coding_category_symbol[CODING_CATEGORY_UTF16],
+ "utf-16");
+ defsymbol (&coding_category_symbol[CODING_CATEGORY_UTF16_BYTE_REVERSED],
+ "utf-16-byte-reversed");
defsymbol (&coding_category_symbol[CODING_CATEGORY_UCS4],
"ucs-4");
defsymbol (&coding_category_symbol[CODING_CATEGORY_UTF8],
@@ -5754,11 +6452,7 @@
Vfile_name_coding_system = Qnil;
DEFVAR_BOOL ("enable-multibyte-characters", &enable_multibyte_characters
/*
-Non-nil means the buffer contents are regarded as multi-byte form
-of characters, not a binary code. This affects the display, file I/O,
-and behaviors of various editing commands.
-
-Setting this to nil does not do anything.
+Setting this has no effect. It is purely for FSF compatibility.
*/ );
enable_multibyte_characters = 1;
}
@@ -5822,6 +6516,33 @@
list4 (Qeol_type, Qlf,
Qmnemonic, build_string ("Binary")));
+#ifdef HAVE_WIN32
+
+ Vmswindows_code_page_table =
+ make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
+
+ staticpro (&Vmswindows_code_page_table);
+
+ Fmake_coding_system
+ (Qmswindows_tstr, Qno_conversion,
+ build_string ("MS Windows tstr: Converts to the proper encoding for Windows API
calls."),
+ list2 (Qmnemonic, build_string ("MSW-Tstr")));
+
+ Fmake_coding_system
+ (Qmswindows_multibyte, Qmswindows_multibyte,
+ build_string ("MS Windows multibyte: Converts to the multibyte encoding for
Windows API calls."),
+ list2 (Qmnemonic, build_string ("MSW-Multibyte")));
+
+ Fmake_coding_system
+ (Qmswindows_unicode, Qchain,
+ build_string ("MS Windows unicode: Converts to the Unicode encoding for Windows
API calls."),
+ list4 (Qmnemonic, build_string ("MSW-Unicode"),
+ Qlist, list2 (Qmswindows_multibyte,
+ Qmswindows_multibyte_to_unicode));
+
+#endif /* HAVE_WIN32 */
+
+
Fdefine_coding_system_alias (Qno_conversion, Qraw_text);
Fdefine_coding_system_alias (Qfile_name, Qbinary);
@@ -5841,6 +6562,19 @@
fcd->ucs_to_mule_table[i] = Qnil;
}
staticpro (&mule_to_ucs_table);
- mule_to_ucs_table = Fmake_char_table(Qgeneric);
+ mule_to_ucs_table = Fmake_char_table (Qgeneric);
#endif /* MULE */
+
+ reinit_file_coding ();
+}
+
+void
+reinit_file_coding (void)
+{
+#ifdef HAVE_WIN32
+ if (mswindows_windows9x_p)
+ Fdefine_coding_system_alias (Qmswindows_tstr, Qmswindows_multibyte);
+ else
+ Fdefine_coding_system_alias (Qmswindows_tstr, Qmswindows_unicode);
+#endif
}
Index: src/file-coding.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/file-coding.h,v
retrieving revision 1.5.2.10
diff -u -r1.5.2.10 file-coding.h
--- file-coding.h 2000/02/07 07:59:45 1.5.2.10
+++ file-coding.h 2000/04/30 09:05:22
@@ -30,30 +30,136 @@
struct decoding_stream;
struct encoding_stream;
+extern const struct struct_description coding_system_methods_description;
+
+struct coding_system_methods
+{
+ const char *name;
+ Lisp_Object predicate_symbol;
+
+ /* Implementation specific methods: */
+
+ /* Create method: Initialize coding_system data. Optional. */
+ void (*create_method) (Lisp_Object coding_system);
+
+ /* Mark method: Mark any lisp object within coding_system data
+ structure. Not required if no coding_system data are Lisp_Objects. */
+ void (*mark_method) (Lisp_Object coding_system);
+
+ /* Equal method: Compare two coding_systems. This is called after
+ ensuring that the two coding_systems are of the same type, and have
+ the same specs. Quit is inhibited during the call so it is safe
+ to call internal_equal().
+
+ If this function is not present, coding_systems considered equal when
+ the above conditions are met, i.e. as if the method returned
+ non-zero. */
+ int (*equal_method) (Lisp_Object sp1, Lisp_Object sp2, int depth);
+
+ /* Hash method: Hash coding_system instance data. This has to hash only
+ data structure of the coding_system, as specs are hashed by the core
+ code.
+
+ If this function is not present, hashing behaves as if it
+ returned zero. */
+ unsigned long (*hash_method) (Lisp_Object coding_system, int depth);
+
+ void (*detect_method) (struct detection_state *st,
+ const unsigned char *src,
+ unsigned int n);
+
+ void (*encode_method) (struct encoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n);
+
+ void (*decode_method) (struct decoding_stream *str,
+ const unsigned char *src,
+ unsigned_char_dynarr *dst, unsigned int n);
+
+
+ /* Copy method: Given an instantiator, copy the bits that we need to
+ for this coding_system type.
+
+ If this function is not present, then Fcopy_tree is used. */
+ Lisp_Object (*copy_instantiator_method) (Lisp_Object instantiator);
+
+ /* Validate-matchspec method: Given a matchspec, verify that it's
+ valid for this coding_system type. If not, signal an error.
+
+ If this function is not present, *no* matchspecs are considered
+ valid. Note that this differs from validate_method(). */
+ void (*validate_matchspec_method) (Lisp_Object matchspec);
+
+ /* Instantiate method: Return CODING_SYSTEM instance in DOMAIN,
+ specified by INSTANTIATOR. MATCHSPEC specifies an additional
+ constraints on the instance value (see the docstring for
+ Fcoding_system_matching_instance function). MATCHSPEC is passed
+ Qunbound when no matching constraints are imposed. The method is
+ called via call_with_suspended_errors(), so allowed to eval
+ safely.
+
+ DEPTH is a lisp integer denoting current depth of instantiation
+ calls. This parameter should be passed as the initial depth value
+ to functions which also instantiate coding_systems (of which I can
+ name coding_system_instance) to avoid creating "external"
+ specification loops.
+
+ This method must presume that both INSTANTIATOR and MATCSPEC are
+ already validated by the corresponding validate_* methods, and
+ may abort if they are invalid.
+
+ Return value is an instance, which is returned immediately to the
+ caller, or Qunbound to continue instantiation lookup chain.
+
+ If this function is not present, INSTANTIATOR is used as the
+ coding_system instance. This is the usual case for "simple"
+ coding_systems, like integer and boolean. */
+ Lisp_Object (*instantiate_method) (Lisp_Object coding_system,
+ Lisp_Object matchspec,
+ Lisp_Object domain,
+ Lisp_Object instantiator,
+ Lisp_Object depth);
+
+ /* Going-to-add method: Called when an instantiator is about
+ to be added to a coding_system. This function can specify
+ that different instantiators should be used instead by
+ returning an inst-list (possibly containing zero elements).
+ If the instantiator is fine as-is, return Qt. The
+ instantiator has been copied with copy-tree, so feel
+ free to reuse parts of it to create a new instantiator.
+ The tag-set, however, is not copied and is not canonicalized
+ (that will be done on the result of this function). */
+ Lisp_Object (*going_to_add_method) (Lisp_Object coding_system,
+ Lisp_Object locale,
+ Lisp_Object tag_set,
+ Lisp_Object instantiator);
+
+ /* After-change method: Called when the CODING_SYSTEM has just been
+ changed in LOCALE. The method is called upon:
+ * Removing and adding specs to/from the coding_system;
+ * Changing the coding_system fallback.
+
+ #### The method may have called more than once per each coding_system
+ change.
+
+ #### Do not still know if this can safely eval. */
+ void (*after_change_method) (Lisp_Object coding_system,
+ Lisp_Object locale);
+
+ const struct lrecord_description *extra_description;
+ int extra_data_size;
+};
+
/* Coding system types. These go into the TYPE field of a
Lisp_Coding_System. */
enum coding_system_type
{
CODESYS_AUTODETECT, /* Automatic conversion. */
-#ifdef MULE
- CODESYS_SHIFT_JIS, /* Shift-JIS; Hankaku (half-width) KANA
- is also supported. */
- CODESYS_ISO2022, /* Any ISO2022-compliant coding system.
- Includes JIS, EUC, CTEXT */
- CODESYS_BIG5, /* BIG5 (used for Taiwanese). */
- CODESYS_UCS4, /* ISO 10646 UCS-4 */
- CODESYS_UTF8, /* ISO 10646 UTF-8 */
- CODESYS_CCL, /* Converter written in CCL. */
-#endif
- CODESYS_NO_CONVERSION /* "No conversion"; used for binary files.
- We use quotes because there really
- is some conversion being applied,
- but it appears to the user as if
- the text is read in without conversion. */
-#ifdef DEBUG_XEMACS
- ,CODESYS_INTERNAL /* Raw (internally-formatted) data. */
-#endif
+#define SLOT(slot) \
+ CODESYS_##slot,
+#include "coding-slots.h"
+#undef SLOT
};
enum eol_type
@@ -82,6 +188,7 @@
struct Lisp_Coding_System
{
struct lcrecord_header header;
+ struct coding_system_methods *methods;
/* Name and doc string of this coding system. */
Lisp_Object name;
@@ -106,6 +213,7 @@
Lisp_Object eol_lf;
Lisp_Object eol_crlf;
Lisp_Object eol_cr;
+
#ifdef MULE
struct
{
@@ -138,6 +246,18 @@
Lisp_Object encode;
} ccl;
#endif
+
+ struct
+ {
+ /* List of coding systems, in encode order */
+ Lisp_Object *chain;
+ int count;
+ } chain;
+
+ /* type-specific extra data attached to a coding_system */
+ char data[1];
+
+
};
typedef struct Lisp_Coding_System Lisp_Coding_System;
@@ -148,6 +268,127 @@
#define CHECK_CODING_SYSTEM(x) CHECK_RECORD (x, coding_system)
#define CONCHECK_CODING_SYSTEM(x) CONCHECK_RECORD (x, coding_system)
+/***** Calling a coding_system method *****/
+
+#define RAW_CODESYSMETH(cs, m) ((cs)->methods->m##_method)
+#define HAS_CODESYSMETH_P(cs, m) (!!RAW_CODESYSMETH (cs, m))
+#define CODESYSMETH(cs, m, args) (((cs)->methods->m##_method) args)
+
+/* Call a void-returning coding_system method, if it exists. */
+#define MAYBE_CODESYSMETH(cs, m, args) do { \
+ Lisp_Coding_System *maybe_codesysmeth_cs = (cs); \
+ if (HAS_CODESYSMETH_P (maybe_codesysmeth_cs, m)) \
+ CODESYSMETH (maybe_codesysmeth_cs, m, args); \
+} while (0)
+
+/***** Defining new coding_system types *****/
+
+#define coding_system_data_offset (offsetof (Lisp_Coding_System, data))
+extern const struct lrecord_description coding_system_empty_extra_description[];
+
+#ifdef ERROR_CHECK_TYPECHECK
+#define DECLARE_CODING_SYSTEM_TYPE(type) \
+extern struct coding_system_methods * type##_coding_system_methods; \
+INLINE_HEADER struct type##_coding_system * \
+error_check_##type##_coding_system_data (Lisp_Coding_System *cs); \
+INLINE_HEADER struct type##_coding_system * \
+error_check_##type##_coding_system_data (Lisp_Coding_System *cs) \
+{ \
+ assert (CODING_SYSTEM_TYPE_P (cs, type)); \
+ return (struct type##_coding_system *) cs->data; \
+} \
+INLINE_HEADER Lisp_Coding_System * \
+error_check_##type##_coding_system_type (Lisp_Object obj); \
+INLINE_HEADER Lisp_Coding_System * \
+error_check_##type##_coding_system_type (Lisp_Object obj) \
+{ \
+ Lisp_Coding_System *cs = XCODING_SYSTEM (obj); \
+ assert (CODING_SYSTEM_TYPE_P (cs, type)); \
+ return cs; \
+} \
+DECLARE_NOTHING
+#else
+#define DECLARE_CODING_SYSTEM_TYPE(type) \
+extern struct coding_system_methods * type##_coding_system_methods
+#endif /* ERROR_CHECK_TYPECHECK */
+
+#define DEFINE_CODING_SYSTEM_TYPE(type) \
+struct coding_system_methods * type##_coding_system_methods
+
+#define INITIALIZE_CODING_SYSTEM_TYPE(type, obj_name, pred_sym) do { \
+ type##_coding_system_methods = \
+ xnew_and_zero (struct coding_system_methods); \
+ type##_coding_system_methods->name = obj_name; \
+ type##_coding_system_methods->extra_description = \
+ coding_system_empty_extra_description; \
+ defsymbol_nodump (&type##_coding_system_methods->predicate_symbol, \
+ pred_sym); \
+ add_entry_to_coding_system_type_list (Q##type, \
+ type##_coding_system_methods); \
+ dumpstruct (&type##_coding_system_methods, \
+ &coding_system_methods_description); \
+} while (0)
+
+#define REINITIALIZE_CODING_SYSTEM_TYPE(type) do { \
+ staticpro_nodump (&type##_coding_system_methods->predicate_symbol); \
+} while (0)
+
+#define INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA(type, obj_name, pred_sym) \
+do { \
+ INITIALIZE_CODING_SYSTEM_TYPE (type, obj_name, pred_sym); \
+ type##_coding_system_methods->extra_data_size = \
+ sizeof (struct type##_coding_system); \
+ type##_coding_system_methods->extra_description = \
+ type##_coding_system_description; \
+} while (0)
+
+/* Declare that coding_system-type TYPE has method METH; used in
+ initialization routines */
+#define CODING_SYSTEM_HAS_METHOD(type, meth) \
+ (type##_coding_system_methods->meth##_method = type##_##meth)
+
+/***** Macros for accessing coding_system types *****/
+
+#define CODING_SYSTEM_TYPE_P(cs, type) \
+ ((cs)->methods == type##_coding_system_methods)
+
+#ifdef ERROR_CHECK_TYPECHECK
+# define CODING_SYSTEM_TYPE_DATA(cs, type) \
+ error_check_##type##_coding_system_data (cs)
+#else
+# define CODING_SYSTEM_TYPE_DATA(cs, type) \
+ ((struct type##_coding_system *) \
+ (cs)->data)
+#endif
+
+#ifdef ERROR_CHECK_TYPECHECK
+# define XCODING_SYSTEM_TYPE(x, type) \
+ error_check_##type##_coding_system_type (x)
+# define XSETCODING_SYSTEM_TYPE(x, p, type) do \
+{ \
+ XSETCODING_SYSTEM (x, p); \
+ assert (CODING_SYSTEM_TYPEP (XCODING_SYSTEM(x), type)); \
+} while (0)
+#else
+# define XCODING_SYSTEM_TYPE(x, type) XCODING_SYSTEM (x)
+# define XSETCODING_SYSTEM_TYPE(x, p, type) XSETCODING_SYSTEM (x, p)
+#endif /* ERROR_CHECK_TYPE_CHECK */
+
+#define CODING_SYSTEM_TYPEP(x, type) \
+ (CODING_SYSTEMP (x) && CODING_SYSTEM_TYPE_P (XCODING_SYSTEM (x), type))
+#define CHECK_CODING_SYSTEM_TYPE(x, type) do { \
+ CHECK_CODING_SYSTEM (x); \
+ if (!CODING_SYSTEM_TYPE_P (XCODING_SYSTEM (x), type)) \
+ dead_wrong_type_argument \
+ (type##_coding_system_methods->predicate_symbol, x); \
+} while (0)
+#define CONCHECK_CODING_SYSTEM_TYPE(x, type) do { \
+ CONCHECK_CODING_SYSTEM (x); \
+ if (!(CODING_SYSTEM_TYPEP (x, type))) \
+ x = wrong_type_argument \
+ (type##_coding_system_methods->predicate_symbol, x); \
+} while (0)
+
#define CODING_SYSTEM_NAME(codesys) ((codesys)->name)
#define CODING_SYSTEM_DOC_STRING(codesys) ((codesys)->doc_string)
#define CODING_SYSTEM_TYPE(codesys) ((codesys)->type)
@@ -182,6 +423,9 @@
#define CODING_SYSTEM_CCL_ENCODE(codesys) ((codesys)->ccl.encode)
#endif /* MULE */
+#define CODING_SYSTEM_CHAIN_CHAIN(codesys) ((codesys)->chain.chain)
+#define CODING_SYSTEM_CHAIN_COUNT(codesys) ((codesys)->chain.count)
+
#define XCODING_SYSTEM_NAME(codesys) \
CODING_SYSTEM_NAME (XCODING_SYSTEM (codesys))
#define XCODING_SYSTEM_DOC_STRING(codesys) \
@@ -228,6 +472,11 @@
CODING_SYSTEM_CCL_ENCODE (XCODING_SYSTEM (codesys))
#endif /* MULE */
+#define XCODING_SYSTEM_CHAIN_CHAIN(codesys) \
+ CODING_SYSTEM_CHAIN_CHAIN (XCODING_SYSTEM (codesys))
+#define XCODING_SYSTEM_CHAIN_COUNT(codesys) \
+ CODING_SYSTEM_CHAIN_COUNT (XCODING_SYSTEM (codesys))
+
EXFUN (Fcoding_category_list, 0);
EXFUN (Fcoding_category_system, 1);
EXFUN (Fcoding_priority_list, 0);
@@ -253,23 +502,27 @@
EXFUN (Fset_coding_priority_list, 1);
EXFUN (Fsubsidiary_coding_system, 2);
-extern Lisp_Object Qucs4, Qutf8;
-extern Lisp_Object Qbig5, Qccl, Qcharset_g0;
+extern Lisp_Object Qcharset_g0;
extern Lisp_Object Qcharset_g1, Qcharset_g2, Qcharset_g3, Qcoding_system_error;
extern Lisp_Object Qcoding_systemp, Qcr, Qcrlf, Qdecode, Qencode;
extern Lisp_Object Qeol_cr, Qeol_crlf, Qeol_lf, Qeol_type, Qescape_quoted;
extern Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output;
extern Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output;
-extern Lisp_Object Qinput_charset_conversion, Qiso2022, Qlf, Qlock_shift;
-extern Lisp_Object Qmnemonic, Qno_ascii_cntl, Qno_ascii_eol, Qno_conversion;
+extern Lisp_Object Qinput_charset_conversion, Qlf, Qlock_shift;
+extern Lisp_Object Qmnemonic, Qno_ascii_cntl, Qno_ascii_eol;
extern Lisp_Object Qraw_text;
extern Lisp_Object Qno_iso6429, Qoutput_charset_conversion;
extern Lisp_Object Qpost_read_conversion, Qpre_write_conversion, Qseven;
-extern Lisp_Object Qshift_jis, Qshort, Vcoding_system_for_read;
+extern Lisp_Object Qshort, Vcoding_system_for_read;
extern Lisp_Object Vcoding_system_for_write, Vcoding_system_hash_table;
extern Lisp_Object Vfile_name_coding_system, Vkeyboard_coding_system;
extern Lisp_Object Vterminal_coding_system;
+#define SLOT(slot) \
+extern Lisp_Object Q##slot;
+#include "coding-slots.h"
+#undef SLOT
+
/* Flags indicating current state while converting code. */
/* Used by everyone. */
@@ -426,6 +679,8 @@
two-dimension characters in the upper half. */
CODING_CATEGORY_ISO_LOCK_SHIFT, /* ISO2022 system using locking shift */
CODING_CATEGORY_BIG5,
+ CODING_CATEGORY_UTF16,
+ CODING_CATEGORY_UTF16_BYTE_REVERSED,
CODING_CATEGORY_UCS4,
CODING_CATEGORY_UTF8,
#endif /* MULE */
@@ -449,6 +704,10 @@
(1 << CODING_CATEGORY_ISO_LOCK_SHIFT)
#define CODING_CATEGORY_BIG5_MASK \
(1 << CODING_CATEGORY_BIG5)
+#define CODING_CATEGORY_UTF16_MASK \
+ (1 << CODING_CATEGORY_UTF16)
+#define CODING_CATEGORY_UTF16_BYTE_REVERSED_MASK \
+ (1 << CODING_CATEGORY_UTF16_BYTE_REVERSED)
#define CODING_CATEGORY_UCS4_MASK \
(1 << CODING_CATEGORY_UCS4)
#define CODING_CATEGORY_UTF8_MASK \
@@ -463,7 +722,7 @@
/* Convert shift-JIS code (sj1, sj2) into internal string
representation (c1, c2). (The leading byte is assumed.) */
-#define DECODE_SJIS(sj1, sj2, c1, c2) \
+#define DECODE_SHIFT_JIS(sj1, sj2, c1, c2) \
do { \
int I1 = sj1, I2 = sj2; \
if (I2 >= 0x9f) \
@@ -478,7 +737,7 @@
(c1, c2) into Shift-JIS code (sj1, sj2). The leading byte is
assumed. */
-#define ENCODE_SJIS(c1, c2, sj1, sj2) \
+#define ENCODE_SHIFT_JIS(c1, c2, sj1, sj2) \
do { \
int I1 = c1, I2 = c2; \
if (I1 & 1) \
@@ -504,7 +763,8 @@
Lisp_Object codesys);
void set_encoding_stream_coding_system (Lstream *stream,
Lisp_Object codesys);
-void determine_real_coding_system (Lstream *stream, Lisp_Object *codesys_in_out,
+void determine_real_coding_system (Lstream *stream,
+ Lisp_Object *codesys_in_out,
eol_type_t *eol_type_in_out);
Index: src/fns.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/fns.c,v
retrieving revision 1.30.2.38
diff -u -r1.30.2.38 fns.c
--- fns.c 2000/04/07 10:36:16 1.30.2.38
+++ fns.c 2000/04/30 09:05:23
@@ -301,25 +301,16 @@
DEFUN ("string-lessp", Fstring_lessp, 2, 2, 0, /*
Return t if first arg string is less than second in lexicographic order.
-If I18N2 support (but not Mule support) was compiled in, ordering is
-determined by the locale. (Case is significant for the default C locale.)
-In all other cases, comparison is simply done on a character-by-
-character basis using the numeric value of a character. (Note that
-this may not produce particularly meaningful results under Mule if
-characters from different charsets are being compared.)
+Comparison is simply done on a character-by- character basis using the
+numeric value of a character. (Note that this may not produce
+particularly meaningful results under Mule if characters from
+different charsets are being compared.)
Symbols are also allowed; their print names are used instead.
-The reason that the I18N2 locale-specific collation is not used under
-Mule is that the locale model of internationalization does not handle
-multiple charsets and thus has no hope of working properly under Mule.
-What we really should do is create a collation table over all built-in
-charsets. This is extremely difficult to do from scratch, however.
-
-Unicode is a good first step towards solving this problem. In fact,
-it is quite likely that a collation table exists (or will exist) for
-Unicode. When Unicode support is added to XEmacs/Mule, this problem
-may be solved.
+Currently we don't do proper language-specific collation or handle
+multiple character sets. This may be changed when Unicode support
+is implemented.
*/
(s1, s2))
{
@@ -348,29 +339,7 @@
if (end > len2)
end = len2;
-#if defined (I18N2) && !defined (MULE)
- /* There is no hope of this working under Mule. Even if we converted
- the data into an external format so that strcoll() processed it
- properly, it would still not work because strcoll() does not
- handle multiple locales. This is the fundamental flaw in the
- locale model. */
{
- Bytecount bcend = charcount_to_bytecount (string_data (p1), end);
- /* Compare strings using collation order of locale. */
- /* Need to be tricky to handle embedded nulls. */
-
- for (i = 0; i < bcend; i += strlen((char *) string_data (p1) + i) + 1)
- {
- int val = strcoll ((char *) string_data (p1) + i,
- (char *) string_data (p2) + i);
- if (val < 0)
- return Qt;
- if (val > 0)
- return Qnil;
- }
- }
-#else /* not I18N2, or MULE */
- {
Bufbyte *ptr1 = string_data (p1);
Bufbyte *ptr2 = string_data (p2);
@@ -389,7 +358,6 @@
INC_CHARPTR (ptr2);
}
}
-#endif /* not I18N2, or MULE */
/* Can't do i < len2 because then comparison between "foo" and
"foo^@"
won't work right in I18N2 case */
return end < len2 ? Qt : Qnil;
Index: src/frame-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/frame-msw.c,v
retrieving revision 1.29.2.19
diff -u -r1.29.2.19 frame-msw.c
--- frame-msw.c 2000/03/16 11:21:51 1.29.2.19
+++ frame-msw.c 2000/04/30 09:05:23
@@ -183,13 +183,20 @@
XSETFRAME (frame_obj, f);
Vmswindows_frame_being_created = frame_obj;
+ {
+ Extbyte *nameext = 0;
+ if (STRINGP (f->name))
+ TO_EXTERNAL_FORMAT (LISP_STRING, f->name,
+ C_STRING_ALLOCA, nameext,
+ Qmswindows_tstr);
+ else if (STRINGP (name))
+ TO_EXTERNAL_FORMAT (LISP_STRING, name,
+ C_STRING_ALLOCA, nameext,
+ Qmswindows_tstr);
hwnd = CreateWindowEx (exstyle,
XEMACS_CLASS,
- STRINGP(f->name) ? XSTRING_DATA(f->name) :
- (STRINGP(name) ?
- (const Extbyte*)XSTRING_DATA(name) :
- (const Extbyte*)XEMACS_CLASS),
+ nameext ? nameext : XEMACS_CLASS),
style,
rect_default.left, rect_default.top,
rect_default.width, rect_default.height,
@@ -483,10 +490,15 @@
mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
{
unsigned int new_checksum = hash_string (title, strlen (title));
- if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f))
+ if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM (f))
{
- FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum;
- SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
+ Extbyte *title_ext;
+
+ FRAME_MSWINDOWS_TITLE_CHECKSUM (f) = new_checksum;
+ TO_EXTERNAL_FORMAT (C_STRING, title,
+ C_STRING_ALLOCA, title_ext,
+ Qmswindows_tstr);
+ SetWindowText (FRAME_MSWINDOWS_HANDLE (f), title);
}
}
@@ -882,9 +894,17 @@
/* Start print job */
di.cbSize = sizeof (di);
- di.lpszDocName = (STRINGP(f->name)
- ? (char*) XSTRING_DATA(f->name)
- : "XEmacs print document");
+ {
+ Extbyte *nameext;
+
+ if (STRINGP (f->name))
+ TO_EXTERNAL_FORMAT (LISP_STRING, f->name,
+ C_STRING_ALLOCA, nameext,
+ Qmswindows_tstr);
+ else
+ nameext = EITEXT ("XEmacs print document");
+ di.lpszDocName = nameext;
+ }
di.lpszOutput = NULL;
di.lpszDatatype = NULL;
di.fwType = 0;
Index: src/general.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/general.c,v
retrieving revision 1.13.2.11
diff -u -r1.13.2.11 general.c
--- general.c 2000/04/14 16:15:39 1.13.2.11
+++ general.c 2000/04/30 09:05:23
@@ -97,7 +97,7 @@
Lisp_Object Qinfo;
Lisp_Object Qinherit;
Lisp_Object Qinteger;
-Lisp_Object Qinternal;
+/* Lisp_Object Qinternal; in file-coding.c */
Lisp_Object Qkey;
Lisp_Object Qkey_assoc;
Lisp_Object Qkeyboard;
@@ -253,7 +253,7 @@
defsymbol (&Qinfo, "info");
defsymbol (&Qinherit, "inherit");
defsymbol (&Qinteger, "integer");
- defsymbol (&Qinternal, "internal");
+ /* defsymbol (&Qinternal, "internal"); in file-coding.c */
defsymbol (&Qkey, "key");
defsymbol (&Qkey_assoc, "key-assoc");
defsymbol (&Qkeyboard, "keyboard");
Index: src/glyphs-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-msw.c,v
retrieving revision 1.21.2.55
diff -u -r1.21.2.55 glyphs-msw.c
--- glyphs-msw.c 2000/04/13 02:37:08 1.21.2.55
+++ glyphs-msw.c 2000/04/30 09:05:24
@@ -687,7 +687,7 @@
}
#if 0 /* Currently unused */
-/* #### Warining: This function is not correct anymore with
+/* #### Warning: This function is not correct anymore with
resizable printer bitmaps. If you uncomment it, clean it. --kkm */
int
mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii,
@@ -722,7 +722,7 @@
struct color_symbol
{
- char* name;
+ Bufbyte * name;
COLORREF color;
};
@@ -779,10 +779,7 @@
colortbl[j].color =
COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
- TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons),
- C_STRING_ALLOCA, colortbl[j].name,
- Qnative);
- colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we
return */
+ colortbl[j].name = xstrdup (XSTRING_DATA (XCAR (cons))); /* mustn't lose this
when we return */
free_cons (XCONS (cons));
cons = results;
results = XCDR (results);
@@ -1225,11 +1222,7 @@
}
do {
- Extbyte* nm=0;
- TO_EXTERNAL_FORMAT (LISP_STRING, name,
- C_STRING_ALLOCA, nm,
- Qnative);
- if (!strcasecmp ((char*)res->name, nm))
+ if (!strcasecmp ((char*)res->name, XSTRING_DATA (name)))
return res->resource_id;
} while ((++res)->name);
return 0;
@@ -1260,7 +1253,7 @@
HINSTANCE hinst = NULL;
ICONINFO iconinfo;
enum image_instance_type iitype;
- char* fname=0;
+ LPCTSTR fname=0;
Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
@@ -1286,18 +1279,15 @@
/* mess with the keyword info we were provided with */
if (!NILP (file))
{
- Extbyte* f=0;
- TO_EXTERNAL_FORMAT (LISP_STRING, file,
- C_STRING_ALLOCA, f,
- Qfile_name);
-#ifdef __CYGWIN32__
- CYGWIN_WIN32_PATH (f, fname);
-#else
- fname = f;
-#endif
+ Bufbyte *f;
+ Bytecount flen;
+ unfuck_cygwin_path (file, f, flen);
+ TO_EXTERNAL_FORMAT (DATA, (f, flen),
+ C_STRING_ALLOCA, fname,
+ Qmswindows_tstr);
if (NILP (resource_id))
- resid = (LPCTSTR)fname;
+ resid = fname;
else
{
hinst = LoadLibraryEx (fname, NULL,
@@ -1308,7 +1298,7 @@
if (!resid)
TO_EXTERNAL_FORMAT (LISP_STRING, resource_id,
C_STRING_ALLOCA, resid,
- Qnative);
+ Qmswindows_tstr);
}
}
else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
@@ -2233,10 +2223,10 @@
/* Possibly update the text in the widget. */
if (IMAGE_INSTANCE_TEXT_CHANGED (p))
{
- Extbyte* lparam=0;
+ LPTSTR lparam=0;
TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p),
C_STRING_ALLOCA, lparam,
- Qnative);
+ Qmswindows_tstr);
SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
WM_SETTEXT, 0, (LPARAM)lparam);
}
@@ -2302,8 +2292,8 @@
signal_simple_error ("window creation failed with code",
make_int (GetLastError()));
- wnd = CreateWindow( "STATIC",
- "",
+ wnd = CreateWindow( TEXT ("STATIC"),
+ TEXT (""),
WS_CHILD,
0, /* starting x position */
0, /* starting y position */
@@ -2390,13 +2380,13 @@
mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
Lisp_Object pointer_fg, Lisp_Object pointer_bg,
int dest_mask, Lisp_Object domain,
- const char* class, int flags, int exflags)
+ LPCTSTR class, int flags, int exflags)
{
/* this function can call lisp */
Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
Lisp_Object frame = FW_FRAME (domain);
- Extbyte* nm=0;
+ LPTSTR nm=0;
HWND wnd;
int id = 0xffff;
Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
@@ -2417,7 +2407,7 @@
if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii),
C_STRING_ALLOCA, nm,
- Qnative);
+ Qmswindows_tstr);
/* allocate space for the clip window and then allocate the clip window */
ii->data = xnew_and_zero (struct mswindows_subwindow_data);
@@ -2518,7 +2508,8 @@
}
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
- pointer_bg, dest_mask, domain, "BUTTON",
+ pointer_bg, dest_mask, domain,
+ TEXT ("BUTTON"),
flags, 0);
wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
@@ -2564,7 +2555,7 @@
int dest_mask, Lisp_Object domain)
{
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
- pointer_bg, dest_mask, domain, "EDIT",
+ pointer_bg, dest_mask, domain, TEXT ("EDIT"),
ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
| WS_BORDER, WS_EX_CLIENTEDGE);
}
@@ -2619,14 +2610,14 @@
tvitem.item.mask |= TVIF_PARAM;
TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
C_STRING_ALLOCA, tvitem.item.pszText,
- Qnative);
+ Qmswindows_tstr);
}
else
TO_EXTERNAL_FORMAT (LISP_STRING, item,
C_STRING_ALLOCA, tvitem.item.pszText,
- Qnative);
+ Qmswindows_tstr);
- tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
+ tvitem.item.cchTextMax = _tcslen (tvitem.item.pszText);
if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
0, (LPARAM)&tvitem)) == 0)
@@ -2701,17 +2692,17 @@
tvitem.mask |= TCIF_PARAM;
TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
C_STRING_ALLOCA, tvitem.pszText,
- Qnative);
+ Qmswindows_tstr);
}
else
{
CHECK_STRING (item);
TO_EXTERNAL_FORMAT (LISP_STRING, item,
C_STRING_ALLOCA, tvitem.pszText,
- Qnative);
+ Qmswindows_tstr);
}
- tvitem.cchTextMax = strlen (tvitem.pszText);
+ tvitem.cchTextMax = _tcslen (tvitem.pszText);
if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM,
i, (LPARAM)&tvitem)) < 0)
@@ -2794,7 +2785,8 @@
int dest_mask, Lisp_Object domain)
{
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
- pointer_bg, dest_mask, domain, "STATIC",
+ pointer_bg, dest_mask, domain,
+ TEXT ("STATIC"),
0, WS_EX_STATICEDGE);
}
@@ -2805,7 +2797,8 @@
int dest_mask, Lisp_Object domain)
{
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
- pointer_bg, dest_mask, domain, "SCROLLBAR",
+ pointer_bg, dest_mask, domain,
+ TEXT ("SCROLLBAR"),
WS_TABSTOP, WS_EX_CLIENTEDGE);
}
@@ -2840,7 +2833,8 @@
/* Now create the widget. */
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
- pointer_bg, dest_mask, domain, "COMBOBOX",
+ pointer_bg, dest_mask, domain,
+ TEXT ("COMBOBOX"),
WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
| CBS_AUTOHSCROLL
| CBS_HASSTRINGS | WS_VSCROLL,
@@ -2856,10 +2850,10 @@
SendMessage (wnd, CB_RESETCONTENT, 0, 0);
LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
{
- Extbyte* lparam;
+ LPTSTR lparam;
TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest),
C_STRING_ALLOCA, lparam,
- Qnative);
+ Qmswindows_tstr);
if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
signal_simple_error ("error adding combo entries", instantiator);
}
@@ -2874,11 +2868,11 @@
/* get the text from a control */
if (EQ (prop, Q_text))
{
- Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
- Extbyte *buf = (Extbyte*) alloca (len+1);
+ int tchar_len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
+ LPTSTR buf = (LPTSTR) alloca_array (TCHAR, tchar_len+1);
- SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf);
- return build_ext_string (buf, Qnative);
+ SendMessage (wnd, WM_GETTEXT, (WPARAM)tchar_len+1, (LPARAM) buf);
+ return build_ext_string (buf, Qmswindows_tstr);
}
return Qunbound;
}
@@ -2910,10 +2904,10 @@
if (EQ (prop, Q_text))
{
long item = SendMessage (wnd, CB_GETCURSEL, 0, 0);
- Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
- Extbyte* buf = (Extbyte*) alloca (len+1);
- SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf);
- return build_ext_string (buf, Qnative);
+ int tchar_len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
+ LPTSTR buf = (LPTSTR) alloca_array (TCHAR, tchar_len+1);
+ SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM) buf);
+ return build_ext_string (buf, Qmswindows_tstr);
}
return Qunbound;
}
Index: src/gui-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/Attic/gui-msw.c,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 gui-msw.c
--- gui-msw.c 2000/04/14 16:15:41 1.1.2.10
+++ gui-msw.c 2000/04/30 09:05:25
@@ -95,9 +95,10 @@
{
/* Encode filename and current directory. */
Lisp_Object current_dir = Ffile_name_directory (document);
- char* path = NULL;
- char* doc = NULL;
- Extbyte* f=0;
+ Extbyte *path = NULL;
+ Extbyte *doc = NULL;
+ Bufbyte *f;
+ Bytecount flen;
int ret;
struct gcpro gcpro1, gcpro2;
@@ -108,40 +109,38 @@
GCPRO2 (current_dir, document);
- /* Use mule and cygwin-safe APIs top get at file data. */
+ /* Use mule and cygwin-safe APIs to get at file data. */
if (STRINGP (current_dir))
{
- TO_EXTERNAL_FORMAT (LISP_STRING, current_dir,
- C_STRING_ALLOCA, f,
- Qfile_name);
-#ifdef __CYGWIN32__
- CYGWIN_WIN32_PATH (f, path);
-#else
- path = f;
-#endif
+ unfuck_cygwin_path (current_dir, f, flen);
+ TO_EXTERNAL_FORMAT (DATA, (f, flen),
+ C_STRING_ALLOCA, path,
+ Qmswindows_tstr);
}
if (STRINGP (document))
{
- TO_EXTERNAL_FORMAT (LISP_STRING, document,
- C_STRING_ALLOCA, f,
- Qfile_name);
-#ifdef __CYGWIN32__
- CYGWIN_WIN32_PATH (f, doc);
-#else
- doc = f;
-#endif
+ unfuck_cygwin_path (document, f, flen);
+ TO_EXTERNAL_FORMAT (DATA, (f, flen),
+ C_STRING_ALLOCA, doc,
+ Qmswindows_tstr);
}
UNGCPRO;
- ret = (int) ShellExecute (NULL,
- (STRINGP (operation) ?
- XSTRING_DATA (operation) : NULL),
- doc,
- (STRINGP (parameters) ?
- XSTRING_DATA (parameters) : NULL),
- path,
+ {
+ Extbyte *opext = 0, *parmext = 0;
+
+ if (STRINGP (operation))
+ TO_EXTERNAL_FORMAT (LISP_STRING, operation,
+ C_STRING_ALLOCA, opext,
+ Qmswindows_tstr);
+ if (STRINGP (parameters))
+ TO_EXTERNAL_FORMAT (LISP_STRING, parameters,
+ C_STRING_ALLOCA, parmext,
+ Qmswindows_tstr);
+
+ ret = (int) ShellExecute (NULL, opext, doc, parmext, path,
(INTP (show_flag) ?
XINT (show_flag) : SW_SHOWDEFAULT));
Index: src/gui.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/gui.c,v
retrieving revision 1.10.2.27
diff -u -r1.10.2.27 gui.c
--- gui.c 2000/04/14 16:15:41 1.10.2.27
+++ gui.c 2000/04/30 09:05:26
@@ -1,6 +1,6 @@
/* Generic GUI code. (menubars, scrollbars, toolbars, dialogs)
Copyright (C) 1995 Board of Trustees, University of Illinois.
- Copyright (C) 1995, 1996 Ben Wing.
+ Copyright (C) 1995, 1996, 2000 Ben Wing.
Copyright (C) 1995 Sun Microsystems, Inc.
Copyright (C) 1998 Free Software Foundation, Inc.
@@ -332,14 +332,12 @@
if (*name == '_' && *(name + 1))
{
Emchar accelerator = charptr_emchar (name + 1);
- /* #### bogus current_buffer dependency */
- return make_char (DOWNCASE (current_buffer, accelerator));
+ return make_char (DOWNCASE (0, accelerator));
}
}
INC_CHARPTR (name);
}
- return make_char (DOWNCASE (current_buffer,
- charptr_emchar (XSTRING_DATA (nm))));
+ return make_char (DOWNCASE (0, charptr_emchar (XSTRING_DATA (nm))));
}
/*
@@ -380,41 +378,19 @@
return 1;
}
-static DOESNT_RETURN
-signal_too_long_error (Lisp_Object name)
-{
- signal_simple_error ("GUI item produces too long displayable string", name);
-}
-
-#ifdef HAVE_WINDOW_SYSTEM
/*
- * Format "left flush" display portion of an item into BUF, guarded by
- * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating
- * null character, so actual maximum size of buffer consumed is
- * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
- * signaled.
- * Return value is the offset to the terminating null character into the
- * buffer.
+ * Format "left flush" display portion of an item.
*/
-unsigned int
-gui_item_display_flush_left (Lisp_Object gui_item,
- char *buf, Bytecount buf_len)
+Lisp_Object
+gui_item_display_flush_left (Lisp_Object gui_item)
{
/* This function can call lisp */
- char *p = buf;
- Bytecount len;
Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
+ Lisp_Object retval;
- /* Copy item name first */
CHECK_STRING (pgui_item->name);
- len = XSTRING_LENGTH (pgui_item->name);
- if (len > buf_len)
- signal_too_long_error (pgui_item->name);
- memcpy (p, XSTRING_DATA (pgui_item->name), len);
- p += len;
+ retval = pgui_item->name;
- /* Add space and suffix, if there is a suffix.
- * If suffix is not string evaluate it */
if (!NILP (pgui_item->suffix))
{
Lisp_Object suffix = pgui_item->suffix;
@@ -425,29 +401,17 @@
CHECK_STRING (suffix);
}
- len = XSTRING_LENGTH (suffix);
- if (p + len + 1 > buf + buf_len)
- signal_too_long_error (pgui_item->name);
- *(p++) = ' ';
- memcpy (p, XSTRING_DATA (suffix), len);
- p += len;
+ retval = concat3 (pgui_item->name, build_string (" "), suffix);
}
- *p = '\0';
- return p - buf;
+
+ return retval;
}
/*
- * Format "right flush" display portion of an item into BUF, guarded by
- * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating
- * null character, so actual maximum size of buffer consumed is
- * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
- * signaled.
- * Return value is the offset to the terminating null character into the
- * buffer.
+ * Format "right flush" display portion of an item into BUF.
*/
-unsigned int
-gui_item_display_flush_right (Lisp_Object gui_item,
- char *buf, Bytecount buf_len)
+Lisp_Object
+gui_item_display_flush_right (Lisp_Object gui_item)
{
Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
*buf = 0;
@@ -455,18 +419,14 @@
#ifdef HAVE_MENUBARS
/* Have keys? */
if (!menubar_show_keybindings)
- return 0;
+ return Qnil;
#endif
/* Try :keys first */
if (!NILP (pgui_item->keys))
{
CHECK_STRING (pgui_item->keys);
- if (XSTRING_LENGTH (pgui_item->keys) + 1 > buf_len)
- signal_too_long_error (pgui_item->name);
- memcpy (buf, XSTRING_DATA (pgui_item->keys),
- XSTRING_LENGTH (pgui_item->keys) + 1);
- return XSTRING_LENGTH (pgui_item->keys);
+ return pgui_item->keys;
}
/* See if we can derive keys out of callback symbol */
@@ -476,17 +436,12 @@
Bytecount len;
where_is_to_char (pgui_item->callback, buf2);
- len = strlen (buf2);
- if (len > buf_len)
- signal_too_long_error (pgui_item->name);
- strcpy (buf, buf2);
- return len;
+ return build_string (buf2);
}
/* No keys - no right flush display */
- return 0;
+ return Qnil;
}
-#endif /* HAVE_WINDOW_SYSTEM */
static Lisp_Object
mark_gui_item (Lisp_Object obj)
Index: src/gui.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/gui.h,v
retrieving revision 1.6.2.15
diff -u -r1.6.2.15 gui.h
--- gui.h 2000/04/14 16:15:42 1.6.2.15
+++ gui.h 2000/04/30 09:05:26
@@ -79,11 +79,8 @@
Lisp_Object gui_item_accelerator (Lisp_Object gui_item);
Lisp_Object gui_name_accelerator (Lisp_Object name);
int gui_item_id_hash (Lisp_Object, Lisp_Object gui_item, int);
-unsigned int gui_item_display_flush_left (Lisp_Object pgui_item,
- char* buf, Bytecount buf_len);
-unsigned int gui_item_display_flush_right (Lisp_Object gui_item,
- char* buf, Bytecount buf_len);
-
+Lisp_Object gui_item_display_flush_left (Lisp_Object gui_item);
+Lisp_Object gui_item_display_flush_right (Lisp_Object gui_item);
Lisp_Object allocate_gui_item (void);
void gui_item_init (Lisp_Object gui_item);
Lisp_Object parse_gui_item_tree_children (Lisp_Object list);
Index: src/intl.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/intl.c,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 intl.c
--- intl.c 2000/02/16 02:06:40 1.4.2.4
+++ intl.c 2000/04/30 09:05:26
@@ -36,137 +36,38 @@
#endif
#endif
-#ifdef I18N4
-#include <X11/Xlib.h>
-
-unsigned long input_method_event_mask;
-Atom wc_atom;
-
-/* init_input -- Set things up for i18n level 4 input.
-*/
-void
-init_input (const char *res_name, const char *res_class, Display *display)
-{
- XIMStyles *styles;
- unsigned short i;
-
- input_method = 0;
- input_method_style = 0;
- initial_input_context = 0;
- input_method_event_mask = 0;
-
- input_method = XOpenIM (display, NULL,
- (char *) res_name, (char *) res_class);
-
- if (!input_method)
- {
- stderr_out ("WARNING: XOpenIM() failed...no input server\n");
- return;
- }
-
- /* Query input method for supported input styles and pick one.
- Right now, we choose a style which supports root-window preediting. */
- XGetIMValues (input_method, XNQueryInputStyle, &styles, NULL);
- for (i = 0; i < styles->count_styles; i++)
- {
- if (styles->supported_styles[i] == (XIMPreeditNothing|XIMStatusNothing))
- {
- input_method_style= styles->supported_styles[i];
- break;
- }
- }
-
- if (!input_method_style)
- {
- stderr_out ("WARNING: Could not find suitable input style.\n");
- return;
- }
-
- initial_input_context = XCreateIC (input_method,
- XNInputStyle, input_method_style,
- NULL);
- if (!initial_input_context)
- {
- stderr_out ("WARNING: Could not create input context.\n");
- return;
- }
-
- XGetICValues (initial_input_context,
- XNFilterEvents, &input_method_event_mask,
- NULL);
-
- /* Get a new atom for wide character client messages. */
- wc_atom = XInternAtom (display, "Wide Character Event", False);
-}
-
-
-/*static widechar_string composed_input_buf = EMPTY_WIDECHAR_STRING;*/
+Lisp_Object Qdefer_gettext;
-#define XIM_Composed_Text_BUFSIZE 64
-typedef struct XIM_Composed_Text {
- int size;
- wchar_t data [XIM_Composed_Text_BUFSIZE];
-} XIM_Composed_Text;
-static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
-/*static wcidechar composed_input_buf [64] = {0};*/
-Window main_window; /* Convenient way to refer to main Era window. */
-
-/* x_get_composed_input -- Process results of input method composition.
-
- This function copies the results of the input method composition to
- composed_input_buf. Then for each character, a custom event of type
- wc_atom is sent with the character as its data.
-
- It is probably more efficient to copy the composition results to some
- allocated memory and send a single event pointing to that memory.
- That would cut down on the event processing as well as allow quick
- insertion into the buffer of the whole string. It might require some
- care, though, to avoid fragmenting memory through the allocation and
- freeing of many small chunks. Maybe the existing system for
- (single-byte) string allocation can be used, multiplying the length by
- sizeof (wchar_t) to get the right size.
-*/
-void
-x_get_composed_input (XKeyPressedEvent *x_key_event, XIC context,
- Display *display)
-{
- KeySym keysym;
- Status status;
- int len;
- int i;
- XClientMessageEvent new_event;
-
- retry:
- len = XwcLookupString (context, x_key_event, composed_input_buf.data,
- composed_input_buf.size, &keysym, &status);
- switch (status)
- {
- case XBufferOverflow:
- /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
- goto retry;
- case XLookupChars:
- break;
- default:
- abort ();
- }
-
- new_event.type = ClientMessage;
- new_event.display = x_key_event->display;
- new_event.window = x_key_event->window;
- new_event.message_type = wc_atom;
- new_event.format = 32; /* 32-bit wide data */
- new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
- new_event.data.l[0] = x_key_event->time;
- for (i = 0; i < len; i++) {
- new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
- XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
- }
+DEFUN ("set-current-locale", Fset_current_locale, 1, 1, 0, /*
+Set the user's current locale.
+Takes a string, the value passed to setlocale().
+This is of the form LANG_COUNTRY.ENCODING, or LANG_COUNTRY, or LANG,
+or .ENCODING. Unfortunately, the meanings of these three values are
+system-dependent, and there is no universal agreement. This function
+is meant to be called only from `set-language-environment', which
+keeps tables to figure out the values to use for particular systems.
+
+If the empty string is passed in, the current full locale of the form
+LANG_COUNTRY.ENCODING is returned.
+
+Returns nil if the call failed (typically, an invalid locale was given).
+Otherwise, returns a full locale of the form LANG_COUNTRY.ENCODING.
+
+*/
+ (locale))
+{
+ Extbyte *loc;
+ Bufbyte *locint;
+
+ CHECK_STRING (locale);
+ TO_EXTERNAL_FORMAT (LISP_STRING, locale, C_STRING_ALLOCA, loc, Qbinary);
+ loc = setlocale (loc);
+ if (!loc)
+ return Qnil;
+ TO_INTERNAL_FORMAT (C_STRING, loc, C_STRING_ALLOCA, locint, Qbinary);
+ return build_string (locint);
}
-#endif /* I18N4 */
-
-Lisp_Object Qdefer_gettext;
-
DEFUN ("ignore-defer-gettext", Fignore_defer_gettext, 1, 1, 0, /*
If OBJ is of the form (defer-gettext "string"), return the string.
The purpose of the defer-gettext symbol is to identify strings which
@@ -286,7 +187,7 @@
void
init_intl_very_early (void)
{
-#if defined (I18N2) || defined (I18N3) || defined (I18N4)
+#if defined (I18N3)
setlocale (LC_ALL, "");
setlocale(LC_NUMERIC, "C");
#endif
@@ -314,9 +215,6 @@
void
vars_of_intl (void)
{
-#ifdef I18N2
- Fprovide (intern ("i18n2"));
-#endif
#ifdef I18N3
Fprovide (intern ("i18n3"));
#endif
Index: src/keymap.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/keymap.c,v
retrieving revision 1.27.2.18
diff -u -r1.27.2.18 keymap.c
--- keymap.c 2000/04/02 12:38:38 1.27.2.18
+++ keymap.c 2000/04/30 09:05:27
@@ -2858,11 +2858,7 @@
{
char *s1 = (char *) string_data (XSYMBOL (obj1)->name);
char *s2 = (char *) string_data (XSYMBOL (obj2)->name);
-#ifdef I18N2
- return 0 > strcoll (s1, s2) ? 1 : -1;
-#else
return 0 > strcmp (s1, s2) ? 1 : -1;
-#endif
}
}
Index: src/lisp.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/lisp.h,v
retrieving revision 1.38.2.56
diff -u -r1.38.2.56 lisp.h
--- lisp.h 2000/04/14 16:15:42 1.38.2.56
+++ lisp.h 2000/04/30 09:05:28
@@ -42,6 +42,10 @@
#include <stddef.h> /* offsetof */
#include <sys/types.h>
+#define DECLARE_INLINE_HEADER (decl) \
+INLINE_HEADER decl; \
+INLINE_HEADER decl
+
/* ---- Dynamic arrays ---- */
#define Dynarr_declare(type) \
Index: src/lrecord.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/lrecord.h,v
retrieving revision 1.8.2.28
diff -u -r1.8.2.28 lrecord.h
--- lrecord.h 2000/04/14 07:54:42 1.8.2.28
+++ lrecord.h 2000/04/30 09:05:28
@@ -288,7 +288,7 @@
A lrecord external description is an array of values. The first
value of each line is a type, the second the offset in the lrecord
structure. Following values are parameters, their presence, type
- and number is type-dependant.
+ and number is type-dependent.
The description ends with a "XD_END" or "XD_SPECIFIER_END"
record.
Index: src/lstream.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/lstream.c,v
retrieving revision 1.12.2.14
diff -u -r1.12.2.14 lstream.c
--- lstream.c 2000/02/21 23:07:03 1.12.2.14
+++ lstream.c 2000/04/30 09:05:29
@@ -95,17 +95,17 @@
void Lstream_fungetc (Lstream *stream, int c)
Function equivalents of the above macros.
-ssize_t Lstream_read (Lstream *stream, void *data, size_t size)
+long Lstream_read (Lstream *stream, void *data, long size)
Read SIZE bytes of DATA from the stream. Return the number of
bytes read. 0 means EOF. -1 means an error occurred and no
bytes were read.
-ssize_t Lstream_write (Lstream *stream, void *data, size_t size)
+long Lstream_write (Lstream *stream, void *data, long size)
Write SIZE bytes of DATA to the stream. Return the number of
bytes written. -1 means an error occurred and no bytes were
written.
-void Lstream_unread (Lstream *stream, void *data, size_t size)
+void Lstream_unread (Lstream *stream, void *data, long size)
Push back SIZE bytes of DATA onto the input queue. The
next call to Lstream_read() with the same size will read the
same bytes back. Note that this will be the case even if
@@ -179,7 +179,7 @@
}
}
-static size_t
+static long
sizeof_lstream (const void *header)
{
const Lstream *lstr = (const Lstream *) header;
@@ -297,16 +297,18 @@
lstr->flags |= LSTREAM_FL_IS_OPEN;
}
-/* Attempt to flush out all of the buffered data for writing. */
+/* Try to write as much of DATA as possible to the stream. Return the
+ number of bytes written. */
-int
-Lstream_flush_out (Lstream *lstr)
+static int
+Lstream_really_write (Lstream *lstr, unsigned char *data, int size)
{
- ssize_t num_written;
+ long num_written;
+ unsigned char *orig_data = data;
+ int error_occurred = 0;
- while (lstr->out_buffer_ind > 0)
+ while (size > 0)
{
- size_t size = lstr->out_buffer_ind;
if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
Lstream_internal_error ("lstream not open", lstr);
if (! (lstr->flags & LSTREAM_FL_WRITE))
@@ -319,7 +321,6 @@
character at the end. We need to spit back that
incomplete character. */
{
- const unsigned char *data = lstr->out_buffer;
const unsigned char *dataend = data + size - 1;
assert (size > 0); /* safety check ... */
/* Optimize the most common case. */
@@ -340,30 +341,58 @@
}
}
- num_written = (lstr->imp->writer) (lstr, lstr->out_buffer, size);
+ num_written = (lstr->imp->writer) (lstr, data, size);
if (num_written == 0)
/* If nothing got written, then just hold the data. This may
occur, for example, if this stream does non-blocking I/O;
the attempt to write the data might have resulted in an
EWOULDBLOCK error. */
- return 0;
- else if (num_written >= lstr->out_buffer_ind)
- lstr->out_buffer_ind = 0;
+ break;
+ else if (num_written > size)
+ abort ();
else if (num_written > 0)
{
- memmove (lstr->out_buffer, lstr->out_buffer + num_written,
- lstr->out_buffer_ind - num_written);
- lstr->out_buffer_ind -= num_written;
+ data += num_written;
+ size -= num_written;
}
else
- /* If error, just hold the data, for similar reasons as above. */
- return -1;
+ {
+ /* If error, just hold the data, for similar reasons as above. */
+ error_occurred = 1;
+ break;
+ }
}
if (lstr->imp->flusher)
- return (lstr->imp->flusher) (lstr);
+ error_occurred = (lstr->imp->flusher) (lstr) < 0;
- return 0;
+ if (data == data_orig && error_occurred)
+ return -1;
+
+ return data - data_orig;
+}
+
+/* Attempt to flush out all of the buffered data for writing.
+ Return -1 if nothing written and error occurred, 0 otherwise. */
+
+int
+Lstream_flush_out (Lstream *lstr)
+{
+ long num_written = Lstream_really_write (lstr, lstr->out_buffer,
+ lstr->out_buffer_ind);
+ if (num_written == out_buffer_ind)
+ {
+ lstr->out_buffer_ind = 0;
+ return 0;
+ }
+ else if (num_written > 0)
+ {
+ memmove (lstr->out_buffer, lstr->out_buffer + num_written,
+ lstr->out_buffer_ind - num_written);
+ lstr->out_buffer_ind -= num_written;
+ return 0;
+ }
+ else return num_written;
}
int
@@ -387,12 +416,12 @@
the buffering size. (This is used to deal with the possibility
that the stream writer might refuse to write any bytes now, e.g.
if it's getting EWOULDBLOCK errors. We have to keep stocking them
- up until they can be written, so as to avoid losing data. */
+ up until they can be written, so as to avoid losing data.) */
-static size_t
-Lstream_adding (Lstream *lstr, size_t num, int force)
+static long
+Lstream_adding (Lstream *lstr, long num, int force)
{
- size_t size = num + lstr->out_buffer_ind;
+ long size = num + lstr->out_buffer_ind;
if (size <= lstr->out_buffer_size)
return num;
@@ -414,58 +443,94 @@
/* Like Lstream_write(), but does not handle line-buffering correctly. */
-static ssize_t
-Lstream_write_1 (Lstream *lstr, const void *data, size_t size)
+static long
+Lstream_write_1 (Lstream *lstr, const void *data, long size)
{
const unsigned char *p = (const unsigned char *) data;
- ssize_t off = 0;
+ long off = 0;
if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
Lstream_internal_error ("lstream not open", lstr);
if (! (lstr->flags & LSTREAM_FL_WRITE))
Lstream_internal_error ("lstream not open for writing", lstr);
- {
- int couldnt_write_last_time = 0;
- while (1)
- {
- /* Figure out how much we can add to the buffer */
- size_t chunk = Lstream_adding (lstr, size, 0);
- if (chunk == 0)
- {
- if (couldnt_write_last_time)
- /* Ung, we ran out of space and tried to flush
- the buffer, but it didn't work because the stream
- writer is refusing to accept any data. So we
- just have to squirrel away all the rest of the
- stuff. */
- chunk = Lstream_adding (lstr, size, 1);
- else
- couldnt_write_last_time = 1;
- }
- /* Do it. */
- if (chunk > 0)
- {
- memcpy (lstr->out_buffer + lstr->out_buffer_ind, p + off, chunk);
- lstr->out_buffer_ind += chunk;
- lstr->byte_count += chunk;
- size -= chunk;
- off += chunk;
- }
- /* If the buffer is full and we have more to add, flush it out. */
- if (size > 0)
- {
- if (Lstream_flush_out (lstr) < 0)
- {
- if (off == 0)
- return -1;
- else
- return off;
- }
- }
- else
- break;
- }
- }
+ if (lstr->buffering == LSTREAM_UNBUFFERED)
+ {
+ /* If there is buffered data, it means we ran into blocking
+ errors the previous time and had to buffer our remaining
+ data. Try to write it now. */
+ if (lstr->out_buffer_ind > 0)
+ {
+ if (Lstream_flush_out (lstr) < 0)
+ return -1;
+ }
+
+ /* If not still blocked, try to write the new data */
+ if (lstr->out_buffer_ind == 0)
+ {
+ /* we don't need to loop because Lstream_really_write does that
+ for us. */
+ long num_written = Lstream_really_write (lstr, p, size);
+ if (num_written < 0)
+ return -1;
+ off += num_written;
+ }
+
+ /* squirrel away the rest of the data */
+ if (off < size)
+ {
+ Lstream_adding (lstr, size - off, 1);
+ memcpy (lstr->out_buffer + lstr->out_buffer_ind, p + off,
+ size - off);
+ lstr->out_buffer_ind += size - off;
+ }
+
+ lstr->byte_count += size;
+ return size;
+ }
+ else
+ {
+ int couldnt_write_last_time = 0;
+
+ while (1)
+ {
+ /* Figure out how much we can add to the buffer */
+ long chunk = Lstream_adding (lstr, size, 0);
+ if (chunk == 0)
+ {
+ if (couldnt_write_last_time)
+ /* Ung, we ran out of space and tried to flush
+ the buffer, but it didn't work because the stream
+ writer is refusing to accept any data. So we
+ just have to squirrel away all the rest of the
+ stuff. */
+ chunk = Lstream_adding (lstr, size, 1);
+ else
+ couldnt_write_last_time = 1;
+ }
+ /* Do it. */
+ if (chunk > 0)
+ {
+ memcpy (lstr->out_buffer + lstr->out_buffer_ind, p + off, chunk);
+ lstr->out_buffer_ind += chunk;
+ lstr->byte_count += chunk;
+ size -= chunk;
+ off += chunk;
+ }
+ /* If the buffer is full and we have more to add, flush it out. */
+ if (size > 0)
+ {
+ if (Lstream_flush_out (lstr) < 0)
+ {
+ if (off == 0)
+ return -1;
+ else
+ return off;
+ }
+ }
+ else
+ break;
+ }
+ }
return off;
}
@@ -474,10 +539,10 @@
repeatedly call Lstream_putc(), which knows how to handle
line buffering. Returns number of bytes written. */
-ssize_t
-Lstream_write (Lstream *lstr, const void *data, size_t size)
+long
+Lstream_write (Lstream *lstr, const void *data, long size)
{
- size_t i;
+ long i;
const unsigned char *p = (const unsigned char *) data;
if (size == 0)
@@ -489,7 +554,7 @@
if (Lstream_putc (lstr, p[i]) < 0)
break;
}
- return i == 0 ? -1 : (ssize_t) i;
+ return i == 0 ? -1 : (long) i;
}
int
@@ -499,7 +564,7 @@
}
static int
-Lstream_raw_read (Lstream *lstr, unsigned char *buffer, size_t size)
+Lstream_raw_read (Lstream *lstr, unsigned char *buffer, long size)
{
if (! (lstr->flags & LSTREAM_FL_IS_OPEN))
Lstream_internal_error ("lstream not open", lstr);
@@ -513,16 +578,16 @@
/* Assuming the buffer is empty, fill it up again. */
-static ssize_t
+static long
Lstream_read_more (Lstream *lstr)
{
#if 0
- ssize_t size_needed = max (1, min (MAX_READ_SIZE, lstr->buffering_size));
+ long size_needed = max (1, min (MAX_READ_SIZE, lstr->buffering_size));
#else
/* If someone requested a larger buffer size, so be it! */
- ssize_t size_needed = max (1, lstr->buffering_size);
+ long size_needed = max (1, lstr->buffering_size);
#endif
- ssize_t size_gotten;
+ long size_gotten;
DO_REALLOC (lstr->in_buffer, lstr->in_buffer_size,
size_needed, unsigned char);
@@ -532,12 +597,12 @@
return size_gotten < 0 ? -1 : size_gotten;
}
-ssize_t
-Lstream_read (Lstream *lstr, void *data, size_t size)
+long
+Lstream_read (Lstream *lstr, void *data, long size)
{
unsigned char *p = (unsigned char *) data;
- size_t off = 0;
- size_t chunk;
+ long off = 0;
+ long chunk;
int error_occurred = 0;
if (size == 0)
@@ -556,25 +621,42 @@
while (size > 0)
{
- /* Take whatever we can from the in buffer */
- chunk = min (size, lstr->in_buffer_current - lstr->in_buffer_ind);
- if (chunk > 0)
- {
- memcpy (p + off, lstr->in_buffer + lstr->in_buffer_ind, chunk);
- lstr->in_buffer_ind += chunk;
- lstr->byte_count += chunk;
- size -= chunk;
- off += chunk;
- }
-
- /* If we need some more, try to get some more from the stream's end */
- if (size > 0)
+ /* If unbuffered, then simply read directly into output buffer.
+ No need to copy. */
+ if (lstr->buffering == LSTREAM_UNBUFFERED)
{
- ssize_t retval = Lstream_read_more (lstr);
- if (retval < 0)
+ chunk = Lstream_raw_read (lstr, p + off, size);
+ if (chunk < 0)
error_occurred = 1;
- if (retval <= 0)
+ if (chunk <= 0)
break;
+ lstr->byte_count += chunk;
+ size -= chunk;
+ off += chunk;
+ }
+ else
+ {
+ /* Take whatever we can from the in buffer */
+ chunk = min (size, lstr->in_buffer_current - lstr->in_buffer_ind);
+ if (chunk > 0)
+ {
+ memcpy (p + off, lstr->in_buffer + lstr->in_buffer_ind, chunk);
+ lstr->in_buffer_ind += chunk;
+ lstr->byte_count += chunk;
+ size -= chunk;
+ off += chunk;
+ }
+
+ /* If we need some more, try to get some more from the
+ stream's end */
+ if (size > 0)
+ {
+ long retval = Lstream_read_more (lstr);
+ if (retval < 0)
+ error_occurred = 1;
+ if (retval <= 0)
+ break;
+ }
}
}
@@ -594,7 +676,7 @@
VALIDATE_CHARPTR_BACKWARD (dataend);
if (dataend + REP_BYTES_BY_FIRST_BYTE (*dataend) != p + off)
{
- size_t newoff = dataend - p;
+ long newoff = dataend - p;
/* If not, chop the size down to ignore the last char
and stash it away for next time. */
Lstream_unread (lstr, dataend, off - newoff);
@@ -603,11 +685,11 @@
}
}
- return off == 0 && error_occurred ? -1 : (ssize_t) off;
+ return off == 0 && error_occurred ? -1 : (long) off;
}
void
-Lstream_unread (Lstream *lstr, const void *data, size_t size)
+Lstream_unread (Lstream *lstr, const void *data, long size)
{
const unsigned char *p = (const unsigned char *) data;
@@ -726,7 +808,7 @@
Lstream_fputc (Lstream *lstr, int c)
{
unsigned char ch = (unsigned char) c;
- ssize_t retval = Lstream_write_1 (lstr, &ch, 1);
+ long retval = Lstream_write_1 (lstr, &ch, 1);
if (retval >= 0 && lstr->buffering == LSTREAM_LINE_BUFFERED && ch
== '\n')
return Lstream_flush_out (lstr);
return retval < 0 ? -1 : 0;
@@ -807,21 +889,21 @@
code (it could even be argued that the error might have fixed
itself, so we should do the fread() again. */
-static ssize_t
-stdio_reader (Lstream *stream, unsigned char *data, size_t size)
+static long
+stdio_reader (Lstream *stream, unsigned char *data, long size)
{
struct stdio_stream *str = STDIO_STREAM_DATA (stream);
- size_t val = fread (data, 1, size, str->file);
+ long val = fread (data, 1, size, str->file);
if (!val && ferror (str->file))
return -1;
return val;
}
-static ssize_t
-stdio_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+stdio_writer (Lstream *stream, const unsigned char *data, long size)
{
struct stdio_stream *str = STDIO_STREAM_DATA (stream);
- size_t val = fwrite (data, 1, size, str->file);
+ long val = fwrite (data, 1, size, str->file);
if (!val && ferror (str->file))
return -1;
return val;
@@ -932,13 +1014,13 @@
return make_filedesc_stream_1 (filedesc, offset, count, flags, "w");
}
-static ssize_t
-filedesc_reader (Lstream *stream, unsigned char *data, size_t size)
+static long
+filedesc_reader (Lstream *stream, unsigned char *data, long size)
{
- ssize_t nread;
+ long nread;
struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
if (str->end_pos >= 0)
- size = min (size, (size_t) (str->end_pos - str->current_pos));
+ size = min (size, (long) (str->end_pos - str->current_pos));
nread = str->allow_quit ?
read_allowing_quit (str->fd, data, size) :
read (str->fd, data, size);
@@ -961,11 +1043,11 @@
return 0;
}
-static ssize_t
-filedesc_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+filedesc_writer (Lstream *stream, const unsigned char *data, long size)
{
struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream);
- ssize_t retval;
+ long retval;
int need_newline = 0;
/* This function would be simple if it were not for the blasted
@@ -1019,7 +1101,7 @@
out for EWOULDBLOCK. */
if (str->chars_sans_newline >= str->pty_max_bytes)
{
- ssize_t retval2 = str->allow_quit ?
+ long retval2 = str->allow_quit ?
write_allowing_quit (str->fd, &str->eof_char, 1) :
write (str->fd, &str->eof_char, 1);
@@ -1052,7 +1134,7 @@
if (need_newline)
{
Bufbyte nl = '\n';
- ssize_t retval2 = str->allow_quit ?
+ long retval2 = str->allow_quit ?
write_allowing_quit (str->fd, &nl, 1) :
write (str->fd, &nl, 1);
@@ -1188,8 +1270,8 @@
return obj;
}
-static ssize_t
-lisp_string_reader (Lstream *stream, unsigned char *data, size_t size)
+static long
+lisp_string_reader (Lstream *stream, unsigned char *data, long size)
{
struct lisp_string_stream *str = LISP_STRING_STREAM_DATA (stream);
/* Don't lose if the string shrank past us ... */
@@ -1204,7 +1286,7 @@
if (stream->flags & LSTREAM_FL_NO_PARTIAL_CHARS)
VALIDATE_CHARPTR_BACKWARD (start);
offset = start - strstart;
- size = min (size, (size_t) (str->end - offset));
+ size = min (size, (long) (str->end - offset));
memcpy (data, start, size);
str->offset = offset + size;
return size;
@@ -1247,15 +1329,15 @@
{
const unsigned char *inbuf;
unsigned char *outbuf;
- size_t size;
- size_t offset;
+ long size;
+ long offset;
};
DEFINE_LSTREAM_IMPLEMENTATION ("fixed-buffer", lstream_fixed_buffer,
sizeof (struct fixed_buffer_stream));
Lisp_Object
-make_fixed_buffer_input_stream (const void *buf, size_t size)
+make_fixed_buffer_input_stream (const void *buf, long size)
{
Lisp_Object obj;
Lstream *lstr = Lstream_new (lstream_fixed_buffer, "r");
@@ -1267,7 +1349,7 @@
}
Lisp_Object
-make_fixed_buffer_output_stream (void *buf, size_t size)
+make_fixed_buffer_output_stream (void *buf, long size)
{
Lisp_Object obj;
Lstream *lstr = Lstream_new (lstream_fixed_buffer, "w");
@@ -1278,8 +1360,8 @@
return obj;
}
-static ssize_t
-fixed_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
+static long
+fixed_buffer_reader (Lstream *stream, unsigned char *data, long size)
{
struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
size = min (size, str->size - str->offset);
@@ -1288,8 +1370,8 @@
return size;
}
-static ssize_t
-fixed_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+fixed_buffer_writer (Lstream *stream, const unsigned char *data, long size)
{
struct fixed_buffer_stream *str = FIXED_BUFFER_STREAM_DATA (stream);
if (str->offset == str->size)
@@ -1334,7 +1416,7 @@
struct resizing_buffer_stream
{
unsigned char *buf;
- size_t allocked;
+ long allocked;
int max_stored;
int stored;
};
@@ -1350,8 +1432,8 @@
return obj;
}
-static ssize_t
-resizing_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+resizing_buffer_writer (Lstream *stream, const unsigned char *data, long size)
{
struct resizing_buffer_stream *str = RESIZING_BUFFER_STREAM_DATA (stream);
DO_REALLOC (str->buf, str->allocked, str->stored + size, unsigned char);
@@ -1412,8 +1494,8 @@
return obj;
}
-static ssize_t
-dynarr_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+dynarr_writer (Lstream *stream, const unsigned char *data, long size)
{
struct dynarr_stream *str = DYNARR_STREAM_DATA (stream);
Dynarr_add_many (str->dyn, data, size);
@@ -1536,8 +1618,8 @@
return lstr;
}
-static ssize_t
-lisp_buffer_reader (Lstream *stream, unsigned char *data, size_t size)
+static long
+lisp_buffer_reader (Lstream *stream, unsigned char *data, long size)
{
struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
unsigned char *orig_data = data;
@@ -1561,7 +1643,7 @@
BI_BUF_ZV (buf));
}
- size = min (size, (size_t) (end - start));
+ size = min (size, (long) (end - start));
end = start + size;
/* We cannot return a partial character. */
VALIDATE_BYTIND_BACKWARD (buf, end);
@@ -1594,8 +1676,8 @@
return data - orig_data;
}
-static ssize_t
-lisp_buffer_writer (Lstream *stream, const unsigned char *data, size_t size)
+static long
+lisp_buffer_writer (Lstream *stream, const unsigned char *data, long size)
{
struct lisp_buffer_stream *str = LISP_BUFFER_STREAM_DATA (stream);
Bufpos pos;
Index: src/lstream.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/lstream.h,v
retrieving revision 1.5.2.6
diff -u -r1.5.2.6 lstream.h
--- lstream.h 2000/02/26 11:39:48 1.5.2.6
+++ lstream.h 2000/04/30 09:05:29
@@ -75,7 +75,7 @@
typedef struct lstream_implementation
{
const char *name;
- size_t size; /* Number of additional bytes to be allocated with this
+ long size; /* Number of additional bytes to be allocated with this
stream. Access this data using Lstream_data(). */
/* Read some data from the stream's end and store it into DATA, which
can hold SIZE bytes. Return the number of bytes read. A return
@@ -95,7 +95,7 @@
/* The omniscient mly, blinded by the irresistable thrall of Common
Lisp, thinks that it is bogus that the types and implementations
of input and output streams are the same. */
- ssize_t (*reader) (Lstream *stream, unsigned char *data, size_t size);
+ long (*reader) (Lstream *stream, unsigned char *data, long size);
/* Send some data to the stream's end. Data to be sent is in DATA
and is SIZE bytes. Return the number of bytes sent. This
function can send and return fewer bytes than is passed in; in
@@ -106,7 +106,7 @@
data. (This is useful, e.g., of you're dealing with a
non-blocking file descriptor and are getting EWOULDBLOCK errors.)
This function can be NULL if the stream is input-only. */
- ssize_t (*writer) (Lstream *stream, const unsigned char *data, size_t size);
+ long (*writer) (Lstream *stream, const unsigned char *data, long size);
/* Return non-zero if the last write operation on the stream resulted
in an attempt to block (EWOULDBLOCK). If this method does not
exists, the implementation returns 0 */
@@ -147,26 +147,28 @@
struct lcrecord_header header;
const Lstream_implementation *imp; /* methods for this stream */
Lstream_buffering buffering; /* type of buffering in use */
- size_t buffering_size; /* number of bytes buffered */
+ long buffering_size; /* number of bytes buffered */
unsigned char *in_buffer; /* holds characters read from stream end */
- size_t in_buffer_size; /* allocated size of buffer */
- size_t in_buffer_current; /* number of characters in buffer */
- size_t in_buffer_ind; /* pointer to next character to take from buffer */
+ long in_buffer_size; /* allocated size of buffer */
+ long in_buffer_current; /* number of characters in buffer */
+ long in_buffer_ind; /* pointer to next character to take from buffer */
unsigned char *out_buffer; /* holds characters to write to stream end */
- size_t out_buffer_size; /* allocated size of buffer */
- size_t out_buffer_ind; /* pointer to next buffer spot to write a character */
+ long out_buffer_size; /* allocated size of buffer */
+ long out_buffer_ind; /* pointer to next buffer spot to write a character */
/* The unget buffer is more or less a stack -- things get pushed
onto the end and read back from the end. Lstream_read()
basically reads backwards from the end to get stuff; Lstream_unread()
similarly has to push the data on backwards. */
unsigned char *unget_buffer; /* holds characters pushed back onto input */
- size_t unget_buffer_size; /* allocated size of buffer */
- size_t unget_buffer_ind; /* pointer to next buffer spot to write a character */
+ long unget_buffer_size; /* allocated size of buffer */
+ long unget_buffer_ind; /* pointer to next buffer spot to write a
+ character */
- size_t byte_count;
+ long byte_count; /* total number of bytes read or written by this
+ lstream */
long flags; /* Align pointer for 64 bit machines (kny) */
char data[1];
};
@@ -209,10 +211,10 @@
int Lstream_fputc (Lstream *lstr, int c);
int Lstream_fgetc (Lstream *lstr);
void Lstream_fungetc (Lstream *lstr, int c);
-ssize_t Lstream_read (Lstream *lstr, void *data, size_t size);
-ssize_t Lstream_write (Lstream *lstr, const void *data, size_t size);
+long Lstream_read (Lstream *lstr, void *data, long size);
+long Lstream_write (Lstream *lstr, const void *data, long size);
int Lstream_was_blocked_p (Lstream *lstr);
-void Lstream_unread (Lstream *lstr, const void *data, size_t size);
+void Lstream_unread (Lstream *lstr, const void *data, long size);
int Lstream_rewind (Lstream *lstr);
int Lstream_seekable_p (Lstream *lstr);
int Lstream_close (Lstream *lstr);
@@ -339,8 +341,8 @@
Lisp_Object make_lisp_string_input_stream (Lisp_Object string,
Bytecount offset,
Bytecount len);
-Lisp_Object make_fixed_buffer_input_stream (const void *buf, size_t size);
-Lisp_Object make_fixed_buffer_output_stream (void *buf, size_t size);
+Lisp_Object make_fixed_buffer_input_stream (const void *buf, long size);
+Lisp_Object make_fixed_buffer_output_stream (void *buf, long size);
const unsigned char *fixed_buffer_input_stream_ptr (Lstream *stream);
unsigned char *fixed_buffer_output_stream_ptr (Lstream *stream);
Lisp_Object make_resizing_buffer_output_stream (void);
Index: src/menubar-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/menubar-msw.c,v
retrieving revision 1.16.2.10
diff -u -r1.16.2.10 menubar-msw.c
--- menubar-msw.c 2000/03/13 07:28:01 1.16.2.10
+++ menubar-msw.c 2000/04/30 09:05:29
@@ -117,54 +117,43 @@
#define MENU_ITEM_ID_BITS(x) (((x) & 0x7FFF) | 0x8000)
static HMENU top_level_menu;
-/* Translate (in place) %_ to &, %% to %.
- Return new length, and (through accel) the accelerator character.
- (If there is no accelerator, it will be added on the first character.)
- len = number of bytes (not including zero terminator).
- maxlen = size of buffer.
- We assume and maintain zero-termination. To be absolutely sure
- of not hitting an error, maxlen should be >= 2*len + 3. */
-
-Bytecount
-msw_translate_menu_or_dialog_item (Bufbyte *item, Bytecount len,
- Bytecount maxlen, Emchar *accel,
- Lisp_Object error_name)
+/* Translate %_ to &, %% to %. */
+
+/* #### Mule-ASCII assumption */
+Lisp_Object
+msw_translate_menu_or_dialog_item (Lisp_Object item, Emchar *accel)
{
- Bufbyte *ptr;
+ Bytecount len = XSTRING_LENGTH (item);
+ Bufbyte *it = (Bufbyte *) alloca (2 * len + 42), *ptr = it;
+ memcpy (ptr, XSTRING_DATA (item), len + 1);
*accel = '\0';
/* Escape '&' as '&&' */
- ptr = item;
- while ((ptr = (Bufbyte *) memchr (ptr, '&', len - (ptr - item))) != NULL)
+ while ((ptr = (Bufbyte *) memchr (ptr, '&', len - (ptr - it))) != NULL)
{
- if (len + 2 > maxlen)
- signal_simple_error ("Menu item produces too long displayable string",
- error_name);
- memmove (ptr + 1, ptr, (len - (ptr - item)) + 1);
+ memmove (ptr + 1, ptr, (len - (ptr - it)) + 1);
len++;
ptr += 2;
}
/* Replace XEmacs accelerator '%_' with Windows accelerator '&'
and `%%' with `%'. */
- ptr = item;
- while ((ptr = memchr (ptr, '%', len - (ptr - item))) != NULL)
+ ptr = it;
+ while ((ptr = memchr (ptr, '%', len - (ptr - it))) != NULL)
{
if (*(ptr + 1) == '_')
{
*ptr = '&';
if (!*accel)
- /* #### urk ! We need a reference translation table for
- case changes that aren't buffer-specific. */
- *accel = DOWNCASE (current_buffer, charptr_emchar (ptr + 2));
- memmove (ptr + 1, ptr + 2, len - (ptr - item + 2) + 1);
+ *accel = DOWNCASE (0, charptr_emchar (ptr + 2));
+ memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1);
len--;
}
else if (*(ptr + 1) == '%')
{
- memmove (ptr + 1, ptr + 2, len - (ptr - item + 2) + 1);
+ memmove (ptr + 1, ptr + 2, len - (ptr - it + 2) + 1);
len--;
}
ptr++;
@@ -172,20 +161,15 @@
if (!*accel)
{
- if (len + 2 > maxlen)
- signal_simple_error ("Menu item produces too long displayable string",
- error_name);
- ptr = item;
+ ptr = it;
memmove (ptr + 1, ptr, len + 1);
- /* #### urk ! We need a reference translation table for
- case changes that aren't buffer-specific. */
- *accel = DOWNCASE (current_buffer, charptr_emchar (ptr + 1));
+ *accel = DOWNCASE (0, charptr_emchar (ptr + 1));
*ptr = '&';
len++;
}
- return len;
+ return make_string (it, len);
}
/*
@@ -193,39 +177,24 @@
* "Left Flush\tRight Flush"
*/
-/* #### This is junk. Need correct handling of sizes. Use a Bufbyte_dynarr,
- not a static buffer. */
-static char*
+static Lisp_Object
displayable_menu_item (Lisp_Object gui_item, int bar_p, Emchar *accel)
{
- unsigned int ll;
+ Lisp_Object left, right = Qnil;
- /* We construct the name in a static buffer. That's fine, because
- menu items longer than 128 chars are probably programming errors,
- and better be caught than displayed! */
-
- static char buf[MAX_MENUITEM_LENGTH+2];
-
/* Left flush part of the string */
- ll = gui_item_display_flush_left (gui_item, buf, MAX_MENUITEM_LENGTH);
+ left = gui_item_display_flush_left (gui_item);
- ll = msw_translate_menu_or_dialog_item ((Bufbyte *) buf, ll,
- MAX_MENUITEM_LENGTH, accel,
- XGUI_ITEM (gui_item)->name);
+ left = msw_translate_menu_or_dialog_item (left, accel);
/* Right flush part, unless we're at the top-level where it's not allowed */
if (!bar_p)
- {
- unsigned int lr;
+ right = gui_item_display_flush_right (gui_item);
- assert (MAX_MENUITEM_LENGTH > ll + 1);
- lr = gui_item_display_flush_right (gui_item, buf + ll + 1,
- MAX_MENUITEM_LENGTH - ll - 1);
- if (lr)
- buf [ll] = '\t';
- }
-
- return buf;
+ if (!NILP (right))
+ return concat3 (left, build_string ("\t"), right);
+ else
+ return left;
}
/*
@@ -325,9 +294,14 @@
item_info.fType = MFT_SEPARATOR;
else
{
+ Extbyte *itemext;
+
item_info.fType = MFT_STRING;
item_info.fState = MFS_DISABLED;
- item_info.dwTypeData = XSTRING_DATA (item);
+ TO_EXTERNAL_FORMAT (LISP_STRING, item,
+ C_STRING_ALLOCA, itemext,
+ Qmswindows_tstr);
+ item_info.dwTypeData = itemext;
}
}
else if (CONSP (item))
@@ -338,6 +312,7 @@
Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
struct gcpro gcpro1, gcpro2, gcpro3;
Emchar accel;
+ Extbyte *itemext;
GCPRO3 (gui_item, path, *accel_list);
@@ -361,7 +336,11 @@
submenu = create_empty_popup_menu ();
item_info.fMask |= MIIM_SUBMENU;
- item_info.dwTypeData = displayable_menu_item (gui_item, bar_p, &accel);
+ TO_EXTERNAL_FORMAT (LISP_STRING,
+ displayable_menu_item (gui_item, bar_p, &accel),
+ C_STRING_ALLOCA, itemext,
+ Qmswindows_tstr);
+ item_info.dwTypeData = itemext;
item_info.hSubMenu = submenu;
if (accel && bar_p)
@@ -393,6 +372,7 @@
Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
struct gcpro gcpro1, gcpro2;
Emchar accel;
+ Extbyte *itemext;
GCPRO2 (gui_item, *accel_list);
@@ -427,7 +407,11 @@
item_info.wID = (UINT) XINT (id);
item_info.fType |= MFT_STRING;
- item_info.dwTypeData = displayable_menu_item (gui_item, bar_p, &accel);
+ TO_EXTERNAL_FORMAT (LISP_STRING,
+ displayable_menu_item (gui_item, bar_p, &accel),
+ C_STRING_ALLOCA, itemext,
+ Qmswindows_tstr);
+ item_info.dwTypeData = itemext;
if (accel && bar_p)
*accel_list = Fcons (make_char (accel), *accel_list);
@@ -527,9 +511,15 @@
two separators in X... In Windows this looks ugly, anyways.) */
if (!bar_p && !deep_p && popup_menu_titles && !NILP
(pgui_item->name))
{
+ Extbyte *nameext;
+
CHECK_STRING (pgui_item->name);
+ TO_EXTERNAL_FORMAT (LISP_STRING,
+ pgui_item->name,
+ C_STRING_ALLOCA, nameext,
+ Qmswindows_tstr);
InsertMenu (menu, 0, MF_BYPOSITION | MF_STRING | MF_DISABLED,
- 0, XSTRING_DATA(pgui_item->name));
+ 0, nameext);
InsertMenu (menu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
SetMenuDefaultItem (menu, 0, MF_BYPOSITION);
}
Index: src/minibuf.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/minibuf.c,v
retrieving revision 1.9.2.7
diff -u -r1.9.2.7 minibuf.c
--- minibuf.c 2000/03/13 07:28:02 1.9.2.7
+++ minibuf.c 2000/04/30 09:05:30
@@ -214,8 +214,8 @@
{
while (l)
{
- Emchar c1 = DOWNCASE (current_buffer, charptr_emchar (s1));
- Emchar c2 = DOWNCASE (current_buffer, charptr_emchar (s2));
+ Emchar c1 = DOWNCASE (0, charptr_emchar (s1));
+ Emchar c2 = DOWNCASE (0, charptr_emchar (s2));
if (c1 == c2)
{
Index: src/nt.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/nt.c,v
retrieving revision 1.17.2.15
diff -u -r1.17.2.15 nt.c
--- nt.c 2000/03/12 23:10:42 1.17.2.15
+++ nt.c 2000/04/30 09:05:30
@@ -1,4 +1,5 @@
-/* Utility and Unix shadow routines for XEmacs on Windows NT.
+/* Utility and Unix shadow routines for XEmacs on Windows 9x and NT.
+ NOT USED UNDER CYGWIN.
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
This file is part of XEmacs.
@@ -26,11 +27,11 @@
#include <config.h>
-#undef signal
#define getwd _getwd
#include "lisp.h"
#undef getwd
+#include "buffer.h"
#include "systime.h"
#include "syssignal.h"
#include "sysproc.h"
@@ -65,6 +66,8 @@
static char startup_dir[ MAXPATHLEN ];
+int mswindows_windows9x_p;
+
/* Get the current working directory. */
char *
getwd (char *dir)
@@ -354,6 +357,27 @@
normalize_filename (p, '\\');
}
+Bufbyte *
+fuck_with_dos_filename (Bufbyte *filename, Bytecount len, Bytecount *len_out)
+{
+ Bufbyte *out;
+
+#ifdef __CYGWIN32__
+ out = (Bufbyte *)
+ xmalloc (len = cygwin32_win32_to_posix_path_list_buf_size (filename));
+ len--;
+ cygwin32_win32_to_posix_path_list (filename, out);
+#else
+ out = (Bufbyte *) xmalloc (len + 1);
+ memcpy (out, filename, len + 1);
+ dostounix_filename ((char *) out);
+#endif
+
+ if (len_out)
+ *len_out = len;
+ return out;
+}
+
/* Remove all CR's that are followed by a LF.
(From msdos.c...probably should figure out a way to share it,
although this code isn't going to ever change.) */
@@ -1137,6 +1161,40 @@
return &dir_static;
}
+
+BOOL
+sys_FindNextFile (HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
+{
+ Bufbyte *intname;
+ BOOL ret_val;
+
+ ret_val = FindNextFile (hFindFile, lpFindFileData);
+ if (ret_val)
+ {
+ TO_INTERNAL_FORMAT (C_STRING, lpFindFileData->cFileName,
+ C_STRING_ALLOCA, intname, Qfile_name);
+ strcpy (lpFindFileData->cFileName, intname);
+ }
+ return ret_val;
+}
+
+HANDLE
+sys_CreateFile (LPCTSTR lpFileName,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDistribution,
+ DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile)
+{
+ Bufbyte *extname;
+ TO_EXTERNAL_FORMAT (C_STRING, lpFileName,
+ C_STRING_ALLOCA, extname, Qfile_name);
+ return CreateFile (extname, dwDesiredAccess, dwShareMode,
+ lpSecurityAttributes, dwCreationDistribution,
+ dwFlagsAndAttributes, hTemplateFile);
+}
+#endif /* MULE */
#if 0
/* #### Have to check if all that sad story about '95 is true - kkm */
Index: src/objects-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/objects-msw.c,v
retrieving revision 1.19.2.15
diff -u -r1.19.2.15 objects-msw.c
--- objects-msw.c 2000/02/21 04:33:52 1.19.2.15
+++ objects-msw.c 2000/04/30 09:05:31
@@ -2,7 +2,7 @@
Copyright (C) 1993, 1994 Free Software Foundation, Inc.
Copyright (C) 1995 Board of Trustees, University of Illinois.
Copyright (C) 1995 Tinker Systems.
- Copyright (C) 1995, 1996 Ben Wing.
+ Copyright (C) 1995, 1996, 2000 Ben Wing.
Copyright (C) 1995 Sun Microsystems, Inc.
Copyright (C) 1997 Jonathan Harris.
@@ -31,6 +31,7 @@
Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
*/
+/* This file has been Mule-ized. */
/* TODO: palette handling */
@@ -49,6 +50,8 @@
#include "device.h"
#include "insdel.h"
+#include <tchar.h>
+
#if (defined(__CYGWIN32__) || defined(__MINGW32__)) && \
CYGWIN_VERSION_DLL_MAJOR < 21
#define stricmp strcasecmp
@@ -767,22 +770,42 @@
{"Symbol" , SYMBOL_CHARSET},
{"Shift JIS" , SHIFTJIS_CHARSET}, /* #### Name to be verified */
{"GB2312" , GB2312_CHARSET}, /* #### Name to be verified */
- {"Hanguel" , HANGEUL_CHARSET},
+ {"Hangeul" , HANGEUL_CHARSET},
{"Chinese Big 5" , CHINESEBIG5_CHARSET}, /* #### Name to be verified */
-#if (WINVER >= 0x0400)
- {"Johab" , JOHAB_CHARSET}, /* #### Name to be verified */
- {"Hebrew" , HEBREW_CHARSET}, /* #### Name to be verified */
- {"Arabic" , ARABIC_CHARSET}, /* #### Name to be verified */
- {"Greek" , GREEK_CHARSET},
- {"Turkish" , TURKISH_CHARSET},
- {"Vietnamese" , VIETNAMESE_CHARSET}, /* #### Name to be verified */
- {"Thai" , THAI_CHARSET}, /* #### Name to be verified */
- {"Central European" , EASTEUROPE_CHARSET},
- {"Cyrillic" , RUSSIAN_CHARSET},
- {"Mac" , MAC_CHARSET},
- {"Baltic" , BALTIC_CHARSET},
+#ifdef JOHAB_CHARSET
+ {"Johab" , JOHAB_CHARSET}, /* #### Name to be verified */
+#endif
+#ifdef HEBREW_CHARSET
+ {"Hebrew" , HEBREW_CHARSET}, /* #### Name to be verified */
+#endif
+#ifdef ARABIC_CHARSET
+ {"Arabic" , ARABIC_CHARSET}, /* #### Name to be verified */
+#endif
+#ifdef GREEK_CHARSET
+ {"Greek" , GREEK_CHARSET},
+#endif
+#ifdef TURKISH_CHARSET
+ {"Turkish" , TURKISH_CHARSET},
+#endif
+#ifdef VIETNAMESE_CHARSET
+ {"Vietnamese" , VIETNAMESE_CHARSET}, /* #### Name to be verified */
+#endif
+#ifdef THAI_CHARSET
+ {"Thai" , THAI_CHARSET}, /* #### Name to be verified */
+#endif
+#ifdef EASTEUROPE_CHARSET
+ {"Central European" , EASTEUROPE_CHARSET},
+#endif
+#ifdef RUSSIAN_CHARSET
+ {"Cyrillic" , RUSSIAN_CHARSET},
+#endif
+#ifdef MAC_CHARSET
+ {"Mac" , MAC_CHARSET},
#endif
- {"OEM/DOS" , OEM_CHARSET}
+#ifdef BALTIC_CHARSET
+ {"Baltic" , BALTIC_CHARSET},
+#endif
+ {"OEM/DOS" , OEM_CHARSET}
};
@@ -803,8 +826,11 @@
}
COLORREF
-mswindows_string_to_color(const char *name)
+mswindows_string_to_color(const Bufbyte *the_name)
{
+ /* #### Assumes Mule-internal format is ASCII-compatible */
+ char *name = (char *) the_name;
+
int i;
if (*name == '#')
@@ -908,9 +934,13 @@
* the corresponding field in the other pattern is either identical or blank.
*/
static int
-match_font (char *pattern1, char *pattern2, char *fontname)
+match_font (Bufbyte *the_pattern1, Bufbyte *the_pattern2,
+ Bufbyte *the_fontname)
{
- char *c1=pattern1, *c2=pattern2, *e1=0, *e2=0;
+ /* #### Assumes Mule-internal format is ASCII-compatible */
+ char *fontname = (char *) the_fontname;
+ char *c1 = (char *) the_pattern1, *c2 = (char *) the_pattern2, *e1 = 0,
+ *e2 = 0;
int i;
if (fontname)
@@ -953,6 +983,74 @@
return 1;
}
+#ifdef MULE
+char *
+mswindows_to_x_charset (int fncharset)
+{
+ static char buf[16];
+
+ switch (fncharset)
+ {
+ /* ansi is considered iso8859-1, as most modern ansi fonts are. */
+ case ANSI_CHARSET: return "iso8859-1";
+ case DEFAULT_CHARSET: return "ascii";
+ case SYMBOL_CHARSET: return "ms-symbol";
+ case SHIFTJIS_CHARSET: return "jisx0201.1976 jisx0208.1983";
+ case HANGEUL_CHARSET: return "ksc5601.1987";
+ case GB2312_CHARSET: return "gb2312";
+ case CHINESEBIG5_CHARSET: return "big5";
+ case OEM_CHARSET: return "ms-oem";
+
+ /* More recent versions of Windows (95 and NT4.0) define more
+ character sets. */
+#ifdef EASTEUROPE_CHARSET
+ case EASTEUROPE_CHARSET: return "iso8859-2";
+#endif
+#ifdef TURKISH_CHARSET
+ case TURKISH_CHARSET: return "iso8859-9";
+#endif
+#ifdef BALTIC_CHARSET
+ case BALTIC_CHARSET: return "iso8859-4";
+#endif
+#ifdef RUSSIAN_CHARSET
+ /* W95 with international support but not IE4 often has the
+ KOI8-R codepage but not ISO8859-5. */
+ case RUSSIAN_CHARSET:
+ if (!IsValidCodePage(28595) && IsValidCodePage(20886))
+ return "koi8-r";
+ else
+ return "iso8859-5";
+#endif
+#ifdef ARABIC_CHARSET
+ case ARABIC_CHARSET: return "iso8859-6";
+#endif
+#ifdef GREEK_CHARSET
+ case GREEK_CHARSET: return "iso8859-7";
+#endif
+#ifdef HEBREW_CHARSET
+ case HEBREW_CHARSET: return "iso8859-8";
+#endif
+#ifdef VIETNAMESE_CHARSET
+ case VIETNAMESE_CHARSET: return "VISCII1.1";
+#endif
+#ifdef THAI_CHARSET
+ case THAI_CHARSET: return "tis620";
+#endif
+#ifdef MAC_CHARSET
+ case MAC_CHARSET: return "mac";
+#endif
+#ifdef JOHAB_CHARSET
+ case JOHAB_CHARSET: return "ksc5601.1992";
+#endif
+#ifdef UNICODE_CHARSET
+ case UNICODE_CHARSET: return "iso10646-unicode";
+#endif
+ }
+ /* Encode numerical value of unknown charset. */
+ sprintf (buf, "*-#%u", fncharset);
+ return buf;
+}
+#endif /* MULE */
@@ -971,9 +1069,10 @@
font_enum_callback_2 (ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme,
int FontType, struct font_enum_t *font_enum)
{
- char fontname[MSW_FONTSIZE];
+ Bufbyte fontname[MSW_FONTSIZE];
Lisp_Object fontname_lispstr;
int i;
+ Bufbyte *facename;
/*
* The enumerated font weights are not to be trusted because:
@@ -986,12 +1085,20 @@
* weights unspecified. This means that we have to weed out duplicates of
* those fonts that do get enumerated with different weights.
*/
+
+ TO_INTERNAL_FORMAT (C_STRING, *lpelfe->elfLogFont.lfFaceName,
+ C_STRING_ALLOCA, facename,
+ Qmswindows_tstr);
+ if (charptr_emchar (facename) == '@')
+ /* This is a font for writing vertically. We ignore it. */
+ return 1;
+
if (FontType == 0 /*vector*/ || FontType == TRUETYPE_FONTTYPE)
/* Scalable, so leave pointsize blank */
- sprintf (fontname, "%s::::", lpelfe->elfLogFont.lfFaceName);
+ sprintf (fontname, "%s::::", facename);
else
/* Formula for pointsize->height from LOGFONT docs in Platform SDK */
- sprintf (fontname, "%s::%d::", lpelfe->elfLogFont.lfFaceName,
+ sprintf (fontname, "%s::%d::", facename,
MulDiv (lpntme->ntmTm.tmHeight - lpntme->ntmTm.tmInternalLeading,
72, GetDeviceCaps (font_enum->hdc, LOGPIXELSY)));
@@ -1063,8 +1170,8 @@
assert (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) == NULL);
- if (GetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0),
- sizeof (lf), (void*) &lf) == 0)
+ if (MSWINFUN (GetObject, (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0),
+ sizeof (lf), (void*) &lf)) == 0)
{
hfont = MSWINDOWS_BAD_HFONT;
}
@@ -1108,15 +1215,11 @@
static int
mswindows_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name,
- Lisp_Object device, Error_behavior errb)
+ Lisp_Object device, Error_behavior errb)
{
- const char *extname;
COLORREF color;
- TO_EXTERNAL_FORMAT (LISP_STRING, name,
- C_STRING_ALLOCA, extname,
- Qctext);
- color = mswindows_string_to_color(extname);
+ color = mswindows_string_to_color (XSTRING_DATA (name));
if (color != -1)
{
c->data = xnew (struct mswindows_color_instance_data);
@@ -1161,7 +1264,8 @@
Lisp_Color_Instance *c2,
int depth)
{
- return (COLOR_INSTANCE_MSWINDOWS_COLOR(c1) == COLOR_INSTANCE_MSWINDOWS_COLOR(c2));
+ return (COLOR_INSTANCE_MSWINDOWS_COLOR(c1) ==
+ COLOR_INSTANCE_MSWINDOWS_COLOR(c2));
}
static unsigned long
@@ -1182,12 +1286,7 @@
static int
mswindows_valid_color_name_p (struct device *d, Lisp_Object color)
{
- const char *extname;
-
- TO_EXTERNAL_FORMAT (LISP_STRING, color,
- C_STRING_ALLOCA, extname,
- Qctext);
- return (mswindows_string_to_color(extname)!=-1);
+ return (mswindows_string_to_color (XSTRING_DATA (color)) != -1);
}
@@ -1204,17 +1303,15 @@
Lisp_Object device_font_list, HDC hdc,
Error_behavior errb)
{
- const char *extname;
LOGFONT logfont;
int fields, i;
int pt;
- char fontname[LF_FACESIZE], weight[LF_FACESIZE], *style, points[8];
- char effects[LF_FACESIZE], charset[LF_FACESIZE];
- char *c;
+ Bufbyte fontname[LF_FACESIZE], weight[LF_FACESIZE], *style, points[8];
+ Bufbyte effects[LF_FACESIZE], charset[LF_FACESIZE];
+ Bufbyte *c;
HFONT hfont, hfont2;
TEXTMETRIC metrics;
-
- extname = XSTRING_DATA (name);
+ Bufbyte *namestr = XSTRING_DATA (name);
/*
* mswindows fonts look like:
@@ -1229,7 +1326,7 @@
* Courier New:Bold Italic:10:underline strikeout:western
*/
- fields = sscanf (extname, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s",
+ fields = sscanf (namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s",
fontname, weight, points, effects, charset);
/* This function is implemented in a fairly ad-hoc manner.
@@ -1239,21 +1336,29 @@
* availability of the requested font */
if (fields < 0)
- {
- maybe_signal_simple_error ("Invalid font", name, Qfont, errb);
- return (0);
- }
+ {
+ maybe_signal_simple_error ("Invalid font", name, Qfont, errb);
+ return (0);
+ }
if (fields>0 && strlen(fontname))
- {
- strncpy (logfont.lfFaceName, fontname, LF_FACESIZE);
- logfont.lfFaceName[LF_FACESIZE-1] = 0;
- }
+ {
+ Extbyte *extfontname;
+ Extcount extlen;
+
+ TO_EXTERNAL_FORMAT (C_STRING, fontname,
+ ALLOCA, (extfontname, extlen),
+ Qmswindows_tstr);
+ extlen = min (extlen, LF_FACESIZE - 1);
+ memcpy (logfont.lfFaceName, fontname, extlen);
+ logfont.lfFaceName[extlen] = 0;
+ }
else
- {
- maybe_signal_simple_error ("Must specify a font name", name, Qfont, errb);
- return (0);
- }
+ {
+ maybe_signal_simple_error ("Must specify a font name", name, Qfont,
+ errb);
+ return (0);
+ }
/* weight */
if (fields < 2)
@@ -1376,7 +1481,7 @@
/* charset can be specified even if earlier fields havn't been */
if (fields < 5)
{
- if ((c=strchr (extname, ':')) && (c=strchr (c+1, ':'))
&&
+ if ((c=strchr (namestr, ':')) && (c=strchr (c+1, ':'))
&&
(c=strchr (c+1, ':')) && (c=strchr (c+1, ':')))
{
strncpy (charset, c+1, LF_FACESIZE);
@@ -1424,7 +1529,8 @@
Lisp_Object fonttail;
char truename[MSW_FONTSIZE];
- sprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects,
charset);
+ sprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects,
+ charset);
LIST_LOOP (fonttail, device_font_list)
{
if (match_font (XSTRING_DATA (XCAR (fonttail)), truename, NULL))
@@ -1437,7 +1543,7 @@
}
}
- if ((hfont = CreateFontIndirect(&logfont)) == NULL)
+ if ((hfont = CreateFontIndirect (&logfont)) == NULL)
{
maybe_signal_simple_error ("Couldn't create font", name, Qfont, errb);
return 0;
@@ -1469,6 +1575,8 @@
f->ascent = (unsigned short) metrics.tmAscent;
f->descent = (unsigned short) metrics.tmDescent;
f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH);
+ FONT_INSTANCE_MSWINDOWS_MAX_WIDTH (f) =
+ (unsigned short) metrics.tmMaxCharWidth;
return 1;
}
@@ -1534,16 +1642,13 @@
mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device)
{
Lisp_Object fonttail, result = Qnil;
- char *extpattern;
-
- TO_EXTERNAL_FORMAT (LISP_STRING, pattern,
- C_STRING_ALLOCA, extpattern,
- Qctext);
-
LIST_LOOP (fonttail, DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device)))
{
- if (match_font (XSTRING_DATA (XCAR (fonttail)), extpattern, NULL))
- result = Fcons (XCAR (fonttail), result);
+ Bufbyte fontname[MSW_FONTSIZE];
+
+ if (match_font (XSTRING_DATA (XCAR (fonttail)), XSTRING_DATA (pattern),
+ fontname))
+ result = Fcons (build_string (fontname), result);
}
return Fnreverse (result);
@@ -1562,60 +1667,81 @@
static Lisp_Object
mswindows_font_instance_truename (Lisp_Font_Instance *f, Error_behavior errb)
{
- int nsep=0;
- char *name = (char *) XSTRING_DATA (f->name);
- char* ptr = name;
- char* extname = (char*) alloca (strlen (name) + 19);
- strcpy (extname, name);
-
- while ((ptr = strchr (ptr, ':')) != 0)
- {
- ptr++;
- nsep++;
- }
-
- switch (nsep)
- {
- case 0:
- strcat (extname, ":Regular:10::Western");
- break;
- case 1:
- strcat (extname, ":10::Western");
- break;
- case 2:
- strcat (extname, "::Western");
- break;
- case 3:
- strcat (extname, ":Western");
- break;
- default:;
- }
-
- return build_ext_string (extname, Qnative);
+ return XCAR (mswindows_list_fonts (f->name, f->device));
}
#ifdef MULE
static int
mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset,
- const Bufbyte *nonreloc, Lisp_Object reloc,
- Bytecount offset, Bytecount length)
-{
- /* #### Implement me */
+ const Bufbyte *nonreloc,
+ Lisp_Object reloc,
+ Bytecount offset, Bytecount length)
+{
+ const Bufbyte *the_nonreloc = nonreloc;
+ int i, ms_charset_id;
+ Bufbyte ms_charset_name[LF_FACESIZE], *c, *x_charset;
+ Bytecount the_length = length;
+
if (UNBOUNDP (charset))
return 1;
+
+ if (!the_nonreloc)
+ the_nonreloc = XSTRING_DATA (reloc);
+ fixup_internal_substring (nonreloc, reloc, offset, &the_length);
+ the_nonreloc += offset;
- return 1;
+ c = the_nonreloc;
+ for (i = 0; i < 4; i++)
+ {
+ Bufbyte *newc = memchr (c, ':', the_length);
+ if (!newc)
+ break;
+ newc++;
+ the_length -= (newc - c);
+ c = newc;
+ }
+
+ if (i == 4)
+ {
+ Bytecount copylen = min (the_length, LF_FACESIZE - 1);
+ strncpy (ms_charset_name, c, copylen);
+ ms_charset_name[copylen] = '\0';
+ }
+ else
+ return 0;
+
+ for (i = 0; i < countof (charset_map); i++)
+ if (stricmp (ms_charset_name, charset_map[i].name) == 0)
+ {
+ ms_charset_id = charset_map[i].value;
+ break;
+ }
+ if (i == countof (charset_map))
+ return 0;
+
+ x_charset = mswindows_to_x_charset (ms_charset_id);
+ return (fast_string_match (XCHARSET_REGISTRY (charset),
+ x_charset, Qnil, 0, -1, 0,
+ ERROR_ME, 0) >= 0);
}
/* find a font spec that matches font spec FONT and also matches
(the registry of) CHARSET. */
static Lisp_Object
mswindows_find_charset_font (Lisp_Object device, Lisp_Object font,
- Lisp_Object charset)
+ Lisp_Object charset)
{
- /* #### Implement me */
- return build_string ("Courier New:Regular:10");
+ Lisp_Object fontlist, fonttail;
+
+ fontlist = mswindows_list_fonts (font, device);
+ LIST_LOOP (fonttail, fontlist)
+ {
+ if (mswindows_font_spec_matches_charset
+ (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1))
+ return XCAR (fonttail);
+ }
+ return Qnil;
}
#endif /* MULE */
Index: src/objects-msw.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/objects-msw.h,v
retrieving revision 1.3.2.5
diff -u -r1.3.2.5 objects-msw.h
--- objects-msw.h 2000/02/21 04:33:52 1.3.2.5
+++ objects-msw.h 2000/04/30 09:05:31
@@ -55,6 +55,7 @@
struct mswindows_font_instance_data
{
HFONT hfont [MSWINDOWS_NUM_FONT_VARIANTS];
+ unsigned short max_width;
};
#define MSWINDOWS_FONT_INSTANCE_DATA(c) \
@@ -65,6 +66,9 @@
#define FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT(c,under,strike) \
FONT_INSTANCE_MSWINDOWS_HFONT_I (c, (!!(strike)<<1)|!!(under))
+
+#define FONT_INSTANCE_MSWINDOWS_MAX_WIDTH(c) \
+ (MSWINDOWS_FONT_INSTANCE_DATA(c)->max_width)
/* If font creation during redisplay fails, then the following
value is used to prevent future attempts to create this font.
Index: src/process.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/process.c,v
retrieving revision 1.39.2.12
diff -u -r1.39.2.12 process.c
--- process.c 2000/02/21 23:06:59 1.39.2.12
+++ process.c 2000/04/30 09:05:32
@@ -1306,8 +1306,7 @@
else
string2 = build_string ("\n");
set_string_char (XSTRING (string), 0,
- DOWNCASE (current_buffer,
- string_char (XSTRING (string), 0)));
+ DOWNCASE (0, string_char (XSTRING (string), 0)));
return concat2 (string, string2);
}
else if (EQ (symbol, Qexit))
Index: src/redisplay-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/redisplay-msw.c,v
retrieving revision 1.28.2.24
diff -u -r1.28.2.24 redisplay-msw.c
--- redisplay-msw.c 2000/04/13 02:37:09 1.28.2.24
+++ redisplay-msw.c 2000/04/30 09:05:32
@@ -48,7 +48,6 @@
#include "window.h"
#ifdef MULE
-#include "mule-ccl.h"
#include "mule-charset.h"
#endif
@@ -74,18 +73,16 @@
Lisp_Object charset;
unsigned char *ptr;
int len;
+ int byte_len;
int dimension;
} textual_run;
/* Separate out the text in DYN into a series of textual runs of a
- particular charset. Also convert the characters as necessary into
- the format needed by XDrawImageString(), XDrawImageString16(), et
- al. (This means converting to one or two byte format, possibly
- tweaking the high bits, and possibly running a CCL program.) You
- must pre-allocate the space used and pass it in. (This is done so
- you can alloca() the space.) You need to allocate (2 * len) bytes
- of TEXT_STORAGE and (len * sizeof (textual_run)) bytes of
- RUN_STORAGE, where LEN is the length of the dynarr.
+ particular charset. You must pre-allocate the space used and pass
+ it in. (This is done so you can alloca() the space.) You need to
+ allocate (2 * len) bytes of TEXT_STORAGE and (len * sizeof
+ (textual_run)) bytes of RUN_STORAGE, where LEN is the length of the
+ dynarr.
Returns the number of runs actually used. */
@@ -99,10 +96,6 @@
MULE is not defined */
int runs_so_far = 0;
int i;
-#ifdef MULE
- struct ccl_program char_converter;
- int need_ccl_conversion = 0;
-#endif
for (i = 0; i < len; i++)
{
@@ -122,23 +115,16 @@
run_storage[runs_so_far].charset = charset;
run_storage[runs_so_far].dimension = dimension;
- if (runs_so_far)
- {
- run_storage[runs_so_far - 1].len =
- text_storage - run_storage[runs_so_far - 1].ptr;
- if (run_storage[runs_so_far - 1].dimension == 2)
- run_storage[runs_so_far - 1].len >>= 1;
- }
- runs_so_far++;
- prev_charset = charset;
-#ifdef MULE
- {
- Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
- need_ccl_conversion = !NILP (ccl_prog);
- if (need_ccl_conversion)
- setup_ccl_program (&char_converter, ccl_prog);
- }
-#endif
+ if (runs_so_far)
+ {
+ run_storage[runs_so_far - 1].len =
+ run_storage[runs_so_far - 1].byte_len =
+ text_storage - run_storage[runs_so_far - 1].ptr;
+ if (run_storage[runs_so_far - 1].dimension == 2)
+ run_storage[runs_so_far - 1].len >>= 1;
+ }
+ runs_so_far++;
+ prev_charset = charset;
}
if (graphic == 0)
@@ -152,17 +138,32 @@
byte2 |= 0x80;
}
#ifdef MULE
- if (need_ccl_conversion)
- {
- char_converter.reg[0] = XCHARSET_ID (charset);
- char_converter.reg[1] = byte1;
- char_converter.reg[2] = byte2;
- char_converter.ic = 0; /* start at beginning each time */
- ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
- byte1 = char_converter.reg[1];
- byte2 = char_converter.reg[2];
- }
-#endif
+ if (dimension == 2)
+ {
+ if (EQ (charset, Vcharset_japanese_jisx0208))
+ {
+ Lisp_Object sjis_char;
+
+ sjis_char = Fencode_shift_jis_char (make_char (ch));
+ byte1 = XINT (XCAR (sjis_char));
+ byte2 = XINT (XCDR (sjis_char));
+ }
+ else if (EQ (charset, Vcharset_chinese_big5_1)
+ || EQ (charset, Vcharset_chinese_big5_2))
+ {
+ Lisp_Object big5_char;
+
+ big5_char = Fencode_big5_char (make_char (ch));
+ byte1 = XINT (XCAR (big5_char));
+ byte2 = XINT (XCDR (big5_char));
+ }
+ else
+ {
+ byte1 |= 0x80;
+ byte2 |= 0x80;
+ }
+ }
+#endif /* MULE */
*text_storage++ = (unsigned char) byte1;
if (dimension == 2)
*text_storage++ = (unsigned char) byte2;
@@ -171,6 +172,7 @@
if (runs_so_far)
{
run_storage[runs_so_far - 1].len =
+ run_storage[runs_so_far - 1].byte_len =
text_storage - run_storage[runs_so_far - 1].ptr;
if (run_storage[runs_so_far - 1].dimension == 2)
run_storage[runs_so_far - 1].len >>= 1;
@@ -188,16 +190,20 @@
Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
SIZE size;
- if (!fi->proportional_p || !hdc)
- return (fi->width * run->len);
- else
- {
- assert(run->dimension == 1); /* #### FIXME! */
- mswindows_set_dc_font (hdc, font_inst,
- cachel->underline, cachel->strikethru);
- GetTextExtentPoint32 (hdc, run->ptr, run->len, &size);
- return(size.cx);
- }
+ if (!fi->proportional_p || !hdc)
+ {
+ if (XCHARSET_DIMENSION (run->charset) == 2)
+ return FONT_INSTANCE_MSWINDOWS_MAX_WIDTH (fi) * run->len;
+ else
+ return fi->width * run->len;
+ }
+ else
+ {
+ mswindows_set_dc_font (hdc, font_inst,
+ cachel->underline, cachel->strikethru);
+ GetTextExtentPoint32 (hdc, run->ptr, run->byte_len, &size);
+ return(size.cx);
+ }
}
/*
@@ -342,8 +348,9 @@
int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
HDC hdc = get_frame_dc (f, 1);
unsigned int local_face_index=0;
- char *p_char = NULL;
- int n_char = 0;
+ unsigned char text_storage[2];
+ textual_run run;
+ int nruns = 0;
RECT rect = { xpos,
DISPLAY_LINE_YPOS (dl),
xpos + width,
@@ -358,19 +365,15 @@
redisplay_unmap_subwindows_maybe (f, xpos, DISPLAY_LINE_YPOS (dl),
width, DISPLAY_LINE_HEIGHT (dl));
+ run.ptr = NULL;
+ run.byte_len = 0;
+
if (real_char_p)
{
/* Use the font from the underlying character */
cachel = WINDOW_FACE_CACHEL (w, findex);
-
- /* #### MULE: Need to know the charset! */
- font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
- }
-
- if ((focus || bar_p) && real_char_p)
- {
- p_char = (char*) &ch;
- n_char = 1;
+ nruns = separate_textual_runs (text_storage, &run, &ch, 1);
+ font = FACE_CACHEL_FONT (cachel, run.charset);
}
if (!image_p)
@@ -388,8 +391,8 @@
if (real_char_p)
mswindows_set_dc_font (hdc, font,
cachel->underline, cachel->strikethru);
-
- ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char,
n_char, NULL);
+ ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect,
+ run.ptr, run.byte_len, NULL);
}
if (!cursor_p)
@@ -409,19 +412,12 @@
the rectangle so character cell will be bounded by the
previously drawn cursor shape */
InflateRect (&rect, -1, -1);
-
- if (real_char_p)
- {
- p_char = (char*) &ch;
- n_char = 1;
- }
-
local_face_index = get_builtin_face_cache_index (w, Vdefault_face);
cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : local_face_index));
mswindows_update_dc (hdc,
cachel->foreground, cachel->background, Qnil);
ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
- &rect, p_char, n_char, NULL);
+ &rect, run.ptr, run.byte_len, NULL);
}
}
@@ -559,10 +555,9 @@
}
}
- assert (runs[i].dimension == 1); /* #### FIXME: Broken when Mule? */
ExtTextOut (hdc, xpos, dl->ypos,
NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED,
- &rect, (char *) runs[i].ptr, runs[i].len, NULL);
+ &rect, (char *) runs[i].ptr, runs[i].byte_len, NULL);
xpos += this_width;
}
@@ -1341,6 +1336,15 @@
GdiFlush();
}
+/* Returning a char width of font instance FI for the CHARSET */
+static int
+mswindows_font_width (Lisp_Font_Instance *fi, Lisp_Object charset)
+{
+ if (XCHARSET_DIMENSION (charset) == 2)
+ return FONT_INSTANCE_MSWINDOWS_MAX_WIDTH (fi);
+ else
+ return FONT_INSTANCE_WIDTH (fi);
+}
/************************************************************************/
@@ -1365,6 +1369,7 @@
CONSOLE_HAS_METHOD (mswindows, bevel_area);
CONSOLE_HAS_METHOD (mswindows, output_string);
CONSOLE_HAS_METHOD (mswindows, output_pixmap);
+ CONSOLE_HAS_METHOD (mswindows, font_width);
/* redisplay methods - printer */
CONSOLE_INHERITS_METHOD (msprinter, mswindows, text_width);
@@ -1379,4 +1384,5 @@
CONSOLE_INHERITS_METHOD (msprinter, mswindows, bevel_area);
CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_string);
CONSOLE_INHERITS_METHOD (msprinter, mswindows, output_pixmap);
+ CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_width);
}
Index: src/redisplay.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/redisplay.c,v
retrieving revision 1.55.2.51
diff -u -r1.55.2.51 redisplay.c
--- redisplay.c 2000/04/10 16:32:17 1.55.2.51
+++ redisplay.c 2000/04/30 09:05:35
@@ -873,7 +873,9 @@
fi = XFONT_INSTANCE (font_instance);
if (!fi->proportional_p)
/* sweetness and light. */
- data->last_char_width = fi->width;
+ data->last_char_width =
+ DEVMETH_OR_GIVEN (XDEVICE (FONT_INSTANCE_DEVICE (fi)),
+ font_width, (fi, charset), fi->width);
else
data->last_char_width = -1;
data->new_ascent = max (data->new_ascent, (int) fi->ascent);
Index: src/search.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/search.c,v
retrieving revision 1.14.2.9
diff -u -r1.14.2.9 search.c
--- search.c 2000/02/16 02:07:14 1.14.2.9
+++ search.c 2000/04/30 09:05:36
@@ -455,8 +455,7 @@
bufp = compile_pattern (regexp, 0,
(case_fold_search
? (char *)
- /* #### evil current-buffer dependency */
- MIRROR_DOWNCASE_TABLE_AS_STRING (current_buffer)
+ MIRROR_DOWNCASE_TABLE_AS_STRING (0)
: 0),
0, errb);
if (!bufp)
Index: src/select-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/select-msw.c,v
retrieving revision 1.7.2.7
diff -u -r1.7.2.7 select-msw.c
--- select-msw.c 2000/03/13 07:28:04 1.7.2.7
+++ select-msw.c 2000/04/30 09:05:36
@@ -1,5 +1,6 @@
/* mswindows selection processing for XEmacs
Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Copyright (C) 2000 Ben Wing.
This file is part of XEmacs.
@@ -24,19 +25,18 @@
Written by Kevin Gallo for FSF Emacs.
Rewritten for mswindows by Jonathan Harris, December 1997 for 21.0.
+ Rewritten April 2000 by Ben Wing -- support device methods, Mule-ize.
*/
#include <config.h>
#include "lisp.h"
+#include "buffer.h"
#include "frame.h"
#include "select.h"
#include "console-msw.h"
-
-/* Do protocol to assert ourself as a selection owner. Under mswindows
-this is easy, we just set the clipboard. */
static Lisp_Object
mswindows_own_selection (Lisp_Object selection_name,
Lisp_Object selection_value)
@@ -50,75 +50,58 @@
if it is the clipboard */
EQ (selection_name, QCLIPBOARD))
{
- int rawsize, size, i;
- unsigned char *src, *dst, *next;
+ Bytecount size, size2;
+ int i;
+ Bufbyte *src, *src2;
+ Extbyte *dst, *winmem;
+ Extcount len;
HGLOBAL h = NULL;
struct frame *f = NULL;
- struct gcpro gcpro1, gcpro2;
Lisp_Object string = XCDR (converted_value);
- GCPRO2 (converted_value, string);
-
CHECK_STRING (string);
-
- /* Calculate size with LFs converted to CRLFs because
- * CF_TEXT format uses CRLF delimited ASCIIZ */
+ size = XSTRING_LENGTH (string);
src = XSTRING_DATA (string);
- size = rawsize = XSTRING_LENGTH (string) + 1;
- for (i=0; i<rawsize; i++)
- if (src[i] == '\n')
- size++;
+ src2 = (Bufbyte *) alloca (2 * size);
- f = selected_frame ();
- if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+ for (i = 0, size2 = 0; i < size; i++)
{
- UNGCPRO;
- return Qnil;
+ /* #### Mule-ASCII assumption */
+ if (src[i] == '\n')
+ src2[size2++] = '\r';
+ src2[size2++] = src[i];
}
+
+ /* #### Visual C++ docs and Nadine Kano's book disagree on whether
+ Win 95 performs automatic Unicode conversion! If not, we need
+ to fix this. */
+ TO_EXTERNAL_DATA (DATA, (src2, size2),
+ ALLOCA, (dst, len),
+ Qmswindows_unicode);
- /* This call to EmptyClipboard may post an event back to us if
- we already own the clipboard (to tell us we lost it) and this
- event may execute random lisp code. Hence we must protect
- the string and get its address again after the call. */
+ f = selected_frame ();
+ if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
+ return Qnil;
+
if (!EmptyClipboard () ||
- (h = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, size)) == NULL ||
- (dst = (unsigned char *) GlobalLock (h)) == NULL)
+ (h = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, len)) == NULL ||
+ (winmem = (Extbyte *) GlobalLock (h)) == NULL)
{
if (h != NULL) GlobalFree (h);
CloseClipboard ();
UNGCPRO;
return Qnil;
}
- src = XSTRING_DATA (string);
- /* Convert LFs to CRLFs */
- do
- {
- /* copy next line or remaining bytes including '\0' */
- next = (char*) memccpy (dst, src, '\n', rawsize);
- if (next)
- {
- /* copied one line ending with '\n' */
- int copied = next - dst;
- rawsize -= copied;
- src += copied;
- /* insert '\r' before '\n' */
- next[-1] = '\r';
- next[0] = '\n';
- dst = next+1;
- }
- }
- while (next);
-
+ memcpy (winmem, dst, len);
+
GlobalUnlock (h);
- i = (SetClipboardData (CF_TEXT, h) != NULL);
+ i = (SetClipboardData (CF_UNICODETEXT, h) != NULL);
CloseClipboard ();
- UNGCPRO;
- /* #### we are supposed to return a time! */
- /* return i ? Qt : Qnil; */
+ /* we don't need to return a time, because we don't use it later. */
return Qnil;
}
@@ -132,43 +115,33 @@
if (EQ (selection_symbol, QCLIPBOARD))
{
HANDLE h;
- unsigned char *src, *dst, *next;
+ Extbyte *src;
Lisp_Object ret = Qnil;
if (!OpenClipboard (NULL))
return Qnil;
- if ((h = GetClipboardData (CF_TEXT)) != NULL &&
- (src = (unsigned char *) GlobalLock (h)) != NULL)
+ /* #### Visual C++ docs and Nadine Kano's book disagree on whether
+ Win 95 performs automatic Unicode conversion! If not, we need
+ to fix this. */
+ if ((h = GetClipboardData (CF_UNICODETEXT)) != NULL &&
+ (src = (Extbyte *) GlobalLock (h)) != NULL)
{
+ Bufbyte *dst, *dst2;
+ Bytecount len, len2;
int i;
- int size, rawsize;
- size = rawsize = strlen (src);
+
+ TO_INTERNAL_FORMAT (DATA, (src, GlobalSize (h)),
+ ALLOCA, (dst, len),
+ Qmswindows_unicode);
- for (i=0; i<rawsize; i++)
- if (src[i] == '\r' && src[i+1] == '\n')
- size--;
-
- /* Convert CRLFs to LFs */
- ret = make_uninit_string (size);
- dst = XSTRING_DATA (ret);
- do
+ for (i = 0, len2 = 0, dst2 = dst; i < len; i++)
{
- /* copy next line or remaining bytes excluding '\0' */
- next = (unsigned char *) memccpy (dst, src, '\r', rawsize);
- if (next)
- {
- /* copied one line ending with '\r' */
- int copied = next - dst;
- rawsize -= copied;
- src += copied;
- if (*src == '\n')
- dst += copied - 1; /* overwrite '\r' */
- else
- dst += copied;
- }
+ /* #### Mule-ASCII assumption */
+ if (! (dst[i] == '\r' && dst[i + 1] == '\n'))
+ dst2[len2++] = dst[i];
}
- while (next);
+ ret = make_string (dst2, len2);
GlobalUnlock (h);
}
@@ -203,7 +176,7 @@
mswindows_selection_exists_p (Lisp_Object selection)
{
if (EQ (selection, QCLIPBOARD))
- return IsClipboardFormatAvailable (CF_TEXT) ? Qt : Qnil;
+ return IsClipboardFormatAvailable (CF_UNICODETEXT) ? Qt : Qnil;
else
return Qnil;
}
Index: src/select.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/Attic/select.h,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 select.h
--- select.h 2000/01/22 12:04:17 1.1.2.2
+++ select.h 2000/04/30 09:05:36
@@ -33,7 +33,7 @@
selection-value is the value that emacs owns for that selection.
It may be any kind of Lisp object.
selection-timestamp is the time at which emacs began owning this selection,
- as a cons of two 16-bit numbers (making a 32 bit time).
+ an opaque. (used only under X.)
If there is an entry in this alist, then it can be assumed that emacs owns
that selection.
The only (eq) parts of this list that are visible from elisp are the
Index: src/sunOS-fix.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sunOS-fix.c,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 sunOS-fix.c
--- sunOS-fix.c 2000/02/16 02:06:36 1.2.2.1
+++ sunOS-fix.c 2000/04/30 09:05:36
@@ -17,49 +17,4 @@
/* Synched up with: Not in FSF. */
-/* If you are using SunOS 4.1.1 and X11r5, then you need this patch.
- There is a stupid bug in the SunOS libc.a: two functions which X11r5
- uses, mbstowcs() and wcstombs(), are unusable when programs are
- statically linked (as Emacs must be) because the static version of
- libc.a contains the *dynamic* versions of these functions. These
- functions don't seem to be called when Emacs is running, so it's
- enough to define stubs for them.
-
- This appears to be fixed in SunOS 4.1.2.
- */
-
-#include <config.h>
-
-#ifndef I18N4 /* we actually need these from the library in this case. */
-
-#ifdef __STDC__
-
-#include <stdlib.h>
-
-size_t mbstowcs (wchar_t *foo, const char *bar, size_t baz)
-{
- abort ();
- return 0;
-}
-
-size_t wcstombs (char *foo, const wchar_t *bar, size_t baz)
-{
- abort ();
- return 0;
-}
-
-#else
-
-void mbstowcs ()
-{
- abort ();
-}
-
-void wcstombs ()
-{
- abort ();
-}
-
-#endif /* __STDC__ */
-
-#endif /* !I18N4 */
+int sunOS_fix_is_empty;
Index: src/sunpro.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/sunpro.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sunpro.c
--- sunpro.c 1996/12/18 22:44:05 1.1.1.1
+++ sunpro.c 2000/04/30 09:05:36
@@ -50,7 +50,7 @@
{
#ifdef USAGE_TRACKING
Lisp_Object xs;
- unsigned char *s; /* #### Does not support I18N4. */
+ unsigned char *s;
if (!NILP (Vusage_tracking))
{
Index: src/symsinit.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/symsinit.h,v
retrieving revision 1.31.2.25
diff -u -r1.31.2.25 symsinit.h
--- symsinit.h 2000/03/21 02:06:44 1.31.2.25
+++ symsinit.h 2000/04/30 09:05:37
@@ -32,6 +32,7 @@
void init_process_times_very_early (void);
void init_ralloc (void);
void init_signals_very_early (void);
+void init_win32_very_early (void);
/* Early Lisp-engine initialization (dump-time for init, run-time for reinit). */
@@ -423,6 +424,7 @@
/* Reset the Lisp engine (run-time only). */
+void reinit_file_coding (void);
void reinit_alloc (void);
void reinit_eval (void);
Index: src/s/cygwin32.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/s/cygwin32.h,v
retrieving revision 1.14.2.15
diff -u -r1.14.2.15 cygwin32.h
--- cygwin32.h 2000/03/06 20:57:49 1.14.2.15
+++ cygwin32.h 2000/04/30 09:05:39
@@ -40,6 +40,8 @@
* Andy Piper <andy(a)xemacs.org> 8/1/98
*
http://www.xemacs.freeserve.co.uk/ */
+#define HAVE_WIN32
+
/* cheesy way to determine cygwin version */
#ifndef NOT_C_CODE
# include <signal.h>
@@ -256,9 +258,6 @@
#define CYGWIN_CONV_PATH(src, dst) \
dst = alloca (cygwin32_win32_to_posix_path_list_buf_size(src)); \
cygwin32_win32_to_posix_path_list(src, dst)
-#define CYGWIN_WIN32_PATH(src, dst) \
-dst = alloca (cygwin32_posix_to_win32_path_list_buf_size(src)); \
-cygwin32_posix_to_win32_path_list(src, dst)
/*
* stolen from usg.
Index: src/s/windows95.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/s/windows95.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 windows95.h
--- windows95.h 1996/12/18 22:44:13 1.1.1.1
+++ windows95.h 2000/04/30 09:05:39
@@ -1,7 +1 @@
-/* Synched up with: FSF 19.31. */
-
-/* System description file for Windows 95. */
-
-#include "windowsnt.h"
-
-#define WINDOWS95
+/* Unused */
Index: src/s/windowsnt.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/s/windowsnt.h,v
retrieving revision 1.15.2.13
diff -u -r1.15.2.13 windowsnt.h
--- windowsnt.h 2000/03/05 13:49:03 1.15.2.13
+++ windowsnt.h 2000/04/30 09:05:39
@@ -1,4 +1,4 @@
-/* System description file for Windows NT.
+/* System description file for Windows 9x and NT.
Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -24,6 +24,9 @@
#define WINDOWSNT
#endif
+#define HAVE_WINDOWS_NATIVE
+#define HAVE_WIN32
+
#ifndef DOS_NT
#define DOS_NT /* MSDOS or WINDOWSNT */
#endif
@@ -312,3 +315,6 @@
#define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
__declspec(noreturn) extern void decl PRINTF_ARGS(str,idx)
#endif /* MSVC 6.0 */
+
+#define CYGWIN_CONV_PATH(src, dst) (dst) = (src)
+#define CYGWIN_WIN32_PATH(src, dst) (dst) = (src)