Mercurial > hg > xemacs-beta
annotate src/intl-win32.c @ 5353:38e24b8be4ea
Improve the lexical scoping in #'block, #'return-from.
lisp/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el:
* bytecomp.el (byte-compile-initial-macro-environment):
Shadow `block', `return-from' here, we implement them differently
when byte-compiling.
* bytecomp.el (byte-compile-active-blocks): New.
* bytecomp.el (byte-compile-block-1): New.
* bytecomp.el (byte-compile-return-from-1): New.
* bytecomp.el (return-from-1): New.
* bytecomp.el (block-1): New.
These are two aliases that exist to have their own associated
byte-compile functions, which functions implement `block' and
`return-from'.
* cl-extra.el (cl-macroexpand-all):
Fix a bug here when macros in the environment have been compiled.
* cl-macs.el (block):
* cl-macs.el (return):
* cl-macs.el (return-from):
Be more careful about lexical scope in these macros.
* cl.el:
* cl.el ('cl-block-wrapper): Removed.
* cl.el ('cl-block-throw): Removed.
These aren't needed in code generated by this XEmacs. They
shouldn't be needed in code generated by XEmacs 21.4, but if it
turns out the packages do need them, we can put them back.
2011-01-30 Mike Sperber <mike@xemacs.org>
* font-lock.el (font-lock-fontify-pending-extents): Don't fail if
`font-lock-mode' is unset, which can happen in the middle of
`revert-buffer'.
2011-01-23 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete):
* cl-macs.el (delq):
* cl-macs.el (remove):
* cl-macs.el (remq):
Don't use the compiler macro if these functions were given the
wrong number of arguments, as happens in lisp-tests.el.
* cl-seq.el (remove, remq): Removed.
I added these to subr.el, and forgot to remove them from here.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-setq, byte-compile-set):
Remove kludge allowing keywords' values to be set, all the code
that does that is gone.
* cl-compat.el (elt-satisfies-test-p):
* faces.el (set-face-parent):
* faces.el (face-doc-string):
* gtk-font-menu.el:
* gtk-font-menu.el (gtk-reset-device-font-menus):
* msw-font-menu.el:
* msw-font-menu.el (mswindows-reset-device-font-menus):
* package-get.el (package-get-installedp):
* select.el (select-convert-from-image-data):
* sound.el:
* sound.el (load-sound-file):
* x-font-menu.el (x-reset-device-font-menus-core):
Don't quote keywords, they're self-quoting, and the
win from backward-compatibility is sufficiently small now that the
style problem overrides it.
2011-01-22 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (block, return-from): Require that NAME be a symbol
in these macros, as always documented in the #'block docstring and
as required by Common Lisp.
* descr-text.el (unidata-initialize-unihan-database):
Correct the use of non-symbols in #'block and #'return-from in
this function.
2011-01-15 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (concatenate): Accept more complicated TYPEs in this
function, handing the sequences over to #'coerce if we don't
understand them here.
* cl-macs.el (inline): Don't proclaim #'concatenate as inline, its
compiler macro is more useful than doing that.
2011-01-11 Aidan Kehoe <kehoea@parhasard.net>
* subr.el (delete, delq, remove, remq): Move #'remove, #'remq
here, they don't belong in cl-seq.el; move #'delete, #'delq here
from fns.c, implement them in terms of #'delete*, allowing support
for sequences generally.
* update-elc.el (do-autoload-commands): Use #'delete*, not #'delq
here, now the latter's no longer dumped.
* cl-macs.el (delete, delq): Add compiler macros transforming
#'delete and #'delq to #'delete* calls.
2011-01-10 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box): Correct a misplaced parenthesis
here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se !
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* dialog.el (make-dialog-box):
* list-mode.el (display-completion-list):
These functions used to use cl-parsing-keywords; change them to
use defun* instead, fixing the build. (Not sure what led to me
not including this change in d1b17a33450b!)
2011-01-02 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (define-star-compiler-macros):
Make sure the form has ITEM and LIST specified before attempting
to change to calls with explicit tests; necessary for some tests
in lisp-tests.el to compile correctly.
(stable-union, stable-intersection): Add compiler macros for these
functions, in the same way we do for most of the other functions
in cl-seq.el.
2011-01-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (dolist, dotimes, do-symbols, macrolet)
(symbol-macrolet):
Define these macros with defmacro* instead of parsing the argument
list by hand, for the sake of style and readability; use backquote
where appropriate, instead of calling #'list and and friends, for
the same reason.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* x-misc.el (device-x-display):
Provide this function, documented in the Lispref for years, but
not existing previously. Thank you Julian Bradfield, thank you
Jeff Mincy.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el:
Move the heavy lifting from this file to C. Dump the
cl-parsing-keywords macro, but don't use defun* for the functions
we define that do take keywords, dynamic scope lossage makes that
not practical.
* subr.el (sort, fillarray): Move these aliases here.
(map-plist): #'nsublis is now built-in, but at this point #'eql
isn't necessarily available as a test; use #'eq.
* obsolete.el (cl-delete-duplicates): Make this available for old
compiler macros and old code.
(memql): Document that this is equivalent to #'member*, and worse.
* cl.el (adjoin, subst): Removed. These are in C.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (assoc-ignore-case): Remove a duplicate definition of
this function (it's already in subr.el).
* iso8859-1.el (char-width):
On non-Mule, make this function equivalent to that produced by
(constantly 1), but preserve its docstring.
* subr.el (subst-char-in-string): Define this in terms of
#'substitute, #'nsubstitute.
(string-width): Define this using #'reduce and #'char-width.
(char-width): Give this a simpler definition, it makes far more
sense to check for mule at load time and redefine, as we do in
iso8859-1.el.
(store-substring): Implement this in terms of #'replace, now
#'replace is cheap.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* update-elc.el (lisp-files-needed-for-byte-compilation)
(lisp-files-needing-early-byte-compilation):
cl-macs belongs in the former, not the latter, it is as
fundamental as bytecomp.el.
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl.el:
Provde the Common Lisp program-error, type-error as error
symbols. This doesn't nearly go far enough for anyone using the
Common Lisp errors.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (delete-duplicates):
If the form has an incorrect number of arguments, don't attempt a
compiler macroexpansion.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (cl-safe-expr-p):
Forms that start with the symbol lambda are also safe.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
For these functions' compiler macros, the optimisation is safe
even if the first and the last arguments have side effects, since
they're only used the once.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (inline-side-effect-free-compiler-macros):
Unroll a loop here at macro-expansion time, so these compiler
macros are compiled. Use #'eql instead of #'eq in a couple of
places for better style.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (notany, notevery): Avoid some dynamic scope
stupidity with local variable names in these functions, when they
weren't prefixed with cl-; go into some more detail in the doc
strings.
2010-12-29 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns): #'remove, #'remq are
free of side-effects.
(side-effect-and-error-free-fns):
Drop dot, dot-marker from the list.
2010-11-17 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (coerce):
In the argument list, name the first argument OBJECT, not X; the
former name was always used in the doc string and is clearer.
Handle vector type specifications which include the length of the
target sequence, error if there's a mismatch.
* cl-macs.el (cl-make-type-test): Handle type specifications
starting with the symbol 'eql.
2010-11-14 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (eql): Don't remove the byte-compile property of this
symbol. That was necessary to override a bug in bytecomp.el where
#'eql was confused with #'eq, which bug we no longer have.
If neither expression is constant, don't attempt to handle the
expression in this compiler macro, leave it to byte-compile-eql,
which produces better code anyway.
* bytecomp.el (eq): #'eql is not the function associated with the
byte-eq byte code.
(byte-compile-eql): Add an explicit compile method for this
function, for cases where the cl-macs compiler macro hasn't
reduced it to #'eq or #'equal.
2010-10-25 Aidan Kehoe <kehoea@parhasard.net>
Add compiler macros and compilation sanity-checking for various
functions that take keywords.
* byte-optimize.el (side-effect-free-fns): #'symbol-value is
side-effect free and not error free.
* bytecomp.el (byte-compile-normal-call): Check keyword argument
lists for sanity; store information about the positions where
keyword arguments start using the new byte-compile-keyword-start
property.
* cl-macs.el (cl-const-expr-val): Take a new optional argument,
cl-not-constant, defaulting to nil, in this function; return it if
the expression is not constant.
(cl-non-fixnum-number-p): Make this into a separate function, we
want to pass it to #'every.
(eql): Use it.
(define-star-compiler-macros): Use the same code to generate the
member*, assoc* and rassoc* compiler macros; special-case some
code in #'add-to-list in subr.el.
(remove, remq): Add compiler macros for these two functions, in
preparation for #'remove being in C.
(define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to
(remove ... :if-not) at compile time, which will be a real win
once the latter is in C.
(define-substitute-if-compiler-macros)
(define-subst-if-compiler-macros): Similarly for these functions.
(delete-duplicates): Change this compiler macro to use
#'plists-equal; if we don't have information about the type of
SEQUENCE at compile time, don't bother attempting to inline the
call, the function will be in C soon enough.
(equalp): Remove an old commented-out compiler macro for this, if
we want to see it it's in version control.
(subst-char-in-string): Transform this to a call to nsubstitute or
nsubstitute, if that is appropriate.
* cl.el (ldiff): Don't call setf here, this makes for a load-time
dependency problem in cl-macs.el
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* term/vt100.el:
Refer to XEmacs, not GNU Emacs, in permissions.
* term/bg-mouse.el:
* term/sup-mouse.el:
Put copyright notice in canonical "Copyright DATE AUTHOR" form.
Refer to XEmacs, not GNU Emacs, in permissions.
* site-load.el:
Add permission boilerplate.
* mule/canna-leim.el:
* alist.el:
Refer to XEmacs, not APEL/this program, in permissions.
* mule/canna-leim.el:
Remove my copyright, I've assigned it to the FSF.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* gtk.el:
* gtk-widget-accessors.el:
* gtk-package.el:
* gtk-marshal.el:
* gtk-compose.el:
* gnome.el:
Add copyright notice based on internal evidence.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* easymenu.el: Add reference to COPYING to permission notice.
* gutter.el:
* gutter-items.el:
* menubar-items.el:
Fix typo "Xmacs" in permissions notice.
2010-06-14 Stephen J. Turnbull <stephen@xemacs.org>
* auto-save.el:
* font.el:
* fontconfig.el:
* mule/kinsoku.el:
Add "part of XEmacs" text to permission notice.
2010-10-14 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (side-effect-free-fns):
* cl-macs.el (remf, getf):
* cl-extra.el (tailp, cl-set-getf, cl-do-remf):
* cl.el (ldiff, endp):
Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp;
add circularity checking for the first two.
#'cl-set-getf and #'cl-do-remf were Lisp implementations of
#'plist-put and #'plist-remprop; change the names to aliases,
changes the macros that use them to using #'plist-put and
#'plist-remprop directly.
2010-10-12 Aidan Kehoe <kehoea@parhasard.net>
* abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table):
Create both these abbrev tables using the usual
#'define-abbrev-table calls, rather than attempting to
special-case them.
* cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is
being loaded interpreted. Previously other, later files would
redundantly call (load "cl-macs") when interpreted, it's more
reasonable to do it here, once.
* cmdloop.el (read-quoted-char-radix): Use defcustom here, we
don't have any dump-order dependencies that would prevent that.
* custom.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling, rely on cl-extra.el in the
former case and the appropriate entry in bytecomp-load-hook in the
latter. Get rid of custom-declare-variable-list, we have no
dump-time dependencies that would require it.
* faces.el (eval-when-compile): Don't load cl-macs when
interpreted or when byte-compiling.
* packages.el: Remove some inaccurate comments.
* post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not
here, now the order of preloaded-file-list has been changed to
make it available.
* subr.el (custom-declare-variable-list): Remove. No need for it.
Also remove a stub define-abbrev-table from this file, given the
current order of preloaded-file-list there's no need for it.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are
also constant.
(byte-compile-initial-macro-environment): In #'the, if FORM is
constant and does not match TYPE, warn at byte-compile time.
2010-10-10 Aidan Kehoe <kehoea@parhasard.net>
* backquote.el (bq-vector-contents, bq-list*): Remove; the former
is equivalent to (append VECTOR nil), the latter to (list* ...).
(bq-process-2): Use (append VECTOR nil) instead of using
#'bq-vector-contents to convert to a list.
(bq-process-1): Now we use list* instead of bq-list
* subr.el (list*): Moved from cl.el, since it is now required to
be available the first time a backquoted form is encountered.
* cl.el (list*): Move to subr.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* test-harness.el (Check-Message):
Add an omitted comma here, thank you the buildbot.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* hash-table.el (hash-table-key-list, hash-table-value-list)
(hash-table-key-value-alist, hash-table-key-value-plist):
Remove some useless #'nreverse calls in these files; our hash
tables have no order, it's not helpful to pretend they do.
* behavior.el (read-behavior):
Do the same in this file, in some code evidently copied from
hash-table.el.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* info.el (Info-insert-dir):
* format.el (format-deannotate-region):
* files.el (cd, save-buffers-kill-emacs):
Use #'some, #'every and related functions for applying boolean
operations to lists, instead of rolling our own ones that cons and
don't short-circuit.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-initial-macro-environment):
* cl-macs.el (the):
Rephrase the docstring, make its implementation when compiling
files a little nicer.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* descr-text.el (unidata-initialize-unicodedata-database)
(unidata-initialize-unihan-database, describe-char-unicode-data)
(describe-char-unicode-data):
Wrap calls to the database functions with (with-fboundp ...),
avoiding byte compile warnings on builds without support for the
database functions.
(describe-char): (reduce #'max ...), not (apply #'max ...), no
need to cons needlessly.
(describe-char): Remove a redundant lambda wrapping
#'extent-properties.
(describe-char-unicode-data): Call #'nsubst when replacing "" with
nil in the result of #'split-string, instead of consing inside
mapcar.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* x-faces.el (x-available-font-sizes):
* specifier.el (let-specifier):
* package-ui.el (pui-add-required-packages):
* msw-faces.el (mswindows-available-font-sizes):
* modeline.el (modeline-minor-mode-menu):
* minibuf.el (minibuf-directory-files):
Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with
the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (= < > <= >=):
When these functions are handed more than two arguments, and those
arguments have no side effects, transform to a series of two
argument calls, avoiding funcall in the byte-compiled code.
* mule/mule-cmds.el (finish-set-language-environment):
Take advantage of this change in a function called 256 times at
startup.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-function-form, byte-compile-quote)
(byte-compile-quote-form):
Warn at compile time, and error at runtime, if a (quote ...) or a
(function ...) form attempts to quote more than one object.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc
(mapcar ...)) to (mapcan ...); warn about use of the first idiom.
* update-elc.el (do-autoload-commands):
* packages.el (packages-find-package-library-path):
* frame.el (frame-list):
* extents.el (extent-descendants):
* etags.el (buffer-tag-table-files):
* dumped-lisp.el (preloaded-file-list):
* device.el (device-list):
* bytecomp-runtime.el (proclaim-inline, proclaim-notinline)
Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files.
* bytecomp-runtime.el (eval-when-compile, eval-and-compile):
In passing, mention that these macros also evaluate the body when
interpreted.
tests/ChangeLog addition:
2011-02-07 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Test lexical scope for `block', `return-from'; add a
Known-Bug-Expect-Failure for a contorted example that fails when
byte-compiled.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 07 Feb 2011 12:01:24 +0000 |
parents | db326b8fe982 |
children | 0af042a0c116 |
rev | line source |
---|---|
771 | 1 /* Win32 internationalization functions. |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
2 Copyright (C) 2000, 2001, 2002, 2004, 2010 Ben Wing. |
771 | 3 Copyright (C) 2000 IKEYAMA Tomonori. |
4 | |
5 This file is part of XEmacs. | |
6 | |
7 XEmacs is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with XEmacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 /* Authorship: | |
25 | |
26 Current primary author: Ben Wing <ben@xemacs.org> | |
27 | |
28 Created summer 2000 by Ben Wing. Almost completely written by Ben Wing. | |
29 Little bits of code in some of the Lisp primitives from FSF Emacs. | |
30 Versions of wcscpy, wcsncpy from Cygwin newlib. | |
31 | |
32 Coding systems written by Ben Wing in file-coding.c; moved here Sep 2001. | |
33 */ | |
34 | |
35 #include <config.h> | |
36 #include "lisp.h" | |
37 | |
38 #include "elhash.h" | |
39 #include "faces.h" | |
40 #include "file-coding.h" | |
872 | 41 #include "frame-impl.h" |
42 #include "window-impl.h" | |
771 | 43 |
872 | 44 #include "console-msw-impl.h" |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5016
diff
changeset
|
45 #include "fontcolor-msw-impl.h" |
771 | 46 |
47 #ifndef CYGWIN_HEADERS | |
48 # include <mbctype.h> | |
49 #elif defined (MINGW) | |
50 int _setmbcp (int); | |
51 int _getmbcp (void); | |
52 #else | |
53 # define NO_EXT_MULTIBYTE_FEATURES | |
54 #endif | |
55 | |
2367 | 56 |
57 | |
58 /* | |
59 | |
60 Detailed info on Microsoft Windows-Related Multilingual Issues: | |
61 | |
62 (Info-goto-node "(internals)Microsoft Windows-Related Multilingual Issues") | |
63 */ | |
64 | |
771 | 65 Lisp_Object Qmswindows_multibyte, Qmswindows_multibyte_to_unicode; |
66 Lisp_Object Qmswindows_tstr, Qmswindows_unicode; | |
67 Lisp_Object Qmswindows_multibyte_system_default; | |
68 | |
69 Lisp_Object Qansi, Qoem, Qmac, Qebcdic; | |
70 /* Qcode_page, Qlocale, Qcurrent, Quser_default, Qsystem_default in | |
71 general-slots.h */ | |
72 | |
73 #ifdef MULE | |
74 | |
75 static Lisp_Object Vmswindows_charset_code_page_table; | |
872 | 76 static Lisp_Object Vmswindows_charset_registry_table; |
771 | 77 |
78 LCID current_locale; | |
79 | |
80 | |
81 /************************************************************************/ | |
82 /* Language/locale/code page conversion functions */ | |
83 /************************************************************************/ | |
84 | |
85 struct lang_to_string | |
86 { | |
87 int code; | |
4932 | 88 const Ascbyte *string; |
771 | 89 }; |
90 | |
91 struct lang_to_string lang_to_string_table[] = | |
92 { | |
93 /* These names change from version to version of VC++, so it's easiest | |
94 just to bracket them all with ifdefs. */ | |
95 #ifdef LANG_AFRIKAANS | |
96 { LANG_AFRIKAANS, "AFRIKAANS" }, | |
97 #endif | |
98 #ifdef LANG_ALBANIAN | |
99 { LANG_ALBANIAN, "ALBANIAN" }, | |
100 #endif | |
101 #ifdef LANG_ARABIC | |
102 { LANG_ARABIC, "ARABIC" }, | |
103 #endif | |
104 #ifdef LANG_ARMENIAN | |
105 { LANG_ARMENIAN, "ARMENIAN" }, | |
106 #endif | |
107 #ifdef LANG_ASSAMESE | |
108 { LANG_ASSAMESE, "ASSAMESE" }, | |
109 #endif | |
110 #ifdef LANG_AZERI | |
111 { LANG_AZERI, "AZERI" }, | |
112 #endif | |
113 #ifdef LANG_BASQUE | |
114 { LANG_BASQUE, "BASQUE" }, | |
115 #endif | |
116 #ifdef LANG_BELARUSIAN | |
117 { LANG_BELARUSIAN, "BELARUSIAN" }, | |
118 #endif | |
119 #ifdef LANG_BENGALI | |
120 { LANG_BENGALI, "BENGALI" }, | |
121 #endif | |
122 #ifdef LANG_BULGARIAN | |
123 { LANG_BULGARIAN, "BULGARIAN" }, | |
124 #endif | |
125 #ifdef LANG_CATALAN | |
126 { LANG_CATALAN, "CATALAN" }, | |
127 #endif | |
128 #ifdef LANG_CHINESE | |
129 { LANG_CHINESE, "CHINESE" }, | |
130 #endif | |
131 #ifdef LANG_CROATIAN | |
132 { LANG_CROATIAN, "CROATIAN" }, | |
133 #endif | |
134 #ifdef LANG_CZECH | |
135 { LANG_CZECH, "CZECH" }, | |
136 #endif | |
137 #ifdef LANG_DANISH | |
138 { LANG_DANISH, "DANISH" }, | |
139 #endif | |
140 #ifdef LANG_DUTCH | |
141 { LANG_DUTCH, "DUTCH" }, | |
142 #endif | |
143 #ifdef LANG_ENGLISH | |
144 { LANG_ENGLISH, "ENGLISH" }, | |
145 #endif | |
146 #ifdef LANG_ESTONIAN | |
147 { LANG_ESTONIAN, "ESTONIAN" }, | |
148 #endif | |
149 #ifdef LANG_FAEROESE | |
150 { LANG_FAEROESE, "FAEROESE" }, | |
151 #endif | |
152 #ifdef LANG_FARSI | |
153 { LANG_FARSI, "FARSI" }, | |
154 #endif | |
155 #ifdef LANG_FINNISH | |
156 { LANG_FINNISH, "FINNISH" }, | |
157 #endif | |
158 #ifdef LANG_FRENCH | |
159 { LANG_FRENCH, "FRENCH" }, | |
160 #endif | |
161 #ifdef LANG_GEORGIAN | |
162 { LANG_GEORGIAN, "GEORGIAN" }, | |
163 #endif | |
164 #ifdef LANG_GERMAN | |
165 { LANG_GERMAN, "GERMAN" }, | |
166 #endif | |
167 #ifdef LANG_GREEK | |
168 { LANG_GREEK, "GREEK" }, | |
169 #endif | |
170 #ifdef LANG_GUJARATI | |
171 { LANG_GUJARATI, "GUJARATI" }, | |
172 #endif | |
173 #ifdef LANG_HEBREW | |
174 { LANG_HEBREW, "HEBREW" }, | |
175 #endif | |
176 #ifdef LANG_HINDI | |
177 { LANG_HINDI, "HINDI" }, | |
178 #endif | |
179 #ifdef LANG_HUNGARIAN | |
180 { LANG_HUNGARIAN, "HUNGARIAN" }, | |
181 #endif | |
182 #ifdef LANG_ICELANDIC | |
183 { LANG_ICELANDIC, "ICELANDIC" }, | |
184 #endif | |
185 #ifdef LANG_INDONESIAN | |
186 { LANG_INDONESIAN, "INDONESIAN" }, | |
187 #endif | |
188 #ifdef LANG_ITALIAN | |
189 { LANG_ITALIAN, "ITALIAN" }, | |
190 #endif | |
191 #ifdef LANG_JAPANESE | |
192 { LANG_JAPANESE, "JAPANESE" }, | |
193 #endif | |
194 #ifdef LANG_KANNADA | |
195 { LANG_KANNADA, "KANNADA" }, | |
196 #endif | |
197 #ifdef LANG_KASHMIRI | |
198 { LANG_KASHMIRI, "KASHMIRI" }, | |
199 #endif | |
200 #ifdef LANG_KAZAK | |
201 { LANG_KAZAK, "KAZAK" }, | |
202 #endif | |
203 #ifdef LANG_KONKANI | |
204 { LANG_KONKANI, "KONKANI" }, | |
205 #endif | |
206 #ifdef LANG_KOREAN | |
207 { LANG_KOREAN, "KOREAN" }, | |
208 #endif | |
209 #ifdef LANG_LATVIAN | |
210 { LANG_LATVIAN, "LATVIAN" }, | |
211 #endif | |
212 #ifdef LANG_LITHUANIAN | |
213 { LANG_LITHUANIAN, "LITHUANIAN" }, | |
214 #endif | |
215 #ifdef LANG_MACEDONIAN | |
216 { LANG_MACEDONIAN, "MACEDONIAN" }, | |
217 #endif | |
218 #ifdef LANG_MALAY | |
219 { LANG_MALAY, "MALAY" }, | |
220 #endif | |
221 #ifdef LANG_MALAYALAM | |
222 { LANG_MALAYALAM, "MALAYALAM" }, | |
223 #endif | |
224 #ifdef LANG_MANIPURI | |
225 { LANG_MANIPURI, "MANIPURI" }, | |
226 #endif | |
227 #ifdef LANG_MARATHI | |
228 { LANG_MARATHI, "MARATHI" }, | |
229 #endif | |
230 #ifdef LANG_NEPALI | |
231 { LANG_NEPALI, "NEPALI" }, | |
232 #endif | |
233 #ifdef LANG_NEUTRAL | |
234 { LANG_NEUTRAL, "NEUTRAL" }, | |
235 #endif | |
236 #ifdef LANG_NORWEGIAN | |
237 { LANG_NORWEGIAN, "NORWEGIAN" }, | |
238 #endif | |
239 #ifdef LANG_ORIYA | |
240 { LANG_ORIYA, "ORIYA" }, | |
241 #endif | |
242 #ifdef LANG_POLISH | |
243 { LANG_POLISH, "POLISH" }, | |
244 #endif | |
245 #ifdef LANG_PORTUGUESE | |
246 { LANG_PORTUGUESE, "PORTUGUESE" }, | |
247 #endif | |
248 #ifdef LANG_PUNJABI | |
249 { LANG_PUNJABI, "PUNJABI" }, | |
250 #endif | |
251 #ifdef LANG_ROMANIAN | |
252 { LANG_ROMANIAN, "ROMANIAN" }, | |
253 #endif | |
254 #ifdef LANG_RUSSIAN | |
255 { LANG_RUSSIAN, "RUSSIAN" }, | |
256 #endif | |
257 #ifdef LANG_SANSKRIT | |
258 { LANG_SANSKRIT, "SANSKRIT" }, | |
259 #endif | |
260 #ifdef LANG_SERBIAN | |
261 { LANG_SERBIAN, "SERBIAN" }, | |
262 #endif | |
263 #ifdef LANG_SINDHI | |
264 { LANG_SINDHI, "SINDHI" }, | |
265 #endif | |
266 #ifdef LANG_SLOVAK | |
267 { LANG_SLOVAK, "SLOVAK" }, | |
268 #endif | |
269 #ifdef LANG_SLOVENIAN | |
270 { LANG_SLOVENIAN, "SLOVENIAN" }, | |
271 #endif | |
272 #ifdef LANG_SPANISH | |
273 { LANG_SPANISH, "SPANISH" }, | |
274 #endif | |
275 #ifdef LANG_SWAHILI | |
276 { LANG_SWAHILI, "SWAHILI" }, | |
277 #endif | |
278 #ifdef LANG_SWEDISH | |
279 { LANG_SWEDISH, "SWEDISH" }, | |
280 #endif | |
281 #ifdef LANG_TAMIL | |
282 { LANG_TAMIL, "TAMIL" }, | |
283 #endif | |
284 #ifdef LANG_TATAR | |
285 { LANG_TATAR, "TATAR" }, | |
286 #endif | |
287 #ifdef LANG_TELUGU | |
288 { LANG_TELUGU, "TELUGU" }, | |
289 #endif | |
290 #ifdef LANG_THAI | |
291 { LANG_THAI, "THAI" }, | |
292 #endif | |
293 #ifdef LANG_TURKISH | |
294 { LANG_TURKISH, "TURKISH" }, | |
295 #endif | |
296 #ifdef LANG_UKRAINIAN | |
297 { LANG_UKRAINIAN, "UKRAINIAN" }, | |
298 #endif | |
299 #ifdef LANG_URDU | |
300 { LANG_URDU, "URDU" }, | |
301 #endif | |
302 #ifdef LANG_UZBEK | |
303 { LANG_UZBEK, "UZBEK" }, | |
304 #endif | |
305 #ifdef LANG_VIETNAMESE | |
306 { LANG_VIETNAMESE, "VIETNAMESE" }, | |
307 #endif | |
308 }; | |
309 | |
310 struct lang_to_string sublang_to_string_table[] = | |
311 { | |
312 { LANG_ARABIC, 0 }, | |
313 #ifdef SUBLANG_ARABIC_ALGERIA | |
314 { SUBLANG_ARABIC_ALGERIA, "ARABIC_ALGERIA" }, | |
315 #endif | |
316 #ifdef SUBLANG_ARABIC_BAHRAIN | |
317 { SUBLANG_ARABIC_BAHRAIN, "ARABIC_BAHRAIN" }, | |
318 #endif | |
319 #ifdef SUBLANG_ARABIC_EGYPT | |
320 { SUBLANG_ARABIC_EGYPT, "ARABIC_EGYPT" }, | |
321 #endif | |
322 #ifdef SUBLANG_ARABIC_IRAQ | |
323 { SUBLANG_ARABIC_IRAQ, "ARABIC_IRAQ" }, | |
324 #endif | |
325 #ifdef SUBLANG_ARABIC_JORDAN | |
326 { SUBLANG_ARABIC_JORDAN, "ARABIC_JORDAN" }, | |
327 #endif | |
328 #ifdef SUBLANG_ARABIC_KUWAIT | |
329 { SUBLANG_ARABIC_KUWAIT, "ARABIC_KUWAIT" }, | |
330 #endif | |
331 #ifdef SUBLANG_ARABIC_LEBANON | |
332 { SUBLANG_ARABIC_LEBANON, "ARABIC_LEBANON" }, | |
333 #endif | |
334 #ifdef SUBLANG_ARABIC_LIBYA | |
335 { SUBLANG_ARABIC_LIBYA, "ARABIC_LIBYA" }, | |
336 #endif | |
337 #ifdef SUBLANG_ARABIC_MOROCCO | |
338 { SUBLANG_ARABIC_MOROCCO, "ARABIC_MOROCCO" }, | |
339 #endif | |
340 #ifdef SUBLANG_ARABIC_OMAN | |
341 { SUBLANG_ARABIC_OMAN, "ARABIC_OMAN" }, | |
342 #endif | |
343 #ifdef SUBLANG_ARABIC_QATAR | |
344 { SUBLANG_ARABIC_QATAR, "ARABIC_QATAR" }, | |
345 #endif | |
346 #ifdef SUBLANG_ARABIC_SAUDI_ARABIA | |
347 { SUBLANG_ARABIC_SAUDI_ARABIA, "ARABIC_SAUDI_ARABIA" }, | |
348 #endif | |
349 #ifdef SUBLANG_ARABIC_SYRIA | |
350 { SUBLANG_ARABIC_SYRIA, "ARABIC_SYRIA" }, | |
351 #endif | |
352 #ifdef SUBLANG_ARABIC_TUNISIA | |
353 { SUBLANG_ARABIC_TUNISIA, "ARABIC_TUNISIA" }, | |
354 #endif | |
355 #ifdef SUBLANG_ARABIC_UAE | |
356 { SUBLANG_ARABIC_UAE, "ARABIC_UAE" }, | |
357 #endif | |
358 #ifdef SUBLANG_ARABIC_YEMEN | |
359 { SUBLANG_ARABIC_YEMEN, "ARABIC_YEMEN" }, | |
360 #endif | |
361 { LANG_AZERI, 0 }, | |
362 #ifdef SUBLANG_AZERI_CYRILLIC | |
363 { SUBLANG_AZERI_CYRILLIC, "AZERI_CYRILLIC" }, | |
364 #endif | |
365 #ifdef SUBLANG_AZERI_LATIN | |
366 { SUBLANG_AZERI_LATIN, "AZERI_LATIN" }, | |
367 #endif | |
368 { LANG_CHINESE, 0 }, | |
369 #ifdef SUBLANG_CHINESE_HONGKONG | |
370 { SUBLANG_CHINESE_HONGKONG, "CHINESE_HONGKONG" }, | |
371 #endif | |
372 #ifdef SUBLANG_CHINESE_MACAU | |
373 { SUBLANG_CHINESE_MACAU, "CHINESE_MACAU" }, | |
374 #endif | |
375 #ifdef SUBLANG_CHINESE_SIMPLIFIED | |
376 { SUBLANG_CHINESE_SIMPLIFIED, "CHINESE_SIMPLIFIED" }, | |
377 #endif | |
378 #ifdef SUBLANG_CHINESE_SINGAPORE | |
379 { SUBLANG_CHINESE_SINGAPORE, "CHINESE_SINGAPORE" }, | |
380 #endif | |
381 #ifdef SUBLANG_CHINESE_TRADITIONAL | |
382 { SUBLANG_CHINESE_TRADITIONAL, "CHINESE_TRADITIONAL" }, | |
383 #endif | |
384 { LANG_DUTCH, 0 }, | |
385 #ifdef SUBLANG_DUTCH | |
386 { SUBLANG_DUTCH, "DUTCH" }, | |
387 #endif | |
388 #ifdef SUBLANG_DUTCH_BELGIAN | |
389 { SUBLANG_DUTCH_BELGIAN, "DUTCH_BELGIAN" }, | |
390 #endif | |
391 { LANG_ENGLISH, 0 }, | |
392 #ifdef SUBLANG_ENGLISH_AUS | |
393 { SUBLANG_ENGLISH_AUS, "ENGLISH_AUS" }, | |
394 #endif | |
395 #ifdef SUBLANG_ENGLISH_BELIZE | |
396 { SUBLANG_ENGLISH_BELIZE, "ENGLISH_BELIZE" }, | |
397 #endif | |
398 #ifdef SUBLANG_ENGLISH_CAN | |
399 { SUBLANG_ENGLISH_CAN, "ENGLISH_CAN" }, | |
400 #endif | |
401 #ifdef SUBLANG_ENGLISH_CARIBBEAN | |
402 { SUBLANG_ENGLISH_CARIBBEAN, "ENGLISH_CARIBBEAN" }, | |
403 #endif | |
404 #ifdef SUBLANG_ENGLISH_EIRE | |
405 { SUBLANG_ENGLISH_EIRE, "ENGLISH_EIRE" }, | |
406 #endif | |
407 #ifdef SUBLANG_ENGLISH_JAMAICA | |
408 { SUBLANG_ENGLISH_JAMAICA, "ENGLISH_JAMAICA" }, | |
409 #endif | |
410 #ifdef SUBLANG_ENGLISH_NZ | |
411 { SUBLANG_ENGLISH_NZ, "ENGLISH_NZ" }, | |
412 #endif | |
413 #ifdef SUBLANG_ENGLISH_PHILIPPINES | |
414 { SUBLANG_ENGLISH_PHILIPPINES, "ENGLISH_PHILIPPINES" }, | |
415 #endif | |
416 #ifdef SUBLANG_ENGLISH_SOUTH_AFRICA | |
417 { SUBLANG_ENGLISH_SOUTH_AFRICA, "ENGLISH_SOUTH_AFRICA" }, | |
418 #endif | |
419 #ifdef SUBLANG_ENGLISH_TRINIDAD | |
420 { SUBLANG_ENGLISH_TRINIDAD, "ENGLISH_TRINIDAD" }, | |
421 #endif | |
422 #ifdef SUBLANG_ENGLISH_UK | |
423 { SUBLANG_ENGLISH_UK, "ENGLISH_UK" }, | |
424 #endif | |
425 #ifdef SUBLANG_ENGLISH_US | |
426 { SUBLANG_ENGLISH_US, "ENGLISH_US" }, | |
427 #endif | |
428 #ifdef SUBLANG_ENGLISH_ZIMBABWE | |
429 { SUBLANG_ENGLISH_ZIMBABWE, "ENGLISH_ZIMBABWE" }, | |
430 #endif | |
431 { LANG_FRENCH, 0 }, | |
432 #ifdef SUBLANG_FRENCH | |
433 { SUBLANG_FRENCH, "FRENCH" }, | |
434 #endif | |
435 #ifdef SUBLANG_FRENCH_BELGIAN | |
436 { SUBLANG_FRENCH_BELGIAN, "FRENCH_BELGIAN" }, | |
437 #endif | |
438 #ifdef SUBLANG_FRENCH_CANADIAN | |
439 { SUBLANG_FRENCH_CANADIAN, "FRENCH_CANADIAN" }, | |
440 #endif | |
441 #ifdef SUBLANG_FRENCH_LUXEMBOURG | |
442 { SUBLANG_FRENCH_LUXEMBOURG, "FRENCH_LUXEMBOURG" }, | |
443 #endif | |
444 #ifdef SUBLANG_FRENCH_MONACO | |
445 { SUBLANG_FRENCH_MONACO, "FRENCH_MONACO" }, | |
446 #endif | |
447 #ifdef SUBLANG_FRENCH_SWISS | |
448 { SUBLANG_FRENCH_SWISS, "FRENCH_SWISS" }, | |
449 #endif | |
450 { LANG_GERMAN, 0 }, | |
451 #ifdef SUBLANG_GERMAN | |
452 { SUBLANG_GERMAN, "GERMAN" }, | |
453 #endif | |
454 #ifdef SUBLANG_GERMAN_AUSTRIAN | |
455 { SUBLANG_GERMAN_AUSTRIAN, "GERMAN_AUSTRIAN" }, | |
456 #endif | |
457 #ifdef SUBLANG_GERMAN_LIECHTENSTEIN | |
458 { SUBLANG_GERMAN_LIECHTENSTEIN, "GERMAN_LIECHTENSTEIN" }, | |
459 #endif | |
460 #ifdef SUBLANG_GERMAN_LUXEMBOURG | |
461 { SUBLANG_GERMAN_LUXEMBOURG, "GERMAN_LUXEMBOURG" }, | |
462 #endif | |
463 #ifdef SUBLANG_GERMAN_SWISS | |
464 { SUBLANG_GERMAN_SWISS, "GERMAN_SWISS" }, | |
465 #endif | |
466 { LANG_ITALIAN, 0 }, | |
467 #ifdef SUBLANG_ITALIAN | |
468 { SUBLANG_ITALIAN, "ITALIAN" }, | |
469 #endif | |
470 #ifdef SUBLANG_ITALIAN_SWISS | |
471 { SUBLANG_ITALIAN_SWISS, "ITALIAN_SWISS" }, | |
472 #endif | |
473 { LANG_KASHMIRI, 0 }, | |
474 #ifdef SUBLANG_KASHMIRI_INDIA | |
475 { SUBLANG_KASHMIRI_INDIA, "KASHMIRI_INDIA" }, | |
476 #endif | |
477 { LANG_KOREAN, 0 }, | |
478 #ifdef SUBLANG_KOREAN | |
479 { SUBLANG_KOREAN, "KOREAN" }, | |
480 #endif | |
481 #ifdef SUBLANG_KOREAN_JOHAB | |
482 /* NOTE: Omitted in more recent versions of VC++ (e.g. v6.0) */ | |
483 { SUBLANG_KOREAN_JOHAB, "KOREAN_JOHAB" }, | |
484 #endif | |
485 { LANG_LITHUANIAN, 0 }, | |
486 #ifdef SUBLANG_LITHUANIAN | |
487 { SUBLANG_LITHUANIAN, "LITHUANIAN" }, | |
488 #endif | |
489 #ifdef SUBLANG_LITHUANIAN_CLASSIC | |
490 { SUBLANG_LITHUANIAN_CLASSIC, "LITHUANIAN_CLASSIC" }, | |
491 #endif | |
492 { LANG_MALAY, 0 }, | |
493 #ifdef SUBLANG_MALAY_BRUNEI_DARUSSALAM | |
494 { SUBLANG_MALAY_BRUNEI_DARUSSALAM, "MALAY_BRUNEI_DARUSSALAM" }, | |
495 #endif | |
496 #ifdef SUBLANG_MALAY_MALAYSIA | |
497 { SUBLANG_MALAY_MALAYSIA, "MALAY_MALAYSIA" }, | |
498 #endif | |
499 { LANG_NEPALI, 0 }, | |
500 #ifdef SUBLANG_NEPALI_INDIA | |
501 { SUBLANG_NEPALI_INDIA, "NEPALI_INDIA" }, | |
502 #endif | |
503 { LANG_NEUTRAL, 0 }, | |
504 #ifdef SUBLANG_NEUTRAL | |
505 { SUBLANG_NEUTRAL, "NEUTRAL" }, | |
506 #endif | |
507 { LANG_NORWEGIAN, 0 }, | |
508 #ifdef SUBLANG_NORWEGIAN_BOKMAL | |
509 { SUBLANG_NORWEGIAN_BOKMAL, "NORWEGIAN_BOKMAL" }, | |
510 #endif | |
511 #ifdef SUBLANG_NORWEGIAN_NYNORSK | |
512 { SUBLANG_NORWEGIAN_NYNORSK, "NORWEGIAN_NYNORSK" }, | |
513 #endif | |
514 { LANG_PORTUGUESE, 0 }, | |
515 #ifdef SUBLANG_PORTUGUESE | |
516 { SUBLANG_PORTUGUESE, "PORTUGUESE" }, | |
517 #endif | |
518 #ifdef SUBLANG_PORTUGUESE_BRAZILIAN | |
519 { SUBLANG_PORTUGUESE_BRAZILIAN, "PORTUGUESE_BRAZILIAN" }, | |
520 #endif | |
521 { LANG_SERBIAN, 0 }, | |
522 #ifdef SUBLANG_SERBIAN_CYRILLIC | |
523 { SUBLANG_SERBIAN_CYRILLIC, "SERBIAN_CYRILLIC" }, | |
524 #endif | |
525 #ifdef SUBLANG_SERBIAN_LATIN | |
526 { SUBLANG_SERBIAN_LATIN, "SERBIAN_LATIN" }, | |
527 #endif | |
528 { LANG_SPANISH, 0 }, | |
529 #ifdef SUBLANG_SPANISH | |
530 { SUBLANG_SPANISH, "SPANISH" }, | |
531 #endif | |
532 #ifdef SUBLANG_SPANISH_ARGENTINA | |
533 { SUBLANG_SPANISH_ARGENTINA, "SPANISH_ARGENTINA" }, | |
534 #endif | |
535 #ifdef SUBLANG_SPANISH_BOLIVIA | |
536 { SUBLANG_SPANISH_BOLIVIA, "SPANISH_BOLIVIA" }, | |
537 #endif | |
538 #ifdef SUBLANG_SPANISH_CHILE | |
539 { SUBLANG_SPANISH_CHILE, "SPANISH_CHILE" }, | |
540 #endif | |
541 #ifdef SUBLANG_SPANISH_COLOMBIA | |
542 { SUBLANG_SPANISH_COLOMBIA, "SPANISH_COLOMBIA" }, | |
543 #endif | |
544 #ifdef SUBLANG_SPANISH_COSTA_RICA | |
545 { SUBLANG_SPANISH_COSTA_RICA, "SPANISH_COSTA_RICA" }, | |
546 #endif | |
547 #ifdef SUBLANG_SPANISH_DOMINICAN_REPUBLIC | |
548 { SUBLANG_SPANISH_DOMINICAN_REPUBLIC, "SPANISH_DOMINICAN_REPUBLIC" }, | |
549 #endif | |
550 #ifdef SUBLANG_SPANISH_ECUADOR | |
551 { SUBLANG_SPANISH_ECUADOR, "SPANISH_ECUADOR" }, | |
552 #endif | |
553 #ifdef SUBLANG_SPANISH_EL_SALVADOR | |
554 { SUBLANG_SPANISH_EL_SALVADOR, "SPANISH_EL_SALVADOR" }, | |
555 #endif | |
556 #ifdef SUBLANG_SPANISH_GUATEMALA | |
557 { SUBLANG_SPANISH_GUATEMALA, "SPANISH_GUATEMALA" }, | |
558 #endif | |
559 #ifdef SUBLANG_SPANISH_HONDURAS | |
560 { SUBLANG_SPANISH_HONDURAS, "SPANISH_HONDURAS" }, | |
561 #endif | |
562 #ifdef SUBLANG_SPANISH_MEXICAN | |
563 { SUBLANG_SPANISH_MEXICAN, "SPANISH_MEXICAN" }, | |
564 #endif | |
565 #ifdef SUBLANG_SPANISH_MODERN | |
566 { SUBLANG_SPANISH_MODERN, "SPANISH_MODERN" }, | |
567 #endif | |
568 #ifdef SUBLANG_SPANISH_NICARAGUA | |
569 { SUBLANG_SPANISH_NICARAGUA, "SPANISH_NICARAGUA" }, | |
570 #endif | |
571 #ifdef SUBLANG_SPANISH_PANAMA | |
572 { SUBLANG_SPANISH_PANAMA, "SPANISH_PANAMA" }, | |
573 #endif | |
574 #ifdef SUBLANG_SPANISH_PARAGUAY | |
575 { SUBLANG_SPANISH_PARAGUAY, "SPANISH_PARAGUAY" }, | |
576 #endif | |
577 #ifdef SUBLANG_SPANISH_PERU | |
578 { SUBLANG_SPANISH_PERU, "SPANISH_PERU" }, | |
579 #endif | |
580 #ifdef SUBLANG_SPANISH_PUERTO_RICO | |
581 { SUBLANG_SPANISH_PUERTO_RICO, "SPANISH_PUERTO_RICO" }, | |
582 #endif | |
583 #ifdef SUBLANG_SPANISH_URUGUAY | |
584 { SUBLANG_SPANISH_URUGUAY, "SPANISH_URUGUAY" }, | |
585 #endif | |
586 #ifdef SUBLANG_SPANISH_VENEZUELA | |
587 { SUBLANG_SPANISH_VENEZUELA, "SPANISH_VENEZUELA" }, | |
588 #endif | |
589 { LANG_SWEDISH, 0 }, | |
590 #ifdef SUBLANG_SWEDISH | |
591 { SUBLANG_SWEDISH, "SWEDISH" }, | |
592 #endif | |
593 #ifdef SUBLANG_SWEDISH_FINLAND | |
594 { SUBLANG_SWEDISH_FINLAND, "SWEDISH_FINLAND" }, | |
595 #endif | |
596 { LANG_URDU, 0 }, | |
597 #ifdef SUBLANG_URDU_INDIA | |
598 { SUBLANG_URDU_INDIA, "URDU_INDIA" }, | |
599 #endif | |
600 #ifdef SUBLANG_URDU_PAKISTAN | |
601 { SUBLANG_URDU_PAKISTAN, "URDU_PAKISTAN" }, | |
602 #endif | |
603 { LANG_UZBEK, 0 }, | |
604 #ifdef SUBLANG_UZBEK_CYRILLIC | |
605 { SUBLANG_UZBEK_CYRILLIC, "UZBEK_CYRILLIC" }, | |
606 #endif | |
607 #ifdef SUBLANG_UZBEK_LATIN | |
608 { SUBLANG_UZBEK_LATIN, "UZBEK_LATIN" }, | |
609 #endif | |
610 }; | |
611 | |
612 static int | |
613 lang_to_langcode (Lisp_Object lang, struct lang_to_string *table, | |
614 int table_size) | |
615 { | |
616 int i; | |
617 | |
618 for (i = 0; i < table_size; i++) | |
2367 | 619 if (!qxestrcmp_ascii (XSTRING_DATA (lang), table[i].string)) |
771 | 620 return table[i].code; |
621 return -1; | |
622 } | |
623 | |
624 static int | |
625 sublang_to_langcode (Lisp_Object lang, struct lang_to_string *table, | |
626 int table_size) | |
627 { | |
628 int i; | |
629 | |
630 for (i = 0; i < table_size; i++) | |
631 if (table[i].string && | |
2367 | 632 !qxestrcmp_ascii (XSTRING_DATA (lang), table[i].string)) |
771 | 633 return table[i].code; |
634 | |
2367 | 635 if (!qxestrcmp_ascii (XSTRING_DATA (lang), "NEUTRAL")) |
771 | 636 return SUBLANG_NEUTRAL; |
2367 | 637 if (!qxestrcmp_ascii (XSTRING_DATA (lang), "DEFAULT")) |
771 | 638 return SUBLANG_DEFAULT; |
2367 | 639 if (!qxestrcmp_ascii (XSTRING_DATA (lang), "SYS_DEFAULT")) |
771 | 640 return SUBLANG_SYS_DEFAULT; |
641 | |
642 return -1; | |
643 } | |
644 | |
645 static Lisp_Object | |
646 langcode_to_lang (int code, struct lang_to_string *table, | |
647 int table_size) | |
648 { | |
649 int i; | |
650 | |
651 for (i = 0; i < table_size; i++) | |
652 if (code == table[i].code) | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
653 return build_ascstring (table[i].string); |
771 | 654 return Qnil; |
655 } | |
656 | |
657 static Lisp_Object | |
658 sublangcode_to_lang (int lang, int sublang, struct lang_to_string *table, | |
659 int table_size) | |
660 { | |
661 int i; | |
662 int found_lang = 0; | |
663 | |
664 for (i = 0; i < table_size; i++) | |
665 { | |
666 if (found_lang) | |
667 { | |
668 if (!table[i].string) | |
669 break; | |
670 if (sublang == table[i].code) | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
671 return build_ascstring (table[i].string); |
771 | 672 } |
673 else if (!table[i].string && lang == table[i].code) | |
674 found_lang = 1; | |
675 } | |
676 | |
677 switch (sublang) | |
678 { | |
679 case SUBLANG_NEUTRAL: | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
680 return build_ascstring ("NEUTRAL"); |
771 | 681 case SUBLANG_DEFAULT: |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
682 return build_ascstring ("DEFAULT"); |
771 | 683 case SUBLANG_SYS_DEFAULT: |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
684 return build_ascstring ("SYS_DEFAULT"); |
771 | 685 } |
686 | |
687 return Qnil; | |
688 } | |
689 | |
690 static LCID | |
691 locale_to_lcid (Lisp_Object locale) | |
692 { | |
693 int langcode, sublangcode; | |
694 Lisp_Object lang, sublang; | |
695 | |
696 if (STRINGP (locale)) | |
697 { | |
698 lang = locale; | |
699 sublang = Qnil; | |
700 } | |
701 else if (CONSP (locale)) | |
702 { | |
703 CHECK_STRING (XCAR (locale)); | |
704 CHECK_STRING (XCDR (locale)); | |
705 lang = XCAR (locale); | |
706 sublang = XCDR (locale); | |
707 } | |
708 else | |
709 invalid_argument ("Locale must be LANG or (LANG . SUBLANG)", locale); | |
710 | |
711 langcode = lang_to_langcode (lang, lang_to_string_table, | |
712 countof (lang_to_string_table)); | |
713 | |
714 if (langcode < 0) | |
715 invalid_constant ("Unrecognized language", lang); | |
716 | |
717 if (!NILP (sublang)) | |
718 { | |
719 sublangcode = sublang_to_langcode (sublang, sublang_to_string_table, | |
720 countof (sublang_to_string_table)); | |
721 if (sublangcode < 0) | |
722 invalid_constant ("Unrecognized sublanguage", sublang); | |
723 } | |
724 else | |
725 sublangcode = SUBLANG_DEFAULT; | |
726 | |
727 return MAKELCID (MAKELANGID (langcode, sublangcode), | |
728 SORT_DEFAULT); | |
729 } | |
730 | |
731 static Lisp_Object | |
732 lcid_to_locale (LCID lcid) | |
733 { | |
734 int langid = LANGIDFROMLCID (lcid); | |
735 int langcode = PRIMARYLANGID (langid); | |
736 int sublangcode = SUBLANGID (langid); | |
737 | |
738 return Fcons (langcode_to_lang (langcode, lang_to_string_table, | |
739 countof (lang_to_string_table)), | |
740 sublangcode_to_lang (langcode, sublangcode, | |
741 sublang_to_string_table, | |
742 countof (sublang_to_string_table))); | |
743 } | |
744 | |
745 int | |
746 mswindows_locale_to_code_page (LCID lcid) | |
747 { | |
748 char codepagestr[10]; | |
749 | |
750 GetLocaleInfoA (lcid, LOCALE_IDEFAULTANSICODEPAGE, codepagestr, 10); | |
751 return atoi (codepagestr); | |
752 } | |
753 | |
754 int | |
755 mswindows_locale_to_oem_code_page (LCID lcid) | |
756 { | |
757 char codepagestr[10]; | |
758 | |
759 GetLocaleInfoA (lcid, LOCALE_IDEFAULTCODEPAGE, codepagestr, 10); | |
760 return atoi (codepagestr); | |
761 } | |
762 | |
763 static void | |
764 set_current_lcid (LCID lcid) | |
765 { | |
766 int cp; | |
767 | |
768 /* This will fail under Win9x, so we remember our own locale rather than | |
769 consulting GetThreadLocale. */ | |
770 SetThreadLocale (lcid); | |
771 current_locale = lcid; | |
772 cp = mswindows_locale_to_code_page (lcid); | |
773 #ifndef NO_EXT_MULTIBYTE_FEATURES | |
774 _setmbcp (cp); | |
775 #endif | |
776 } | |
777 | |
778 DEFUN ("mswindows-set-current-locale", Fmswindows_set_current_locale, | |
779 1, 1, 0, /* | |
780 Set the current MS Windows locale. | |
781 | |
782 LOCALE should a language string, or a cons (LANG . SUBLANG). | |
783 If SUBLANG is omitted, "SUBLANG_DEFAULT" is used. | |
784 | |
785 Recognized language names are | |
3767 | 786 \(some may not be recognized if the compiler is older than VC++ 6.0) |
771 | 787 |
788 "AFRIKAANS" | |
789 "ALBANIAN" | |
790 "ARABIC" | |
791 "ARMENIAN" | |
792 "ASSAMESE" | |
793 "AZERI" | |
794 "BASQUE" | |
795 "BELARUSIAN" | |
796 "BENGALI" | |
797 "BULGARIAN" | |
798 "CATALAN" | |
799 "CHINESE" | |
800 "CROATIAN" | |
801 "CZECH" | |
802 "DANISH" | |
803 "DUTCH" | |
804 "ENGLISH" | |
805 "ESTONIAN" | |
806 "FAEROESE" | |
807 "FARSI" | |
808 "FINNISH" | |
809 "FRENCH" | |
810 "GEORGIAN" | |
811 "GERMAN" | |
812 "GREEK" | |
813 "GUJARATI" | |
814 "HEBREW" | |
815 "HINDI" | |
816 "HUNGARIAN" | |
817 "ICELANDIC" | |
818 "INDONESIAN" | |
819 "ITALIAN" | |
820 "JAPANESE" | |
821 "KANNADA" | |
822 "KASHMIRI" | |
823 "KAZAK" | |
824 "KONKANI" | |
825 "KOREAN" | |
826 "LATVIAN" | |
827 "LITHUANIAN" | |
828 "MACEDONIAN" | |
829 "MALAY" | |
830 "MALAYALAM" | |
831 "MANIPURI" | |
832 "MARATHI" | |
833 "NEPALI" | |
834 "NEUTRAL" | |
835 "NORWEGIAN" | |
836 "ORIYA" | |
837 "POLISH" | |
838 "PORTUGUESE" | |
839 "PUNJABI" | |
840 "ROMANIAN" | |
841 "RUSSIAN" | |
842 "SANSKRIT" | |
843 "SERBIAN" | |
844 "SINDHI" | |
845 "SLOVAK" | |
846 "SLOVENIAN" | |
847 "SPANISH" | |
848 "SWAHILI" | |
849 "SWEDISH" | |
850 "TAMIL" | |
851 "TATAR" | |
852 "TELUGU" | |
853 "THAI" | |
854 "TURKISH" | |
855 "UKRAINIAN" | |
856 "URDU" | |
857 "UZBEK" | |
858 "VIETNAMESE" | |
859 | |
860 Recognized sub-language names are | |
3767 | 861 \(some may not be recognized if the compiler is older than VC++ 6.0) |
771 | 862 |
863 "ARABIC_ALGERIA" | |
864 "ARABIC_BAHRAIN" | |
865 "ARABIC_EGYPT" | |
866 "ARABIC_IRAQ" | |
867 "ARABIC_JORDAN" | |
868 "ARABIC_KUWAIT" | |
869 "ARABIC_LEBANON" | |
870 "ARABIC_LIBYA" | |
871 "ARABIC_MOROCCO" | |
872 "ARABIC_OMAN" | |
873 "ARABIC_QATAR" | |
874 "ARABIC_SAUDI_ARABIA" | |
875 "ARABIC_SYRIA" | |
876 "ARABIC_TUNISIA" | |
877 "ARABIC_UAE" | |
878 "ARABIC_YEMEN" | |
879 "AZERI_CYRILLIC" | |
880 "AZERI_LATIN" | |
881 "CHINESE_HONGKONG" | |
882 "CHINESE_MACAU" | |
883 "CHINESE_SIMPLIFIED" | |
884 "CHINESE_SINGAPORE" | |
885 "CHINESE_TRADITIONAL" | |
886 "DEFAULT" | |
887 "DUTCH" | |
888 "DUTCH_BELGIAN" | |
889 "ENGLISH_AUS" | |
890 "ENGLISH_BELIZE" | |
891 "ENGLISH_CAN" | |
892 "ENGLISH_CARIBBEAN" | |
893 "ENGLISH_EIRE" | |
894 "ENGLISH_JAMAICA" | |
895 "ENGLISH_NZ" | |
896 "ENGLISH_PHILIPPINES" | |
897 "ENGLISH_SOUTH_AFRICA" | |
898 "ENGLISH_TRINIDAD" | |
899 "ENGLISH_UK" | |
900 "ENGLISH_US" | |
901 "ENGLISH_ZIMBABWE" | |
902 "FRENCH" | |
903 "FRENCH_BELGIAN" | |
904 "FRENCH_CANADIAN" | |
905 "FRENCH_LUXEMBOURG" | |
906 "FRENCH_MONACO" | |
907 "FRENCH_SWISS" | |
908 "GERMAN" | |
909 "GERMAN_AUSTRIAN" | |
910 "GERMAN_LIECHTENSTEIN" | |
911 "GERMAN_LUXEMBOURG" | |
912 "GERMAN_SWISS" | |
913 "ITALIAN" | |
914 "ITALIAN_SWISS" | |
915 "KASHMIRI_INDIA" | |
916 "KOREAN" | |
917 "KOREAN_JOHAB" (NOTE: omitted in Visual C++ 6.0 and later) | |
918 "LITHUANIAN" | |
919 "LITHUANIAN_CLASSIC" | |
920 "MALAY_BRUNEI_DARUSSALAM" | |
921 "MALAY_MALAYSIA" | |
922 "NEPALI_INDIA" | |
923 "NEUTRAL" | |
924 "NORWEGIAN_BOKMAL" | |
925 "NORWEGIAN_NYNORSK" | |
926 "PORTUGUESE" | |
927 "PORTUGUESE_BRAZILIAN" | |
928 "SERBIAN_CYRILLIC" | |
929 "SERBIAN_LATIN" | |
930 "SPANISH" | |
931 "SPANISH_ARGENTINA" | |
932 "SPANISH_BOLIVIA" | |
933 "SPANISH_CHILE" | |
934 "SPANISH_COLOMBIA" | |
935 "SPANISH_COSTA_RICA" | |
936 "SPANISH_DOMINICAN_REPUBLIC" | |
937 "SPANISH_ECUADOR" | |
938 "SPANISH_EL_SALVADOR" | |
939 "SPANISH_GUATEMALA" | |
940 "SPANISH_HONDURAS" | |
941 "SPANISH_MEXICAN" | |
942 "SPANISH_MODERN" | |
943 "SPANISH_NICARAGUA" | |
944 "SPANISH_PANAMA" | |
945 "SPANISH_PARAGUAY" | |
946 "SPANISH_PERU" | |
947 "SPANISH_PUERTO_RICO" | |
948 "SPANISH_URUGUAY" | |
949 "SPANISH_VENEZUELA" | |
950 "SWEDISH" | |
951 "SWEDISH_FINLAND" | |
952 "SYS_DEFAULT" | |
953 "URDU_INDIA" | |
954 "URDU_PAKISTAN" | |
955 "UZBEK_CYRILLIC" | |
956 "UZBEK_LATIN" | |
957 */ | |
958 (locale)) | |
959 { | |
960 LCID lcid = locale_to_lcid (locale); | |
961 | |
962 set_current_lcid (lcid); | |
963 return Qnil; | |
964 } | |
965 | |
966 #ifdef DEBUG_XEMACS | |
967 | |
872 | 968 int getacp (void); |
771 | 969 int |
970 getacp (void) | |
971 { | |
972 return GetACP (); | |
973 } | |
974 | |
975 #endif /* DEBUG_XEMACS */ | |
976 | |
977 LCID | |
978 mswindows_current_locale (void) | |
979 { | |
980 /* Even if SetThreadLocale() failed, return the right locale anyway */ | |
981 return current_locale; | |
982 } | |
983 | |
984 DEFUN ("mswindows-current-locale", Fmswindows_current_locale, | |
985 0, 0, 0, /* | |
986 Return the current MS Windows locale. | |
987 | |
988 The return value will be a cons (LANG . SUBLANG). See | |
989 `mswindows-set-current-locale' for more info. | |
990 */ | |
991 ()) | |
992 { | |
993 return lcid_to_locale (mswindows_current_locale ()); | |
994 } | |
995 | |
996 DEFUN ("mswindows-user-default-locale", Fmswindows_user_default_locale, | |
997 0, 0, 0, /* | |
998 Return the MS Windows user-default locale. | |
999 */ | |
1000 ()) | |
1001 { | |
1002 return lcid_to_locale (GetUserDefaultLCID ()); | |
1003 } | |
1004 | |
1005 DEFUN ("mswindows-system-default-locale", Fmswindows_system_default_locale, | |
1006 0, 0, 0, /* | |
1007 Return the MS Windows system-default locale. | |
1008 */ | |
1009 ()) | |
1010 { | |
1011 return lcid_to_locale (GetSystemDefaultLCID ()); | |
1012 } | |
1013 | |
1014 DEFUN ("mswindows-locale-code-page", Fmswindows_locale_code_page, | |
1015 0, 1, 0, /* | |
1016 Return the (ANSI) code page of the specified MS Windows locale. | |
1017 If LOCALE is nil or omitted, the current locale is used. | |
1018 */ | |
1019 (locale)) | |
1020 { | |
1021 LCID lcid = NILP (locale) ? current_locale : locale_to_lcid (locale); | |
1022 return make_int (mswindows_locale_to_code_page (lcid)); | |
1023 } | |
1024 | |
1025 DEFUN ("mswindows-locale-oem-code-page", Fmswindows_locale_oem_code_page, | |
1026 0, 1, 0, /* | |
1027 Return the OEM code page of the specified MS Windows locale. | |
1028 If LOCALE is nil or omitted, the current locale is used. | |
1029 */ | |
1030 (locale)) | |
1031 { | |
1032 LCID lcid = NILP (locale) ? current_locale : locale_to_lcid (locale); | |
1033 return make_int (mswindows_locale_to_oem_code_page (lcid)); | |
1034 } | |
1035 | |
1036 static DWORD | |
2367 | 1037 int_from_hex (Ascbyte *s) |
771 | 1038 { |
1039 DWORD val = 0; | |
2367 | 1040 static Ascbyte hex[] = "0123456789abcdefABCDEF"; |
1041 Ascbyte *p; | |
771 | 1042 |
1043 while (*s && (p = strchr (hex, *s)) != NULL) | |
1044 { | |
1045 int digit = p - hex; | |
1046 if (digit > 15) | |
1047 digit -= 6; | |
1048 val = val * 16 + digit; | |
1049 s++; | |
1050 } | |
1051 return val; | |
1052 } | |
1053 | |
1054 /* We need to build a global list, since the EnumSystemLocale callback | |
1055 function isn't given a context pointer. */ | |
1056 static Lisp_Object Vmswindows_valid_locales; | |
1057 | |
1058 static BOOL CALLBACK | |
2367 | 1059 enum_locale_fn (Ascbyte *localeNum) |
771 | 1060 { |
1061 DWORD id = int_from_hex (localeNum); | |
1062 Vmswindows_valid_locales = | |
1063 Fcons (lcid_to_locale ((LCID) id), Vmswindows_valid_locales); | |
1064 return TRUE; | |
1065 } | |
1066 | |
1067 DEFUN ("mswindows-supported-locales", Fmswindows_supported_locales, | |
1068 0, 0, 0, /* | |
1069 Return a list of the supported MS Windows locales on this system. | |
1070 */ | |
1071 ()) | |
1072 { | |
1073 Vmswindows_valid_locales = Qnil; | |
1074 | |
1075 /* Use the ANSI version because the return value is just a hex number. */ | |
1076 EnumSystemLocalesA (enum_locale_fn, LCID_SUPPORTED); | |
1077 | |
1078 Vmswindows_valid_locales = Fnreverse (Vmswindows_valid_locales); | |
1079 return Vmswindows_valid_locales; | |
1080 } | |
1081 | |
1082 /************************************************************************/ | |
1083 /* Mule functions */ | |
1084 /************************************************************************/ | |
1085 | |
1086 DEFUN ("mswindows-charset-code-page", | |
1087 Fmswindows_charset_code_page, 1, 1, 0, /* | |
1088 Return the code page for the CHARSET. | |
1089 | |
1090 #### This function may be changed in the near future. | |
1091 | |
1092 Currently defined Windows code pages include (along with their status | |
1093 as Ansi, OEM, Mac, EBCDIC, or some combination): | |
1094 | |
1095 EBCDIC 037 EBCDIC | |
1096 OEM 437 MS-DOS United States | |
1097 EBCDIC 500 EBCDIC "500V1" | |
1098 OEM 708 Arabic (ASMO 708) | |
1099 OEM 709 Arabic (ASMO 449+, BCON V4) | |
1100 OEM 710 Arabic (Transparent Arabic) | |
1101 OEM 720 Arabic (Transparent ASMO) | |
1102 OEM 737 Greek (formerly 437G) | |
1103 OEM 775 Baltic | |
1104 OEM 850 MS-DOS Multilingual (Latin I) | |
1105 OEM 852 MS-DOS Slavic (Latin II) | |
1106 OEM 855 IBM Cyrillic (primarily Russian) | |
1107 OEM 857 IBM Turkish | |
1108 OEM 860 MS-DOS Portuguese | |
1109 OEM 861 MS-DOS Icelandic | |
1110 OEM 862 Hebrew | |
1111 OEM 863 MS-DOS Canadian-French | |
1112 OEM 864 Arabic | |
1113 OEM 865 MS-DOS Nordic | |
1114 OEM 866 MS-DOS Russian | |
1115 OEM 869 IBM Modern Greek | |
1116 Ansi/OEM 874 Thai | |
1117 EBCDIC 875 EBCDIC | |
1118 Ansi/OEM 932 Japanese | |
1119 Ansi/OEM 936 Chinese (PRC, Singapore) | |
1120 Ansi/OEM 949 Korean | |
1121 Ansi/OEM 950 Chinese (Taiwan; Hong Kong SAR, PRC) | |
1122 EBCDIC 1026 EBCDIC | |
1123 ANSI 1200 Unicode (BMP of ISO 10646) | |
1124 ANSI 1250 Windows 3.1 Eastern European | |
1125 ANSI 1251 Windows 3.1 Cyrillic | |
1126 ANSI 1252 Windows 3.1 US (ANSI) | |
1127 ANSI 1253 Windows 3.1 Greek | |
1128 ANSI 1254 Windows 3.1 Turkish | |
1129 ANSI 1255 Hebrew | |
1130 ANSI 1256 Arabic | |
1131 ANSI 1257 Baltic | |
1132 ANSI 1258 VietNam | |
1133 Ansi/OEM 1361 Korean (Johab) | |
1134 Mac 10000 Macintosh Roman | |
1135 Mac 10001 Macintosh Japanese | |
1136 Mac 10006 Macintosh Greek I | |
1137 Mac 10007 Macintosh Cyrillic | |
1138 Mac 10029 Macintosh Latin 2 | |
1139 Mac 10079 Macintosh Icelandic | |
1140 Mac 10081 Macintosh Turkish | |
1141 | |
1142 A code page is a set of characters, along with an enumeration of these | |
1143 characters and an encoding of them in a byte stream. Thus, in XEmacs | |
1144 parlance it defines both a "charset" and a "coding system" for this | |
1145 charset. Traditional encodings are either simple one-byte encodings, or | |
1146 combination one-byte/two-byte encodings (aka MBCS encodings, where MBCS | |
1147 stands for "Multibyte Character Set") with the following properties: | |
1148 | |
1149 -- all characters are encoded as a one-byte or two-byte sequence | |
1150 -- the encoding is stateless (non-modal) | |
1151 -- the lower 128 bytes are compatible with ASCII | |
1152 -- in the higher bytes, the value of the first byte ("lead byte") | |
1153 determines whether a second byte follows | |
1154 -- the values used for second bytes may overlap those used for first bytes, | |
1155 and (in some encodings) include values in the low half; thus, moving | |
1156 backwards is hard, and pure-ASCII algorithms (e.g. finding the next slash) | |
1157 will fail unless rewritten to be MBCS-aware (neither of these problems | |
1158 exist in UTF-8 or in the XEmacs internal string encoding) | |
1159 | |
1160 Recent code pages, however, do not necessarily follow these properties -- | |
1161 code pages have been expanded to include arbitrary encodings, such as UTF-8 | |
1162 \(may have more than two bytes per character) and ISO-2022-JP (complex modal | |
1163 encoding). | |
1164 | |
1165 Every locale has four associated code pages: ANSI (an international | |
1166 standard or some Microsoft-created approximation; the native code page | |
1167 under Windows), OEM (a DOS encoding, still used in the FAT file system), | |
1168 Mac (an encoding used on the Macintosh) and EBCDIC (a non-ASCII-compatible | |
1169 encoding used on IBM mainframes, originally based on the BCD or | |
1170 "binary-coded decimal" encoding of numbers). All code pages associated | |
1171 with a locale follow (as far as I know) the properties listed above for | |
1172 traditional code pages. | |
1173 */ | |
1174 (charset)) | |
1175 { | |
1176 charset = Fget_charset (charset); | |
1177 return Fgethash (charset, Vmswindows_charset_code_page_table, Qnil); | |
1178 } | |
1179 | |
1180 DEFUN ("mswindows-set-charset-code-page", | |
1181 Fmswindows_set_charset_code_page, 2, 2, 0, /* | |
1182 Set the CODE-PAGE for the CHARSET. | |
1183 | |
1184 #### This function may be changed once full Unicode support is present. | |
1185 */ | |
1186 (charset, code_page)) | |
1187 { | |
1188 charset = Fget_charset (charset); | |
1189 CHECK_INT (code_page); | |
1190 Fputhash (charset, code_page, Vmswindows_charset_code_page_table); | |
1191 return Qnil; | |
1192 } | |
1193 | |
1194 Lisp_Object | |
1195 mswindows_get_code_page_charset (int code_page) | |
1196 { | |
1197 Lisp_Object charset_tail; | |
1198 Lisp_Object charset = Qunbound; | |
1199 | |
1200 LIST_LOOP (charset_tail, Fcharset_list ()) | |
1201 { | |
1202 Lisp_Object charset_code_page; | |
1203 | |
1204 charset_code_page = Fmswindows_charset_code_page (XCAR (charset_tail)); | |
1205 if (INTP (charset_code_page) && | |
1206 code_page == XINT (charset_code_page)) | |
1207 { | |
1208 charset = Fget_charset (XCAR (charset_tail)); | |
1209 break; | |
1210 } | |
1211 } | |
1212 return charset; | |
1213 } | |
1214 | |
872 | 1215 DEFUN ("mswindows-charset-registry", |
1216 Fmswindows_charset_registry, 1, 1, 0, /* | |
1217 Return the registry for the CHARSET. | |
1218 This is the last item in an MS Windows font spec. | |
1219 | |
1220 #### This function may be changed in the near future. | |
1221 */ | |
1222 (charset)) | |
1223 { | |
1224 charset = Fget_charset (charset); | |
1225 return Fgethash (charset, Vmswindows_charset_registry_table, Qnil); | |
1226 } | |
1227 | |
1228 DEFUN ("mswindows-set-charset-registry", | |
1229 Fmswindows_set_charset_registry, 2, 2, 0, /* | |
1230 Set the REGISTRY for the CHARSET. | |
1231 | |
1232 #### This function may be changed once full Unicode support is present. | |
1233 */ | |
1234 (charset, registry)) | |
1235 { | |
1236 charset = Fget_charset (charset); | |
1237 CHECK_STRING (registry); | |
1238 Fputhash (charset, registry, Vmswindows_charset_registry_table); | |
1239 invalidate_charset_font_caches (charset); | |
1240 face_property_was_changed (Vdefault_face, Qfont, Qglobal); | |
1241 return Qnil; | |
1242 } | |
1243 | |
1111 | 1244 #if 0 /* Unused */ |
1245 | |
1246 static Lisp_Object | |
872 | 1247 mswindows_get_registry_charset (Ibyte *registry) |
1248 { | |
1249 Lisp_Object charset_tail; | |
1250 Lisp_Object charset = Qunbound; | |
1251 | |
1252 LIST_LOOP (charset_tail, Fcharset_list ()) | |
1253 { | |
1254 Lisp_Object charset_registry; | |
1255 | |
1256 charset_registry = Fmswindows_charset_registry (XCAR (charset_tail)); | |
1257 if (STRINGP (charset_registry) && | |
1258 !qxestrcasecmp (XSTRING_DATA (charset_registry), registry)) | |
1259 { | |
1260 charset = Fget_charset (XCAR (charset_tail)); | |
1261 break; | |
1262 } | |
1263 } | |
1264 return charset; | |
1265 } | |
1266 | |
1111 | 1267 #endif /* 0 */ |
1268 | |
771 | 1269 |
1270 | |
1271 #if 0 /* #### from Emacs 20.6; consider porting */ | |
1272 | |
826 | 1273 DEFUN ("mswindows-get-locale-info", Fmswindows_get_locale_info, 1, 2, 0, /* |
771 | 1274 Return information about the Windows locale LCID. |
1275 By default, return a three letter locale code which encodes the default | |
1276 language as the first two characters, and the country or regionial variant | |
1277 as the third letter. For example, ENU refers to `English (United States)', | |
1278 while ENC means `English (Canadian)'. | |
1279 | |
1280 If the optional argument LONGFORM is t, the long form of the locale | |
1281 name is returned, e.g. `English (United States)' instead; if LONGFORM | |
1282 is a number, it is interpreted as an LCTYPE constant and the corresponding | |
1283 locale information is returned. | |
1284 | |
1285 If LCID (a 16-bit number) is not a valid locale, the result is nil. | |
1286 */ | |
1287 (lcid, longform)) | |
1288 { | |
1289 int got_abbrev; | |
1290 int got_full; | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1291 Extbyte abbrev_name[32] = { 0 }; |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1292 Extbyte full_name[256] = { 0 }; |
771 | 1293 |
1294 CHECK_INT (lcid); | |
1295 | |
1296 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED)) | |
1297 return Qnil; | |
1298 | |
1299 if (NILP (longform)) | |
1300 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1301 got_abbrev = qxeGetLocaleInfo (XINT (lcid), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1302 LOCALE_SABBREVLANGNAME | |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1303 LOCALE_USE_CP_ACP, |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1304 abbrev_name, sizeof (abbrev_name)); |
771 | 1305 if (got_abbrev) |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1306 return build_tstr_string (abbrev_name); |
771 | 1307 } |
1308 else if (EQ (longform, Qt)) | |
1309 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1310 got_full = qxeGetLocaleInfo (XINT (lcid), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1311 LOCALE_SLANGUAGE | LOCALE_USE_CP_ACP, |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1312 full_name, sizeof (full_name)); |
771 | 1313 if (got_full) |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1314 return build_tstr_string (full_name); |
771 | 1315 } |
1316 else if (NUMBERP (longform)) | |
1317 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1318 got_full = qxeGetLocaleInfo (XINT (lcid), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1319 XINT (longform), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1320 full_name, sizeof (full_name)); |
771 | 1321 if (got_full) |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1322 return build_tstr_string (full_name); |
771 | 1323 } |
1324 | |
1325 return Qnil; | |
1326 } | |
1327 | |
1328 /* We need to build a global list, since the EnumCodePages callback | |
1329 function isn't given a context pointer. */ | |
1330 Lisp_Object Vmswindows_valid_code_pages; | |
1331 | |
1332 BOOL CALLBACK enum_code_page_fn (LPTSTR codepageNum) | |
1333 { | |
1334 DWORD id = atoi (codepageNum); | |
1335 Vmswindows_valid_code_pages = Fcons (make_int (id), Vmswindows_valid_code_pages); | |
1336 return TRUE; | |
1337 } | |
1338 | |
826 | 1339 DEFUN ("mswindows-get-valid-code-pages", Fmswindows_get_valid_code_pages, 0, 0, 0, /* |
771 | 1340 Return list of all valid Windows code pages. |
1341 */ | |
1342 ()) | |
1343 { | |
1344 Vmswindows_valid_code_pages = Qnil; | |
1345 | |
1346 EnumSystemCodePages (enum_code_page_fn, CP_SUPPORTED); | |
1347 | |
1348 Vmswindows_valid_code_pages = Fnreverse (Vmswindows_valid_code_pages); | |
1349 return Vmswindows_valid_code_pages; | |
1350 } | |
1351 | |
826 | 1352 DEFUN ("mswindows-get-console-code-page", Fmswindows_get_console_code_page, 0, 0, 0, /* |
771 | 1353 Return current Windows code page for console input. |
1354 */ | |
1355 ()) | |
1356 { | |
1357 return make_int (GetConsoleCP ()); | |
1358 } | |
1359 | |
826 | 1360 DEFUN ("mswindows-set-console-code-page", Fmswindows_set_console_code_page, 1, 1, 0, /* |
771 | 1361 Make Windows code page CP be the current code page setting for Emacs. |
1362 The code page setting affects keyboard input and display in tty mode. | |
1363 If successful, the new CP is returned, otherwise nil. | |
1364 */ | |
1365 (cp)) | |
1366 { | |
1367 CHECK_INT (cp); | |
1368 | |
1369 if (!IsValidCodePage (XINT (cp))) | |
1370 return Qnil; | |
1371 | |
1372 if (!SetConsoleCP (XINT (cp))) | |
1373 return Qnil; | |
1374 | |
1375 return make_int (GetConsoleCP ()); | |
1376 } | |
1377 | |
826 | 1378 DEFUN ("mswindows-get-console-output-code-page", Fmswindows_get_console_output_code_page, 0, 0, 0, /* |
771 | 1379 Return current Windows code page for console output. |
1380 */ | |
1381 ()) | |
1382 { | |
1383 return make_int (GetConsoleOutputCP ()); | |
1384 } | |
1385 | |
826 | 1386 DEFUN ("mswindows-set-console-output-code-page", Fmswindows_set_console_output_code_page, 1, 1, 0, /* |
771 | 1387 Make Windows code page CP be the current code page setting for Emacs. |
1388 The code page setting affects keyboard input and display in tty mode. | |
1389 If successful, the new CP is returned, otherwise nil. | |
1390 */ | |
1391 (cp)) | |
1392 { | |
1393 CHECK_INT (cp); | |
1394 | |
1395 if (!IsValidCodePage (XINT (cp))) | |
1396 return Qnil; | |
1397 | |
1398 if (!SetConsoleOutputCP (XINT (cp))) | |
1399 return Qnil; | |
1400 | |
1401 return make_int (GetConsoleOutputCP ()); | |
1402 } | |
1403 | |
826 | 1404 DEFUN ("mswindows-get-code-page-charset", Fmswindows_get_code_page_charset, 1, 1, 0, /* |
771 | 1405 Return charset of code page CP. |
1406 Returns nil if the code page is not valid. | |
1407 */ | |
1408 (cp)) | |
1409 { | |
1410 CHARSETINFO info; | |
1411 | |
1412 CHECK_INT (cp); | |
1413 | |
1414 if (!IsValidCodePage (XINT (cp))) | |
1415 return Qnil; | |
1416 | |
1417 if (TranslateCharsetInfo ((DWORD *) XINT (cp), &info, TCI_SRCCODEPAGE)) | |
1418 return make_int (info.ciCharset); | |
1419 | |
1420 return Qnil; | |
1421 } | |
1422 | |
826 | 1423 DEFUN ("mswindows-get-valid-keyboard-layouts", Fmswindows_get_valid_keyboard_layouts, 0, 0, 0, /* |
771 | 1424 Return list of Windows keyboard languages and layouts. |
1425 The return value is a list of pairs of language id and layout id. | |
1426 */ | |
1427 ()) | |
1428 { | |
1429 int num_layouts = GetKeyboardLayoutList (0, NULL); | |
2367 | 1430 HKL *layouts = alloca_array (HKL, num_layouts); |
771 | 1431 Lisp_Object obj = Qnil; |
1432 | |
1433 if (GetKeyboardLayoutList (num_layouts, layouts) == num_layouts) | |
1434 { | |
1435 while (--num_layouts >= 0) | |
1436 { | |
1437 DWORD kl = (DWORD) layouts[num_layouts]; | |
1438 | |
1439 obj = Fcons (Fcons (make_int (kl & 0xffff), | |
1440 make_int ((kl >> 16) & 0xffff)), | |
1441 obj); | |
1442 } | |
1443 } | |
1444 | |
1445 return obj; | |
1446 } | |
1447 | |
826 | 1448 DEFUN ("mswindows-get-keyboard-layout", Fmswindows_get_keyboard_layout, 0, 0, 0, /* |
771 | 1449 Return current Windows keyboard language and layout. |
1450 The return value is the cons of the language id and the layout id. | |
1451 */ | |
1452 ()) | |
1453 { | |
1454 DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId); | |
1455 | |
1456 return Fcons (make_int (kl & 0xffff), | |
1457 make_int ((kl >> 16) & 0xffff)); | |
1458 } | |
1459 | |
826 | 1460 DEFUN ("mswindows-set-keyboard-layout", Fmswindows_set_keyboard_layout, 1, 1, 0, /* |
771 | 1461 Make LAYOUT be the current keyboard layout for Emacs. |
1462 The keyboard layout setting affects interpretation of keyboard input. | |
1463 If successful, the new layout id is returned, otherwise nil. | |
1464 */ | |
1465 (layout)) | |
1466 { | |
1467 DWORD kl; | |
1468 | |
1469 CHECK_CONS (layout); | |
1470 CHECK_INT (XCAR (layout))); | |
1471 CHECK_INT (XCDR (layout))); | |
1472 | |
1473 kl = (XINT (XCAR (layout))) & 0xffff) | |
1474 | (XINT (XCDR (layout))) << 16); | |
1475 | |
1476 if (!ActivateKeyboardLayout ((HKL) kl, 0)) | |
1477 return Qnil; | |
1478 | |
1479 return Fmswindows_get_keyboard_layout (); | |
1480 } | |
1481 | |
1482 #endif /* 0 */ | |
1483 | |
1484 | |
1485 /* input method functions. */ | |
1486 | |
1487 #ifdef HAVE_MS_WINDOWS | |
1488 | |
1489 void | |
1490 mswindows_start_ime_composition (struct frame *f) | |
1491 { | |
1492 COMPOSITIONFORM form; | |
1493 HWND hwnd = FRAME_MSWINDOWS_HANDLE (f); | |
1494 HIMC himc = ImmGetContext (hwnd); | |
1495 | |
1496 /* Set a position of composition window. */ | |
1497 xzero (form); | |
1498 form.dwStyle = CFS_POINT; | |
1499 form.ptCurrentPos.x = FRAME_MSWINDOWS_CURSOR_X (f); | |
1500 form.ptCurrentPos.y = FRAME_MSWINDOWS_CURSOR_Y (f); | |
1501 ImmSetCompositionWindow (himc, &form); | |
1502 | |
1503 /* Set composition window font same as current face one. */ | |
1504 { | |
1505 LOGFONTW old_logfont; | |
1506 CHARSETINFO info; | |
1507 Lisp_Object charset; | |
1508 | |
1509 /* Get Mule charset from current ime font charset. */ | |
1510 qxeImmGetCompositionFont (himc, &old_logfont); | |
1511 TranslateCharsetInfo ((DWORD *) (DWORD) old_logfont.lfCharSet, &info, | |
1512 TCI_SRCCHARSET); | |
1513 charset = mswindows_get_code_page_charset (info.ciACP); | |
1514 | |
1515 if (CHARSETP (charset)) | |
1516 { | |
1517 Lisp_Object window = FRAME_SELECTED_WINDOW (f); | |
1518 struct window *w = XWINDOW (window); | |
1519 face_index findex = FRAME_MSWINDOWS_CURSOR_FINDEX (f); | |
1520 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex); | |
1521 Lisp_Object face_font = FACE_CACHEL_FONT (cachel, charset); | |
1522 | |
1523 if (!FONT_INSTANCEP (face_font)) | |
1524 face_font = | |
1525 ensure_face_cachel_contains_charset (cachel, window, charset); | |
1526 | |
1527 if (!EQ (face_font, Vthe_null_font_instance)) | |
1528 { | |
1529 LOGFONTW new_logfont; | |
1530 | |
1531 /* Get LOGFONT from the face font */ | |
1532 if (qxeGetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT | |
1533 (XFONT_INSTANCE (face_font), | |
1534 cachel->underline, cachel->strikethru), | |
1535 sizeof (LOGFONTW), (void*) &new_logfont)) | |
1536 qxeImmSetCompositionFont (himc, &new_logfont); | |
1537 } | |
1538 } | |
1539 } | |
1540 ImmReleaseContext (hwnd, himc); | |
1541 return; | |
1542 } | |
1543 | |
1544 #endif /* HAVE_MS_WINDOWS */ | |
1545 | |
1546 #else /* not MULE */ | |
1547 | |
1548 int | |
2286 | 1549 mswindows_locale_to_code_page (LCID UNUSED (lcid)) |
771 | 1550 { |
1551 return CP_ACP; | |
1552 } | |
1553 | |
2935 | 1554 LCID |
1555 mswindows_current_locale (void) | |
1556 { | |
1557 /* In non-MULE version just return the default locale */ | |
1558 return GetUserDefaultLCID (); | |
1559 } | |
1560 | |
771 | 1561 #endif /* MULE */ |
1562 | |
1563 | |
1564 #ifdef CYGWIN | |
1565 | |
1111 | 1566 /* based on newlib str*() */ |
1567 | |
1568 #ifndef HAVE_WCSCMP | |
1569 | |
1570 int | |
1571 wcscmp (const wchar_t *s1, const wchar_t *s2) | |
1572 { | |
3648 | 1573 if (s1 == NULL || s2 == NULL) return NULL; |
1111 | 1574 while (*s1 != '\0' && *s1 == *s2) |
1575 { | |
1576 s1++; | |
1577 s2++; | |
1578 } | |
1579 | |
1580 return *s1 - *s2; | |
1581 } | |
1582 | |
1583 #endif /* not HAVE_WCSCMP */ | |
1584 | |
1585 #ifndef HAVE_WCSLEN | |
1586 | |
1587 size_t | |
1588 wcslen (const wchar_t *str) | |
1589 { | |
3648 | 1590 if (str == NULL) return NULL; |
1111 | 1591 const wchar_t *start = str; |
1592 | |
1593 while (*str) | |
1594 str++; | |
1595 | |
1596 return str - start; | |
1597 } | |
1598 | |
1599 #endif /* not HAVE_WCSLEN */ | |
771 | 1600 |
1601 wchar_t * | |
1602 wcsncpy (wchar_t *dst0, const wchar_t *src0, size_t count) | |
1603 { | |
1604 wchar_t *dscan; | |
1605 const wchar_t *sscan; | |
1606 | |
5016
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
1607 if (dst0 == NULL || src0 == NULL) return NULL; |
771 | 1608 dscan = dst0; |
1609 sscan = src0; | |
1610 while (count > 0) | |
1611 { | |
1612 --count; | |
1613 if ((*dscan++ = *sscan++) == '\0') | |
1614 break; | |
1615 } | |
1616 while (count-- > 0) | |
1617 *dscan++ = '\0'; | |
1618 | |
1619 return dst0; | |
1620 } | |
1621 | |
1622 wchar_t * | |
1623 wcscpy (wchar_t *dst0, const wchar_t *src0) | |
1624 { | |
3648 | 1625 if (dst0 == NULL || src0 == NULL) return NULL; |
771 | 1626 wchar_t *s = dst0; |
1627 | |
1628 while ((*dst0++ = *src0++)) | |
1629 ; | |
1630 | |
1631 return s; | |
1632 } | |
1633 | |
1634 wchar_t * | |
1635 wcsdup (const wchar_t *str) | |
1636 { | |
3648 | 1637 if (str == NULL) return NULL; |
771 | 1638 int len = wcslen (str) + 1; |
2367 | 1639 wchar_t *val = xnew_array (wchar_t, len); |
771 | 1640 |
1641 if (val == 0) return 0; | |
1642 return (wchar_t *) memcpy (val, str, len * sizeof (wchar_t)); | |
1643 } | |
1644 | |
1645 #endif /* CYGWIN */ | |
1646 | |
1647 | |
1648 /************************************************************************/ | |
1649 /* MS Windows multibyte-to-unicode methods */ | |
1650 /************************************************************************/ | |
1651 | |
1652 enum mswindows_multibyte_cp_type | |
1653 { | |
1654 MULTIBYTE_ANSI, | |
1655 MULTIBYTE_OEM, | |
1656 MULTIBYTE_EBCDIC, | |
1657 MULTIBYTE_MAC | |
1658 }; | |
1659 | |
1660 enum mswindows_multibyte_locale_type | |
1661 { | |
1662 MULTIBYTE_SPECIFIED_LOCALE, | |
1663 MULTIBYTE_SPECIFIED_CODE_PAGE, | |
1664 MULTIBYTE_CURRENT, | |
1665 MULTIBYTE_USER_DEFAULT, | |
1666 MULTIBYTE_SYSTEM_DEFAULT | |
1667 }; | |
1668 | |
1669 struct mswindows_multibyte_to_unicode_coding_system | |
1670 { | |
1671 enum mswindows_multibyte_cp_type cp_type; | |
1672 enum mswindows_multibyte_locale_type locale_type; | |
1673 LCID locale; /* if locale_type is MULTIBYTE_SPECIFIED_LOCALE */ | |
1674 int cp; /* if locale_type is MULTIBYTE_SPECIFIED_CODE_PAGE */ | |
1675 }; | |
1676 | |
1677 struct mswindows_multibyte_to_unicode_coding_stream | |
1678 { | |
1679 int partial_byte; | |
1680 int partial_byte_present; | |
1681 int cp; | |
1682 }; | |
1683 | |
1204 | 1684 static const struct memory_description |
771 | 1685 mswindows_multibyte_to_unicode_coding_system_description[] = { |
1686 { XD_END } | |
1687 }; | |
1688 | |
1204 | 1689 DEFINE_CODING_SYSTEM_TYPE_WITH_DATA (mswindows_multibyte_to_unicode); |
1690 | |
771 | 1691 static void |
1692 mswindows_multibyte_to_unicode_init (Lisp_Object codesys) | |
1693 { | |
1694 struct mswindows_multibyte_to_unicode_coding_system *data = | |
1695 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte_to_unicode); | |
1696 | |
1697 data->cp_type = MULTIBYTE_ANSI; | |
1698 data->locale_type = MULTIBYTE_CURRENT; | |
1699 } | |
1700 | |
1701 static Lisp_Object | |
2286 | 1702 lcid_to_locale_mule_or_no (LCID USED_IF_MULE (lcid)) |
771 | 1703 { |
1704 #ifdef MULE | |
1705 return lcid_to_locale (lcid); | |
1706 #else | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1707 return Fcons (build_ascstring ("NEUTRAL"), build_ascstring ("DEFAULT")); |
771 | 1708 #endif |
1709 } | |
1710 | |
1711 static int | |
2286 | 1712 determine_code_page (Lisp_Object USED_IF_MULE (codesys)) |
771 | 1713 { |
1714 #ifdef MULE | |
1715 LCID locale; | |
1716 struct mswindows_multibyte_to_unicode_coding_system *data = | |
1717 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte_to_unicode); | |
1718 | |
1719 switch (data->locale_type) | |
1720 { | |
1721 case MULTIBYTE_SPECIFIED_CODE_PAGE: | |
1722 return data->cp; | |
1723 case MULTIBYTE_SPECIFIED_LOCALE: | |
1724 locale = data->locale; break; | |
1725 case MULTIBYTE_CURRENT: | |
1726 locale = mswindows_current_locale (); break; | |
1727 case MULTIBYTE_USER_DEFAULT: | |
1728 locale = GetUserDefaultLCID (); break; | |
1729 case MULTIBYTE_SYSTEM_DEFAULT: | |
1730 locale = GetSystemDefaultLCID (); break; | |
1731 default: | |
2500 | 1732 ABORT (); locale = 0; |
771 | 1733 } |
1734 | |
1735 switch (data->cp_type) | |
1736 { | |
1737 case MULTIBYTE_ANSI: | |
1738 return mswindows_locale_to_code_page (locale); | |
1739 case MULTIBYTE_OEM: | |
1740 return mswindows_locale_to_oem_code_page (locale); | |
1741 case MULTIBYTE_EBCDIC: | |
1742 #ifdef LOCALE_IDEFAULTEBCDICCODEPAGE /* Doesn't exist under Cygwin */ | |
1743 { | |
1744 char codepagestr[10]; | |
1745 GetLocaleInfoA (locale, LOCALE_IDEFAULTEBCDICCODEPAGE, codepagestr, | |
1746 10); | |
1747 return atoi (codepagestr); | |
1748 } | |
1749 #else | |
1750 invalid_operation ("Unable to determine EBCDIC code page for locale", | |
1751 lcid_to_locale (locale)); | |
1752 return 0; | |
1753 #endif | |
1754 case MULTIBYTE_MAC: | |
1755 #ifdef LOCALE_IDEFAULTMACCODEPAGE /* Doesn't exist under Cygwin */ | |
1756 { | |
1757 char codepagestr[10]; | |
1758 GetLocaleInfoA (locale, LOCALE_IDEFAULTMACCODEPAGE, codepagestr, | |
1759 10); | |
1760 return atoi (codepagestr); | |
1761 } | |
1762 #else | |
1763 invalid_operation ("Unable to determine Mac code page for locale", | |
1764 lcid_to_locale (locale)); | |
1765 return 0; | |
1766 #endif | |
1767 default: | |
2500 | 1768 ABORT (); return 0; |
771 | 1769 } |
1770 #else /* not MULE */ | |
1771 return CP_ACP; | |
1772 #endif | |
1773 } | |
1774 | |
1775 static int | |
1776 mswindows_multibyte_to_unicode_putprop (Lisp_Object codesys, | |
1777 Lisp_Object key, | |
1778 Lisp_Object value) | |
1779 { | |
1780 struct mswindows_multibyte_to_unicode_coding_system *data = | |
1781 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte_to_unicode); | |
1782 | |
1783 if (EQ (key, Qcode_page)) | |
1784 { | |
1785 if (EQ (value, Qansi)) | |
1786 data->cp_type = MULTIBYTE_ANSI; | |
1787 else if (EQ (value, Qoem)) | |
1788 data->cp_type = MULTIBYTE_OEM; | |
1789 else if (EQ (value, Qebcdic)) | |
1790 data->cp_type = MULTIBYTE_EBCDIC; | |
1791 else if (EQ (value, Qmac)) | |
1792 data->cp_type = MULTIBYTE_MAC; | |
1793 else | |
1794 { | |
1795 data->locale_type = MULTIBYTE_SPECIFIED_CODE_PAGE; | |
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1796 #ifdef HAVE_BIGNUM |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1797 check_integer_range (value, Qzero, make_integer (INT_MAX)); |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1798 data->cp = BIGNUMP (value) ? bignum_to_int (XBIGNUM_DATA (value)) : XINT (value); |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1799 #else |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1800 CHECK_NATNUM (value); |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1801 data->cp = XINT (value); |
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1802 #endif |
771 | 1803 } |
1804 } | |
1805 else if (EQ (key, Qlocale)) | |
1806 { | |
1807 if (EQ (value, Qcurrent)) | |
1808 data->locale_type = MULTIBYTE_CURRENT; | |
1809 else if (EQ (value, Quser_default)) | |
1810 data->locale_type = MULTIBYTE_USER_DEFAULT; | |
1811 else if (EQ (value, Qsystem_default)) | |
1812 data->locale_type = MULTIBYTE_SYSTEM_DEFAULT; | |
1813 else | |
1814 { | |
1815 data->locale_type = MULTIBYTE_SPECIFIED_LOCALE; | |
1816 #ifdef MULE | |
1817 data->locale = locale_to_lcid (value); | |
1818 #else | |
1819 data->locale = 0; | |
1820 #endif | |
1821 } | |
1822 } | |
1823 else | |
1824 return 0; | |
1825 return 1; | |
1826 } | |
1827 | |
1828 static Lisp_Object | |
1829 mswindows_multibyte_to_unicode_getprop (Lisp_Object coding_system, | |
1830 Lisp_Object prop) | |
1831 { | |
1832 struct mswindows_multibyte_to_unicode_coding_system *data = | |
1833 XCODING_SYSTEM_TYPE_DATA (coding_system, mswindows_multibyte_to_unicode); | |
1834 | |
1835 if (EQ (prop, Qcode_page)) | |
1836 { | |
1837 if (data->locale_type == MULTIBYTE_SPECIFIED_CODE_PAGE) | |
1838 return make_int (data->cp); | |
1839 else | |
1840 switch (data->cp_type) | |
1841 { | |
1842 case MULTIBYTE_ANSI: return Qansi; | |
1843 case MULTIBYTE_OEM: return Qoem; | |
1844 case MULTIBYTE_EBCDIC: return Qebcdic; | |
1845 case MULTIBYTE_MAC: return Qmac; | |
2500 | 1846 default: ABORT (); |
771 | 1847 } |
1848 } | |
1849 else if (EQ (prop, Qlocale)) | |
1850 { | |
1851 switch (data->locale_type) | |
1852 { | |
1853 case MULTIBYTE_CURRENT: return Qcurrent; | |
1854 case MULTIBYTE_USER_DEFAULT: return Quser_default; | |
1855 case MULTIBYTE_SYSTEM_DEFAULT: return Qsystem_default; | |
1856 case MULTIBYTE_SPECIFIED_LOCALE: | |
1857 return lcid_to_locale_mule_or_no (data->locale); | |
1858 | |
1859 case MULTIBYTE_SPECIFIED_CODE_PAGE: | |
1860 return Qnil; | |
2500 | 1861 default: ABORT (); |
771 | 1862 } |
1863 } | |
1864 | |
1865 return Qunbound; | |
1866 } | |
1867 | |
1868 static void | |
2286 | 1869 mswindows_multibyte_to_unicode_print (Lisp_Object cs, Lisp_Object printcharfun, |
1870 int UNUSED (escapeflag)) | |
771 | 1871 { |
1872 struct mswindows_multibyte_to_unicode_coding_system *data = | |
1873 XCODING_SYSTEM_TYPE_DATA (cs, mswindows_multibyte_to_unicode); | |
1874 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1875 write_ascstring (printcharfun, "("); |
771 | 1876 if (data->locale_type == MULTIBYTE_SPECIFIED_CODE_PAGE) |
1877 print_internal (make_int (data->cp), printcharfun, 1); | |
1878 else | |
1879 { | |
800 | 1880 write_fmt_string_lisp (printcharfun, "%s, ", 1, mswindows_multibyte_to_unicode_getprop (cs, Qlocale)); |
1881 print_internal (mswindows_multibyte_to_unicode_getprop (cs, Qcode_page), printcharfun, 0); | |
771 | 1882 } |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1883 write_ascstring (printcharfun, ")"); |
771 | 1884 } |
1885 | |
2367 | 1886 /* ----------------------------------------------------------------------- */ |
1887 /* Unicode/Multibyte converters */ | |
1888 /* ----------------------------------------------------------------------- */ | |
1889 | |
771 | 1890 /* Convert multibyte to Unicode according to the specified code page |
1891 and return the value as a malloc()ed string. This currently exists | |
1892 because the TO_INTERNAL_FORMAT() mechanism -- the normal way to do | |
1893 such conversions -- has no way of passing in a parameter to control | |
1894 the operation. We could use a global variable to pass this value | |
1895 in, but that runs the risk of causing problems due to reentrancy. | |
1896 (You might say, yeah, right, how can TO_INTERNAL_FORMAT() get | |
1897 called recursively merely when I'm doing a simple conversion | |
1898 operation? It turns out this can and does happen, consistently, as | |
1899 a result of calling QUIT -- it happens consistently for complicated | |
2367 | 1900 reasons outlined in event-msw.c, WM_KEYDOWN handling.) |
1901 | |
1902 NOTE: These functions are also used at startup. */ | |
771 | 1903 |
1904 Extbyte * | |
1905 convert_multibyte_to_unicode_malloc (const Extbyte *src, Bytecount n, | |
1906 int cp, Bytecount *size_out) | |
1907 { | |
2367 | 1908 Charcount nout = MultiByteToWideChar (cp, MBTOWC_OPTIONS, src, n, 0, 0); |
771 | 1909 Extbyte *outp = xnew_array (Extbyte, nout * sizeof (WCHAR)); |
1910 | |
2367 | 1911 MultiByteToWideChar (cp, MBTOWC_OPTIONS, src, n, (LPWSTR) outp, nout); |
771 | 1912 if (size_out) |
1913 *size_out = nout * sizeof (WCHAR); | |
1914 return outp; | |
1915 } | |
1916 | |
2367 | 1917 Extbyte * |
1918 convert_unicode_to_multibyte_malloc (const Extbyte *src, Bytecount n, | |
1919 int cp, Bytecount *size_out) | |
1920 { | |
1921 Bytecount nout = WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
1922 n / sizeof (WCHAR), | |
1923 0, 0, WCTOMB_INVALID_STRING, 0); | |
1924 Extbyte *outp = xnew_array (Extbyte, nout); | |
1925 | |
1926 WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
1927 n / sizeof (WCHAR), (LPSTR) outp, nout, | |
1928 WCTOMB_INVALID_STRING, 0); | |
1929 if (size_out) | |
1930 *size_out = nout; | |
1931 return outp; | |
1932 } | |
1933 | |
771 | 1934 /* Convert MS Windows multibyte to internal, with specified code page. |
1935 See above for why this exists, and the TO_INTERNAL_FORMAT() macros | |
1936 aren't just used. */ | |
1937 | |
867 | 1938 Ibyte * |
771 | 1939 convert_multibyte_to_internal_malloc (const Extbyte *src, Bytecount n, |
1940 int cp, Bytecount *size_out) | |
1941 { | |
1942 Bytecount size; | |
1943 Extbyte *unidata = convert_multibyte_to_unicode_malloc (src, n, cp, &size); | |
867 | 1944 Ibyte *intdata; |
771 | 1945 |
1946 TO_INTERNAL_FORMAT (DATA, (unidata, size), MALLOC, (intdata, size), | |
1947 Qmswindows_unicode); | |
1948 | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1949 xfree (unidata); |
771 | 1950 |
1951 if (size_out) | |
1952 *size_out = size; | |
1953 | |
1954 return intdata; | |
1955 } | |
1956 | |
2367 | 1957 static void |
1958 unicode_multibyte_convert_now_damn_it (const void *src, Bytecount src_size, | |
1959 int to_unicode, void **dst, | |
1960 Bytecount *dst_size, int cp) | |
1961 { | |
1962 if (to_unicode) | |
1963 { | |
1964 Charcount nout = MultiByteToWideChar (cp, MBTOWC_OPTIONS, (LPSTR) src, | |
1965 src_size, 0, 0); | |
1966 Extbyte *outp = (Extbyte *) stack_like_malloc (nout * sizeof (WCHAR)); | |
1967 | |
1968 MultiByteToWideChar (cp, MBTOWC_OPTIONS, (LPSTR) src, src_size, | |
1969 (LPWSTR) outp, nout); | |
1970 *dst = (void *) outp; | |
1971 *dst_size = nout * sizeof (WCHAR); | |
1972 } | |
1973 else | |
1974 { | |
1975 Bytecount nout = WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
1976 src_size / sizeof (WCHAR), | |
1977 0, 0, WCTOMB_INVALID_STRING, 0); | |
1978 Extbyte *outp = (Extbyte *) stack_like_malloc (nout); | |
1979 | |
1980 WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
1981 src_size / sizeof (WCHAR), (LPSTR) outp, nout, | |
1982 WCTOMB_INVALID_STRING, 0); | |
1983 *dst = (void *) outp; | |
1984 *dst_size = nout; | |
1985 } | |
1986 } | |
1987 | |
1988 Bytecount | |
1989 unicode_multibyte_convert_size (const char *srctext, const void *src, | |
1990 Bytecount src_size, int to_unicode, int cp) | |
1991 { | |
1992 alloca_convert_vals vals; | |
2658 | 1993 |
1994 int pos = find_pos_of_existing_active_alloca_convert (srctext); | |
1995 assert (pos < 0); | |
2367 | 1996 |
1997 vals.srctext = srctext; | |
1998 | |
1999 unicode_multibyte_convert_now_damn_it (src, src_size, to_unicode, &vals.dst, | |
2000 &vals.dst_size, cp); | |
2001 | |
2002 Dynarr_add (active_alloca_convert, vals); | |
2003 return vals.dst_size; | |
2004 } | |
2005 | |
2006 void * | |
2007 unicode_multibyte_convert_copy_data (const char *srctext, void *alloca_data) | |
2008 { | |
2009 alloca_convert_vals *vals; | |
2010 int i = find_pos_of_existing_active_alloca_convert (srctext); | |
2011 | |
2012 assert (i >= 0); | |
2013 vals = Dynarr_atp (active_alloca_convert, i); | |
2014 assert (alloca_data); | |
2015 memcpy (alloca_data, vals->dst, vals->dst_size); | |
2016 stack_like_free (vals->dst); | |
2017 Dynarr_delete (active_alloca_convert, i); | |
2018 return alloca_data; | |
2019 } | |
2020 | |
771 | 2021 /* Convert multibyte to Unicode according to the specified code page |
2022 and append the results onto the specified Dynarr. See above. */ | |
2023 | |
2024 void | |
2025 convert_multibyte_to_unicode_dynarr (const Extbyte *src, Bytecount n, | |
2026 int cp, unsigned_char_dynarr *dst) | |
2027 { | |
2367 | 2028 Charcount nout = MultiByteToWideChar (cp, MBTOWC_OPTIONS, src, n, 0, 0); |
771 | 2029 void *outp; |
2030 | |
2031 Dynarr_add_many (dst, 0, nout * sizeof (WCHAR)); | |
2032 /* dynarr's buffer may be realloc()ed by call above, so access it after */ | |
2033 outp = Dynarr_atp (dst, Dynarr_length (dst) - nout * sizeof (WCHAR)); | |
2367 | 2034 MultiByteToWideChar (cp, MBTOWC_OPTIONS, src, n, (LPWSTR) outp, nout); |
771 | 2035 } |
2036 | |
2367 | 2037 void |
2038 convert_unicode_to_multibyte_dynarr (const Extbyte *src, Bytecount n, | |
2039 int cp, unsigned_char_dynarr *dst) | |
2040 { | |
2041 Bytecount nout = WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
2042 n / sizeof (WCHAR), | |
2043 0, 0, WCTOMB_INVALID_STRING, 0); | |
2044 void *outp; | |
2045 | |
2046 Dynarr_add_many (dst, 0, nout); | |
2047 /* dynarr's buffer may be realloc()ed by call above, so access it after */ | |
2048 outp = Dynarr_atp (dst, Dynarr_length (dst) - nout); | |
2049 WideCharToMultiByte (cp, WCTOMB_OPTIONS, (LPWSTR) src, | |
2050 n / sizeof (WCHAR), (LPSTR) outp, nout, | |
2051 WCTOMB_INVALID_STRING, 0); | |
2052 } | |
2053 | |
2054 | |
771 | 2055 /* Convert MS Windows multibyte to Unicode. */ |
2056 | |
2057 static Bytecount | |
2058 mswindows_multibyte_to_unicode_convert (struct coding_stream *str, | |
2059 const unsigned char *src, | |
2060 unsigned_char_dynarr *dst, | |
2061 Bytecount n) | |
2062 { | |
2063 unsigned char *new_src = (unsigned char *) src; | |
2064 int i; | |
2065 struct mswindows_multibyte_to_unicode_coding_stream *data = | |
2066 CODING_STREAM_TYPE_DATA (str, mswindows_multibyte_to_unicode); | |
2067 Bytecount orign = n; | |
2068 | |
2069 if (data->cp == 0) | |
2070 data->cp = determine_code_page (str->codesys); | |
2071 if (data->partial_byte_present) | |
2072 { | |
2073 new_src = alloca_array (unsigned char, n + 1); | |
2074 memcpy (new_src + 1, src, n); | |
2075 new_src[0] = | |
2076 (unsigned char) data->partial_byte; | |
2077 n++; | |
2078 } | |
2079 | |
2080 if (str->direction == CODING_DECODE) | |
2081 { | |
2082 for (i = n - 1; i >= 0; i--) | |
2083 { | |
2084 if (!IsDBCSLeadByteEx (data->cp, new_src[i])) | |
2085 break; | |
2086 } | |
2087 | |
2088 i++; | |
2089 | |
2090 for (; i < n; i++) | |
2091 { | |
2092 if (IsDBCSLeadByteEx (data->cp, new_src[i])) | |
2093 i++; | |
2094 } | |
2095 | |
2096 if (i > n) | |
2097 { | |
2098 /* a char is split across the boundary */ | |
2099 data->partial_byte = new_src[n - 1]; | |
2100 data->partial_byte_present = 1; | |
2101 n--; | |
2102 } | |
2103 else | |
2104 data->partial_byte_present = 0; | |
2105 | |
2106 convert_multibyte_to_unicode_dynarr ((Extbyte *) new_src, n, data->cp, | |
2107 dst); | |
2108 } | |
2109 else | |
2110 { | |
2111 if (n & 1) | |
2112 { | |
2113 /* a char is split across the boundary */ | |
2114 data->partial_byte = new_src[n - 1]; | |
2115 data->partial_byte_present = 1; | |
2116 n--; | |
2117 } | |
2118 else | |
2119 data->partial_byte_present = 0; | |
2120 | |
2367 | 2121 convert_unicode_to_multibyte_dynarr ((Extbyte *) new_src, n, data->cp, |
2122 dst); | |
771 | 2123 } |
2124 return orign; | |
2125 } | |
2126 | |
2127 static enum source_sink_type | |
2286 | 2128 mswindows_multibyte_to_unicode_conversion_end_type (Lisp_Object UNUSED (codesys)) |
771 | 2129 { |
2130 return DECODES_BYTE_TO_BYTE; | |
2131 } | |
2132 | |
2133 | |
2134 /************************************************************************/ | |
2135 /* MS Windows Multibyte methods */ | |
2136 /************************************************************************/ | |
2137 | |
2138 struct mswindows_multibyte_coding_system | |
2139 { | |
2140 Lisp_Object code_page; | |
2141 Lisp_Object locale; | |
2142 }; | |
2143 | |
2144 struct mswindows_multibyte_coding_stream | |
2145 { | |
2146 int dummy; | |
2147 }; | |
2148 | |
1204 | 2149 static const struct memory_description |
771 | 2150 mswindows_multibyte_coding_system_description[] = { |
2151 { XD_LISP_OBJECT, | |
1204 | 2152 offsetof (struct mswindows_multibyte_coding_system, code_page) }, |
771 | 2153 { XD_LISP_OBJECT, |
1204 | 2154 offsetof (struct mswindows_multibyte_coding_system, locale) }, |
771 | 2155 { XD_END } |
2156 }; | |
2157 | |
1204 | 2158 DEFINE_CODING_SYSTEM_TYPE_WITH_DATA (mswindows_multibyte); |
2159 | |
771 | 2160 static Bytecount |
2286 | 2161 mswindows_multibyte_convert (struct coding_stream *UNUSED (str), |
2162 const UExtbyte *UNUSED (src), | |
2163 unsigned_char_dynarr *UNUSED (dst), Bytecount n) | |
771 | 2164 { |
2165 Bytecount orign = n; | |
2166 /* should never be called; is preprocessed away in the | |
2167 canonicalize method */ | |
2500 | 2168 ABORT (); |
771 | 2169 return orign; |
2170 } | |
2171 | |
2172 static void | |
2173 mswindows_multibyte_init (Lisp_Object codesys) | |
2174 { | |
2175 struct mswindows_multibyte_coding_system *data = | |
2176 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte); | |
2177 | |
2178 data->code_page = Qnil; | |
2179 data->locale = Qnil; | |
2180 } | |
2181 | |
2182 static void | |
2183 mswindows_multibyte_mark (Lisp_Object codesys) | |
2184 { | |
2185 struct mswindows_multibyte_coding_system *data = | |
2186 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte); | |
2187 | |
2188 mark_object (data->code_page); | |
2189 mark_object (data->locale); | |
2190 } | |
2191 | |
2192 static int | |
2193 mswindows_multibyte_putprop (Lisp_Object codesys, | |
2194 Lisp_Object key, | |
2195 Lisp_Object value) | |
2196 { | |
2197 struct mswindows_multibyte_coding_system *data = | |
2198 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte); | |
2199 | |
2200 if (EQ (key, Qcode_page)) | |
2201 data->code_page = value; | |
2202 else if (EQ (key, Qlocale)) | |
2203 data->locale = value; | |
2204 else | |
2205 return 0; | |
2206 return 1; | |
2207 } | |
2208 | |
2209 static Lisp_Object | |
2210 mswindows_multibyte_getprop (Lisp_Object coding_system, | |
2211 Lisp_Object prop) | |
2212 { | |
2213 struct mswindows_multibyte_coding_system *data = | |
2214 XCODING_SYSTEM_TYPE_DATA (coding_system, mswindows_multibyte); | |
2215 | |
2216 if (EQ (prop, Qcode_page)) | |
2217 return data->code_page; | |
2218 else if (EQ (prop, Qlocale)) | |
2219 return data->locale; | |
2220 else | |
2221 return Qunbound; | |
2222 } | |
2223 | |
2224 /* Convert this coding system into the proper chain. */ | |
2225 | |
2226 static Lisp_Object | |
2227 mswindows_multibyte_canonicalize (Lisp_Object codesys) | |
2228 { | |
2229 struct mswindows_multibyte_coding_system *data = | |
2230 XCODING_SYSTEM_TYPE_DATA (codesys, mswindows_multibyte); | |
2231 Lisp_Object m2u; | |
2232 | |
2233 m2u = | |
2234 make_internal_coding_system | |
2235 (Qnil, | |
2236 "internal-mswindows-multibyte-to-unicode", | |
2237 Qmswindows_multibyte_to_unicode, | |
2238 Qnil, NILP (data->locale) ? | |
2239 list2 (Qcode_page, data->code_page) : | |
2240 list4 (Qcode_page, data->code_page, Qlocale, data->locale)); | |
2241 | |
2242 return make_internal_coding_system (codesys, | |
2243 "internal-mswindows-multibyte-chain", | |
2244 Qchain, Qunbound, | |
2245 list4 (Qchain, | |
2246 list2 (m2u, Qmswindows_unicode), | |
2247 Qcanonicalize_after_coding, | |
2248 codesys)); | |
2249 } | |
2250 | |
2251 | |
2252 void | |
2253 syms_of_intl_win32 (void) | |
2254 { | |
2255 #ifdef MULE | |
2256 DEFSUBR (Fmswindows_set_current_locale); | |
2257 DEFSUBR (Fmswindows_current_locale); | |
2258 DEFSUBR (Fmswindows_user_default_locale); | |
2259 DEFSUBR (Fmswindows_system_default_locale); | |
2260 DEFSUBR (Fmswindows_locale_code_page); | |
2261 DEFSUBR (Fmswindows_locale_oem_code_page); | |
2262 DEFSUBR (Fmswindows_supported_locales); | |
2263 DEFSUBR (Fmswindows_charset_code_page); | |
2264 DEFSUBR (Fmswindows_set_charset_code_page); | |
872 | 2265 DEFSUBR (Fmswindows_charset_registry); |
2266 DEFSUBR (Fmswindows_set_charset_registry); | |
771 | 2267 |
2268 #if 0 | |
2269 DEFSUBR (Fmswindows_get_locale_info); | |
2270 DEFSUBR (Fmswindows_get_current_locale_id); | |
2271 DEFSUBR (Fmswindows_get_default_locale_id); | |
2272 DEFSUBR (Fmswindows_get_valid_locale_ids); | |
2273 DEFSUBR (Fmswindows_set_current_locale); | |
2274 | |
2275 DEFSUBR (Fmswindows_get_console_code_page); | |
2276 DEFSUBR (Fmswindows_set_console_code_page); | |
2277 DEFSUBR (Fmswindows_get_console_output_code_page); | |
2278 DEFSUBR (Fmswindows_set_console_output_code_page); | |
2279 DEFSUBR (Fmswindows_get_valid_code_pages); | |
2280 DEFSUBR (Fmswindows_get_code_page_charset); | |
2281 | |
2282 DEFSUBR (Fmswindows_get_valid_keyboard_layouts); | |
2283 DEFSUBR (Fmswindows_get_keyboard_layout); | |
2284 DEFSUBR (Fmswindows_set_keyboard_layout); | |
2285 #endif | |
2286 #endif /* MULE */ | |
2287 | |
2288 DEFSYMBOL (Qmswindows_tstr); | |
2289 DEFSYMBOL (Qmswindows_multibyte); | |
2290 DEFSYMBOL (Qmswindows_multibyte_to_unicode); | |
2291 DEFSYMBOL (Qmswindows_unicode); | |
2292 DEFSYMBOL (Qmswindows_multibyte_system_default); | |
2293 | |
2294 DEFSYMBOL (Qansi); | |
2295 DEFSYMBOL (Qoem); | |
2296 DEFSYMBOL (Qmac); | |
2297 DEFSYMBOL (Qebcdic); | |
2298 } | |
2299 | |
2300 void | |
2301 coding_system_type_create_intl_win32 (void) | |
2302 { | |
2303 INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA | |
2304 (mswindows_multibyte_to_unicode, | |
2305 "mswindows-multibyte-to-unicode-coding-system-p"); | |
2306 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, init); | |
2307 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, print); | |
2308 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, convert); | |
2309 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, getprop); | |
2310 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, putprop); | |
2311 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte_to_unicode, | |
2312 conversion_end_type); | |
2313 | |
2314 INITIALIZE_CODING_SYSTEM_TYPE_WITH_DATA | |
2315 (mswindows_multibyte, | |
2316 "mswindows-multibyte-coding-system-p"); | |
2317 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, convert); | |
2318 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, init); | |
2319 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, mark); | |
2320 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, getprop); | |
2321 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, putprop); | |
2322 CODING_SYSTEM_HAS_METHOD (mswindows_multibyte, canonicalize); | |
2323 } | |
2324 | |
2325 void | |
2326 reinit_coding_system_type_create_intl_win32 (void) | |
2327 { | |
2328 REINITIALIZE_CODING_SYSTEM_TYPE (mswindows_multibyte_to_unicode); | |
2329 REINITIALIZE_CODING_SYSTEM_TYPE (mswindows_multibyte); | |
2330 } | |
2331 | |
2332 void | |
2333 vars_of_intl_win32 (void) | |
2334 { | |
2335 #ifdef MULE | |
2336 Vmswindows_charset_code_page_table = | |
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
2337 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, Qeq); |
771 | 2338 staticpro (&Vmswindows_charset_code_page_table); |
872 | 2339 Vmswindows_charset_registry_table = |
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
2340 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, Qeq); |
872 | 2341 staticpro (&Vmswindows_charset_registry_table); |
771 | 2342 #endif /* MULE */ |
2343 } | |
2344 | |
2345 static void | |
2346 determine_if_using_unicode (void) | |
2347 { | |
2348 if (XEUNICODE_P) | |
2349 Fdefine_coding_system_alias (Qmswindows_tstr, Qmswindows_unicode); | |
2350 else | |
2351 Fdefine_coding_system_alias (Qmswindows_tstr, | |
2352 Qmswindows_multibyte_system_default); | |
2353 } | |
2354 | |
2355 void | |
2356 complex_vars_of_intl_win32 (void) | |
2357 { | |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3767
diff
changeset
|
2358 Fmake_coding_system_internal |
771 | 2359 (Qmswindows_unicode, Qunicode, |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
2360 build_defer_string ("MS Windows Unicode"), |
5345
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2361 listu (Qdocumentation, |
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2362 build_defer_string ( |
771 | 2363 "Converts to the Unicode encoding for Windows API calls.\n" |
2364 "This encoding is equivalent to standard UTF16, little-endian." | |
2365 ), | |
5345
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2366 Qmnemonic, build_ascstring ("MSW-U"), |
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2367 Qunicode_type, Qutf_16, |
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2368 Qlittle_endian, Qt, |
db326b8fe982
Use Ben's recently-introduced listu (), where appropriate.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5307
diff
changeset
|
2369 Qunbound)); |
771 | 2370 |
2371 #ifdef MULE | |
2372 /* Just temporarily. This will get fixed in mule-msw-init.el. */ | |
2373 Fdefine_coding_system_alias (Qmswindows_multibyte_system_default, | |
2374 Qraw_text); | |
2375 #else | |
2376 /* Not temporarily. These may be referenced by Lisp code so we need to | |
2377 define them. */ | |
2378 Fdefine_coding_system_alias (Qmswindows_multibyte, | |
2379 Qraw_text); | |
2380 Fdefine_coding_system_alias (Qmswindows_multibyte_system_default, | |
2381 Qraw_text); | |
2382 Fdefine_coding_system_alias (intern ("mswindows-multibyte-user-default"), | |
2383 Qraw_text); | |
2384 Fdefine_coding_system_alias (intern ("mswindows-multibyte-oem"), | |
2385 Qraw_text); | |
2386 Fdefine_coding_system_alias (intern | |
2387 ("mswindows-multibyte-oem-system-default"), | |
2388 Qraw_text); | |
2389 Fdefine_coding_system_alias (intern ("mswindows-multibyte-oem-user-default"), | |
2390 Qraw_text); | |
2391 #endif /* MULE */ | |
2392 | |
2393 determine_if_using_unicode (); | |
2394 } | |
2395 | |
2396 void | |
2397 init_intl_win32 (void) | |
2398 { | |
2399 #ifdef MULE | |
2400 set_current_lcid (GetUserDefaultLCID ()); | |
2401 #endif /* MULE */ | |
2402 | |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4690
diff
changeset
|
2403 #ifdef HAVE_CYGWIN_CONV_PATH |
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4690
diff
changeset
|
2404 Fprovide (intern ("cygwin-use-utf-8")); |
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4690
diff
changeset
|
2405 #endif |
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4690
diff
changeset
|
2406 |
771 | 2407 if (initialized) |
2408 /* If not initialized, we also call this, but early -- see the | |
2409 previous function. */ | |
2410 determine_if_using_unicode (); | |
2411 } |