Mercurial > hg > xemacs-beta
comparison src/text.h @ 4990:8f0cf4fd3d2c
Automatic merge
| author | Ben Wing <ben@xemacs.org> |
|---|---|
| date | Sat, 06 Feb 2010 04:01:46 -0600 |
| parents | 3c3c1d139863 |
| children | ae48681c47fa 46cf825f6158 |
comparison
equal
deleted
inserted
replaced
| 4989:d2ec55325515 | 4990:8f0cf4fd3d2c |
|---|---|
| 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, 2003, 2004, 2005 Ben Wing. | 4 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2010 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 |
| 535 #else | 535 #else |
| 536 | 536 |
| 537 #define validate_ibyte_string_backward(ptr, n) (n) | 537 #define validate_ibyte_string_backward(ptr, n) (n) |
| 538 | 538 |
| 539 #endif /* MULE */ | 539 #endif /* MULE */ |
| 540 | |
| 541 /* ASSERT_ASCTEXT_ASCII(ptr): Check that an Ascbyte * pointer points to | |
| 542 purely ASCII text. Useful for checking that putatively ASCII strings | |
| 543 (i.e. declared as Ascbyte * or const Ascbyte *) are actually ASCII. | |
| 544 This is important because otherwise we need to worry about what | |
| 545 encoding they are in -- internal or some external encoding. | |
| 546 | |
| 547 ASSERT_ASCTEXT_ASCII_LEN(ptr, len): Same as ASSERT_ASCTEXT_ASCII() | |
| 548 but where the length has been explicitly given. Useful if the string | |
| 549 may contain embedded zeroes. | |
| 550 */ | |
| 540 | 551 |
| 541 #ifdef ERROR_CHECK_TEXT | 552 #ifdef ERROR_CHECK_TEXT |
| 542 #define ASSERT_ASCTEXT_ASCII_LEN(ptr, len) \ | 553 #define ASSERT_ASCTEXT_ASCII_LEN(ptr, len) \ |
| 543 do { \ | 554 do { \ |
| 544 int aia2; \ | 555 int aia2; \ |
| 1923 \ | 1934 \ |
| 1924 ASSERT_ASCTEXT_ASCII_LEN (ei6, ei6len); \ | 1935 ASSERT_ASCTEXT_ASCII_LEN (ei6, ei6len); \ |
| 1925 eicpy_ext_len (ei, ei6, ei6len, Qbinary); \ | 1936 eicpy_ext_len (ei, ei6, ei6len, Qbinary); \ |
| 1926 } while (0) | 1937 } while (0) |
| 1927 | 1938 |
| 1928 #define eicpy_ext_len(ei, extdata, extlen, codesys) \ | 1939 #define eicpy_ext_len(ei, extdata, extlen, codesys) \ |
| 1929 do { \ | 1940 do { \ |
| 1930 const Extbyte *ei7 = (extdata); \ | 1941 const Extbyte *ei7 = (extdata); \ |
| 1931 int ei7len = (extlen); \ | 1942 int ei7len = (extlen); \ |
| 1932 \ | 1943 \ |
| 1933 SIZED_EXTERNAL_TO_SIZED_C_STRING (ei7, ei7len, (ei)->data_, \ | 1944 TO_INTERNAL_FORMAT (DATA, (ei7, ei7len), \ |
| 1934 (ei)->bytelen_, codesys); \ | 1945 ALLOCA, ((ei)->data_, (ei)->bytelen_), \ |
| 1935 (ei)->max_size_allocated_ = (ei)->bytelen_ + 1; \ | 1946 codesys); \ |
| 1947 (ei)->max_size_allocated_ = (ei)->bytelen_ + 1; \ | |
| 1936 (ei)->charlen_ = bytecount_to_charcount ((ei)->data_, (ei)->bytelen_); \ | 1948 (ei)->charlen_ = bytecount_to_charcount ((ei)->data_, (ei)->bytelen_); \ |
| 1937 } while (0) | 1949 } while (0) |
| 1938 | 1950 |
| 1939 #define eicpy_ext(ei, extdata, codesys) \ | 1951 #define eicpy_ext(ei, extdata, codesys) \ |
| 1940 do { \ | 1952 do { \ |
| 1996 #define eifree(ei) \ | 2008 #define eifree(ei) \ |
| 1997 do { \ | 2009 do { \ |
| 1998 if ((ei)->mallocp_) \ | 2010 if ((ei)->mallocp_) \ |
| 1999 { \ | 2011 { \ |
| 2000 if ((ei)->data_) \ | 2012 if ((ei)->data_) \ |
| 2001 xfree ((ei)->data_, Ibyte *); \ | 2013 xfree ((ei)->data_); \ |
| 2002 if ((ei)->extdata_) \ | 2014 if ((ei)->extdata_) \ |
| 2003 xfree ((ei)->extdata_, Extbyte *); \ | 2015 xfree ((ei)->extdata_); \ |
| 2004 eiinit_malloc (ei); \ | 2016 eiinit_malloc (ei); \ |
| 2005 } \ | 2017 } \ |
| 2006 else \ | 2018 else \ |
| 2007 eiinit (ei); \ | 2019 eiinit (ei); \ |
| 2008 } while (0) | 2020 } while (0) |
| 2023 \ | 2035 \ |
| 2024 (ei)->max_size_allocated_ = \ | 2036 (ei)->max_size_allocated_ = \ |
| 2025 eifind_large_enough_buffer (0, (ei)->bytelen_ + 1); \ | 2037 eifind_large_enough_buffer (0, (ei)->bytelen_ + 1); \ |
| 2026 ei13newdata = alloca_ibytes ((ei)->max_size_allocated_); \ | 2038 ei13newdata = alloca_ibytes ((ei)->max_size_allocated_); \ |
| 2027 memcpy (ei13newdata, (ei)->data_, (ei)->bytelen_ + 1); \ | 2039 memcpy (ei13newdata, (ei)->data_, (ei)->bytelen_ + 1); \ |
| 2028 xfree ((ei)->data_, Ibyte *); \ | 2040 xfree ((ei)->data_); \ |
| 2029 (ei)->data_ = ei13newdata; \ | 2041 (ei)->data_ = ei13newdata; \ |
| 2030 } \ | 2042 } \ |
| 2031 \ | 2043 \ |
| 2032 if ((ei)->extdata_) \ | 2044 if ((ei)->extdata_) \ |
| 2033 { \ | 2045 { \ |
| 2035 \ | 2047 \ |
| 2036 memcpy (ei13newdata, (ei)->extdata_, (ei)->extlen_); \ | 2048 memcpy (ei13newdata, (ei)->extdata_, (ei)->extlen_); \ |
| 2037 /* Double null-terminate in case of Unicode data */ \ | 2049 /* Double null-terminate in case of Unicode data */ \ |
| 2038 ei13newdata[(ei)->extlen_] = '\0'; \ | 2050 ei13newdata[(ei)->extlen_] = '\0'; \ |
| 2039 ei13newdata[(ei)->extlen_ + 1] = '\0'; \ | 2051 ei13newdata[(ei)->extlen_ + 1] = '\0'; \ |
| 2040 xfree ((ei)->extdata_, Extbyte *); \ | 2052 xfree ((ei)->extdata_); \ |
| 2041 (ei)->extdata_ = ei13newdata; \ | 2053 (ei)->extdata_ = ei13newdata; \ |
| 2042 } \ | 2054 } \ |
| 2043 } while (0) | 2055 } while (0) |
| 2044 | 2056 |
| 2045 | 2057 |
| 2237 do { \ | 2249 do { \ |
| 2238 if ((ei)->mallocp_) \ | 2250 if ((ei)->mallocp_) \ |
| 2239 { \ | 2251 { \ |
| 2240 if ((ei)->extdata_) \ | 2252 if ((ei)->extdata_) \ |
| 2241 { \ | 2253 { \ |
| 2242 xfree ((ei)->extdata_, Extbyte *); \ | 2254 xfree ((ei)->extdata_); \ |
| 2243 (ei)->extdata_ = 0; \ | 2255 (ei)->extdata_ = 0; \ |
| 2244 } \ | 2256 } \ |
| 2245 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ | 2257 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ |
| 2246 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ | 2258 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ |
| 2247 codesys); \ | 2259 codesys); \ |
| 2418 source and sink, and usually data is output as alloca() rather than | 2430 source and sink, and usually data is output as alloca() rather than |
| 2419 malloc(). For this reason, convenience macros are defined for many types | 2431 malloc(). For this reason, convenience macros are defined for many types |
| 2420 of conversions involving raw data and/or Lisp strings, especially when | 2432 of conversions involving raw data and/or Lisp strings, especially when |
| 2421 the output is an alloca()ed string. (When the destination is a | 2433 the output is an alloca()ed string. (When the destination is a |
| 2422 Lisp_String, there are other functions that should be used instead -- | 2434 Lisp_String, there are other functions that should be used instead -- |
| 2423 build_ext_string() and make_ext_string(), for example.) The convenience | 2435 build_extstring() and make_extstring(), for example.) The convenience |
| 2424 macros are of two types -- the older kind that store the result into a | 2436 macros are of two types -- the older kind that store the result into a |
| 2425 specified variable, and the newer kind that return the result. The newer | 2437 specified variable, and the newer kind that return the result. The newer |
| 2426 kind of macros don't exist when the output is sized data, because that | 2438 kind of macros don't exist when the output is sized data, because that |
| 2427 would have two return values. NOTE: All convenience macros are | 2439 would have two return values. NOTE: All convenience macros are |
| 2428 ultimately defined in terms of TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. | 2440 ultimately defined in terms of TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. |
| 2798 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) | 2810 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) |
| 2799 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ | 2811 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ |
| 2800 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ | 2812 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ |
| 2801 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) | 2813 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) |
| 2802 | 2814 |
| 2803 /* #define TEST_NEW_DFC */ | |
| 2804 | |
| 2805 /* Convenience macros for extremely common invocations */ | |
| 2806 #ifdef TEST_NEW_DFC | |
| 2807 #define C_STRING_TO_EXTERNAL(in, out, codesys) \ | |
| 2808 do { * (Extbyte **) &(out) = \ | |
| 2809 NEW_C_STRING_TO_EXTERNAL (in, codesys); } while (0) | |
| 2810 #define SIZED_C_STRING_TO_EXTERNAL(in, inlen, out, codesys) \ | |
| 2811 do { * (Extbyte **) &(out) = \ | |
| 2812 NEW_SIZED_C_STRING_TO_EXTERNAL (in, inlen, codesys); } while (0) | |
| 2813 #define EXTERNAL_TO_C_STRING(in, out, codesys) \ | |
| 2814 do { * (Ibyte **) &(out) = \ | |
| 2815 NEW_EXTERNAL_TO_C_STRING (in, codesys); } while (0) | |
| 2816 #define SIZED_EXTERNAL_TO_C_STRING(in, inlen, out, codesys) \ | |
| 2817 do { * (Ibyte **) &(out) = \ | |
| 2818 NEW_SIZED_EXTERNAL_TO_C_STRING (in, inlen, codesys); } while (0) | |
| 2819 #define LISP_STRING_TO_EXTERNAL(in, out, codesys) \ | |
| 2820 do { * (Extbyte **) &(out) = \ | |
| 2821 NEW_LISP_STRING_TO_EXTERNAL (in, codesys); } while (0) | |
| 2822 #else | |
| 2823 #define C_STRING_TO_EXTERNAL(in, out, codesys) \ | |
| 2824 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, codesys) | |
| 2825 #define SIZED_C_STRING_TO_EXTERNAL(in, inlen, out, codesys) \ | |
| 2826 TO_EXTERNAL_FORMAT (DATA, (in, inlen), C_STRING_ALLOCA, out, codesys) | |
| 2827 #define EXTERNAL_TO_C_STRING(in, out, codesys) \ | |
| 2828 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_ALLOCA, out, codesys) | |
| 2829 #define SIZED_EXTERNAL_TO_C_STRING(in, inlen, out, codesys) \ | |
| 2830 TO_INTERNAL_FORMAT (DATA, (in, inlen), C_STRING_ALLOCA, out, codesys) | |
| 2831 #define LISP_STRING_TO_EXTERNAL(in, out, codesys) \ | |
| 2832 TO_EXTERNAL_FORMAT (LISP_STRING, in, C_STRING_ALLOCA, out, codesys) | |
| 2833 #endif /* TEST_NEW_DFC */ | |
| 2834 | |
| 2835 #define C_STRING_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ | |
| 2836 TO_EXTERNAL_FORMAT (C_STRING, in, ALLOCA, (out, outlen), codesys) | |
| 2837 #define SIZED_C_STRING_TO_SIZED_EXTERNAL(in, inlen, out, outlen, codesys) \ | |
| 2838 TO_EXTERNAL_FORMAT (DATA, (in, inlen), ALLOCA, (out, outlen), codesys) | |
| 2839 #define EXTERNAL_TO_SIZED_C_STRING(in, out, outlen, codesys) \ | |
| 2840 TO_INTERNAL_FORMAT (C_STRING, in, ALLOCA, (out, outlen), codesys) | |
| 2841 #define SIZED_EXTERNAL_TO_SIZED_C_STRING(in, inlen, out, outlen, codesys) \ | |
| 2842 TO_INTERNAL_FORMAT (DATA, (in, inlen), ALLOCA, (out, outlen), codesys) | |
| 2843 #define LISP_STRING_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ | |
| 2844 TO_EXTERNAL_FORMAT (LISP_STRING, in, ALLOCA, (out, outlen), codesys) | |
| 2845 | |
| 2846 /* In place of EXTERNAL_TO_LISP_STRING(), use build_ext_string() and/or | |
| 2847 make_ext_string(). */ | |
| 2848 | |
| 2849 #ifdef TEST_NEW_DFC | |
| 2850 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
| 2851 do { * (Extbyte **) &(out) = \ | |
| 2852 NEW_C_STRING_TO_EXTERNAL_MALLOC (in, codesys); } while (0) | |
| 2853 #define SIZED_C_STRING_TO_EXTERNAL_MALLOC(in, inlen, out, codesys) \ | |
| 2854 do { * (Extbyte **) &(out) = \ | |
| 2855 NEW_SIZED_C_STRING_TO_EXTERNAL_MALLOC (in, inlen, codesys); } \ | |
| 2856 while (0) | |
| 2857 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, codesys) \ | |
| 2858 do { * (Ibyte **) &(out) = \ | |
| 2859 NEW_EXTERNAL_TO_C_STRING_MALLOC (in, codesys); } while (0) | |
| 2860 #define SIZED_EXTERNAL_TO_C_STRING_MALLOC(in, inlen, out, codesys) \ | |
| 2861 do { * (Ibyte **) &(out) = \ | |
| 2862 NEW_SIZED_EXTERNAL_TO_C_STRING_MALLOC (in, inlen, codesys); } \ | |
| 2863 while (0) | |
| 2864 #define LISP_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
| 2865 do { * (Extbyte **) &(out) = \ | |
| 2866 NEW_LISP_STRING_TO_EXTERNAL_MALLOC (in, codesys); } while (0) | |
| 2867 #else | |
| 2868 #define C_STRING_TO_EXTERNAL_MALLOC(in, out, codesys) \ | |
| 2869 TO_EXTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, codesys) | |
| 2870 #define SIZED_C_STRING_TO_EXTERNAL_MALLOC(in, inlen, out, codesys) \ | |
| 2871 TO_EXTERNAL_FORMAT (DATA, (in, inlen), C_STRING_MALLOC, out, codesys) | |
| 2872 #define EXTERNAL_TO_C_STRING_MALLOC(in, out, codesys) \ | |
| 2873 TO_INTERNAL_FORMAT (C_STRING, in, C_STRING_MALLOC, out, codesys) | |
| 2874 #define SIZED_EXTERNAL_TO_C_STRING_MALLOC(in, inlen, out, codesys) \ | |
| 2875 TO_INTERNAL_FORMAT (DATA, (in, inlen), 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 #define C_STRING_TO_SIZED_EXTERNAL_MALLOC(in, out, outlen, codesys) \ | |
| 2881 TO_EXTERNAL_FORMAT (C_STRING, in, MALLOC, (out, outlen), codesys) | |
| 2882 #define SIZED_C_STRING_TO_SIZED_EXTERNAL_MALLOC(in, inlen, out, outlen, \ | |
| 2883 codesys) \ | |
| 2884 TO_EXTERNAL_FORMAT (DATA, (in, inlen), MALLOC, (out, outlen), codesys) | |
| 2885 #define EXTERNAL_TO_SIZED_C_STRING_MALLOC(in, out, outlen, codesys) \ | |
| 2886 TO_INTERNAL_FORMAT (C_STRING, in, MALLOC, (out, outlen), codesys) | |
| 2887 #define SIZED_EXTERNAL_TO_SIZED_C_STRING_MALLOC(in, inlen, out, outlen, \ | |
| 2888 codesys) \ | |
| 2889 TO_INTERNAL_FORMAT (DATA, (in, inlen), MALLOC, (out, outlen), codesys) | |
| 2890 #define LISP_STRING_TO_SIZED_EXTERNAL_MALLOC(in, out, outlen, codesys) \ | |
| 2891 TO_EXTERNAL_FORMAT (LISP_STRING, in, MALLOC, (out, outlen), codesys) | |
| 2892 | |
| 2893 enum new_dfc_src_type | 2815 enum new_dfc_src_type |
| 2894 { | 2816 { |
| 2895 DFC_EXTERNAL, | 2817 DFC_EXTERNAL, |
| 2896 DFC_SIZED_EXTERNAL, | 2818 DFC_SIZED_EXTERNAL, |
| 2897 DFC_INTERNAL, | 2819 DFC_INTERNAL, |
| 2910 MODULE_API void *new_dfc_convert_copy_data (const char *srctext, | 2832 MODULE_API void *new_dfc_convert_copy_data (const char *srctext, |
| 2911 void *alloca_data); | 2833 void *alloca_data); |
| 2912 | 2834 |
| 2913 END_C_DECLS | 2835 END_C_DECLS |
| 2914 | 2836 |
| 2915 /* Version of EXTERNAL_TO_C_STRING that *RETURNS* the translated string, | 2837 /* Version of EXTERNAL_TO_ITEXT that *RETURNS* the translated string, |
| 2916 still in alloca() space. Requires some trickiness to do this, but gets | 2838 still in alloca() space. Requires some trickiness to do this, but gets |
| 2917 it done! */ | 2839 it done! */ |
| 2918 | 2840 |
| 2919 /* NOTE: If you make two invocations of the dfc functions below in the same | 2841 /* NOTE: If you make two invocations of the dfc functions below in the same |
| 2920 subexpression and use the exact same expression for the source in both | 2842 subexpression and use the exact same expression for the source in both |
| 2932 #define NEW_DFC_CONVERT_1_ALLOCA(src, src_size, type, codesys) \ | 2854 #define NEW_DFC_CONVERT_1_ALLOCA(src, src_size, type, codesys) \ |
| 2933 new_dfc_convert_copy_data \ | 2855 new_dfc_convert_copy_data \ |
| 2934 (#src, ALLOCA_FUNCALL_OK (new_dfc_convert_size (#src, src, src_size, \ | 2856 (#src, ALLOCA_FUNCALL_OK (new_dfc_convert_size (#src, src, src_size, \ |
| 2935 type, codesys))) | 2857 type, codesys))) |
| 2936 | 2858 |
| 2937 #define NEW_EXTERNAL_TO_C_STRING(src, codesys) \ | 2859 #define EXTERNAL_TO_ITEXT(src, codesys) \ |
| 2938 (Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_EXTERNAL, codesys) | 2860 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_EXTERNAL, codesys)) |
| 2939 #define NEW_EXTERNAL_TO_C_STRING_MALLOC(src, codesys) \ | 2861 #define EXTERNAL_TO_ITEXT_MALLOC(src, codesys) \ |
| 2940 (Ibyte *) new_dfc_convert_malloc (src, -1, DFC_EXTERNAL, codesys) | 2862 ((Ibyte *) new_dfc_convert_malloc (src, -1, DFC_EXTERNAL, codesys)) |
| 2941 #define NEW_SIZED_EXTERNAL_TO_C_STRING(src, len, codesys) \ | 2863 #define SIZED_EXTERNAL_TO_ITEXT(src, len, codesys) \ |
| 2942 (Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_EXTERNAL, codesys) | 2864 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_EXTERNAL, codesys)) |
| 2943 #define NEW_SIZED_EXTERNAL_TO_C_STRING_MALLOC(src, len, codesys) \ | 2865 #define SIZED_EXTERNAL_TO_ITEXT_MALLOC(src, len, codesys) \ |
| 2944 (Ibyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_EXTERNAL, codesys) | 2866 ((Ibyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_EXTERNAL, codesys)) |
| 2945 #define NEW_C_STRING_TO_EXTERNAL(src, codesys) \ | 2867 #define ITEXT_TO_EXTERNAL(src, codesys) \ |
| 2946 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_INTERNAL, codesys) | 2868 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_INTERNAL, codesys)) |
| 2947 #define NEW_C_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ | 2869 #define ITEXT_TO_EXTERNAL_MALLOC(src, codesys) \ |
| 2948 (Extbyte *) new_dfc_convert_malloc (src, -1, DFC_INTERNAL, codesys) | 2870 ((Extbyte *) new_dfc_convert_malloc (src, -1, DFC_INTERNAL, codesys)) |
| 2949 #define NEW_SIZED_C_STRING_TO_EXTERNAL(src, len, codesys) \ | 2871 #define LISP_STRING_TO_EXTERNAL(src, codesys) \ |
| 2950 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_INTERNAL, codesys) | 2872 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (LISP_TO_VOID (src), -1, \ |
| 2951 #define NEW_SIZED_C_STRING_TO_EXTERNAL_MALLOC(src, len, codesys) \ | 2873 DFC_LISP_STRING, codesys)) |
| 2952 (Extbyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_INTERNAL, codesys) | 2874 #define LISP_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ |
| 2953 #define NEW_LISP_STRING_TO_EXTERNAL(src, codesys) \ | 2875 ((Extbyte *) new_dfc_convert_malloc (LISP_TO_VOID (src), -1, \ |
| 2954 (Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (LISP_TO_VOID (src), -1, \ | 2876 DFC_LISP_STRING, codesys)) |
| 2955 DFC_LISP_STRING, codesys) | 2877 /* In place of EXTERNAL_TO_LISP_STRING(), use build_extstring() and/or |
| 2956 #define NEW_LISP_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ | 2878 make_extstring(). */ |
| 2957 (Extbyte *) new_dfc_convert_malloc (LISP_TO_VOID (src), -1, \ | 2879 |
| 2958 DFC_LISP_STRING, codesys) | 2880 /* The next four have two outputs, so we make both of them be parameters */ |
| 2959 | 2881 #define ITEXT_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ |
| 2960 /* Standins for various encodings. */ | 2882 TO_EXTERNAL_FORMAT (C_STRING, in, ALLOCA, (out, outlen), codesys) |
| 2961 #ifdef WEXTTEXT_IS_WIDE | 2883 #define LISP_STRING_TO_SIZED_EXTERNAL(in, out, outlen, codesys) \ |
| 2962 #define Qcommand_argument_encoding Qmswindows_unicode | 2884 TO_EXTERNAL_FORMAT (LISP_STRING, in, ALLOCA, (out, outlen), codesys) |
| 2963 #define Qenvironment_variable_encoding Qmswindows_unicode | 2885 #define ITEXT_TO_SIZED_EXTERNAL_MALLOC(in, out, outlen, codesys) \ |
| 2964 #else | 2886 TO_EXTERNAL_FORMAT (C_STRING, in, MALLOC, (out, outlen), codesys) |
| 2965 #define Qcommand_argument_encoding Qnative | 2887 #define LISP_STRING_TO_SIZED_EXTERNAL_MALLOC(in, out, outlen, codesys) \ |
| 2966 #define Qenvironment_variable_encoding Qnative | 2888 TO_EXTERNAL_FORMAT (LISP_STRING, in, MALLOC, (out, outlen), codesys) |
| 2967 #endif | |
| 2968 #define Qunix_host_name_encoding Qnative | |
| 2969 #define Qunix_service_name_encoding Qnative | |
| 2970 #define Qtime_function_encoding Qnative | |
| 2971 #define Qtime_zone_encoding Qtime_function_encoding | |
| 2972 #define Qmswindows_host_name_encoding Qmswindows_multibyte | |
| 2973 #define Qmswindows_service_name_encoding Qmswindows_multibyte | |
| 2974 #define Quser_name_encoding Qnative | |
| 2975 #define Qerror_message_encoding Qnative | |
| 2976 #define Qjpeg_error_message_encoding Qerror_message_encoding | |
| 2977 #define Qtooltalk_encoding Qnative | |
| 2978 #define Qgtk_encoding Qnative | |
| 2979 | 2889 |
| 2980 /* Wexttext functions. The type of Wexttext is selected at compile time | 2890 /* Wexttext functions. The type of Wexttext is selected at compile time |
| 2981 and will sometimes be wchar_t, sometimes char. */ | 2891 and will sometimes be wchar_t, sometimes char. */ |
| 2982 | 2892 |
| 2983 int wcscmp_ascii (const wchar_t *s1, const Ascbyte *s2); | 2893 int wcscmp_ascii (const wchar_t *s1, const Ascbyte *s2); |
| 2999 #define wext_strrchr wcsrchr | 2909 #define wext_strrchr wcsrchr |
| 3000 #define wext_strdup wcsdup | 2910 #define wext_strdup wcsdup |
| 3001 #define wext_atol(str) wcstol (str, 0, 10) | 2911 #define wext_atol(str) wcstol (str, 0, 10) |
| 3002 #define wext_sprintf wsprintfW /* Huh? both wsprintfA and wsprintfW? */ | 2912 #define wext_sprintf wsprintfW /* Huh? both wsprintfA and wsprintfW? */ |
| 3003 #define wext_getenv _wgetenv | 2913 #define wext_getenv _wgetenv |
| 3004 #define build_wext_string(str, cs) build_ext_string ((Extbyte *) str, cs) | 2914 #define build_wext_string(str, cs) build_extstring ((Extbyte *) str, cs) |
| 3005 #define WEXTTEXT_TO_8_BIT(arg) WEXTTEXT_TO_MULTIBYTE(arg) | 2915 #define WEXTTEXT_TO_8_BIT(arg) WEXTTEXT_TO_MULTIBYTE(arg) |
| 3006 #ifdef WIN32_NATIVE | 2916 #ifdef WIN32_NATIVE |
| 3007 int XCDECL wext_retry_open (const Wexttext *path, int oflag, ...); | 2917 int XCDECL wext_retry_open (const Wexttext *path, int oflag, ...); |
| 3008 #else | 2918 #else |
| 3009 #error Cannot handle Wexttext yet on this system | 2919 #error Cannot handle Wexttext yet on this system |
| 3024 #define wext_strrchr strrchr | 2934 #define wext_strrchr strrchr |
| 3025 #define wext_strdup xstrdup | 2935 #define wext_strdup xstrdup |
| 3026 #define wext_atol(str) atol (str) | 2936 #define wext_atol(str) atol (str) |
| 3027 #define wext_sprintf sprintf | 2937 #define wext_sprintf sprintf |
| 3028 #define wext_getenv getenv | 2938 #define wext_getenv getenv |
| 3029 #define build_wext_string build_ext_string | 2939 #define build_wext_string build_extstring |
| 3030 #define wext_retry_open retry_open | 2940 #define wext_retry_open retry_open |
| 3031 #define wext_access access | 2941 #define wext_access access |
| 3032 #define wext_stat stat | 2942 #define wext_stat stat |
| 3033 #define WEXTTEXT_TO_8_BIT(arg) ((Extbyte *) arg) | 2943 #define WEXTTEXT_TO_8_BIT(arg) ((Extbyte *) arg) |
| 3034 #endif | 2944 #endif |
| 3035 | 2945 |
| 3036 /* Standins for various X encodings. | 2946 /* Standins for various encodings. |
| 3037 | 2947 |
| 3038 About encodings in X: | 2948 About encodings in X: |
| 3039 | 2949 |
| 3040 X works with 5 different encodings: | 2950 X works with 5 different encodings: |
| 3041 | 2951 |
| 3086 used, for example, in XmbSetWMProperties, in the window_name and | 2996 used, for example, in XmbSetWMProperties, in the window_name and |
| 3087 icon_name properties (WM_NAME and WM_ICON_NAME), which are in the | 2997 icon_name properties (WM_NAME and WM_ICON_NAME), which are in the |
| 3088 locale-specific encoding on input, and are stored as STRING if possible, | 2998 locale-specific encoding on input, and are stored as STRING if possible, |
| 3089 COMPOUND_TEXT otherwise. | 2999 COMPOUND_TEXT otherwise. |
| 3090 */ | 3000 */ |
| 3001 | |
| 3002 #ifdef WEXTTEXT_IS_WIDE | |
| 3003 #define Qcommand_argument_encoding Qmswindows_unicode | |
| 3004 #define Qenvironment_variable_encoding Qmswindows_unicode | |
| 3005 #else | |
| 3006 #define Qcommand_argument_encoding Qnative | |
| 3007 #define Qenvironment_variable_encoding Qnative | |
| 3008 #endif | |
| 3009 #define Qunix_host_name_encoding Qnative | |
| 3010 #define Qunix_service_name_encoding Qnative | |
| 3011 #define Qtime_function_encoding Qnative | |
| 3012 #define Qtime_zone_encoding Qtime_function_encoding | |
| 3013 #define Qmswindows_host_name_encoding Qmswindows_multibyte | |
| 3014 #define Qmswindows_service_name_encoding Qmswindows_multibyte | |
| 3015 #define Quser_name_encoding Qnative | |
| 3016 #define Qerror_message_encoding Qnative | |
| 3017 #define Qjpeg_error_message_encoding Qerror_message_encoding | |
| 3018 #define Qtooltalk_encoding Qnative | |
| 3019 #define Qgtk_encoding Qnative | |
| 3020 | |
| 3021 #define Qdll_symbol_encoding Qnative | |
| 3022 #define Qdll_function_name_encoding Qdll_symbol_encoding | |
| 3023 #define Qdll_variable_name_encoding Qdll_symbol_encoding | |
| 3024 #define Qdll_filename_encoding Qfile_name | |
| 3025 #define Qemodule_string_encoding Qnative | |
| 3091 | 3026 |
| 3092 /* !!#### Need to verify the encoding used in lwlib -- Qnative or Qctext? | 3027 /* !!#### Need to verify the encoding used in lwlib -- Qnative or Qctext? |
| 3093 Almost certainly the former. Use a standin for now. */ | 3028 Almost certainly the former. Use a standin for now. */ |
| 3094 #define Qlwlib_encoding Qnative | 3029 #define Qlwlib_encoding Qnative |
| 3095 | 3030 |
| 3128 int __gsnum__ = (num); \ | 3063 int __gsnum__ = (num); \ |
| 3129 Extbyte * __gserr__ = strerror (__gsnum__); \ | 3064 Extbyte * __gserr__ = strerror (__gsnum__); \ |
| 3130 \ | 3065 \ |
| 3131 if (!__gserr__) \ | 3066 if (!__gserr__) \ |
| 3132 { \ | 3067 { \ |
| 3133 var = alloca_ibytes (99); \ | 3068 var = alloca_ibytes (99); \ |
| 3134 qxesprintf (var, "Unknown error %d", __gsnum__); \ | 3069 qxesprintf (var, "Unknown error %d", __gsnum__); \ |
| 3135 } \ | 3070 } \ |
| 3136 else \ | 3071 else \ |
| 3137 EXTERNAL_TO_C_STRING (__gserr__, var, Qstrerror_encoding); \ | 3072 var = EXTERNAL_TO_ITEXT (__gserr__, Qstrerror_encoding); \ |
| 3138 } while (0) | 3073 } while (0) |
| 3139 | 3074 |
| 3140 #endif /* INCLUDED_text_h_ */ | 3075 #endif /* INCLUDED_text_h_ */ |
