Mercurial > hg > xemacs-beta
comparison src/text.h @ 1318:b531bf8658e9
[xemacs-hg @ 2003-02-21 06:56:46 by ben]
redisplay fixes et al.
PROBLEMS: Add comment about Cygwin, unexec and sysmalloc.
Move some non-general stuff out of general.
Make a section for x86.
configure.in: Add check for broken alloca in funcalls.
mule/mule-cmds.el: Alias file-name to native not vice-versa.
Do set EOL of native but not of process output to fix various
problems and be consistent with code-init.el.
code-cmds.el: Return a name not a coding system.
code-init.el: Reindent. Remove `file-name' since it should always be the same
as native.
unicode.el: Rename to load-unicode-mapping-table as suggested by the anonymous
(but rather Turnbullian) comment in unicode.c.
xemacs.dsp: Add /k to default build.
alloc.c: Make gc_currently_forbidden static.
config.h.in, lisp.h: Move some stuff to lisp.h.
console-gtk.h, console-impl.h, console-msw.h, console-x.h, event-Xt.c, event-msw.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, gtk-xemacs.c: Remove duplicated code to redraw exposed area. Add deadbox
method needed by the generalized redraw code. Defer redrawing
if already in redisplay.
frame-msw.c, event-stream.c, frame.c: Add comments about calling Lisp.
debug.c, general-slots.h: Move generalish symbols to general-slots.h.
doprnt.c: reindent.
lisp.h, dynarr.c: Add debug code for locking a dynarr to catch invalid mods.
Use in redisplay.c.
eval.c:
file-coding.c: Define file-name as alias for native not vice-versa.
frame-gtk.c, frame-x.c: Move Qwindow_id to general-slots.
dialog-msw.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, gui.c, gui.h, menubar-msw.c, menubar.c: Ensure that various glyph functions that eval within redisplay
protect the evals. Same for calls to internal_equal().
Modify various functions, e.g. gui_item_*(), to protect evals
within redisplay, taking an in_redisplay parameter if it's
possible for them to be called both inside and outside of
redisplay.
gutter.c: Defer specifier-changed updating till after redisplay, if
necessary, since we need to enter redisplay to do it.
gutter.c: Do nothing if in redisplay.
lisp.h: Add version of alloca() for use in function calls.
lisp.h: Add XCAD[D+]R up to 6 D's, and aliases X1ST, X2ND, etc.
frame.c, frame.h, redisplay.c, redisplay.h, signal.c, toolbar.c: Redo critical-section code and move from frame.c to redisplay.c.
Require that every place inside of redisplay catch errors itself,
not at the edge of the critical section (thereby bypassing the
rest of redisplay and leaving things in an inconsistent state).
Introduce separate means of holding frame-size changes without
entering a complete critical section. Introduce "post-redisplay"
methods for deferring things till after redisplay. Abort if
we enter redisplay reentrantly. Disable all quit checking in
redisplay since it's too dangerous. Ensure that all calls to
QUIT trigger an abort if unprotected.
redisplay.c, scrollbar-gtk.c, scrollbar-x.c, scrollbar.c: Create enter/exit_redisplay_critical_section_maybe() for code
that needs to ensure it's in a critical section but doesn't
interfere with an existing critical section.
sysdep.c: Use _wexecve() when under Windows NT for Unicode correctness.
text.c, text.h: Add new_dfc() functions, which return an alloca()ed value rather
than requiring an lvalue. (Not really used yet; used in another
workspace, to come.) Add some macros for SIZED_EXTERNAL.
Update the encoding aliases after involved scrutinization of the
X manual.
unicode.c: Answer the anonymous but suspiciously Turnbullian questions.
Rename parse-unicode-translation-table to
load-unicode-mapping-table, as suggested.
author | ben |
---|---|
date | Fri, 21 Feb 2003 06:57:21 +0000 |
parents | 70921960b980 |
children | 1b0339b048ce |
comparison
equal
deleted
inserted
replaced
1317:d9d08dc5e617 | 1318:b531bf8658e9 |
---|---|
1 /* Header file for text manipulation primitives and macros. | 1 /* Header file for text manipulation primitives and macros. |
2 Copyright (C) 1985-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Sun Microsystems, Inc. | 3 Copyright (C) 1995 Sun Microsystems, Inc. |
4 Copyright (C) 2000, 2001, 2002 Ben Wing. | 4 Copyright (C) 2000, 2001, 2002, 2003 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
334 #define ichar_fits_in_format(ch, fmt, object) 1 | 334 #define ichar_fits_in_format(ch, fmt, object) 1 |
335 #define objects_have_same_internal_representation(srcobj, dstobj) 1 | 335 #define objects_have_same_internal_representation(srcobj, dstobj) 1 |
336 | 336 |
337 #endif /* MULE */ | 337 #endif /* MULE */ |
338 | 338 |
339 int dfc_coding_system_is_unicode (Lisp_Object coding_system); | 339 int dfc_coding_system_is_unicode (Lisp_Object codesys); |
340 | 340 |
341 DECLARE_INLINE_HEADER ( | 341 DECLARE_INLINE_HEADER ( |
342 Bytecount dfc_external_data_len (const void *ptr, Lisp_Object codesys) | 342 Bytecount dfc_external_data_len (const void *ptr, Lisp_Object codesys) |
343 ) | 343 ) |
344 { | 344 { |
1408 the string are *ILLEGAL* (read abort() with error-checking defined). | 1408 the string are *ILLEGAL* (read abort() with error-checking defined). |
1409 void eicpy_c_len (Eistring *eistr, const Char_ASCII *c_string, len); | 1409 void eicpy_c_len (Eistring *eistr, const Char_ASCII *c_string, len); |
1410 ... from an ASCII string, with length specified. Non-ASCII characters | 1410 ... from an ASCII string, with length specified. Non-ASCII characters |
1411 in the string are *ILLEGAL* (read abort() with error-checking defined). | 1411 in the string are *ILLEGAL* (read abort() with error-checking defined). |
1412 void eicpy_ext (Eistring *eistr, const Extbyte *extdata, | 1412 void eicpy_ext (Eistring *eistr, const Extbyte *extdata, |
1413 Lisp_Object coding_system); | 1413 Lisp_Object codesys); |
1414 ... from external null-terminated data, with coding system specified. | 1414 ... from external null-terminated data, with coding system specified. |
1415 void eicpy_ext_len (Eistring *eistr, const Extbyte *extdata, | 1415 void eicpy_ext_len (Eistring *eistr, const Extbyte *extdata, |
1416 Bytecount extlen, Lisp_Object coding_system); | 1416 Bytecount extlen, Lisp_Object codesys); |
1417 ... from external data, with length and coding system specified. | 1417 ... from external data, with length and coding system specified. |
1418 void eicpy_lstream (Eistring *eistr, Lisp_Object lstream); | 1418 void eicpy_lstream (Eistring *eistr, Lisp_Object lstream); |
1419 ... from an lstream; reads data till eof. Data must be in default | 1419 ... from an lstream; reads data till eof. Data must be in default |
1420 internal format; otherwise, interpose a decoding lstream. | 1420 internal format; otherwise, interpose a decoding lstream. |
1421 | 1421 |
1590 | 1590 |
1591 ********************************************** | 1591 ********************************************** |
1592 * Converting to an external format * | 1592 * Converting to an external format * |
1593 ********************************************** | 1593 ********************************************** |
1594 | 1594 |
1595 void eito_external (Eistring *eistr, Lisp_Object coding_system); | 1595 void eito_external (Eistring *eistr, Lisp_Object codesys); |
1596 Convert the Eistring to an external format and store the result | 1596 Convert the Eistring to an external format and store the result |
1597 in the string. NOTE: Further changes to the Eistring will *NOT* | 1597 in the string. NOTE: Further changes to the Eistring will *NOT* |
1598 change the external data stored in the string. You will have to | 1598 change the external data stored in the string. You will have to |
1599 call eito_external() again in such a case if you want the external | 1599 call eito_external() again in such a case if you want the external |
1600 data. | 1600 data. |
2001 \ | 2001 \ |
2002 EI_ASSERT_ASCII (ei6, ei6len); \ | 2002 EI_ASSERT_ASCII (ei6, ei6len); \ |
2003 eicpy_ext_len (ei, ei6, ei6len, Qbinary); \ | 2003 eicpy_ext_len (ei, ei6, ei6len, Qbinary); \ |
2004 } while (0) | 2004 } while (0) |
2005 | 2005 |
2006 #define eicpy_ext_len(ei, extdata, extlen, coding_system) \ | 2006 #define eicpy_ext_len(ei, extdata, extlen, codesys) \ |
2007 do { \ | 2007 do { \ |
2008 const Extbyte *ei7 = (extdata); \ | 2008 const Extbyte *ei7 = (extdata); \ |
2009 int ei7len = (extlen); \ | 2009 int ei7len = (extlen); \ |
2010 \ | 2010 \ |
2011 TO_INTERNAL_FORMAT (DATA, (ei7, ei7len), \ | 2011 SIZED_EXTERNAL_TO_SIZED_C_STRING (ei7, ei7len, (ei)->data_, \ |
2012 ALLOCA, ((ei)->data_, (ei)->bytelen_), \ | 2012 (ei)->bytelen_, codesys); \ |
2013 coding_system); \ | |
2014 (ei)->max_size_allocated_ = (ei)->bytelen_ + 1; \ | 2013 (ei)->max_size_allocated_ = (ei)->bytelen_ + 1; \ |
2015 (ei)->charlen_ = bytecount_to_charcount ((ei)->data_, (ei)->bytelen_); \ | 2014 (ei)->charlen_ = bytecount_to_charcount ((ei)->data_, (ei)->bytelen_); \ |
2016 } while (0) | 2015 } while (0) |
2017 | 2016 |
2018 #define eicpy_ext(ei, extdata, coding_system) \ | 2017 #define eicpy_ext(ei, extdata, codesys) \ |
2019 do { \ | 2018 do { \ |
2020 const Extbyte *ei8 = (extdata); \ | 2019 const Extbyte *ei8 = (extdata); \ |
2021 \ | 2020 \ |
2022 eicpy_ext_len (ei, ei8, dfc_external_data_len (ei8, coding_system), \ | 2021 eicpy_ext_len (ei, ei8, dfc_external_data_len (ei8, codesys), \ |
2023 coding_system); \ | 2022 codesys); \ |
2024 } while (0) | 2023 } while (0) |
2025 | 2024 |
2026 #define eicpy_lbuf(eistr, lisp_buf, off, charoff, len, charlen) \ | 2025 #define eicpy_lbuf(eistr, lisp_buf, off, charoff, len, charlen) \ |
2027 NOT YET IMPLEMENTED | 2026 NOT YET IMPLEMENTED |
2028 | 2027 |
2310 eisub_1(ei, off, charoff, len, charlen, NULL, 0, 0) | 2309 eisub_1(ei, off, charoff, len, charlen, NULL, 0, 0) |
2311 | 2310 |
2312 | 2311 |
2313 /* ----- Converting to an external format ----- */ | 2312 /* ----- Converting to an external format ----- */ |
2314 | 2313 |
2315 #define eito_external(ei, coding_system) \ | 2314 #define eito_external(ei, codesys) \ |
2316 do { \ | 2315 do { \ |
2317 if ((ei)->mallocp_) \ | 2316 if ((ei)->mallocp_) \ |
2318 { \ | 2317 { \ |
2319 if ((ei)->extdata_) \ | 2318 if ((ei)->extdata_) \ |
2320 { \ | 2319 { \ |
2321 xfree ((ei)->extdata_); \ | 2320 xfree ((ei)->extdata_); \ |
2322 (ei)->extdata_ = 0; \ | 2321 (ei)->extdata_ = 0; \ |
2323 } \ | 2322 } \ |
2324 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ | 2323 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ |
2325 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ | 2324 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ |
2326 coding_system); \ | 2325 codesys); \ |
2327 } \ | 2326 } \ |
2328 else \ | 2327 else \ |
2329 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ | 2328 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ |
2330 ALLOCA, ((ei)->extdata_, (ei)->extlen_), \ | 2329 ALLOCA, ((ei)->extdata_, (ei)->extlen_), \ |
2331 coding_system); \ | 2330 codesys); \ |
2332 } while (0) | 2331 } while (0) |
2333 | 2332 |
2334 #define eiextdata(ei) ((ei)->extdata_) | 2333 #define eiextdata(ei) ((ei)->extdata_) |
2335 #define eiextlen(ei) ((ei)->extlen_) | 2334 #define eiextlen(ei) ((ei)->extlen_) |
2336 | 2335 |
2455 /* */ | 2454 /* */ |
2456 /* Converting between internal and external format */ | 2455 /* Converting between internal and external format */ |
2457 /* */ | 2456 /* */ |
2458 /************************************************************************/ | 2457 /************************************************************************/ |
2459 /* | 2458 /* |
2460 All client code should use only the two macros | 2459 The macros below are used for converting data between different formats. |
2461 | 2460 Generally, the data is textual, and the formats are related to |
2462 TO_EXTERNAL_FORMAT (source_type, source, sink_type, sink, coding_system) | 2461 internationalization (e.g. converting between internal-format text and |
2463 TO_INTERNAL_FORMAT (source_type, source, sink_type, sink, coding_system) | 2462 UTF-8) -- but the mechanism is general, and could be used for anything, |
2463 e.g. decoding gzipped data. | |
2464 | |
2465 In general, conversion involves a source of data, a sink, the existing | |
2466 format of the source data, and the desired format of the sink. The | |
2467 macros below, however, always require that either the source or sink is | |
2468 internal-format text. Therefore, in practice the conversions below | |
2469 involve source, sink, an external format (specified by a coding system), | |
2470 and the direction of conversion (internal->external or vice-versa). | |
2471 | |
2472 Sources and sinks can be raw data (sized or unsized -- when unsized, | |
2473 input data is assumed to be null-terminated [double null-terminated for | |
2474 Unicode-format data], and on output the length is not stored anywhere), | |
2475 Lisp strings, Lisp buffers, lstreams, and opaque data objects. When the | |
2476 output is raw data, the result can be allocated either with alloca() or | |
2477 malloc(). (There is currently no provision for writing into a fixed | |
2478 buffer. If you want this, use alloca() output and then copy the data -- | |
2479 but be careful with the size! Unless you are very sure of the encoding | |
2480 being used, upper bounds for the size are not in general computable.) | |
2481 The obvious restrictions on source and sink types apply (e.g. Lisp | |
2482 strings are a source and sink only for internal data). | |
2483 | |
2484 All raw data outputted will contain an extra null byte (two bytes for | |
2485 Unicode -- currently, in fact, all output data, whether internal or | |
2486 external, is double-null-terminated, but you can't count on this; see | |
2487 below). This means that enough space is allocated to contain the extra | |
2488 nulls; however, these nulls are not reflected in the returned output | |
2489 size. | |
2490 | |
2491 The most basic macros are TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. | |
2492 These can be used to convert between any kinds of sources or sinks. | |
2493 However, 99% of conversions involve raw data or Lisp strings as both | |
2494 source and sink, and usually data is output as alloca() rather than | |
2495 malloc(). For this reason, convenience macros are defined for many types | |
2496 of conversions involving raw data and/or Lisp strings, especially when | |
2497 the output is an alloca()ed string. (When the destination is a | |
2498 Lisp_String, there are other functions that should be used instead -- | |
2499 build_ext_string() and make_ext_string(), for example.) The convenience | |
2500 macros are of two types -- the older kind that store the result into a | |
2501 specified variable, and the newer kind that return the result. The newer | |
2502 kind of macros don't exist when the output is sized data, because that | |
2503 would have two return values. NOTE: All convenience macros are | |
2504 ultimately defined in terms of TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. | |
2505 Thus, any comments below about the workings of these macros also apply to | |
2506 all convenience macros. | |
2507 | |
2508 TO_EXTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) | |
2509 TO_INTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) | |
2464 | 2510 |
2465 Typical use is | 2511 Typical use is |
2466 | 2512 |
2467 TO_EXTERNAL_FORMAT (DATA, (ptr, len), | 2513 TO_EXTERNAL_FORMAT (DATA, (ptr, len), |
2468 LISP_BUFFER, buffer, | 2514 LISP_BUFFER, buffer, |
2646 these functions are not used *very* carefully. Another reason to only use | 2692 these functions are not used *very* carefully. Another reason to only use |
2647 TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ | 2693 TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */ |
2648 void | 2694 void |
2649 dfc_convert_to_external_format (dfc_conversion_type source_type, | 2695 dfc_convert_to_external_format (dfc_conversion_type source_type, |
2650 dfc_conversion_data *source, | 2696 dfc_conversion_data *source, |
2651 Lisp_Object coding_system, | 2697 Lisp_Object codesys, |
2652 dfc_conversion_type sink_type, | 2698 dfc_conversion_type sink_type, |
2653 dfc_conversion_data *sink); | 2699 dfc_conversion_data *sink); |
2654 void | 2700 void |
2655 dfc_convert_to_internal_format (dfc_conversion_type source_type, | 2701 dfc_convert_to_internal_format (dfc_conversion_type source_type, |
2656 dfc_conversion_data *source, | 2702 dfc_conversion_data *source, |
2657 Lisp_Object coding_system, | 2703 Lisp_Object codesys, |
2658 dfc_conversion_type sink_type, | 2704 dfc_conversion_type sink_type, |
2659 dfc_conversion_data *sink); | 2705 dfc_conversion_data *sink); |
2660 /* CPP Trickery */ | 2706 /* CPP Trickery */ |
2661 #define DFC_CPP_CAR(x,y) (x) | 2707 #define DFC_CPP_CAR(x,y) (x) |
2662 #define DFC_CPP_CDR(x,y) (y) | 2708 #define DFC_CPP_CDR(x,y) (y) |
2764 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) | 2810 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) |
2765 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ | 2811 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ |
2766 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ | 2812 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ |
2767 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) | 2813 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) |
2768 | 2814 |
2815 /* #define TEST_NEW_DFC */ | |
2816 | |
2769 /* Convenience macros for extremely common invocations */ | 2817 /* Convenience macros for extremely common invocations */ |
2770 #define C_STRING_TO_EXTERNAL(in, out, coding_system) \ | 2818 #ifdef TEST_NEW_DFC |
2771 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) | 2819 #define C_STRING_TO_EXTERNAL(in, out, codesys) \ |
2772 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ | 2820 do { * (Extbyte **) &(out) = \ |
2773 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) | 2821 NEW_C_STRING_TO_EXTERNAL (in, codesys); } while (0) |
2774 #define EXTERNAL_TO_C_STRING(in, out, coding_system) \ | 2822 #define SIZED_C_STRING_TO_EXTERNAL(in, inlen, out, codesys) \ |
2775 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, coding_system) | 2823 do { * (Extbyte **) &(out) = \ |
2776 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, coding_system) \ | 2824 NEW_SIZED_C_STRING_TO_EXTERNAL (in, inlen, codesys); } while (0) |
2777 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, coding_system) | 2825 #define EXTERNAL_TO_C_STRING(in, out, codesys) \ |
2778 #define LISP_STRING_TO_EXTERNAL(in, out, coding_system) \ | 2826 do { * (Ibyte **) &(out) = \ |
2779 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_ALLOCA, out, coding_system) | 2827 NEW_EXTERNAL_TO_C_STRING (in, codesys); } while (0) |
2780 #define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, coding_system) \ | 2828 #define SIZED_EXTERNAL_TO_C_STRING(in, inlen, out, codesys) \ |
2781 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_MALLOC, out, coding_system) | 2829 do { * (Ibyte **) &(out) = \ |
2830 NEW_SIZED_EXTERNAL_TO_C_STRING (in, inlen, codesys); } while (0) | |
2831 #define LISP_STRING_TO_EXTERNAL(in, out, codesys) \ | |
2832 do { * (Extbyte **) &(out) = \ | |
2833 NEW_LISP_STRING_TO_EXTERNAL (in, codesys); } while (0) | |
2834 #else | |
2835 #define C_STRING_TO_EXTERNAL(in, out, codesys) \ | |
2836 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, codesys) | |
2837 #define SIZED_C_STRING_TO_EXTERNAL(in, inlen, out, codesys) \ | |
2838 TO_EXTERNAL_FORMAT (DATA, (in, inlen), C_STRING_ALLOCA, out, codesys) | |
2839 #define EXTERNAL_TO_C_STRING(in, out, codesys) \ | |
2840 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, codesys) | |
2841 #define SIZED_EXTERNAL_TO_C_STRING(in, inlen, out, codesys) \ | |
2842 TO_INTERNAL_FORMAT (DATA, (in, inlen), C_STRING_ALLOCA, out, codesys) | |
2843 #define LISP_STRING_TO_EXTERNAL(in, out, codesys) \ | |
2844 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_ALLOCA, out, codesys) | |
2845 #endif /* TEST_NEW_DFC */ | |
2846 | |
2847 #define C_STRING_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ | |
2848 TO_EXTERNAL_FORMAT (C_STRING, in, ALLOCA, (out, outlen), codesys) | |
2849 #define SIZED_C_STRING_TO_SIZED_EXTERNAL(in, inlen, out, outlen, codesys) \ | |
2850 TO_EXTERNAL_FORMAT (DATA, (in, inlen), ALLOCA, (out, outlen), codesys) | |
2851 #define EXTERNAL_TO_SIZED_C_STRING(in, out, outlen, codesys) \ | |
2852 TO_INTERNAL_FORMAT (C_STRING, in, ALLOCA, (out, outlen), codesys) | |
2853 #define SIZED_EXTERNAL_TO_SIZED_C_STRING(in, inlen, out, outlen, codesys) \ | |
2854 TO_INTERNAL_FORMAT (DATA, (in, inlen), ALLOCA, (out, outlen), codesys) | |
2855 #define LISP_STRING_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ | |
2856 TO_EXTERNAL_FORMAT (LISP_STRING, in, ALLOCA, (out, outlen), codesys) | |
2857 | |
2858 /* In place of EXTERNAL_TO_LISP_STRING(), use build_ext_string() and/or | |
2859 make_ext_string(). */ | |
2860 | |
2861 #ifdef TEST_NEW_DFC | |
2862 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
2863 do { * (Extbyte **) &(out) = \ | |
2864 NEW_C_STRING_TO_EXTERNAL_MALLOC (in, codesys); } while (0) | |
2865 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, codesys) \ | |
2866 do { * (Ibyte **) &(out) = \ | |
2867 NEW_EXTERNAL_TO_C_STRING_MALLOC (in, codesys); } while (0) | |
2868 #define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
2869 do { * (Extbyte **) &(out) = \ | |
2870 NEW_LISP_STRING_TO_EXTERNAL_MALLOC (in, codesys); } while (0) | |
2871 #else | |
2872 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
2873 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, codesys) | |
2874 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, codesys) \ | |
2875 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, codesys) | |
2876 #define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
2877 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_MALLOC, out, codesys) | |
2878 #endif /* TEST_NEW_DFC */ | |
2879 | |
2880 enum new_dfc_src_type | |
2881 { | |
2882 DFC_EXTERNAL, | |
2883 DFC_SIZED_EXTERNAL, | |
2884 DFC_INTERNAL, | |
2885 DFC_SIZED_INTERNAL, | |
2886 DFC_LISP_STRING | |
2887 }; | |
2888 | |
2889 void *new_dfc_convert_malloc (const void *src, Bytecount src_size, | |
2890 enum new_dfc_src_type type, Lisp_Object codesys); | |
2891 void *new_dfc_convert_alloca (const char *srctext, void *alloca_data); | |
2892 Bytecount new_dfc_convert_size (const char *srctext, const void *src, | |
2893 Bytecount src_size, enum new_dfc_src_type type, | |
2894 Lisp_Object codesys); | |
2895 | |
2896 /* Version of EXTERNAL_TO_C_STRING that *RETURNS* the translated string, | |
2897 still in alloca() space. Requires some trickiness to do this, but gets | |
2898 it done! */ | |
2899 | |
2900 /* NOTE: If you make two invocations of the dfc functions below in the same | |
2901 subexpression and use the exact same expression for the source in both | |
2902 cases, you will lose. In this unlikely case, you will get an abort, and | |
2903 need to rewrite the code. | |
2904 */ | |
2905 | |
2906 /* We need to use ALLOCA_FUNCALL_OK here. Some compilers have been known | |
2907 to choke when alloca() occurs as a funcall argument, and so we check | |
2908 this in configure. Rewriting the expressions below to use a temporary | |
2909 variable, so that the call to alloca() is outside of | |
2910 new_dfc_convert_alloca(), won't help because the entire NEW_DFC call | |
2911 could be inside of a function call. */ | |
2912 | |
2913 #define NEW_DFC_CONVERT_1_ALLOCA(src, src_size, type, codesys) \ | |
2914 new_dfc_convert_alloca \ | |
2915 (#src, ALLOCA_FUNCALL_OK (new_dfc_convert_size (#src, src, src_size, \ | |
2916 type, codesys))) | |
2917 | |
2918 #define NEW_EXTERNAL_TO_C_STRING(src, codesys) \ | |
2919 (Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_EXTERNAL, codesys) | |
2920 #define NEW_EXTERNAL_TO_C_STRING_MALLOC(src, codesys) \ | |
2921 (Ibyte *) new_dfc_convert_malloc (src, -1, DFC_EXTERNAL, codesys) | |
2922 #define NEW_SIZED_EXTERNAL_TO_C_STRING(src, len, codesys) \ | |
2923 (Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_EXTERNAL, codesys) | |
2924 #define NEW_SIZED_EXTERNAL_TO_C_STRING_MALLOC(src, len, codesys) \ | |
2925 (Ibyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_EXTERNAL, codesys) | |
2926 #define NEW_C_STRING_TO_EXTERNAL(src, codesys) \ | |
2927 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_INTERNAL, codesys) | |
2928 #define NEW_C_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ | |
2929 (Extbyte *) new_dfc_convert_malloc (src, -1, DFC_INTERNAL, codesys) | |
2930 #define NEW_SIZED_C_STRING_TO_EXTERNAL(src, len, codesys) \ | |
2931 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_INTERNAL, codesys) | |
2932 #define NEW_SIZED_C_STRING_TO_EXTERNAL_MALLOC(src, len, codesys) \ | |
2933 (Extbyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_INTERNAL, codesys) | |
2934 #define NEW_LISP_STRING_TO_EXTERNAL(src, codesys) \ | |
2935 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (LISP_TO_VOID (src), -1, \ | |
2936 DFC_LISP_STRING, codesys) | |
2937 #define NEW_LISP_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ | |
2938 (Extbyte *) new_dfc_convert_malloc (LISP_TO_VOID (src), -1, \ | |
2939 DFC_LISP_STRING, codesys) | |
2782 | 2940 |
2783 /* Standins for various encodings, until we know them better */ | 2941 /* Standins for various encodings, until we know them better */ |
2784 #define Qcommand_argument_encoding Qnative | 2942 #define Qcommand_argument_encoding Qnative |
2785 #define Qenvironment_variable_encoding Qnative | 2943 #define Qenvironment_variable_encoding Qnative |
2786 #define Qunix_host_name_encoding Qnative | 2944 #define Qunix_host_name_encoding Qnative |
2787 #define Qunix_service_name_encoding Qnative | 2945 #define Qunix_service_name_encoding Qnative |
2788 #define Qmswindows_host_name_encoding Qmswindows_multibyte | 2946 #define Qmswindows_host_name_encoding Qmswindows_multibyte |
2789 #define Qmswindows_service_name_encoding Qmswindows_multibyte | 2947 #define Qmswindows_service_name_encoding Qmswindows_multibyte |
2790 | 2948 |
2791 /* Standins for various X encodings, until we know them better */ | 2949 /* Standins for various X encodings, until we know them better. |
2950 | |
2951 About encodings in X: | |
2952 | |
2953 X works with 5 different encodings: | |
2954 | |
2955 -- "Host Portable Character Encoding" == printable ASCII + space, tab, | |
2956 newline | |
2957 | |
2958 -- STRING encoding == ASCII + Latin-1 + tab, newline | |
2959 | |
2960 -- Locale-specific encoding | |
2961 | |
2962 -- Compound text == STRING encoding + ISO-2022 escape sequences to | |
2963 switch between different locale-specific encodings. | |
2964 | |
2965 -- ANSI C wide-character encoding | |
2966 | |
2967 The Host Portable Character Encoding (HPCE) is used for atom names, font | |
2968 names, color names, keysyms, geometry strings, resource manager quarks, | |
2969 display names, locale names, and various other things. When describing | |
2970 such strings, the X manual typically says "If the ... is not in the Host | |
2971 Portable Character Encoding, the result is implementation dependent." | |
2972 | |
2973 The wide-character encoding is used only in the Xwc* functions, which | |
2974 are provided as equivalents to Xmb* functions. | |
2975 | |
2976 STRING and compound text are used in the value of string properties and | |
2977 selection data, both of which are values with an associated type atom, | |
2978 which can be STRING or COMPOUND_TEXT. It can also be a locale name, as | |
2979 specified in setlocale() (#### as usual, there is no normalization | |
2980 whatsoever of these names). | |
2981 | |
2982 X also defines a type called "TEXT", which is used only as a requested | |
2983 type, and produces data in a type "convenient to the owner". However, | |
2984 there is some indication that X expects this to be the locale-specific | |
2985 encoding. | |
2986 | |
2987 According to the glossary, the locale is used in | |
2988 | |
2989 -- Encoding and processing of input method text | |
2990 -- Encoding of resource files and values | |
2991 -- Encoding and imaging of text strings | |
2992 -- Encoding and decoding for inter-client text communication | |
2993 | |
2994 The functions XmbTextListToTextProperty and XmbTextPropertyToTextList | |
2995 (and Xwc* equivalents) can be used to convert between the | |
2996 locale-specific encoding (XTextStyle), STRING (XStringStyle), and | |
2997 compound text (XCompoundTextStyle), as well as XStdICCTextStyle, which | |
2998 converts to STRING if possible, and if not, COMPOUND_TEXT. This is | |
2999 used, for example, in XmbSetWMProperties, in the window_name and | |
3000 icon_name properties (WM_NAME and WM_ICON_NAME), which are in the | |
3001 locale-specific encoding on input, and are stored as STRING if possible, | |
3002 COMPOUND_TEXT otherwise. | |
3003 */ | |
2792 | 3004 |
2793 /* !!#### Need to verify the encoding used in lwlib -- Qnative or Qctext? | 3005 /* !!#### Need to verify the encoding used in lwlib -- Qnative or Qctext? |
2794 Almost certainly the former. Use a standin for now. */ | 3006 Almost certainly the former. Use a standin for now. */ |
2795 #define Qlwlib_encoding Qnative | 3007 #define Qlwlib_encoding Qnative |
2796 | 3008 |
2797 #define Qx_atom_name_encoding Qctext | 3009 /* The Host Portable Character Encoding. */ |
2798 /* font names are often stored in atoms, so it gets sticky if we set this | 3010 #define Qx_hpc_encoding Qnative |
2799 to something different from atom-name encoding */ | 3011 |
2800 #define Qx_font_name_encoding Qctext | 3012 #define Qx_atom_name_encoding Qx_hpc_encoding |
2801 | 3013 #define Qx_font_name_encoding Qx_hpc_encoding |
2802 #define Qx_color_name_encoding Qctext | 3014 #define Qx_color_name_encoding Qx_hpc_encoding |
2803 | 3015 #define Qx_keysym_encoding Qx_hpc_encoding |
3016 #define Qx_geometry_encoding Qx_hpc_encoding | |
3017 #define Qx_resource_name_encoding Qx_hpc_encoding | |
3018 #define Qx_application_class_encoding Qx_hpc_encoding | |
2804 /* the following probably must agree with Qcommand_argument_encoding and | 3019 /* the following probably must agree with Qcommand_argument_encoding and |
2805 Qenvironment_variable_encoding */ | 3020 Qenvironment_variable_encoding */ |
2806 #define Qx_display_name_encoding Qnative | 3021 #define Qx_display_name_encoding Qx_hpc_encoding |
3022 #define Qx_xpm_data_encoding Qx_hpc_encoding | |
3023 | |
3024 /* RedHat 6.2 contains a locale called "Francais" with the C-cedilla | |
3025 encoded in ISO2022! */ | |
3026 #define Qlocale_name_encoding Qctext | |
2807 | 3027 |
2808 #define Qstrerror_encoding Qnative | 3028 #define Qstrerror_encoding Qnative |
3029 | |
3030 /* Encoding for strings coming from Offix drag-n-drop */ | |
3031 #define Qoffix_dnd_encoding Qnative | |
3032 | |
3033 /* !!#### This exists to remind us that our hexify routine is totally | |
3034 un-Muleized. */ | |
3035 #define Qdnd_hexify_encoding Qascii | |
2809 | 3036 |
2810 #define GET_STRERROR(var, num) \ | 3037 #define GET_STRERROR(var, num) \ |
2811 do { \ | 3038 do { \ |
2812 int __gsnum__ = (num); \ | 3039 int __gsnum__ = (num); \ |
2813 Extbyte * __gserr__ = strerror (__gsnum__); \ | 3040 Extbyte * __gserr__ = strerror (__gsnum__); \ |