Mercurial > hg > xemacs-beta
diff src/text.c @ 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 | 969b7290edca |
line wrap: on
line diff
--- a/src/text.c Thu Feb 20 22:52:51 2003 +0000 +++ b/src/text.c Fri Feb 21 06:57:21 2003 +0000 @@ -3219,6 +3219,156 @@ PROFILE_RECORD_EXITING_SECTION (QSin_internal_external_conversion); } +/* ----------------------------------------------------------------------- */ +/* New-style DFC converters (data is returned rather than stored into var) */ +/* ----------------------------------------------------------------------- */ + +/* We handle here the cases where SRC is a Lisp_Object, internal data + (sized or unsized), or external data (sized or unsized), and return type + is unsized alloca() or malloc() data. If the return type is a + Lisp_Object, use build_ext_string() for unsized external data, + make_ext_string() for sized external data. If the return type needs to + be sized data, use the *_TO_SIZED_*() macros, and for other more + complicated cases, use the original TO_*_FORMAT() macros. */ + +static void +new_dfc_convert_now_damn_it (const void *src, Bytecount src_size, + enum new_dfc_src_type type, + void **dst, Bytecount *dst_size, + Lisp_Object codesys) +{ + /* #### In the case of alloca(), it would be a bit more efficient, for + small strings, to use static Dynarr's like are used internally in + TO_*_FORMAT(), or some other way of avoiding malloc() followed by + free(). I doubt it really matters, though. */ + + switch (type) + { + case DFC_EXTERNAL: + TO_INTERNAL_FORMAT (C_STRING, src, + MALLOC, (*dst, *dst_size), codesys); + break; + + case DFC_SIZED_EXTERNAL: + TO_INTERNAL_FORMAT (DATA, (src, src_size), + MALLOC, (*dst, *dst_size), codesys); + break; + + case DFC_INTERNAL: + TO_EXTERNAL_FORMAT (C_STRING, src, + MALLOC, (*dst, *dst_size), codesys); + break; + + case DFC_SIZED_INTERNAL: + TO_EXTERNAL_FORMAT (DATA, (src, src_size), + MALLOC, (*dst, *dst_size), codesys); + break; + + case DFC_LISP_STRING: + TO_EXTERNAL_FORMAT (LISP_STRING, VOID_TO_LISP (src), + MALLOC, (*dst, *dst_size), codesys); + break; + + default: + abort (); + } +} + +void * +new_dfc_convert_malloc (const void *src, Bytecount src_size, + enum new_dfc_src_type type, Lisp_Object codesys) +{ + void *dst; + Bytecount dst_size; + + new_dfc_convert_now_damn_it (src, src_size, type, &dst, &dst_size, codesys); + return dst; +} + +/* For alloca(), things are trickier because the calling function needs to + allocate. This means that the caller needs to do the following: + + (a) invoke us to do the conversion, remember the data and return the size. + (b) alloca() the proper size. + (c) invoke us again to copy the data. + + We need to handle the possibility of two or more invocations of the + converter in the same expression. In such cases it's conceivable that + the evaluation of the sub-expressions will be overlapping (e.g. one size + function called, then the other one called, then the copy functions + called). To handle this, we keep a list of active data, indexed by the + src expression. (We use the stringize operator to avoid evaluating the + expression multiple times.) If the caller uses the exact same src + expression twice in two converter calls in the same subexpression, we + will lose, but at least we can check for this and abort(). We could + conceivably try to index on other parameters as well, but there is not + really any point. */ + +typedef struct +{ + const char *srctext; + void *dst; + Bytecount dst_size; +} dfc_e2c_vals; + +typedef struct +{ + Dynarr_declare (dfc_e2c_vals); +} dfc_e2c_vals_dynarr; + +static dfc_e2c_vals_dynarr *active_dfc_e2c; + +static int +find_pos_of_existing_active_dfc_e2c (const char *srctext) +{ + dfc_e2c_vals *vals = NULL; + int i; + + for (i = 0; i < Dynarr_length (active_dfc_e2c); i++) + { + vals = Dynarr_atp (active_dfc_e2c, i); + if (vals->srctext == srctext) + return i; + } + + return -1; +} + +void * +new_dfc_convert_alloca (const char *srctext, void *alloca_data) +{ + dfc_e2c_vals *vals; + int i = find_pos_of_existing_active_dfc_e2c (srctext); + + assert (i >= 0); + vals = Dynarr_atp (active_dfc_e2c, i); + assert (alloca_data); + memcpy (alloca_data, vals->dst, vals->dst_size + 2); + xfree (vals->dst); + Dynarr_delete (active_dfc_e2c, i); + return alloca_data; +} + +Bytecount +new_dfc_convert_size (const char *srctext, const void *src, + Bytecount src_size, enum new_dfc_src_type type, + Lisp_Object codesys) +{ + dfc_e2c_vals vals; + + assert (find_pos_of_existing_active_dfc_e2c (srctext) < 0); + + vals.srctext = srctext; + + new_dfc_convert_now_damn_it (src, src_size, type, &vals.dst, &vals.dst_size, + codesys); + + Dynarr_add (active_dfc_e2c, vals); + /* The size is always + 2 because we have double zero-termination at the + end of all data (for Unicode-correctness). */ + return vals.dst_size + 2; +} + /************************************************************************/ /* Basic Ichar functions */ @@ -3740,6 +3890,7 @@ Ibyte_dynarr *); conversion_out_dynarr_list = Dynarr_new2 (Extbyte_dynarr_dynarr, Extbyte_dynarr *); + active_dfc_e2c = Dynarr_new (dfc_e2c_vals); for (i = 0; i <= MAX_BYTEBPOS_GAP_SIZE_3; i++) three_to_one_table[i] = i / 3;