Mercurial > hg > xemacs-beta
comparison src/text.h @ 5026:46cf825f6158
revamp DFC comment in text.h, some whitespace cleanup
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-10 Ben Wing <ben@xemacs.org>
* text.h:
* text.h (VALIDATE_IBYTEPTR_BACKWARD):
* text.h (EI_ALLOC):
* text.h (eicpyout_alloca_fmt):
* text.h (eifree):
* text.h (eito_alloca):
* text.h (eito_external):
* text.h (DFC_LISP_STRING_USE_CONVERTED_DATA):
* text.h (EXTERNAL_TO_ITEXT):
(1) Fix up long comment about the internal-external conversion
macros to reflect the recent changes to the macros.
(2) Reformat the macros in text.h so they line up properly.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 10 Feb 2010 07:15:36 -0600 |
parents | 3c3c1d139863 |
children | 22179cd0fe15 |
comparison
equal
deleted
inserted
replaced
5002:0cd784a6ec44 | 5026:46cf825f6158 |
---|---|
478 */ | 478 */ |
479 | 479 |
480 /* Note that this reads the byte at *PTR! */ | 480 /* Note that this reads the byte at *PTR! */ |
481 | 481 |
482 #define VALIDATE_IBYTEPTR_BACKWARD(ptr) do { \ | 482 #define VALIDATE_IBYTEPTR_BACKWARD(ptr) do { \ |
483 while (!valid_ibyteptr_p (ptr)) ptr--; \ | 483 while (!valid_ibyteptr_p (ptr)) ptr--; \ |
484 } while (0) | 484 } while (0) |
485 | 485 |
486 /* Make sure that PTR is pointing to the beginning of a character. If not, | 486 /* Make sure that PTR is pointing to the beginning of a character. If not, |
487 move forward until this is the case. Note that there are not too many | 487 move forward until this is the case. Note that there are not too many |
488 places where it is legitimate to do this sort of thing. It's an error | 488 places where it is legitimate to do this sort of thing. It's an error |
1812 /* Make sure we can hold NEWBYTELEN bytes (which is NEWCHARLEN chars) | 1812 /* Make sure we can hold NEWBYTELEN bytes (which is NEWCHARLEN chars) |
1813 plus a zero terminator. Preserve existing data as much as possible, | 1813 plus a zero terminator. Preserve existing data as much as possible, |
1814 including existing zero terminator. Put a new zero terminator where it | 1814 including existing zero terminator. Put a new zero terminator where it |
1815 should go if NEWZ if non-zero. All args but EI are evalled only once. */ | 1815 should go if NEWZ if non-zero. All args but EI are evalled only once. */ |
1816 | 1816 |
1817 #define EI_ALLOC(ei, newbytelen, newcharlen, newz) \ | 1817 #define EI_ALLOC(ei, newbytelen, newcharlen, newz) \ |
1818 do { \ | 1818 do { \ |
1819 int ei1oldeibytelen = (ei)->bytelen_; \ | 1819 int ei1oldeibytelen = (ei)->bytelen_; \ |
1820 \ | 1820 \ |
1821 (ei)->charlen_ = (newcharlen); \ | 1821 (ei)->charlen_ = (newcharlen); \ |
1822 (ei)->bytelen_ = (newbytelen); \ | 1822 (ei)->bytelen_ = (newbytelen); \ |
1823 \ | 1823 \ |
1824 if (ei1oldeibytelen != (ei)->bytelen_) \ | 1824 if (ei1oldeibytelen != (ei)->bytelen_) \ |
1825 { \ | 1825 { \ |
1826 int ei1newsize = (ei)->max_size_allocated_; \ | 1826 int ei1newsize = (ei)->max_size_allocated_; \ |
1827 while (ei1newsize < (ei)->bytelen_ + 1) \ | 1827 while (ei1newsize < (ei)->bytelen_ + 1) \ |
1828 { \ | 1828 { \ |
1829 ei1newsize = (int) (ei1newsize * 1.5); \ | 1829 ei1newsize = (int) (ei1newsize * 1.5); \ |
1830 if (ei1newsize < 32) \ | 1830 if (ei1newsize < 32) \ |
1831 ei1newsize = 32; \ | 1831 ei1newsize = 32; \ |
1832 } \ | 1832 } \ |
1833 if (ei1newsize != (ei)->max_size_allocated_) \ | 1833 if (ei1newsize != (ei)->max_size_allocated_) \ |
1834 { \ | 1834 { \ |
1835 if ((ei)->mallocp_) \ | 1835 if ((ei)->mallocp_) \ |
1836 /* xrealloc always preserves existing data as much as possible */ \ | 1836 /* xrealloc always preserves existing data as much as possible */ \ |
1837 (ei)->data_ = (Ibyte *) xrealloc ((ei)->data_, ei1newsize); \ | 1837 (ei)->data_ = (Ibyte *) xrealloc ((ei)->data_, ei1newsize); \ |
1838 else \ | 1838 else \ |
1839 { \ | 1839 { \ |
1840 /* We don't have realloc, so ALLOCA() more space and copy the \ | 1840 /* We don't have realloc, so ALLOCA() more space and copy the \ |
1841 data into it. */ \ | 1841 data into it. */ \ |
1842 Ibyte *ei1oldeidata = (ei)->data_; \ | 1842 Ibyte *ei1oldeidata = (ei)->data_; \ |
1843 (ei)->data_ = alloca_ibytes (ei1newsize); \ | 1843 (ei)->data_ = alloca_ibytes (ei1newsize); \ |
1844 if (ei1oldeidata) \ | 1844 if (ei1oldeidata) \ |
1845 memcpy ((ei)->data_, ei1oldeidata, ei1oldeibytelen + 1); \ | 1845 memcpy ((ei)->data_, ei1oldeidata, ei1oldeibytelen + 1); \ |
1846 } \ | 1846 } \ |
1847 (ei)->max_size_allocated_ = ei1newsize; \ | 1847 (ei)->max_size_allocated_ = ei1newsize; \ |
1848 } \ | 1848 } \ |
1849 if (newz) \ | 1849 if (newz) \ |
1850 (ei)->data_[(ei)->bytelen_] = '\0'; \ | 1850 (ei)->data_[(ei)->bytelen_] = '\0'; \ |
1851 } \ | 1851 } \ |
1852 } while (0) | 1852 } while (0) |
1853 | 1853 |
1854 #define EI_ALLOC_AND_COPY(ei, data, bytelen, charlen) \ | 1854 #define EI_ALLOC_AND_COPY(ei, data, bytelen, charlen) \ |
1855 do { \ | 1855 do { \ |
1856 EI_ALLOC (ei, bytelen, charlen, 1); \ | 1856 EI_ALLOC (ei, bytelen, charlen, 1); \ |
1997 Bytecount *ei23lenout = &(lenout); \ | 1997 Bytecount *ei23lenout = &(lenout); \ |
1998 \ | 1998 \ |
1999 assert (ei23fmt == FORMAT_DEFAULT); \ | 1999 assert (ei23fmt == FORMAT_DEFAULT); \ |
2000 \ | 2000 \ |
2001 *ei23lenout = (eistr)->bytelen_; \ | 2001 *ei23lenout = (eistr)->bytelen_; \ |
2002 *ei23ptrout = alloca_ibytes ((eistr)->bytelen_ + 1); \ | 2002 *ei23ptrout = alloca_ibytes ((eistr)->bytelen_ + 1); \ |
2003 memcpy (*ei23ptrout, (eistr)->data_, (eistr)->bytelen_ + 1); \ | 2003 memcpy (*ei23ptrout, (eistr)->data_, (eistr)->bytelen_ + 1); \ |
2004 } while (0) | 2004 } while (0) |
2005 | 2005 |
2006 /* ----- Moving to the heap ----- */ | 2006 /* ----- Moving to the heap ----- */ |
2007 | 2007 |
2008 #define eifree(ei) \ | 2008 #define eifree(ei) \ |
2009 do { \ | 2009 do { \ |
2010 if ((ei)->mallocp_) \ | 2010 if ((ei)->mallocp_) \ |
2011 { \ | 2011 { \ |
2012 if ((ei)->data_) \ | 2012 if ((ei)->data_) \ |
2013 xfree ((ei)->data_); \ | 2013 xfree ((ei)->data_); \ |
2014 if ((ei)->extdata_) \ | 2014 if ((ei)->extdata_) \ |
2015 xfree ((ei)->extdata_); \ | 2015 xfree ((ei)->extdata_); \ |
2016 eiinit_malloc (ei); \ | 2016 eiinit_malloc (ei); \ |
2017 } \ | 2017 } \ |
2018 else \ | 2018 else \ |
2019 eiinit (ei); \ | 2019 eiinit (ei); \ |
2020 } while (0) | 2020 } while (0) |
2035 \ | 2035 \ |
2036 (ei)->max_size_allocated_ = \ | 2036 (ei)->max_size_allocated_ = \ |
2037 eifind_large_enough_buffer (0, (ei)->bytelen_ + 1); \ | 2037 eifind_large_enough_buffer (0, (ei)->bytelen_ + 1); \ |
2038 ei13newdata = alloca_ibytes ((ei)->max_size_allocated_); \ | 2038 ei13newdata = alloca_ibytes ((ei)->max_size_allocated_); \ |
2039 memcpy (ei13newdata, (ei)->data_, (ei)->bytelen_ + 1); \ | 2039 memcpy (ei13newdata, (ei)->data_, (ei)->bytelen_ + 1); \ |
2040 xfree ((ei)->data_); \ | 2040 xfree ((ei)->data_); \ |
2041 (ei)->data_ = ei13newdata; \ | 2041 (ei)->data_ = ei13newdata; \ |
2042 } \ | 2042 } \ |
2043 \ | 2043 \ |
2044 if ((ei)->extdata_) \ | 2044 if ((ei)->extdata_) \ |
2045 { \ | 2045 { \ |
2047 \ | 2047 \ |
2048 memcpy (ei13newdata, (ei)->extdata_, (ei)->extlen_); \ | 2048 memcpy (ei13newdata, (ei)->extdata_, (ei)->extlen_); \ |
2049 /* Double null-terminate in case of Unicode data */ \ | 2049 /* Double null-terminate in case of Unicode data */ \ |
2050 ei13newdata[(ei)->extlen_] = '\0'; \ | 2050 ei13newdata[(ei)->extlen_] = '\0'; \ |
2051 ei13newdata[(ei)->extlen_ + 1] = '\0'; \ | 2051 ei13newdata[(ei)->extlen_ + 1] = '\0'; \ |
2052 xfree ((ei)->extdata_); \ | 2052 xfree ((ei)->extdata_); \ |
2053 (ei)->extdata_ = ei13newdata; \ | 2053 (ei)->extdata_ = ei13newdata; \ |
2054 } \ | 2054 } \ |
2055 } while (0) | 2055 } while (0) |
2056 | 2056 |
2057 | 2057 |
2249 do { \ | 2249 do { \ |
2250 if ((ei)->mallocp_) \ | 2250 if ((ei)->mallocp_) \ |
2251 { \ | 2251 { \ |
2252 if ((ei)->extdata_) \ | 2252 if ((ei)->extdata_) \ |
2253 { \ | 2253 { \ |
2254 xfree ((ei)->extdata_); \ | 2254 xfree ((ei)->extdata_); \ |
2255 (ei)->extdata_ = 0; \ | 2255 (ei)->extdata_ = 0; \ |
2256 } \ | 2256 } \ |
2257 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ | 2257 TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_), \ |
2258 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ | 2258 MALLOC, ((ei)->extdata_, (ei)->extlen_), \ |
2259 codesys); \ | 2259 codesys); \ |
2427 The most basic macros are TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. | 2427 The most basic macros are TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. |
2428 These can be used to convert between any kinds of sources or sinks. | 2428 These can be used to convert between any kinds of sources or sinks. |
2429 However, 99% of conversions involve raw data or Lisp strings as both | 2429 However, 99% of conversions involve raw data or Lisp strings as both |
2430 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 |
2431 malloc(). For this reason, convenience macros are defined for many types | 2431 malloc(). For this reason, convenience macros are defined for many types |
2432 of conversions involving raw data and/or Lisp strings, especially when | 2432 of conversions involving raw data and/or Lisp strings, when the output is |
2433 the output is an alloca()ed string. (When the destination is a | 2433 an alloca()ed or malloc()ed string. (When the destination is a |
2434 Lisp_String, there are other functions that should be used instead -- | 2434 Lisp_String, there are other functions that should be used instead -- |
2435 build_extstring() and make_extstring(), for example.) The convenience | 2435 build_extstring() and make_extstring(), for example.) In general, the |
2436 macros are of two types -- the older kind that store the result into a | 2436 convenience macros return their result as a return value, even if the |
2437 specified variable, and the newer kind that return the result. The newer | 2437 result is an alloca()ed string -- some trickery is required to do this, |
2438 kind of macros don't exist when the output is sized data, because that | 2438 but it's definitely possible. However, for macros whose result is a |
2439 would have two return values. NOTE: All convenience macros are | 2439 "sized string" (i.e. a string plus a length), there are two values to |
2440 ultimately defined in terms of TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. | 2440 return, and both are returned through parameters. |
2441 Thus, any comments below about the workings of these macros also apply to | 2441 |
2442 all convenience macros. | 2442 The convenience macros have the form: |
2443 | |
2444 (a) (SIZED_)?EXTERNAL_TO_ITEXT(_MALLOC)? | |
2445 (b) (ITEXT|LISP_STRING)_TO_(SIZED_)?EXTERNAL(_MALLOC)? | |
2446 | |
2447 Note also that there are some additional, more specific macros defined | |
2448 elsewhere, for example macros like EXTERNAL_TO_TSTR() in syswindows.h for | |
2449 conversions that specifically involve the `mswindows-tstr' coding system | |
2450 (which is normally an alias of `mswindows-unicode', a variation of | |
2451 UTF-16). | |
2452 | |
2453 Convenience macros of type (a) are for conversion from external to | |
2454 internal, while type (b) macros convert internal to external. A few | |
2455 notes: | |
2456 | |
2457 -- The output is an alloca()ed string unless `_MALLOC' is appended, | |
2458 in which case it's a malloc()ed string. | |
2459 -- When the destination says ITEXT, it means internally-formatted text of | |
2460 type `Ibyte *' (which boils down to `unsigned char *'). | |
2461 -- When the destination says EXTERNAL, it means externally-formatted | |
2462 text of type `Extbyte *' (which boils down to `char *'). Because | |
2463 `Ibyte *' and `Extbyte *' are different underlying types, accidentally | |
2464 mixing them will generally lead to a warning under gcc, and an error | |
2465 under g++. | |
2466 -- When SIZED_EXTERNAL is involved, there are two parameters, one for | |
2467 the string and one for its length. When SIZED_EXTERNAL is the | |
2468 destination, these two parameters should be lvalues and will have the | |
2469 result stored into them. | |
2470 -- There is no LISP_STRING destination; use `build_extstring' instead of | |
2471 `EXTERNAL_TO_LISP_STRING' and `make_extstring' instead of | |
2472 `SIZED_EXTERNAL_TO_LISP_STRING'. | |
2473 -- There is no SIZED_ITEXT type. If you need this: First, if your data | |
2474 is coming from a Lisp string, it would be better to use the | |
2475 LISP_STRING_TO_* macros. If this doesn't apply or work, call the | |
2476 TO_EXTERNAL_FORMAT() or TO_INTERNAL_FORMAT() macros directly. | |
2477 | |
2478 Note that previously the convenience macros, like the raw TO_*_FORMAT | |
2479 macros, were always written to store their arguments into a passed-in | |
2480 lvalue rather than return them, due to major bugs in calling alloca() | |
2481 inside of a function call on x86 gcc circa version 2.6. This has | |
2482 apparently long since been fixed, but just to make sure we have a | |
2483 `configure' test for broken alloca() in function calls, and in such case | |
2484 the portable xemacs_c_alloca() implementation is substituted instead. | |
2485 Note that this implementation actually uses malloc() but notes the stack | |
2486 pointer at the time of allocation, and at next call any allocations | |
2487 belonging to inner stack frames are freed. This isn't perfect but | |
2488 more-or-less gets the job done as an emergency backup, and in most | |
2489 circumstances it prevents arbitrary memory leakage -- at most you should | |
2490 get a fixed amount of leakage. | |
2491 | |
2492 NOTE: All convenience macros are ultimately defined in terms of | |
2493 TO_EXTERNAL_FORMAT and TO_INTERNAL_FORMAT. Thus, any comments below | |
2494 about the workings of these macros also apply to all convenience macros. | |
2443 | 2495 |
2444 TO_EXTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) | 2496 TO_EXTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) |
2445 TO_INTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) | 2497 TO_INTERNAL_FORMAT (source_type, source, sink_type, sink, codesys) |
2446 | 2498 |
2447 Typical use is | 2499 Typical use is |
2507 by parenthesizing them, as in the examples above. | 2559 by parenthesizing them, as in the examples above. |
2508 | 2560 |
2509 Anything prefixed by dfc_ (`data format conversion') is private. | 2561 Anything prefixed by dfc_ (`data format conversion') is private. |
2510 They are only used to implement these macros. | 2562 They are only used to implement these macros. |
2511 | 2563 |
2512 [[Using C_STRING* is appropriate for using with external APIs that | 2564 Using C_STRING* is appropriate for data that comes from or is going to |
2513 take null-terminated strings. For internal data, we should try to | 2565 an external API that takes null-terminated strings, or when the string is |
2514 be '\0'-clean - i.e. allow arbitrary data to contain embedded '\0'. | 2566 always intended to contain text and never binary data, e.g. file names. |
2515 | 2567 Any time we are dealing with binary or general data, we must be '\0'-clean, |
2516 Sometime in the future we might allow output to C_STRING_ALLOCA or | 2568 i.e. allow arbitrary data which might contain embedded '\0', by tracking |
2517 C_STRING_MALLOC _only_ with TO_EXTERNAL_FORMAT(), not | 2569 both pointer and length. |
2518 TO_INTERNAL_FORMAT().]] | |
2519 | |
2520 The above comments are not true. Frequently (most of the time, in | |
2521 fact), external strings come as zero-terminated entities, where the | |
2522 zero-termination is the only way to find out the length. Even in | |
2523 cases where you can get the length, most of the time the system will | |
2524 still use the null to signal the end of the string, and there will | |
2525 still be no way to either send in or receive a string with embedded | |
2526 nulls. In such situations, it's pointless to track the length | |
2527 because null bytes can never be in the string. We have a lot of | |
2528 operations that make it easy to operate on zero-terminated strings, | |
2529 and forcing the user the deal with the length everywhere would only | |
2530 make the code uglier and more complicated, for no gain. --ben | |
2531 | 2570 |
2532 There is no problem using the same lvalue for source and sink. | 2571 There is no problem using the same lvalue for source and sink. |
2533 | 2572 |
2534 Also, when pointers are required, the code (currently at least) is | 2573 Also, when pointers are required, the code (currently at least) is |
2535 lax and allows any pointer types, either in the source or the sink. | 2574 lax and allows any pointer types, either in the source or the sink. |
2551 whether the external coding system is in fact Unicode. This | 2590 whether the external coding system is in fact Unicode. This |
2552 behavior may change in the future, and you cannot rely on this -- | 2591 behavior may change in the future, and you cannot rely on this -- |
2553 the most you can rely on is that sink data in Unicode format will | 2592 the most you can rely on is that sink data in Unicode format will |
2554 have two terminating nulls, which combine to form one Unicode null | 2593 have two terminating nulls, which combine to form one Unicode null |
2555 character. | 2594 character. |
2556 | 2595 */ |
2557 NOTE: You might ask, why are these not written as functions that | |
2558 *RETURN* the converted string, since that would allow them to be used | |
2559 much more conveniently, without having to constantly declare temporary | |
2560 variables? The answer is that in fact I originally did write the | |
2561 routines that way, but that required either | |
2562 | |
2563 (a) calling alloca() inside of a function call, or | |
2564 (b) using expressions separated by commas and a global temporary variable, or | |
2565 (c) using the GCC extension ({ ... }). | |
2566 | |
2567 Turned out that all of the above had bugs, all caused by GCC (hence the | |
2568 comments about "those GCC wankers" and "ream gcc up the ass"). As for | |
2569 (a), some versions of GCC (especially on Intel platforms), which had | |
2570 buggy implementations of alloca() that couldn't handle being called | |
2571 inside of a function call -- they just decremented the stack right in the | |
2572 middle of pushing args. Oops, crash with stack trashing, very bad. (b) | |
2573 was an attempt to fix (a), and that led to further GCC crashes, esp. when | |
2574 you had two such calls in a single subexpression, because GCC couldn't be | |
2575 counted upon to follow even a minimally reasonable order of execution. | |
2576 True, you can't count on one argument being evaluated before another, but | |
2577 GCC would actually interleave them so that the temp var got stomped on by | |
2578 one while the other was accessing it. So I tried (c), which was | |
2579 problematic because that GCC extension has more bugs in it than a | |
2580 termite's nest. | |
2581 | |
2582 So reluctantly I converted to the current way. Now, that was awhile ago | |
2583 (c. 1994), and it appears that the bug involving alloca in function calls | |
2584 has long since been fixed. More recently, I defined the new-dfc routines | |
2585 down below, which DO allow exactly such convenience of returning your | |
2586 args rather than store them in temp variables, and I also wrote a | |
2587 configure check to see whether alloca() causes crashes inside of function | |
2588 calls, and if so use the portable alloca() implementation in alloca.c. | |
2589 If you define TEST_NEW_DFC, the old routines get written in terms of the | |
2590 new ones, and I've had a beta put out with this on and it appeared to | |
2591 this appears to cause no problems -- so we should consider | |
2592 switching, and feel no compunctions about writing further such function- | |
2593 like alloca() routines in lieu of statement-like ones. --ben */ | |
2594 | 2596 |
2595 #define TO_EXTERNAL_FORMAT(source_type, source, sink_type, sink, codesys) \ | 2597 #define TO_EXTERNAL_FORMAT(source_type, source, sink_type, sink, codesys) \ |
2596 do { \ | 2598 do { \ |
2597 dfc_conversion_type dfc_simplified_source_type; \ | 2599 dfc_conversion_type dfc_simplified_source_type; \ |
2598 dfc_conversion_type dfc_simplified_sink_type; \ | 2600 dfc_conversion_type dfc_simplified_sink_type; \ |
2802 #define DFC_C_STRING_MALLOC_USE_CONVERTED_DATA(sink) do { \ | 2804 #define DFC_C_STRING_MALLOC_USE_CONVERTED_DATA(sink) do { \ |
2803 void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 2); \ | 2805 void * dfc_sink_ret = xmalloc (dfc_sink.data.len + 2); \ |
2804 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \ | 2806 memcpy (dfc_sink_ret, dfc_sink.data.ptr, dfc_sink.data.len + 2); \ |
2805 VOIDP_CAST (sink) = dfc_sink_ret; \ | 2807 VOIDP_CAST (sink) = dfc_sink_ret; \ |
2806 } while (0) | 2808 } while (0) |
2807 #define DFC_LISP_STRING_USE_CONVERTED_DATA(sink) \ | 2809 #define DFC_LISP_STRING_USE_CONVERTED_DATA(sink) \ |
2808 sink = make_string ((Ibyte *) dfc_sink.data.ptr, dfc_sink.data.len) | 2810 sink = make_string ((Ibyte *) dfc_sink.data.ptr, dfc_sink.data.len) |
2809 #define DFC_LISP_OPAQUE_USE_CONVERTED_DATA(sink) \ | 2811 #define DFC_LISP_OPAQUE_USE_CONVERTED_DATA(sink) \ |
2810 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) | 2812 sink = make_opaque (dfc_sink.data.ptr, dfc_sink.data.len) |
2811 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ | 2813 #define DFC_LISP_LSTREAM_USE_CONVERTED_DATA(sink) /* data already used */ |
2812 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ | 2814 #define DFC_LISP_BUFFER_USE_CONVERTED_DATA(sink) \ |
2813 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) | 2815 Lstream_delete (XLSTREAM (dfc_sink.lisp_object)) |
2814 | 2816 |
2815 enum new_dfc_src_type | 2817 enum new_dfc_src_type |
2816 { | 2818 { |
2817 DFC_EXTERNAL, | 2819 DFC_EXTERNAL, |
2854 #define NEW_DFC_CONVERT_1_ALLOCA(src, src_size, type, codesys) \ | 2856 #define NEW_DFC_CONVERT_1_ALLOCA(src, src_size, type, codesys) \ |
2855 new_dfc_convert_copy_data \ | 2857 new_dfc_convert_copy_data \ |
2856 (#src, ALLOCA_FUNCALL_OK (new_dfc_convert_size (#src, src, src_size, \ | 2858 (#src, ALLOCA_FUNCALL_OK (new_dfc_convert_size (#src, src, src_size, \ |
2857 type, codesys))) | 2859 type, codesys))) |
2858 | 2860 |
2859 #define EXTERNAL_TO_ITEXT(src, codesys) \ | 2861 #define EXTERNAL_TO_ITEXT(src, codesys) \ |
2860 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_EXTERNAL, codesys)) | 2862 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_EXTERNAL, codesys)) |
2861 #define EXTERNAL_TO_ITEXT_MALLOC(src, codesys) \ | 2863 #define EXTERNAL_TO_ITEXT_MALLOC(src, codesys) \ |
2862 ((Ibyte *) new_dfc_convert_malloc (src, -1, DFC_EXTERNAL, codesys)) | 2864 ((Ibyte *) new_dfc_convert_malloc (src, -1, DFC_EXTERNAL, codesys)) |
2863 #define SIZED_EXTERNAL_TO_ITEXT(src, len, codesys) \ | 2865 #define SIZED_EXTERNAL_TO_ITEXT(src, len, codesys) \ |
2864 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_EXTERNAL, codesys)) | 2866 ((Ibyte *) NEW_DFC_CONVERT_1_ALLOCA (src, len, DFC_SIZED_EXTERNAL, codesys)) |
2865 #define SIZED_EXTERNAL_TO_ITEXT_MALLOC(src, len, codesys) \ | 2867 #define SIZED_EXTERNAL_TO_ITEXT_MALLOC(src, len, codesys) \ |
2866 ((Ibyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_EXTERNAL, codesys)) | 2868 ((Ibyte *) new_dfc_convert_malloc (src, len, DFC_SIZED_EXTERNAL, codesys)) |
2867 #define ITEXT_TO_EXTERNAL(src, codesys) \ | 2869 #define ITEXT_TO_EXTERNAL(src, codesys) \ |
2868 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_INTERNAL, codesys)) | 2870 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (src, -1, DFC_INTERNAL, codesys)) |
2869 #define ITEXT_TO_EXTERNAL_MALLOC(src, codesys) \ | 2871 #define ITEXT_TO_EXTERNAL_MALLOC(src, codesys) \ |
2870 ((Extbyte *) new_dfc_convert_malloc (src, -1, DFC_INTERNAL, codesys)) | 2872 ((Extbyte *) new_dfc_convert_malloc (src, -1, DFC_INTERNAL, codesys)) |
2871 #define LISP_STRING_TO_EXTERNAL(src, codesys) \ | 2873 #define LISP_STRING_TO_EXTERNAL(src, codesys) \ |
2872 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (LISP_TO_VOID (src), -1, \ | 2874 ((Extbyte *) NEW_DFC_CONVERT_1_ALLOCA (LISP_TO_VOID (src), -1, \ |
2873 DFC_LISP_STRING, codesys)) | 2875 DFC_LISP_STRING, codesys)) |
2874 #define LISP_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ | 2876 #define LISP_STRING_TO_EXTERNAL_MALLOC(src, codesys) \ |
2875 ((Extbyte *) new_dfc_convert_malloc (LISP_TO_VOID (src), -1, \ | 2877 ((Extbyte *) new_dfc_convert_malloc (LISP_TO_VOID (src), -1, \ |
2876 DFC_LISP_STRING, codesys)) | 2878 DFC_LISP_STRING, codesys)) |
2877 /* In place of EXTERNAL_TO_LISP_STRING(), use build_extstring() and/or | 2879 /* In place of EXTERNAL_TO_LISP_STRING(), use build_extstring() and/or |
2878 make_extstring(). */ | 2880 make_extstring(). */ |
2879 | 2881 |
2880 /* The next four have two outputs, so we make both of them be parameters */ | 2882 /* The next four have two outputs, so we make both of them be parameters */ |