diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/.arch-inventory | 12 | ||||
-rw-r--r-- | src/.gdbinit | 81 | ||||
-rw-r--r-- | src/ChangeLog | 6122 | ||||
-rw-r--r-- | src/ChangeLog.1 | 8 | ||||
-rw-r--r-- | src/ChangeLog.10 | 26 | ||||
-rw-r--r-- | src/ChangeLog.2 | 26 | ||||
-rw-r--r-- | src/ChangeLog.3 | 4 | ||||
-rw-r--r-- | src/ChangeLog.4 | 27 | ||||
-rw-r--r-- | src/ChangeLog.5 | 62 | ||||
-rw-r--r-- | src/ChangeLog.6 | 2 | ||||
-rw-r--r-- | src/ChangeLog.8 | 16 | ||||
-rw-r--r-- | src/ChangeLog.9 | 50 | ||||
-rw-r--r-- | src/Makefile.in | 1740 | ||||
-rw-r--r-- | src/README | 14 | ||||
-rw-r--r-- | src/alloc.c | 754 | ||||
-rw-r--r-- | src/atimer.c | 68 | ||||
-rw-r--r-- | src/atimer.h | 27 | ||||
-rw-r--r-- | src/autodeps.mk | 6 | ||||
-rw-r--r-- | src/bidi.c | 1811 | ||||
-rw-r--r-- | src/bidimirror.h | 365 | ||||
-rw-r--r-- | src/biditype.h | 447 | ||||
-rw-r--r-- | src/blockinput.h | 3 | ||||
-rw-r--r-- | src/buffer.c | 719 | ||||
-rw-r--r-- | src/buffer.h | 86 | ||||
-rw-r--r-- | src/bytecode.c | 23 | ||||
-rw-r--r-- | src/callint.c | 49 | ||||
-rw-r--r-- | src/callproc.c | 185 | ||||
-rw-r--r-- | src/casefiddle.c | 60 | ||||
-rw-r--r-- | src/casetab.c | 41 | ||||
-rw-r--r-- | src/category.c | 65 | ||||
-rw-r--r-- | src/category.h | 4 | ||||
-rw-r--r-- | src/ccl.c | 53 | ||||
-rw-r--r-- | src/ccl.h | 8 | ||||
-rw-r--r-- | src/character.c | 199 | ||||
-rw-r--r-- | src/character.h | 74 | ||||
-rw-r--r-- | src/charset.c | 203 | ||||
-rw-r--r-- | src/charset.h | 20 | ||||
-rw-r--r-- | src/chartab.c | 127 | ||||
-rw-r--r-- | src/cm.c | 21 | ||||
-rw-r--r-- | src/cm.h | 14 | ||||
-rw-r--r-- | src/cmds.c | 297 | ||||
-rw-r--r-- | src/coding.c | 629 | ||||
-rw-r--r-- | src/coding.h | 73 | ||||
-rw-r--r-- | src/commands.h | 2 | ||||
-rw-r--r-- | src/composite.c | 725 | ||||
-rw-r--r-- | src/composite.h | 55 | ||||
-rw-r--r-- | src/config.in | 316 | ||||
-rw-r--r-- | src/data.c | 1653 | ||||
-rw-r--r-- | src/dbusbind.c | 497 | ||||
-rw-r--r-- | src/deps.mk | 281 | ||||
-rw-r--r-- | src/dired.c | 103 | ||||
-rw-r--r-- | src/dispextern.h | 946 | ||||
-rw-r--r-- | src/dispnew.c | 1132 | ||||
-rw-r--r-- | src/disptab.h | 6 | ||||
-rw-r--r-- | src/doc.c | 109 | ||||
-rw-r--r-- | src/doprnt.c | 73 | ||||
-rw-r--r-- | src/dosfns.c | 50 | ||||
-rw-r--r-- | src/dosfns.h | 5 | ||||
-rw-r--r-- | src/ecrt0.c | 173 | ||||
-rw-r--r-- | src/editfns.c | 544 | ||||
-rw-r--r-- | src/emacs-icon.h | 2 | ||||
-rw-r--r-- | src/emacs.c | 517 | ||||
-rw-r--r-- | src/eval.c | 845 | ||||
-rw-r--r-- | src/fileio.c | 614 | ||||
-rw-r--r-- | src/filelock.c | 71 | ||||
-rw-r--r-- | src/filemode.c | 30 | ||||
-rw-r--r-- | src/floatfns.c | 236 | ||||
-rw-r--r-- | src/fns.c | 847 | ||||
-rw-r--r-- | src/font.c | 749 | ||||
-rw-r--r-- | src/font.h | 239 | ||||
-rw-r--r-- | src/fontset.c | 167 | ||||
-rw-r--r-- | src/fontset.h | 32 | ||||
-rw-r--r-- | src/frame.c | 448 | ||||
-rw-r--r-- | src/frame.h | 105 | ||||
-rw-r--r-- | src/fringe.c | 107 | ||||
-rw-r--r-- | src/ftfont.c | 270 | ||||
-rw-r--r-- | src/ftfont.h | 3 | ||||
-rw-r--r-- | src/ftxfont.c | 68 | ||||
-rw-r--r-- | src/getloadavg.c | 2 | ||||
-rw-r--r-- | src/gmalloc.c | 33 | ||||
-rw-r--r-- | src/gnutls.c | 631 | ||||
-rw-r--r-- | src/gnutls.h | 64 | ||||
-rw-r--r-- | src/gtkutil.c | 1534 | ||||
-rw-r--r-- | src/gtkutil.h | 224 | ||||
-rw-r--r-- | src/image.c | 1897 | ||||
-rw-r--r-- | src/indent.c | 96 | ||||
-rw-r--r-- | src/indent.h | 28 | ||||
-rw-r--r-- | src/insdel.c | 107 | ||||
-rw-r--r-- | src/intervals.c | 254 | ||||
-rw-r--r-- | src/intervals.h | 122 | ||||
-rw-r--r-- | src/keyboard.c | 1188 | ||||
-rw-r--r-- | src/keyboard.h | 168 | ||||
-rw-r--r-- | src/keymap.c | 328 | ||||
-rw-r--r-- | src/keymap.h | 29 | ||||
-rw-r--r-- | src/lisp.h | 1399 | ||||
-rw-r--r-- | src/lread.c | 484 | ||||
-rw-r--r-- | src/m/alpha.h | 81 | ||||
-rw-r--r-- | src/m/amdx86-64.h | 89 | ||||
-rw-r--r-- | src/m/arm.h | 30 | ||||
-rw-r--r-- | src/m/hp800.h | 112 | ||||
-rw-r--r-- | src/m/ia64.h | 34 | ||||
-rw-r--r-- | src/m/ibmrs6000.h | 59 | ||||
-rw-r--r-- | src/m/ibmrs6000.inp | 4 | ||||
-rw-r--r-- | src/m/ibms390.h | 25 | ||||
-rw-r--r-- | src/m/ibms390x.h | 74 | ||||
-rw-r--r-- | src/m/intel386.h | 79 | ||||
-rw-r--r-- | src/m/iris4d.h | 59 | ||||
-rw-r--r-- | src/m/m68k.h | 14 | ||||
-rw-r--r-- | src/m/macppc.h | 38 | ||||
-rw-r--r-- | src/m/mips.h | 50 | ||||
-rw-r--r-- | src/m/sh3.h | 6 | ||||
-rw-r--r-- | src/m/sparc.h | 50 | ||||
-rw-r--r-- | src/m/template.h | 59 | ||||
-rw-r--r-- | src/m/vax.h | 30 | ||||
-rw-r--r-- | src/m/xtensa.h | 8 | ||||
-rw-r--r-- | src/macros.c | 35 | ||||
-rw-r--r-- | src/macros.h | 6 | ||||
-rw-r--r-- | src/makefile.w32-in | 127 | ||||
-rw-r--r-- | src/marker.c | 128 | ||||
-rw-r--r-- | src/md5.c | 36 | ||||
-rw-r--r-- | src/md5.h | 20 | ||||
-rw-r--r-- | src/mem-limits.h | 62 | ||||
-rw-r--r-- | src/menu.c | 113 | ||||
-rw-r--r-- | src/menu.h | 35 | ||||
-rw-r--r-- | src/minibuf.c | 173 | ||||
-rw-r--r-- | src/mktime.c | 8 | ||||
-rw-r--r-- | src/msdos.c | 870 | ||||
-rw-r--r-- | src/msdos.h | 21 | ||||
-rw-r--r-- | src/ndir.h | 9 | ||||
-rw-r--r-- | src/ns.mk | 39 | ||||
-rw-r--r-- | src/nsfns.m | 218 | ||||
-rw-r--r-- | src/nsfont.m | 22 | ||||
-rw-r--r-- | src/nsimage.m | 26 | ||||
-rw-r--r-- | src/nsmenu.m | 70 | ||||
-rw-r--r-- | src/nsselect.m | 49 | ||||
-rw-r--r-- | src/nsterm.h | 45 | ||||
-rw-r--r-- | src/nsterm.m | 80 | ||||
-rw-r--r-- | src/point.h | 8 | ||||
-rw-r--r-- | src/prefix-args.c | 84 | ||||
-rw-r--r-- | src/print.c | 266 | ||||
-rw-r--r-- | src/process.c | 2198 | ||||
-rw-r--r-- | src/process.h | 33 | ||||
-rw-r--r-- | src/puresize.h | 11 | ||||
-rw-r--r-- | src/ralloc.c | 125 | ||||
-rw-r--r-- | src/regex.c | 186 | ||||
-rw-r--r-- | src/region-cache.c | 124 | ||||
-rw-r--r-- | src/region-cache.h | 32 | ||||
-rw-r--r-- | src/s/aix4-2.h | 108 | ||||
-rw-r--r-- | src/s/bsd-common.h | 57 | ||||
-rw-r--r-- | src/s/cygwin.h | 45 | ||||
-rw-r--r-- | src/s/darwin.h | 126 | ||||
-rw-r--r-- | src/s/freebsd.h | 125 | ||||
-rw-r--r-- | src/s/gnu-linux.h | 147 | ||||
-rw-r--r-- | src/s/gnu.h | 46 | ||||
-rw-r--r-- | src/s/hpux10-20.h | 103 | ||||
-rw-r--r-- | src/s/hpux11.h | 5 | ||||
-rw-r--r-- | src/s/irix6-5.h | 50 | ||||
-rw-r--r-- | src/s/lynxos.h | 57 | ||||
-rw-r--r-- | src/s/ms-w32.h | 124 | ||||
-rw-r--r-- | src/s/msdos.h | 125 | ||||
-rw-r--r-- | src/s/netbsd.h | 102 | ||||
-rw-r--r-- | src/s/openbsd.h | 37 | ||||
-rw-r--r-- | src/s/sol2-10.h | 19 | ||||
-rw-r--r-- | src/s/sol2-3.h | 98 | ||||
-rw-r--r-- | src/s/sol2-4.h | 32 | ||||
-rw-r--r-- | src/s/sol2-5.h | 32 | ||||
-rw-r--r-- | src/s/sol2-6.h | 65 | ||||
-rw-r--r-- | src/s/template.h | 82 | ||||
-rw-r--r-- | src/s/unixware.h | 61 | ||||
-rw-r--r-- | src/s/usg5-4-2.h | 73 | ||||
-rw-r--r-- | src/s/usg5-4-common.h | 111 | ||||
-rw-r--r-- | src/s/usg5-4.h | 215 | ||||
-rw-r--r-- | src/scroll.c | 148 | ||||
-rw-r--r-- | src/search.c | 314 | ||||
-rw-r--r-- | src/sound.c | 202 | ||||
-rw-r--r-- | src/strftime.c | 28 | ||||
-rw-r--r-- | src/syntax.c | 464 | ||||
-rw-r--r-- | src/syntax.h | 71 | ||||
-rw-r--r-- | src/sysdep.c | 1046 | ||||
-rw-r--r-- | src/sysselect.h | 5 | ||||
-rw-r--r-- | src/syssignal.h | 82 | ||||
-rw-r--r-- | src/systime.h | 9 | ||||
-rw-r--r-- | src/systty.h | 141 | ||||
-rw-r--r-- | src/term.c | 502 | ||||
-rw-r--r-- | src/termcap.c | 149 | ||||
-rw-r--r-- | src/termhooks.h | 99 | ||||
-rw-r--r-- | src/terminal.c | 39 | ||||
-rw-r--r-- | src/terminfo.c | 9 | ||||
-rw-r--r-- | src/textprop.c | 187 | ||||
-rw-r--r-- | src/tparam.c | 73 | ||||
-rw-r--r-- | src/undo.c | 37 | ||||
-rw-r--r-- | src/unexaix.c | 73 | ||||
-rw-r--r-- | src/unexalpha.c | 539 | ||||
-rw-r--r-- | src/unexcoff.c (renamed from src/unexec.c) | 264 | ||||
-rw-r--r-- | src/unexcw.c | 3 | ||||
-rw-r--r-- | src/unexelf.c | 51 | ||||
-rw-r--r-- | src/unexhp9k800.c | 14 | ||||
-rw-r--r-- | src/unexmacosx.c | 32 | ||||
-rw-r--r-- | src/unexsol.c | 4 | ||||
-rw-r--r-- | src/unexw32.c | 7 | ||||
-rw-r--r-- | src/vm-limit.c | 98 | ||||
-rw-r--r-- | src/w16select.c | 76 | ||||
-rw-r--r-- | src/w32.c | 392 | ||||
-rw-r--r-- | src/w32console.c | 113 | ||||
-rw-r--r-- | src/w32fns.c | 502 | ||||
-rw-r--r-- | src/w32font.c | 259 | ||||
-rw-r--r-- | src/w32font.h | 40 | ||||
-rw-r--r-- | src/w32gui.h | 2 | ||||
-rw-r--r-- | src/w32heap.c | 3 | ||||
-rw-r--r-- | src/w32heap.h | 6 | ||||
-rw-r--r-- | src/w32inevt.c | 5 | ||||
-rw-r--r-- | src/w32menu.c | 202 | ||||
-rw-r--r-- | src/w32proc.c | 94 | ||||
-rw-r--r-- | src/w32reg.c | 13 | ||||
-rw-r--r-- | src/w32select.c | 22 | ||||
-rw-r--r-- | src/w32term.c | 667 | ||||
-rw-r--r-- | src/w32term.h | 42 | ||||
-rw-r--r-- | src/w32uniscribe.c | 102 | ||||
-rw-r--r-- | src/w32xfns.c | 35 | ||||
-rw-r--r-- | src/widget.c | 97 | ||||
-rw-r--r-- | src/widget.h | 4 | ||||
-rw-r--r-- | src/window.c | 696 | ||||
-rw-r--r-- | src/window.h | 71 | ||||
-rw-r--r-- | src/xdisp.c | 4060 | ||||
-rw-r--r-- | src/xfaces.c | 706 | ||||
-rw-r--r-- | src/xfns.c | 731 | ||||
-rw-r--r-- | src/xfont.c | 104 | ||||
-rw-r--r-- | src/xftfont.c | 107 | ||||
-rw-r--r-- | src/xgselect.c | 12 | ||||
-rw-r--r-- | src/xgselect.h | 12 | ||||
-rw-r--r-- | src/xmenu.c | 312 | ||||
-rw-r--r-- | src/xml.c | 158 | ||||
-rw-r--r-- | src/xrdb.c | 173 | ||||
-rw-r--r-- | src/xselect.c | 568 | ||||
-rw-r--r-- | src/xsettings.c | 343 | ||||
-rw-r--r-- | src/xsettings.h | 12 | ||||
-rw-r--r-- | src/xsmfns.c | 188 | ||||
-rw-r--r-- | src/xterm.c | 1290 | ||||
-rw-r--r-- | src/xterm.h | 340 |
239 files changed, 31016 insertions, 29667 deletions
diff --git a/src/.arch-inventory b/src/.arch-inventory deleted file mode 100644 index c21e38d47d7..00000000000 --- a/src/.arch-inventory +++ /dev/null @@ -1,12 +0,0 @@ -# Source files which don't match the usual naming conventions, mostly dot files -source ^\.(gdbinit|dbxinit)$ - -# Auto-generated files, which ignore -precious ^(config\.stamp|config\.h|epaths\.h|buildobj\.lst)$ -precious ^(TAGS-LISP)$ -precious ^(buildobj\.lst)$ - -backup ^(stamp-oldxmenu|prefix-args|temacs|emacs|emacs-[0-9.]*)$ -backup ^(bootstrap-emacs)$ - -# arch-tag: 277cc7ae-b3f5-44af-abf1-84c073164543 diff --git a/src/.gdbinit b/src/.gdbinit index e8a64f5dfe4..b3bb6b58267 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -21,6 +21,8 @@ # Force loading of symbols, enough to give us gdb_valbits etc. set main +# With some compilers, we need this to give us struct Lisp_Symbol etc.: +set Fmake_symbol # Find lwlib source files too. dir ../lwlib @@ -271,6 +273,9 @@ define pitx end end printf "\n" + if ($it->bidi_p) + printf "BIDI: base_stop=%d prev_stop=%d level=%d\n", $it->base_level_stop, $it->prev_stop, $it->bidi_it.resolved_level + end if ($it->region_beg_charpos >= 0) printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos end @@ -447,6 +452,36 @@ document pwin Pretty print window structure w. end +define pbiditype + if ($arg0 == 0) + printf "UNDEF" + end + if ($arg0 == 1) + printf "L" + end + if ($arg0 == 2) + printf "R" + end + if ($arg0 == 3) + printf "EN" + end + if ($arg0 == 4) + printf "AN" + end + if ($arg0 == 5) + printf "BN" + end + if ($arg0 == 6) + printf "B" + end + if ($arg0 < 0 || $arg0 > 6) + printf "%d??", $arg0 + end +end +document pbiditype +Print textual description of bidi type given as first argument. +end + define pgx set $g = $arg0 # CHAR_GLYPH @@ -475,6 +510,11 @@ define pgx else printf " pos=%d", $g->charpos end + # For characters, print their resolved level and bidi type + if ($g->type == 0) + printf " blev=%d,btyp=", $g->resolved_level + pbiditype $g->bidi_type + end printf " w=%d a+d=%d+%d", $g->pixel_width, $g->ascent, $g->descent # If not DEFAULT_FACE_ID if ($g->face_id != 0) @@ -495,6 +535,9 @@ define pgx if ($g->overlaps_vertically_p) printf " OVL" end + if ($g->avoid_cursor_p) + printf " AVOID" + end if ($g->left_box_line_p) printf " [" end @@ -575,6 +618,31 @@ document pgrowit Pretty print all glyphs in it->glyph_row. end +define prowlims + printf "edges=(%d,%d),r2l=%d,cont=%d,trunc=(%d,%d),at_zv=%d\n", $arg0->minpos.charpos, $arg0->maxpos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->truncated_on_left_p, $arg0->truncated_on_right_p, $arg0->ends_at_zv_p +end +document prowlims +Print important attributes of a glyph_row structure. +Takes one argument, a pointer to a glyph_row structure. +end + +define pmtxrows + set $mtx = $arg0 + set $gl = $mtx->rows + set $glend = $mtx->rows + $mtx->nrows - 1 + set $i = 0 + while ($gl < $glend) + printf "%d: ", $i + prowlims $gl + set $gl = $gl + 1 + set $i = $i + 1 + end +end +document pmtxrows +Print data about glyph rows in a glyph matrix. +Takes one argument, a pointer to a glyph_matrix structure. +end + define xtype xgettype $ output $type @@ -829,6 +897,19 @@ Print the address of the char-table $, and its purpose. This command assumes that $ is an Emacs Lisp char-table value. end +define xsubchartable + xgetptr $ + print (struct Lisp_Sub_Char_Table *) $ptr + xgetint $->depth + set $depth = $int + xgetint $->min_char + printf "Depth: %d, Min char: %d (0x%x)\n", $depth, $int, $int +end +document xsubchartable +Print the address of the sub-char-table $, its depth and min-char. +This command assumes that $ is an Emacs Lisp sub-char-table value. +end + define xboolvector xgetptr $ print (struct Lisp_Bool_Vector *) $ptr diff --git a/src/ChangeLog b/src/ChangeLog index 40c0cb231e4..938cc73e7c3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,4 @@ -2010-10-13 Damyan Pepper <damyanp@gmail.com> +2010-10-14 Damyan Pepper <damyanp@gmail.com> Fix handling of font properties on Windows (bug#6303). * font.c (font_filter_properties): New function, refactored from @@ -9,12 +9,55 @@ (w32font_filter_properties): New function. (w32font_driver): Add w32font_filter_properties. -2010-10-12 Juanma Barranquero <lekktu@gmail.com> +2010-10-14 Juanma Barranquero <lekktu@gmail.com> * font.c (Ffont_variation_glyphs): * ccl.c (Fccl_execute_on_string): Fix typo in docstring. -2010-10-10 Jan Djärv <jan.h.d@swipnet.se> +2010-10-14 Juanma Barranquero <lekktu@gmail.com> + + * w32fns.c (w32_wnd_proc, file_dialog_callback): + * w32font.c (w32_generic_family): + * w32inevt.c (key_event): + * w32menu.c (fill_in_menu): + * w32proc.c (reader_thread, w32_executable_type, compare_env) + (merge_and_sort_env, int_from_hex, enum_locale_fn, enum_codepage_fn): + * w32term.c (w32_read_socket): Make static. + +2010-10-13 Juanma Barranquero <lekktu@gmail.com> + + * image.c (DEF_IMGLIB_FN): Add argument to adapt to strict + prototypes; all callers changed. + +2010-10-13 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in (TLIB2): Rename from TLIBW32. + (OBJ2): New macro. + (WIN32OBJ, FONTOBJ): Remove. + (OBJ1): Redistribute object files with OBJ2. + (LIBS, $(TEMACS)): Use TLIB2. + (make-buildobj-CMD, make-buildobj-SH): Use OBJ2. + ($(TLIB2), TAGS, TAGS-LISP, TAGS-gmake): Depend on OBJ2. + +2010-10-13 Juanma Barranquero <lekktu@gmail.com> + + * emacs.c (Vdynamic_library_alist) + (syms_of_emacs) <dynamic-library-alist>: Move from image.c and rename. + Doc fix. + + * lisp.h (Vdynamic_library_alist): Declare extern. + + * image.c (Vimage_library_alist) + (syms_of_image) <image-library-alist>: Move to emacs.c and rename. + (lookup_image_type): Use Vdynamic_library_alist. + (Finit_image_library): Doc fix. + +2010-10-12 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (lispsource, libsrc, etc, oldxmenudir, lwlibdir) + (lispdir): Remove trailing /, update all uses. + +2010-10-12 Jan Djärv <jan.h.d@swipnet.se> * nsterm.m (Qleft): Declare. (ns_right_alternate_modifier): New variable @@ -25,33 +68,72 @@ as emacs modifier for NSRightAlternateKeyMask. (syms_of_nsterm): DEFVAR_LISP ns-right-alternate-modifier. +2010-10-10 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnutls.c (emacs_gnutls_write): If we're trying to write before + gnutls is ready, return EAGAIN as the errno. + +2010-10-10 Dan Nicolaescu <dann@ics.uci.edu> + + * vm-limit.c: + * unexhp9k800.c: + * unexelf.c: + * unexaix.c: + * termcap.c: Remove #ifdef emacs / #ifndef emacs code, unused. + + * Makefile.in (temacs): Use $(ALL_CFLAGS) on the link line. + (PROFILING_LDFLAGS): Remove, not needed anymore. + + * Makefile.in: Use $(...) everywhere instead of ${...} + (CRT_DIR): Move near potential user. + (START_FILE): Move near CRT_DIR, it might use it. + + * sysdep.c (LPASS8): Remove, unused. + (emacs_ospeed): Change from being a global to a local in the only + user: init_baud_rate. + +2010-10-09 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnutls.c (syms_of_gnutls): All the bootprops are keywords. + (emacs_gnutls_write): Remove the debuggin fsync call. + (emacs_gnutls_read): Return -1 if we got an error from + gnutls_read. This allows us to actually read lots of data from + the GnuTLS stream. + (emacs_gnutls_write): Check for GNUTLS_E_AGAIN and not EINTR. + According to the documentation, this is correct, and it seems to + make things work. + +2010-10-09 Chong Yidong <cyd@stupidchicken.com> + + * xterm.c (x_draw_relief_rect): Clear corner pixels. + 2010-10-08 Michael Albinus <michael.albinus@gmx.de> - * dbusbind.c (xd_get_dispatch_status): Return a Lisp_Object. - (xd_pending_messages): Catch xd_get_dispatch_status calls. + * keyboard.c: Revert last change; it was not intended to be + synchronized with the trunk. 2010-10-08 Kenichi Handa <handa@m17n.org> * coding.c (complement_process_encoding_system): Fix previous change. -2010-10-03 Michael Albinus <michael.albinus@gmx.de> +2010-10-08 Michael Albinus <michael.albinus@gmx.de> * dbusbind.c (syms_of_dbusbind): Move putenv call ... (Fdbus_init_bus): ... here. (Bug#7113) -2010-10-03 Glenn Morris <rgm@gnu.org> +2010-10-08 Glenn Morris <rgm@gnu.org> * buffer.c (before-change-functions, after-change-functions): Three-year overdue doc fix following 2007-08-13 change. -2010-10-02 Kenichi Handa <handa@m17n.org> +2010-10-08 Kenichi Handa <handa@m17n.org> * coding.c (coding_inherit_eol_type): If parent doesn't specify eol-format, inherit from the system's default. (complement_process_encoding_system): Make a new coding system inherit the original eol-format. -2010-09-30 Kenichi Handa <handa@m17n.org> +2010-10-08 Kenichi Handa <handa@m17n.org> * coding.c (complement_process_encoding_system): New function. @@ -67,12 +149,12 @@ (send_process): Complement the coding system for encoding what sent to the process. -2010-09-29 Kenichi Handa <handa@m17n.org> +2010-10-08 Kenichi Handa <handa@m17n.org> * xfont.c (xfont_open): Fix setting of font->average_width from :avgwidth property (Bug#7123). -2010-09-28 Michael Albinus <michael.albinus@gmx.de> +2010-10-08 Michael Albinus <michael.albinus@gmx.de> * dbusbind.c (syms_of_dbusbind): Use putenv instead of setenv, it is more portable. @@ -81,26 +163,1007 @@ (kbd_buffer_get_event): ... here. This is needed for cygwin, which has not defined SIGIO. +2010-10-08 Chong Yidong <cyd@stupidchicken.com> + + * xterm.c (x_draw_relief_rect): If box width is larger than 1, + draw the outermost line using the black relief, for legibility. + Omit drawing the four corner pixels. + +2010-10-04 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (echo_prompt): Function moved into read_key_sequence. + (read_key_sequence): Inline echo_prompt. + (echo_dash): Add a dash only if key is continued (Bug#7137). + +2010-10-04 Dan Nicolaescu <dann@ics.uci.edu> + + Remove O_RDONLY, O_WRONLY definitions, not needed. + * unexcoff.c: + * lread.c: + * fileio.c: + * doc.c: + * callproc.c: + * alloc.c: + * termcap.c: Remove O_RDONLY O_WRONLY definitions. + +2010-10-03 Teodor Zlatanov <tzz@lifelogs.com> + + * gnutls.h (GNUTLS_LOG2): Convenience macro. + + * gnutls.c: Add property list symbol holders. + (emacs_gnutls_handshake): Clarify how sockets are passed to + GnuTLS. + (gnutls_log_function2): Convenience function using GNUTLS_LOG2. + (Fgnutls_boot): Get all parameters from a plist. Require trustfiles + and keyfiles to be a list of file names. Default to "NORMAL" for + the priority string. Improve logging. + +2010-10-03 Glenn Morris <rgm@gnu.org> + + * fileio.c (Vdirectory_sep_char): Remove. + +2010-10-03 Dan Nicolaescu <dann@ics.uci.edu> + + * termhooks.h: Remove #ifdef CONSP. + + * xterm.c (NO_INLINE, noinline): Move definitions to ../configure.in. + + Include <fcntl.h> unconditionally. + * termcap.c: + * sysdep.c: + * lread.c: + * keyboard.c: + * filelock.c: + * fileio.c: + * doc.c: + * callproc.c: + * alloc.c: Remove include guards for <fcntl.h>, process.c already + does it. + + * process.c: Do not include <sys/wait.h>, syswait.h does it. + + * sysdep.c (flush_pending_output): Remove code, does not do + anything on any platform. + + Remove unused code. + * sysdep.c (select_alarm, sys_select, read_input_waiting): Remove + select emulation, all systems support select. + (set_exclusive_use): Remove, the only user is in an #if 0 block. + * process.c (create_process): Remove #if 0 code. + + Remove unused arguments for unexec. + The third one is never used, and the last two are always passed as zero. + * emacs.c (unexec): Add declaration. + (Fdump_emacs): Only pass the first two arguments to unexec. + Simplify #ifdef. + * unexw32.c (unexec): + * unexsol.c (unexec): + * unexhp9k800.c (unexec): + * unexcw.c (unexec): Remove the last 3 arguments, unused. + * unexelf.c (unexec): Remove the last 3 arguments, unused. + (find_section): Use const. + * unexmacosx.c (unexec): Remove the last 3 arguments, unused. + (unexec_error): Declare it NO_RETURN. + * unexcoff.c (make_hdr): Assume bss_start is always zero, remove + it as an argument, remove data_start and entry_address arguments, unused. + (unexec): Remove bss_start, data_start and + entry_address arguments. + * unexaix.c (make_hdr): Assume bss_start is always zero, remove + it as an argument, remove data_start and entry_address arguments, unused. + (unexec): Remove bss_start, data_start and + entry_address arguments. + +2010-10-03 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in (TAGS, TAGS-LISP, TAGS-gmake): Add $(FONTOBJ). + + * gnutls.c (emacs_gnutls_handshake, gnutls_make_error) + (gnutls_emacs_global_init, gnutls_emacs_global_deinit): Make static. + (Fgnutls_get_initstage, Fgnutls_deinit, Fgnutls_boot, Fgnutls_bye): + Fix typos in docstrings. + (Fgnutls_error_fatalp, Fgnutls_error_string): Doc fixes. + (Fgnutls_errorp): Doc fix; use ERR for the argument name. + +2010-10-03 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (command_loop_1): Make sure the mark is really alive + before using it (Bug#7044). + +2010-10-02 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in (tags): Rename target to full-tags. + +2010-10-02 Eli Zaretskii <eliz@gnu.org> + + * emacs.c (main): Remove !WINDOWSNT conditional. + (Fkill_emacs): Don't mention exemption on MS-Windows. + +2010-10-02 Glenn Morris <rgm@gnu.org> + + * character.c (Fchar_bytes): Remove obsolete function. + (syms_of_character): Remove Schar_bytes. + + * emacs.c (fatal_error_signal): Also run Fkill_emacs on SIGINT. + (main) [!WINDOWSNT]: Handle SIGINT with fatal_error_signal + in batch-mode. + (Fkill_emacs): Doc fix. Also run the hook in batch mode. + (kill-emacs-hook): Doc fix. + +2010-10-02 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (Flibxml_parse_xml_region, Flibxml_parse_html_region) + (parse_region): Reworked to take regions instead of strings, and + renamed to reflect that these are the libxml functions. + +2010-10-01 Eli Zaretskii <eliz@gnu.org> + + * term.c (init_tty) [DOS_NT]: Don't call Wcm_clear after setting + screen dimensions in tty->Wcm. + + * xdisp.c (set_cursor_from_row): When the row is truncated and + point is outside the range of displayed characters, position the + cursor inside the scroll margin. (Bug#6349) + +2010-10-01 Dan Nicolaescu <dann@ics.uci.edu> + + Do not include stdlib.h and string.h, config.h does it. + * xfont.c: + * w32term.c: + * w32reg.c: + * w32inevt.c: + * w32heap.c: + * w32console.c: + * w16select.c: + * unexsol.c: + * term.c: + * sound.c: + * scroll.c (m): + * gtkutil.c: + * font.c: + * filelock.c: + * fileio.c: + * dosfns.c: + * dbusbind.c: + * bidi.c: + * callproc.c: + * process.c: + * msdos.c: + * charset.c: Do not include stdlib.h and string.h, config.h does it. + + * callproc.c (SIGCHLD): Remove conditional definition, syssignal.h defines it. + + * process.c: Move #include <pty.h> earlier. + (SIGCHLD): Remove conditional definition, syssignal.h defines it. + (pty_name): Move definition later. + + * nsselect.m (syms_of_nsselect): + * nsmenu.m (syms_of_nsmenu): + * nsfns.m (syms_of_nsfns): + * msdos.c (syms_of_msdos): + + * image.c (syms_of_image): + * charset.c (syms_of_charset): Use intern_c_string instead of intern. + + * point.h: Remove, unused. + +2010-10-01 Eli Zaretskii <eliz@gnu.org> + + * makefile.w32-in (TAGS, frc, TAGS-LISP, ../nt/TAGS, tags) + (TAGS-gmake, TAGS-nmake, TAGS-LISP-gmake, TAGS-LISP-nmake) + (nt-TAGS-gmake, nt-TAGS-nmake): New targets. + +2010-09-30 Dan Nicolaescu <dann@ics.uci.edu> + + * xml.c (parse_string): Use const. + +2010-09-30 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * eval.c (Fbacktrace): Don't overwrite print-level on exit. Also + only override Vprint_level if it isn't already bound, and increase + the level to 8 to produce more useful backtraces for bug reports. + +2010-09-30 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in: ecrt0.c does not exist anymore, do not mention it. + +2010-09-30 Juanma Barranquero <lekktu@gmail.com> + + * w32console.c (vga_stdcolor_name): Remove unused function; + presumed dead after 2007-11-30T13:57:21Z!jasonr@gnu.org. + +2010-09-29 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnutls.c (emacs_gnutls_handshake): Made into internal function. + (Fgnutls_boot): Start the handshake. + (emacs_gnutls_read): Perform the handshake from the reader loop. + (Fgnutls_boot): Remove some debugging messages. + Change indentation throughout to use the Emacs style. + (emacs_gnutls_handshake): Cast the fds to something that's + possibly the expected length. + (emacs_gnutls_write): Return -1 if we try to write before handshake. + + * process.h (Lisp_Process): Add a gnutls_p field to Lisp_Process. + + * process.c (make_process): Set the gnutls_p field to zero by + default. + (read_process_output): Always call the gnutls_read function if the + stream is a gnutls stream. + (send_process): Ditto for writes. + + * gnutls.c (emacs_gnutls_write, emacs_gnutls_read): Refuse to read + or write anything until the state is GNUTLS_STAGE_READY. + (Fgnutls_boot): Mark the stream as being a gnutls stream. + +2010-09-29 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (reseat_1): Initialize bidi_it.paragraph_dir to + NEUTRAL_DIR. + (handle_invisible_prop, iterate_out_of_display_property) + (next_element_from_buffer): If bidi_it.first_elt is set, call + bidi_paragraph_init with NO_DEFAULT_P argument non-zero. + (Bug#7128) + + * print.c (print_object): Fix format string and argument types for + printing a Lisp_Misc_Marker. + + * xdisp.c (pos_visible_p, c_string_pos, number_of_chars) + (load_overlay_strings, get_overlay_strings_1) + (get_overlay_strings, forward_to_next_line_start) + (back_to_previous_visible_line_start, reseat, reseat_to_string) + (get_next_display_element, next_element_from_string) + (next_element_from_c_string, next_element_from_buffer) + (move_it_vertically_backward, move_it_by_lines, add_to_log) + (message_dolog, message_log_check_duplicate, message2_nolog) + (message3, message3_nolog, vmessage, set_message, set_message_1) + (hscroll_window_tree, text_outside_line_unchanged_p) + (set_cursor_from_row, set_vertical_scroll_bar, redisplay_window) + (find_last_unchanged_at_beg_row) + (find_first_unchanged_at_end_row, row_containing_pos) + (trailing_whitespace_p, display_mode_element, decode_mode_spec) + (display_count_lines, x_produce_glyphs, note_mouse_highlight): Use + EMACS_INT for buffer and string positions. + + * dispextern.h (struct it) <string_nchars>: Declare EMACS_INT. + (row_containing_pos): Adjust prototype. + + * lisp.h (pos_visible_p, message2, message2_nolog, message3) + (message2_nolog, set_message): Adjust prototypes. + +2010-09-28 Stefan Monnier <monnier@iro.umontreal.ca> + + * gnutls.c (Fgnutls_boot): Remove unused vars `data' and `srp_cred'. + (Fgnutls_boot): Use SDATA. + (Fgnutls_handshake): Remove unused var `max_log_level'. + 2010-09-27 Michael Albinus <michael.albinus@gmx.de> * dbusbind.c (syms_of_dbusbind): Set $DBUS_FATAL_WARNINGS to "0". (Bug#7113) -2010-09-26 Jan Djärv <jan.h.d@swipnet.se> +2010-09-27 Jan Djärv <jan.h.d@swipnet.se> * xgselect.c (xg_select): Clear file descriptors not set from rfds and wfds. -2010-09-21 Stefan Monnier <monnier@iro.umontreal.ca> + * process.c (wait_reading_process_output): Add missing FD_CLR + for write_mask (must mirror connect_wait_mask). + +2010-09-27 Teodor Zlatanov <tzz@lifelogs.com> + + * gnutls.c (gnutls_log_function): Show level and "gnutls.c" + prefix. + (Fgnutls_boot): Use changed process members. Use log level with a + function parameter to set it. Bring back Emacs-level debugging + messages at log level 1 and 2. + + * process.c (make_process): Initialize gnutls_log_level. + + * process.h: Add gnutls_log_level and rename x509_cred and + anon_cred to have the gnutls_ prefix for consistency. + + * gnutls.h (GNUTLS_LOG): Add convenience macro. + +2010-09-27 Juanma Barranquero <lekktu@gmail.com> + + * w32.c (g_b_init_get_sid_identifier_authority) + (GetSidIdentifierAuthority_Proc, get_sid_identifier_authority): + Remove, not used. + (globals_of_w32): Don't set g_b_init_get_sid_identifier_authority. + (init_winsock): Remove useless assignment. + (open_process_token, get_token_information, lookup_account_sid) + (get_sid_sub_authority, get_sid_sub_authority_count, get_file_security) + (get_security_descriptor_owner, get_security_descriptor_group) + (is_valid_sid, equal_sid, get_length_sid, copy_sid) + (get_native_system_info, get_system_times, init_user_info, crlf_to_lf) + (is_unc_volume, GetCachedVolumeInformation, get_volume_info) + (is_fat_volume, open_unc_volume, read_unc_volume, close_unc_volume) + (unc_volume_file_attributes, convert_from_time_t) + (create_toolhelp32_snapshot, process32_first, process32_next) + (open_thread_token, impersonate_self, revert_to_self) + (get_process_memory_info, get_process_working_set_size) + (global_memory_status, global_memory_status_ex, socket_to_fd) + (shutdown_handler): Make static. + +2010-09-27 Michael Albinus <michael.albinus@gmx.de> + + * dbusbind.c (dbus_fd_cb, xd_get_dispatch_status) + (xd_pending_messages): Functions removed. + (xd_read_queued_messages): Add parameters fd, *data, for_read in + order to be compatible with add_read_fd. Determine bus from data, + and call xd_read_message just for this bus. + (xd_add_watch): Use xd_read_queued_messages as callback function. + Add data. + + * lisp.h (xd_pending_messages, xd_read_queued_messages): Remove. + +2010-09-27 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnutls.c (gnutls_log_function): Added more debugging. + (emacs_gnutls_read): Don't infloop while reading. + +2010-09-27 Kenichi Handa <handa@m17n.org> + + These changes are to remove restriction on the number of glyphs in + one composition. + + * dispextern.h (struct glyph): Change the member "slice" to union. + Remove u.cmp.from and u.cmp.to. Give more bits to u.cmp.id. + (GLYPH_SLICE_EQUAL_P): Adjusted for the above change. + + * dispnew.c (buffer_posn_from_coords): Use glyph->slice.img + instead of glyph->slice. + (marginal_area_string): Likewise. + + * term.c (encode_terminal_code): Use glyph->slice.cmp instead of + glyph->u.cmp. + (append_composite_glyph): Likewise. + + * xdisp.c (dump_glyph): Use glyph->slice.cmp instead of + glyph->u.cmp. + (fill_gstring_glyph_string, x_get_glyph_overhangs) + (append_composite_glyph): Likewise. + (fill_image_glyph_string): Use glyph->slice.img instead of + glyph->slice. + (append_glyph, produce_image_glyph, append_stretch_glyph) + (note_mouse_highlight): Likewise. + +2010-09-26 Jan Djärv <jan.h.d@swipnet.se> + + * process.c (add_keyboard_wait_descriptor) + (delete_keyboard_wait_descriptor): Reinstate ifdef subprocesses. + (wait_reading_process_output): Don't pass write_mask to select + if SELECT_CANT_DO_WRITE_MASK is defined. + (SELECT_CANT_DO_WRITE_MASK): Define if SELECT_CANT_DO_WRITE_MASK. + + * process.h (add_read_fd, delete_read_fd, add_write_fd) + (delete_write_fd): Declare. + + * process.c (gpm_wait_mask, max_gpm_desc): Remove. + (write_mask): New variable. + (max_input_desc): Renamed from max_keyboard_desc. + (fd_callback_info): New variable. + (add_read_fd, delete_read_fd, add_write_fd, delete_write_fd): + New functions. + (Fmake_network_process): FD_SET write_mask. + (deactivate_process): FD_CLR write_mask. + (wait_reading_process_output): Connecting renamed to Writeok. + check_connect removed. check_write is new. Remove references to gpm. + Use Writeok/check_write unconditionally (i.e. no #ifdef + NON_BLOCKING_CONNECT) instead of Connecting. + Loop over file descriptors and call callbacks in fd_callback_info + if file descriptor is ready for I/O. + (add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor. + (delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor. + (keyboard_bit_set): Use max_input_desc. + (add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor): + Remove #ifdef subprocesses. Use max_input_desc. + (init_process): Initialize write_mask and fd_callback_info. + + * keyboard.c (readable_events, gobble_input): Remove DBUS code. + + * dbusbind.c: Include process.h. + (dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch) + (xd_read_message_1): New functions. + (xd_add_watch, xd_remove_watch): Call xd_find_watch_fd. + Handle watch for both read and write. + (Fdbus_init_bus): Also register xd_toggle_watch. + (Fdbus_call_method_asynchronously, Fdbus_method_return_internal) + (Fdbus_method_error_internal, Fdbus_send_signal): Remove call + to dbus_connection_flush. + (xd_read_message): Move most of the code to xd_read_message_1. + Call xd_read_message_1 until status is COMPLETE. + +2010-09-26 Dan Nicolaescu <dann@ics.uci.edu> + + * term.c: Do not include sys/ioctl.h, not needed. + (init_tty): Reorder code to reduce the number of #ifdefs. + No code changes. + +2010-09-26 Teodor Zlatanov <tzz@lifelogs.com> + + * process.h: Set up GnuTLS support. + + * process.c (make_process, Fstart_process) + (read_process_output, send_process): Set up GnuTLS support for + process input/output file descriptors. + + * gnutls.h: The GnuTLS glue for Emacs, macros and enums. + + * gnutls.c: The source code for GnuTLS support in Emacs. + + * emacs.c: Set up GnuTLS support and call syms_of_gnutls. + + * config.in: Set up GnuTLS support. + + * Makefile.in (LIBGNUTLS_LIBS, LIBGNUTLS_CFLAGS, ALL_CFLAGS) + (obj, LIBES): Set up GnuTLS support. + +2010-09-26 Juanma Barranquero <lekktu@gmail.com> + + * w32.c (get_emacs_configuration_options): Fix previous change. + +2010-09-25 Chong Yidong <cyd@stupidchicken.com> + + * insdel.c (prepare_to_modify_buffer): Ensure the mark marker is + alive before using it (Bug#6977). + +2010-09-25 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xdisp.c (face_before_or_after_it_pos): EMACS_INT/int fixup. + + * dispextern.h: EMACS_INT/int fixup. + + * xdisp.c (string_pos_nchars_ahead, init_iterator): EMACS_INT/int + fixup. + + * xrdb.c (magic_file_p): EMACS_INT/int fixup. + +2010-09-25 Eli Zaretskii <eliz@gnu.org> + + * window.c (Fpos_visible_in_window_p, Fdelete_other_windows) + (Fselect_window, window_scroll_pixel_based) + (window_scroll_line_based, Frecenter, Fset_window_configuration): + Use EMACS_INT for buffer positions. + + * textprop.c (validate_interval_range, interval_of) + (property_change_between_p, Fadd_text_properties) + (set_text_properties_1, Fremove_text_properties) + (Fremove_list_of_text_properties, Ftext_property_any) + (Ftext_property_not_all, copy_text_properties) + (text_property_list, extend_property_ranges) + (verify_interval_modification): Use EMACS_INT for buffer + positions. + + * term.c (fast_find_position, term_mouse_highlight): Use EMACS_INT + for buffer positions. + + * process.c (read_process_output, send_process) + (Fprocess_send_region, status_notify): Use EMACS_INT for buffer + and string positions and size. + + * print.c (print_object, print_string, strout): Use EMACS_INT for + string indices. + + * minibuf.c (string_to_object): Use EMACS_INT for string position + and size. + + * marker.c (verify_bytepos): Use EMACS_INT for buffer positions. + + * lread.c <read_from_string_index, read_from_string_index_byte> + <read_from_string_limit, readchar_count>: Define EMACS_INT. + (readchar, unreadchar, read_internal_start): Use EMACS_INT for + buffer positions and string length. + + * keyboard.c <last_point_position, last_non_minibuf_size>: Declare + EMACS_INT. + (echo_truncate, adjust_point_for_property, read_char) + (gen_help_event, make_lispy_event, modify_event_symbol) + (Fexecute_extended_command, stuff_buffered_input): Use EMACS_INT + for buffer positions and string length. + + * keyboard.h (gen_help_event): Adjust prototype. + + * termhooks.h <struct input_event>: Make `code' member EMACS_INT. + + * commands.h <last_point_position>: Declare EMACS_INT. + + * xdisp.c <help_echo_pos>: Define as EMACS_INT. + (truncate_echo_area): Accept EMACS_INT argument. + + * dispextern.h <help_echo_pos>: Declare EMACS_INT. + + * lisp.h (truncate_echo_area): Adjust prototype. + + * composite.c (composition_adjust_point): Return EMACS_INT. + + * composite.h (composition_adjust_point): Adjust prototype. + +2010-09-25 Juanma Barranquero <lekktu@gmail.com> + + * process.c (Fmake_network_process): When arg :host is 'local, + use address 127.0.0.1, not name "localhost". (Bug#6781) + +2010-09-24 Eli Zaretskii <eliz@gnu.org> + + * indent.c (Fcurrent_indentation, indented_beyond_p) + (compute_motion): Use EMACS_INT for buffer position variables. + + * lisp.h (indented_beyond_p): Adjust prototype. + + * buffer.c (overlay_strings): Return EMACS_INT. + + * buffer.h (overlay_strings): Adjust prototype. + + * region-cache.c (pp_cache): Adjust format to arguments. + + * eval.c <specpdl_size, lisp_eval_depth>: Declare EMACS_INT. + (call_debugger): Use EMACS_INT for specpdl_size related variables. + (verror): Use EMACS_INT for size of allocated buffer. + + * keyboard.c (make_lispy_position): Use EMACS_INT for buffer + positions. + + * xdisp.c (redisplay_internal, try_window_id) + (set_cursor_from_row, find_first_unchanged_at_end_row): Use + EMACS_INT for buffer positions. + + * dispextern.h (set_cursor_from_row): Adjust prototype. + + * dispnew.c (increment_matrix_positions) + (increment_row_positions, copy_glyph_row_contents) + (mode_line_string, marginal_area_string): Use EMACS_INT for buffer + positions. + + * dispextern.h (mode_line_string, marginal_area_string) + (increment_matrix_positions, increment_row_positions): Adjust + prototypes. + + * data.c (Faref, Faset): Use EMACS_INT for string length and + positions. + + * cmds.c (internal_self_insert): Use EMACS_INT for the count of + characters to insert. + + * ccl.c (Fccl_execute_on_string): Use EMACS_INT for string + position and size. + + * syntax.c (scan_words, update_syntax_table) + (prev_char_comend_first, back_comment, skip_chars) + (skip_syntaxes, Fforward_comment, Fbackward_prefix_chars): Use + EMACS_INT for buffer and string positions. + + * syntax.h (scan_words, update_syntax_table): Adjust prototypes. + + * casefiddle.c (operate_on_word): Use EMACS_INT for buffer + positions. + +2010-09-24 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * scroll.c (calculate_scrolling, line_ins_del) + (calculate_direct_scrolling, scroll_cost): Fix EMACS_INT/int + conversion. + + * region-cache.c (move_cache_gap, set_cache_region, pp_cache) + (region_cache_backward, region_cache_forward) + (revalidate_region_cache, set_cache_region): FIX EMACS_INT/int + conversion. + + * xdisp.c (message_dolog): Fix EMACS_INT/int conversion. + + * eval.c (verror): Fix EMACS_INT/int conversion. + + * print.c (PRINTDECLARE, PRINTPREPARE, strout, print_string) + (print_preprocess, print_check_string_charset_prop) + (print_object): Fix EMACS_INT/int conversion. + + * xdisp.c (message_dolog): Fix EMACS_INT/int conversion. + +2010-09-24 Eli Zaretskii <eliz@gnu.org> + + * callproc.c (Fcall_process): Use EMACS_INT for count of + characters read from the subprocess. + + * bidi.c (struct bidi_paragraph_info): Use EMACS_INT for buffer + positions. + (bidi_cache_search, bidi_cache_find): Use EMACS_INT for buffer + positions. + + * buffer.c (struct sortvec): Use EMACS_INT for buffer positions. + (struct sortstrlist, overlay_str_len): Use EMACS_INT for string + length. + (advance_to_char_boundary, Fset_buffer_multibyte) + (overlays_at, overlays_in, mouse_face_overlay_overlaps) + (overlay_touches_p, record_overlay_string, overlay_strings) + (recenter_overlay_lists, fix_start_end_in_overlays) + (modify_overlay, Fmove_overlay, report_overlay_modification) + (evaporate_overlays): Use EMACS_INT for buffer positions. + + * lisp.h (fix_start_end_in_overlays, overlay_touches_p): Adjust + prototypes. + + * dispextern.h (struct bidi_saved_info): Use EMACS_INT for buffer + positions. + + * fns.c (Fcompare_strings, Fstring_lessp, concat) + (string_make_unibyte, Fstring_as_unibyte, Fsubstring) + (Fsubstring_no_properties, substring_both, Ffillarray) + (Fclear_string, mapcar1, Fmapconcat, Fmapcar, Fmapc) + (Fbase64_encode_region, Fbase64_encode_string, base64_encode_1) + (Fbase64_decode_region, Fbase64_decode_string, base64_decode_1) + (Fmd5): Use EMACS_INT for buffer and string positions and length + variables and arguments. + + * lisp.h (substring_both): Adjust prototype. + +2010-09-24 Juanma Barranquero <lekktu@gmail.com> + + Remove W32 API function pointer unused since 2005-02-15 (revno 2005-02-15T23:19:26Z!jasonr@gnu.org). + * w32fns.c (clipboard_sequence_fn): Don't declare. + (globals_of_w32fns): Don't initialize it. + +2010-09-23 Stefan Monnier <monnier@iro.umontreal.ca> * syntax.c (back_comment): Detect the case where a 1-char comment starter is also the 2nd char of a 2-char comment ender. -2010-09-17 Jan Djärv <jan.h.d@swipnet.se> +2010-09-23 Jan Djärv <jan.h.d@swipnet.se> * gtkutil.c (xg_tool_bar_menu_proxy): Set gtk-menu-items to TRUE. -2010-09-12 Jan Djärv <jan.h.d@swipnet.se> +2010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * eval.c (verror): EMACS_INT/int cleanup. + + * lisp.h (SPECPDL_INDEX): Cast to int, since we're not going to + unwind_protect more than 2GB worth of functions. + + * editfns.c (Finsert_char): EMACS_INT/int cleanup. + + * lisp.h: Have oblookup take EMACS_INT to allow interning big + string and avoid compiler warnings. + (USE_SAFE_ALLOCA): Cast to int to avoid compilation warnings in + all users. + + * lread.c (oblookup): EMACS_INT/int cleanup. + + * cmds.c (Fforward_line, Fdelete_char): EMACS_INT/int cleanup. + +2010-09-23 Eli Zaretskii <eliz@gnu.org> + + * editfns.c (clip_to_bounds): Return an EMACS_INT value. + + * lisp.h (clip_to_bounds): Adjust prototype. + + * intervals.c (adjust_for_invis_intang): Return EMACS_INT value. + +2010-09-23 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * lisp.h: doprnt.c EMACS_INT/int cleanup. + + * doprnt.c (doprnt): EMACS_INT/int cleanup. + + * doc.c (Fsnarf_documentation, get_doc_string): EMACS_INT/int + cleanup. + + * lisp.h: Change the definition of all marker.c functions that + take and return buffer stuff to be EMACS_INT instead of int. + + * marker.c (buf_charpos_to_bytepos, CONSIDER, set_marker_both) + (buf_charpos_to_bytepos, bytepos_to_charpos) + (buf_bytepos_to_charpos, Fbuffer_has_markers_at) + (set_marker_restricted, set_marker_both): Convert int to EMACS_INT + for all buffer positions. + +2010-09-23 Chong Yidong <cyd@stupidchicken.com> + + * intervals.c (traverse_intervals, rotate_right, rotate_left) + (split_interval_right, find_interval, next_interval) + (delete_node, delete_interval, interval_deletion_adjustment) + (adjust_intervals_for_deletion, merge_interval_right) + (merge_interval_left, graft_intervals_into_buffer) + (copy_intervals): Convert EMACS_UINTs to EMACS_INT. + + * intervals.h (traverse_intervals): Update prototype. + +2010-09-23 Eli Zaretskii <eliz@gnu.org> + + * indent.c (compute_motion): Use EMACS_INT for arguments to + region_cache_forward. + + * region-cache.c (struct boundary, struct region_cache): Use + EMACS_INT for positions. + (find_cache_boundary, move_cache_gap, insert_cache_boundary) + (delete_cache_boundaries, set_cache_region) + (invalidate_region_cache, know_region_cache) + (region_cache_forward, region_cache_backward, pp_cache): Use + EMACS_INT for buffer positions. + + * region-cache.h (know_region_cache, invalidate_region_cache) + (region_cache_forward, region_cache_backward): Adjust prototypes. + + * search.c (string_match_1, fast_c_string_match_ignore_case) + (looking_at_1, scan_buffer, scan_newline) + (find_next_newline_no_quit, find_before_next_newline) + (search_command, trivial_regexp_p, search_buffer, simple_search) + (boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer + and string positions and length. + + * lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit) + (find_before_next_newline): Adjust prototypes. + + * editfns.c (transpose_markers, update_buffer_properties) + (buildmark, clip_to_bounds, Fgoto_char, overlays_around) + (get_pos_property, Fconstrain_to_field) + (Fline_beginning_position, Fline_end_position, Fprevious_char) + (Fchar_after, Fchar_before, Finsert_char) + (Finsert_buffer_substring, Fcompare_buffer_substrings) + (Fsubst_char_in_region, Fformat, Ftranspose_regions): Use + EMACS_INT for buffer and string position variables. + (Finsert_char): Protect against too large insertions. + + * lisp.h (clip_to_bounds): Adjust prototype. + + * intervals.c (traverse_intervals, rotate_right, rotate_left) + (balance_an_interval, split_interval_right, split_interval_left) + (find_interval, next_interval, update_interval) + (adjust_intervals_for_insertion, delete_node, delete_interval) + (interval_deletion_adjustment, adjust_intervals_for_deletion) + (offset_intervals, merge_interval_right, merge_interval_left) + (graft_intervals_into_buffer, adjust_for_invis_intang) + (move_if_not_intangible, get_local_map, copy_intervals) + (copy_intervals_to_string, compare_string_intervals) + (set_intervals_multibyte_1): Use EMACS_INT for buffer positions + and for interval tree size. + + * intervals.h (traverse_intervals, split_interval_right) + (split_interval_left, find_interval, offset_intervals) + (graft_intervals_into_buffer, copy_intervals) + (copy_intervals_to_string, move_if_not_intangible, get_local_map) + (update_interval): Adjust prototypes. + + * xdisp.c (check_point_in_composition, reconsider_clip_changes): + Use EMACS_INT for buffer position variables and arguments. + + * composite.c (get_composition_id, find_composition) + (run_composition_function, compose_text) + (composition_gstring_width, autocmp_chars) + (composition_update_it, Ffind_composition_internal): Use EMACS_INT + for buffer positions and string length variables and arguments. + + * composite.h (get_composition_id, find_composition, compose_text) + (composition_gstring_width): Adjust prototypes. + + * editfns.c (Fformat): Use EMACS_INT for string size variables. + + * xdisp.c (store_mode_line_noprop, display_mode_element): Use + EMACS_INT for string positions. + + * intervals.c (get_property_and_range): Use EMACS_INT for buffer + position arguments. + + * intervals.h (get_property_and_range): Adjust prototype. + + * character.c (parse_str_as_multibyte, str_as_multibyte) + (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte) + (string_count_byte8, string_escape_byte8, c_string_width) + (strwidth, lisp_string_width, multibyte_chars_in_text): Use + EMACS_INT for string length variables and arguments. + + * character.h (parse_str_as_multibyte, str_as_multibyte) + (parse_str_to_multibyte, str_to_multibyte, str_as_unibyte) + (c_string_width, strwidth, lisp_string_width): Adjust + prototypes. + + * font.c (font_intern_prop): Use EMACS_INT for string length + variables. + + * font.c (font_intern_prop): Use EMACS_INT for string length + variables. + + * fns.c (Fstring_as_multibyte): Use EMACS_INT for string length + variables. + + * alloc.c <total_string_size>: Declare as EMACS_INT, not int. + (Fmake_string): Protect against too large strings. + (live_string_p, live_cons_p, live_symbol_p, live_float_p) + (live_misc_p): Use ptrdiff_t instead of int for pointer + differences. + (string_bytes, check_sblock, check_string_free_list) + (allocate_string_data, compact_small_strings, Fmake_string) + (Fmake_bool_vector, make_string, make_unibyte_string) + (make_multibyte_string, make_string_from_bytes) + (make_specified_string_string, Fmake_list, Fmake_vector): Use + EMACS_INT for string length variables and arguments. + (find_string_data_in_pure, make_pure_string, make_pure_c_string) + (Fpurecopy): Use EMACS_INT for string size. + (mark_vectorlike, mark_char_table, mark_object): Use EMACS_UINT + for vector size. + + * lisp.h (make_string, make_unibyte_string, make_multibyte_string) + (make_string_from_bytes, make_specified_string_string) + (make_pure_string, string_bytes, check_point_in_composition): + Adjust prototypes. + +2010-09-22 Eli Zaretskii <eliz@gnu.org> + + * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal) + (check_translation): Use EMACS_INT for buffer positions and + length. + + * undo.c (record_marker_adjustment, record_delete) + (record_change, record_point, record_insert) + (record_property_change, Fprimitive_undo): Use EMACS_INT for + buffer positions. + + * lisp.h (record_marker_adjustment, record_delete) + (record_change, record_point, record_insert) + (record_property_change, Fprimitive_undo): Adjust prototypes. + +2010-09-22 Juanma Barranquero <lekktu@gmail.com> + Eli Zaretskii <eliz@gnu.org> + + * w32.c (get_emacs_configuration_options): Fix buffer overrun. + +2010-09-22 Eli Zaretskii <eliz@gnu.org> + + * minibuf.c (Fminibuffer_contents) + (Fminibuffer_contents_no_properties) + (Fminibuffer_completion_contents): Use EMACS_INT for minibuffer + positions. + + * keyboard.c (command_loop_1): Use EMACS_INT to compare point with + mark. + + * alloc.c (make_uninit_string, make_uninit_multibyte_string) + (allocate_string_data): Accept EMACS_INT for string length. + + * editfns.c (Ffield_string, Ffield_string_no_properties) + (make_buffer_string, make_buffer_string_both, Fbuffer_substring) + (Fbuffer_substring_no_properties, find_field, Fdelete_field) + (Ffield_string, Ffield_string_no_properties, Ffield_beginning) + (Ffield_end): Use EMACS_INT for buffer positions. + + * insdel.c (prepare_to_modify_buffer): Use EMACS_INT to compare + point with mark. + + * lisp.h (allocate_string_data, make_uninit_string) + (make_uninit_multibyte_string, make_buffer_string) + (make_buffer_string_both): Adjust prototypes. + +2010-09-22 Chong Yidong <cyd@stupidchicken.com> + + * xml.c: Switch to GNU indentation. + (make_dom): Change parse tree format to match xml.el. + (Fxml_parse_html_string_internal): Rename from html-parse-string. + (Fxml_parse_string_internal): Rename from xml-parse-string. + +2010-09-22 Kenichi Handa <handa@m17n.org> + + * xdisp.c (compute_stop_pos): Call composition_compute_stop_pos + only if we are not at a composition. + (set_iterator_to_next): Give it->end_charpos to + composition_compute_stop_pos. + (set_iterator_to_next, next_element_from_buffer): Likewise. + + * dispnew.c (buffer_posn_from_coords): Fix position when the + current display element is a grapheme cluster in bidi-reordered + region. + +2010-09-21 Ari Roponen <ari.roponen@gmail.com> (tiny change) + + * doc.c (Fsnarf_documentation): Use memmove instead of memcpy as + the regions may overlap. + +2010-09-21 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/sysdep.$(O)): Update dependencies. + +2010-09-21 Dan Nicolaescu <dann@ics.uci.edu> + + * emacs.c: Do not include sys/ioctl.h, not needed. + + * doprnt.c: Do not include stdlib.h, config.h does it. + Move #include before macro definition. + +2010-09-20 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (temacs): Link using $(CC) not $(LD). + (LD_FIRSTFLAG): Define using autoconf. + (LD): Remove. + + Remove HAVE_TERMIOS definitions. + * s/usg5-4-common.h (HAVE_TERMIOS): + * s/template.h (HAVE_TERMIOS): + * s/gnu-linux.h (HAVE_TERMIOS): + * s/darwin.h (HAVE_TERMIOS): + * s/cygwin.h (HAVE_TERMIOS): + * s/bsd-common.h (HAVE_TERMIOS): + * s/aix4-2.h (HAVE_TERMIOS): + * s/hpux10-20.h (HAVE_TERMIOS): Do not define, it is assumed + defined on all non-MS platforms. + (HAVE_PSTAT_GETDYNAMIC): Do not define, autoconf does it. + + * xterm.c (xt_action_hook): Use const. + +2010-09-20 Juanma Barranquero <lekktu@gmail.com> + + Don't make W32 code conditional on HAVE_SOCKETS, it's always defined. + * w32.c: Remove top-level uses of #ifdef HAVE_SOCKETS. + (gethostname) [!HAVE_SOCKETS]: Remove. + (SOCK_REPLACE_HANDLE): Remove macro. + (socket_to_fd, sys_close, _sys_read_ahead, sys_read, sys_write) + (term_ntproc, init_ntproc): Don't conditionalize on HAVE_SOCKETS. + * w32proc.c: Remove top-level uses of #ifdef HAVE_SOCKETS. + (syms_of_ntproc): Don't conditionalize on HAVE_SOCKETS. + +2010-09-18 Eli Zaretskii <eliz@gnu.org> + + * deps.mk (xml.o): Add dependencies. + + * xdisp.c (Fcurrent_bidi_paragraph_direction): + Call bidi_paragraph_init with NO_DEFAULT_P non-zero. (Bug#7038) + + * bidi.c (bidi_paragraph_init): Accept an additional argument + NO_DEFAULT_P; all callers changed. If NO_DEFAULT_P is non-zero, + search back until a paragraph with a strong directional character + is found, and use that to determine paragraph's base direction. + + * dispextern.h (bidi_paragraph_init): Update prototype. + +2010-09-17 Eli Zaretskii <eliz@gnu.org> + + * w32.c (_PROCESS_MEMORY_COUNTERS_EX): Don't define with versions + of w32api >= 3.15. (Bug#6989) + +2010-09-17 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * process.c (wait_reading_process_output): Don't message about + accept-process-output unless the time limit really is zero. + +2010-09-17 Stefan Monnier <monnier@iro.umontreal.ca> + + * frame.c (Ftool_bar_pixel_width): YAILOM (Yet another + int/Lisp_Object mixup). + +2010-09-17 Jan Djärv <jan.h.d@swipnet.se> + + * keyboard.c (parse_tool_bar_item): For QClabel, set TOOL_BAR_ITEM_LABEL + not HELP. + +2010-09-17 Stephen Berman <stephen.berman@gmx.net> + + * frame.c (Ftool_bar_pixel_width): New function to expose tool + bar's pixel width to Lisp (Bug#7048). + +2010-09-14 Juanma Barranquero <lekktu@gmail.com> + + * cmds.c (syms_of_cmds) <post-self-insert-hook>: Fix typos in docstring. + +2010-09-17 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (xg_pack_tool_bar): Call gtk_handle_box_set_handle_position + with argument top/left if tool bar is vertical/horizontal (Bug#7051). + +2010-09-17 Kenichi Handa <handa@m17n.org> + + * ftfont.c (ftfont_check_otf): Fix previous change. + +2010-09-14 Kenichi Handa <handa@m17n.org> + + * ftfont.c (ftfont_check_otf): Fix the case of checking just + existence of GSUB or GPOS. + +2010-09-14 Juanma Barranquero <lekktu@gmail.com> + + * cmds.c (syms_of_cmds) <post-self-insert-hook>: Fix typos in docstring. + +2010-09-14 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (parse_buffer): Renamed to parse_string(), since that's + what it does. + (parse_string): Return nil when the document can't be parsed. + +2010-09-14 Jan Djärv <jan.h.d@swipnet.se> * xterm.c (get_current_vm_state): New function. (do_ewmh_fullscreen): Call get_current_vm_state and compare with @@ -108,20 +1171,107 @@ (x_handle_net_wm_state): Move code to get_current_vm_state and call that function. -2010-09-11 Courtney Bane <emacs-bugs-7626@cbane.org> (tiny change) +2010-09-14 Courtney Bane <emacs-bugs-7626@cbane.org> (tiny change) * term.c (tty_set_terminal_modes): Don't initialize twice (bug#7002). -2010-09-08 Kenichi Handa <handa@m17n.org> +2010-09-14 Kenichi Handa <handa@m17n.org> * coding.c (encode_coding_iso_2022): Don't optimize for ASCII if we may use designation or locking-shift. -2010-09-07 Kenichi Handa <handa@m17n.org> +2010-09-14 Kenichi Handa <handa@m17n.org> * coding.c (detect_coding_emacs_mule): Fix checking of multibyte sequence when the source is multibyte. +2010-09-14 Andreas Schwab <schwab@linux-m68k.org> + + * xml.c (Fxml_parse_string, Fxml_parse_string): Revert last change. + Don't make first argument optional. Doc fix. + +2010-09-14 Leo <sdl.web@gmail.com> (tiny change) + + * xml.c (Fxml_parse_string, Fhtml_parse_string): Fix up the + parameters for the doc string. + +2010-09-12 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (Fhtml_parse_string, Fxml_parse_string): Mention BASE-URL. + +2010-09-12 Stefan Monnier <monnier@iro.umontreal.ca> + + * fns.c (Fy_or_n_p): Move to lisp/subr.el. + (syms_of_fns): Don't defsubr Sy_or_n_p. + * lisp.h: Don't declare Fy_or_n_p. + * fileio.c (barf_or_query_if_file_exists): Fy_or_n_p -> y-or-n-p. + +2010-09-09 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c (Fxml_parse_buffer): New function to parse XML files. + +2010-09-08 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * xml.c: New file. + (Fhtml_parse_buffer): New function to interface to the libxml2 + html parsing function. + +2010-09-05 Juanma Barranquero <lekktu@gmail.com> + + * biditype.h: Regenerate. + +2010-09-04 Andreas Schwab <schwab@linux-m68k.org> + + * nsimage.m (ns_load_image): Check argument types. + + * image.c: Remove all uses of gcpro. + (xpm_load): Check all lisp types. + (pbm_load): Likewise. + (png_load): Likewise. + (jpeg_load): Likewise. + (tiff_load): Likewise. + (gif_load): Likewise. + (imagemagick_load_image): Likewise. + (imagemagick_load): Likewise. + (svg_load): Likewise. + (gs_load): Likewise. + +2010-09-04 Eli Zaretskii <eliz@gnu.org> + + * w32uniscribe.c (uniscribe_shape): Update commentary. Don't + try to reorder grapheme clusters, since LGSTRING should always + hold them in the logical order. + (uniscribe_encode_char, uniscribe_shape): Force ScriptShape to + return glyph codes in the logical order. + +2010-09-04 Andreas Schwab <schwab@linux-m68k.org> + + * image.c (imagemagick_image_p): Replace bcopy by memcpy. + (imagemagick_load_image): Fix type mismatch. + (Fimagemagick_types): Likewise. Doc fix. + +2010-09-02 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.h (struct dpyinfo): Remove cut_buffers_initialized. + + * xterm.c (x_term_init): Don't set dpyinfo->cut_buffers_initialized. + + * xselect.c: Remove declaration of cut-buffer objects and functions. + (symbol_to_x_atom): Remove mapping to XA_CUT_BUFFERn. + (x_atom_to_symbol): Remove mapping to QCUT_BUFFERn. + (Fx_get_cut_buffer_internal, Fx_store_cut_buffer_internal) + (Fx_rotate_cut_buffers_internal): Remove. + (syms_of_xselect): Remove defsubr of above. + Remove intern of QCUT_BUFFERn. + +2010-09-01 Stefan Monnier <monnier@iro.umontreal.ca> + + * cmds.c (Vblink_paren_function): Remove. + (internal_self_insert): Make it insert N chars at a time. + Don't call blink-paren-function. + (Fself_insert_command): Adjust accordingly. + (syms_of_cmds): Don't declare blink-paren-function. + 2010-08-31 Kenichi Handa <handa@m17n.org> * dispextern.h (FACE_FOR_CHAR): Use an ASCII face for 8-bit @@ -152,39 +1302,566 @@ Don't handle unibyte-display-via-language-environment here. For a character of no glyph, use font->space_width instead of FONT_WIDTH. +2010-08-31 Stefan Monnier <monnier@iro.umontreal.ca> + + * keyboard.c (Fwindow_system): Fix compilation for USE_LISP_UNION_TYPE. + +2010-08-31 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (command_loop_1): Don't call x-set-selection on tty. + +2010-08-30 Stefan Monnier <monnier@iro.umontreal.ca> + + * marker.c (Fcopy_marker): Make the first arg optional. + +2010-08-30 Kenichi Handa <handa@m17n.org> + + * composite.c (composition_update_it): Fix computing of + cmp_it->width. + 2010-08-29 Kenichi Handa <handa@m17n.org> * term.c (encode_terminal_code): Encode byte chars to the - correspnding bytes. + corresponding bytes. + +2010-08-29 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_draw_window_cursor): Draw BAR_CURSOR correct for R2L. + +2010-08-26 Kenichi Handa <handa@m17n.org> + + * xdisp.c (compute_stop_pos): Pay attention to bidi scan direction + on calling composition_compute_stop_pos. + +2010-08-25 Kenichi Handa <handa@m17n.org> + + * fontset.c (reorder_font_vector): Prefer a font-spec specifying + :otf. + + * composite.c (composition_compute_stop_pos): Don't break + composition at PT. + (composition_reseat_it): Likewise. Fix calculation of character + position starting a composition. + (Fcomposition_get_gstring): Don't limit the number of components + for automatic composition. + +2010-08-25 Kenichi Handa <handa@m17n.org> -2010-08-17 Andreas Schwab <schwab@linux-m68k.org> + * composite.c (composition_compute_stop_pos): In forward search, + pay attention to the possibility that some character after ENDPOS + will be composed with charactrs before ENDPOS. + +2010-08-24 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (command_loop_1): Don't clobber primary selection + during handle-switch-frame (Bug#6872). + +2010-08-23 Michael Albinus <michael.albinus@gmx.de> + + * dbusbind.c: Accept UNIX domain sockets as bus address. + (Fdbus_close_bus): New function. + (Vdbus_registered_buses): New variable. + (xd_initialize): Implement string as bus address. + (Fdbus_init_bus): Add bus to Vdbus_registered_buses). + (Fdbus_get_unique_name, Fdbus_call_method) + (Fdbus_call_method_asynchronously, Fdbus_method_return_internal) + (Fdbus_method_error_internal, Fdbus_send_signal) + (Fdbus_register_signal, Fdbus_register_method): Remove bus type + check. This is done in xd_initialize_bus. Adapt doc string, if + necessary. + (xd_pending_messages, xd_read_queued_messages): Loop over buses in + Vdbus_registered_buses. + (Vdbus_registered_objects_table): Create hash. + +2010-08-22 Juri Linkov <juri@jurta.org> + + * keyboard.c (Fexecute_extended_command): Move reading a command name + with `completing-read' to a new Elisp function `read-extended-command'. + Call it to read a command to `function' (bug#5364, bug#5214). + +2010-08-22 Chong Yidong <cyd@stupidchicken.com> + + * emacs.c (main): Remove handling of --unibyte arg (Bug#6886). + +2010-08-22 Andreas Schwab <schwab@linux-m68k.org> * eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA_LISP instead of SAFE_ALLOCA. -2010-08-17 Chong Yidong <cyd@stupidchicken.com> +2010-08-22 Chong Yidong <cyd@stupidchicken.com> * eval.c (Flet, Feval, Fapply, apply_lambda): Use SAFE_ALLOCA (Bug#6214). -2010-08-14 Jan Djärv <jan.h.d@swipnet.se> +2010-08-22 Jan Djärv <jan.h.d@swipnet.se> * doc.c (Fsnarf_documentation): Set skip_file only if p[1] is S. -2010-08-13 Jan Djärv <jan.h.d@swipnet.se> +2010-08-22 Jan Djärv <jan.h.d@swipnet.se> * doc.c (Fsnarf_documentation): Initialize skip_file before build-files test. -2010-08-09 Peter O'Gorman <pogma@thewrittenword.com> (tiny change) +2010-08-22 Peter O'Gorman <pogma@thewrittenword.com> (tiny change) * s/hpux10-20.h (HAVE_TERMIOS, NO_TERMIO, ORDINARY_LINK): New definitions. (HAVE_TERMIO): Remove. -2010-08-06 Kenichi Handa <handa@m17n.org> +2010-08-22 Eli Zaretskii <eliz@gnu.org> + + * deps.mk (sysdep.o, msdos.o): Depend on sysselect.h. + + * sysselect.h [WINDOWSNT]: Don't define the FD_* and select stuff + for w32. + + * s/ms-w32.h (HAVE_SYS_TIMEB_H): Don't #undef HAVE_SYS_SELECT_H, + it's done in nt/config.nt. + + * makefile.w32-in ($(BLD)/sysdep.$(O)): Depend on sysselect.h. - * charset.c: Include <stdlib.h> + * unexcoff.c (report_error, make_hdr, write_segment) + (copy_text_and_data, copy_sym, mark_x, adjust_lnnoptrs, unexec): + Convert argument lists and prototypes to ANSI C. + (make_hdr, write_segment): Remove unused variables. + (unexec): Remove commented-out line. Initialize `new' to shut up + compiler warnings. + +2010-08-22 Dan Nicolaescu <dann@ics.uci.edu> + + Simplify termio code. + All non-MSDOS non-WINDOWSNT platforms define HAVE_TERMIOS, so + HAVE_TERMIO code is obsolete. + Replace HAVE_TERMIOS conditionals with !DOS_NT. + * systty.h: Do not define HAVE_TCATTR. + Remove HAVE_TERMIO, HAVE_LTCHARS and HAVE_TCHARS code. + Do not define EMACS_HAVE_TTY_PGRP. Only define + EMACS_GET_TTY_PGRP for !DOS_NT. + * sysdep.c: Include sysselect.h unconditionally. Do not include + sys/ioctl.h and termios.h, systty.h does it. Use + HAVE_SYS_UTSNAME_H instead of USG as an include guard. + (init_baud_rate): Remove HAVE_TERMIO code. + (child_setup_tty): Remove HAVE_TERMIO code. + (emacs_get_tty, emacs_set_tty): Remove HAVE_TERMIO, HAVE_TCHARS + and HAVE_LTCHARS code. Use !DOS_NT instead of HAVE_TCATTR. + (new_ltchars, new_tchars): Remove, unused. + (init_sys_modes): Remove HAVE_TERMIO, HAVE_TCHARS and HAVE_LTCHARS + code. Remove special casing for __mips__, it was a no-op. Remove + HAVE_TCATTR conditional, it is implied by HAVE_TERMIOS. + (init_sys_modes): Remove HPUX special case. + * process.c: Include stdlib.h unconditionally. Do not include + fcntl.h, systty.h does it. Remove conditional code for + HAVE_SERIAL, it is always true. + (process_send_signal): Remove HAVE_TERMIOS conditional, it's + always true when SIGNALS_VIA_CHARACTERS is true. + (Fcontinue_process, Fprocess_send_eof): Simplify conditionals: + !WINDOWSNT means HAVE_TERMIOS. + (create_process): Remove HAVE_TERMIOS, it's inside a HAVE_PTYS + conditional, which is true for all HAVE_TERMIOS systems. + * keyboard.c (init_keyboard): Do not use HAVE_TERMIO, use !DOS_NT + instead of HAVE_TERMIOS. + * emacs.c (shut_down_emacs): Use !defined DOS_NT instead of + EMACS_HAVE_TTY_PGRP. + * callproc.c (child_setup): Move EMACS_SET_TTY_PGRP use to the + non-MSDOS, non-WINDOWSNT code, it's only defined for such systems + anyway. + +2010-08-21 Eli Zaretskii <eliz@gnu.org> + + * dispnew.c (buffer_posn_from_coords): Fix off-by-one error in + mirroring pixel positions. + +2010-08-20 Dan Nicolaescu <dann@ics.uci.edu> + + * alloc.c (malloc_sbrk_used, malloc_sbrk_unused): Remove, + write only. + (init_alloc_once): Remove writes to malloc_sbrk_unused, and + malloc_sbrk_used, nothing uses them. + + * puresize.h: Remove code assuming PNTR_COMPARISON_TYPE is not + defined, unconditionally defined in lisp.h. + + * term.c: Do not include <termios.h>, systty.h does it. + + * s/unixware.h (HAVE_TCATTR): + * s/aix4-2.h (HAVE_TCATTR): Remove definitions, not needed. + systty.h defines it when HAVE_TERMIOS is defined. + +2010-08-20 Eli Zaretskii <eliz@gnu.org> + + * dispnew.c (buffer_posn_from_coords): Fix last change for text + terminals: add one-character offset for R2L lines. + + * emacs.c <emacs_version>: Add a comment regarding + msdos/mainmake.v2's dependency on the syntax of this declaration. + +2010-08-20 Eli Zaretskii <eliz@gnu.org> + + * dispnew.c (buffer_posn_from_coords): Fix calculation of buffer + position for R2L lines by mirroring the pixel position wrt the + text are box. Improve commentary. + +2010-08-20 Andreas Schwab <schwab@linux-m68k.org> + + * image.c (imagemagick_clear_image): Remove debugging output. + +2010-08-19 Stefan Monnier <monnier@iro.umontreal.ca> + + * cmds.c (Vself_insert_face, Vself_insert_face_command): Remove. + (Qpost_self_insert_hook, Vpost_self_insert_hook): New vars. + (internal_self_insert): Run Qpost_self_insert_hook rather than handle + self-insert-face. + (syms_of_cmds): Initialize the new vars. + +2010-08-19 Jason Rumney <jasonr@gnu.org> + + * w32menu.c (set_frame_menubar): Remove call to undefined function. + + * w32fns.c (w32_wnd_proc): Don't check context before initializing. + +2010-08-19 Jan Djärv <jan.h.d@swipnet.se> + + * nsselect.m (nxatoms_of_nsselect): Use "Selection" and "Secondary". + +2010-08-18 Eli Zaretskii <eliz@gnu.org> + + * xterm.c (x_draw_bar_cursor): + * w32term.c (x_draw_bar_cursor): If the character under cursor is + R2L, draw the bar cursor on its right rather than on its left. + +2010-08-18 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c (Fdefmacro): Only obey one declaration. + + * casefiddle.c (casify_region): Setup gl_state. + +2010-08-18 Jan Djärv <jan.h.d@swipnet.se> + + * nsterm.m (ns_define_frame_cursor): Call x_update_cursor (Bug#6868). + +2010-08-18 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (update_frame_tool_bar): Literal strings are const char*. + +2010-08-18 David De La Harpe Golden <david@harpegolden.net> + + * nsselect.m (QCLIPBOARD, NXPrimaryPboard): Define. + (symbol_to_nsstring): Map QCLIPBOARD => NSGeneralPboard, + QPRIMARY => NXPrimaryPboard. + (ns_string_to_symbol): NSGeneralPboard => QCLIPBOARD, + NXPrimaryPboard => QPRIMARY. + (nxatoms_of_nsselect): NXPrimaryPboard = PrimarySelection, + NXSecondaryPboard = SecondarySelection. + (syms_of_nsselect): Intern QCLIPBOARD (Bug#6677). + +2010-08-18 Joakim Verona <joakim@verona.se> + + * image.c: Add support for ImageMagick. When HAVE_IMAGEMAGICK is + defined: + (imagemagick_image_p): New function to test for ImageMagic image. + (imagemagick_load): New function to load ImageMagick image. + (imagemagick_load_image): New function, helper for imagemagick_load. + (imagemagick-types): New function. + (Qimagemagick): New Lisp_object. + (imagemagick-render-type): New variable, decides which renderer to use. + +2010-08-17 Stefan Monnier <monnier@iro.umontreal.ca> + + * gtkutil.c (update_frame_tool_bar): Don't assume TOOL_BAR_ITEM_LABEL + is a string. + +2010-08-17 Jan Djärv <jan.h.d@swipnet.se> + + * nsfns.m (ns_frame_parm_handlers): Add a slot for the + x_set_tool_bar_position handler. + +2010-08-17 Eli Zaretskii <eliz@gnu.org> + + * w32fns.c <w32_frame_parm_handlers>: Add a slot for the + x_set_tool_bar_position handler, needed to support changes from + 2010-07-29T16:49:59Z!jan.h.d@swipnet.se for positioning the tool bar. (Bug#6796) + +2010-08-16 Jan Djärv <jan.h.d@swipnet.se> + + * nsselect.m: include keyboard.h for QPRIMARY, remove its + declaration (Bug#6863). + (syms_of_nsselect): Don't intern QPRIMARY. + + * xselect.c: Remove declaration of QPRIMARY (Bug#6864). + + * keyboard.h (QPRIMARY): Declare (Bug#6864). + +2010-08-16 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (command_loop_1): Avoid setting selection twice, + since it's done in deactivate-mark as well. + (Vselect_active_regions): Change default to t. Replace `lazy' + with non-default value `only', meaning only set PRIMARY for + temporarily active regions. + + * insdel.c (prepare_to_modify_buffer): Handle `only' value of + select-active-regions. + +2010-08-15 Jan Djärv <jan.h.d@swipnet.se> + + * keyboard.c (parse_tool_bar_item): Put in a bad label if :label + isn't a string. + +2010-08-15 Andreas Schwab <schwab@linux-m68k.org> + + * keyboard.c (parse_tool_bar_item): Avoid excessive use of strlen. + +2010-08-15 Jan Djärv <jan.h.d@swipnet.se> + + * keyboard.c (parse_tool_bar_item): malloc buf. + Set TOOL_BAR_ITEM_LABEL to empty string if not set to + new_lbl (Bug#6855). + +2010-08-14 Eli Zaretskii <eliz@gnu.org> + + * xterm.c (x_draw_stretch_glyph_string): + * w32term.c (x_draw_stretch_glyph_string): In R2L rows, display + the cursor on the right edge of the stretch glyph. + + * xdisp.c (window_box_right_offset, window_box_right): + Fix commentary. + + * xdisp.c (Fcurrent_bidi_paragraph_direction): Fix paragraph + direction when point is inside a run of whitespace characters. + + * bidi.c (bidi_at_paragraph_end): Remove obsolete comment. + +2010-08-14 Jason Rumney <jasonr@gnu.org> + + * keyboard.c (lispy_function_keys): Do not define VK_PACKET (bug#4836) + +2010-08-14 Chong Yidong <cyd@stupidchicken.com> + + * fns.c (Fmake_hash_table): Doc fix (Bug#6851). + +2010-08-13 Jason Rumney <jasonr@gnu.org> + + * w32menu.c (simple_dialog_show): Use unicode message box if available. + (MessageBoxW_Proc): New function typedef. + (unicode-message-box): New function pointer. + (globals_of_w32menu): Import it from user32.dll. (Bug#5629) + +2010-08-13 Jan Djärv <jan.h.d@swipnet.se> + + * frame.h (Qtool_bar_position): Declare. + + * xfns.c (Fx_create_frame): Call x_default_parameter for + Qtool_bar_position. + +2010-08-13 Eli Zaretskii <eliz@gnu.org> + + * unexcoff.c: Remove the parts used when "emacs" is not defined. + (report_error, report_error_1): Ditto. + (write_segment): Remove "#if 0" unused code. + (make_hdr): Remove code that was "#ifndef NO_REMAP" before + NO_REMAP was removed (in 2010-07-29T03:25:08Z!dann@ics.uci.edu). + (start_of_text): Remove unused function (was used only if NO_REMAP + was NOT defined). + + * msdos.c (IT_set_face): Fix format string to match argument + types. + (IT_write_glyphs, IT_note_mode_line_highlight) + (IT_set_frame_parameters): Remove unused variables. + (x_set_menu_bar_lines): Declare set_menu_bar_lines. + (IT_set_terminal_modes): Disambiguate expression in if clause. + (Fmsdos_remember_default_colors): Return Qnil. + (IT_set_frame_parameters): Add parens to disambiguate boolean + expression for logging the cursor type to termscript. + (keyboard_layout_list, keypad_translate_map) + (grey_key_translate_map): Add braces in inner initializers. + (dos_rawgetc): Add parens in condition for mouse-3 button-press. + (dos_rawgetc): Remove unused label. + (XMenuActivate): Add braces to remove ambiguous `else'. + (dos_ttraw): Always return a value. + (spawnve): Declare. + (run_msdos_command): Cast 3rd arg of spawnve to "char **". + + * dosfns.h (x_set_title): Declare. + + * w16select.c (Fw16_set_clipboard_data, Fw16_get_clipboard_data): + Remove unused variables. + + * dosfns.c (Fint86, Fdos_memget, Fdos_memput): Remove unused + variables. + (init_dosfns): Declare get_lim_data. + (system_process_attributes): Declare Fget_internal_run_time. + + * xmenu.c (xmenu_show) [!USE_X_TOOLKIT && !USE_GTK]: Fix argument + list to be consistent with menu.h. + + * w32menu.c (add_menu_item, name_is_separator): Shut up compiler + warnings due to mixing of "char *" and "const char *". + +2010-08-12 Stefan Monnier <monnier@iro.umontreal.ca> + + Introduce a new comment style "c" flag. + * syntax.c (SYNTAX_FLAGS_COMMENT_STYLEB) + (SYNTAX_FLAGS_COMMENT_STYLEC): New macros. + (SYNTAX_FLAGS_COMMENT_STYLE): Use them, add an argument. + (syntax_prefix_flag_p): New function. + (Fstring_to_syntax): Understand new "c" flag. + (Finternal_describe_syntax_value): Recognize new flag; use the + SYNTAX_FLAGS_* macros. + (scan_sexps_forward, Fparse_partial_sexp): Change representation of + comment style to accomodate the new styles. + (back_comment, forw_comment, Fforward_comment, scan_lists) + (scan_sexps_forward): Update code to obey the new comment style flag. + + * syntax.h: Move SYNTAX_FLAGS_FOO() macros to syntax.c. + + * casefiddle.c (casify_region): Use the new syntax_prefix_flag_p. + +2010-08-11 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (x_defined_color): If USE_GTK, call xg_check_special_colors + first. + (Fx_hide_tip): Check FRAME_LIVE_P (f) before calling xg_hide_tooltip. + + * gtkutil.h (xg_check_special_colors): Declare. + + * gtkutil.c (xg_check_special_colors, style_changed_cb): New functions. + (xg_create_frame_widgets): Connect theme name changes to + style_changed_cb. + + * xterm.c (emacs_class): New char[] for EMACS_CLASS. + (xim_open_dpy, xim_initialize, xim_close_dpy): Use emacs_class. + (x_term_init): Use char[] display_opt and name_opt instead of + string literal. file is const char*. + + * xsmfns.c (NOSPLASH_OPT): Change to char[]. + (smc_save_yourself_CB): Do xstrdup on all ->type and ->name for + props. Free them at the end. + + * xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "". + + * xrdb.c (get_system_app): Make path const and use char *p for + non-const char. + + * xmenu.c (Fx_popup_dialog): error_name is const char*. + (xmenu_show): error parameter is const char **. pane_string is const + char *. + (button_names): Is const char *. + (xdialog_show): error_name and pane_string is const. + + * process.h (synch_process_death): Is const char*. + + * w32menu.c (w32_menu_show): + * nsmenu.m (ns_menu_show): error parameter is const char **. + + * menu.h (w32_menu_show, ns_menu_show, xmenu_show): error parameter + is const char **. + + * menu.c (Fx_popup_menu): error_name is const. + + * keyboard.h (_widget_value): Add defined USE_GTK. Replace Boolean + with unsigned char and XtPointer with void *. + + * gtkutil.h: Replace widget_value with struct _widget_value. + (enum button_type, struct _widget_value): Remove and use the one from + keyboard.h. + + * gtkutil.c (get_utf8_string): Always return an allocated string. + Parameter is const. + (create_dialog, xg_create_one_menuitem, create_menus) + (xg_item_label_same_p, xg_update_menu_item): Free result from + get_utf8_string. + (xg_separator_p, xg_item_label_same_p): label is const. + + * font.h (font_open_by_name): Make name const. + + * font.c (font_open_by_name): Make name const. + + * floatfns.c (matherr): Use a const char* variable for x->name. + + * emacs.c (main): Pass char[] to putenv instead of literal. + + * callproc.c (synch_process_death): Make const. + (Fcall_process): Make signame const. + + * nsterm.h (parseKeyEquiv, addSubmenuWithTitle) + (addDisplayItemWithImage): Use const char*. + + * nsmenu.m (parseKeyEquiv, addSubmenuWithTitle) + (addDisplayItemWithImage, update_frame_tool_bar): Use const char*. + + * nsfont.m (ns_descriptor_to_entity): Use const char*. + + * keyboard.h (_widget_value): name, value and key are const char*. + + * unexmacosx.c (unexec_error): Use const char *. + +2010-08-09 Dan Nicolaescu <dann@ics.uci.edu> + + * font.h (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) + (font_parse_name, font_open_by_name): + * font.c (font_parse_xlfd, font_parse_fcname, font_unparse_fcname) + (font_parse_name, font_open_by_name): Remove const. + +2010-08-09 Andreas Schwab <schwab@linux-m68k.org> + + Use autoconf determined WORDS_BIGENDIAN instead of hardcoded + definition. + + * m/alpha.h: Don't define/undef WORDS_BIG_ENDIAN. + * m/amdx86-64.h: Likewise. + * m/arm.h: Likewise. + * m/hp800.h: Likewise. + * m/ia64.h: Likewise. + * m/ibmrs6000.h: Likewise. + * m/ibms390.h: Likewise. + * m/intel386.h: Likewise. + * m/iris4d.h: Likewise. + * m/m68k.h: Likewise. + * m/macppc.h: Likewise. + * m/mips.h: Likewise. + * m/sh3.h: Likewise. + * m/sparc.h: Likewise. + * m/template.h: Likewise. + * m/vax.h: Likewise. + * m/xtensa.h: Likewise. + * fringe.c (init_fringe_bitmap): Test WORDS_BIGENDIAN instead of + WORDS_BIG_ENDIAN. + * lisp.h: Likewise. + * md5.c: Likewise. + * sound.c (le2hl, le2hs, be2hl, be2hs): Likewise. + +2010-08-09 Dan Nicolaescu <dann@ics.uci.edu> + + Use const char* instead of char*. + Reduce the number of warnings with -Wwrite-strings. + * xrdb.c (get_environ_db, get_system_name): + * unexelf.c (find_section): + * term.c (string_cost, string_cost_one_line, per_line_cost) + (get_named_tty, init_tty): + * sysdep.c (sys_subshell): + * sound.c (sound_perror, sound_warning, vox_open, vox_init) + (alsa_sound_perror, alsa_open, alsa_configure, alsa_init): + * search.c (Freplace_match): + * process.c (Fmake_network_process, send_process, init_process): + * lread.c (Fload, init_lread): + * keymap.c (Fdescribe_buffer_bindings, describe_map_tree): + * keyboard.c (parse_tool_bar_item, struct event_head): + * gtkutil.h (xg_get_font_name): + * gtkutil.c (get_dialog_title, create_dialog, xg_get_font_name) + (make_widget_for_menu_item, make_menu_item, create_menus) + (xg_make_tool_item): + * font.c (parse_matrix, font_parse_name): + * floatfns.c (rounding_driver, float_error_fn_name): + * filelock.c (get_boot_time_1, lock_file_1): + * fileio.c (barf_or_query_if_file_exists, check_writable): + * editfns.c (get_system_name, get_operating_system_release) + (Fencode_time, Fset_time_zone_rule): + * dispextern.h (string_cost, per_line_cost, get_named_tty, init_tty): + * buffer.c (defvar_per_buffer): Use const. + +2010-08-08 Kenichi Handa <handa@m17n.org> + + * charset.c: Include <stdlib.h>. (struct charset_sort_data): New struct. (charset_compare): New function. (Fsort_charsets): New function. @@ -193,45 +1870,852 @@ * coding.c (decode_coding_iso_2022): Fix checking of dimension number in CTEXT extended segment. -2010-08-01 Juanma Barranquero <lekktu@gmail.com> +2010-08-08 Juanma Barranquero <lekktu@gmail.com> * w32fns.c (syms_of_w32fns) <x-max-tooltip-size>: Fix typo in docstring. * xfns.c (syms_of_xfns) <x-max-tooltip-size>: Reflow docstring. -2010-07-30 Juanma Barranquero <lekktu@gmail.com> +2010-08-08 Juanma Barranquero <lekktu@gmail.com> * fns.c (Fsubstring_no_properties, Fnthcdr, Ffeaturep) (Fhash_table_size): Fix typos in docstrings. (Fmake_hash_table): Doc fix. -2010-07-28 Juanma Barranquero <lekktu@gmail.com> +2010-08-08 Juanma Barranquero <lekktu@gmail.com> * minibuf.c (syms_of_minibuf) <read-buffer-function>: Doc fix (bug#5625). -2010-07-27 Ken Brown <kbrown@cornell.edu> +2010-08-08 Ken Brown <kbrown@cornell.edu> * dired.c (DIRENTRY_NONEMPTY) [cygwin]: Use d_ino instead of the MSDOS definition. -2010-07-25 Christoph Scholtes <cschol2112@gmail.com> +2010-08-08 Dan Nicolaescu <dann@ics.uci.edu> + + Use const char* instead of char*. + * xterm.c (x_create_toolkit_scroll_bar): + * xfont.c (xfont_list_pattern): + * xfns.c (x_default_scroll_bar_color_parameter) + (xic_create_fontsetname, x_default_font_parameter) + (x_screen_planes): + * xdisp.c (c_string_pos, number_of_chars, reseat_to_string) + (store_mode_line_string, decode_mode_spec, display_string): + * menu.c (digest_single_submenu): + * keymap.h (initial_define_key, initial_define_lispy_key): + * keymap.c (initial_define_key, initial_define_lispy_key): + * image.c (image_error, image_keyword): + * gtkutil.h (xg_create_widget, xg_create_scroll_bar): + * gtkutil.c (xg_create_widget, xg_create_scroll_bar): + * ftfont.c (struct fc_charset_table, ftfont_spec_pattern) + (ftfont_list, ftfont_match): + * frame.c (frame_parm_table): + * font.h (font_intern_prop, font_parse_xlfd, font_parse_fcname) + (font_unparse_fcname, font_unparse_fcname, font_open_by_name) + (font_add_log, font_deferred_log): + * font.c (font_intern_prop, font_parse_xlfd, font_parse_fcname) + (font_unparse_fcname, font_unparse_fcname, font_open_by_name) + (font_add_log, font_deferred_log): + * emacs.c (argmatch): + * dispextern.h (struct it): + * coding.c (ENCODE_DESIGNATION): + * charset.c (define_charset_internal): Use const. + + * s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused. + + * xrdb.c: Remove include guard. + Remove DECLARE_GETPWUID_WITH_UID_T conditional it had no effect. + Remove #if 0 code. Replace malloc->xmalloc, free->xfree, + realloc->xrealloc instead of using #defines. + +2010-08-08 Eli Zaretskii <eliz@gnu.org> + + * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): + * editfns.c (Fline_beginning_position, Fline_end_position): + State in the doc strings that start and end of line are in the + logical order. + + * xdisp.c (display_line): Move the handling of overlay arrow after + the call to find_row_edges. (Bug#6699) + +2010-08-07 Chong Yidong <cyd@stupidchicken.com> + + * keyboard.c (command_loop_1): + * insdel.c (prepare_to_modify_buffer): Don't call validate_region. + +2010-08-07 Chong Yidong <cyd@stupidchicken.com> + + * insdel.c (prepare_to_modify_buffer): Save active region text to + Vsaved_region_selection. + + * xselect.c (QPRIMARY): Move to keyboard.c. + + * keyboard.c (Vselect_active_regions): Move from simple.el. + (Vsaved_region_selection, Qx_set_selection, QPRIMARY, Qlazy): New vars. + (command_loop_1): Set window selection prior to deactivating the mark. + +2010-08-07 Juanma Barranquero <lekktu@gmail.com> + + * alloc.c (lisp_malloc): + * buffer.c (set_buffer_internal, set_buffer_internal_1): + * charset.h (emacs_mule_charset): + * dispextern.h (inhibit_free_realized_faces, redraw_frame) + (redraw_garbaged_frames, scroll_cost, update_frame, scrolling) + (bitch_at_user): + * lisp.h (Fcheck_coding_system, Fget_text_property) + (Qfunction, Qcompletion_ignore_case, QCwidth, QCsize): + Remove duplicate declarations. + +2010-08-06 Dan Nicolaescu <dann@ics.uci.edu> + + * process.c: Simplify include logic. + + * keyboard.h (quit_char): Add declaration. + * process.h (QCport, QCspeed, QCprocess, QCbytesize, QCstopbits) + (QCparity, Qodd, Qeven, QCflowcontrol, Qhw, Qsw, QCsummary): + Add declarations. + * sysdep.c: + * w32.c: Remove the above declarations. - * minibuf.c (Fread_buffer): Doc fix (bug#6528). + Remove extern declarations in .c files, .h files have them. + * xterm.c: + * xdisp.c: + * msdos.c: + * image.c: + * gtkutil.c: + * fileio.c: + * eval.c: Remove declarations. + + * frame.c (frame_params): Make const. + + * lisp.h (fatal_error_signal, emacs_root_dir): Add declaration. + + * emacs.c (emacs_copyright, emacs_version): Make static. + (Vinitial_window_system, Vauto_save_list_file_name) + (Vinhibit_redisplay): Remove declarations. + (main): Remove HAVE_SHM code, unused. Remove _I386 conditional + for AIX. + + Use const for some arrays and functions. + * xterm.h (xg_set_icon_from_xpm_data): + * xfns.c (xg_set_icon_from_xpm_data): + * term.c (fkeys): + * keyboard.c (lispy_accent_keys, lispy_function_keys) + (lispy_multimedia_keys, lispy_kana_keys, iso_lispy_function_keys) + (lispy_drag_n_drop_names, scroll_bar_parts, modify_event_symbol) + (frame.c frame_parms): + * emacs-icon.h (gnu_xpm_bits): + * callint.c (callint_argfuns): Use const. + +2010-08-06 Jan Djärv <jan.h.d@swipnet.se> + + * sysdep.c: Move include term.h last of includes (Bug#6812). + +2010-08-06 Eli Zaretskii <eliz@gnu.org> + + * dispnew.c (realloc_glyph_pool): Zero out newly allocated glyphs. + + * msdos.c (IT_display_cursor): Log cursor position on termscript. + + * .gdbinit (pgx): Display the avoid_cursor_p flag. + +2010-08-06 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/xdisp.$(O)): Update dependencies. + +2010-08-06 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.h (x_get_focus_frame): Declare. + + * keyboard.h (poll_for_input_1): Unconditionally declare. + + * nsterm.h (x_set_menu_bar_lines): Declare. + + * window.c: Don't include menu.h, it depends on lots of other .h-files. + + * xfaces.c (x_create_gc, x_free_gc): Convert to ANSI C prototypes. + + * window.c: Include menu.h. + + * unexmacosx.c (print_region_list, print_regions) + (build_region_list, find_emacs_zone_regions) + (unexec_regions_merge, read_load_commands, dump_it) + (unexec_init_emacs_zone): Convert to ANSI C prototypes. + + * term.c: Check HAVE_SYS_IOCTL_H. + + * sysdep.c: Check HAVE_TERM_H. + + * process.c: Check HAVE_UTIL_H. Include nsterm.h if HAVE_NS. + + * nsterm.m (ns_init_paths, ns_alloc_autorelease_pool) + (ns_ring_bell, ns_defined_color, hide_hourglass) + (x_display_pixel_height, x_display_pixel_width, syms_of_nsterm): + Convert to ANSI C prototypes. + (x_set_window_size, ns_draw_fringe_bitmap, judge): Move declarations + before code. + + * nsterm.h : Include sysselect.h. + (x_sync, x_get_focus_frame, x_set_mouse_position) + (x_set_mouse_pixel_position, x_make_frame_visible) + (x_make_frame_invisible, x_iconify_frame, x_char_width, x_char_height) + (x_pixel_width, x_pixel_height, x_set_frame_alpha, x_set_tool_bar_lines) + (x_activate_menubar, free_frame_menubar, ns_init_paths, ns_select) + (syms_of_nsterm, syms_of_nsfns, syms_of_nsmenu, syms_of_nsselect): + Declare. -2010-07-22 Christoph Scholtes <cschol2112@gmail.com> + * nsmenu.m (popup_activated, name_is_separator) + (syms_of_nsmenu): Convert to ANSI C prototypes. + (runMenuAt): Prototypes and move declarations before code. + + * nsimage.m (ns_load_image): Move NSTRACE after declarations. + + * nsfont.m (ns_fallback_entity, syms_of_nsfont): Convert to ANSI C + prototypes. + + * nsfns.m (have_menus_p, ns_display_info_for_name) + (x_set_cursor_type, ns_appkit_version_str) + (ns_appkit_version_int, ns_do_applescript) + (x_set_scroll_bar_default_width, x_sync, compute_tip_xy) + (syms_of_nsfns): Convert to ANSI C prototypes. + + * menu.h (x_set_menu_bar_line): Declare. + (free_menubar_widget_value_tree et.al): Add HAVE_NS for these functions. + + * lisp.h (fmod_float): Declare. + + * image.c (xpm_scan, xpm_make_color_table_v) + (xpm_put_color_table_v, xpm_get_color_table_v) + (xpm_make_color_table_h, xpm_put_color_table_h) + (xpm_get_color_table_h, xpm_str_to_color_key, xpm_load_image) + (xpm_load): Convert to ANSI C prototypes. + + * emacs.c: Include nsterm.h if HAVE_NS. + + * bidi.c (bidi_dump_cached_states): Fix fprintf warning. + +2010-08-06 Dan Nicolaescu <dann@ics.uci.edu> + + * process.c: Remove HAVE_SOCKETS #ifdefs inside #ifdef + subprocesses, only MSDOS does not define HAVE_SOCKETS. + (socket_options): Use const char* for name. + +2010-08-06 Juanma Barranquero <lekktu@gmail.com> + + Fix changes in 2010-08-05T23:15:24Z!dann@ics.uci.edu..2010-08-05T23:34:12Z!dann@ics.uci.edu for Windows build. + + * xmenu.c [USE_X_TOOLKIT || USE_GTK]: + Don't declare xmalloc_widget_value and digest_single_submenu. + + * w32font.c (Qlatin): Remove declaration. + + * menu.h (xmalloc_widget_value, digest_single_submenu): Declare. + + * dired.c (compile_pattern): Restore declaration. + +2010-08-05 Dan Nicolaescu <dann@ics.uci.edu> + + Remove extern declarations in .c files, .h files have them. + * data.c: + * dired.c: + * editfns.c: + * filelock.c: + * fns.c: + * font.c: + * fontset.c: + * frame.c: + * fringe.c: + * ftfont.c: + * gtkutil.c: + * indent.c: + * keyboard.c: + * keymap.c: + * lread.c: + * menu.c: + * print.c: + * search.c: + * sound.c: + * window.c: + * xdisp.c: + * xfaces.c: + * xfns.c: + * xfont.c: + * xftfont.c: + * xmenu.c: + * xterm.c: Remove declarations. + + Cleanup syssignal.h. + * syssignal.h (sighold, sigrelse, RETSIGTYPE): Remove, unused. + (main_thread): Move down to remove #ifdef. + (SIGMASKTYPE, SIGEMPTYMASK, SIGFULLMASK, sigmask, sigunblock): + Remove conditional definition following unconditional ones. + + * lisp.h: Remove HAVE_SHM code, unused. + (QCmap, QCrehash_size, QCrehash_threshold, QCsize, QCtest) + (QCweakness, Qabove_handle, Qbackquote, Qbar, Qbelow_handle) + (Qborder, Qbottom, Qbox, Qcircular_list, Qcomma, Qcomma_at) + (Qcomma_dot, Qcursor, Qdefault, Qdown, Qend_scroll, Qeq, Qeql) + (Qequal, Qfile_exists_p, Qfont_param, Qfringe, Qfunction) + (Qfunction_documentation, Qhandle, Qhbar, Qheader_line, Qhollow) + (Qidentity, Qleft_margin, Qmenu, Qmenu_bar_update_hook) + (Qmode_line_inactive, Qmouse, Qoverriding_local_map) + (Qoverriding_terminal_local_map, Qratio, Qregion, Qright_margin) + (Qscroll_bar, Qtool_bar, Qtop, Qup, Qvertical_border, Qwhen) + (Qwindow_scroll_functions, Vafter_load_alist) + (Vauto_save_list_file_name, Vface_alternative_font_family_alist) + (Vface_alternative_font_registry_alist, Vface_font_rescale_alist) + (Vface_ignored_fonts, Vinhibit_redisplay, Vminibuffer_list) + (Vprint_length, Vprint_level, Vscalable_fonts_allowed) + (Vshell_file_name, Vsystem_name, Vwindow_scroll_functions) + (Vwindow_system_version, Vx_no_window_manager, initial_argc) + (initial_argv, last_nonmenu_event, load_in_progress) + (noninteractive_need_newline, scroll_margin): Add declarations. + + * keyboard.h (xmalloc_widget_value, digest_single_submenu): Remove + declarations, menu.h has them. + (QCbutton, QCtoggle, QCradio, QClabel, extra_keyboard_modifiers) + (Vinput_method_function, Qinput_method_function) + (Qevent_symbol_element_mask, last_event_timestamp): + * dispextern.h (Voverflow_newline_into_fringe): + * font.h (QCantialias, Qp, syms_of_ftfont, syms_of_xfns) + (syms_of_ftxfont, syms_of_xftfont, syms_of_bdffont) + (syms_of_w32font, syms_of_nsfont): + * fontset.h (find_font_encoding, Qlatin): + * frame.h (Qtooltip, Qrun_hook_with_args, Vmenu_bar_mode) + (Vtool_bar_mode, set_frame_menubar): + * ftfont.h (ftfont_font_format, ftfont_get_fc_charset): + * xterm.h (Qx_gtk_map_stock): + * keymap.h (meta_prefix_char): Add declarations. + + * term.c: Remove dead code. + + Fix emacs -Q -f server-start & emacsclient -t on GNU/Linux. + * term.c (dissociate_if_controlling_tty): Use USG5 instead of + USG. This is equivalent to defined (USG) && !defined (BSD_PGRPS), + which is what was there before BSD_PGRPS was removed. + +2010-08-05 Eli Zaretskii <eliz@gnu.org> + + * deps.mk (unexcoff.o): Rename unexec.[co] => unexcoff.[co]. + + * unexcoff.c: Renamed from unexec.c. + +2010-08-04 Stefan Monnier <monnier@iro.umontreal.ca> + + * sysdep.c (child_setup_tty): Comment-out left-over non-ICANON code. + +2010-08-03 Johan Bockgård <bojohan@gnu.org> + + * data.c (Flocal_variable_p): Handle variable aliases correctly. + (Bug#6744) + +2010-08-02 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (x_create_toolkit_scroll_bar): Only set XtNbeNiceToColormap + to TRUE if depth of screen is < 16. + + * gtkutil.c (hierarchy_ch_cb, qttip_cb): Do not define unless + USE_GTK_TOOLTIP. + (xg_prepare_tooltip): Return 0 unless USE_GTK_TOOLTIP. + (xg_show_tooltip, xg_hide_tooltip): Do nothing unless USE_GTK_TOOLTIP. + (xg_create_frame_widgets): Surround tooltip-related code with ifdef + USE_GTK_TOOLTIP. + (xg_free_frame_widgets): Don't delete ttip_* unless USE_GTK_TOOLTIP. + + * xterm.h (USE_GTK_TOOLTIP): New define. + (struct x_output): Put ttip_* inside ifdef USE_GTK_TOOLTIP. + + * sysdep.c (child_setup_tty): Enable ICANON in lflags and set VEOF + to Control-D (Bug#6771). + +2010-08-02 Juanma Barranquero <lekktu@gmail.com> + + * editfns.c (Fregion_beginning, Fregion_end): Doc fixes (bug#6493). + Wording by Drew Adams <drew.adams@oracle.com>. + +2010-08-01 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.h (struct x_output): Add ttip_widget, ttip_window and + ttip_lbl. + + * xterm.c (x_clear_frame): Check FRAME_GTK_WIDGET (f) before + calling gtk_widget_queue_draw. + (x_free_frame_resources): Call xg_free_frame_widgets. + + * xfns.c (x_gtk_use_system_tooltips): New variable. + (Fx_show_tip): If USE_GTK and x_gtk_use_system_tooltips, call + new gtkutil tooltip functions to show the tooltip. + (Fx_hide_tip): Call xg_hide_tooltip. + (syms_of_xfns): Defvar x-gtk-use-system-tooltips. + + * gtkutil.h (xg_free_frame_widgets, xg_prepare_tooltip) + (xg_show_tooltip, xg_hide_tooltip): Declare. + + * gtkutil.c (hierarchy_ch_cb, qttip_cb, xg_prepare_tooltip) + (xg_show_tooltip, xg_hide_tooltip, xg_free_frame_widgets): + New functions. + (xg_create_frame_widgets): Set ttip_* to 0. Set a dummy tooltip + text so qttip_cb is called. Connect query-tooltip to qttip_cb. + Remove code that is commented out. + +2010-08-01 Stefan Monnier <monnier@iro.umontreal.ca> + + * keymap.c (Fdefine_key, Flookup_key): Say what event is invalid. + +2010-07-31 Chong Yidong <cyd@stupidchicken.com> + + * xselect.c (x_own_selection): Use list4. + +2010-07-30 Dan Nicolaescu <dann@ics.uci.edu> + + * buffer.c (Qwindow): Do not define, already defined in data.c. + (syms_of_buffer): Do not intern and staticpro Qwindow. (Bug#6760) + +2010-07-29 Chad Brown <yandros@mit.edu> + + Replace tests for SYSV_SYSTEM_DIR with HAVE_DIRENT_H, set via autoconf. + * dired.c, sysdep.c: Test HAVE_DIRENT_H instead of SYSV_SYSTEM_DIR. + * config.in: Undef HAVE_DIRENT_H. + * s/aix4-2.h, s/bsd-common.h, s/cygwin.h, s/gnu-linux.h, + * s/msdos.h, s/usg5-4.h: Don't define SYSV_SYSTEM_DIR. + +2010-07-29 Dan Nicolaescu <dann@ics.uci.edu> + + Rename s/usg5-4.h -> s/usg5-4-common.h. + * s/usg5-4.h: Rename file to ... + * s/usg5-4-common.h: ... this for consistency with what we do for BSD. + * s/unixware.h: + * s/sol2-6.h: + * s/irix6-5.h: Update includes accordingly. + +2010-07-29 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (x_set_tool_bar_position): Remove debug fprintf. + + * xterm.h (struct x_output): Add toolbar_top_height, + toolbar_bottom_height, toolbar_left_width, toolbar_right_width. + Remove toolbar_height. + If USE_GTK: Add hbox_widget and toolbar_in_hbox. + (FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT) + (FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros. + (FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT. + + * xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth. + + * xfns.c (x_set_tool_bar_position): New function. + (xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT. + (x_frame_parm_handlers): Add x_set_tool_bar_position. + (syms_of_xfns): If USE_GTK, provide move-toolbar. + + * window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT + and FRAME_TOOLBAR_LEFT_WIDTH. + + * gtkutil.h (xg_change_toolbar_position): Declare. + + * gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro. + (xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth. + (xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH. + (xg_create_frame_widgets): Create a hobox for placing widgets + vertically. Use gtk_box_pack_start. + (xg_height_or_width_changed): Renamed from xg_height_changed. + (x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width. + (xg_update_frame_menubar, free_frame_menubar): Change to + xg_height_or_width_changed. + (xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar + size correctly. Remove hardcoded 4, instead use handlebox size - + toolbar size. + (xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar + size correctly. Use handlebox size + toolbar size as additional size. + (xg_pack_tool_bar): POS is a new parameter. + Set orientation of tool bar based on pos. + Only make handlebox_widget if NULL. + Check if tool bar goes to vbox or hbox depending on pos. + (xg_update_tool_bar_sizes): New function. + (update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar + height, call xg_update_tool_bar_sizes instead. + (free_frame_tool_bar): Remove from hbox or vbox depending on + toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero. + (xg_change_toolbar_position): New function. + + * frame.h (struct frame): Add tool_bar_position. + (Qbottom): Declare. + + * frame.c (Qtool_bar_position): New variable. + (make_frame): Set tool_bar_position to Qtop. + (frame_parms): Add tool-bar-position. + (x_report_frame_params): Store tool_bar_position. + (x_set_fringe_width): Reset wm size hint after fringe changes. + +2010-07-29 Dan Nicolaescu <dann@ics.uci.edu> + + Make lisp_time_argument declaration work on all systems. + * lisp.h (lisp_time_argument): Move declaration ... + * systime.h (lisp_time_argument): ... here + * editfns.c (lisp_time_argument): Remove declaration. (Bug#6751) + +2010-07-29 Jan Djärv <jan.h.d@swipnet.se> + + * vm-limit.c (POINTER): Add typedef for it. + (start_of_data): Change return type from POINTER to char *. + + * frame.h (Qtty_color_mode): Move declaration out of ifdef + HAVE_WINDOW_SYSTEM. + +2010-07-29 Dan Nicolaescu <dann@ics.uci.edu> + + * vm-limit.c: Do not include sys/resource.h, mem-limits.h does it. + Remove reference to __osf__, unused. + + * mem-limits.h: Remove duplicated includes. + (NULL): Remove definition, unused. + (POINTER): Remove definition. + (start_of_data): Use char* in prototype, as the function + definition does. + + Remove extern declarations from .c files, and them to .h files. + * keyboard.h (Qhelp_echo, waiting_for_input) + (input_available_clear_time, ignore_mouse_drag_p) + (Vdouble_click_time, real_this_command, Vthis_original_command): + * keymap.h (Qremap, Qmenu_item, Voverriding_local_map) + (Voverriding_local_map_menu_flag): + * lisp.h (Qinteractive_form, use_file_dialog) + (Qcursor_in_echo_area, QCascent, QCmargin, QCrelief, Qcount) + (Qextension_data, QCconversion, QCcolor_symbols, QCheuristic_mask) + (QCindex, QCmatrix, QCcolor_adjustment, QCmask) + (Qrisky_local_variable, map_char_table_for_charset, Vprint_level) + (Qfunction, debug_on_next_call, Qfield) + (Vinhibit_field_text_motion, Vuser_login_name, lisp_time_argument) + (Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string) + (Qfile_directory_p, Qinsert_file_contents) + (Qcompletion_ignore_case, Qcompletion_ignore_case) + (Vcompletion_regexp_list, Vhistory_length, completion_ignore_case) + (history_delete_duplicates, minibuffer_auto_raise, Qonly) + (Qfile_name_handler_alist, Qfront_sticky, Qrear_nonsticky) + (Qminibuffer_prompt) + (Vtemporary_file_directory,char_ins_del_vector, Qface): + * xterm.h (gray_bitmap_width, gray_bitmap_height) + (gray_bitmap_bits, xic_create_fontsetname): + * coding.h (Vtranslation_table_for_input): Add extern declarations. + + * xsmfns.c (Vuser_login_name): + * xrdb.c (Vdouble_click_time): + * xfaces.c (xic_create_fontsetname): + * w32select.c (waiting_for_input): + * print.c (minibuffer_auto_raise): + * msdos.c (Qhelp_echo): + * macros.c (real_this_command): + * keymap.c (Voverriding_local_map): + * xterm.c (poll_for_input_1, gray_bitmap_width) + (gray_bitmap_height, gray_bitmap_bits; + * xmenu.c ( Voverriding_local_map) + (Voverriding_local_map_menu_flag; Qmenu_item; use_dialog_box) + (use_file_dialog, Xt_app_con): + * xdisp.c (minibuffer_auto_raise, Voverriding_local_map) + (Voverriding_local_map_menu_flag, Qmenu_item, Qface, Qinvisible) + (Qwidth, Qinvisible, Qwindow, Qpriority, Qtool_bar_lines) + (Qtool_bar_lines, ignore_mouse_drag_p): + * minibuf.c (Voverriding_local_map, Qfield, Qfront_sticky) + (Qrear_nonsticky, nconc2): + * keyboard.c (current_global_map, minibuf_level, Qmenu_item) + (Vhistory_length, Vtranslation_table_for_input, Qcomposition) + (Qdisplay, Qafter_string, Qbefore_string, Qundefined): + * fileio.c (use_dialog_box, use_file_dialog, Vuser_login_name) + (minibuf_level, minibuffer_auto_raise, lisp_time_argument): + * eval.c (Qinteractive_form, Qrisky_local_variable, Qfunction) + (gc_in_progress): + * doc.c (Voverriding_local_map, Qremap): + * dired.c (completion_ignore_case, Qcompletion_ignore_case) + (Vcompletion_regexp_list): + * coding.c (Qmac, Qinsert_file_contents, Qwrite_region) + (Qcompletion_ignore_case): + * callint.c (Qcursor_in_echo_area, Qfile_directory_p, Qonly) + (Vhistory_length, Vthis_original_command, real_this_command) + (Qface, Qminibuffer_prompt, history_delete_duplicates): + * image.c (Qrisky_local_variable): + * fontset.c (QCname): + * fns.c (minibuffer_auto_raise, QCname): + * dispnew.c (char_ins_del_cost): + * composite.c (font_fill_lglyph_metrics): + * cmds.c (Qface, Vtranslation_table_for_input): + * charset.c (map_char_table_for_charset, Qfile_name_handler_alist): + * ccl.c (charset_unicode): + * callproc.c (Vtemporary_file_directory): + * buffer.c (emacs_strerror): Remove extern declarations. + + * data.c (Qwindow): Make non-static, used from other files too. + * frame.c (validate_x_resource_name): Remove shadow definition for i. + + * unexec.c (make_hdr): Remove references to NO_REMAP, COFF, + SEGMENT_MASK, SECTION_ALIGNMENT, ADJUST_EXEC_HEADER. + * s/usg5-4.h (COFF): + * s/template.h: + * s/msdos.h (COFF, NO_REMAP): + * s/ms-w32.h (NO_REMAP): + * s/hpux10-20.h (NO_REMAP): + * m/sparc.h (SEGMENT_MASK): + * m/m68k.h (NO_REMAP): + * m/intel386.h (SEGMENT_MASK): + * m/arm.h (NO_REMAP): + * m/alpha.h (COFF): + * m/template.h: Remove references to unused defines. + +2010-07-28 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (Ftool_bar_get_system_style): Also check for + Qtext_image_horiz. + + * xdisp.c (Qtext_image_horiz): Define. + (syms_of_xdisp): Initialize Qtext_image_horiz. Add text-image-horiz + to documentation of tool-bar-style. + + * lisp.h (Qtext_image_horiz): Declare. + + * gtkutil.c (xg_make_tool_item, xg_show_toolbar_item): Handle tool bar + style text_image_horiz. + +2010-07-27 Dan Nicolaescu <dann@ics.uci.edu> + + * emacs.c (Fkill_emacs): Remove return statement. + + * term.c (Qspace, QCalign_to, QCwidth): Remove declarations. + (encode_terminal_code, produce_composite_glyph): Remove unused variables. + (set_tty_color_mode, term_mouse_highlight, term_get_fkeys): Remove + local extern declarations. + + * xmenu.c: Do not included lwlib.h, not needed. + + * m/iris4d.h (XUINT, XSET): Remove, not needed. + + * process.c: Move definitions earlier to minimize #ifdefs. + + * xterm.h (x_get_customization_string, x_load_resources) + (x_get_resource, x_text_icon, x_text_icon, x_check_errors) + (x_check_errors, x_property_data_to_lisp, defined_color) + (xic_set_xfontset, x_defined_color): Use const. + + * xterm.c (xlwmenu_window_p, xlwmenu_redisplay): Remove declarations. + (x_text_icon, x_check_errors, x_connection_closed): Use const. + + * xselect.c (selection_data_to_lisp_data) + (x_property_data_to_lisp): + * xrdb.c (x_get_string_resource, file_p) + (x_get_customization_string, magic_file_p, search_magic_path) + (get_system_app, get_user_app, x_load_resources, x_get_resource) + (x_get_string_resource): Use const. + + * xfns.c: Include xlwmenu.h when USE_LUCID. + (x_defined_color, xic_set_xfontset): Use const. + (Fx_hide_tip): Remove local extern declaration. + + * xfaces.c (Qmouse_face): Remove declaration. + (face_color_gray_p, tty_defined_color, defined_color) + (face_color_gray_p, face_color_supported_p): Add const. + + * xdisp.c (do_mouse_tracking): Remove declaration. + (add_to_log): Use const. + + * minibuf.c (Qmouse_face): Remove declaration. + + * msdos.c (IT_note_mouse_highlight): Remove local extern declaration. + + * keyboard.h (do_mouse_tracking): Add declaration. + + * image.c (QCwidth, QCheight, QCforeground, QCbackground, QCfile) + (QCdata, QCtype, Qcenter): Remove declarations. + + * frame.c (x_get_resource_string, x_get_string_resource) + (x_get_arg, x_frame_get_arg, x_frame_get_and_record_arg) + (x_default_parameter): Use const. + + * font.c (Qnormal, QCtype, QCfamily, QCweight, QCslant, QCwidth) + (QCheight, QCsize, QCname): Remove declarations. + + * emacs.c (main): Remove local extern declaration. + + * editfns.c (region_limit, syms_of_editfns): Remove local extern + declarations. + + * dispnew.c: Remove duplicate #include <unistd.h>. + (update_window, update_frame_1, init_display): Remove local extern + declarations. + + * dispextern.h (add_to_log): Remove declaration. + (x_get_arg, x_frame_get_arg, x_frame_get_and_record_arg) + (x_frame_get_and_record_arg, x_default_parameter): Add const. + + * dired.c (scmp): Add const. + (directory_files_internal): Remove local extern declaration. + + * data.c (Finteractive_form): Use const. + + * composite.c (syms_of_composite): Remove local extern declarations. + + * charset.c (add_to_log): Remove declaration. + + * character.c (strwidth, parse_str_to_multibyte): Add const. + + * character.h (strwidth, parse_str_to_multibyte): Likewise. + + * buffer.c (Fset_buffer_multibyte): Remove local extern declaration. + + * lisp.h (Fkill_emacs): Mark as NO_RETURN. + (Lisp_Subr): Make doc and intspec constant. + (QCsize, Qspace, Qcenter, QCalign_to, QCdata, QCfile, QCtype) + (Qlocal, Qapply, Qnormal, QCfamily, QCweight, QCslant, QCwidth) + (QCheight, QCsize, QCname, QCwidth, QCforeground) + (QCbackground, add_to_log, stack_base, Vmark_even_if_inactive) + (display_arg): Add declarations. + +2010-07-27 Christoph Scholtes <cschol2112@gmail.com> + + * minibuf.c (Fread_buffer): Doc fix (bug#6528). * window.c (Fwindow_height): Doc fix (bug#6518). -2010-07-21 Juanma Barranquero <lekktu@gmail.com> +2010-07-27 Juanma Barranquero <lekktu@gmail.com> * buffer.c (syms_of_buffer) <fringe-indicator-alist>: Doc fix. +2010-07-26 Dan Nicolaescu <dann@ics.uci.edu> + + * keyboard.c (Ftop_level, Fexit_recursive_edit) + (Fabort_recursive_edit): Remove return statements in NO_RETURN + functions. + + * frame.h (Qtty_color_mode): Add declaration. + + * lisp.h (Ftop_level, Fexit_recursive_edit) + (Fabort_recursive_edit): Mark as NO_RETURN. + +2010-07-26 Kenichi Handa <handa@m17n.org> + + * font.c (Ffont_shape_gstring): Terminate GSTRING by nil if the + number of glyphs gets smaller than the original length. (Bug#6621) + +2010-07-26 Juanma Barranquero <lekktu@gmail.com> + + * lread.c (unreadpure, mapatoms_1): Make static. + +2010-07-25 Juanma Barranquero <lekktu@gmail.com> + + * terminfo.c (tparam): Fix prototype of tparm. + +2010-07-25 Andreas Schwab <schwab@linux-m68k.org> + + * emacs.c (main) [PROFILING]: Use __executable_start if defined to + find start of text segment. + * dispnew.c (safe_bcopy): Don't define if HAVE___EXECUTABLE_START + is defined. + + * callproc.c (set_initial_environment): Avoid unbalanced braces. + +2010-07-25 Ken Brown <kbrown@cornell.edu> + + * vm-limit.c (check_memory_limits): Fix previous change; + accidentally reverted an earlier change. + +2010-07-25 Ken Brown <kbrown@cornell.edu> + + * mem-limits.h (BSD4_2) [cygwin]: Don't define here; instead... + * vm-limit.c: ...add 'defined (CYGWIN)' here (Bug#6715). + +2010-07-25 Juanma Barranquero <lekktu@gmail.com> + + * callproc.c (relocate_fd): Set inside #ifndef WINDOWSNT. + * dired.c (opendir, readdir): Fix prototypes. + * editfns.c (w32_get_internal_run_time): Fix prototypes. + * keyboard.c (input_available_signal): Declare inside #ifdef SIGIO. + * ndir.h (opendir, readdir, seekdir, closedir): Fix prototypes. + (telldir): Remove declaration. + * ralloc.c (real_morecore, __morecore): Fix prototypes. + * sound.c (alsa_sound_perror): Declare inside #ifdef HAVE_ALSA. + * syssignal.h (strsignal): Fix prototype. + * term.c (tparam): Fix prototype. + (term_get_fkeys_address, term_get_fkeys_kboard, term_get_fkeys_1) + (term_get_fkeys): Set inside "#ifndef DOS_NT". + * vm-limit.c (check_memory_limits): Fix prototypes of real_morecore + and __morecore. + * w32gui.h (XParseGeometry): Fix prototype. + * w32heap.h (get_data_start, get_data_end, init_heap): Fix prototypes. + * w32term.c (my_set_focus): Declare inside #if 0. + * w32term.h (x_window_to_frame, x_display_info_for_name, w32_term_init) + (w32_fill_rect, w32_clear_window, init_crit, delete_crit, signal_quit) + (drain_message_queue, get_next_msg, post_msg, parse_button) + (ClipboardSequence_Proc): Fix prototypes. + (wait_for_sync): Remove declaration. + +2010-07-24 Juanma Barranquero <lekktu@gmail.com> + + * w32fns.c (w32_to_x_color): Remove, unused. + +2010-07-24 Andreas Schwab <schwab@linux-m68k.org> + + * lisp.h: Remove leftover P_. + +2010-07-24 Dan Nicolaescu <dann@ics.uci.edu> + + * ecrt0.c, unexalpha.c: Remove files, unused. + +2010-07-24 Andreas Schwab <schwab@linux-m68k.org> + + * cmds.c (internal_self_insert): Make static. + * lisp.h (internal_self_insert): Remove declaration. + +2010-07-23 Juanma Barranquero <lekktu@gmail.com> + + * alloc.c (free_float): + * font.c [ENABLE_CHECKING] (font_match_xlfd, font_check_xlfd_parse): + * frame.c (delete_frame_handler): + * ralloc.c (reorder_bloc): + * w32menu.c (menubar_id_to_frame, add_left_right_boundary): + Remove unused static functions. + + * menu.c (cleanup_popup_menu): Set inside "#ifdef HAVE_NS"; + it is called only from NS code. + + * w32term.c (my_set_focus): #ifdef away; it is called only from + "#ifdef 0" code. + + * w32fns.c (x_edge_detection): + * xfaces.c (may_use_scalable_font_p): + Remove obsolete static declarations. + +2010-07-20 Juanma Barranquero <lekktu@gmail.com> + + * alloc.c (emacs_blocked_free, emacs_blocked_malloc) + (emacs_blocked_realloc, uninterrupt_malloc): + * fringe.c (w32_reset_fringes): + * image.c (convert_mono_to_color_image, lookup_rgb_color) + (init_color_table, XPutPixel, jpeg_resync_to_restart_wrapper): + * sound.c (be2hs, do_play_sound): + * vm-limit.c (get_lim_data, ret_lim_data): + * w32term.c (x_free_frame_resources): + * xfaces.c (x_create_gc, x_free_gc): + Convert definitions to standard C. + +2010-07-20 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c (Feval, Ffuncall): Use the new names. + + * lisp.h (struct Lisp_Subr): Rename `am' to aMANY and add aUNEVALLED. + (DEFUN): Add braces around the union initialisation and use ## to + specify the right union alternative and avoid a cast. + +2010-07-18 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/keyboard.$(O)): Update dependencies. + +2010-07-17 Chong Yidong <cyd@stupidchicken.com> + + * frame.c (make_initial_frame): Use set_menu_bar_lines (Bug#6660). + 2010-07-17 Jan Djärv <jan.h.d@swipnet.se> * gtkutil.c (xg_event_is_for_menubar): Also check that event window is related to the menu bar (Bug#6499). + (xg_frame_resized): GTK_IS_MAPPED => gtk_widget_get_mapped, for Gtk 3.0. -2010-07-14 Jan Djärv <jan.h.d@swipnet.se> +2010-07-16 Jan Djärv <jan.h.d@swipnet.se> * xterm.h (x_menubar_window_to_frame): Second parameter is XEvent*. @@ -248,11 +2732,1133 @@ * gtkutil.c (xg_event_is_for_menubar): New function (Bug#6499). -2010-07-14 Eli Zaretskii <eliz@gnu.org> +2010-07-16 Eli Zaretskii <eliz@gnu.org> * w32fns.c (x_set_foreground_color): Fix setting the cursor color when it's the same as the old foreground. (Bug#6609) +2010-07-16 Jan Djärv <jan.h.d@swipnet.se> + + * xmenu.c (free_frame_menubar): Only call x_set_window_size if + widget is non-null (Bug#6645). + +2010-07-15 Andreas Schwab <schwab@linux-m68k.org> + + * xterm.c (x_fully_uncatch_errors, x_trace_wire, x_check_font): + Convert old-style definition. + + * xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of + timestamp argument. + +2010-07-15 Eli Zaretskii <eliz@gnu.org> + + * fringe.c (update_window_fringes): Restore mistakenly reverted + code from 2010-04-17T12:33:05Z!eliz@gnu.org merged in 2010-04-20T13:31:28Z!eliz@gnu.org. + +2010-07-14 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (xm_scroll_callback, x_process_timeouts): K&R => prototype. + (SET_SAVED_KEY_EVENT): Remove (not used). + (SET_SAVED_MENU_EVENT): Rename to SET_SAVED_BUTTON_EVENT and + remove size parameter. + (handle_one_xevent): Check popup_activated () for menu for Xt also. + Remove #ifdef USE_GTK around finish = X_EVENT_DROP. + Remove #ifdef USE_MOTIF code that did SET_SAVED_BUTTON_EVENT for + ButtonRelease. + (x_set_window_size_1): scroll_bar_actual_width is always + SCROLL_BAR_COLS * COLUMN_WIDTH for the purpose of frame sizing. + + * xdisp.c (pending_menu_activation): Remove extern declaration. + (prepare_menu_bars): Remove setting of pending_menu_activation. + + * xmenu.c (pending_menu_activation): Remove. + (x_activate_menubar): Set popup_activated_flag for Xt also. + Remove setting of pending_menu_activation. + (set_frame_menubar): Remove check of pending_menu_activation. + Declare menubar_size before code. Correct spelling in comment. + +2010-07-14 Kenichi Handa <handa@m17n.org> + + * font.c (font_open_entity): Cancel previous change. + (Ffont_get): Don't check FONT_ENTITY_INDEX of a font-object. + +2010-07-13 Eli Zaretskii <eliz@gnu.org> + + Remove subprocesses #ifdefs. + * process.c <inhibit_sentinels>: Move to the common part. + (Fwaiting_for_user_input_p): Move to the common part; return nil + if async subprocesses aren't supported. + * sysdep.c (wait_for_termination) [!MSDOS]: Don't compile on + MS-DOS. Remove "#ifdef subprocesses". + (sys_subshell, sys_select): Remove "#ifdef subprocesses". + (gettimeofday): Remove "#ifdef subprocesses". + (wait_without_blocking): Remove function. + (flush_pending_output, child_setup_tty): Don't compile on MS-DOS. + Remove "#ifdef subprocesses". + (child_setup_tty): Use WINDOWSNT instead of DOS_NT, since not + compiled on MS-DOS. + * callproc.c (Fcall_process) [!MSDOS]: Don't call + wait_for_termination on MS-DOS. + * emacs.c (shut_down_emacs): Remove "#ifndef subprocesses" from + initialization of inhibit_sentinels. + * keyboard.c (record_asynch_buffer_change): Remove "#ifdef + subprocesses" conditional. + * callproc.c (Fcall_process) [!subprocesses]: Don't call + wait_for_termination, since `buffer' cannot be an integer when + async subprocesses are not supported + * xdisp.c (decode_mode_spec): Use `MSDOS' instead of `subprocesses' + for ifdefing away the call to Fprocess_status. + + * process.c (add_keyboard_wait_descriptor) [!subprocesses]: Ifdef + away the entire body of the function. + +2010-07-13 Dan Nicolaescu <dann@ics.uci.edu> + + Remove subprocesses #ifdefs from term.c. + * process.c (add_keyboard_wait_descriptor) + (delete_keyboard_wait_descriptor): Move to common section, do + nothing when subprocesses is not defined. + * term.c (Fsuspend_tty, Fresume_tty, init_tty): + Remove subprocesses #ifdefs. + + Convert maybe_fatal to standard C. + * lisp.h (verror): Declare. + * eval.c (verror): New function containing the code from ... + (error): ... this. Call verror. + * term.c (vfatal): New function containing the code from ... + (fatal): ... this. Call vfatal. + (maybe_fatal): Convert to standard C, use variable number of + arguments. Declare as non-return. + (init_tty): Fix maybe_fatal call. + +2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> + + * xterm.c (x_scroll_bar_set_handle, x_scroll_bar_expose) + (_scroll_bar_note_movement): Convert definitions to standard C. + * xmenu.c (menu_help_callback, pop_down_menu, xmenu_show): + * xfns.c (hack_wm_protocols, x_window, x_window): Likewise. + +2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> + + * xterm.c (x_frame_of_widget, x_alloc_nearest_color_for_widget) + (x_alloc_lighter_color_for_widget, cvt_string_to_pixel) + (cvt_pixel_dtor, x_window_to_menu_bar, xt_action_hook) + (xaw_jump_callback, xaw_scroll_callback) + (x_create_toolkit_scroll_bar, x_set_toolkit_scroll_bar_thumb) + (x_wm_set_size_hint, x_activate_timeout_atimer): Convert + definitions to standard C. + * xmenu.c (menubar_id_to_frame, popup_get_selection) + (popup_activate_callback, popup_deactivate_callback) + (menu_highlight_callback, menubar_selection_callback) + (apply_systemfont_to_dialog, apply_systemfont_to_menu) + (free_frame_menubar, popup_selection_callback, as) + (create_and_show_popup_menu, dialog_selection_callback) + (create_and_show_dialog): + * xfns.c (hack_wm_protocols, x_window): + * xfaces.c (x_update_menu_appearance): + * widget.c (get_default_char_pixel_size, pixel_to_char_size) + (char_to_pixel_size, round_size_to_char, get_wm_shell) + (set_frame_size, update_wm_hints, setup_frame_gcs) + (update_various_frame_slots, update_from_various_frame_slots) + (EmacsFrameInitialize, EmacsFrameRealize, EmacsFrameResize) + (EmacsFrameSetValues, EmacsFrameQueryGeometry) + (EmacsFrameSetCharSize, widget_store_internal_border): Likewise. + +2010-07-12 Andreas Schwab <schwab@linux-m68k.org> + + * dbusbind.c (xd_initialize): Don't compare boolean with a constant. + +2010-07-12 Eli Zaretskii <eliz@gnu.org> + + * process.c (setup_process_coding_systems): Move to the part + shared by non-subprocesses systems, and make its body empty when + subprocesses is not defined. + (close_process_descs): Move to the part shared by non-subprocesses + systems. + (wait_reading_process_output) [!subprocesses]: Convert arg list to + ANSI C. + +2010-07-12 Andreas Schwab <schwab@linux-m68k.org> + + * editfns.c (transpose_markers): Convert old-style definition. + * emacs.c (abort, shut_down_emacs, fixup_locale) + (synchronize_system_time_locale) + (synchronize_system_messages_locale, syms_of_emacs): Likewise. + * floatfns.c (extract_float, matherr, init_floatfns) + (syms_of_floatfns): Likewise. + * fns.c (make_hash_table): Likewise. + * ftfont.c (ftfont_get_otf, ftfont_otf_features) + (ftfont_otf_capability, ftfont_get_glyph_id, ftfont_get_metrics) + (ftfont_drive_otf, ftfont_shape_by_flt, ftfont_shape) + (ftfont_variation_glyphs): Likewise. + * gtkutil.c (xg_create_widget, xg_modify_menubar_widgets): Likewise. + * keymap.c (describe_map_tree, describe_map, describe_vector): Likewise. + * lread.c (read_filtered_event): Likewise. + * minibuf.c (read_minibuf_noninteractive, read_minibuf): Likewise. + * process.c (wait_reading_process_output): Likewise. + * scroll.c (do_line_insertion_deletion_costs): Likewise. + * search.c (search_buffer, boyer_moore): Likewise. + * syntax.c (scan_sexps_forward): Likewise. + * xdisp.c (try_scrolling): Likewise. + * xfaces.c (face_at_buffer_position, face_for_overlay_string) + (face_at_string_position): Likewise. + * xfns.c (x_default_scroll_bar_color_parameter): Likewise. + * xselect.c (x_get_window_property, receive_incremental_selection) + (x_get_window_property_as_lisp_data, lisp_data_to_selection_data): + Likewise. + * xterm.c (x_draw_relief_rect, x_draw_box_rect): Likewise. + +2010-07-12 Dan Nicolaescu <dann@ics.uci.edu> + + * callproc.c (child_setup): Remove subprocesses conditional. + Remove code dealing with SET_EMACS_PRIORITY, unused. + + * buffer.c (Fset_buffer_multibyte): Remove subprocesses conditional. + * process.c (close_process_descs): Use DOS_NT instead of WINDOWSNT. + + * emacs.c (__do_global_ctors, __do_global_ctors_aux) + (__do_global_dtors, __main): Use void in definition. + (main): Remove code dealing with SET_EMACS_PRIORITY, unused. + Remove SYMS_MACHINE code, unused. Remove SYMS_SYSTEM, inline + the only users from ... + * s/ms-w32.h (SYMS_SYSTEM): ... here and ... + * s/msdos.h (SYMS_SYSTEM): ... here. Remove. + (HAVE_VOLATILE): Remove, unused. + + Convert more function definitions to standard C. + * xdisp.c (window_box_edges, handle_single_display_spec) + (display_string): Convert definition to standard C. + * scroll.c (do_direct_scrolling, scrolling_1): + * dispnew.c (allocate_matrices_for_frame_redisplay) + (mirrored_line_dance): + * coding.c (code_convert_string): + * charset.c (map_charset_chars): + * ccl.c (Fccl_program_p, Fccl_execute, Fccl_execute_on_string) + (Fregister_ccl_program, Fregister_code_conversion_map): + * keyboard.c (kbd_buffer_nr_stored): Likewise. + (head_table): Make static and const. + +2010-07-12 Andreas Schwab <schwab@linux-m68k.org> + + * Makefile.in (C_WARNINGS_SWITCH, PROFILING_CFLAGS) + (PROFILING_LDFLAGS): Set from substitution. + (ALL_CFLAGS): Add C_WARNINGS_SWITCH and PROFILING_CFLAGS, put + CFLAGS last. + +2010-07-12 Kenichi Handa <handa@m17n.org> + + * Makefile.in (lisp): Change hebrew.el to hebrew.elc. + (shortlisp): Likewise. + + * font.h (enum font_property_index): New member FONT_ENTITY_INDEX. + + * font.c (font_open_entity): Record ENTITY in FONT_OBJECT's slot + of FONT_ENTITY_INDEX. + (Ffont_get): If KEY is :otf and the font-object doesn't have the + property, get the property value dynamically. + (Ffont_put): Accept font-entity and font-object too. + (Ffont_get_glyhphs): Renamed from Fget_font_glyphs. Arguments and + return value changed. + (syms_of_font): Adjusted for the above change. + +2010-07-11 Andreas Schwab <schwab@linux-m68k.org> + + * blockinput.h: Remove obsolete comment. + + * lisp.h: Include <stddef.h>. + (OFFSETOF): Don't define. + (VECSIZE): Use offsetof instead of OFFSETOF. + (PSEUDOVECSIZE): Likewise. + * process.c (conv_sockaddr_to_lisp): Likewise. + * alloc.c: Don't include <stddef.h>. + * buffer.h (PER_BUFFER_VAR_OFFSET): Use offsetof. + + * process.c: Remove obsolete comment. + +2010-07-11 Chong Yidong <cyd@stupidchicken.com> + + * xfaces.c (Vface_remapping_alist): Doc fix (Bug#6091). + +2010-07-11 Andreas Schwab <schwab@linux-m68k.org> + + * callint.c (Fcall_interactively): Use strchr, strrchr instead of + index, rindex. + * doc.c (get_doc_string, Fsnarf_documentation): Likewise. + * editfns.c (Fuser_full_name, Fformat): Likewise. + * emacs.c (argmatch, sort_args, decode_env_path): Likewise. + * fileio.c (Ffile_symlink_p): Likewise. + * filelock.c (current_lock_owner): Likewise. + * font.c (font_parse_name, font_parse_family_registry): Likewise. + * fontset.c (fontset_pattern_regexp): Likewise. + * lread.c (read1): Likewise. + * sysdep.c (init_system_name): Likewise. + * xfns.c (select_visual): Likewise. + * s/hpux10-20.h (index, rindex): Don't define. + * s/ms-w32.h (index): Likewise. + * s/usg5-4.h: Likewise. + + * callproc.c (relocate_fd): Use F_DUPFD if defined. + + * alloc.c (pending_malloc_warning, malloc_warning): Add const. + * callproc.c (relocate_fd, getenv_internal_1, getenv_internal) + (egetenv): Likewise. + * doprnt.c (doprnt): Likewise. + * editfns.c (set_time_zone_rule, format2): Likewise. + * emacs.c (decode_env_path): Likewise. + * eval.c (signal_error, error): Likewise. + * insdel.c (replace_range_2): Likewise. + * keyboard.c (cmd_error_internal): Likewise. + * lread.c (isfloat_string, make_symbol, dir_warning): Likewise. + * print.c (write_string, write_string_1, print_error_message): + Likewise. + * vm-limit.c (warn_function, memory_warnings): Likewise. + * xdisp.c (message1, message1_nolog, message_with_string) + (vmessage, message, message_nolog): Likewise. + * emacs.c: Remove duplicate declaration. + * keyboard.h: Likewise. + * lisp.h: Update prototypes. + + * eval.c: Fix indentation problem. + + * keyboard.c: Include "process.h" + + * eval.c: Remove obsolete noinline declaration. + * fns.c: Likewise. + +2010-07-11 Ken Raeburn <raeburn@raeburn.org> + + * doprnt.c (doprnt): Take a va_list argument instead of count and + pointer. + * eval.c (error): Change to a standard-C variadic function. + * xdisp.c (vmessage): Renamed from message, made static, and + changed to take a va_list argument. + (message): New variadic wrapper. + (message_nolog): Now a variadic function, calling vmessage. + * lisp.h: Include stdarg.h for va_list. + (doprnt, error, message, message_nolog): Decls updated. + +2010-07-11 Eli Zaretskii <eliz@gnu.org> + + * process.c (syms_of_process) <delete-exited-processes>: Define + even if !subprocesses. + (delete_exited_processes): Ditto. + + * msdos.c (syms_of_msdos) <delete-exited-processes>: Remove DEFVAR. + (delete_exited_processes): Don't define. + +2010-07-10 Chong Yidong <cyd@stupidchicken.com> + + * frame.c (make_frame): Initialize menu_bar_lines and + tool_bar_lines members. + (make_initial_frame, make_terminal_frame): Initialize + menu_bar_lines using value of menu-bar-mode. + + * msdos.c (IT_set_frame_parameters): Don't set menu-bar-lines. + +2010-07-10 Eli Zaretskii <eliz@gnu.org> + + * process.c: Reshuffle #include's. Condition some of the global + and static variables on `subprocesses'. + (hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): + Leave only one implementation. + (Fget_buffer_process, Fprocess_inherit_coding_system_flag) + (kill_buffer_processes, Flist_system_processes) + (Fprocess_attributes, init_process, syms_of_process): Unify the + implementations for with subprocesses and without them. + +2010-07-09 Jan Djärv <jan.h.d@swipnet.se> + + * xmenu.c (set_frame_menubar): Must realize menubar_widget to get the + correct size for Motif. + (free_frame_menubar): Call x_set_window_size to update frame size. + + * xfns.c (x_window): Set borderWidth to 0 for pane and + EmacsFrame. Frame size calculation is wrong otherwise. + +2010-07-09 Michael Albinus <michael.albinus@gmx.de> + + * dbusbind.c (xd_initialize): Add new argument RAISE_ERROR, which + allows to suppress errors when polling in Emacs' main loop. + (Fdbus_init_bus, Fdbus_get_unique_name, Fdbus_call_method) + (Fdbus_call_method_asynchronously, Fdbus_method_return_internal) + (Fdbus_method_error_internal, Fdbus_send_signal) + (xd_get_dispatch_status, xd_read_message, Fdbus_register_signal) + (Fdbus_register_method): Use it. (Bug#6579) + +2010-07-08 Dan Nicolaescu <dann@ics.uci.edu> + + * alloc.c: Convert DEFUNs to standard C. + * buffer.c: + * bytecode.c: + * callint.c: + * callproc.c: + * casefiddle.c: + * casetab.c: + * category.c: + * character.c: + * charset.c: + * chartab.c: + * cmds.c: + * coding.c: + * composite.c: + * data.c: + * dbusbind.c: + * dired.c: + * dispnew.c: + * doc.c: + * dosfns.c: + * editfns.c: + * emacs.c: + * eval.c: + * fileio.c: + * filelock.c: + * floatfns.c: + * fns.c: + * font.c: + * fontset.c: + * frame.c: + * fringe.c: + * image.c: + * indent.c: + * insdel.c: + * keyboard.c: + * keymap.c: + * lread.c: + * macros.c: + * marker.c: + * menu.c: + * minibuf.c: + * msdos.c: + * nsfns.m: + * nsmenu.m: + * nsselect.m: + * print.c: + * process.c: + * search.c: + * sound.c: + * syntax.c: + * term.c: + * terminal.c: + * textprop.c: + * undo.c: + * w16select.c: + * w32console.c: + * w32fns.c: + * w32font.c: + * w32menu.c: + * w32proc.c: + * w32select.c: + * window.c: + * xdisp.c: + * xfaces.c: + * xfns.c: + * xmenu.c: + * xselect.c: + * xsettings.c: + * xsmfns.c: Likewise. + +2010-07-08 Eli Zaretskii <eliz@gnu.org> + + * process.c (kbd_is_on_hold, hold_keyboard_input) + (unhold_keyboard_input, kbd_on_hold_p) [!subprocesses]: Define. + +2010-07-08 Jan Djärv <jan.h.d@swipnet.se> + + * xmenu.c (set_frame_menubar, create_and_show_popup_menu) + (create_and_show_dialog): Don't call apply_systemfont_to_(menu|dialog) + unless USE_LUCID. + +2010-07-08 Dan Nicolaescu <dann@ics.uci.edu> + + * xdisp.c (store_mode_line_noprop_char): Remove K&R alternative + declaration. + + Clean up include guards. + * tparam.c: Remove include guards for config.h, string.h and code + that assumes #ifndef emacs. + * termcap.c: + * unexalpha.c: + * sysdep.c: + * filemode.c: + * filelock.c: + * bidi.c: Likewise. + + Remove prefix-args.c + * prefix-args.c: Remove file. + * autodeps.mk (ALLOBJS): Remove reference to prefix-args. + * Makefile.in (temacs${EXEEXT}): Remove references to + PRE_EDIT_LDFLAGS and POST_EDIT_LDFLAGS. + (mostlyclean): Remove reference to prefix-args. + (prefix-args): Remove. + + Simplify cstart_of_data, start_of_code and related code. + * mem-limits.h: Remove !emacs and _LIBC conditional code. + (start_of_data): Merge into start_of_data function. + * sysdep.c (start_of_text): Remove. Move simplified versions of + it in the only users: unexaix.c and unexec.c. + (read_input_waiting): Remove local declaration of quit_char. + (start, etext): Remove declarations. + (start_of_data): Merge with the version in mem-limits.h and move + to vm-limits.c. + * vm-limit.c (start_of_data): Merged and simplified version of the + code formerly in mem-limits.h and sysdep.c. + * unexec.c (start): New declaration, moved from sysdep.c. + (start_of_text): Simplified version of the code formerly in sysdep.c. + * unexaix.c (start_of_text): Simplified version of the code + formerly in sysdep.c. + * m/alpha.h (HAVE_TEXT_START): Remove. + (TEXT_START): Move ... + * unexalpha.c (TEXT_START): ... here. + * s/hpux10-20.h (TEXT_START): Remove. + * s/darwin.h (TEXT_START): + * m/mips.h (TEXT_START): + * m/macppc.h (HAVE_TEXT_START): + * m/m68k.h (TEXT_START): + * m/iris4d.h (TEXT_START): + * m/intel386.h (TEXT_START): + * m/ibmrs6000.h (TEXT_START): + * m/ia64.h (HAVE_TEXT_START): + * s/msdos.h (TEXT_START): Likewise. + +2010-07-07 Andreas Schwab <schwab@linux-m68k.org> + + * alloc.c (overrun_check_malloc, overrun_check_realloc) + (overrun_check_free, xstrdup, allocate_string) + (allocate_string_data, compact_small_strings, Fmake_string) + (make_unibyte_string, make_multibyte_string) + (make_string_from_bytes, make_specified_string, make_float) + (Fcons, allocate_terminal, allocate_frame, make_pure_string) + (Fgarbage_collect): Replace bcopy, safe_bcopy, bzero, bcmp by + memcpy, memmove, memset, memcmp. + * atimer.c (start_atimer, set_alarm): Likewise. + * buffer.c (clone_per_buffer_values, report_overlay_modification) + (mmap_realloc, init_buffer_once): Likewise. + * callint.c (Fcall_interactively): Likewise. + * callproc.c (Fcall_process, Fcall_process_region, child_setup) + (getenv_internal_1): Likewise. + * casefiddle.c (casify_object): Likewise. + * ccl.c (ccl_driver): Likewise. + * character.c (str_as_multibyte, str_to_multibyte): Likewise. + * charset.c (load_charset_map_from_file) + (load_charset_map_from_file, load_charset_map_from_vector) + (Fdefine_charset_internal): Likewise. + * cm.c (Wcm_clear): Likewise. + * coding.c (decode_eol, decode_coding_object) + (Fset_coding_system_priority, make_subsidiaries): Likewise. + * data.c (Faset): Likewise. + * dired.c (directory_files_internal, file_name_completion_stat): + Likewise. + * dispnew.c (new_glyph_matrix, adjust_glyph_matrix) + (clear_glyph_row, copy_row_except_pointers) + (copy_glyph_row_contents, new_glyph_pool, realloc_glyph_pool) + (save_current_matrix, restore_current_matrix) + (build_frame_matrix_from_leaf_window, mirrored_line_dance) + (mirror_line_dance, scrolling_window): Likewise. + * doc.c (Fsnarf_documentation, Fsubstitute_command_keys): + Likewise. + * doprnt.c (doprnt): Likewise. + * editfns.c (Fuser_full_name, make_buffer_string_both) + (Fmessage_box, Fformat, Ftranspose_regions): Likewise. + * emacs.c (sort_args): Likewise. + * eval.c (Fapply, Ffuncall): Likewise. + * fileio.c (Ffile_name_directory, make_temp_name) + (Fexpand_file_name, search_embedded_absfilename) + (Fsubstitute_in_file_name, Ffile_symlink_p, Finsert_file_contents) + (auto_save_error): Likewise. + * fns.c (Fstring_equal, Fcopy_sequence, concat) + (string_to_multibyte, Fstring_as_unibyte, Fstring_as_multibyte) + (internal_equal, Fclear_string, larger_vector, copy_hash_table) + (Fmake_hash_table): Likewise. + * fringe.c (Fdefine_fringe_bitmap): Likewise. + * ftfont.c (ftfont_text_extents): Likewise. + * getloadavg.c (getloadavg): Likewise. + * image.c (define_image_type, make_image, make_image_cache) + (x_create_x_image_and_pixmap, xbm_image_p) + (w32_create_pixmap_from_bitmap_data, xbm_load, xpm_lookup_color) + (xpm_image_p, x_create_bitmap_from_xpm_data, xpm_load) + (init_color_table, x_build_heuristic_mask, pbm_image_p, pbm_load) + (png_image_p, png_read_from_memory, png_load, jpeg_image_p) + (tiff_image_p, tiff_read_from_memory, gif_image_p) + (gif_read_from_memory, gif_load, svg_image_p, gs_image_p): + Likewise. + * indent.c (scan_for_column, compute_motion): Likewise. + * insdel.c (gap_left, gap_right, make_gap_smaller, copy_text) + (insert_1_both, insert_from_gap, replace_range_2): Likewise. + * intervals.c (reproduce_tree, reproduce_tree_obj): Likewise. + * keyboard.c (echo_char, save_getcjmp, restore_getcjmp) + (kbd_buffer_store_event_hold, apply_modifiers_uncached) + (store_user_signal_events, menu_bar_items, tool_bar_items) + (process_tool_bar_item, append_tool_bar_item) + (read_char_minibuf_menu_prompt, read_key_sequence) + (Fread_key_sequence, Fread_key_sequence_vector, Frecent_keys): + Likewise. + * keymap.c (current_minor_maps, Fdescribe_buffer_bindings): + Likewise. + * lisp.h (STRING_COPYIN): Likewise. + * lread.c (Fload, read1, oblookup): Likewise. + * msdos.c (Frecent_doskeys): Likewise. + * nsfns.m (Fx_create_frame): Likewise. + * nsfont.m (nsfont_open, nsfont_text_extents, ns_glyph_metrics): + Likewise. + * nsimage.m (EmacsImage-initFromSkipXBM:width:height:) + (EmacsImage-initForXPMWithDepth:width:height:flip:length:): + Likewise. + * nsmenu.m (ns_update_menubar): Likewise. + * nsterm.m (ns_draw_fringe_bitmap, ns_term_init): Likewise. + * print.c (print_unwind, printchar, strout, print_string) + (print_error_message): Likewise. + * process.c (conv_lisp_to_sockaddr, set_socket_option) + (Fmake_network_process, Fnetwork_interface_list) + (Fnetwork_interface_info, read_process_output, Fprocess_send_eof) + (init_process): Likewise. + * ralloc.c (resize_bloc, r_alloc_sbrk, r_alloc_init): Likewise. + * regex.c (init_syntax_once, regex_compile, re_compile_fastmap): + Likewise. + * scroll.c (do_scrolling, do_direct_scrolling) + (scrolling_max_lines_saved): Likewise. + * search.c (search_buffer, wordify, Freplace_match): Likewise. + * sound.c (wav_init, au_init, Fplay_sound_internal): Likewise. + * syntax.c (skip_chars, skip_syntaxes): Likewise. + * sysdep.c (child_setup_tty, sys_subshell, emacs_get_tty) + (emacs_set_tty): Likewise. + * term.c (encode_terminal_code, calculate_costs) + (produce_special_glyphs, create_tty_output, init_tty, delete_tty): + Likewise. + * termcap.c (tgetst1, gobble_line): Likewise. + * termhooks.h (EVENT_INIT): Likewise. + * tparam.c (tparam1): Likewise. + * unexalpha.c (unexec): Likewise. + * unexec.c (write_segment): Likewise. + * unexmacosx.c (unexec_write_zero): Likewise. + * w32fns.c (w32_wnd_proc, Fx_create_frame, x_create_tip_frame) + (Fx_file_dialog, Fsystem_move_file_to_trash): Likewise. + * w32font.c (w32font_list_family, w32font_text_extents) + (w32font_list_internal, w32font_match_internal) + (w32font_open_internal, compute_metrics, Fx_select_font): + Likewise. + * w32menu.c (set_frame_menubar, add_menu_item) + (w32_menu_display_help, w32_free_submenu_strings): Likewise. + * w32term.c (XCreateGC, w32_initialize_display_info): Likewise. + * w32uniscribe.c (uniscribe_list_family): Likewise. + * w32xfns.c (get_next_msg, post_msg, prepend_msg): Likewise. + * window.c (make_window, replace_window, set_window_buffer) + (Fsplit_window): Likewise. + * xdisp.c (init_iterator, RECORD_OVERLAY_STRING, reseat_to_string) + (add_to_log, message3, x_consider_frame_title) + (append_space_for_newline, extend_face_to_end_of_line) + (decode_mode_spec_coding, init_glyph_string): Likewise. + * xfaces.c (x_create_gc, get_lface_attributes_no_remap) + (Finternal_copy_lisp_face, Finternal_merge_in_global_face) + (face_attr_equal_p, make_realized_face, make_face_cache) + (free_realized_faces, lookup_named_face, smaller_face) + (face_with_height, lookup_derived_face) + (x_supports_face_attributes_p, Finternal_set_font_selection_order) + (Finternal_set_font_selection_order, realize_default_face) + (compute_char_face, face_at_buffer_position) + (face_for_overlay_string, face_at_string_position, merge_faces): + Likewise. + * xfns.c (xic_create_fontsetname, Fx_create_frame) + (Fx_window_property, x_create_tip_frame) + (Fx_backspace_delete_keys_p): Likewise. + * xfont.c (xfont_list, xfont_match, xfont_list_family) + (xfont_text_extents): Likewise. + * xmenu.c (set_frame_menubar, xmenu_show): Likewise. + * xrdb.c (magic_file_p, x_get_resource): Likewise. + * xselect.c (x_queue_event, x_get_window_property) + (receive_incremental_selection): Likewise. + * xsmfns.c (x_session_check_input): Likewise. + * xterm.c (x_send_scroll_bar_event, SET_SAVED_MENU_EVENT) + (handle_one_xevent, x_check_errors, xim_initialize, x_term_init): + Likewise. + * character.h (BCOPY_SHORT): Removed. + * config.in: Regenerate. + * dispnew.c (safe_bcopy): Only define as dummy if PROFILING. + * emacs.c (main) [PROFILING]: Don't declare + dump_opcode_frequencies. + * lisp.h (safe_bcopy): Remove declaration. + (memset) [!HAVE_MEMSET]: Declare. + (memcpy) [!HAVE_MEMCPY]: Likewise. + (memmove) [!HAVE_MEMMOVE]: Likewise. + (memcmp) [!HAVE_MEMCMP]: Likewise. + * s/ms-w32.h (bzero, bcopy, bcmp, GAP_USE_BCOPY) + (BCOPY_UPWARD_SAFE, BCOPY_DOWNWARD_SAFE, HAVE_BCOPY, HAVE_BCMP): + Don't define. + (HAVE_MEMCMP, HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET): Define. + * s/msdos.h (GAP_USE_BCOPY, BCOPY_UPWARD_SAFE) + (BCOPY_DOWNWARD_SAFE): Don't define. + * sysdep.c (memset) [!HAVE_MEMSET]: Define. + (memcpy) [!HAVE_MEMCPY]: Define. + (memmove) [!HAVE_MEMMOVE]: Define. + (memcmp) [!HAVE_MEMCMP]: Define. + +2010-07-07 Jan Djärv <jan.h.d@swipnet.se> + + * process.c (kbd_is_on_hold): New variable. + (hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p): + New functions. + (wait_reading_process_output): If kbd_on_hold_p returns non-zero, + select on empty input mask. + (init_process): Initialize kbd_is_on_hold to 0. + + * process.h (hold_keyboard_input, unhold_keyboard_input) + (kbd_on_hold_p): Declare. + + * keyboard.c (input_available_signal): Declare. + (kbd_buffer_nr_stored): New function. + (kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns + more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571). + (kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored + returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571). + (tty_read_avail_input): If input is on hold, return. + Don't read more that free slots in kbd_buffer (Bug#6571). + +2010-07-07 Eli Zaretskii <eliz@gnu.org> + + * msdos.h: + * msdos.c: + * dosfns.c: + * w16select.c: Convert function definitions to ANSI C. + + * msdos.h (ctrl_break_func, install_ctrl_break_check): + Remove unused prototypes. + +2010-07-07 Juanma Barranquero <lekktu@gmail.com> + + * coding.c, sysdep.c: Convert some more functions to standard C. + +2010-07-07 Juanma Barranquero <lekktu@gmail.com> + + * coding.c (decode_coding_gap, encode_coding_gap, decode_coding_object) + (encode_coding_object): Use SPECPDL_INDEX. + (syms_of_coding): Use DOS_NT. + +2010-07-07 Dan Nicolaescu <dann@ics.uci.edu> + + * intervals.h (interval): Use EMACS_UINT instead of unsigned EMACS_INT. + + Make the function member of Lisp_Subr use standard C prototypes. + * lisp.h (struct Lisp_Subr): Use a union for the function member. + (DECL_ALIGN): Add a cast for the function. + * eval.c (Feval, Ffuncall): Use the proper type for each type + function call. + +2010-07-06 Chong Yidong <cyd@stupidchicken.com> + + * fringe.c (draw_fringe_bitmap_1): Use lookup_named_face to get + fringe face id, so face-remapping-alist works (Bug#6091). + +2010-07-06 Juanma Barranquero <lekktu@gmail.com> + + * w32.c, w32console.c, w32fns.c, w32font.c, w32heap.c, w32inevt.c + * w32menu.c, w32proc.c, w32reg.c, w32select.c, w32term.c + * w32uniscribe.c, w32xfns.c: Convert function definitions to standard C. + +2010-07-06 Andreas Schwab <schwab@linux-m68k.org> + + * xterm.c (x_get_keysym_name): Change type of parameter to int. + * lisp.h: Declare x_get_keysym_name. + * keyboard.c (modify_event_symbol): Don't declare + x_get_keysym_name here. + +2010-07-06 Dan Nicolaescu <dann@ics.uci.edu> + + * ecrt0.c: Revert conversion to standard C. + +2010-07-05 Dan Nicolaescu <dann@ics.uci.edu> + + * vm-limit.c (memory_warnings): + * keyboard.c (modify_event_symbol): + * floatfns.c (rounding_driver, ceiling2, floor2, truncate2) + (round2, emacs_rint): + * process.c (send_process, old_sigpipe): Convert function + definitions and declarations to standard C. + +2010-07-05 Juanma Barranquero <lekktu@gmail.com> + + * buffer.c, cm.c, eval.c, keyboard.c, process.c, term.c, vm-limit.c, + * xdisp.c: Convert function definitions to standard C. + + * cm.c (cmputc): Arg C is now int, not char. + * process.c (Fmake_network_process): Cast sockaddr_in* to sockaddr*. + +2010-07-05 James Cloos <cloos@jhcloos.com> + + * xterm.h (Xatom_net_wm_name, Xatom_net_wm_icon_name): New. + + * xterm.c (x_term_init): Intern the _NET_WM_NAME and + _NET_WM_ICON_NAME atoms. + + * xfns.c (x_set_name_internal): Set the EWMH _NET_WM_NAME + and _NET_WM_ICON_NAME properties, too, matching what is + done in the Gtk+ case. + +2010-07-05 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (XTring_bell, XTset_terminal_window): Fix wrong prototype. + + * xsmfns.c (SSDATA): New macro. + (smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings + passed to strlen/strcpy/strcat. + (create_client_leader_window): Surround with #ifndef USE_GTK. Cast + 7:th arg to XChangeProperty to (unsigned char *). + + * xsettings.c (something_changedCB, parse_settings) + (apply_xft_settings): Reformat prototype. + (something_changedCB, init_gconf): Remove unused variable i. + (read_settings): Remove unused variable long_len. + + * gtkutil.c (xg_get_pixbuf_from_pix_and_mask) + (xg_get_image_for_pixmap, create_dialog) + (xg_get_file_with_selection, xg_get_file_name, update_cl_data) + (menuitem_highlight_callback, make_menu_item) + (xg_create_one_menuitem, create_menus, xg_update_menu_item) + (xg_create_scroll_bar, xg_update_scrollbar_pos) + (xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb) + (xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback) + (xg_tool_bar_attach_callback, xg_tool_bar_help_callback) + (xg_tool_bar_item_expose_callback): Reformat prototype. + (xg_update_menubar): GList *group => GSList *group. + (xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0 + before use. + (update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed + to GTK_IMAGE (wimage). + +2010-07-05 Dan Nicolaescu <dann@ics.uci.edu> + + * atimer.c: Use "" instead of <> for local includes for + consistency with the rest of the code. + + * xsmfns.c (smc_save_yourself_CB, smc_error_handler): + * xrdb.c (get_system_name): + * window.c (shrink_windows): + * syntax.c (forw_comment): + * scroll.c (calculate_scrolling, calculate_direct_scrolling) + (ins_del_costs): + * mem-limits.h (start_of_data): + * lread.c (readevalloop): + * gtkutil.c (xg_dialog_response_cb, xg_get_file_with_chooser) + (xg_get_file_with_selection, xg_update_menubar, xg_update_submenu): + * frame.c (x_get_focus_frame): + * floatfns.c (fmod_float): + * fileio.c (choose_write_coding_system): + * emacs.c (fatal_error_signal, init_cmdargs, argmatch) + (malloc_initialize_hook, sort_args, synchronize_locale): + * doprnt.c (doprnt): + * dired.c (compile_pattern): + * data.c (fmod_float): + * chartab.c (map_sub_char_table, map_sub_char_table_for_charset) + (map_char_table_for_charset): + * charset.c (define_charset_internal): + * alloc.c (Fgarbage_collect): Convert declarations or definitions + to standard C. + +2010-07-04 Tetsurou Okazaki <okazaki@be.to> (tiny change) + Stefan Monnier <monnier@iro.umontreal.ca> + + * lread.c (read1): Fix up last change to not mess up `c'. + +2010-07-04 Juanma Barranquero <lekktu@gmail.com> + + * strftime.c: Revert conversion to standard C (2010-07-04T07:50:25Z!dann@ics.uci.edu). + +2010-07-04 Juanma Barranquero <lekktu@gmail.com> + + Fix prototypes. + + * atimer.c (start_atimer): Use EMACS_TIME, not struct timeval. + * dired.c (file_name_completion_stat): Use DIRENTRY, not struct dirent. + * fileio.c (read_non_regular, read_non_regular_quit): Add Lisp_Object + arg, as required by internal_condition_case_1. + * print.c (strout): Use const char* for arg PTR. + * regex.c (bcmp_translate): Use RE_TRANSLATE_TYPE, not Lisp_Object. + (analyse_first): Fix "const const". + * sysdep.c (set_file_times): Use EMACS_TIME, not struct timeval. + * unexelf.c (round_up, find_section): Use ElfW macro for arguments. + * xgselect.c (xg_select): Use SELECT_TYPE, EMACS_TIME. + +2010-07-04 Dan Nicolaescu <dann@ics.uci.edu> + + * alloc.c: Convert function definitions to standard C. + * atimer.c: + * bidi.c: + * bytecode.c: + * callint.c: + * callproc.c: + * casefiddle.c: + * casetab.c: + * category.c: + * ccl.c: + * character.c: + * charset.c: + * chartab.c: + * cmds.c: + * coding.c: + * composite.c: + * data.c: + * dbusbind.c: + * dired.c: + * dispnew.c: + * doc.c: + * doprnt.c: + * ecrt0.c: + * editfns.c: + * fileio.c: + * filelock.c: + * filemode.c: + * fns.c: + * font.c: + * fontset.c: + * frame.c: + * fringe.c: + * ftfont.c: + * ftxfont.c: + * gtkutil.c: + * indent.c: + * insdel.c: + * intervals.c: + * keymap.c: + * lread.c: + * macros.c: + * marker.c: + * md5.c: + * menu.c: + * minibuf.c: + * prefix-args.c: + * print.c: + * ralloc.c: + * regex.c: + * region-cache.c: + * scroll.c: + * search.c: + * sound.c: + * strftime.c: + * syntax.c: + * sysdep.c: + * termcap.c: + * terminal.c: + * terminfo.c: + * textprop.c: + * tparam.c: + * undo.c: + * unexelf.c: + * window.c: + * xfaces.c: + * xfns.c: + * xfont.c: + * xftfont.c: + * xgselect.c: + * xmenu.c: + * xrdb.c: + * xselect.c: + * xsettings.c: + * xsmfns.c: + * xterm.c: Likewise. + +2010-07-03 Eli Zaretskii <eliz@gnu.org> + + * msdos.c (IT_set_frame_parameters): Fix setting of colors in + frames other than the initial one. Fix reversal of colors when + `reverse' is specified in the frame parameters. Call + update_face_from_frame_parameter instead of + internal-set-lisp-face-attribute. Initialize screen colors from + initial_screen_colors[] when f->default_face_done_p is zero, + instead of depending on being called with default-frame-alist as + the alist argument. + + * xfaces.c (update_face_from_frame_parameter): Move out of + HAVE_WINDOW_SYSTEM portion. Condition window-system only parts + with HAVE_WINDOW_SYSTEM. + + * msdos.c (IT_set_frame_parameters): Set menu-bar-lines according + to menu-bar-mode, if not set in the frame parameters or in + default-frame-alist. + + * w32console.c (sys_tputs): Adjust argument list to prototype in + term.c. + +2010-07-03 Juanma Barranquero <lekktu@gmail.com> + + * lisp.h (memory_warnings): Fix prototype. + + * cm.h (evalcost): Fix prototype. + + * cm.c (evalcost): Fix arg type. + +2010-07-02 Dan Nicolaescu <dann@ics.uci.edu> + + * term.c (term_clear_mouse_face, Fidentity): + * syssignal.h (signal_handler_t): + * lisp.h (memory_warnings): + * coding.h (preferred_coding_system): + * cm.h (evalcost): + * blockinput.h (reinvoke_input_signal): Convert to standard C prototypes. + +2010-07-02 Eli Zaretskii <eliz@gnu.org> + + * dosfns.h (msdos_stdcolor_idx, msdos_stdcolor_name): Remove P_ + from prototypes. + + * msdos.h (load_pixmap): Don't define away. + +2010-07-02 Jan Djärv <jan.h.d@swipnet.se> + + * lisp.h: + * atimer.h: Remove define for P_. + + * alloc.c: Remove __P and P_ from .c and .m files. + * atimer.c: + * buffer.c: + * callint.c: + * category.c: + * charset.c: + * chartab.c: + * cm.c: + * coding.c: + * composite.c: + * data.c: + * dired.c: + * dispnew.c: + * doc.c: + * editfns.c: + * emacs.c: + * eval.c: + * fileio.c: + * filelock.c: + * fns.c: + * font.c: + * fontset.c: + * frame.c: + * ftfont.c: + * ftxfont.c: + * gmalloc.c: + * gtkutil.c: + * image.c: + * indent.c: + * intervals.c: + * keyboard.c: + * keymap.c: + * lread.c: + * marker.c: + * menu.c: + * minibuf.c: + * print.c: + * process.c: + * scroll.c: + * search.c: + * sound.c: + * strftime.c: + * syntax.c: + * sysdep.c: + * term.c: + * terminal.c: + * textprop.c: + * unexalpha.c: + * w32console.c: + * w32fns.c: + * w32font.c: + * w32menu.c: + * w32term.c: + * w32uniscribe.c: + * window.c: + * xdisp.c: + * xfaces.c: + * xfns.c: + * xfont.c: + * xftfont.c: + * xmenu.c: + * xselect.c: + * xterm.c: Likewise. + + Remove P_ and __P macros. + * atimer.h: Remove P_ and __P macros. + * buffer.h: + * category.h: + * ccl.h: + * character.h: + * charset.h: + * cm.h: + * coding.h: + * composite.h: + * dispextern.h: + * disptab.h: + * dosfns.h: + * font.h: + * fontset.h: + * frame.h: + * gtkutil.h: + * indent.h: + * intervals.h: + * keyboard.h: + * keymap.h: + * lisp.h: + * macros.h: + * md5.h: + * menu.h: + * msdos.h: + * nsterm.h: + * puresize.h: + * region-cache.h: + * syntax.h: + * syssignal.h: + * systime.h: + * termhooks.h: + * w32font.h: + * w32term.h: + * widget.h: + * window.h: + * xgselect.h: + * xsettings.h: + * xterm.h: Likewise. + +2010-07-02 Dan Nicolaescu <dann@ics.uci.edu> + + * lisp.h: Document that USE_LISP_UNION_TYPE is now enabled using autoconf. + + Cleanup old code. + * dired.c (BSD4_3): Remove all uses, redundant with BSD4_2. + * syssignal.h: Remove code for Lynx, not supported anymore. + * vm-limit.c: Remove unused code the depends on emacs not being + defined and NO_LIM_DATA being defined. + * mem-limits.h: Remove dead code. + +2010-07-01 Jan Djärv <jan.h.d@swipnet.se> + + * window.c (Fwindow_absolute_pixel_edges): Doc fix. + + * window.c (calc_absolute_offset, Fwindow_absolute_pixel_edges) + (Fwindow_inside_absolute_pixel_edges): New functions (bug#5721). + + * nsfns.m (compute_tip_xy): Do not convert coordinates from frame + parameters, they are already absolute. + + * nsterm.m (x_set_window_size, initFrameFromEmacs): + Rename FRAME_NS_TOOLBAR_HEIGHT to FRAME_TOOLBAR_HEIGHT. + + * nsterm.h (FRAME_NS_TOOLBAR_HEIGHT): Rename to FRAME_TOOLBAR_HEIGHT. + + * nsmenu.m (update_frame_tool_bar, free_frame_tool_bar): + Update FRAME_TOOLBAR_HEIGHT. + + * nsmenu.m (free_frame_tool_bar, update_frame_tool_bar): + Add BLOCK/UNBLOCK_INPUT so asserts don't trigger. + +2010-06-30 Chong Yidong <cyd@stupidchicken.com> + + * frame.c (get_future_frame_param, Fmake_terminal_frame): Don't + check default-frame-alist. + +2010-06-30 Andreas Schwab <schwab@linux-m68k.org> + + * process.c (create_process): Avoid using invalid file descriptors. + + * callproc.c (child_setup): Avoid closing a file descriptor twice. + +2010-06-30 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (Ffont_get_system_normal_font, Ffont_get_system_font): + Improve documentation. Return font regardless of use_system_font. + (syms_of_xsettings): Improve documentation for font-use-system-font. + 2010-07-10 Chong Yidong <cyd@stupidchicken.com> * xfaces.c (realize_face): Garbage the frame if a face is removed @@ -275,7 +3881,7 @@ * nsterm.m (ns_draw_fringe_bitmap): Likewise. * fringe.c (draw_fringe_bitmap_1): Don't clip bitmap here. - Take account of bitmap offset. + Take account of bitmap offset. (draw_window_fringes): Take account of window vscroll. (update_window_fringes): Likewise. Extend top-aligned top indicator or bottom-aligned bottom indicator to adjacent rows if it doesn't fit @@ -301,13 +3907,185 @@ * xfns.c (x_create_tip_frame): * w32fns.c (x_create_tip_frame): Use it. -2010-06-30 Naohiro Aota <naota@elisp.net> (tiny change) +2010-06-17 Naohiro Aota <naota@elisp.net> (tiny change) * xftfont.c (xftfont_open): Check font width one by one also when spacing is dual. * ftfont.c (ftfont_open): Ditto. +2010-06-30 Glenn Morris <rgm@gnu.org> + + * s/sol2-6.h (INHIBIT_X11R6_XIM): Remove, handled by configure now. + + * Makefile.in (CANNOT_DUMP): Update for configure name change. + + * s/freebsd.h (USE_MMAP_FOR_BUFFERS): + * s/irix6-5.h (USE_MMAP_FOR_BUFFERS): + * s/darwin.h (SYSTEM_MALLOC): + * s/sol2-10.h (SYSTEM_MALLOC): Move to configure. + +2010-06-29 Jan Djärv <jan.h.d@swipnet.se> + + * nsfns.m: extern declare Vmenu_bar_mode, Vtool_bar_mode. + (ns_get_screen): Don't assign integer to f. + (Fx_display_color_cells): Declarations before statements. + +2010-06-28 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (x_default_font_parameter): Remove got_from_system + (Bug#6526). + + * xterm.h (gtk_widget_get_window, gtk_widget_get_mapped) + (gtk_adjustment_get_page_size, gtk_adjustment_get_upper): New + defines based on what configure finds. + + * xterm.c (XTflash): Use gtk_widget_get_window. + (xg_scroll_callback): Use gtk_adjustment_get_upper and + gtk_adjustment_get_page_size. + (handle_one_xevent): Use gtk_widget_get_mapped. + (x_term_init): Remove HAVE_GTK_MULTIDISPLAY and associated error + messages. + + * xmenu.c (create_and_show_popup_menu): Call gtk_widget_get_mapped. + + * gtkutil.h: Replace HAVE_GTK_FILE_BOTH with + HAVE_GTK_FILE_SELECTION_NEW. + + * gtkutil.c (xg_display_open, xg_display_close): Remove + HAVE_GTK_MULTIDISPLAY, it is always defined. + (xg_display_open): Return type is void. + (gtk_widget_set_has_window) + (gtk_dialog_get_action_area, gtk_dialog_get_content_area) + (gtk_widget_get_sensitive, gtk_adjustment_set_page_size) + (gtk_adjustment_set_page_increment) + (gtk_adjustment_get_step_increment): #define these if not found + by configure. + (remove_submenu): New define based on Gtk+ version. + (xg_set_cursor, xg_frame_resized, xg_event_is_for_scrollbar): Use + gtk_widget_get_window. + (xg_frame_resized, xg_update_frame_menubar): Use gtk_widget_get_mapped. + (xg_create_frame_widgets): Use gtk_widget_set_has_window. + (create_dialog): Use gtk_dialog_get_action_area and + gtk_dialog_get_content_area. + (xg_uses_old_file_dialog, xg_get_file_name): Remove HAVE_GTK_FILE_BOTH + and HAVE_GTK_FILE_CHOOSER_DIALOG_NEW. File chooser is always + available, so checking for HAVE_GTK_FILE_SELECTION_NEW is enough. + (xg_update_menubar, xg_update_submenu, xg_show_toolbar_item): Use + g_object_ref and g_object_unref. + (xg_update_menu_item, xg_tool_bar_menu_proxy): Use + gtk_widget_get_sensitive. + (xg_update_submenu): Use remove_submenu. + (xg_update_scrollbar_pos): Don't use GtkFixedChild, use child + properties instead to get old x and y position. + (xg_set_toolkit_scroll_bar_thumb): Use gtk_adjustment_get_page_size, + gtk_adjustment_get_step_increment, gtk_adjustment_set_page_size, + gtk_adjustment_set_step_increment and gtk_adjustment_set_page_increment. + (xg_get_tool_bar_widgets): New function. + (xg_tool_bar_menu_proxy, xg_show_toolbar_item) + (update_frame_tool_bar): Call xg_get_tool_bar_widgets. + (toolbar_set_orientation): New #define based on if configure + finds gtk_orientable_set_orientation. + (xg_create_tool_bar): Call toolbar_set_orientation. + (xg_make_tool_item, xg_show_toolbar_item): Call gtk_box_pack_start + instead of gtk_box_pack_start_defaults. + +2010-06-28 Chong Yidong <cyd@stupidchicken.com> + + * cmds.c (Fdelete_backward_char): Move into Lisp. + +2010-06-27 Dan Nicolaescu <dann@ics.uci.edu> + + * s/freebsd.h (BSD4_2): Remove redundant definition. + bsd-common.h defines it already. + +2010-06-27 Chong Yidong <cyd@stupidchicken.com> + + * xfns.c (Fx_create_frame): Don't consult X resouces when setting + menu-bar-lines and tool-bar-lines. Use menu-bar-mode and + tool-bar-mode, which are now set using these X resources at + startup, to determine the defaults (Bug#2249). + + * w32fns.c (Fx_create_frame): + * nsfns.m (Fx_create_frame): Likewise. + + * frame.c (Vmenu_bar_mode, Vtool_bar_mode): New vars. + +2010-06-24 Juanma Barranquero <lekktu@gmail.com> + + * gtkutil.c (xg_update_scrollbar_pos): + Avoid C99 mid-block variable declaration. + +2010-06-22 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (x_scroll_bar_create): Remove call to xg_show_scroll_bar. + + * gtkutil.h (xg_show_scroll_bar): Remove. + + * gtkutil.c (xg_update_scrollbar_pos): Show/hide scroll bar as needed + if height is less than scroll bar min size. + (xg_show_scroll_bar): Remove, show moved to xg_update_scrollbar_pos. + + * xfns.c (x_default_font_parameter): Try to open font from system + before using it (bug#6478). Rename got_from_gconf to got_from_system. + +2010-06-22 Keith Packard <keithp@keithp.com> (tiny change) + + * font.c (font_parse_fcname): Allow . for sizes like 7.5 (bug#6437). + +2010-06-20 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (try_scrolling): When scroll-conservatively is set to + most-positive-fixnum, be extra accurate when scrolling window + start, to avoid missing the cursor line. + +2010-06-19 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (try_scrolling): Compute the limit for searching point + in forward scroll from scroll_max, instead of an arbitrary limit + of 10 screen lines. See + http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00766.html + and + http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00773.html + for details. + +2010-06-16 Glenn Morris <rgm@gnu.org> + + * editfns.c (Fbyte_to_string): Pacify compiler. + +2010-06-16 Stefan Monnier <monnier@iro.umontreal.ca> + + * lread.c (read1): Phase out old-style backquotes a bit more. + +2010-06-12 Eli Zaretskii <eliz@gnu.org> + + * makefile.w32-in ($(BLD)/bidi.$(O)): Depend on biditype.h and + bidimirror.h. + + * deps.mk (bidi.o): Depend on biditype.h and bidimirror.h. + + * bidi.c (bidi_initialize): Remove explicit initialization of + bidi_type_table; include biditype.h instead. Don't support + entries whose second codepoint is zero. Initialize bidi_mirror_table. + (bidi_mirror_char): Use bidi_mirror_table. + + * biditype.h: New file. + + * bidimirror.h: New file. + + * window.c (syms_of_window): Doc fix (bug#6409). + +2010-06-12 Romain Francoise <romain@orebokech.com> + + * Makefile.in (lisp, shortlisp): Use new location of vc-hooks and + ediff-hook. + +2010-06-10 Glenn Morris <rgm@gnu.org> + + * editfns.c (Fbyte_to_string): Pacify compiler. + + * m/ibms390x.h: Rather than duplicating ibms390.h, just include it. + 2010-06-26 Andreas Schwab <schwab@linux-m68k.org> * alloc.c (Fmake_byte_code): Don't access undefined argument @@ -337,6 +4115,11 @@ * dbusbind.c (xd_append_arg): Don't "make-unibyte" the string. Check `object's type before accessing its guts. +2010-06-09 Dan Nicolaescu <dann@ics.uci.edu> + + * s/usg5-4.h: Fix previous change. + Suggested by Lawrence Mitchell <wence@gmx.li> + 2010-06-08 Andreas Schwab <schwab@linux-m68k.org> * minibuf.c (Fall_completions): Add more checks. @@ -345,39 +4128,407 @@ * minibuf.c (Fall_completions): Check COLLECTION's size (bug#6378). +2010-06-08 Dan Nicolaescu <dann@ics.uci.edu> + + * lread.c (X_OK): Remove, unused. + + * dispnew.c: Remove obsolete comment. + + Remove INCLUDED_FCNTL. + * xterm.c (INCLUDED_FCNTL): + * callproc.c (INCLUDED_FCNTL): + * alloc.c (INCLUDED_FCNTL): + * systty.h (INCLUDED_FCNTL): Remove all uses, not needed anymore. + (emacs_get_tty, emacs_set_tty): Declare unconditionally. + +2010-06-07 Martin Rudalics <rudalics@gmx.at> + + * window.c (Fselect_window): Move `record_buffer' up to the + beginning of this function, so the buffer gets recorded + even if the selected window does not change. + http://lists.gnu.org/archive/html/emacs-devel/2010-06/msg00137.html + +2010-06-07 Juanma Barranquero <lekktu@gmail.com> + + * cmds.c (Fforward_char, Fbackward_char): Fix typos in docstrings. + (Fforward_line, Fbeginning_of_line): Reflow docstrings. + +2010-06-06 Dan Nicolaescu <dann@ics.uci.edu> + + Remove BSTRING related code, all platforms define it. + * s/usg5-4.h (BSTRING): Remove definition. + * s/template.h (BSTRING): + * s/msdos.h (BSTRING): + * s/ms-w32.h (BSTRING): + * s/hpux10-20.h (BSTRING): + * s/gnu-linux.h (BSTRING): + * s/darwin.h (BSTRING): + * s/cygwin.h (BSTRING): + * s/bsd-common.h (BSTRING): + * s/aix4-2.h (BSTRING): Likewise. + * sysdep.c: Remove code depending on BSTRING not being defined. + +2010-06-05 Juanma Barranquero <lekktu@gmail.com> + + Remove obsolete macro BASE_LEADING_CODE_P. + * character.h (BASE_LEADING_CODE_P): Remove. + * regex.c [!emacs] (BASE_LEADING_CODE_P): Remove. + * buffer.c (Fset_buffer_multibyte): + * indent.c (scan_for_column, compute_motion): + * insdel.c (count_combining_before, count_combining_after): + Use LEADING_CODE_P instead of BASE_LEADING_CODE_P. + +2010-06-04 Juanma Barranquero <lekktu@gmail.com> + + Turn `directory-sep-char' into a noop. + + * lisp.h [WINDOWSNT] (Vdirectory_sep_char): Don't declare. + (DIRECTORY_SEP): Define unconditionally. + + * s/ms-w32.h (DIRECTORY_SEP): Remove. + + * emacs.c (decode_env_path): Don't check DIRECTORY_SEP, + call dostounix_filename directly. + + * fileio.c (CORRECT_DIR_SEPS): Remove. + (Ffile_name_directory, directory_file_name, Fexpand_file_name) + (Fsubstitute_in_file_name): Use dostounix_filename instead. + (file_name_as_directory): Use dostounix_filename, DIRECTORY_SEP. + (syms_of_fileio) <directory-sep-char>: Move to subr.el. + + * w32proc.c (CORRECT_DIR_SEPS): Remove. + (Fw32_short_file_name, Fw32_long_file_name): Use dostounix_filename. + 2010-06-03 Andreas Schwab <schwab@linux-m68k.org> - * process.c (conv_lisp_to_sockaddr): Fix conversion of IPv4 - address. (Bug#6346) + * process.c (conv_lisp_to_sockaddr): Fix conversion of IPv4 address. + (Bug#6346) 2010-06-03 Juanma Barranquero <lekktu@gmail.com> * ccl.c (Fccl_program_p): Fix typo in docstring. +2010-06-03 Dan Nicolaescu <dann@ics.uci.edu> + + Move UNEXEC definition to autoconf. + * s/usg5-4.h (UNEXEC): Remove, move to configure.in. + * s/sol2-10.h (UNEXEC): + * s/irix6-5.h (UNEXEC): + * s/hpux10-20.h (UNEXEC): + * s/gnu-linux.h (UNEXEC): + * s/darwin.h (UNEXEC): + * s/cygwin.h (UNEXEC): + * s/bsd-common.h (UNEXEC): + * s/aix4-2.h (UNEXEC): + * m/alpha.h (UNEXEC): Likewise. + * Makefile.in (UNEXEC_OBJ): Define using @UNEXEC_OBJ@. + +2010-06-03 Juanma Barranquero <lekktu@gmail.com> + + Remove obsolete pre-unicode2 macros. + * character.h (MULTIBYTE_FORM_LENGTH, PARSE_MULTIBYTE_SEQ): Remove. + * composite.c (composition_reseat_it): + * data.c (Faset): + * fns.c (Ffillarray): + * regex.c (re_search_2): Use BYTES_BY_CHAR_HEAD. + [!emacs] (BYTES_BY_CHAR_HEAD): Define instead of MULTIBYTE_FORM_LENGTH. + +2010-06-03 Juri Linkov <juri@jurta.org> + + * buffer.c (Fother_buffer): Add CHECK_FRAME. + (Fswitch_to_buffer): Remove unused variable `err'. + +2010-06-03 Glenn Morris <rgm@gnu.org> + + * m/template.h (NO_SOCK_SIGIO): Remove, no longer used. + + * m/hp800.h (alloca) [__NetBSD__ && __GNUC__]: No need to define it, + now that AH_BOTTOM does it. + + * m/hp800.h (HAVE_ALLOCA): + * m/ibms390x.h (HAVE_ALLOCA): Do not define, no longer needed. + + * m/ia64.h, s/gnu-linux.h, s/gnu.h, s/netbsd.h, s/usg5-4.h: + Remove NOT_C_CODE tests, it is always true now. + +2010-06-02 Dan Nicolaescu <dann@ics.uci.edu> + + Fix config.h includes. + * xsettings.c: + * xgselect.c: + * nsterm.m: + * nsselect.m: + * nsimage.m: + * nsfont.m: + * nsfns.m: + * dbusbind.c: Use #include <config.h> instead of "config.h" as all + other files do. + + * gmalloc.c: Remove BROKEN_PROTOTYPES reference, unused. + + * s/sol2-6.h: Remove obsolete comments. + + Remove unnecessary alloca.h includes. + * keymap.c: Do not include alloca.h, config.h does that. + * sysdep.c: Likewise. Do not define fwrite, not used. + +2010-06-01 Stefan Monnier <monnier@iro.umontreal.ca> + + * sysdep.c (child_setup_tty): Move the non-canonical initialization to + the HAVE_TERMIO where it belongs (bug#6149). + 2010-05-31 Stefan Monnier <monnier@iro.umontreal.ca> * keymap.c (Fwhere_is_internal): Fix handling of remapping (in thread of bug#6305). +2010-05-30 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_move_to_visually_next): Make sure the sentinel + state is always cached (bug#6306). + +2010-05-29 Eli Zaretskii <eliz@gnu.org> + + Fix cursor motion in bidi-reordered continued lines. + * xdisp.c (try_cursor_movement): Backup to non-continuation line + only after finding point's row. Fix the logic. Rewrite the loop + over continuation lines in bidi-reordered buffers. Return + CURSOR_MOVEMENT_MUST_SCROLL upon failure to find a suitable row, + rather than CURSOR_MOVEMENT_CANNOT_BE_USED. + +2010-05-28 Michael Albinus <michael.albinus@gmx.de> + + * fileio.c (Fdelete_file): Pass TRASH arg to handler call. + +2010-05-28 Kenichi Handa <handa@m17n.org> + + * font.c (font_delete_unmatched): Check Vface_ignored_fonts. + Don't sheck SPEC if it is nil. + (font_list_entities): Call font_delete_unmatched if + Vface_ignored_fonts is non-nil. (Bug#6287) + +2010-05-28 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBES): Remove $LOADLIBES, it is never set. + +2010-05-27 Chong Yidong <cyd@stupidchicken.com> + + * fileio.c (Fdelete_file): Change meaning of optional arg to mean + whether to trash. + (internal_delete_file, Frename_file): Callers changed. + (delete_by_moving_to_trash): Doc fix. + (Fdelete_directory_internal): Don't move to trash. + + * callproc.c (delete_temp_file): + * buffer.c (Fkill_buffer): Callers changed. + + * lisp.h: Update prototype. + 2010-05-27 Chong Yidong <cyd@stupidchicken.com> * xdisp.c (redisplay_window): After redisplay, check if point is still valid before setting it (Bug#6177). +2010-05-27 Glenn Morris <rgm@gnu.org> + + * Makefile.in, autodeps.mk, deps.mk, ns.mk: + Convert comments to Makefile format. + + * Makefile.in (bootstrap-clean): No more Makefile.c. + +2010-05-26 Glenn Morris <rgm@gnu.org> + + * Makefile.in (YMF_PASS_LDFLAGS): Remove. + (temacs${EXEEXT}): Use PRE_EDIT_LDFLAGS, POST_EDIT_LDFLAGS. + + * Makefile.in (NS_IMPL_GNUSTEP_INC, NS_IMPL_GNUSTEP_TEMACS_LDFLAGS): + Remove. + (TEMACS_LDFLAGS): Do not use NS_IMPL_GNUSTEP_TEMACS_LDFLAGS. + +2010-05-26 Kenichi Handa <handa@m17n.org> + + * composite.c (composition_compute_stop_pos): Fix condition for + backward scanning. + +2010-05-25 Glenn Morris <rgm@gnu.org> + + * Makefile.in (@NS_IMPL_GNUSTEP_INC@, NS_IMPL_GNUSTEP_TEMACS_LDFLAGS): + Move before TEMACS_LDFLAGS. + (TEMACS_LDFLAGS): Use $NS_IMPL_GNUSTEP_TEMACS_LDFLAGS. + (temacs${EXEEXT}): Do not use $NS_IMPL_GNUSTEP_TEMACS_LDFLAGS. + + * Makefile.in (NOT_C_CODE): No longer define. + (config.h): No longer include. + + * Makefile.in (LD_SWITCH_SYSTEM_TEMACS): Move definition after some + variables it may reference. + + * Makefile.in (LD_SWITCH_SYSTEM_EXTRA): Remove. + (TEMACS_LDFLAGS): Remove LD_SWITCH_SYSTEM_EXTRA. + +2010-05-25 Kenichi Handa <handa@m17n.org> + + * dispextern.h (struct composition_it): New members rule_idx and + charpos. + + * xdisp.c (set_iterator_to_next): While scanning backward, assume + that the character positions of IT point the last character of the + current grapheme cluster. + (next_element_from_composition): Don't change character positions + of IT. + (append_composite_glyph): Set glyph->charpos to + it->cmp_it.charpos. + + * composite.c (autocmp_chars): Change the first argument to RULE, + and try composition with RULE only. + (composition_compute_stop_pos): Record the index number of the + composition rule in CMP_IT->rule_idx. + (composition_reseat_it): Call autocmp_chars repeatedly until the + correct rule of the composition is found. + (composition_update_it): Set CMP_IT->charpos. Assume the CHARPOS + is at the last character of the current grapheme cluster when + CMP_IT->reversed_p is nonzero. + +2010-05-24 Stefan Monnier <monnier@iro.umontreal.ca> + + * editfns.c (Fbyte_to_string): New function. + +2010-05-24 Stefan Monnier <monnier@iro.umontreal.ca> + + * process.c (Fmake_network_process): Set :host to nil if it's not used. + Suggested by Masatake YAMATO <yamato@redhat.com>. + +2010-05-23 Eli Zaretskii <eliz@gnu.org> + + * dispextern.h (init_iterator): Sync prototype with changed definition. + 2010-05-20 enami tsugutomo <tsugutomo.enami@jp.sony.com> * s/netbsd.h: If terminfo is found, use it in preference to termcap. (Bug#6190) [Backport from trunk] +2010-05-19 Eli Zaretskii <eliz@gnu.org> + + Redesign and reimplement bidi-aware edge positions of glyph rows. + + * dispextern.h (struct glyph_row): New members minpos and maxpos. + (MATRIX_ROW_START_CHARPOS, MATRIX_ROW_START_BYTEPOS) + (MATRIX_ROW_END_CHARPOS, MATRIX_ROW_END_BYTEPOS): Reference minpos + and maxpos members instead of start.pos and end.pos, respectively. + + * xdisp.c (display_line): Compare IT_CHARPOS with the position in + row->start.pos, rather than with MATRIX_ROW_START_CHARPOS. + (cursor_row_p): Use row->end.pos rather than MATRIX_ROW_END_CHARPOS. + (try_window_reusing_current_matrix, try_window_id): + Use ROW->minpos rather than ROW->start.pos. + (init_from_display_pos, init_iterator): Use EMACS_INT for + character and byte positions. + (find_row_edges): Rename from find_row_end. Accept additional + arguments for minimum and maximum buffer positions seen by + display_line for this row. Don't use iterator to find the + position following the maximum one; instead, increment the + position found by display_line directly. Fix logic; eol_pos + should be tested before the rest. Handle the case of characters + delivered from display vector (bug#6036). Fix tests related to + it->method. Handle the truncated_on_right_p rows. + (RECORD_MAX_MIN_POS): New macro. + (display_line): Use it to record the minimum and maximum buffer + positions for glyphs in the row being assembled. Record the + position of the newline that terminates the line. If word wrap is + in effect, restore minimum and maximum positions seen up to the + wrap point, when iterator returns to it. + (try_window_reusing_current_matrix): Give up if in bidi-reordered + row and cursor not already at point. Restore original pre-bidi + code for unidirectional buffers. + + * dispnew.c (increment_row_positions, check_matrix_invariants): + Increment and check row->start.pos and row->end.pos, in addition + to MATRIX_ROW_START_CHARPOS and MATRIX_ROW_END_CHARPOS. + + * .gdbinit (prowlims): Display row->minpos and row->maxpos. + Display truncated_on_left_p and truncated_on_right_p flags. + Formatting fixes. + (pmtxrows): Display the ordinal number of each row. Don't display + rows beyond the last one. + + * bidi.c (bidi_cache_iterator_state): Don't zero out new_paragraph: + it is not copied by bidi_copy_it. + +2010-05-22 Eli Zaretskii <eliz@gnu.org> + + * w32.c (sys_write): Break writes into chunks smaller than 32MB. + (Bug#6237) + +2010-05-22 Chong Yidong <cyd@stupidchicken.com> + + * image.c (Fimage_flush): Rename from image-refresh. + +2010-05-21 Chong Yidong <cyd@stupidchicken.com> + + * xdisp.c (redisplay_internal): Clear caches even if redisplaying + just one window. + + * image.c (Vimage_cache_eviction_delay): Decrease to 300. + (clear_image_cache): If the number of cached images is unusually + large, decrease the cache eviction delay (Bug#6230). + +2010-05-21 Glenn Morris <rgm@gnu.org> + + * Makefile.in (${ns_appdir}, ${ns_appbindir}Emacs, ns-app): + Move these rules to ns.mk. + * ns.mk: New file. + + * Makefile.in (../src/$(OLDXMENU), $(OLDXMENU)): Always define rules. + + * Makefile.in (CANNOT_DUMP): New, set by configure. + (emacs${EXEEXT}, bootstrap-emacs${EXEEXT}): Use $CANNOT_DUMP. + +2010-05-20 Juri Linkov <juri@jurta.org> + + * fileio.c (Fdelete_file): Change interative spec to use + `read-file-name' like in `find-file-read-args' where the default + value is `default-directory' instead of `buffer-file-name'. + http://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00533.html + 2010-05-20 Kevin Ryde <user42@zip.com.au> * keyboard.c (Vlast_command, Vkeyboard_translate_table) (Voverriding_terminal_local_map, Vsystem_key_alist) (Vlocal_function_key_map): Fix manual link in docstring (Bug#6224). -2010-05-19 Stefan Monnier <monnier@iro.umontreal.ca> +2010-05-20 Glenn Morris <rgm@gnu.org> - * editfns.c (Fbyte_to_string): New function. + * Makefile.in (DEPDIR): New constant. + (DEPFLAGS): Set with configure, not cpp. + (MKDEPDIR): New, set by configure. + (.c.o, .m.o, ecrt0.o): Use $MKDEPDIR. + (clean): Use $DEPDIR. + (deps_frag): Include from configure. + Move static/dynamic dependency stuff to deps.mk/autodeps.mk. + * deps.mk, autodeps.mk: New files, extracted from Makefile.in. + + * bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix + reallocation of the cache. (Bug#6210) + +2010-05-19 Glenn Morris <rgm@gnu.org> + + * s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp. + + * Makefile.in (LD, YMF_PASS_LDFLAGS): Set with configure, not cpp. + (GNULIB_VAR): Remove. + (LIBES): Use LIB_GCC instead of GNULIB_VAR. + + * m/ibms390x.h (LINKER): + * m/macppc.h (LINKER) [GNU_LINUX]: + * s/aix4-2.h (ORDINARY_LINK): + * s/cygwin.h (LINKER): + * s/darwin.h (ORDINARY_LINK): + * s/gnu.h (ORDINARY_LINK): + * s/netbsd.h (LINKER): + * s/usg5-4.h (ORDINARY_LINK): + Move to configure. + + * s/aix4-2.h (LINKER): Remove; this file sets ORDINARY_LINK. 2010-05-18 Chong Yidong <cyd@stupidchicken.com> @@ -385,24 +4536,260 @@ prevent stack overflow if number of arguments is too large (Bug#6214). -2010-05-11 Eli Zaretskii <eliz@gnu.org> +2010-05-18 Juanma Barranquero <lekktu@gmail.com> - * makefile.w32-in ($(BLD)/w32fns.$(O)): Depend on $(SRC)/w32.h. + * charset.c (load_charset_map_from_file): Don't call close after fclose. - * w32fns.c: Include w32.h. - (Fw32_shell_execute): Decode the error message before passing it - to `error'. (Bug#6126) +2010-05-18 Glenn Morris <rgm@gnu.org> + + * s/gnu-linux.h: Combine two conditionals. + + * Makefile.in (otherobj): Include $(VMLIMIT_OBJ) separately from + $(POST_ALLOC_OBJ). + + * Makefile.in (RALLOC_OBJ): New, set by configure. + (rallocobj): Replace with the previous variable. + (otherobj): Use $RALLOC_OBJ. + + * s/gnu.h (REL_ALLOC) [DOUG_LEA_MALLOC]: + * s/gnu-linux.h (REL_ALLOC) [DOUG_LEA_MALLOC]: Move undef to configure. + + * Makefile.in (GMALLOC_OBJ, VMLIMIT_OBJ): New, set by configure. + (gmallocobj, vmlimitobj): Replace with previous two variables. + (otherobj): Use $GMALLOC_OBJ, $VMLIMIT_OBJ. + +2010-05-17 Glenn Morris <rgm@gnu.org> + + * Makefile.in (OLDXMENU_DEPS): New, set by configure. + (stamp-oldxmenu): Use $OLDXMENU_DEPS. + +2010-05-16 Glenn Morris <rgm@gnu.org> + + * Makefile.in (${ns_appbindir}Emacs, ns-app): Always define these rules. + + * Makefile.in (clean): Get rid of HAVE_NS conditional. + + * Makefile.in (ns_appdir, ns_appbindir): Now configure adds the + trailing "/". + + * Makefile.in (TEMACS_LDFLAGS2): New, set by configure. + (temacs${EXEEXT}): Combine the NS_IMPL_GNUSTEP case with the default. + + * Makefile.in (GNUSTEP_SYSTEM_LIBRARIES): Remove, unused. + (NS_IMPL_GNUSTEP_TEMACS_LDFLAGS): New, set by configure. + (LD) [NS_IMPL_GNUSTEP]: Set to $(CC) -rdynamic. + (temacs${EXEEXT}): Remove $LOCALCPP, never defined or referenced. + Make most of the NS_IMPL_GNUSTEP case the same as the default case. + + * Makefile.in (temacs${EXEEXT}) [!NS_IMPL_GNUSTEP]: + Remove ${STARTFLAGS}, nothing ever sets it. + +2010-05-16 Dan Nicolaescu <dann@ics.uci.edu> + + * m/ia64.h (UNEXEC): Remove, set in s/*.h. + +2010-05-16 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBX_BASE): Always define. + + * Makefile.in (LIBX_OTHER): Move out of cpp section. + + * Makefile.in (LIBXT): Always define. + +2010-05-15 Glenn Morris <rgm@gnu.org> + + * Makefile.in (OLDXMENU, LIBXMENU, LIBX_OTHER): Always define. + + * Makefile.in (FONT_DRIVERS): Remove, replace with $FONT_OBJ. + (obj, SOME_MACHINE_OBJECTS): Use $FONT_OBJ. + +2010-05-15 Ken Raeburn <raeburn@raeburn.org> + + * lisp.h (XFLOAT_DATA): Use "0?x:x" to generate an rvalue. (Bug#5916) + (LISP_MAKE_RVALUE) [!USE_LISP_UNION_TYPE && !__GNUC__]: Likewise. + + * emacs.c (main): Initialize initial-environment and + process-environment before generating from env, not after. + + Handle --version reasonably in CANNOT_DUMP configuration. + * emacs.c (emacs_version, emacs_copyright): New string variables. + (Vemacs_version, Vemacs_copyright): New Lisp_Object variables. + (syms_of_emacs): Defvar them, and initialize them from the C + string variables. + (main): If initialization hasn't been done, print initial version + info from the C strings, instead of starting an interactive session. + +2010-05-15 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_paragraph_init): Don't leave alone garbage values + of bidi_it->paragraph_dir. Call bidi_initialize if needed. + (bidi_paragraph_init): Remove redundant assertion that we are at + the beginning of a line after call to bidi_find_paragraph_start. + + * xdisp.c (Fcurrent_bidi_paragraph_direction): New function. + (syms_of_xdisp): Defsubr it. + + * cmds.c (Fforward_char, Fbackward_char): Doc fix. + + * Makefile.in: Fix MSDOS-related comments. + +2010-05-15 Glenn Morris <rgm@gnu.org> + + * Makefile.in (OLDXMENU_TARGET): New, set by configure. + (really-lwlib, really-oldXMenu): Always define. + ($OLDXMENU): Depend on $OLDXMENU_TARGET. + + * Makefile.in: Simplify cpp conditional. + + * Makefile.in (${ns_appdir}): Simplify using umask. + + * Makefile.in (${ns_appdir}): Remove references to CVS-related files. + +2010-05-14 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c (specbind): Remove left-over duplicate test. + Disallow let-binding frame-local vars. Add comment. + +2010-05-14 Eli Zaretskii <eliz@gnu.org> + + Make the cache of bidi iterator states dynamically allocated. + * bidi.c (bidi_cache_shrink): New function. + (bidi_init_it): Call it. + (bidi_cache_iterator_state): Enlarge the cache if needed. + + * bidi.c (bidi_move_to_visually_next): Rename from + bidi_get_next_char_visually. All callers changed. + +2010-05-14 Kenichi Handa <handa@m17n.org> + + * dispextern.h (struct composition_it): New member reversed_p. + + * composite.c (composition_compute_stop_pos): Search backward if + ENDPOS < CHARPOS. + (composition_reseat_it): Handle the case that ENDPOS < CHARPOS. + Set CMP_IT->reversed_p. + (composition_update_it): Pay attention to CMP_IT->reversed_p. + + * xdisp.c (set_iterator_to_next): + Call composition_compute_stop_pos with negative ENDPOS if we are + scanning backward. Call composition_compute_stop_pos if scan + direction is changed. + (next_element_from_buffer): Call composition_compute_stop_pos with + negative ENDPOS if we are scanning backward. + (next_element_from_composition): Pay attention to + IT->cmp_it.reversed_p. + +2010-05-14 Kenichi Handa <handa@m17n.org> + + * font.c (font_range): Return the range for the font found at first. + +2010-05-14 Glenn Morris <rgm@gnu.org> + + * Makefile.in (ns_appdir, ns_appbindir, ns_appsrc): Always define. + + * Makefile.in (mktime, X11, register): Move undefs to configure. + + * Makefile.in (MSDOS_OBJ): Default to empty, let msdos scripts set it. + (MSDOS_X_OBJ): New variable. + (MSDOS_SUPPORT_REAL): New constant. + (MSDOS_SUPPORT): Set as a variable, not with cpp. + (obj): Use MSDOS_X_OBJ. + (lisp): Use MSDOS_SUPPORT as a variable. + + * Makefile.in (REAL_MOUSE_SUPPORT): New constant. + (GPM_MOUSE_SUPPORT): Now it's a constant. + (MOUSE_SUPPORT, TOOLTIP_SUPPORT, WINDOW_SUPPORT): Set with configure, + not cpp. + + * Makefile.in (@NS_IMPL_GNUSTEP_INC@): Use in place of #ifdef. + (ns_appresdir): Remove, unused. + + * Makefile.in (SHELL): Move outside cpp section. + + * s/netbsd.h (AMPERSAND_FULL_NAME): Remove (defined in AH_BOTTOM). + +2010-05-13 Glenn Morris <rgm@gnu.org> + + * Makefile.in (FONT_DRIVERS): Place with other HAVE_X_WINDOWS stuff. + (TOOLTIP_SUPPORT): Place with other HAVE_WINDOW_SYSTEM stuff. + + * Makefile.in (FONT_DRIVERS): If HAVE_X_WINDOWS is defined, + HAVE_WINDOW_SYSTEM must be too. + + * Makefile.in (WINNT_SUPPORT): Remove, nt build does not use this file. + (lisp): Remove WINNT_SUPPORT. + + * Makefile.in (OLDXMENU, LIBXMENU) [!HAVE_MENUS]: + Let configure set these variables (to empty) in this case as well. + + * Makefile.in (LD_SWITCH_X_SITE): Define as a variable, not via cpp. + (LIBX_BASE): Use $LD_SWITCH_X_SITE. + + * Makefile.in (C_SWITCH_X_SYSTEM, C_SWITCH_X_SITE, LIB_STANDARD) + (LIB_MATH, FONTCONFIG_CFLAGS, FONTCONFIG_LIBS, FREETYPE_CFLAGS) + (FREETYPE_LIBS, LIBOTF_CFLAGS, LIBOTF_LIBS, M17N_FLT_CFLAGS) + (M17N_FLT_LIBS, GNU_OBJC_CFLAGS, GNUSTEP_SYSTEM_LIBRARIES, LIBGPM) + (LIBRESOLV, UNEXEC_OBJ): For clarity, define variables to hold + the values output by configure. + (ALL_CFLAGS, obj, LIBES, temacs${EXEEXT}): Use the above variables. + +2010-05-12 Glenn Morris <rgm@gnu.org> + + * Makefile.in (YMF_PASS_LDFLAGS, LD, LINKER): Simplify the logic. + (LINKER_WAS_SPECIFIED): Remove. + + * Makefile.in (LIB_GCC): Set using configure, not cpp. + (GNULIB_VAR) [!ORDINARY_LINK]: Always set to $LIB_GCC. + * m/arm.h (LIB_GCC) [GNU_LINUX]: + * s/cygwin.h (LIB_GCC): + * s/freebsd.h (LIB_GCC): + * s/gnu-linux.h (LIB_GCC): + * s/msdos.h (LIB_GCC): + * s/netbsd.h (LIB_GCC): + Move to configure. 2010-05-11 Karel Klic <kklic@redhat.com> * ftfont.c: Fix incorrect parentheses of #if condition for definining M17N_FLT_USE_NEW_FEATURE. -2010-05-07 Chong Yidong <cyd@stupidchicken.com> +2010-05-11 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBS_SYSTEM) [MSDOS]: Do not reset. + * s/msdos.h (MSDOS_LIBS_SYSTEM): Remove. + +2010-05-10 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (init_iterator): Don't turn on bidi reordering in + unibyte buffers. See + http://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00263.html. + +2010-05-10 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBS_SYSTEM): Set using configure, not cpp. + (LIBS_SYSTEM) [MSDOS]: Reset with MSDOS_LIBS_SYSTEM. + (LIBES): Use LIBS_SYSTEM as a variable. + * s/msdos.h (LIBS_SYSTEM): Rename to MSDOS_LIBS_SYSTEM. Always define. + * s/aix4-2.h (LIBS_SYSTEM): + * s/freebsd.h (LIBS_SYSTEM): + * s/hpux10-20.h (LIBS_SYSTEM): + * s/sol2-6.h (LIBS_SYSTEM): + * s/unixware.h (LIBS_SYSTEM): + Move to configure. + + * s/aix4-2.h (MAIL_USE_LOCKF): + * s/bsd-common.h (MAIL_USE_FLOCK): + * s/darwin.h (MAIL_USE_FLOCK): + * s/gnu-linux.h (MAIL_USE_FLOCK): + * s/irix6-5.h (MAIL_USE_FLOCK): + * s/template.h (MAIL_USE_FLOCK): + Move to configure. + +2010-05-08 Chong Yidong <cyd@stupidchicken.com> * Version 23.2 released. -2010-04-30 Andreas Schwab <schwab@linux-m68k.org> +2010-05-08 Andreas Schwab <schwab@linux-m68k.org> * composite.c (autocmp_chars): Save point as marker before calling auto-composition-function (Bug#5984). @@ -411,7 +4798,7 @@ * fileio.c (restore_point_unwind): Remove static attribute. -2010-04-23 Kenichi Handa <handa@m17n.org> +2010-05-08 Kenichi Handa <handa@m17n.org> * ftfont.c (M17N_FLT_USE_NEW_FEATURE): Define it if we can use the new feature of libotf and m17n-flt. @@ -426,24 +4813,1119 @@ (ftfont_shape_by_flt) [M17N_FLT_USE_NEW_FEATURE]: Setup mflt_enable_new_feature and mflt_try_otf. +2010-05-08 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (Ftool_bar_get_system_style): Correct comment. + + * gtkutil.c (xg_pack_tool_bar): Change show_all to show for handle + box and toolbar (Bug #6139). + (xg_create_tool_bar): Remove comment (Bug #6139). + (xg_make_tool_item): Remove gtk_widget_show_all (Bug #6139). + (xg_show_toolbar_item): Add gtk_widget_show for weventbox (Bug #6139). + +2010-05-08 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/eval.$(O), $(BLD)/w32fns.$(O)): + Update dependencies. + +2010-05-08 Eli Zaretskii <eliz@gnu.org> + + * fringe.c (update_window_fringes): Set up truncation bitmaps for + R2L lines. + +2010-05-08 Glenn Morris <rgm@gnu.org> + + * Makefile.in (THIS_IS_MAKEFILE): Remove, unused. + + * Makefile.in (LIBS_TERMCAP): Set with configure, not cpp. + (TERMCAP_OBJ): New, set by configure, replacing termcapobj. + (termcapobj): Replace with TERMCAP_OBJ. + (otherobj): Use $TERMCAP_OBJ instead of $termcapobj. + (LIBES): Use LIBS_TERMCAP as a variable. + + * s/freebsd.h (osreldate.h): No longer include, since this file + does not use __FreeBSD_version any more. + + * s/aix4-2.h (TERMINFO): + * s/cygwin.h (TERMINFO): + * s/darwin.h (TERMINFO, LIBS_TERMCAP) [HAVE_LIBNCURSES]: + * s/freebsd.h (TERMINFO, LIBS_TERMCAP): + * s/gnu-linux.h (TERMINFO, LIBS_TERMCAP) [HAVE_LIBNCURSES]: + * s/gnu.h (TERMINFO, LIBS_TERMCAP) [HAVE_LIBNCURSES]: + * s/hpux10-20.h (TERMINFO, LIBS_TERMCAP): + * s/irix6-5.h (TERMINFO): + * s/netbsd.h (LIBS_TERMCAP): + * s/openbsd.h (TERMINFO, LIBS_TERMCAP): + * s/sol2-6.h (LIBS_TERMCAP) [!TERMINFO]: + * s/usg5-4.h (TERMINFO): + Move to configure. + +2010-05-07 Stefan Monnier <monnier@iro.umontreal.ca> + + * eval.c (unbind_to): Don't unbind a local binding into the global + binding when the local binding disappeared. Inversely, don't unbind + a global binding into a newly created local binding. + * data.c (set_internal): Make its `buf' arg into a `where' arg so we + can specify the frame to use, when applicable. Adjust callers. + +2010-05-07 Vincent Belaïche <vincent.belaiche@gmail.com> + Stefan Monnier <monnier@iro.umontreal.ca> + + * floatfns.c (Fisnan, Fcopysign, Ffrexp, Fldexp): New functions. + +2010-05-07 Eli Zaretskii <eliz@gnu.org> + + * w32fns.c: Include w32.h. + (Fw32_shell_execute): Decode the error message before passing it + to `error'. (Bug#6126) + + * msdos.c (dos_set_window_size): + * w16select.c (Fx_selection_exists_p): Use `Fsymbol_value (foo)' + instead of `XSYMBOL (foo)->value'. + +2010-05-07 Eli Zaretskii <eliz@gnu.org> + + Fix the MS-DOS build, broken by autoconfiscation. + + * Makefile.in: Don't use Make-style comments past the "start of + cpp stuff" line. + (MSDOS_OBJ): Remove xmenu.o (it is now defined by XMENU_OBJ). + + * s/msdos.h (UNEXEC): Don't define (@unexec@ in Makefile.in is + edited directly by msdos/sed1v2.inp). + +2010-05-07 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LD_SWITCH_SYSTEM): Set with configure, not cpp. + (LD_SWITCH_SYSTEM_EXTRA): New variable, set by configure. + (TEMACS_LDFLAGS): Use $LD_SWITCH_SYSTEM and $LD_SWITCH_SYSTEM_EXTRA, + move out of cpp section. + * s/freebsd.h (LD_SWITCH_SYSTEM): + * s/gnu-linux.h (LD_SWITCH_SYSTEM): + * s/netbsd.h (LD_SWITCH_SYSTEM): + * s/openbsd.h (LD_SWITCH_SYSTEM): Move to configure.in. + +2010-05-07 Dan Nicolaescu <dann@ics.uci.edu> + + Define LIB_STANDARD and START_FILES using autoconf. + * s/usg5-4.h (LIB_STANDARD): + * s/netbsd.h (START_FILES): + * s/irix6-5.h (LIB_STANDARD): + * s/hpux10-20.h (LIB_STANDARD, START_FILES): + * s/gnu-linux.h (START_FILES, LIB_STANDARD): + * s/freebsd.h (START_FILES): + * s/darwin.h (START_FILES): + * s/cygwin.h (START_FILES): + * s/aix4-2.h (LIB_STANDARD): + * m/ibmrs6000.h (START_FILES): Remove, move logic to configure.in. + * Makefile.in (STARTFILES): Rename to START_FILES, define using + autoconf, not cpp. + +2010-05-06 Dan Nicolaescu <dann@ics.uci.edu> + + Remove NEED_BSDTTY and NEED_UNISTD_H. + * s/hpux10-20.h (NEED_BSDTTY): Remove. + * s/aix4-2.h (NEED_UNISTD_H): Remove. + * systty.h: Simplify conditionals for including <sys/bsdtty.h>, + <sys/ptyio.h> and <unistd.h>. + + * emacs.c (main): Remove NO_DIR_LIBRARY conditional, unused. + + * Makefile.in (STARTFILES): Conditionally define to make the usage clear. + * s/gnu.h (START_FILES): Remove empty definition. + +2010-05-06 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (x_draw_image_relief): Move declaration of extra to beginning. + +2010-05-06 Glenn Morris <rgm@gnu.org> + + * Makefile.in (CPP, LN_S): Remove unused variables. + +2010-05-05 Stefan Monnier <monnier@iro.umontreal.ca> + + * syntax.c (Fchar_syntax): Check the arg is a character (bug#6080). + +2010-05-05 Lawrence Mitchell <wence@gmx.li> + + * m/sparc.h: Fix typo in earlier change. + +2010-05-04 Stefan Monnier <monnier@iro.umontreal.ca> + + Misc tweaks. + * eval.c (Fdefvaralias): Remove unintended nested if. + (internal_condition_case_2, internal_condition_case_n): Use ANSI type. + +2010-05-04 Bernhard Herzog <bh@intevation.de> (tiny change) + + * xsmfns.c (smc_save_yourself_CB): strlen(client_id) => strlen(cwd). + +2010-05-04 Dan Nicolaescu <dann@ics.uci.edu> + + Remove BSD_PGRPS. + * s/bsd-common.h (BSD_PGRPS): Remove undef. + * s/gnu-linux.h (BSD_PGRPS): Remove. + * term.c (dissociate_if_controlling_tty): + * sysdep.c (narrow_foreground_group, widen_foreground_group) + (init_sys_modes, reset_sys_modes): + * emacs.c (main): + * callproc.c (Fcall_process, child_setup): Remove code depending + on BSD_PGRPS. + + Remove POSIX_SIGNALS. + * s/usg5-4.h (POSIX_SIGNALS): + * s/netbsd.h (POSIX_SIGNALS): + * s/msdos.h (POSIX_SIGNALS): + * s/ms-w32.h (POSIX_SIGNALS): + * s/hpux11.h (POSIX_SIGNALS): + * s/gnu.h (POSIX_SIGNALS): + * s/gnu-linux.h (POSIX_SIGNALS): + * s/freebsd.h (POSIX_SIGNALS): + * s/darwin.h (POSIX_SIGNALS): + * s/cygwin.h (POSIX_SIGNALS): + * s/aix4-2.h (POSIX_SIGNALS): Remove definition. + * s/unixware.h: + * s/sol2-6.h: Remove comments on POSIX_SIGNALS. + * process.c (create_process): + * syssignal.h: + * sysdep.c (wait_for_termination, init_signals): + * process.c (create_process): + * msdos.c: POSIX_SIGNALS is always defined on all platforms, + remove all code that assumes the contrary. + +2010-05-04 Glenn Morris <rgm@gnu.org> + + * s/gnu-linux.h (LD_SWITCH_SYSTEM): Use LD_SWITCH_X_SITE_AUX as a shell + variable. + * s/netbsd.h (LD_SWITCH_SYSTEM_tmp): Remove. + (LD_SWITCH_SYSTEM): Use $LD_SWITCH_X_SITE_AUX_RPATH. + * s/openbsd.h (LD_SWITCH_SYSTEM_tmp): Remove. + (LD_SWITCH_SYSTEM): Use $LD_SWITCH_X_SITE_AUX_RPATH instead of + LD_SWITCH_SYSTEM_tmp. + * Makefile.in (LD_SWITCH_X_SITE_AUX, LD_SWITCH_X_SITE_AUX_RPATH): + New variables, set by configure. + + * s/aix4-2.h (LD_SWITCH_SYSTEM_TEMACS): Move to configure.in. + * s/darwin.h (HEADERPAD_EXTRA, LIBS_NSGUI): Remove. + (LD_SWITCH_SYSTEM_TEMACS): Move to configure.in. + * Makefile.in (LD_SWITCH_SYSTEM_TEMACS): New variable, set by configure. + (TEMACS_LDFLAGS): Use $LD_SWITCH_SYSTEM_TEMACS. + + * s/aix4-2.h (C_SWITCH_SYSTEM): + * m/alpha.h (C_SWITCH_MACHINE): + Move to configure.in. + * Makefile.in (C_SWITCH_MACHINE, C_SWITCH_SYSTEM): + New variables, set by configure. + (ALL_CFLAGS): Use $C_SWITCH_MACHINE and $C_SWITCH_SYSTEM in place of + $c_switch_machine and $c_switch_system. + +2010-05-04 Dan Nicolaescu <dann@ics.uci.edu> + + * s/hpux10-20.h (LIB_STANDARD): New definition. + * Makefile.in (ORDINARY_LINK): Remove setting LIB_STANDARD based + on it, not used anymore. + +2010-05-03 Chong Yidong <cyd@stupidchicken.com> + + * eval.c (internal_condition_case_n): Rename from + internal_condition_case_2. + (internal_condition_case_2): New function. + + * xdisp.c (safe_call): Use internal_condition_case_n. + + * fileio.c (Fdelete_file, internal_delete_file): New arg FORCE. + (internal_delete_file, Frename_file): Callers changed. + + * buffer.c (Fkill_buffer): + * callproc.c (delete_temp_file): Callers changed (Bug#6070). + + * lisp.h: Update prototypes. + +2010-05-03 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBX_EXTRA, LIBX_BASE): New variables. + (LIBXT_OTHER, LIBX_OTHER): New, set by configure. + (LIBXT): Set with configure, not cpp. + (LIBX): Remove. + (LIBES): Replace $LIBX with $LIBX_BASE and $LIBX_OTHER. + +2010-05-02 Dan Nicolaescu <dann@ics.uci.edu> + + * m/amdx86-64.h (START_FILES, LIB_STANDARD): Remove. + The FreeBSD is not needed, the default works, Solaris version is + not needed, and the remaining case is not supported by configure. + +2010-05-02 Jan Djärv <jan.h.d@swipnet.se> + + * xsmfns.c (CHDIR_OPT): New define. + (smc_save_yourself_CB): Add CHDIR_OPT to options to use when + restarting emacs. + + * xterm.c (x_connection_closed): Call Fkill_emacs instead of + shut_down_emacs. + + * emacs.c (USAGE1): Mention --chdir. + (main): Handle --chdir. + (standard_args): Add --chdir. + (fatal_error_signal): Call Fkill_emacs for SIGTERM and SIGHUP (Bug + #5552). + +2010-05-01 Dan Nicolaescu <dann@ics.uci.edu> + + Remove LD_SWITCH_MACHINE. + * Makefile.in (LD_SWITCH_MACHINE): Remove definition, unused. + (TEMACS_LDFLAGS): Do not use LD_SWITCH_MACHINE. + + Clean up IRIX code. + * m/iris4d.h (TERMINFO, FIRST_PTY_LETTER): Move definitions ... + * s/irix6-5.h (TERMINFO, FIRST_PTY_LETTER): ... here. + + Clean up AIX code. + * m/ibmrs6000.inp: Remove file, unused. + * m/ibmrs6000.h (IBMR2AIX): Remove, unused. + (LD_SWITCH_MACHINE): Rename to LD_SWITCH_SYSTEM_TEMACS, and move + definition ... + * s/aix4-2.h (LD_SWITCH_SYSTEM_TEMACS): ... here. + + * sysdep.c (child_setup_tty, init_sys_modes): Remove !IBMR2AIX code, + unused. + +2010-05-01 Eli Zaretskii <eliz@gnu.org> + + Emulate POSIX_SIGNALS on MS-Windows. + + * s/ms-w32.h (POSIX_SIGNALS, struct sigaction, SIG_BLOCK) + (SIG_SETMASK, SIG_UNBLOCK): Define. + + * sysdep.c (sys_signal) [WINDOWSNT]: #ifdef away. + (wait_for_termination) [WINDOWSNT]: Move MS-Windows specific code + from non-POSIX_SIGNALS section to POSIX_SIGNALS section. + + * w32.c (sigemptyset, sigaddset, sigfillset, sigprocmask): + New stubs. + + Miscellaneous fixes of bidi display. + + * xdisp.c (find_row_end): New function, refactored from display_line. + (display_line): Use it. + (extend_face_to_end_of_line): In almost-filled rows, extend only + if the row is R2L and not continued. + (display_line): Fix prepending of truncation glyphs to R2L rows. + Preserve overlay and string info in row->end. + (insert_left_trunc_glyphs): Support addition of left truncation + glyphs to R2L rows. + (set_cursor_from_row): Don't place cursor on the vertical border + glyph between adjacent windows. Fix a crash when a display string + is continued to the next line. Don't return zero if cursor was + found by `cursor' property of a display string. + (try_cursor_movement): Don't assume that row->end == (row+1)->start, + test for that explicitly. + +2010-05-01 Glenn Morris <rgm@gnu.org> + + * Makefile.in (gmallocobj, rallocobj, vmlimitobj): Initialize to null, + for clarity. + (OTHER_OBJ): Remove. + (PRE_ALLOC_OBJ, POST_ALLOC_OBJ): New, set by configure. + (otherobj): Use PRE_ALLOC_OBJ, POST_ALLOC_OBJ rather than OTHER_OBJ. + +2010-05-01 Karel Klíč <kklic@redhat.com> + + * fileio.c (Ffile_selinux_context): Context functions may return null. + +2010-04-30 Dan Nicolaescu <dann@ics.uci.edu> + + * s/gnu.h (POSIX_SIGNALS, START_FILES): New definitions. + +2010-04-30 Glenn Morris <rgm@gnu.org> + + * Makefile.in (vmlimitobj) [!SYSTEM_MALLOC]: New variable. (Bug#6065) + (OTHER_OBJ): Define as a separate variable, for clarity. + +2010-04-30 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c: include limits.h and update file comment. + +2010-04-30 Glenn Morris <rgm@gnu.org> + + * Makefile.in (OLDXMENU, LIBXMENU) [HAVE_MENUS]: + Set with configure, not cpp. + (LIBW): Remove, replace with $TOOLKIT_LIBW. + + * Makefile.in (mallocobj): Remove. + (otherobj): Simplify using @OTHER_OBJ@. + + * Makefile.in (dispnew.o, frame.o, fringe.o, font.o, fontset.o) + (keyboard.o, window.o, xdisp.o, xfaces.o, menu.o): + Don't bother making nsgui.h dependency platform-specific. + + * Makefile.in (nsfns.o): Remove duplicate nsgui.h dependency. + +2010-04-29 Stefan Monnier <monnier@iro.umontreal.ca> + + * process.c (read_process_output, exec_sentinel): Don't burp if the + sentinel/filter kills the current buffer (bug#6060). + + Fix wrong-docstring problem introduced with hash-consing. (Bug#6008) + * eval.c (Fautoload): Set doc to a unique number rather than to 0. + Remove unused var `args'. + * lisp.h (XSETCARFASTINT, XSETCDRFASTINT): Remove. + (LOADHIST_ATTACH): Wrap with do...while to avoid surprises for callers. + * doc.c (store_function_docstring): Use XSETCAR. + +2010-04-28 Glenn Morris <rgm@gnu.org> + + * Makefile.in (BASE_WINDOW_SUPPORT, X_WINDOW_SUPPORT): New variables. + (WINDOW_SUPPORT) [HAVE_WINDOW_SYSTEM]: Use them. + + * Makefile.in (CYGWIN_OBJ): Set with configure, not cpp. + + * Makefile.in (GPM_MOUSE_SUPPORT): New, set by configure. + (MOUSE_SUPPORT) [!HAVE_MOUSE]: Use $GPM_MOUSE_SUPPORT. + + * Makefile.in (FONT_OBJ): New, set by configure. + (FONT_DRIVERS): Use $FONT_OBJ. + + * Makefile.in (LIBXMU): Set with configure, not cpp. + * s/aix4-2.h (LIBXMU): + * s/hpux10-20.h (LIBXMU): + Remove definition, now set in configure. + + * Makefile.in (NS_OBJ, NS_SUPPORT): Set with configure, not cpp. + + * m/amdx86-64.h [i386]: Move this test to configure.in. + +2010-04-27 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBXTR6): Set with configure, not cpp. + * s/unixware.h (NEED_LIBW): Remove definition. + + * Makefile.in (LUCID_LIBW, MOTIF_LIBW): Remove, replacing by... + (TOOLKIT_LIBW): New, set by configure. + (@X_TOOLKIT_TYPE@): No longer define it. + + * Makefile.in (LIBXP): Remove, since included in MOTIF_LIBW. + (MOTIF_LIBW): Set with configure, not cpp. + * s/aix4-2.h (LIB_MOTIF): + * s/gnu-linux.h (LIB_MOTIF): + * s/unixware.h (LIB_MOTIF): Move to configure.in. + +2010-04-27 Dan Nicolaescu <dann@ics.uci.edu> + + Reduce CPP usage. + * Makefile.in (LIB_X11_LIB): Remove, inline in the only user. + (obj): Use autoconf for unexec instead of cpp. + (C_SWITCH_SYSTEM, C_SWITCH_MACHINE, C_SWITCH_X_SITE): Remove + definitions and undefs. Inline definitions in the only user. + (ALL_CFLAGS): Substitute C_SWITCH_X_SYSTEM using autoconf. + +2010-04-27 Glenn Morris <rgm@gnu.org> + + * m/amdx86-64.h (START_FILES, LIB_STANDARD): Change the logic around, + since the defaults (set by the system file) are fine in most cases. + [GNU_LINUX, __OpenBSD__, __NetBSD__, __APPLE__]: Remove sections. + * m/ibms390x.h (START_FILES, LIB_STANDARD): + * m/macppc.h (START_FILES, LIB_STANDARD) [GNU_LINUX]: + * m/sparc.h (START_FILES, LIB_STANDARD) [__linux__]: + Remove definitions, since they are set correctly in s/gnu-linux.h. + * s/freebsd.h (START_FILES, LIB_STANDARD): + * s/gnu-linux.h (START_FILES, LIB_STANDARD): + * s/hpux10-20.h (START_FILES): + * s/netbsd.h (START_FILES, LIB_STANDARD, START_FILES_1, END_FILES_1): + Use $CRT_DIR in place of fixed /usr/lib, /lib directories. + + * Makefile.in (LIBXP, LUCID_LIBW, WIDGET_OBJ): Set via configure. + (MOTIF_LIBW): Use $LIBXP. + (otherobj): Use $WIDGET_OBJ. + +2010-04-26 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (LIBS_MACHINE): Remove, unused. + + Use autoconf instead of cpp for LIB_MATH. + * s/darwin.h (LIB_MATH): Do not define here, move to configure. + * s/cygwin.h (LIB_MATH): Likewise. + * Makefile.in (LIB_MATH): Do not define with cpp. + (LIBES): Use autoconf for LIB_MATH. + +2010-04-26 Kenichi Handa <handa@m17n.org> + + * composite.c (Ffind_composition_internal): Fix the return value + for an automatic composition. + +2010-04-25 Dan Nicolaescu <dann@ics.uci.edu> + + Remove all NO_ARG_ARRAY uses. + * fns.c (concat2, concat3, nconc2): + * eval.c (apply1, call1, call2, call3, call4, call5, call6) + (call7): Remove NO_ARG_ARRAY usage, assume it's always true. + * m/xtensa.h (NO_ARG_ARRAY): + * m/template.h (NO_ARG_ARRAY): + * m/sparc.h (NO_ARG_ARRAY): + * m/sh3.h (NO_ARG_ARRAY): + * m/mips.h (NO_ARG_ARRAY): + * m/macppc.h (NO_ARG_ARRAY): + * m/iris4d.h (NO_ARG_ARRAY): + * m/intel386.h (NO_ARG_ARRAY): + * m/ibms390x.h (NO_ARG_ARRAY): + * m/ibms390.h (NO_ARG_ARRAY): + * m/ibmrs6000.h (NO_ARG_ARRAY): + * m/ia64.h (NO_ARG_ARRAY): + * m/hp800.h (NO_ARG_ARRAY): + * m/arm.h (NO_ARG_ARRAY): + * m/amdx86-64.h (NO_ARG_ARRAY): + * m/alpha.h (NO_ARG_ARRAY): Remove definition. + +2010-04-25 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (display_line): Don't assume 2nd call to + get_next_display_element cannot return zero. (Bug#6030) + (iterate_out_of_display_property): New function, body from pop_it. + (pop_it): Use it. + +2010-04-24 Glenn Morris <rgm@gnu.org> + + * m/amdx86-64.h (START_FILES, LIB_STANDARD) [__OpenBSD__]: + For clarity, revert to using fixed /usr/lib rather than $CRT_DIR. + (START_FILES, LIB_STANDARD) [__FreeBSD__]: Merge into the generic case, + since CRT_DIR defaults to /usr/lib. Suggested by Dan Nicolaescu. + +2010-04-24 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (display_line): Use `reseat' instead of `reseat_1', and + use `get_next_display_element' and `set_iterator_to_next' to + advance to the next character, when looking for the character that + begins the next row. + + * .gdbinit: Add a "set Fmake_symbol" line to force GDB to load the + definition of "struct Lisp_Symbol". + +2010-04-24 Glenn Morris <rgm@gnu.org> + + * Makefile.in (CRT_DIR): New variable, set by configure. + * m/amdx86-64.h, m/ibms390x.h (START_FILES, LIB_STANDARD): + Use $CRT_DIR rather than HAVE_LIB64_DIR. (Bug#5655) + +2010-04-23 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in: Remove C_SWITCH_X_MACHINE, unused. + + * s/cygwin.h (LIBS_DEBUG): Remove, unused. + + Remove redundant flags. + * s/freebsd.h (C_SWITCH_SYSTEM): + * s/hpux10-20.h (C_SWITCH_X_SYSTEM, LD_SWITCH_X_DEFAULT): + * s/netbsd.h (C_SWITCH_SYSTEM): + * s/openbsd.h (LD_SWITCH_X_DEFAULT): Remove, configure takes care + of these. + + Simplify m/intel386.h. + * m/intel386.h (CRT0_DUMMIES): Remove, inline value in the only + user: ecrt0.c. + (SOLARIS2): Remove LOAD_AVE_TYPE, LOAD_AVE_CVT, LIBS_MACHINE, unused. + (USG5_4): Move LOAD_AVE_TYPE, LOAD_AVE_CVT, FSCALE definitions to + the only user: s/unixware.h. + * ecrt0.c: Remove #ifndef static. Inline CRT0_DUMMIES definition + from m/intel386.h. + * s/unixware.h (LOAD_AVE_TYPE, LOAD_AVE_CVT, FSCALE): Definitions + moved here from m/intel386.h. + + * m/mips.h: Remove #if 0 code. + +2010-04-23 Eli Zaretskii <eliz@gnu.org> + + Fix display of composed characters from L2R scripts in bidi buffers. + * xdisp.c (set_iterator_to_next, next_element_from_composition): + After advancing IT past the composition, resync the bidi iterator + with IT's position. (Bug#5977) + +2010-04-23 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (LD_SWITCH_MACHINE_TEMACS): Remove, unused. + (TEMACS_LDFLAGS): Don't use LD_SWITCH_SYSTEM_TEMACS. + +2010-04-23 Stefan Monnier <monnier@iro.umontreal.ca> + + * gtkutil.c: Include xsettings.h for Ftool_bar_get_system_style. + +2010-04-23 Eli Zaretskii <eliz@gnu.org> + + Support `display' text properties and overlay strings in bidi buffers. + * xdisp.c (pop_it): When the stack is popped after displaying + from a string, bidi-iterate to exit from the text portion covered + by the `display' property or overlay. (Bug#5988, bug#5920) + +2010-04-23 Dan Nicolaescu <dann@ics.uci.edu> + + * m/macppc.h (LD_SWITCH_SYSTEM_TEMACS): Remove #undef. + (LD_SWITCH_MACHINE_TEMACS): Remove, configure sets nocombreloc. + + * s/netbsd.h (LD_SWITCH_SYSTEM_TEMACS): Remove, configure sets nocombreloc. + * s/openbsd.h (LD_SWITCH_SYSTEM_TEMACS): Remove. + + Simplify STARTFILES definition. + * s/hpux10-20.h (START_FILES): Explicitly define here instead of + relying on Makefile.in to define it. + * s/cygwin.h (START_FILES): Likewise. + * Makefile.in (STARTFILES): Remove conditional code, not needed anymore. + + Clean up Solaris code. + * s/sol2-6.h (LD_SWITCH_SYSTEM_TEMACS, C_SWITCH_X_SYSTEM) + (LIB_MOTIF): Remove, configure takes care of this. + (NOT_USING_MOTIF): Remove, unused. + * xrdb.c: Remove #if 0-ed #include. + (SYSV): Remove conditional for old SysV. + * sysdep.c (closedir): Remove conditional code for Solaris, + Solaris has closedir. + +2010-04-22 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (read_and_apply_settings): Check if current_font is + NULL before strcmp (Bug#6001). + +2010-04-21 Dan Nicolaescu <dann@ics.uci.edu> + + Clean up HP-UX files. + * m/hp800.h (NO_REMAP, VIRT_ADDR_VARIES, DATA_SEG_BITS) + (DATA_START, TEXT_START, LOAD_AVE_TYPE, LOAD_AVE_CVT) + (LDAV_SYMBOL, index, rindex): Move definitions only used in HP-UX ... + * s/hpux10-20.h: ... to the only user, here. + +2010-04-21 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_find_paragraph_start, bidi_at_paragraph_end): Don't + use buffer-local values of paragraph-start and paragraph-separate. + <paragraph_start_re, paragraph_separate_re>: Rename from + fallback_paragraph_start_re and fallback_paragraph_separate_re. + (Bug#5992) + +2010-04-21 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c: Qmonospace_font_name, Qtool_bar_style and + current_tool_bar_style are new. + (store_config_changed_event): Rename from store_font_changed_event. + (XSETTINGS_TOOL_BAR_STYLE): New define. + (SEEN_FONT, SEEN_TB_STYLE): New enum values. + (struct xsettings): Add font and tb_style, set xft stuff inside #ifdef + HAVE_XFT. + (something_changedCB): store_font_changed_event is now + store_config_changed_event. + (parse_settings): Rename from parse_xft_settings. Read + non-xft xsettings outside #ifdef HAVE_XFT. + (read_settings): Renamed from read_xft_settings. + (apply_xft_settings): Take current settings as parameter. Do not + call read_(xft)_settings. + (read_and_apply_settings): New function. + (xft_settings_event): Do non-xft stuff out of HAVE_XFT. Call + read_and_apply_settings if there are settings to be read. + (init_xsettings): Renamed from init_xfd_settings. + Call read_and_apply_settings unconditionally. + (xsettings_initialize): Call init_xsettings. + (Ftool_bar_get_system_style): New function. + (syms_of_xsettings): Define Qmonospace_font_name and + Qtool_bar_style. Initialize current_tool_bar_style to nil. + defsubr Stool_bar_get_system_style. Fprovide on + dynamic-setting. + Move misplaced HAVE_GCONF + + * xsettings.h (Ftool_bar_get_system_style): Declare. + + * xdisp.c: Vtool_bar_style, tool_bar_max_label_size, + Qtext, Qboth, Qboth_horiz are new. + (syms_of_xdisp): Intern Qtext, Qboth, Qboth_horiz, DEFVAR + Vtool_bar_style, tool_bar_max_label_size. + + * lisp.h: Extern declare Qtext, Qboth, Qboth_horiz. + + * keyboard.c: QClabel is new. + (parse_tool_bar_item): Take out QClabel from tool bar items. + Try to construct a label if ther is no QClabel. + (syms_of_keyboard): Intern :label as QClabel. + + * dispextern.h (tool_bar_item_idx): TOOL_BAR_ITEM_LABEL is new. + (Vtool_bar_style, tool_bar_max_label_size, DEFAULT_TOOL_BAR_LABEL_SIZE): + New. + + * Makefile.in (SOME_MACHINE_LISP): font-setting.el renamed to + dynamic-setting.el. + + * gtkutil.c (xg_tool_bar_menu_proxy): Handle label in tool bar item. + (xg_make_tool_item, xg_show_toolbar_item): New function. + (update_frame_tool_bar): Take label from TOOL_BAR_ITEM_LABEL. + Call xg_make_tool_item to make a tool bar item. + Call xg_show_toolbar_item. Use wtoolbar instead of x->toolbar_widget. + + * xterm.c (x_draw_image_relief): Take Vtool_bar_button_margin + into account for toolbars. + +2010-04-21 Jan Djärv <jan.h.d@swipnet.se> + + * data.c (make_blv): Declarations before code (Bug#5993). + +2010-04-21 Glenn Morris <rgm@gnu.org> + + * Makefile.in (DBUS_OBJ, GTK_OBJ, XMENU_OBJ, XOBJ): + Define using autoconf, not cpp. + (LIBXSM): New variable, set by autoconf. + (LIBXT): Use $LIBXSM. + +2010-04-21 Dan Nicolaescu <local_user@dannlt> + + Remove NOMULTIPLEJOBS, unused. + * s/template.h (NOMULTIPLEJOBS): + * s/msdos.h (NOMULTIPLEJOBS): Remove, unused. + + Simplify LD_SWITCH_SYSTEM_TEMACS usage. + * s/freebsd.h (LD_SWITCH_SYSTEM_TEMACS): + * s/gnu-linux.h (LD_SWITCH_SYSTEM_TEMACS): Remove, configure + detects -znocombreloc and passes it to the linker + * s/hpux10-20.h (LD_SWITCH_SYSTEM_TEMACS): Remove, empty. + +2010-04-21 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBSELINUX_LIBS): Move out of #ifdef. + +2010-04-21 Karel Klíč <kklic@redhat.com> + + * Makefile.in (LIBSELINUX_LIBS): New. + (LIBES): Add $LIBSELINUX_LIBS. + * eval.c, lisp.h (call7): New function. + * fileio.c [HAVE_LIBSELINUX]: Include selinux headers. + (Ffile_selinux_context, Fset_file_selinux_context): + New functions. + (Fcopy_file): New parameter preserve-selinux-context. + (Frename_file): Preserve selinux context when renaming by copy-file. + +2010-04-21 Juanma Barranquero <lekktu@gmail.com> + Eli Zaretskii <eliz@gnu.org> + + Don't depend on cm.c or termcap.c on Windows, use stubs. + * makefile.w32-in (OBJ1): Remove cm.$(O) and termcap.$(O). + ($(BLD)/cm.$(O), $(BLD)/termcap.$(O)): Remove. + * w32console.c (current_tty, cost): New vars; lifted from cm.c. + (evalcost, cmputc, cmcheckmagic, cmcostinit, cmgoto, Wcm_clear) + (sys_tputs, sys_tgetstr): New stubs. + * s/ms-w32.h (chcheckmagic, cmcostinit, cmgoto, cmputc, Wcm_clear) + (tputs, tgetstr): New; define to sys_*. + +2010-04-20 Juanma Barranquero <lekktu@gmail.com> + + * buffer.c (syms_of_buffer) <bidi-display-reordering>: Doc fix. + +2010-04-20 Stefan Monnier <monnier@iro.umontreal.ca> + + * data.c (Fmake_variable_buffer_local, Fmake_local_variable): + Just signal a warning rather than an error when inside a let. + (Fmake_variable_frame_local): Add the same test. + + * font.c (syms_of_font): Make the style table vars read-only. + + * buffer.h (struct buffer): Remove unused var `direction_reversed'. + * buffer.c (init_buffer_once, syms_of_buffer): Remove its initialization. + + * bidi.c (bidi_initialize): Simplify fallback_paragraph_*_re init. + +2010-04-20 Eli Zaretskii <eliz@gnu.org> + + Fix R2L paragraph display on TTY. + + * xdisp.c (unproduce_glyphs): New function. + (display_line): Use it when produced glyphs are discarded from R2L + glyph rows. + (append_composite_glyph): In R2L rows, prepend the glyph rather + than appending it. + + * term.c (append_composite_glyph): In R2L rows, prepend the glyph + rather than append it. Set up the resolved_level and bidi_type + attributes of the appended glyph. + (produce_special_glyphs): Mirror the backslash continuation + character in R2L lines. + + Implement display of R2L paragraphs in GUI sessions. + + * xdisp.c [HAVE_WINDOW_SYSTEM]: Add prototype for + append_stretch_glyph. + (set_cursor_from_row) <cursor_x>: Remove unused variable. Fix + off-by-one error in computing x at end of text in the row. + (append_stretch_glyph): In reversed row, prepend the glyph rather + than append it. Set resolved_level and bidi_type of the glyph. + (extend_face_to_end_of_line): If the row is reversed, prepend a + stretch glyph whose width is such that the rightmost glyph will be + drawn at the right margin of the window. Fix off-by-one error on + TTY frames in testing whether a line needs face extension. Fix + face extension at ZV. If this is the last glyph row, use + DEFAULT_FACE_ID, to avoid painting the rest of the window with the + region face. + (set_cursor_from_row, display_line): Use + MATRIX_ROW_CONTINUATION_LINE_P instead of testing value of + row->continuation_lines_width. + (next_element_from_buffer): Don't call bidi_paragraph_init if we + are at ZV. Fixes a crash when reseated to ZV by + try_window_reusing_current_matrix. + (display_and_set_cursor, erase_phys_cursor): Handle negative HPOS, + which happens with R2L glyph rows. Fixes a crash when inserting a + character at end of an R2L line. + (set_cursor_from_row): Don't be fooled by truncated rows: don't + treat them as having zero-width characters. Improve comments. + Don't reverse pos_before and pos_after for reversed glyph rows. + Set cursor.x to negative value when the cursor might be on the + left fringe. + (IT_OVERFLOW_NEWLINE_INTO_FRINGE): For R2L lines, consider the + left fringe, not the right one. + (notice_overwritten_cursor, draw_phys_cursor_glyph) + (erase_phys_cursor): For reversed cursor_row, support cursor on + the left fringe. + + * fringe.c (update_window_fringes): For R2L rows, swap the bitmaps + of continuation indicators on the fringes. + (draw_fringe_bitmap): For reversed glyph rows, allow cursor on the + left fringe. + + * w32term.c (w32_draw_window_cursor): For reversed glyph rows, + draw cursor on the left fringe. + + * xterm.c (x_draw_window_cursor): For reversed glyph rows, draw + cursor on the left fringe. + + * dispnew.c (update_text_area): Handle reversed desired rows when + the cursor is on the left fringe. + (set_window_cursor_after_update): Limit cursor's hpos by -1 from + below, not by 0, for when the cursor is on the left fringe. + +2010-04-20 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (xg_event_is_for_scrollbar): Check if grabbed + widget is a scrollbar. + +2010-04-20 Kenichi Handa <handa@m17n.org> + + * charset.c (char_charset): Consider Vcharset_non_preferred_head + only when the arg CHARSET_LIST is nil. + +2010-04-20 Stefan Monnier <monnier@iro.umontreal.ca> + + Make variable forwarding explicit rather the using special values. + Basically, this makes the structure of buffer-local values and object + forwarding explicit in the type of Lisp_Symbols rather than use + special Lisp_Objects for that. This tends to lead to slightly more + verbose code, but is more C-like, simpler, and makes it easier to make + sure we handled all cases, among other things by letting the compiler + help us check it. + * lisp.h (enum Lisp_Misc_Type, union Lisp_Misc): + Removing forwarding objects. + (enum Lisp_Fwd_Type, enum symbol_redirect, union Lisp_Fwd): New types. + (struct Lisp_Symbol): Make the various forms of variable-forwarding + explicit rather than hiding them inside Lisp_Object "values". + (XFWDTYPE): New macro. + (XINTFWD, XBOOLFWD, XOBJFWD, XKBOARD_OBJFWD): Redefine. + (XBUFFER_LOCAL_VALUE): Remove. + (SYMBOL_VAL, SYMBOL_ALIAS, SYMBOL_BLV, SYMBOL_FWD, SET_SYMBOL_VAL) + (SET_SYMBOL_ALIAS, SET_SYMBOL_BLV, SET_SYMBOL_FWD): New macros. + (SYMBOL_VALUE, SET_SYMBOL_VALUE): Remove. + (struct Lisp_Intfwd, struct Lisp_Boolfwd, struct Lisp_Objfwd) + (struct Lisp_Buffer_Objfwd, struct Lisp_Kboard_Objfwd): + Remove the Lisp_Misc_* header. + (struct Lisp_Buffer_Local_Value): Redefine. + (BLV_FOUND, SET_BLV_FOUND, BLV_VALUE, SET_BLV_VALUE): New macros. + (struct Lisp_Misc_Any): Add filler to get the right size. + (struct Lisp_Free): Use struct Lisp_Misc_Any rather than struct + Lisp_Intfwd. + (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL, DEFVAR_INT) + (DEFVAR_KBOARD): Allocate a forwarding object. + * data.c (do_blv_forwarding, store_blv_forwarding): New macros. + (let_shadows_global_binding_p): New function. + (union Lisp_Val_Fwd): New type. + (make_blv): New function. + (swap_in_symval_forwarding, indirect_variable, do_symval_forwarding) + (store_symval_forwarding, swap_in_global_binding, Fboundp) + (swap_in_symval_forwarding, find_symbol_value, Fset) + (let_shadows_buffer_binding_p, set_internal, default_value) + (Fset_default, Fmake_variable_buffer_local, Fmake_local_variable) + (Fkill_local_variable, Fmake_variable_frame_local) + (Flocal_variable_p, Flocal_variable_if_set_p) + (Fvariable_binding_locus): + * xdisp.c (select_frame_for_redisplay): + * lread.c (Fintern, Funintern, init_obarray, defvar_int) + (defvar_bool, defvar_lisp_nopro, defvar_lisp, defvar_kboard): + * frame.c (store_frame_param): + * eval.c (Fdefvaralias, Fuser_variable_p, specbind, unbind_to): + * bytecode.c (Fbyte_code) <varref, varset>: Adapt to the new symbol + value structure. + * buffer.c (PER_BUFFER_SYMBOL): Move from buffer.h. + (clone_per_buffer_values): Only adjust markers into the current buffer. + (reset_buffer_local_variables): PER_BUFFER_IDX is never -2. + (Fbuffer_local_value, set_buffer_internal_1) + (swap_out_buffer_local_variables): + Adapt to the new symbol value structure. + (DEFVAR_PER_BUFFER): Allocate a Lisp_Buffer_Objfwd object. + (defvar_per_buffer): Take a new arg for the fwd object. + (buffer_lisp_local_variables): Return a proper alist (different fix + for bug#4138). + * alloc.c (Fmake_symbol): Use SET_SYMBOL_VAL. + (Fgarbage_collect): Don't handle buffer_defaults specially. + (mark_object): Handle new symbol value structure rather than the old + special Lisp_Misc_* objects. + (gc_sweep) <symbols>: Free also the buffer-local-value objects. + * term.c (set_tty_color_mode): + * bidi.c (bidi_initialize): Don't access the ->value field directly. + * buffer.h (PER_BUFFER_VAR_OFFSET): Don't bother with + a buffer_local_flags. + * print.c (print_object): Get rid of impossible forwarding objects. + +2010-04-19 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_get_type, bidi_get_category) + (bidi_at_paragraph_end, bidi_resolve_weak, bidi_resolve_neutral) + (bidi_type_of_next_char, bidi_level_of_next_char): + Declare static. Use `INLINE' rather than `inline'. + 2010-04-19 Juanma Barranquero <lekktu@gmail.com> * dired.c (Ffile_attributes): Fix typo in docstring. -2010-04-13 Adrian Robert <Adrian.B.Robert@gmail.com> +2010-04-19 Adrian Robert <Adrian.B.Robert@gmail.com> * nsmenu.m (EmacsDialog-runDialogAt:): Declare ret as NSInteger (Bug#5811). -2010-04-10 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> +2010-04-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * s/darwin.h (PTY_ITERATION, PTY_NAME_SPRINTF, PTY_TTY_NAME_SPRINTF) (PTY_OPEN): New defines. Use openpty (Bug#726, Bug#5819). -2010-04-08 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> +2010-04-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * frame.h (FRAME_LINE_TO_PIXEL_Y): Add missing parenthesis. +2010-04-19 Chong Yidong <cyd@stupidchicken.com> + + * xdisp.c (prepare_menu_bars): Don't call ns_set_doc_edited for + terminal frames (Bug#5837). + +2010-04-19 Eli Zaretskii <eliz@gnu.org> + + * .gdbinit (xsubchartable): New command. + +2010-04-19 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (display_line): Don't write beyond the last glyph row in + the desired matrix. Fixes a crash in "emacs -nw" (bug#5972), see + http://lists.gnu.org/archive/html/emacs-devel/2010-04/msg00075.html + and + http://lists.gnu.org/archive/html/emacs-devel/2010-04/msg00213.html + +2010-04-18 Stefan Monnier <monnier@iro.umontreal.ca> + + * alloc.c (Fpurecopy): Hash-cons if requested. + (syms_of_alloc): Update purify-flag docstring. + +2010-04-18 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (xg_set_geometry): Set size in geometry string also. + (x_wm_set_size_hint): Set USER_POS in hint_flags (Bug#5968). + +2010-04-17 Eli Zaretskii <eliz@gnu.org> + + Fix a crash when an NSM character is inserted at BEGV. + + * bidi.c (bidi_init_it): Fix initialization of bidi_it->prev. + (bidi_resolve_weak): Don't use prev.type_after_w1 if it is + NEUTRAL_B or UNKNOWN_BT. + +2010-04-16 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (set_cursor_from_row): Don't consider possibility of + other rows with cursor unless they are different from this row and + this row is part of a continued line. (Bug#5943) + +2010-04-16 Dan Nicolaescu <dann@ics.uci.edu> + + * s/freebsd.h: Restore osreldate.h include. + Suggested by Naohiro Aota. + +2010-04-16 Jan Djärv <jan.h.d@swipnet.se> + + * xmenu.c (apply_systemfont_to_menu): *childs was incorrectly used. + +2010-04-16 Ken Brown <kbrown@cornell.edu> (tiny change) + + * s/cygwin.h: Avoid linking against static libgcc. + +2010-04-15 Juri Linkov <juri@jurta.org> + + * window.c: Add Qscroll_command. + Remove Vscroll_preserve_screen_position_commands. + (window_scroll_pixel_based, window_scroll_line_based): Check the + `scroll-command' property on the last command instead of searching + the last command in Vscroll_preserve_screen_position_commands. + (syms_of_window): Initialize and staticpro `Qscroll_command'. + Put Qscroll_command property on Qscroll_up and Qscroll_down. + (scroll-preserve-screen-position): Doc fix. + (Vscroll_preserve_screen_position_commands): Remove variable. + +2010-04-15 Dan Nicolaescu <dann@ics.uci.edu> + + * xdisp.c (message): Do not use NO_ARG_ARRAY. + +2010-04-14 Dan Nicolaescu <dann@ics.uci.edu> + + Reduce cpp use in Makefile.in. + * Makefile.in (DBUS_CFLAGS, DBUS_LIBS, GCONF_CFLAGS, GCONF_LIBS) + (LIBSOUND, CFLAGS_SOUND, RSVG_LIBS, RSVG_CFLAGS, INTERVALS_H) + (GETLOADAVG_LIBS, RUN_TEMACS): Move to the autoconf section. + (ORDINARY_LINK): Remove, defined in src/s/gnu.h. + (CRT0_COMPILE): Remove, inline it in the only user. + +2010-04-14 Juri Linkov <juri@jurta.org> + + * window.c (keys_of_window): Rebind `C-v' from `scroll-up' to + `scroll-up-command' and `M-v' from `scroll-down' to + `scroll-down-command'. + +2010-04-14 Juri Linkov <juri@jurta.org> + + * window.c (Vscroll_preserve_screen_position_commands): New variable + with the default value as the list of Qscroll_down and Qscroll_up. + (window_scroll_pixel_based, window_scroll_line_based): Search the + last command in the list Vscroll_preserve_screen_position_commands + instead of comparing with Qscroll_up and Qscroll_down. + +2010-04-13 Jan Djärv <jan.h.d@swipnet.se> + + * gtkutil.c (xg_set_geometry): Set geometry for PPosition also. + (x_wm_set_size_hint): Dont set position flags, gtk_window_parse_geometry + does that. + + * xfns.c (Fx_create_frame, x_create_tip_frame): Set default border width + to zero. + +2010-04-13 Stefan Monnier <monnier@iro.umontreal.ca> + + * term.c (init_tty): Move common text outside of #ifdef TERMINFO. + + Try to solve the problem of spurious EOF chars in long lines of text + sent to interactive subprocesses. + * sysdep.c (child_setup_tty): Do not enable ICANON any more. + (system_process_attributes): Remove unused var `ttotal'. + * process.c (send_process): Don't bother breaking long line with EOF + chars when talking to ttys any more. + (wait_reading_process_output): Output a warning when called in such + a way that it could block without being interruptible. + + Try to detect file modification within the same second. + * buffer.h (struct buffer): New field modtime_size. + * buffer.c (reset_buffer): Initialize it. + * fileio.c (Finsert_file_contents, Fwrite_region): Set it. + (Fverify_visited_file_modtime): Check it. + (Fclear_visited_file_modtime, Fset_visited_file_modtime): Clear it. + (Fset_visited_file_modtime): Set (or clear) it. + +2010-04-12 Stefan Monnier <monnier@iro.umontreal.ca> + + * process.c (status_notify): Remove unused var `ro'. + +2010-04-12 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (select_visual): Don't call error if XGetVisualInfo returns + more than one visual (Bug#5938). + +2010-04-12 Dan Nicolaescu <dann@ics.uci.edu> + + * Makefile.in (C_SWITCH_SYSTEM,C_SWITCH_MACHINE,C_SWITCH_X_SITE): + Undefine. + +2010-04-11 Dan Nicolaescu <dann@ics.uci.edu> + + Remove C_SWITCH_SYSTEM_TEMACS. + * s/darwin.h (C_SWITCH_SYSTEM_TEMACS): Remove. + (malloc, realloc, free): Use emacs, not temacs for conditional + definition. + + * Makefile.in (C_SWITCH_SYSTEM_TEMACS): Remove. + (ALL_CFLAGS): Do not use C_SWITCH_SYSTEM_TEMACS. + + Use autoconf, not cpp for some variables. + * Makefile.in (C_SWITCH_SYSTEM, C_SWITCH_MACHINE) + (C_SWITCH_X_SITE): Define using autoconf, not cpp. + (ALL_CFLAGS): Use them as make variables. + (really-lwlib, really-oldXMenu): Do not pass them. + +2010-04-11 Jan Djärv <jan.h.d@swipnet.se> + + * xmenu.c (apply_systemfont_to_dialog): New. + (create_and_show_dialog): Call apply_systemfont_to_dialog if HAVE_XFT. + +2010-04-11 Stefan Monnier <monnier@iro.umontreal.ca> + + * process.c (exec_sentinel): Preserve current-buffer. + + * process.c (read_process_output): Move the save-current-buffer to + apply to both the filter and the non-filter branches. + +2010-04-10 Dan Nicolaescu <dann@ics.uci.edu> + + * s/msdos.h (UNEXEC): New definition. + +2010-04-10 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * dispextern.h (TRY_WINDOW_CHECK_MARGINS) + (TRY_WINDOW_IGNORE_FONTS_CHANGE): New defines. + + * xdisp.c (try_window): Change arg from CHECK_MARGINS to FLAGS. + Don't abort with fonts change if TRY_WINDOW_IGNORE_FONTS_CHANGE is + set in FLAGS. Callers with non-zero CHECK_MARGINS changed to use + TRY_WINDOW_CHECK_MARGINS. + + * xfns.c (Fx_show_tip): Undo last change. Call try_window with + TRY_WINDOW_IGNORE_FONTS_CHANGE (Bug#2423). Subtract last glyph's + width only when it is for padding. + +2010-04-09 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (Fx_show_tip): Call try_window in a loop until + fonts_changed_p is zero (Bug#2423). + +2010-04-08 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (set_cursor_from_row): Don't dereference glyphs beyond + the end of TEXT_AREA. (Bug#5856) + +2010-04-08 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (XSETTINGS_FONT_NAME): Move XSETTINGS_FONT_NAME out of + HAVE_GCONF. + +2010-04-08 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_resolve_weak): Use prev.type_after_w1, instead of + prev.orig_type, for resolving type of NSM. (Bug#5858) + +2010-04-08 Jan Djärv <jan.h.d@swipnet.se> + + * xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New. + (parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that + in current_font. + (init_gconf): Read value of SYSTEM_FONT and save it in current_font. + (Ffont_get_system_normal_font, xsettings_get_system_normal_font): + New functions. + (syms_of_xsettings): Initialize current_font. + defsubr Sfont_get_system_normal_font. + + * xsettings.h (Ffont_get_system_normal_font) + (xsettings_get_system_normal_font): Declare. + + * xfns.c (extern xlwmenu_default_font): Remove. + (Fx_create_frame): Remove setting of xlwmenu_default_font, moved + to xlwmenu.c. + + * menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode + menu items in UTF-8. + + * xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID. + (apply_systemfont_to_menu): New function. + (set_frame_menubar, create_and_show_popup_menu): Call + apply_systemfont_to_menu. + 2010-04-07 Jan Djärv <jan.h.d@swipnet.se> * frame.h (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT): Don't use @@ -452,10 +5934,125 @@ * xterm.c (x_set_window_size_1): Don't add border_width/height to pixelwidth/height. -2010-04-05 Chong Yidong <cyd@stupidchicken.com> +2010-04-07 Dan Nicolaescu <dann@ics.uci.edu> - * xdisp.c (prepare_menu_bars): Don't call ns_set_doc_edited for - terminal frames (Bug#5837). + Simplify code for HP machines. + * m/hp800.h (LOAD_AVE_TYPE, LOAD_AVE_CVT, NO_REMAP): Do not define + for GNU_LINUX, not needed. + (UNEXEC, NEED_BSDTTY): Move definitions... + * s/hpux10-20.h (UNEXEC, NEED_BSDTTY): ... here. + + * m/iris4d.h (UNEXEC): Move definition ... + * s/irix6-5.h (UNEXEC): ... here. + +2010-04-04 Jan Djärv <jan.h.d@swipnet.se> + + * xfns.c (set_machine_and_pid_properties): New function. + (Fx_create_frame): Call set_machine_and_pid_properties. + +2010-04-03 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_resolve_explicit, bidi_level_of_next_char): Check + bidi_it->bytepos against ZV_BYTE instead of bidi_it->ch against + BIDI_EOB. Fixes infloop with vertical cursor motion at ZV. + + * w32fns.c (x_create_tip_frame): Copy `parms' before we modify it + in this function. (Bug#5703) + +2010-04-03 Chong Yidong <cyd@stupidchicken.com> + + * nsterm.h: Fix last change. + +2010-04-03 Dan Nicolaescu <dann@ics.uci.edu> + + * m/intel386.h (NO_REMAP): Move definition ... + * s/msdos.h (NO_REMAP): ... here. + + * m/vax.h (CRT0_DUMMIES): Remove, unused. + + * ecrt0.c: Remove MSDOS, m68k and __sparc__ conditionals, file not + used on those platforms. + +2010-04-02 Dan Nicolaescu <dann@ics.uci.edu> + + Remove extern errno declarations. + * xterm.c: + * xrdb.c: + * w32term.c: + * unexec.c: + * unexaix.c: + * sysdep.c: + * process.c: + * lread.c: + * keyboard.c: + * floatfns.c: + * filelock.c: + * fileio.c: + * emacs.c (main): + * ecrt0.c: + * dispnew.c: + * callproc.c: + * buffer.c: Remove errno extern declarations. + * s/netbsd.h (NEED_ERRNO): Remove. + +2010-04-01 Dan Nicolaescu <dann@ics.uci.edu> + + Remove all uses of LIBX11_SYSTEM. + * Makefile.in (LIBX11_SYSTEM): Remove. + * s/msdos.h (LIBX11_SYSTEM): Do not define, define LIBS_SYSTEM + instead. + +2010-04-01 Eli Zaretskii <eliz@gnu.org> + + Remove support for DJGPP v1.x (bug#5813). + + * w16select.c (__dpmi_int): Remove DJGPP v1.x compatibility. + * s/msdos.h: + * unexec.c (make_hdr, copy_text_and_data): + * sysdep.c (wait_for_termination, sys_subshell): + * msdos.c (dos_set_window_size, msdos_set_cursor_shape) + (IT_set_terminal_modes, __write, _rename, gethostname) + (gettimeofday, alarm, fork, kill, dos_ttraw, dos_ttcooked) + (run_msdos_command, abort): Remove DJGPP v1.x code and tests of + the value of __DJGPP__. + (nice, pause, sigsetmask, sigblock): Remove DJGPP v1.x + compatibility code. + * lread.c: + * gmalloc.c (memalign): + * fileio.c (Fcopy_file, check_executable, Ffile_modes): + * emacs.c (main): + * dosfns.c (init_dosfns): + * dired.c (file_name_completion_stat): Remove tests of __DJGPP__. + +2010-04-01 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (set_cursor_from_row): Fix cursor positioning when the + string with `cursor' property comes from an `after-string' + overlay. (Bug#5816) + +2010-04-01 Glenn Morris <rgm@gnu.org> + + * Makefile.in (LIBTIFF, LIBJPEG, LIBPNG, LIBGIF, LIBXPM, XFT_LIBS): + Define as Makefile variables. + (LIBX): Use above variables rather than directly using autoconf. + +2010-03-31 Dan Nicolaescu <dann@ics.uci.edu> + + Clean up BSD_SYSTEM use. + * xterm.c: + * process.c: + * emacs.c: Use HAVE_SYS_IOCTL_H instead of BSD_SYSTEM as a guard + for including <sys/ioctl.h>. + * sysdep.c (wait_without_blocking): Remove BSD_SYSTEM case, this + code is only used for MSDOS. + +2010-03-31 Juri Linkov <juri@jurta.org> + + * image.c: Add `Qextension_data'. + (syms_of_image): Initialize and staticpro `Qextension_data'. + (Fimage_metadata): Rename from `Fimage_extension_data'. + (gif_load): Put GIF extension data to the property + `Qextension_data'. 2010-03-31 Chong Yidong <cyd@stupidchicken.com> @@ -464,26 +6061,38 @@ 2010-03-31 Eli Zaretskii <eliz@gnu.org> - * w32fns.c (x_create_tip_frame): Copy `parms' before we modify it - in this function. (Bug#5703) + * xdisp.c (highlight_trailing_whitespace): Support highlight of + trailing whitespace in right-to-left rows. -2010-03-31 Chong Yidong <cyd@stupidchicken.com> +2010-03-31 Stefan Monnier <monnier@iro.umontreal.ca> - * nsterm.h: Fix last change. + Get rid of the direct_output optimizations. + * keyboard.c (nonundocount): Remove extern declaration. + (command_loop_1): Remove brittle optimisation for cheap and + common operations. + * xdisp.c (redisplay_internal): Don't bother checking + redisplay_performed_directly_p any more. + * sysdep.c (init_sys_modes): Don't call direct_output_forward_char + any more. + * dispnew.c (redisplay_performed_directly_p) + (direct_output_for_insert, direct_output_forward_char): + * dispextern.h (redisplay_performed_directly_p) + (direct_output_for_insert, direct_output_forward_char): Remove. + * cmds.c (nonundocount): Make it static. -2010-03-30 Bernhard Herzog <bh@intevation.de> (tiny change) +2010-03-31 Bernhard Herzog <bh@intevation.de> (tiny change) * menu.c (Fx_popup_menu): Use last_event_timestamp (Bug#4930). -2010-03-30 Jan Djärv <jan.h.d@swipnet.se> +2010-03-31 Jan Djärv <jan.h.d@swipnet.se> * xdisp.c (note_mouse_highlight): Don't do highlight if pointer is invisible (Bug#5766). -2010-03-29 Adrian Robert <adrian.b.robert@gmail.com> +2010-03-31 Adrian Robert <adrian.b.robert@gmail.com> - * xdisp.c (x_consider_frame_title, update_window_cursor): Remove - HAVE_NS conditionals. + * xdisp.c (x_consider_frame_title, update_window_cursor): + Remove HAVE_NS conditionals. (prepare_menu_bars) [HAVE_NS]: Call ns_set_doc_edited. * nsfns.m (x_implicitly_set_name): If frame-title-format is t, use @@ -496,16 +6105,176 @@ * nsterm.m: Remove unneeded prototype. -2010-03-28 Glenn Morris <rgm@gnu.org> +2010-03-31 Glenn Morris <rgm@gnu.org> * Makefile.in (SOME_MACHINE_OBJECTS): Ensure dbus stuff is always in the DOC file. (Bug#5336) -2010-03-24 Chong Yidong <cyd@stupidchicken.com> +2010-03-31 Chong Yidong <cyd@stupidchicken.com> * xdisp.c (pos_visible_p): Revert 2008-01-25 change (Bug#5730). -2010-03-20 Jan Djärv <jan.h.d@swipnet.se> +2010-03-31 Stefan Monnier <monnier@iro.umontreal.ca> + + * window.c (keys_of_window): Remove redundant/overridden bindings. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + * xdisp.c (BUFFER_POS_REACHED_P, move_it_in_display_line_to): + Restore original behavior when the iterator is not bidi_p. + +2010-03-30 Dan Nicolaescu <dann@ics.uci.edu> + + * xdisp.c (syms_of_xdisp): Use intern_c_string instead of intern. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + * bidi.c (bidi_cache_iterator_state): Invalidate the cache if we + are outside the range of cached character positions. + +2010-03-30 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in ($(BLD)/bidi.$(O)): Add dependency on w32gui.h. + +2010-03-30 Eli Zaretskii <eliz@gnu.org> + + Initial support for bidirectional editing. + + * Makefile.in (obj): Include bidi.o. + (bidi.o): New target. + + * makefile.w32-in (OBJ1): Add $(BLD)/bidi.$(O). + ($(BLD)/bidi.$(O)): New target. + + * bidi.c: New file. + + * buffer.h (struct buffer): New members bidi_display_reordering + and bidi_paragraph_direction. + + * buffer.c (init_buffer_once): Initialize bidi_display_reordering + and bidi_paragraph_direction. + (syms_of_buffer): Declare Lisp variables bidi-display-reordering + and bidi-paragraph-direction. + (Fbuffer_swap_text): Swap the values of + bidi_display_reordering and bidi_paragraph_direction. + + * dispextern.h (BIDI_MAXLEVEL, BIDI_AT_BASE_LEVEL): New macros. + (bidi_type_t, bidi_dir_t): New types. + (bidi_saved_info, bidi_stack, bidi_it): New structures. + (struct it): New members bidi_p, bidi_it, paragraph_embedding, + prev_stop, base_level_stop, and eol_pos. + (bidi_init_it, bidi_get_next_char_visually): New prototypes. + (IT_STACK_SIZE): Enlarge to 5. + (struct glyph_row): New member reversed_p. + <string_buffer_position>: Update prototype. + (PRODUCE_GLYPHS): Set the reversed_p flag in the iterator's + glyph_row if bidi_it.paragraph_dir == R2L. + (struct glyph): New members resolved_level and bidi_type. + + * dispnew.c (direct_output_forward_char): Give up if we need bidi + processing or buffer's direction is right-to-left. + (prepare_desired_row): Preserve the reversed_p flag. + (row_equal_p): Compare the reversed_p attributes as well. + + * xdisp.c (init_iterator): Initialize it->bidi_p. Call + bidi_init_it and set it->paragraph_embedding from the current + buffer's value of bidi_paragraph_direction. + (reseat_1): Initialize bidi_it.first_elt. + (set_iterator_to_next, next_element_from_buffer): Use the value of + paragraph_embedding to determine the paragraph direction. + (set_iterator_to_next): Under bidi reordering, call + bidi_get_next_char_visually. Call bidi_paragraph_init if the + new_paragraph flag is set in the bidi iterator. + (next_element_from_buffer): If bidi_it.first_elt is set, + initialize paragraph direction and find the first character to + display in the visual order. If reseated to a middle of a line, + prime the bidi iterator starting at the line's beginning. Handle + the situation where we overstepped stop_charpos due to + non-linearity of the bidi iteration. Likewise for when we back up + beyond the previous stop_charpos. When moving across stop_charpos, + record it in prev_stop. + (display_line): Set row->end and it->start for the next row to the + next character in logical order. Always extend reversed_p rows to + the end of line, even if they end at ZV. Copy the reversed_p flag + to the next glyph row. Keep calling set_cursor_from_row for + bidi-reordered rows even if we already have a possible candidate + for cursor position. Set row_end after all the row's glyphs have + been produced, by looping over the glyphs. Record the position + after EOL in it->eol_pos, and use it to set end_pos of the last + row produced for a continued line. + <Qright_to_left, Qleft_to_right>: New variables. + (syms_of_xdisp): Initialize and staticpro them. + (string_buffer_position_lim): New function. + (string_buffer_position): Most of code moved to + string_buffer_position_lim. Last argument and return value are + now EMACS_INT; all callers changed. + (set_cursor_from_row): Rewritten to support bidirectional text and + reversed glyph rows. + (text_outside_line_unchanged_p, try_window_id): Disable + optimizations if we are reordering bidirectional text and the + paragraph direction can be affected by the change. + (append_glyph, append_composite_glyph) + (produce_image_glyph, append_stretch_glyph): Set the + resolved_level and bidi_type members of each glyph. + (append_glyph): If the glyph row is reversed, prepend the glyph + rather than appending it. + (handle_stop_backwards): New function. + (reseat_1, pop_it, push_it): Set prev_stop and base_level_stop. + (reseat): call handle_stop_backwards to recompute prev_stop and + base_level_stop for the new position. + (handle_invisible_prop): Under bidi iteration, skip invisible text + using bidi_get_next_char_visually. If we are `reseat'ed, init the + paragraph direction. Update IT->prev_stop after skipping + invisible text. + (move_it_in_display_line_to): New variables prev_method + and prev_pos. Compare for strict equality in + BUFFER_POS_REACHED_P. + (try_cursor_movement): Examine all the candidate rows that occlude + point, to return the best match. If rows are bidi-reordered + and point moved backwards, back up to the row that is not a + continuation line, and start looking for a suitable row from + there. + + * term.c (append_glyph): Reverse glyphs by pre-pending them, + rather than appending, if the glyph_row's reversed_p flag is set. + Set the resolved_level and bidi_type members of each glyph. + + * .gdbinit (pbiditype): New command. + (pgx): Use it to display bidi level and type of the glyph. + (pitx): Display some bidi information about the iterator. + (prowlims, pmtxrows): New commands. + +2010-03-30 Dan Nicolaescu <dann@ics.uci.edu> + + Remove all uses of C_DEBUG_SWITCH and LIBS_DEBUG. + * s/usg5-4.h (LIBS_DEBUG): + * s/irix6-5.h (C_DEBUG_SWITCH): + * s/gnu-linux.h (LIBS_DEBUG): + * s/darwin.h (LIBS_DEBUG): + * s/bsd-common.h (LIBS_DEBUG): + * s/aix4-2.h (LIBS_DEBUG, C_DEBUG_SWITCH): + * m/iris4d.h (LIBS_DEBUG): + * m/hp800.h (LIBS_DEBUG): Remove definitions. + + * Makefile.in (LIBES): Remove reference to LIBS_DEBUG. + (LIBS_DEBUG): Remove definition. + +2010-03-27 Chong Yidong <cyd@stupidchicken.com> + + * process.c (Fmake_network_process): Don't apply Bug#5173 fix for + Windows. + +2010-03-25 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * process.c (Fmake_network_process): Don't call turn_on_atimers around + `connect' (Bug#5723). + +2010-03-25 Helmut Eller <eller.helmut@gmail.com> + + * process.c (Fmake_network_process): Call `select' for interrupted + `connect' rather than creating new socket (Bug#5173). + +2010-03-24 Jan Djärv <jan.h.d@swipnet.se> * frame.c (x_get_arg): Handle RES_TYPE_BOOLEAN_NUMBER (bug #5736). @@ -513,12 +6282,12 @@ * dispextern.h (resource_types): RES_TYPE_BOOLEAN_NUMBER is new. -2010-03-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> +2010-03-24 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * xfns.c (Fx_create_frame) [USE_LUCID]: Add BLOCK_INPUT around XLoadQueryFont. -2010-03-16 Kenichi Handa <handa@m17n.org> +2010-03-24 Kenichi Handa <handa@m17n.org> * coding.c (decode_coding_ccl): Fix previous change for the multibyte case. @@ -526,11 +6295,182 @@ case that the output buffer is fullfilled. (encode_coding): Setup ccl program here. -2010-03-15 Andreas Politz <politza@fh-trier.de> (tiny change) +2010-03-23 Dan Nicolaescu <dann@ics.uci.edu> + + * s/gnu-linux.h (LIBS_SYSTEM): Remove, same as default. + + Simplify LIBS_MACHINE definitions. + * m/hp800.h (LIBS_MACHINE): Remove, same as default. + * m/iris4d.h (LIBS_MACHINE): Likewise. + * m/ibmrs6000.h (LIBS_MACHINE): Rename to LIBS_SYSTEM and move ... + * s/aix4-2.h (LIBS_SYSTEM): ... here. + * s/netbsd.h: Remove commented out code. + +2010-03-22 Dan Nicolaescu <dann@ics.uci.edu> + + Remove dead code dealing with POSIX_SIGNALS. + * atimer.c (set_alarm): Remove dead code, all USG systems define + POSIX_SIGNALS. + * data.c (arith_error): Likewise. + * keyboard.c (input_available_signal, handle_user_signal) + (interrupt_signal): Likewise. + * process.c (sigchld_handler): Likewise. + (create_process): Remove if 0 code. Remove HPUX conditional when + !defined (POSIX_SIGNALS), it cannot be true. + * syssignal.h: Remove USG5_4 and USG conditionals when + !POSIX_SIGNALS, they cannot be true. + + * keyboard.c (Fset_input_interrupt_mode): Remove code depending on + NO_SOCK_SIGIO, not used anymore. + +2010-03-21 Dan Nicolaescu <dann@ics.uci.edu> + + * m/vax.h (BSD_SYSTEM, BSD4_2): Remove conditionals, we only + support vax on BSDs. + + * m/ibmrs6000.h (ORDINARY_LINK): Move definition ... + * s/aix4-2.h (ORDINARY_LINK): ... here. + +2010-03-21 Andreas Schwab <schwab@linux-m68k.org> + + * Makefile.in (abs_builddir): Define. + (bootstrap_exe): Use it. + (VPATH): Use $(srcdir) instead of @srcdir@. + +2010-03-20 Stefan Monnier <monnier@iro.umontreal.ca> + + * Makefile.in (bootstrap_exe): Use an absolute name. + +2010-03-20 Dan Nicolaescu <dann@ics.uci.edu> + + Remove support for old GNU/Linux using libc version 5. + * m/alpha.h (LINUX_SBRK_BUG): Remove definition. + * emacs.c (main): Remove code depending on LINUX_SBRK_BUG. + + Consolidate redundant definitions in s/bsd-common.h. + * s/bsd-common.h (BSD4_2, TABDLY, TAB3, HAVE_TERMIOS, NO_TERMIO) + (LIBS_DEBUG, SYSV_SYSTEM_DIR, UNEXEC, NARROWPROTO, BSD_PGRPS) + (LDAV_SYMBOL, KERNEL_FILE): Define (or undefine) here instead of + doing it in all files that include this one. + * s/gnu.h (BSD4_2, TABDLY, TAB3, HAVE_TERMIOS, NO_TERMIO) + (LIBS_DEBUG, SYSV_SYSTEM_DIR, UNEXEC, NARROWPROTO, BSD_PGRPS) + (LDAV_SYMBOL, KERNEL_FILE): Remove. + * s/freebsd.h (BSD4_2, TABDLY, TAB3, HAVE_TERMIOS, NO_TERMIO) + (LIBS_DEBUG, SYSV_SYSTEM_DIR, UNEXEC, NARROWPROTO, BSD_PGRPS) + (LDAV_SYMBOL, KERNEL_FILE): Remove. + * s/netbsd.h (BSD4_2, TABDLY, TAB3, HAVE_TERMIOS, NO_TERMIO) + (LIBS_DEBUG, SYSV_SYSTEM_DIR, UNEXEC, NARROWPROTO, BSD_PGRPS) + (LDAV_SYMBOL, KERNEL_FILE): Remove. + + Consolidate redundant definitions. + * s/usg5-4.h (sigsetmask, PTY_TTY_NAME_SPRINTF): Do not define, + it's undefined in all files that include this one. + (POSIX_SIGNALS): Define here instead of doing it in all files that + include this one. + * s/irix6-5.h (sigsetmask, PTY_TTY_NAME_SPRINTF): Do not undef. + (POSIX_SIGNALS): Do not define. + * s/sol2-6.h (sigsetmask, PTY_TTY_NAME_SPRINTF): Do not undef. + (POSIX_SIGNALS): Do not define. + * s/unixware.h (sigsetmask, PTY_TTY_NAME_SPRINTF): Do not undef. + (POSIX_SIGNALS): Do not define. + + Remove support for old UNIX System V systems. + * s/unixware.h: Add the contents of s/usg-5-4-2.h. + * s/usg-5-4-2.h: Remove. + + Remove support for Solaris on PPC and for old versions. + * s/sol2-6.h: Add the contents of s/sol-2.3.h, s/sol-2.4.h, s/sol-2.5.h. + (LD_SWITCH_SYSTEM, USE_MMAP_FOR_BUFFERS): Remove #defines/#undef + that cancel each other. + * s/sol2-3.h: + * s/sol2-4.h: + * s/sol2-5.h: Remove. + * m/ibmrs6000.h: Remove code for USG5_4, this file is only used on AIX. + (NO_REMAP): Remove, unused. + (UNEXEC): Move definition ... + * s/aix4-2.h (UNEXEC): ... here. + + * s/openbsd.h: Remove support for non-ELF and for systems that do + not support shared libraries. + * s/netbsd.h: + * s/freebsd.h: Likewise. + +2010-03-20 Dan Nicolaescu <dann@ics.uci.edu> + + Remove non-working support for lynxos 3.0. + * s/lynxos.h: Remove file. + + * unexec.c (unexec, adjust_lnnoptrs): Do not depend on + COFF_BSD_SYMBOLS, nothing defines it anymore. + +2010-03-20 Dan Nicolaescu <dann@ics.uci.edu> + + Remove obsolete uses of HAVE_SHM. + * emacs.c (standard_args): + (Fdump_emacs): + (syms_of_emacs): Remove code depending on HAVE_SHM. + + * alloc.c: Remove HAVE_SHM dependent definition. + + * Makefile.in (RUN_TEMACS): Do not depend on HAVE_SHM. + +2010-03-18 Glenn Morris <rgm@gnu.org> + + * emacs.c (USAGE4): Hard-code bug address. + (REPORT_EMACS_BUG_ADDRESS, REPORT_EMACS_BUG_PRETEST_ADDRESS): Remove. + (bug_reporting_address): Remove. + (main): Don't call bug_reporting_address. + + * Makefile.in (XFT_LIBS, LIBXPM, LIBJPEG, LIBPNG, LIBTIFF, LIBGIF) + (LIBGPM, LIBRESOLV): Set using autoconf rather than cpp. + +2010-03-15 Chong Yidong <cyd@stupidchicken.com> + + * xfns.c (Fx_create_frame): + * frame.c (Vdefault_frame_scroll_bars): Put non-GTK X scroll-bars + on left. + +2010-03-13 Andreas Politz <politza@fh-trier.de> (tiny change) * editfns.c (Fformat): Account for string precision when computing field width (Bug#5710). +2010-03-12 Chong Yidong <cyd@stupidchicken.com> + + * xfns.c (Fx_create_frame): Set default to Qright. + + * frame.c (Vdefault_frame_scroll_bars): Set default to Qright for + all window systems. + +2010-03-12 Eli Zaretskii <eliz@gnu.org> + + These changes remove termcap.c from the build on Posix platforms. + * Makefile.in (termcapobj): Move termcap.o from here... + (MSDOS_OBJ): ...to here. + (termcapobj) [!LIBS_TERMCAP]: Remove specialized value, as it is + now identical to when LIBS_TERMCAP is defined. + + * term.c: Remove (ifdef'ed away) inclusion of termcap.h. + + * cm.c: Remove (ifdef'ed away) inclusion of termcap.h. + + * config.in: Regenerated. (See top-level ChangeLog.) + +2010-03-10 Chong Yidong <cyd@stupidchicken.com> + + * Branch for 23.2. + +2010-03-10 Stefan Monnier <monnier@iro.umontreal.ca> + + Cleanup setup of gl_state in various parts of the code. + * syntax.h (SETUP_BUFFER_SYNTAX_TABLE): New macro. + (SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT): + * syntax.c (find_defun_start, Fchar_syntax, Fmatching_paren) + (skip_chars): + * regex.c (regex_compile): Use it. + (re_compile_pattern): Don't set gl_state.current_syntax_table since + it's now set in regex_compile when/if we need it. + 2010-03-05 Stefan Monnier <monnier@iro.umontreal.ca> Make it possible to C-g in a tight bytecode loop again (bug#5680). @@ -1218,7 +7158,7 @@ (scroll_end_callback): Remove. (xg_create_scroll_bar): Add parameter end_callback, bind it to button-release-event. Replace value-changed event with change-value, - bug #5177, + bug #5177. (xg_event_is_for_scrollbar): Only return true if button is less than 4, bug #5177. @@ -1239,7 +7179,7 @@ 2009-12-12 Eli Zaretskii <eliz@gnu.org> - * dispextern.h (struct text_pos): Use EMACS_INT; + * dispextern.h (struct text_pos): Use EMACS_INT. (struct glyph): Use EMACS_INT for charpos. (struct it): Use EMACS_INT for stop_charpos, end_charpos, region_beg_charpos, region_end_charpos, @@ -1774,7 +7714,7 @@ (store_symval_forwarding): Take into account the fact that Ints can now have more than one tag. * buffer.c (syms_of_buffer): Use LISP_INT_TAG. - buffer_slot_type_mismatch): + (buffer_slot_type_mismatch): * xfaces.c (face_attr_equal_p): * print.c (print_object): * alloc.c (mark_maybe_object, mark_object, survives_gc_p): @@ -2586,7 +8526,7 @@ * xterm.h: Rename x_non_menubar_window_to_frame to x_menubar_window_to_frame. - * xterm.c: Remove declarations also in xterm.h + * xterm.c: Remove declarations also in xterm.h. (XTmouse_position): Do not return valid positions for clicks in the menubar and the toolbar for Gtk+. @@ -3146,7 +9086,7 @@ 2009-07-04 Eli Zaretskii <eliz@gnu.org> Emulation of `getloadavg' on MS-Windows. - * w32.c: Include float.h + * w32.c: Include float.h. (g_b_init_get_native_system_info, g_b_init_get_system_times) (GetNativeSystemInfo_Proc, GetSystemTimes_Proc): Declare. (get_native_system_info, get_system_times): New functions. @@ -7738,7 +13678,7 @@ <after-change-functions>: Reflow docstrings. 2008-08-04 Adrian Robert <Adrian.B.Robert@gmail.com> - Ken Raeburn <raeburn@gnu.org> + Ken Raeburn <raeburn@gnu.org> Dock menu customization, based on a patch by Ken Raeburn, plus some other fixes. @@ -8803,10 +14743,10 @@ batch-compiling for bootstrap). 2008-07-15 Chris Hall <chris@web.workinglinux.com> (tiny change) - YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> - (make_initial_frame): Call init_frame_faces(f) in CANNOT_DUMP case -- - fix crash due to different init order. + * frame.c (make_initial_frame): Call init_frame_faces(f) in + CANNOT_DUMP case -- fix crash due to different init order. 2008-07-15 Adrian Robert <Adrian.B.Robert@gmail.com> @@ -9003,7 +14943,7 @@ * m/macppc.h: * m/alpha.h: Use GNU_LINUX instead of LINUX. Reorganize conditionals. - * m/ibms390x.h (XINT, XUINT): Don't define, same as the default + * m/ibms390x.h (XINT, XUINT): Don't define, same as the default. (SPECIAL_EMACS_INT): * m/ia64.h (SPECIAL_EMACS_INT): * m/amdx86-64.h (SPECIAL_EMACS_INT): @@ -9092,7 +15032,7 @@ 2008-07-10 Dan Nicolaescu <dann@ics.uci.edu> * fileio.c: - * sysdep.c + * sysdep.c: * systty.h: * m/ibmrs6000.h: * m/iris4d.h: @@ -9421,7 +15361,7 @@ (USG_SHARED_LIBRARIES): Remove duplicate definition. 2008-06-26 Juanma Barranquero <lekktu@gmail.com> - Eli Zaretskii <eliz@gnu.org> + Eli Zaretskii <eliz@gnu.org> * makefile.w32-in (LOCAL_FLAGS): Don't include WINDOWSNT, DOS_NT and _UCHAR_T. @@ -9669,7 +15609,7 @@ the property of LFACE_FONT of LFACE (if any). 2008-06-21 Seiji Zenitani <zenitani@mac.com> - Ryo Yoshitake <ryo@shiftmode.net> + Ryo Yoshitake <ryo@shiftmode.net> * xterm.c (x_set_frame_alpha): Add x_catch_errors for bug#437. @@ -10190,7 +16130,7 @@ definitions from xmenu.c. Suggested by Adrian Robert. * xmenu.c: Remove platform-independent menu definitions. - (menu_items menu_items_inuse, menu_items_allocated) + (menu_items, menu_items_inuse, menu_items_allocated) (menu_items_used, menu_items_n_panes) (menu_items_submenu_depth): Move to keyboard.h. (init_menu_items, finish_menu_items, unuse_menu_items) @@ -10765,7 +16705,7 @@ * xterm.c (x_set_frame_alpha): Move declarations before statements. 2008-05-21 Seiji Zenitani <zenitani@mac.com> - Ryo Yoshitake <ryo@shiftmode.net> + Ryo Yoshitake <ryo@shiftmode.net> * frame.c (Qalpha): Add a new frame parameter `alpha'. (Vframe_alpha_lower_limit): New variable. @@ -12185,12 +18125,6 @@ Report an error when image size is invalid. Read two bytes at a time when raw images have max_color_idx above 255. -2008-04-05 Eli Zaretskii <eliz@gnu.org> - - * w32.c (readdir): If FindFirstFile/FindNextFile return in - cFileName a file name that includes `?' characters, use the 8+3 - alias in cAlternateFileName instead. - 2008-04-05 Kenichi Handa <handa@ni.aist.go.jp> * ccl.c (ccl_driver): If ccl->quit_silently is nonzero, don't @@ -15528,7 +21462,7 @@ * search.c (search_buffer): Give up BM search on case-fold-search if one of a target character has a case-equivalence of different - byte length even if that target charcter is an ASCII. + byte length even if that target character is an ASCII. (simple_search): Fix calculation of byte length of matched text. (boyer_moore): Fix handling of case-equivalent multibyte characters. @@ -17641,7 +23575,7 @@ * charset.c (charset_ordered_list_tick): New variable. (Fdefine_charset_internal): Increment charset_ordered_list_tick. (Funify_charset): New optional arg DEUNIFY. If it is non-nil, - deunify intead of unify a charset. + deunify instead of unify a charset. (string_xstring_p): Add `const' to local variables. (find_charsets_in_text): Add `const' to arguments and local variables. (encode_char): Adjust for the change of Funify_charset. Fix diff --git a/src/ChangeLog.1 b/src/ChangeLog.1 index 921123f236a..8b4a9afbc6c 100644 --- a/src/ChangeLog.1 +++ b/src/ChangeLog.1 @@ -1187,7 +1187,7 @@ prompt. (various): Pass window being displayed as arg to vmotion. (various): Compute starting-hpos arg to compute_motion - using minibuf_prompt_width if in minibuf starting at top. + using minibuf_prompt_width if in minibuf starting at top. * window.c (Fdisplay_buffer & callers): Take second arg, non-nil means do not use selected window @@ -1645,8 +1645,8 @@ Use signal, not sigset, since we simulate signal on all system versions when nec. - * buffer.c (syms_of_buffer, init_buffer_once, - reset_buffer_local_variables): + * buffer.c (syms_of_buffer, init_buffer_once) + (reset_buffer_local_variables): Define default-abbrev-mode, and init new buffers' abbrev-mode from it. Move definition of abbrev-mode here from abbrev.c. @@ -2861,7 +2861,7 @@ * keymap.c, callint.c, minibuf.c, fns.c, commands.h: Rename MinbufLocalMap to Vminibuffer_local_map, etc. Rename minibuf-local-{,-ns,-completion,must-match}map, - and DefLispVar them (document even!). + and DefLispVar them (document even!). => New lisp variables minibuffer-local-map, minibuffer-local-ns-map, minibuffer-local-completion-map, minibuffer-local-must-match-map. diff --git a/src/ChangeLog.10 b/src/ChangeLog.10 index 39b70d9b199..393c7bdf8dc 100644 --- a/src/ChangeLog.10 +++ b/src/ChangeLog.10 @@ -3252,7 +3252,7 @@ 2006-07-02 Kim F. Storm <storm@cua.dk> * xdisp.c (display_tool_bar_line): Skip glyphs which are too big - to ever fit the tool-bar, + to ever fit the tool-bar. (MAX_FRAME_TOOL_BAR_HEIGHT): New macro. (tool_bar_lines_needed): Use unused mode-line row as temp_row. (redisplay_tool_bar): Only clear desired matrix if we actually @@ -4645,10 +4645,6 @@ * image.c: Include "charset.h" and "coding.h". (x_find_image_file): Return an encoded file name. -2006-04-01 Eli Zaretskii <eliz@gnu.org> - - * configure: Regenerated. - 2006-03-31 Kenichi Handa <handa@m17n.org> * xfns.c (xg_set_icon): Delete superfluous UNGCPRO. @@ -6918,7 +6914,7 @@ * search.c (search_buffer): Give up BM search on case-fold-search if one of a target character has a case-equivalence of different - charset even if that target charcter is an ASCII. + charset even if that target character is an ASCII. * casefiddle.c (casify_object): Fix for the case that case conversion change the byte length. @@ -7873,7 +7869,7 @@ 2005-07-19 Juanma Barranquero <lekktu@gmail.com> - * eval.c (Fprog2, Fcalled_interactively_p), + * eval.c (Fprog2, Fcalled_interactively_p) (syms_of_eval) <debug-on-quit>: Doc fixes. (syms_of_eval) <max-specpdl-size>: (Finteractive_p): Fix typos in docstrings. @@ -11254,7 +11250,7 @@ 2004-12-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * macterm.c (endif, x_font_name_to_mac_font_name): - Use maccentraleurroman instead of maccentraleuropean + Use maccentraleurroman instead of maccentraleuropean. (mac_c_string_match, mac_do_list_fonts): Speed up font search by quickly finding a specific font without needing regexps. @@ -12481,7 +12477,7 @@ * gtkutil.h (xg_frame_cleared): Remove. - * xterm.c (x_clear_frame): Remove call to xg_frame_cleared + * xterm.c (x_clear_frame): Remove call to xg_frame_cleared. (x_scroll_bar_create, XTset_vertical_scroll_bar): Remove arguments left and width to xg_update_scrollbar_pos. (XTset_vertical_scroll_bar): Do x_clear_area for USE_GTK also. @@ -13021,9 +13017,9 @@ * macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte strings in menu items. - (single_submenu): Use ENCODE_MENU_STRING + (single_submenu): Use ENCODE_MENU_STRING. (mac_menu_show): Use ENCODE_MENU_STRING. Reset grabbed because - button release isn't passed to event loop + button release isn't passed to event loop. (add_menu_item): Use SetMenuItemWithCFString. 2004-08-26 Steven Tamm <steventamm@mac.com> @@ -15411,7 +15407,7 @@ (Fxw_display_color_p): Use dpyinfo->color_p. (Fx_display_grayscale_p, Fx_display_planes): Don't use dpyinfo->n_cbits. - (Fx_display_color_cells): Use dpyinfo->n_planes; + (Fx_display_color_cells): Use dpyinfo->n_planes. (QCmatrix, QCcolor_adjustment, QCmask, Qemboss, Qedge_detection) (Qheuristic, cross_disabled_images, emboss_matrix) (laplace_matrix): New variables (from xfns.c). @@ -16418,7 +16414,7 @@ (append_glyph, append_composite_glyph, produce_image_glyph) (append_stretch_glyph): Set glyph's ascent and descent. (on_hot_spot_p): New function to check if position is inside an - rectangular, circular, or polygon-shaped image hot-spot, + rectangular, circular, or polygon-shaped image hot-spot. (find_hot_spot): New function to search for image hot-spot. (Flookup_image_map): New defun to search for image hot-spot. (define_frame_cursor1): New aux function to determine frame @@ -18574,7 +18570,7 @@ change/simplify relevant callers. (x_y_to_hpos_vpos): Adapt to per-window fringes and scroll bars, and new fringe vs. display margin position. - Use window_box_left_offset and window_box_right_offset + Use window_box_left_offset and window_box_right_offset. (get_glyph_string_clip_rect): Adapt to per-window fringes and scroll bars, and new fringe vs. display margin position. Use WINDOW_LEFT_EDGE_X and WINDOW_TOTAL_WIDTH. @@ -21093,7 +21089,7 @@ * w32.c (g_b_init_is_windows_9x, g_b_init_open_process_token) (g_b_init_get_token_information, g_b_init_lookup_account_sid) - (g_b_init_get_sid_identifier_authority ): Add several static + (g_b_init_get_sid_identifier_authority): Add several static global variables. * w32.c (globals_of_w32): New function. Used to initialize those diff --git a/src/ChangeLog.2 b/src/ChangeLog.2 index d90e326f970..0397478f09d 100644 --- a/src/ChangeLog.2 +++ b/src/ChangeLog.2 @@ -984,7 +984,7 @@ 1988-01-06 Richard Stallman (rms@frosted-flakes) * s-hpux.h: Don't define nomultiplejobs, LDAV_SYMBOL, LIBS_DEBUG - or BROKEN_FIONREAD. + or BROKEN_FIONREAD. * m-hp9000s300.h: Define those four. * s-hpux.h: Define BSTRING, and define bcopy, etc., as macros. @@ -1323,7 +1323,7 @@ 1987-06-09 Richard M. Stallman (rms@prep) - * syntax.c: (scan_lists): Clear mathexit on 2nd math-char in a pair. + * syntax.c (scan_lists): Clear mathexit on 2nd math-char in a pair. 1987-06-08 Richard M. Stallman (rms@prep) @@ -2817,7 +2817,7 @@ 1986-11-26 Richard M. Stallman (rms@prep) * sysdep.c (get_system_name): - Eliminate internal static var in USG case. + Eliminate internal static var in USG case. * lisp.h: New case testing and conversion macros UPPERCASEP, LOWERCASEP, NOCASEP, UPCASE, DOWNCASE. @@ -3102,9 +3102,9 @@ [So (-259 . (259 . x)) means to format x -exactly- 259 chars wide.] * dispnew.c (Fding): - Do not terminate macro-definition if given an argument + Do not terminate macro-definition if given an argument. (This is so things like asynchronous process notifications - can beep but not screw) + can beep but not screw.) 1986-11-10 Richard M. Stallman (rms@prep) @@ -3852,7 +3852,7 @@ (so now (let ((case-fold-search t))) doesn't force buffer-localness) However, setting a binding will still make it buffer-local. (ie (let ((case-fold-search t)) (setq case-fold-search t)) - will cause case-fold-search be buffer-local even outside the let) + will cause case-fold-search be buffer-local even outside the let) * xfns.c: Preserve studlycaps: "Gnuemacs" => "GNU Emacs" @@ -4452,16 +4452,16 @@ * search.c (Freplace_match): Delete unused some_multiletter_word init. * alloc.c (gc_sweep): Delete unused next initializers. * fns.c (concat): After error on non-int elt for string, - do store the new value from the error handler. + do store the new value from the error handler. * lread.c (read1): Comment out unused end =. * lread.c (read_list): Delete unused tail =. * data.c (Fmake_variable_buffer_local): - If value type is Lisp_Some_Buffer_Local_Value, - change it to Lisp_Buffer_Local_Value permanently. + If value type is Lisp_Some_Buffer_Local_Value, + change it to Lisp_Buffer_Local_Value permanently. * undo.c (record_block): Delete unused cp =. - Don't bother reallocing if n = 0 after first batch. + Don't bother reallocing if n = 0 after first batch. * fileio.c (Fverify_visited_file_modtime): - If CHECK_BUFFER changes buf, use the changed value. + If CHECK_BUFFER changes buf, use the changed value. 1986-07-07 Richard M. Stallman (rms@prep) @@ -4663,8 +4663,8 @@ * editfns.c (Fgoto_char): Use new interactive code N. - * callint.c (Fcall_interactively): New code N - means use prefix argif have one, else read number from minibuffer. + * callint.c (Fcall_interactively): New code N means use + prefix arg if have one, else read number from minibuffer. * buffer.c (record_buffer): Don't use Frassq, Fmemq or Fdelq since their loops diff --git a/src/ChangeLog.3 b/src/ChangeLog.3 index 11c818f18d9..e3ba2b37ccd 100644 --- a/src/ChangeLog.3 +++ b/src/ChangeLog.3 @@ -6993,7 +6993,7 @@ * keyboard.c (Qvertical_split): Renamed to `vertical-line', since the window arrangement is actually referred to as a - `horizontal split.' + `horizontal split'. (make_lispy_event, make_lispy_movement, syms_of_keyboard): Uses renamed here. * keyboard.h (Qvertical_split): Extern declaration changed here. @@ -14197,7 +14197,7 @@ 1989-12-14 Joseph Arceneaux (jla@spiff) * xfns.c: New variable Vx_no_window_manager. - (Fx_track_pointer): If bufp < 0, abort. + (Fx_track_pointer): If bufp < 0, abort. * xterm.c (XTread_socket): When leaving window, set x_mouse_x and x_mouse_y to -1. diff --git a/src/ChangeLog.4 b/src/ChangeLog.4 index 7e5728fbbcd..c853ad7b4a6 100644 --- a/src/ChangeLog.4 +++ b/src/ChangeLog.4 @@ -4329,7 +4329,7 @@ 1993-11-01 Richard Stallman (rms@mole.gnu.ai.mit.edu) - * s/sunos4-1-3.h (HAVE_TERMIOS): Defined. + * s/sunos4-1-3.h (HAVE_TERMIOS): Define. 1993-10-25 Brian J. Fox (bfox@albert.gnu.ai.mit.edu) @@ -4411,7 +4411,7 @@ * keyboard.c (read_key_sequence): Don't declare first_event; it is no longer used. Change "#if 0" for first_event reading to - "#if defined (GOBBLE_FIRST_EVENT)". + "#if defined (GOBBLE_FIRST_EVENT)". 1993-10-03 Brian J. Fox (bfox@ai.mit.edu) @@ -4426,9 +4426,9 @@ * Makefile.in: File removed. It is now generated by ../configure. - * Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end. This - change to ymakefile was mysteriously lost. Were any others lost - too? + * Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end. + This change to ymakefile was mysteriously lost. + Were any others lost too? 1993-10-02 Brian J. Fox (bfox@ai.mit.edu) @@ -4461,8 +4461,7 @@ 1993-09-24 Brian J. Fox (bfox@ai.mit.edu) - * textprop.c (validate_plist): Add declaration for `list' - argument. + * textprop.c (validate_plist): Add declaration for `list' argument. * frame.c (Fhandle_switch_frame): Doc fix. @@ -4501,7 +4500,7 @@ * doc.c (Fsubstitute_command_keys): Pass new arg. * abbrev.c (Funexpand_abbrev, Fexpand_abbrev): Pass new arg. - * s/aix3-2.h (AIX3_2): Defined. + * s/aix3-2.h (AIX3_2): Define. * m/ibmrs6000.h (LIBS_MACHINE): Include -lrts, -liconv only if AIX3_2. * xterm.h (HAVE_X11R4): If AIX, do not define HAVE_X11R4. @@ -4703,13 +4702,13 @@ * xfns.c (XScreenNumberOfScreen): New function. - * m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Defined. + * m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Define. * m/iris4d.h (START_FILES, LIB_STANDARD): Don't define if USG5_4. (DEFAULT_ENTRY_ADDRESS): Likewise. (UNEXEC): Use unexelfsgi.o if USG5_4. - * s/irix5-0.h (C_SWITCH_MACHINE): Deleted. + * s/irix5-0.h (C_SWITCH_MACHINE): Delete. 1993-08-13 Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr) @@ -4809,7 +4808,7 @@ * m/dpx2.h (HAVE_TCATTR): Macro #defined. (HAVE_CLOSEDIR): #undef to allow use of closedir in sysdep.c. - (SIGTSTP): Commented #undef to allow use of ^Z in shell-mode. + (SIGTSTP): Comment #undef to allow use of ^Z in shell-mode. (SIGNALS_VIA_CHARACTERS): #defined. 1993-08-09 Paul Eggert (eggert@twinsun.com) @@ -4849,10 +4848,10 @@ and calculate position properly. * s/bsd4-2.h, s/bsd4-3.h, s/umax.h, s/rtu.h, s/dgux.h (HAVE_VFORK): - Defined. + Define. * ymakefile (alloc.o): Don't use DEBUG_MOLE. - (DEBUG_MOLE): Deleted. + (DEBUG_MOLE): Delete. * gnu-hp300: File deleted. * .gdbinit: Don't put -q in args. @@ -4878,7 +4877,7 @@ (main): Call init_buffer, init_callproc and init_cmdargs before init_lread. (syms_of_emacs): Install the function, and protect the variable. - * lisp.h (Vinvocation_directory): Declared. + * lisp.h (Vinvocation_directory): Declare. * lread.c (init_lread): Normally put Vinvocation_directory at end of Vload_path, if not present already. diff --git a/src/ChangeLog.5 b/src/ChangeLog.5 index 89d43526609..cc3fcdd88f2 100644 --- a/src/ChangeLog.5 +++ b/src/ChangeLog.5 @@ -176,7 +176,7 @@ 1995-06-12 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * mem-limits.h [_LIBC] (start_of_data): Define to &__data_start - for GNU libc. + for GNU libc. 1995-06-11 Richard Stallman <rms@gnu.ai.mit.edu> @@ -227,7 +227,7 @@ * xterm.c (x_get_keysym_name): New function. * keyboard.c (modify_event_symbol): Mask out high bits here, and only for certain purposes. table_size now unsigned. - (modify_event_symbol) [HAVE_X_WINDOWS]: Use x_get_keysym_name. + (modify_event_symbol) [HAVE_X_WINDOWS]: Use x_get_keysym_name. (make_lispy_event): Don't mask high bits here. Supply -1 as table_size for system-specific keys. @@ -316,9 +316,9 @@ (Fexecute_extended_command, init_kboard, syms_of_keyboard): Undo Feb 28 change; prefix arg handling is now in Lisp code again. - * buffer.c: (syms_of_buffer): Doc fix. + * buffer.c (syms_of_buffer): Doc fix. - * buffer.c: (Fbuffer_disable_undo): Make this function interactive. + * buffer.c (Fbuffer_disable_undo): Make this function interactive. 1995-06-07 Richard Stallman <rms@gnu.ai.mit.edu> @@ -335,7 +335,7 @@ (ALL_CFLAGS): Insert $(TOOLKIT_DEFINES) here. * xfns.c (syms_of_xfns): Provide motif in Motif version. - * lisp.h: (Fwaiting_for_user_input_p): Function declared. + * lisp.h (Fwaiting_for_user_input_p): Function declared. (Fupcase_initials, Fupcase_initials_region): Likewise. (Fplist_get, get_local_map, Fx_popup_menu, Fx_popup_dialog): Likewise. (Fframe_first_window): Likewise. @@ -387,7 +387,7 @@ based on frame name and icon_name fields. (x_set_icon_name): New function. (x_icon): Call x_text_icon. - (x_set_name): Look at icon_name field when setting the icon name, + (x_set_name): Look at icon_name field when setting the icon name. (x_frame_parms): Add icon-name. (syms_of_xfns): Set up Qicon_name. @@ -849,7 +849,7 @@ 1995-05-07 Richard Stallman <rms@mole.gnu.ai.mit.edu> * process.c (wait_reading_process_input): Pass arg in new call to - set_waiting_for_input. + set_waiting_for_input. * xfns.c (Funfocus_frame): Check for live X frame. @@ -903,7 +903,7 @@ 1995-05-04 Richard Stallman <rms@mole.gnu.ai.mit.edu> - * s/freebsd.h: (GETPGRP_NO_ARG): Defined + * s/freebsd.h (GETPGRP_NO_ARG): Define. (HAVE_GETPAGESIZE): Definition deleted. * data.c (store_symval_forwarding): Error if value out of range @@ -1308,7 +1308,7 @@ * ntinevt.c (do_mouse_event): Use XSETFASTINT. (SET_FRAME): Undefined. - (select): Renamed to sys_select to correspond to routine in sysdep.c + (select): Renamed to sys_select to correspond to routine in sysdep.c. (sys_select): Support struct timeval. (key_event): Support German keyboard. Replace SET_FRAME with XSETFRAME. @@ -1366,8 +1366,8 @@ 1995-04-11 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * process.c (create_process): Set PROCESS's tty_name to Qnil when - !PTY_FLAG, so Fprocess_tty_name returns nil for pipes as its - docstring says. + !PTY_FLAG, so Fprocess_tty_name returns nil for pipes as its + docstring says. 1995-04-11 Richard Stallman <rms@mole.gnu.ai.mit.edu> @@ -1764,12 +1764,12 @@ * keyboard.c (kbd_buffer_get_event): Pass 0 for `insist' arg. * m/intel386.h (C_SWITCH_SYSTEM): Don't #undef or define it. - [SOLARIS2, SOLARIS2_4, !__GNUC__] (C_SWITCH_MACHINE): Define instead. + [SOLARIS2, SOLARIS2_4, !__GNUC__] (C_SWITCH_MACHINE): Define instead. 1995-03-26 Germano Caronni <caronni@tik.ethz.ch> * ralloc.c (r_re_alloc): Correct realloc behavior--allow shrinking - of blocks while reallocating, if shrinking by more than one page. + of blocks while reallocating, if shrinking by more than one page. (relocate_blocs, resize_blocs): Added failsafe to protect future calling of these routines when in frozen state. (r_alloc_thaw): Added call to r_alloc_init. @@ -1820,7 +1820,7 @@ * m/sparc.h: Don't include alloca.h if NOT_C_CODE. * m/mips-siemens.h (UNEXEC): Override the definition. - (LIBS_DEBUG, ORDINARY_LINK): Add #undefs. + (LIBS_DEBUG, ORDINARY_LINK): Add #undefs. 1995-03-22 Karl Heuer <kwzh@hal.gnu.ai.mit.edu> @@ -2334,7 +2334,7 @@ 1995-02-14 Richard Stallman <rms@geech.gnu.ai.mit.edu> - * filelock.c: (unlock_buffer, unlock_all_files, Flock_buffer) + * filelock.c (unlock_buffer, unlock_all_files, Flock_buffer) (Funlock_buffer): Use buffer's file_truename, not filename. * buffer.c (syms_of_buffer): Set up Lisp var buffer-file-truename. @@ -3461,7 +3461,7 @@ 1994-11-19 Francesco Potortì <pot@cnuce.cnr.it> - * lisp.h: (running_asynch_code): New global flag. + * lisp.h (running_asynch_code): New global flag. * emacs.c (running_asynch_code): New global flag. (main): Initialise it. * process.c (read_process_output, exec_sentinel): Set and @@ -3493,7 +3493,7 @@ 1994-11-17 Karl Heuer <kwzh@hal.gnu.ai.mit.edu> - * lisp.h: (enum Lisp_Misc_Type): Rename Lisp_Vector to + * lisp.h (enum Lisp_Misc_Type): Rename Lisp_Vector to Lisp_Vectorlike. Mark Lisp_Window_Configuration as obsolete. (PSEUDOVECTOR_FLAG, PSEUDOVECTOR_SIZE_MASK, PVEC_BUFFER, PVEC_PROCESS, PVEC_FRAME, PVEC_COMPILED, PVEC_WINDOW, @@ -3645,7 +3645,7 @@ 1994-11-14 Karl Heuer <kwzh@hal.gnu.ai.mit.edu> - * lisp.h: (enum Lisp_Misc_Type): Add new enumeration Lisp_Misc_Overlay. + * lisp.h (enum Lisp_Misc_Type): Add new enumeration Lisp_Misc_Overlay. (enum Lisp_Type): Delete the corresponding enumeration from here. (struct Lisp_Overlay): New structure. (XOVERLAY, OVERLAYP): Access the new structure. @@ -3711,7 +3711,7 @@ 1994-11-11 Karl Heuer <kwzh@nutrimat.gnu.ai.mit.edu> - * lisp.h: (enum Lisp_Misc_Type): Add new enumerations + * lisp.h (enum Lisp_Misc_Type): Add new enumerations Lisp_Misc_Buffer_Local_Value and Lisp_Misc_Some_Buffer_Local_Value. (enum Lisp_Type): Delete the corresponding enumerations from here. (struct Lisp_Buffer_Local_Value): New structure. @@ -3798,7 +3798,7 @@ * xfns.c (Fx_list_fonts): Don't bother to retrieve font info when there's no size_ref to compare it against. - * editfns.c: (Fdecode_time): Fix Lisp_Object vs. integer problems. + * editfns.c (Fdecode_time): Fix Lisp_Object vs. integer problems. Don't use tm_gmtoff; it's not portable. * lisp.h: Leave DEVICE_SEP undefined by default. @@ -3955,7 +3955,7 @@ Use the return value of child_setup to get the child's pid; don't call vfork etc. explicitly. - * callproc.c [WINDOWSNT]: Add includes. Define NOMINMAX, _P_NOWAIT. + * callproc.c [WINDOWSNT]: Add includes. Define NOMINMAX, _P_NOWAIT. (Vbinary_process_input, Vbinary_process_output) (Qbuffer_file_type): Test DOS_NT, not MSDOS. (syms_of_callproc): Test DOS_NT, not MSDOS. @@ -4217,7 +4217,7 @@ * process.c: Handle multiple keyboard input descriptors. (non_keyboard_wait_mask): New variable. - (Fset_process_filter): Update non_keyboard_wait_mask + (Fset_process_filter): Update non_keyboard_wait_mask. (create_process, Fopen_network_stream, deactivate_process): (init_process, sigchld_handler): Likewise. (wait_reading_process_input): Maybe use non_keyboard_wait_mask. @@ -4367,7 +4367,7 @@ (the_x_screen): Variable moved here. (syms_of_xterm): Staticpro parts of the_x_screen. * xfns.c (Fx_open_connection): Get dpyinfo from x_term_init. - Don't set up atoms, xrdb here. Pass name as Lisp_Object. + Don't set up atoms, xrdb here. Pass name as Lisp_Object. (the_x_screen): Variable moved to xterm.c. (syms_of_xfns): Don't staticpro it here. @@ -4456,7 +4456,7 @@ * xfns.c: Use FRAME_X_DISPLAY instead of x_current_display and XDISPLAY. - (x_in_use): New variable, + (x_in_use): New variable. (check_x, using_x_p): Test x_in_use. (Fx_open_connection): Set x_in_use. (check_x_frame): New function. @@ -4511,7 +4511,7 @@ 1994-10-19 Karl Heuer <kwzh@hal.gnu.ai.mit.edu> - * search.c: (searchbufs): New variable, replaces searchbuf and + * search.c (searchbufs): New variable, replaces searchbuf and last_regexp and search_fastmap. (syms_of_search): Initialize it. (searchbuf_head): New variable. @@ -4597,7 +4597,7 @@ * frame.h [!MULTI_FRAME]: We give up having selected_frame be an always-zero integer variable. From now on it will be a pointer to a `struct frame' just like in the MULTI_FRAME case. - (selected_frame, last_nonminibuf_frame): use FRAME_PTR, not EMACS_INT. + (selected_frame, last_nonminibuf_frame): use FRAME_PTR, not EMACS_INT. (XFRAME): Redefine to use the_only_frame. (XSETFRAME): Define to set Lisp value. (WINDOW_FRAME): Redefine to return Lisp value. @@ -4640,7 +4640,7 @@ (the_only_x_display, x_current_display) [!HAVE_X_WINDOWS]: New variables. - * msdos.h: (XFontStruct, GC, Pixmap, Display, Window) [MSDOS_NO_X]: + * msdos.h (XFontStruct, GC, Pixmap, Display, Window) [MSDOS_NO_X]: Dummy types. (struct face, FACE_HAS_GC, FACE_GC, FACE_FOREGROUND, FACE_BACKGROUND, FACE_FONT, FACE_STIPPLE, FACE_UNDERLINE_P) [MSDOS_NO_X]: Define like @@ -4937,7 +4937,7 @@ (struct Lisp_Free): New structure. (Lisp_Misc_Free): Type code for that structure. * buffer.h (OVERLAY_POSITION): Marker assert now tests substructure. - * alloc.c: (MARKER_BLOCK_SIZE, marker_block, marker_free_list): + * alloc.c (MARKER_BLOCK_SIZE, marker_block, marker_free_list): Now refers to the superset type, not just markers. (allocate_misc): New function, extracted from Fmake_marker. (Fpurecopy): Check the substructure. @@ -5185,7 +5185,7 @@ 1994-10-02 Paul Reilly <pmr@geech.gnu.ai.mit.edu> - * xfns.c: (HACK_EDITRES): Declare if using X11R5. + * xfns.c (HACK_EDITRES): Declare if using X11R5. (widget_id_tick): New variable. (x_any_window_to_frame): Use lw_window_is_in_menubar for widget set independence. @@ -5953,7 +5953,7 @@ 1994-09-03 Kaveh R. Ghazi (ghazi@noc.rutgers.edu) * m/delta88k.h [__GNUC__] (HAVE_ALLOCA): Defined. - [__GNUC__] (C_ALLOCA): Add #undef + [__GNUC__] (C_ALLOCA): Add #undef. (LIB_X11_LIB): Add #undef. (HAVE_TERMIOS): Defined. (HAVE_TERMIO): Add #undef. @@ -6107,7 +6107,7 @@ * fileio.c (Fmake_symbolic_link, Ffile_accessible_directory_p, Finsert_file_contents, auto_save_error, Fwrite_region): Likewise. (Fcopy_file, build_annotations, Fdo_auto_save): Delete unused - variables. + variables. 1994-08-23 Richard Stallman <rms@mole.gnu.ai.mit.edu> diff --git a/src/ChangeLog.6 b/src/ChangeLog.6 index 6c7d04a531e..3b1bdbffabc 100644 --- a/src/ChangeLog.6 +++ b/src/ChangeLog.6 @@ -2830,7 +2830,7 @@ * dosfns.c (Fint86, Fdos_memget, Fdos_memput, Fmsdos_set_keyboard): Harmonize arguments with documentation. - * editfns.c (Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time, + * editfns.c (Fchar_to_string, Fstring_to_char, Fgoto_char, Fencode_time) (Finsert_char, Fbuffer_substring, Fbuffer_substring_no_properties) (Finsert_buffer_substring, Fdelete_region, Fnarrow_to_region): Harmonize arguments with documentation. diff --git a/src/ChangeLog.8 b/src/ChangeLog.8 index eeaae29db52..9c38b29ff32 100644 --- a/src/ChangeLog.8 +++ b/src/ChangeLog.8 @@ -4629,9 +4629,6 @@ * Makefile.in (LIBGIF): Use libungif. - * configure.in (HAVE_GIF): Use libungif instead of libgif - because the former doesn't contain patented compression code. - * xdisp.c (compute_window_start_on_continuation_line): Don't do it if line start is too far away from window start. @@ -10395,7 +10392,7 @@ * term.c (get_char_info): Use WHAT field of CHAR_INFO. Use tabs as multiples of spaces. - * dispextern.h (struct char_info ): WHAT field. + * dispextern.h (struct char_info): WHAT field. * term.c (encode_terminal_code): Don't use GLYPH_CHAR, use FAST_GLYPH_CHAR instead because GLYPH_CHAR won't remove faces. @@ -10410,8 +10407,7 @@ * xterm.c (XTget_char_info): Check WANT_ELLIPSIS_P. - * dispextern.h (struct char_info ): GLYPH_ROW for intermediate - glyphs. + * dispextern.h (struct char_info): GLYPH_ROW for intermediate glyphs. * dispnew.c (init_char_info): Init GLYPH_ROW to NULL. CHAR_CURSOR moved to xdisp.c. @@ -10439,7 +10435,7 @@ * term.c (get_char_info): Set MAX_PIXEL_WIDTH in CHAR_INFO. - * dispextern.h (struct char_info ): Use LISP_CHAR_TABLE for DP. + * dispextern.h (struct char_info): Use LISP_CHAR_TABLE for DP. New member MAX_PIXEL_HEIGHT. * xterm.c (x_per_char_metric): Get per character metrics. @@ -13872,10 +13868,10 @@ 1998-08-31 Kenichi Handa <handa@etl.go.jp> * charset.c (unibyte_char_to_multibyte): - Vnonacii_translation_table will convert a 7-bit charcater. + Vnonacii_translation_table will convert a 7-bit character. (multibyte_char_to_unibyte): Handle the case that - Vnonacii_translation_table converts a multibyte charcater to a - unibyte charcter of less than 128. + Vnonacii_translation_table converts a multibyte character to a + unibyte character of less than 128. (init_charset_once): Initialize nonascii_insert_offset and Vnonacii_translation_table. diff --git a/src/ChangeLog.9 b/src/ChangeLog.9 index a56c1a2c088..fc4f2d4ad37 100644 --- a/src/ChangeLog.9 +++ b/src/ChangeLog.9 @@ -319,7 +319,7 @@ * lisp.h (Ftop_level): Add prototype. - * xterm.c: (xlwmenu_window_p, xlwmenu_redisplay): Add prototypes. + * xterm.c (xlwmenu_window_p, xlwmenu_redisplay): Add prototypes. (XTread_socket): Improve style of comments to follow other comments. @@ -1126,7 +1126,7 @@ * xterm.c (note_mouse_highlight) <help-echo>: When looking for help-echo for a string which doesn't have help-echo itself, use - get-char-property to obtain the help-echo from the string's buffer + get-char-property to obtain the help-echo from the string's buffer. (note_mouse_highlight) <mouse-face>: When on a string that doesn't have mouse-face, look ``under'' the string for mouse-face from an overlay. @@ -1496,7 +1496,7 @@ * coding.c (setup_coding_system): Don't do any designation based on reg_bits if charset is not yet defined. - * lisp.h (XVECTOR): Verify correct object type before returning a + * lisp.h (XVECTOR): Verify correct object type before returning a pointer, using eassert. 2001-07-17 Gerd Moellmann <gerd@gnu.org> @@ -1752,7 +1752,7 @@ creating the directory might signal an error, and leaves Emacs in a strange state. - * term.c: (tty_cursor_hidden): New variable. + * term.c (tty_cursor_hidden): New variable. (update_begin): Don't call tty_hide_cursor. Clean up. (update_end, set_terminal_window, set_scroll_region): Clean up. (ring_bell, reset_terminal_modes): Clean up. @@ -3109,7 +3109,7 @@ * w32term.c (w32_encode_char): Treat eight bit graphic and control characters the same as ASCII and latin-1. - (x_display_and_set_cursor): Check for the focus frame's selected + (x_display_and_set_cursor): Check for the focus frame's selected window instead of selected_window. (x_after_update_window_line): Don't clear if frame's internal border width is zero. @@ -3119,7 +3119,7 @@ * w32fns.c (Fx_show_tip): Fix calls to make_number. (x_set_font): If font hasn't changed, avoid recomputing faces and other things. - (x_set_tool_bar_lines): Do nothing if frame is minibuffer-only, + (x_set_tool_bar_lines): Do nothing if frame is minibuffer-only. (Fx_create_frame): Add the tool bar height to the frame height. (x_create_tip_frame): Prevent changing the tooltip's background color by specifying a color for the default font @@ -3913,7 +3913,7 @@ 2001-01-05 Gerd Moellmann <gerd@gnu.org> * sysdep.c: Don't prototype srandom; it takes an unsigned argument - on some systems, and an unsigned long on others, like FreeBSD 4.1. + on some systems, and an unsigned long on others, like FreeBSD 4.1. 2001-01-04 Gerd Moellmann <gerd@gnu.org> @@ -4887,7 +4887,7 @@ * md5.c: Delay include of md5.h until after namespace cleaning. - * makefile.w32-in (fns.o): Depend on md5.h + * makefile.w32-in (fns.o): Depend on md5.h. (md5.o): New target. (sunfns.o): Remove. @@ -5004,7 +5004,7 @@ the metrics of BDF fonts. (x_estimate_mode_line_height): If `mode-line' face hasn't a font, use that of the frame, as drawing glyphs does. - (note_mouse_highlight): Change the cursor shape on the vertical + (note_mouse_highlight): Change the cursor shape on the vertical border between windows [not enabled]. * w32term.h (struct w32_output): Add member horizontal_drag_cursor. @@ -5161,9 +5161,9 @@ `vertical-line', `mode-line' and `header-line' events. * xdisp.c (try_window_id): Avoid starting to display in the middle - of a character, a TAB for instance. This is easier than to set - up the iterator exactly, and it's not a frequent case, so the - additional effort wouldn't really pay off. + of a character, a TAB for instance. This is easier than to set + up the iterator exactly, and it's not a frequent case, so the + additional effort wouldn't really pay off. 2000-11-26 Andrew Choi <akochoi@i-cable.com> @@ -5196,9 +5196,9 @@ 2000-11-24 Gerd Moellmann <gerd@gnu.org> * xdisp.c (init_from_display_pos): If POS says we're already after - an overlay string ending at POS, make sure to pop the iterator - because it will be in front of that overlay string. When POS is - ZV, we've thereby also ``processed'' overlay strings at ZV. + an overlay string ending at POS, make sure to pop the iterator + because it will be in front of that overlay string. When POS is + ZV, we've thereby also ``processed'' overlay strings at ZV. * xfaces.c (lface_from_face_name): Function comment fix. @@ -7254,7 +7254,7 @@ * charset.h (MAKE_CHAR): Be sure to set MSB of C1 to 0. - * charset.c: Include composite.h + * charset.c: Include composite.h. (lisp_string_width): New function. (Fstring_width): Call lisp_string_width instead of strwidth. @@ -7333,7 +7333,7 @@ * s/ms-w32.h (ORDINARY_LINK): New define. - * w32.c (_ANONYMOUS_UNION) [__GNUC__]: New define + * w32.c (_ANONYMOUS_UNION) [__GNUC__]: New define. (_ANONYMOUS_STRUCT) [__GNUC__]: New define. * makefile.w32-in (clean): Don't delete config.h and epaths.h. @@ -8409,7 +8409,7 @@ (encode_coding_iso2022): New local variable safe_chars. Check unsafe chars. (setup_coding_system): Delete the code to initialize - coding->safe_charses + coding->safe_charses. (intersection, find_safe_codings): New functions. (Ffind_coding_systems_region_internal): New function. (syms_of_coding): Defsubr it. Initialize Qsafe_chars, @@ -8729,7 +8729,7 @@ * w32term.c (help_echo_object, help_echo_pos): New variables. (note_mode_line_highlight): Store additional information about the help-echo in help_echo_object and help_echo_pos. Check both - `local-map' and `keymap' properties for changing the cursor + `local-map' and `keymap' properties for changing the cursor. (note_mouse_highlight): Store additional information about the help-echo in help_echo_object and help_echo_pos. (note_tool_bar_highlight): Set help_echo_object to nil and @@ -8797,7 +8797,7 @@ * xterm.c (help_echo_object, help_echo_pos): New variables. (note_mode_line_highlight): Store additional information about the help-echo in help_echo_object and help_echo_pos. Check both - `local-map' and `keymap' properties for changing the cursor + `local-map' and `keymap' properties for changing the cursor. (note_mouse_highlight): Store additional information about the help-echo in help_echo_object and help_echo_pos. (note_tool_bar_highlight): Set help_echo_object to nil and @@ -11979,7 +11979,7 @@ (detect_coding_utf_8): New function. (UTF_16_INVALID_P, UTF_16_HIGH_SURROGATE_P UTF_16_LOW_SURROGATE_P): New macros. - (detect_coding_utf_16): New function + (detect_coding_utf_16): New function. (detect_coding_mask): When priorities are specified, skip any categories that have `nil' coding-system. Fix bug of returning wrong mask when PRIORITIES is specified and detect_coding_XXX() @@ -12222,7 +12222,7 @@ * makefile.nt: Add atimer.h to dependencies. * w32.c (init_environment): Set Vw32_num_mouse_buttons here. - * w32console.c: Only disable window system features for dispextern.h + * w32console.c: Only disable window system features for dispextern.h. (initialize_w32_display): Build a display info for the console. * w32faces.c (tty_defined_color): Apply xfaces.c change from 02-17. * w32fns.c (w32_wnd_proc) [WM_LBUTTON_DOWN, WM_RBUTTON_DOWN, @@ -12825,7 +12825,7 @@ (FRAME_XIM): Removed. * xfns.c (supported_styles): New variable. - (DEFAULT_STYLE, DEFAULT_FONT): New macros + (DEFAULT_STYLE, DEFAULT_FONT): New macros. (xic_create_xfontset, best_style, xic_create_frame) (xic_destroy_frame, xic_set_preeditarea, xic_set_statusarea) (xic_set_xfontset): New functions. @@ -13029,7 +13029,7 @@ 2000-01-19 Dave Love <fx@gnu.org> - * lread.c: (syms_of_lread) [user-init-file]: Doc change. + * lread.c (syms_of_lread) [user-init-file]: Doc change. 2000-01-18 Kenichi Handa <handa@etl.go.jp> @@ -13156,7 +13156,7 @@ (GC_STRING_BYTES, GC_STRING_CHARS): New macros. (DONT_COPY_FLAG): Removed. (SBLOCK_SIZE, LARGE_STRING_BYTES): New macros. - (struct sdata, struct sblock): New + (struct sdata, struct sblock): New. (struct string_block): Rewritten. (STRINGS_IN_STRING_BLOCK): New macro. (oldest_sblock, current_sblock, total_strings, total_free_strings) diff --git a/src/Makefile.in b/src/Makefile.in index 9caa01d9066..871806e8222 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,8 @@ + # Makefile for GNU Emacs. # Copyright (C) 1985, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. # This file is part of GNU Emacs. @@ -23,421 +24,196 @@ # script may need modifying in sync with changes made here. Try to # avoid shell-ism because the DOS build has to use the DOS shell. -# Don't try to replace the cpp processing using autoconf facilities, -# says rms. -# Replacing a particular part of the conditionals to work via autoconf -# is OK. -# Some of the conditionals might be dead now. Finding them and -# deleting them would be fine. - +SHELL = /bin/sh # Here are the things that we expect ../configure to edit. # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH. -srcdir=@srcdir@ -VPATH=@srcdir@ -CC=@CC@ -CPP=@CPP@ -CFLAGS=@CFLAGS@ -CPPFLAGS=@CPPFLAGS@ -LDFLAGS=@LDFLAGS@ -LN_S=@LN_S@ -EXEEXT=@EXEEXT@ -version=@version@ +srcdir = @srcdir@ +abs_builddir = @abs_builddir@ +VPATH = $(srcdir) +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LD_FIRSTFLAG=@LD_FIRSTFLAG@ +EXEEXT = @EXEEXT@ +version = @version@ # Substitute an assignment for the MAKE variable, because # BSD doesn't have it as a default. @SET_MAKE@ # Don't use LIBS. configure puts stuff in it that either shouldn't be -# linked with Emacs or is duplicated by the cpp stuff below. +# linked with Emacs or is duplicated by the other stuff below. # LIBS = @LIBS@ LIBOBJS = @LIBOBJS@ -lispsource = ${srcdir}/../lisp/ -libsrc = ../lib-src/ -etc = ../etc/ -oldXMenudir = ../oldXMenu/ -lwlibdir = ../lwlib/ -lispdir = ../lisp/ +lispsource = $(srcdir)/../lisp +libsrc = ../lib-src +etc = ../etc +oldXMenudir = ../oldXMenu +lwlibdir = ../lwlib +lispdir = ../lisp # Configuration files for .o files to depend on. -M_FILE = ${srcdir}/@machfile@ -S_FILE = ${srcdir}/@opsysfile@ +M_FILE = $(srcdir)/@machfile@ +S_FILE = $(srcdir)/@opsysfile@ config_h = config.h $(M_FILE) $(S_FILE) -bootstrap_exe = ../src/bootstrap-emacs${EXEEXT} +bootstrap_exe = $(abs_builddir)/bootstrap-emacs$(EXEEXT) +## ns-app if HAVE_NS, else empty. OTHER_FILES = @OTHER_FILES@ -# ========================== start of cpp stuff ======================= -/* From here on, comments must be done in C syntax. */ - -C_SWITCH_SYSTEM= - -/* just to be sure the sh is used */ -SHELL=/bin/sh - -#define THIS_IS_MAKEFILE -#define NOT_C_CODE -#include "config.h" - -#ifdef AUTO_DEPEND -DEPFLAGS = -MMD -MF deps/$*.d -#endif - -/* Do not let the file name mktime.c get messed up. */ -#ifdef mktime -#undef mktime -#endif - -/* Use HAVE_X11 as an alias for X11 in this file - to avoid problems with X11 as a subdirectory name - in -I and other such options which pass through this file. */ - -#ifdef X11 -#define HAVE_X11 -#undef X11 -#endif - -/* On some machines #define register is done in config; - do not let it interfere with this file. */ -#undef register - -/* GNU libc requires ORDINARY_LINK so that its own crt0 is used. - GNU/Linux is an exception because it uses a funny variant of GNU libc. */ -#ifdef __GNU_LIBRARY__ -#ifndef GNU_LINUX -#define ORDINARY_LINK -#endif -#endif - -/* Some machines do not find the standard C libraries in the usual place. */ -#ifndef ORDINARY_LINK -#ifndef LIB_STANDARD -#define LIB_STANDARD -lc -#endif -#else -#ifndef LIB_STANDARD -#define LIB_STANDARD -#endif -#endif - -/* Under GNUstep, putting libc on the link line causes problems. */ -#ifdef NS_IMPL_GNUSTEP -#undef LIB_STANDARD -#define LIB_STANDARD -#endif - -/* Unless inhibited or changed, use -lg to link for debugging. */ -#ifndef LIBS_DEBUG -#define LIBS_DEBUG -lg -#endif - -/* Some s/SYSTEM.h files define this to request special libraries. */ -#ifndef LIBS_SYSTEM -#define LIBS_SYSTEM -#endif - -/* Some m/MACHINE.h files define this to request special libraries. */ -#ifndef LIBS_MACHINE -#define LIBS_MACHINE -#endif - -#ifndef LIB_MATH -# define LIB_MATH -lm -#endif /* LIB_MATH */ - -/* Some s/SYSTEM.h files define this to request special switches in ld. */ -#ifndef LD_SWITCH_SYSTEM -#if !defined (__GNUC__) && ((defined (BSD_SYSTEM) && !defined (COFF))) -#define LD_SWITCH_SYSTEM -X -#else /* (defined (BSD_SYSTEM) && !defined (COFF)) */ -#define LD_SWITCH_SYSTEM -#endif /* (defined (BSD_SYSTEM) && !defined (COFF)) */ -#endif /* LD_SWITCH_SYSTEM */ - -/* This holds special options for linking temacs - that should be used for linking anything else. */ -#ifndef LD_SWITCH_SYSTEM_TEMACS -#define LD_SWITCH_SYSTEM_TEMACS -#endif - -/* Some s/SYSTEM.h files define this to request special switches - for compiling temacs. */ -#ifndef C_SWITCH_SYSTEM_TEMACS -#define C_SWITCH_SYSTEM_TEMACS -#endif - -/* Some m/MACHINE.h files define this to request special switches in ld. */ -#ifndef LD_SWITCH_MACHINE -#define LD_SWITCH_MACHINE -#endif - -/* This holds special options for linking temacs - that should be used for linking anything else. */ -#ifndef LD_SWITCH_MACHINE_TEMACS -#define LD_SWITCH_MACHINE_TEMACS -#endif - -/* Some m/MACHINE.h files define this to request special switches in cc. */ -#ifndef C_SWITCH_MACHINE -#define C_SWITCH_MACHINE -#endif - -/* Some s/SYSTEM.h files define this to request special switches in cc. */ -#ifndef C_SWITCH_SYSTEM -#define C_SWITCH_SYSTEM -#endif - -/* These macros are for switches specifically related to X Windows. */ -#ifndef C_SWITCH_X_MACHINE -#define C_SWITCH_X_MACHINE -#endif - -#ifndef C_SWITCH_X_SYSTEM -#define C_SWITCH_X_SYSTEM -#endif - -#ifndef C_SWITCH_X_SITE -#define C_SWITCH_X_SITE -#endif - -#ifndef LD_SWITCH_X_SITE -#define LD_SWITCH_X_SITE -#endif - -#ifndef LD_SWITCH_X_DEFAULT -#define LD_SWITCH_X_DEFAULT -#endif - -#ifndef ORDINARY_LINK - -#ifndef CRT0_COMPILE -#define CRT0_COMPILE $(CC) -c $(ALL_CFLAGS) -#endif - -#ifndef START_FILES -#ifdef NO_REMAP -#define START_FILES pre-crt0.o /lib/crt0.o -#else /* ! defined (NO_REMAP) */ -#define START_FILES ecrt0.o -#endif /* ! defined (NO_REMAP) */ -#endif /* START_FILES */ -STARTFILES = START_FILES - -#else /* ORDINARY_LINK */ - -/* config.h might want to force START_FILES anyway */ -#ifdef START_FILES -STARTFILES = START_FILES -#endif /* START_FILES */ - -#endif /* not ORDINARY_LINK */ - - -#ifdef NS_IMPL_GNUSTEP -/* Pull in stuff from GNUstep-make. */ -FOUNDATION_LIB=gnu -GUI_LIB=gnu -include @GNUSTEP_MAKEFILES@/Additional/base.make -include @GNUSTEP_MAKEFILES@/Additional/gui.make -shared=no -#endif - -#ifdef HAVE_DBUS +## Flags to pass for profiling builds +PROFILING_CFLAGS = @PROFILING_CFLAGS@ + +## Flags to pass to the compiler to enable build warnings +C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@ + +## Machine-specific CFLAGS. +C_SWITCH_MACHINE=@C_SWITCH_MACHINE@ +## System-specific CFLAGS. +C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@ + +## Currently only set if NS_IMPL_GNUSTEP. +## C_SWITCH_X_SITE may override this. +C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@ + +## Define C_SWITCH_X_SITE to contain any special flags your compiler +## may need to deal with X Windows. For instance, if you've defined +## HAVE_X_WINDOWS and your X include files aren't in a place that your +## compiler can find on its own, you might want to add "-I/..." or +## something similar. This is normally set by configure. +## This is used before C_SWITCH_X_SYSTEM and may override it. +C_SWITCH_X_SITE=@C_SWITCH_X_SITE@ + +## Define LD_SWITCH_X_SITE to contain any special flags your loader +## may need to deal with X Windows. For instance, if your X libraries +## aren't in a place that your loader can find on its own, you might +## want to add "-L/..." or something similar. Only used if +## HAVE_X_WINDOWS. +## FIXME? configure sets a value for this, but it has never been +## substituted in this or any other Makefile. Cf C_SWITCH_X_SITE. +LD_SWITCH_X_SITE= + +## Next two must come before LD_SWITCH_SYSTEM. +## If needed, a -R option that says where to find X windows at run time. +LD_SWITCH_X_SITE_AUX=@LD_SWITCH_X_SITE_AUX@ +## As above, but using -rpath instead. +LD_SWITCH_X_SITE_AUX_RPATH=@LD_SWITCH_X_SITE_AUX_RPATH@ + +## System-specific LDFLAGS. +LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@ + +## This holds any special options for linking temacs only (ie, not +## used by configure). Not used elsewhere because it sometimes +## contains options that have to do with using Emacs's crt0, +## which are only good with temacs. +LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@ + +## Flags to pass to ld only for temacs. +TEMACS_LDFLAGS = $(LD_SWITCH_SYSTEM) $(LD_SWITCH_SYSTEM_TEMACS) + +## $LDFLAGS or empty if NS_IMPL_GNUSTEP (for some reason). +TEMACS_LDFLAGS2 = @TEMACS_LDFLAGS2@ + +## Some systems define this to request special libraries. +LIBS_SYSTEM=@LIBS_SYSTEM@ + +## Where to find libgcc.a, if using gcc and necessary. +LIB_GCC=@LIB_GCC@ + +CRT_DIR=@CRT_DIR@ +## May use $CRT_DIR. +LIB_STANDARD=@LIB_STANDARD@ +START_FILES = @START_FILES@ + +## -lm, or empty. +LIB_MATH=@LIB_MATH@ + +LIBTIFF=@LIBTIFF@ +LIBJPEG=@LIBJPEG@ +LIBPNG=@LIBPNG@ +LIBGIF=@LIBGIF@ +LIBXPM=@LIBXPM@ +XFT_LIBS=@XFT_LIBS@ +LIBX_EXTRA=$(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) -lX11 $(XFT_LIBS) + +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +LIBOTF_CFLAGS = @LIBOTF_CFLAGS@ +LIBOTF_LIBS = @LIBOTF_LIBS@ +M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ +M17N_FLT_LIBS = @M17N_FLT_LIBS@ + DBUS_CFLAGS = @DBUS_CFLAGS@ DBUS_LIBS = @DBUS_LIBS@ -DBUS_OBJ = dbusbind.o -#endif +DBUS_OBJ = @DBUS_OBJ@ -#ifdef HAVE_GCONF GCONF_CFLAGS = @GCONF_CFLAGS@ GCONF_LIBS = @GCONF_LIBS@ -#endif -/* DO NOT use -R. There is a special hack described in lastfile.c - which is used instead. Some initialized data areas are modified - at initial startup, then labeled as part of the text area when - Emacs is dumped for the first time, and never changed again. */ +GTK_OBJ=@GTK_OBJ@ -/* -Demacs is needed to make some files produce the correct version - for use in Emacs. +## -ltermcap, or -lncurses, or -lcurses, or "". +LIBS_TERMCAP=@LIBS_TERMCAP@ +## terminfo.o if TERMINFO, else tparam.o. +TERMCAP_OBJ=@TERMCAP_OBJ@ - -DHAVE_CONFIG_H is needed for some other files to take advantage of - the information in ``config.h''. */ +LIBXMU=@LIBXMU@ -/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM - since it may have -I options that should override those two. */ -ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS_SOUND} ${RSVG_CFLAGS} ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${CFLAGS} @FREETYPE_CFLAGS@ @FONTCONFIG_CFLAGS@ @LIBOTF_CFLAGS@ @M17N_FLT_CFLAGS@ ${DEPFLAGS} -ALL_OBJC_CFLAGS=$(ALL_CFLAGS) @GNU_OBJC_CFLAGS@ +LIBXSM=@LIBXSM@ -.SUFFIXES: .m -.c.o: -#ifdef AUTO_DEPEND - @-test -d deps || mkdir deps -#endif - $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< -.m.o: -#ifdef AUTO_DEPEND - @-test -d deps || mkdir deps -#endif - $(CC) -c $(CPPFLAGS) $(ALL_OBJC_CFLAGS) $< +LIBXTR6=@LIBXTR6@ -#ifndef LIBX11_SYSTEM -#define LIBX11_SYSTEM -#endif - -#ifndef LIB_X11_LIB -#define LIB_X11_LIB -lX11 -#endif - -#ifdef HAVE_X_WINDOWS -XMENU_OBJ = xmenu.o -XOBJ= xterm.o xfns.o xselect.o xrdb.o fontset.o xsmfns.o fringe.o image.o \ - xsettings.o xgselect.o - -#ifdef HAVE_MENUS - -#ifdef USE_GTK -GTK_OBJ= gtkutil.o -#endif - -/* The X Menu stuff is present in the X10 distribution, but missing - from X11. If we have X10, just use the installed library; - otherwise, use our own copy. */ -#ifdef HAVE_X11 -#ifdef USE_X_TOOLKIT -OLDXMENU=${lwlibdir}liblw.a -LIBXMENU= $(OLDXMENU) -#else /* not USE_X_TOOLKIT */ -OLDXMENU= ${oldXMenudir}libXMenu11.a -LIBXMENU= $(OLDXMENU) -#endif /* not USE_X_TOOLKIT */ -#else /* not HAVE_X11 */ -LIBXMENU= -lXMenu -#endif /* not HAVE_X11 */ - -#else /* not HAVE_MENUS */ - -/* Otherwise, do not worry about the menu library at all. */ -LIBXMENU= -#endif /* not HAVE_MENUS */ - -#ifdef USE_X_TOOLKIT -# define @X_TOOLKIT_TYPE@ -# if HAVE_XAW3D -LUCID_LIBW= -lXaw3d -# else -LUCID_LIBW= -lXaw -# endif -# if defined (HAVE_MOTIF_2_1) && defined (HAVE_LIBXP) -# define LIB_MOTIF_EXTRA -lXp -# else -# define LIB_MOTIF_EXTRA -# endif -# ifdef LIB_MOTIF -MOTIF_LIBW= LIB_MOTIF LIB_MOTIF_EXTRA -# else -MOTIF_LIBW= -lXm LIB_MOTIF_EXTRA -# endif -LIBW=$(@X_TOOLKIT_TYPE@_LIBW) - -#ifdef HAVE_X11XTR6 -#ifdef NEED_LIBW -LIBXTR6 = -lSM -lICE -lw -#else -LIBXTR6 = -lSM -lICE -#endif -#endif - -#ifndef LIBXMU -#define LIBXMU -lXmu -#endif - -LIBXT= $(LIBW) LIBXMU -lXt $(LIBXTR6) -lXext - -#else /* not USE_X_TOOLKIT */ - -#ifdef USE_GTK -LIBW=@GTK_LIBS@ -OLDXMENU= -LIBXMENU= -#endif /* USE_GTK */ - -#ifdef HAVE_X_SM -LIBXT=$(LIBW) -lSM -lICE -#else -LIBXT=$(LIBW) -#endif -#endif /* not USE_X_TOOLKIT */ - -#if HAVE_XFT -XFT_LIBS=@XFT_LIBS@ -#endif /* HAVE_XFT */ - -#if HAVE_XPM -#ifndef LIBXPM -#define LIBXPM -lXpm -#endif /* not defined LIBXPM */ -#else /* not HAVE_XPM */ -#define LIBXPM -#endif /* not HAVE_XPM */ - -#if HAVE_JPEG -#ifndef LIBJPEG -#define LIBJPEG -ljpeg -#endif /* not defined LIBJPEG */ -#else /* not HAVE_JPEG */ -#define LIBJPEG -#endif /* not HAVE_JPEG */ - -#if HAVE_PNG -#ifndef LIBPNG -#define LIBPNG -lpng -lz -lm -#endif /* not defined LIBPNG */ -#else /* not HAVE_PNG */ -#define LIBPNG -#endif /* not HAVE_PNG */ - -#if HAVE_TIFF -#ifndef LIBTIFF -#define LIBTIFF -ltiff -#endif /* not defined LIBTIFF */ -#else /* not HAVE_TIFF */ -#define LIBTIFF -#endif /* not HAVE_TIFF */ - -#if HAVE_GIF -#ifndef LIBGIF -#define LIBGIF -lgif -#endif /* not defined LIBGIF */ -#else /* not HAVE_GIF */ -#define LIBGIF -#endif /* not HAVE_GIF */ - -#ifdef HAVE_X11 -/* LD_SWITCH_X_DEFAULT comes after everything else that specifies - options for where to find X libraries, but before those libraries. */ -X11_LDFLAGS = LD_SWITCH_X_SITE LD_SWITCH_X_DEFAULT -LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) LIBTIFF LIBJPEG LIBPNG LIBGIF LIBXPM LIB_X11_LIB LIBX11_SYSTEM $(XFT_LIBS) -#else /* not HAVE_X11 */ -LIBX= $(LIBXMENU) LD_SWITCH_X_SITE -#endif /* not HAVE_X11 */ -#endif /* not HAVE_X_WINDOWS */ - -#if HAVE_GPM -#ifndef LIBGPM -#define LIBGPM -lgpm -#endif /* not defined LIBGPM */ -#else /* not HAVE_GPM */ -#define LIBGPM -#endif /* not HAVE_GPM */ - -#if HAVE_LIBRESOLV -#ifndef LIBRESOLV -#define LIBRESOLV -lresolv -#endif /* not defined LIBRESOLV */ -#else /* not HAVE_LIBRESOLV */ -#define LIBRESOLV -#endif /* not HAVE_LIBRESOLV */ +## $(LIBXMU) -lXt $(LIBXTR6) -lXext if USE_X_TOOLKIT, else $(LIBXSM). +## Only used if HAVE_X_WINDOWS. +LIBXT_OTHER=@LIBXT_OTHER@ + +## If !HAVE_X11 || USE_GTK, empty. +## Else if USE_X_TOOLKIT really-lwlib, else really-oldxmenu. +OLDXMENU_TARGET=@OLDXMENU_TARGET@ + +## If !HAVE_X11 || USE_GTK, empty. +## Else if USE_X_TOOLKIT, $(lwlibdir)/liblw.a. +## Else $(oldxmenudir)/libXMenu11.a. +## (Actually, rather than being empty, it is set to "nothing". +## It is never actually used for anything in this case. +## This is done because there is a rule with target $(OLDXMENU) below, +## and I think it might be a syntax error with some makes to have +## an empty target, even if the associated rule is never run. +## http://lists.gnu.org/archive/html/help-make/2010-05/msg00058.html +## The alternative would be to put that rule in a makefile fragment.) +OLDXMENU=@OLDXMENU@ + +## If HAVE_X11 && !USE_GTK, $(OLDXMENU) ../src/$(OLDXMENU); else empty. +## We use stamp-xmenu with these two deps to both ensure that lwlib +## gets remade based on its dependencies in its own makefile, +## and remake temacs if lwlib gets changed by this. +OLDXMENU_DEPS=@OLDXMENU_DEPS@ + +## If !HAVE_X11 && HAVE_X_WINDOWS, -lXMenu (this case no longer possible). +## Else if !HAVE_X11 || USE_GTK, empty. +## Else $(OLDXMENU). +LIBXMENU=@LIBXMENU@ + +XMENU_OBJ=@XMENU_OBJ@ +XOBJ=@XOBJ@ + +TOOLKIT_LIBW=@TOOLKIT_LIBW@ + +## Only used if HAVE_X11, in LIBX_OTHER. +LIBXT=$(TOOLKIT_LIBW) $(LIBXT_OTHER) + +## If HAVE_X11, $(LIBXT) $(LIBX_EXTRA), else empty. +LIBX_OTHER=@LIBX_OTHER@ + +## LIBXMENU is nil if !HAVE_X_WINDOWS. +## LD_SWITCH_X_SITE should not be used if not using X, but nothing +## sets it at present, and if something ever does, it should be +## configure, which should set it to nil in non-X builds. +LIBX_BASE=$(LIBXMENU) $(LD_SWITCH_X_SITE) LIBSOUND= @LIBSOUND@ CFLAGS_SOUND= @CFLAGS_SOUND@ @@ -445,122 +221,127 @@ CFLAGS_SOUND= @CFLAGS_SOUND@ RSVG_LIBS= @RSVG_LIBS@ RSVG_CFLAGS= @RSVG_CFLAGS@ -#ifndef ORDINARY_LINK -/* Fix linking if compiled with GCC. */ -#ifdef __GNUC__ - -#ifdef LINKER -#define LINKER_WAS_SPECIFIED -#endif - -/* Versions of GCC >= 2.0 put their library, libgcc.a, in obscure - places that are difficult to figure out at make time. Fortunately, - these same versions allow you to pass arbitrary flags on to the - linker, so there is no reason not to use it as a linker. - - Well, it is not quite perfect. The "-nostdlib" keeps GCC from - searching for libraries in its internal directories, so we have to - ask GCC explicitly where to find libgcc.a. */ - -#ifndef LINKER -#define LINKER $(CC) -nostdlib -#endif - -#ifndef LIB_GCC -/* Ask GCC where to find libgcc.a. */ -#define LIB_GCC `$(CC) -print-libgcc-file-name` -#endif /* not LIB_GCC */ - -GNULIB_VAR = LIB_GCC - -#ifndef LINKER_WAS_SPECIFIED -/* GCC passes any argument prefixed with -Xlinker directly to the - linker. See prefix-args.c for an explanation of why we do not do - this with the shell''s ``for'' construct. - Note that some people do not have '.' in their paths, so we must - use ./prefix-args. */ -#define YMF_PASS_LDFLAGS(flags) `./prefix-args -Xlinker flags` -#else -#define YMF_PASS_LDFLAGS(flags) flags -#endif - -#else /* not __GNUC__ */ -GNULIB_VAR = - -#endif /* not __GNUC__ */ -#endif /* not ORDINARY_LINK */ - -#ifdef ORDINARY_LINK -LD = $(CC) -#else -#ifdef LINKER -LD=LINKER -#else /* not LINKER */ -LD=ld -#endif /* not LINKER */ -#endif /* not ORDINARY_LINK */ - -/* Flags to pass to LD only for temacs. */ -/* Do not split this line with a backslash. That can cause trouble with - some cpps. */ -TEMACS_LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_TEMACS LD_SWITCH_MACHINE LD_SWITCH_MACHINE_TEMACS - -/* A macro which other sections of Makefile can redefine to munge the - flags before they are passed to LD. This is helpful if you have - redefined LD to something odd, like "gcc". - (The YMF prefix is a holdover from the old name "ymakefile".) - */ -#ifndef YMF_PASS_LDFLAGS -#define YMF_PASS_LDFLAGS(flags) flags -#endif - -/* Allow config.h to specify a replacement file for unexec.c. */ -#ifndef UNEXEC -#define UNEXEC unexec.o -#endif +IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@ +IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@ + +LIBXML2_LIBS = @LIBXML2_LIBS@ +LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ + +## widget.o if USE_X_TOOLKIT, otherwise empty. +WIDGET_OBJ=@WIDGET_OBJ@ + +## sheap.o if CYGWIN, otherwise empty. +CYGWIN_OBJ=@CYGWIN_OBJ@ + +## dosfns.o msdos.o w16select.o if MSDOS. +MSDOS_OBJ = +## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. +MSDOS_X_OBJ = +MSDOS_SUPPORT_REAL = $(lispsource)/ls-lisp.elc $(lispsource)/disp-table.elc \ + $(lispsource)/dos-fns.elc $(lispsource)/dos-w32.elc $(lispsource)/dos-vars.elc \ + $(lispsource)/term/internal.elc $(lispsource)/term/pc-win.elc +## $MSDOS_SUPPORT_REAL if MSDOS. +MSDOS_SUPPORT = + +ns_appdir=@ns_appdir@ +ns_appbindir=@ns_appbindir@ +ns_appsrc=@ns_appsrc@ +NS_OBJ=@NS_OBJ@ +NS_SUPPORT=@NS_SUPPORT@ +## Only set if NS_IMPL_GNUSTEP. +GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@ + +## Empty if !HAVE_X_WINDOWS +## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT +## xfont.o ftfont.o ftxfont.o if HAVE_FREETYPE +## else xfont.o +FONT_OBJ=@FONT_OBJ@ + +## Used if HAVE_MOUSE. +REAL_MOUSE_SUPPORT=$(lispsource)/mouse.elc $(lispsource)/select.elc \ + $(lispsource)/scroll-bar.elc +## Used if HAVE_GPM && !HAVE_MOUSE +GPM_MOUSE_SUPPORT=$(lispsource)/mouse.elc +LIBGPM = @LIBGPM@ +## Either of the two preceding options, or empty. +MOUSE_SUPPORT=@MOUSE_SUPPORT@ + +## $(lispsource)/tooltip.elc if HAVE_WINDOW_SYSTEM, else empty. +TOOLTIP_SUPPORT=@TOOLTIP_SUPPORT@ + +BASE_WINDOW_SUPPORT=$(lispsource)/fringe.elc $(lispsource)/image.elc \ + $(lispsource)/international/fontset.elc $(lispsource)/dnd.elc \ + $(lispsource)/tool-bar.elc $(lispsource)/mwheel.elc + +X_WINDOW_SUPPORT=$(lispsource)/x-dnd.elc $(lispsource)/term/common-win.elc \ + $(lispsource)/term/x-win.elc $(lispsource)/dynamic-setting.elc + +## If HAVE_X_WINDOWS, both the above +## else if HAVE_WINDOW_SYSTEM (ie, HAVE_NS) just the former; else empty. +WINDOW_SUPPORT=@WINDOW_SUPPORT@ + +## -lresolv, or empty. +LIBRESOLV = @LIBRESOLV@ + +LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ + +LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ +LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ INTERVALS_H = dispextern.h intervals.h composite.h GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ -#ifdef MSDOS -#ifdef HAVE_X_WINDOWS -MSDOS_OBJ = dosfns.o msdos.o xmenu.o -#else -MSDOS_OBJ = dosfns.o msdos.o w16select.o xmenu.o -#endif -#endif - -#ifdef CYGWIN -CYGWIN_OBJ = sheap.o -#endif - -#ifdef HAVE_NS -ns_appdir=@ns_appdir@/ -ns_appbindir=@ns_appbindir@/ -ns_appresdir=@ns_appresdir@/ -ns_appsrc=@ns_appsrc@ -/* Object files for NeXTstep */ -NS_OBJ= nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ - fontset.o fringe.o image.o -#endif /* HAVE_NS */ - -#ifdef HAVE_WINDOW_SYSTEM -#ifdef HAVE_X_WINDOWS -#if defined (HAVE_XFT) -FONT_DRIVERS = xfont.o ftfont.o xftfont.o ftxfont.o -#elif defined (HAVE_FREETYPE) -FONT_DRIVERS = xfont.o ftfont.o ftxfont.o -#else /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */ -FONT_DRIVERS = xfont.o -#endif /* ! defined (HAVE_XFT) && ! defined (HAVE_FREETYPE) */ -#endif /* HAVE_X_WINDOWS */ -#endif /* HAVE_WINDOW_SYSTEM */ - -/* lastfile must follow all files - whose initialized data areas should be dumped as pure by dump-emacs. */ +RUN_TEMACS = `/bin/pwd`/temacs + +UNEXEC_OBJ = @UNEXEC_OBJ@ + +CANNOT_DUMP=@CANNOT_DUMP@ + +DEPDIR=deps +## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. +DEPFLAGS=@DEPFLAGS@ +## test -d $(DEPDIR) || mkdir $(DEPDIR) (if AUTO_DEPEND); else ':'. +MKDEPDIR=@MKDEPDIR@ + +## DO NOT use -R. There is a special hack described in lastfile.c +## which is used instead. Some initialized data areas are modified +## at initial startup, then labeled as part of the text area when +## Emacs is dumped for the first time, and never changed again. +## +## -Demacs is needed to make some files produce the correct version +## for use in Emacs. +## +## -DHAVE_CONFIG_H is needed for some other files to take advantage of +## the information in `config.h'. +## +## C_SWITCH_X_SITE must come before C_SWITCH_X_SYSTEM +## since it may have -I options that should override those. +## +## FIXME? MYCPPFLAGS only referenced in etc/DEBUG. +ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \ + $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ + $(C_SWITCH_X_SYSTEM) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ + $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ + $(GCONF_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ + $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ + $(LIBGNUTLS_CFLAGS) \ + $(C_WARNINGS_SWITCH) $(CFLAGS) +ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) + +.SUFFIXES: .m +.c.o: + @$(MKDEPDIR) + $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< +.m.o: + @$(MKDEPDIR) + $(CC) -c $(CPPFLAGS) $(ALL_OBJC_CFLAGS) $< + + +## lastfile must follow all files whose initialized data areas should +## be dumped as pure by dump-emacs. obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ - charset.o coding.o category.o ccl.o character.o chartab.o \ + charset.o coding.o category.o ccl.o character.o chartab.o bidi.o \ cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \ emacs.o keyboard.o macros.o keymap.o sysdep.o \ buffer.o filelock.o insdel.o marker.o \ @@ -568,239 +349,147 @@ obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \ alloc.o data.o doc.o editfns.o callint.o \ eval.o floatfns.o fns.o font.o print.o lread.o \ - syntax.o UNEXEC bytecode.o \ - process.o callproc.o \ + syntax.o $(UNEXEC_OBJ) bytecode.o \ + process.o gnutls.o callproc.o \ region-cache.o sound.o atimer.o \ - doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \ - $(MSDOS_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_DRIVERS) + doprnt.o strftime.o intervals.o textprop.o composite.o md5.o xml.o \ + $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) -/* Object files used on some machine or other. - These go in the DOC file on all machines - in case they are needed there. */ +## Object files used on some machine or other. +## These go in the DOC file on all machines in case they are needed. SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ fontset.o dbusbind.o \ nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ - w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONT_DRIVERS) - - -#ifdef TERMINFO -/* Used to be -ltermcap here. If your machine needs that, - define LIBS_TERMCAP in the m/MACHINE.h file. */ -#ifndef LIBS_TERMCAP -#define LIBS_TERMCAP -lcurses -#endif /* LIBS_TERMCAP */ -termcapobj = terminfo.o -#else /* ! defined (TERMINFO) */ -#ifndef LIBS_TERMCAP -#define LIBS_TERMCAP -termcapobj = termcap.o tparam.o -#else /* LIBS_TERMCAP */ -termcapobj = tparam.o -#endif /* LIBS_TERMCAP */ -#endif /* ! defined (TERMINFO) */ - - -#ifndef SYSTEM_MALLOC - -#ifndef DOUG_LEA_MALLOC -gmallocobj = gmalloc.o -#endif - -#ifdef REL_ALLOC -rallocobj = ralloc.o -#endif - -mallocobj = $(gmallocobj) $(rallocobj) vm-limit.o - -#endif /* SYSTEM_MALLOC */ - - -#ifdef USE_X_TOOLKIT -widgetobj= widget.o -#else /* not USE_X_TOOLKIT */ -widgetobj= -#endif /* not USE_X_TOOLKIT */ - - -/* define otherobj as list of object files that make-docfile - should not be told about. */ -#ifdef CYGWIN -/* Cygwin differs because of its unexec(). */ -otherobj= $(termcapobj) $(gmallocobj) $(rallocobj) lastfile.o vm-limit.o $(widgetobj) $(LIBOBJS) -#else -otherobj= $(termcapobj) lastfile.o $(mallocobj) $(widgetobj) $(LIBOBJS) -#endif - -#ifdef HAVE_MOUSE -#define MOUSE_SUPPORT ${lispsource}mouse.elc \ - ${lispsource}select.elc ${lispsource}scroll-bar.elc -#else -#ifdef HAVE_GPM -#define MOUSE_SUPPORT ${lispsource}mouse.elc -#else -#define MOUSE_SUPPORT -#endif -#endif - -#ifdef MSDOS -#define MSDOS_SUPPORT ${lispsource}ls-lisp.elc ${lispsource}disp-table.elc \ - ${lispsource}dos-fns.elc ${lispsource}dos-w32.elc ${lispsource}dos-vars.elc \ - ${lispsource}term/internal.elc ${lispsource}term/pc-win.elc - -#else -#define MSDOS_SUPPORT -#endif - -#ifdef HAVE_WINDOW_SYSTEM -#ifdef HAVE_X_WINDOWS -#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \ - ${lispsource}international/fontset.elc ${lispsource}dnd.elc \ - ${lispsource}tool-bar.elc ${lispsource}mwheel.elc ${lispsource}x-dnd.elc \ - ${lispsource}term/common-win.elc ${lispsource}term/x-win.elc \ - ${lispsource}font-setting.elc -#else -#define WINDOW_SUPPORT ${lispsource}fringe.elc ${lispsource}image.elc \ - ${lispsource}international/fontset.elc ${lispsource}dnd.elc \ - ${lispsource}tool-bar.elc ${lispsource}mwheel.elc -#endif -#else -#define WINDOW_SUPPORT -#endif - -#ifdef WINDOWSNT -#define WINNT_SUPPORT ${lispsource}ls-lisp.elc ${lispsource}disp-table.elc \ - ${lispsource}dos-w32.elc ${lispsource}w32-vars.elc \ - ${lispsource}w32-fns.elc ${lispsource}term/common-win.elc \ - ${lispsource}term/w32-win.elc -#else -#define WINNT_SUPPORT -#endif - -#ifdef HAVE_WINDOW_SYSTEM -#define TOOLTIP_SUPPORT ${lispsource}tooltip.elc -#else -#define TOOLTIP_SUPPORT -#endif - -#ifdef HAVE_NS -#define NS_SUPPORT ${lispsource}emacs-lisp/easymenu.elc \ - ${lispsource}term/ns-win.elc -#else -#define NS_SUPPORT -#endif - -/* This is the platform-specific list of Lisp files loaded into the - dumped Emacs. It is arranged like this because it is easier to generate - it semi-mechanically from loadup.el this way. - - Note that this list should not include lisp files which might not - be present, like site-load.el and site-init.el; this makefile - expects them all to be either present or buildable. - - Files which are loaded unconditionally (i.e., on all platforms) should - also be in shortlisp. Files which are loaded conditionally (i.e., only - on some platforms) should instead be in SOME_MACHINE_LISP. */ - -/* Place loaddefs.el first, so it gets generated first, since it is on - the critical path (relevant in parallel compilations). */ - + w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o $(FONT_OBJ) + +## gmalloc.o if !SYSTEM_MALLOC && !DOUG_LEA_MALLOC, else empty. +GMALLOC_OBJ=@GMALLOC_OBJ@ + +## vm-limit.o if !SYSTEM_MALLOC, else empty. +VMLIMIT_OBJ=@VMLIMIT_OBJ@ + +## ralloc.o if !SYSTEM_MALLOC && REL_ALLOC, else empty. +RALLOC_OBJ=@RALLOC_OBJ@ + +## Empty on Cygwin, lastfile.o elsewhere. +PRE_ALLOC_OBJ=@PRE_ALLOC_OBJ@ +## lastfile.o on Cygwin, empty elsewhere. +POST_ALLOC_OBJ=@POST_ALLOC_OBJ@ + +## List of object files that make-docfile should not be told about. +otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ + $(POST_ALLOC_OBJ) $(VMLIMIT_OBJ) $(WIDGET_OBJ) $(LIBOBJS) + +## This is the platform-specific list of Lisp files loaded into the +## dumped Emacs. It is arranged like this because it is easier to generate +## it semi-mechanically from loadup.el this way. +## +## Note that this list should not include lisp files which might not +## be present, like site-load.el and site-init.el; this makefile +## expects them all to be either present or buildable. +## +## Files which are loaded unconditionally (i.e., on all platforms) should +## also be in shortlisp. Files which are loaded conditionally (i.e., only +## on some platforms) should instead be in SOME_MACHINE_LISP. +## +## Place loaddefs.el first, so it gets generated first, since it is on +## the critical path (relevant in parallel compilations). lisp= \ - ${lispsource}loaddefs.el \ - ${lispsource}abbrev.elc \ - ${lispsource}buff-menu.elc \ - ${lispsource}button.elc \ - ${lispsource}emacs-lisp/byte-run.elc \ - ${lispsource}composite.elc \ - ${lispsource}cus-face.elc \ - ${lispsource}cus-start.elc \ - ${lispsource}custom.elc \ - ${lispsource}emacs-lisp/backquote.elc \ - ${lispsource}emacs-lisp/lisp-mode.elc \ - ${lispsource}emacs-lisp/lisp.elc \ - ${lispsource}env.elc \ - ${lispsource}faces.elc \ - ${lispsource}files.elc \ - ${lispsource}format.elc \ - ${lispsource}facemenu.elc \ - MOUSE_SUPPORT \ - ${lispsource}emacs-lisp/float-sup.elc \ - ${lispsource}frame.elc \ - ${lispsource}help.elc \ - ${lispsource}indent.elc \ - ${lispsource}isearch.elc \ - ${lispsource}rfn-eshadow.elc \ - ${lispsource}loadup.el \ - ${lispsource}bindings.elc \ - ${lispsource}emacs-lisp/map-ynp.elc \ - ${lispsource}menu-bar.elc \ - ${lispsource}international/mule.elc \ - ${lispsource}international/mule-conf.elc \ - ${lispsource}international/mule-cmds.elc \ - ${lispsource}international/characters.elc \ - ${lispsource}international/charprop.el \ - ${lispsource}case-table.elc \ - ${lispsource}language/chinese.elc \ - ${lispsource}language/cyrillic.elc \ - ${lispsource}language/indian.elc \ - ${lispsource}language/sinhala.el \ - ${lispsource}language/english.el \ - ${lispsource}language/ethiopic.elc \ - ${lispsource}language/european.elc \ - ${lispsource}language/czech.el \ - ${lispsource}language/slovak.el \ - ${lispsource}language/romanian.el \ - ${lispsource}language/greek.el \ - ${lispsource}language/hebrew.el \ - ${lispsource}language/japanese.el \ - ${lispsource}language/korean.el \ - ${lispsource}language/lao.el \ - ${lispsource}language/cham.el \ - ${lispsource}language/tai-viet.el \ - ${lispsource}language/thai.el \ - ${lispsource}language/tibetan.elc \ - ${lispsource}language/vietnamese.elc \ - ${lispsource}language/misc-lang.el \ - ${lispsource}language/utf-8-lang.el \ - ${lispsource}language/georgian.el \ - ${lispsource}language/khmer.el \ - ${lispsource}language/burmese.el \ - ${lispsource}paths.el \ - ${lispsource}register.elc \ - ${lispsource}replace.elc \ - ${lispsource}simple.elc \ - ${lispsource}minibuffer.elc \ - ${lispsource}startup.elc \ - ${lispsource}subr.elc \ - ${lispsource}term/tty-colors.elc \ - ${lispsource}font-core.elc \ - ${lispsource}emacs-lisp/syntax.elc \ - ${lispsource}font-lock.elc \ - ${lispsource}jit-lock.elc \ - ${lispsource}textmodes/fill.elc \ - ${lispsource}textmodes/page.elc \ - ${lispsource}textmodes/paragraphs.elc \ - ${lispsource}textmodes/text-mode.elc \ - ${lispsource}emacs-lisp/timer.elc \ - ${lispsource}jka-cmpr-hook.elc \ - ${lispsource}vc-hooks.elc \ - ${lispsource}ediff-hook.elc \ - ${lispsource}epa-hook.elc \ - TOOLTIP_SUPPORT \ - MSDOS_SUPPORT \ - WINNT_SUPPORT \ - WINDOW_SUPPORT \ - NS_SUPPORT \ - ${lispsource}widget.elc \ - ${lispsource}window.elc \ - ${lispsource}version.el - -/* List of relative names for those files from $lisp that are loaded - unconditionally (i.e. on all platforms). Files from $lisp that - are only loaded on some platforms should instead be placed in - SOME_MACHINE_LISP. The only reason this variable exists is to prevent - the make-docfile command-line getting too long for some systems. */ + $(lispsource)/loaddefs.el \ + $(lispsource)/abbrev.elc \ + $(lispsource)/buff-menu.elc \ + $(lispsource)/button.elc \ + $(lispsource)/emacs-lisp/byte-run.elc \ + $(lispsource)/composite.elc \ + $(lispsource)/cus-face.elc \ + $(lispsource)/cus-start.elc \ + $(lispsource)/custom.elc \ + $(lispsource)/emacs-lisp/backquote.elc \ + $(lispsource)/emacs-lisp/lisp-mode.elc \ + $(lispsource)/emacs-lisp/lisp.elc \ + $(lispsource)/env.elc \ + $(lispsource)/faces.elc \ + $(lispsource)/files.elc \ + $(lispsource)/format.elc \ + $(lispsource)/facemenu.elc \ + $(MOUSE_SUPPORT) \ + $(lispsource)/emacs-lisp/float-sup.elc \ + $(lispsource)/frame.elc \ + $(lispsource)/help.elc \ + $(lispsource)/indent.elc \ + $(lispsource)/isearch.elc \ + $(lispsource)/rfn-eshadow.elc \ + $(lispsource)/loadup.el \ + $(lispsource)/bindings.elc \ + $(lispsource)/emacs-lisp/map-ynp.elc \ + $(lispsource)/menu-bar.elc \ + $(lispsource)/international/mule.elc \ + $(lispsource)/international/mule-conf.elc \ + $(lispsource)/international/mule-cmds.elc \ + $(lispsource)/international/characters.elc \ + $(lispsource)/international/charprop.el \ + $(lispsource)/case-table.elc \ + $(lispsource)/language/chinese.elc \ + $(lispsource)/language/cyrillic.elc \ + $(lispsource)/language/indian.elc \ + $(lispsource)/language/sinhala.el \ + $(lispsource)/language/english.el \ + $(lispsource)/language/ethiopic.elc \ + $(lispsource)/language/european.elc \ + $(lispsource)/language/czech.el \ + $(lispsource)/language/slovak.el \ + $(lispsource)/language/romanian.el \ + $(lispsource)/language/greek.el \ + $(lispsource)/language/hebrew.elc \ + $(lispsource)/language/japanese.el \ + $(lispsource)/language/korean.el \ + $(lispsource)/language/lao.el \ + $(lispsource)/language/cham.el \ + $(lispsource)/language/tai-viet.el \ + $(lispsource)/language/thai.el \ + $(lispsource)/language/tibetan.elc \ + $(lispsource)/language/vietnamese.elc \ + $(lispsource)/language/misc-lang.el \ + $(lispsource)/language/utf-8-lang.el \ + $(lispsource)/language/georgian.el \ + $(lispsource)/language/khmer.el \ + $(lispsource)/language/burmese.el \ + $(lispsource)/paths.el \ + $(lispsource)/register.elc \ + $(lispsource)/replace.elc \ + $(lispsource)/simple.elc \ + $(lispsource)/minibuffer.elc \ + $(lispsource)/startup.elc \ + $(lispsource)/subr.elc \ + $(lispsource)/term/tty-colors.elc \ + $(lispsource)/font-core.elc \ + $(lispsource)/emacs-lisp/syntax.elc \ + $(lispsource)/font-lock.elc \ + $(lispsource)/jit-lock.elc \ + $(lispsource)/textmodes/fill.elc \ + $(lispsource)/textmodes/page.elc \ + $(lispsource)/textmodes/paragraphs.elc \ + $(lispsource)/textmodes/text-mode.elc \ + $(lispsource)/emacs-lisp/timer.elc \ + $(lispsource)/jka-cmpr-hook.elc \ + $(lispsource)/vc/vc-hooks.elc \ + $(lispsource)/vc/ediff-hook.elc \ + $(lispsource)/epa-hook.elc \ + $(TOOLTIP_SUPPORT) \ + $(MSDOS_SUPPORT) \ + $(WINDOW_SUPPORT) \ + $(NS_SUPPORT) \ + $(lispsource)/widget.elc \ + $(lispsource)/window.elc \ + $(lispsource)/version.el + +## List of relative names for those files from $lisp that are loaded +## unconditionally (i.e. on all platforms). Files from $lisp that +## are only loaded on some platforms should instead be placed in +## SOME_MACHINE_LISP. The only reason this variable exists is to prevent +## the make-docfile command-line getting too long for some systems. shortlisp= \ ../lisp/loaddefs.el \ ../lisp/abbrev.elc \ @@ -844,7 +533,7 @@ shortlisp= \ ../lisp/language/slovak.el \ ../lisp/language/romanian.el \ ../lisp/language/greek.el \ - ../lisp/language/hebrew.el \ + ../lisp/language/hebrew.elc \ ../lisp/language/japanese.el \ ../lisp/language/korean.el \ ../lisp/language/lao.el \ @@ -876,16 +565,16 @@ shortlisp= \ ../lisp/textmodes/paragraphs.elc \ ../lisp/textmodes/text-mode.elc \ ../lisp/emacs-lisp/timer.elc \ - ../lisp/vc-hooks.elc \ + ../lisp/vc/vc-hooks.elc \ + ../lisp/vc/ediff-hook.elc \ ../lisp/jka-cmpr-hook.elc \ - ../lisp/ediff-hook.elc \ ../lisp/epa-hook.elc \ ../lisp/widget.elc \ ../lisp/window.elc \ ../lisp/version.el -/* Like $shortlisp, but includes only those files from $lisp that are loaded - conditionally (i.e., only on some platforms). */ +## Like $shortlisp, but includes only those files from $lisp that are loaded +## conditionally (i.e., only on some platforms). SOME_MACHINE_LISP = ../lisp/mouse.elc \ ../lisp/select.elc ../lisp/scroll-bar.elc \ ../lisp/ls-lisp.elc ../lisp/dos-fns.elc \ @@ -894,7 +583,7 @@ SOME_MACHINE_LISP = ../lisp/mouse.elc \ ../lisp/tooltip.elc ../lisp/image.elc \ ../lisp/fringe.elc ../lisp/dnd.elc \ ../lisp/mwheel.elc ../lisp/tool-bar.elc \ - ../lisp/x-dnd.elc ../lisp/font-setting.elc \ + ../lisp/x-dnd.elc ../lisp/dynamic-setting.elc \ ../lisp/international/ccl.elc \ ../lisp/international/fontset.elc \ ../lisp/mouse.elc \ @@ -904,132 +593,87 @@ SOME_MACHINE_LISP = ../lisp/mouse.elc \ ../lisp/term/ns-win.elc ../lisp/term/w32-win.elc \ ../lisp/emacs-lisp/easymenu.elc -/* Construct full set of libraries to be linked. - Note that SunOS needs -lm to come before -lc; otherwise, you get - duplicated symbols. If the standard libraries were compiled - with GCC, we might need gnulib again after them. */ - -LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) $(RSVG_LIBS) $(DBUS_LIBS) \ - LIBGPM LIBRESOLV LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \ - LIBS_DEBUG $(GETLOADAVG_LIBS) ${GCONF_LIBS} \ - @FREETYPE_LIBS@ @FONTCONFIG_LIBS@ @LIBOTF_LIBS@ @M17N_FLT_LIBS@ \ - $(GNULIB_VAR) LIB_MATH LIB_STANDARD $(GNULIB_VAR) +## Construct full set of libraries to be linked. +## Note that SunOS needs -lm to come before -lc; otherwise, you get +## duplicated symbols. If the standard libraries were compiled +## with GCC, we might need LIB_GCC again after them. +LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ + $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ + $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ + $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(GCONF_LIBS) $(LIBSELINUX_LIBS) \ + $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ + $(LIBGNUTLS_LIBS) \ + $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) + +all: emacs$(EXEEXT) $(OTHER_FILES) + +## Does anyone ever pay attention to the load-path-shadows output here? +## The dumped Emacs is as functional and more efficient than +## bootstrap-emacs, so we replace the latter with the former. +emacs$(EXEEXT): temacs$(EXEEXT) $(etc)/DOC $(lisp) + if test "$(CANNOT_DUMP)" = "yes"; then \ + ln -f temacs$(EXEEXT) emacs$(EXEEXT); \ + EMACSLOADPATH=$(lispsource) ./emacs -q -batch \ + -f list-load-path-shadows || true; \ + else \ + LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump || exit 1; \ + ln -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \ + ./emacs -q -batch -f list-load-path-shadows || true; \ + fi -#ifdef HAVE_SHM -RUN_TEMACS = `/bin/pwd`/temacs -nl -#else -RUN_TEMACS = `/bin/pwd`/temacs -#endif - -all: emacs${EXEEXT} $(OTHER_FILES) - -emacs${EXEEXT}: temacs${EXEEXT} ${etc}DOC ${lisp} -#ifdef CANNOT_DUMP - rm -f emacs${EXEEXT} - ln temacs${EXEEXT} emacs${EXEEXT} - -EMACSLOADPATH=${lispsource} ./emacs -q -batch -f list-load-path-shadows -#else - LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump - @: This new Emacs is as functional and more efficient then - @: bootstrap-emacs, so let us replace it. - -ln -f emacs${EXEEXT} bootstrap-emacs${EXEEXT} - -./emacs -q -batch -f list-load-path-shadows -#endif /* ! defined (CANNOT_DUMP) */ - -/* We run make-docfile twice because the command line may get too long - on some systems. */ -/* ${SOME_MACHINE_OBJECTS} comes before ${obj} because some files may - or may not be included in ${obj}, but they are always included in - ${SOME_MACHINE_OBJECTS}. Since a file is processed when it is mentioned - for the first time, this prevents any variation between configurations - in the contents of the DOC file. - Likewise for ${SOME_MACHINE_LISP}. */ -/* Most of this Makefile refers to Lisp files via ${lispsource}, so - we also use ${lisp} rather than ${shortlisp} for the dependency since - the Makefile uses string equality to decide when we talk about identical - files. Apparently we pass ${shortlisp} rather than ${lisp} to make-docfile - only in order to reduce the command line length. --Stef */ -${etc}DOC: ${libsrc}make-docfile${EXEEXT} ${obj} ${lisp} ${SOME_MACHINE_LISP} - -rm -f ${etc}DOC - ${libsrc}make-docfile -d ${srcdir} ${SOME_MACHINE_OBJECTS} ${obj} > ${etc}DOC - ${libsrc}make-docfile -a ${etc}DOC -d ${srcdir} ${SOME_MACHINE_LISP} ${shortlisp} - -${libsrc}make-docfile${EXEEXT}: - cd ${libsrc}; ${MAKE} ${MFLAGS} make-docfile${EXEEXT} +## We run make-docfile twice because the command line may get too long +## on some systems. +## $(SOME_MACHINE_OBJECTS) comes before $(obj) because some files may +## or may not be included in $(obj), but they are always included in +## $(SOME_MACHINE_OBJECTS). Since a file is processed when it is mentioned +## for the first time, this prevents any variation between configurations +## in the contents of the DOC file. +## Likewise for $(SOME_MACHINE_LISP). +## Most of this Makefile refers to Lisp files via $(lispsource), so +## we also use $(lisp) rather than $(shortlisp) for the dependency since +## the Makefile uses string equality to decide when we talk about identical +## files. Apparently we pass $(shortlisp) rather than $(lisp) to make-docfile +## only in order to reduce the command line length. --Stef +$(etc)/DOC: $(libsrc)/make-docfile$(EXEEXT) $(obj) $(lisp) $(SOME_MACHINE_LISP) + -rm -f $(etc)/DOC + $(libsrc)/make-docfile -d $(srcdir) $(SOME_MACHINE_OBJECTS) $(obj) > $(etc)/DOC + $(libsrc)/make-docfile -a $(etc)/DOC -d $(srcdir) $(SOME_MACHINE_LISP) $(shortlisp) + +$(libsrc)/make-docfile$(EXEEXT): + cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT) buildobj.h: Makefile - echo "#define BUILDOBJ \"${obj} ${otherobj} " "\"" > buildobj.h - -temacs${EXEEXT}: $(LOCALCPP) $(STARTFILES) stamp-oldxmenu ${obj} ${otherobj} prefix-args${EXEEXT} -#ifdef NS_IMPL_GNUSTEP - $(CC) -rdynamic YMF_PASS_LDFLAGS ( ${TEMACS_LDFLAGS} \ - -L@GNUSTEP_SYSTEM_LIBRARIES@ -lgnustep-gui -lgnustep-base \ - -lobjc $(CONFIG_SYSTEM_LIBS) -lpthread ) -o temacs \ - ${obj} ${otherobj} ${LIBES} -#else - $(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${TEMACS_LDFLAGS}) $(LDFLAGS) \ - -o temacs ${STARTFILES} ${obj} ${otherobj} \ - ${LIBES} -#endif - -/* We do not use ALL_LDFLAGS because LD_SWITCH_SYSTEM and LD_SWITCH_MACHINE - often contain options that have to do with using Emacs''s crt0, - which are only good with temacs. */ -prefix-args${EXEEXT}: prefix-args.o $(config_h) - $(CC) $(LDFLAGS) prefix-args.o -o prefix-args - -#if defined (HAVE_X_WINDOWS) && defined (HAVE_X11) && defined (HAVE_MENUS) && ! defined (USE_GTK) - -/* We use stamp-xmenu with these two deps - to both ensure that lwlib gets remade based on its dependencies - in its own makefile, - and remake temacs if lwlib gets changed by this. */ -stamp-oldxmenu: ${OLDXMENU} ../src/$(OLDXMENU) - touch stamp-oldxmenu -/* Supply an ordering for parallel make. */ -../src/$(OLDXMENU): ${OLDXMENU} + echo "#define BUILDOBJ \"$(obj) $(otherobj) " "\"" > buildobj.h -/* Encode the values of these two macros in Make variables, - so we can use $(...) to substitute their values within "...". */ -C_SWITCH_MACHINE_1 = C_SWITCH_MACHINE -C_SWITCH_SYSTEM_1 = C_SWITCH_SYSTEM -C_SWITCH_X_SITE_1 = C_SWITCH_X_SITE -C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE -C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM -#ifdef USE_X_TOOLKIT -$(OLDXMENU): really-lwlib +temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) + $(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(TEMACS_LDFLAGS2) \ + -o temacs $(START_FILES) $(obj) $(otherobj) $(LIBES) +## The following oldxmenu-related rules are only (possibly) used if +## HAVE_X11 && !USE_GTK, but there is no harm in always defining them +## (provided we take a little care that OLDXMENU is never empty). really-lwlib: - cd ${lwlibdir}; ${MAKE} ${MFLAGS} \ - CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \ - "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \ - "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \ - "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \ - "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \ - "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)" - @true /* make -t should not create really-lwlib. */ + cd $(lwlibdir); $(MAKE) $(MFLAGS) \ + CC='$(CC)' CFLAGS='$(CFLAGS)' MAKE='$(MAKE)' + @true # make -t should not create really-lwlib. .PHONY: really-lwlib -#else /* not USE_X_TOOLKIT */ -$(OLDXMENU): really-oldXMenu really-oldXMenu: - cd ${oldXMenudir}; ${MAKE} ${MFLAGS} \ - CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \ - "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \ - "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \ - "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \ - "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \ - "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)" - @true /* make -t should not create really-oldXMenu. */ + cd $(oldxmenudir); $(MAKE) $(MFLAGS) \ + CC='$(CC)' CFLAGS='$(CFLAGS)' MAKE='$(MAKE)' + @true # make -t should not create really-oldXMenu. .PHONY: really-oldXMenu -#endif /* not USE_X_TOOLKIT */ -#else /* not (HAVE_X_WINDOWS && HAVE_X11 && HAVE_MENUS && ! USE_GTK) */ -/* We don''t really need this, but satisfy the dependency. */ -stamp-oldxmenu: +## We do not really need this when OLDXMENU_DEPS is empty, but as +## things stand we need something to satisfy the temacs dependency. +stamp-oldxmenu: $(OLDXMENU_DEPS) touch stamp-oldxmenu -#endif /* not (HAVE_X_WINDOWS && HAVE_X11 && HAVE_MENUS && ! USE_GTK) */ + +## Supply an ordering for parallel make. +../src/$(OLDXMENU): $(OLDXMENU) + +$(OLDXMENU): $(OLDXMENU_TARGET) ../config.status:: epaths.in @echo "The file epaths.h needs to be set up from epaths.in." @@ -1041,302 +685,35 @@ stamp-oldxmenu: @echo "Please run the `configure' script again." exit 1 -ecrt0.o: ecrt0.c $(config_h) -#ifdef AUTO_DEPEND - @-test -d deps || mkdir deps -#endif - CRT0_COMPILE ${srcdir}/ecrt0.c doc.o: buildobj.h -#ifndef AUTO_DEPEND - -atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \ - $(config_h) -buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \ - $(INTERVALS_H) blockinput.h atimer.h systime.h character.h \ - indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h) -callint.o: callint.c window.h commands.h buffer.h keymap.h \ - keyboard.h dispextern.h systime.h coding.h composite.h lisp.h $(config_h) -callproc.o: callproc.c epaths.h buffer.h commands.h lisp.h $(config_h) \ - process.h systty.h syssignal.h character.h coding.h ccl.h msdos.h \ - composite.h w32.h blockinput.h atimer.h systime.h frame.h termhooks.h \ - buffer.h -casefiddle.o: casefiddle.c syntax.h commands.h buffer.h character.h \ - composite.h keymap.h lisp.h $(config_h) -casetab.o: casetab.c buffer.h character.h lisp.h $(config_h) -category.o: category.c category.h buffer.h charset.h keymap.h \ - character.h lisp.h $(config_h) -ccl.o: ccl.c ccl.h charset.h character.h coding.h composite.h lisp.h $(config_h) -character.o: character.c character.h buffer.h charset.h composite.h disptab.h \ - lisp.h $(config_h) -charset.o: charset.c charset.h character.h buffer.h coding.h composite.h \ - disptab.h lisp.h $(config_h) -chartab.o: charset.h character.h ccl.h lisp.h $(config_h) -coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \ - window.h dispextern.h frame.h termhooks.h lisp.h $(config_h) -cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h lisp.h $(config_h) -cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h $(config_h) \ - msdos.h dispextern.h keyboard.h keymap.h systime.h coding.h frame.h \ - composite.h -pre-crt0.o: pre-crt0.c -dbusbind.o: dbusbind.c termhooks.h frame.h keyboard.h lisp.h $(config_h) -dired.o: dired.c commands.h buffer.h lisp.h $(config_h) character.h charset.h \ - coding.h regex.h systime.h blockinput.h atimer.h composite.h -dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \ - window.h buffer.h termchar.h termopts.h termhooks.h cm.h \ - disptab.h indent.h $(INTERVALS_H) \ - xterm.h blockinput.h atimer.h character.h msdos.h keyboard.h \ - syssignal.h lisp.h $(config_h) -doc.o: doc.c lisp.h $(config_h) epaths.h buffer.h keyboard.h keymap.h \ - character.h systime.h coding.h composite.h -doprnt.o: doprnt.c character.h lisp.h $(config_h) -dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \ - msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \ - lisp.h $(config_h) -editfns.o: editfns.c window.h buffer.h systime.h $(INTERVALS_H) character.h \ - coding.h frame.h blockinput.h atimer.h lisp.h $(config_h) -emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \ - termhooks.h buffer.h atimer.h systime.h $(INTERVALS_H) lisp.h $(config_h) \ - window.h dispextern.h keyboard.h keymap.h frame.h coding.h -fileio.o: fileio.c window.h buffer.h systime.h $(INTERVALS_H) character.h \ - coding.h msdos.h blockinput.h atimer.h lisp.h $(config_h) frame.h commands.h -filelock.o: filelock.c buffer.h character.h coding.h systime.h composite.h \ - lisp.h $(config_h) -filemode.o: filemode.c $(config_h) -frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \ - blockinput.h atimer.h systime.h buffer.h character.h fontset.h font.h \ - msdos.h dosfns.h dispextern.h w32term.h termchar.h coding.h composite.h \ - lisp.h $(config_h) termhooks.h ccl.h -fringe.o: fringe.c dispextern.h frame.h window.h buffer.h termhooks.h \ - blockinput.h atimer.h systime.h lisp.h $(config_h) -font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \ - font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h -ftfont.o: dispextern.h frame.h character.h charset.h composite.h font.h \ - lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h fontset.h \ - ccl.h ftfont.h -fontset.o: fontset.c fontset.h ccl.h buffer.h character.h \ - charset.h frame.h keyboard.h termhooks.h font.h lisp.h $(config_h) \ - blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) window.h xterm.h -getloadavg.o: getloadavg.c $(config_h) -gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \ - blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \ - charset.h coding.h syssignal.h dispextern.h composite.h -image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \ - systime.h xterm.h w32term.h w32gui.h font.h epaths.h character.h coding.h \ - nsterm.h nsgui.h lisp.h $(config_h) composite.h termhooks.h ccl.h -indent.o: indent.c frame.h window.h indent.h buffer.h lisp.h $(config_h) termchar.h \ - termopts.h disptab.h region-cache.h character.h category.h \ - keyboard.h systime.h coding.h $(INTERVALS_H) -insdel.o: insdel.c window.h buffer.h $(INTERVALS_H) blockinput.h character.h \ - dispextern.h atimer.h systime.h region-cache.h lisp.h $(config_h) -keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \ - commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \ - systime.h syntax.h $(INTERVALS_H) blockinput.h atimer.h composite.h \ - xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h coding.h \ - lisp.h $(config_h) -keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \ - atimer.h systime.h puresize.h character.h charset.h $(INTERVALS_H) keymap.h window.h \ - coding.h frame.h lisp.h $(config_h) -lastfile.o: lastfile.c $(config_h) -macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \ - dispextern.h lisp.h $(config_h) systime.h coding.h composite.h -gmalloc.o: gmalloc.c $(config_h) -ralloc.o: ralloc.c lisp.h $(config_h) -vm-limit.o: vm-limit.c mem-limits.h lisp.h $(config_h) -marker.o: marker.c buffer.h character.h lisp.h $(config_h) -md5.o: md5.c md5.h $(config_h) -minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \ - buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \ - termhooks.h lisp.h $(config_h) coding.h -mktime.o: mktime.c $(config_h) -msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \ - termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \ - keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h lisp.h $(config_h) -nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \ - dispextern.h nsgui.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \ - atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h) -nsfont.o: nsterm.h dispextern.h frame.h lisp.h lisp.h $(config_h) -nsimage.o: nsimage.m nsterm.h lisp.h $(config_h) -nsmenu.o: nsmenu.m termhooks.h frame.h window.h dispextern.h \ - nsgui.h keyboard.h blockinput.h atimer.h systime.h buffer.h \ - nsterm.h lisp.h $(config_h) -nsterm.o: nsterm.m blockinput.h atimer.h systime.h syssignal.h nsterm.h \ - nsgui.h frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h \ - termopts.h termchar.h disptab.h buffer.h window.h keyboard.h \ - $(INTERVALS_H) process.h coding.h lisp.h $(config_h) -nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h lisp.h $(config_h) -process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \ - commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \ - blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \ - keyboard.h lisp.h $(config_h) character.h xgselect.h sysselect.h -regex.o: regex.c syntax.h buffer.h lisp.h $(config_h) regex.h category.h character.h -region-cache.o: region-cache.c buffer.h region-cache.h lisp.h $(config_h) -scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \ - termhooks.h lisp.h $(config_h) systime.h coding.h composite.h window.h -search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \ - blockinput.h atimer.h systime.h category.h character.h charset.h \ - $(INTERVALS_H) \ - lisp.h $(config_h) -sound.o: sound.c dispextern.h syssignal.h lisp.h $(config_h) atimer.h systime.h -strftime.o: strftime.c $(config_h) -syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \ - keymap.h regex.h $(INTERVALS_H) lisp.h $(config_h) -sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ - process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \ - frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h $(config_h) \ - composite.h -term.o: term.c termchar.h termhooks.h termopts.h lisp.h $(config_h) cm.h frame.h \ - disptab.h keyboard.h character.h charset.h coding.h ccl.h xterm.h \ - msdos.h window.h keymap.h blockinput.h atimer.h systime.h systty.h \ - syssignal.h $(INTERVALS_H) buffer.h -termcap.o: termcap.c lisp.h $(config_h) -terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ - keyboard.h lisp.h $(config_h) dispextern.h composite.h systime.h -terminfo.o: terminfo.c lisp.h $(config_h) -tparam.o: tparam.c lisp.h $(config_h) -undo.o: undo.c buffer.h commands.h window.h dispextern.h lisp.h $(config_h) -unexaix.o: unexaix.c lisp.h $(config_h) -unexalpha.o: unexalpha.c $(config_h) -unexcw.o: unexcw.c lisp.h $(config_h) -unexec.o: unexec.c lisp.h $(config_h) -unexelf.o: unexelf.c $(config_h) -unexhp9k800.o: unexhp9k800.c $(config_h) -unexmacosx.o: unexmacosx.c $(config_h) -unexsol.o: unexsol.c lisp.h $(config_h) -unexw32.o: unexw32.c $(config_h) -w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \ - msdos.h buffer.h charset.h coding.h composite.h lisp.h $(config_h) -widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \ - $(srcdir)/../lwlib/lwlib.h lisp.h $(config_h) -window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \ - disptab.h keyboard.h msdos.h coding.h termhooks.h \ - keymap.h blockinput.h atimer.h systime.h $(INTERVALS_H) \ - xterm.h w32term.h nsterm.h lisp.h $(config_h) -xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \ - coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h \ - charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h xterm.h \ - w32term.h nsterm.h msdos.h composite.h fontset.h ccl.h \ - blockinput.h atimer.h systime.h keymap.h font.h -xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \ - window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h \ - systime.h keyboard.h fontset.h w32term.h nsterm.h coding.h ccl.h \ - $(INTERVALS_H) termchar.h termhooks.h font.h lisp.h $(config_h) -xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \ - $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \ - character.h charset.h coding.h gtkutil.h lisp.h $(config_h) termhooks.h \ - fontset.h termchar.h font.h xsettings.h $(INTERVALS_H) ccl.h -xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ - font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h -xftfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ - font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h ftfont.h -ftxfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ - font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h -menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \ - dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \ - lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h -xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \ - charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \ - systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \ - keymap.h sysselect.h -xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \ - dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \ - keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \ - coding.h process.h gtkutil.h font.h fontset.h lisp.h $(config_h) \ - xsettings.h intervals.h keymap.h xgselect.h sysselect.h -xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \ - buffer.h atimer.h systime.h termhooks.h lisp.h $(config_h) keyboard.h \ - coding.h composite.h -xgselect.o: xgselect.h systime.h sysselect.h lisp.h $(config_h) -xrdb.o: xrdb.c lisp.h $(config_h) epaths.h -xsmfns.o: xsmfns.c lisp.h $(config_h) systime.h sysselect.h termhooks.h xterm.h \ - lisp.h termopts.h frame.h dispextern.h -xsettings.o: xterm.h xsettings.h lisp.h frame.h termhooks.h $(config_h) \ - dispextern.h keyboard.h systime.h coding.h composite.h blockinput.h atimer.h \ - termopts.h -/* The files of Lisp proper */ - -alloc.o: alloc.c process.h frame.h window.h buffer.h puresize.h syssignal.h \ - keyboard.h blockinput.h atimer.h systime.h character.h lisp.h $(config_h) \ - $(INTERVALS_H) termhooks.h -bytecode.o: bytecode.c buffer.h syntax.h character.h window.h dispextern.h \ - frame.h xterm.h lisp.h $(config_h) -data.o: data.c buffer.h puresize.h character.h syssignal.h keyboard.h frame.h \ - termhooks.h systime.h coding.h composite.h dispextern.h font.h ccl.h \ - lisp.h $(config_h) -eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \ - dispextern.h lisp.h $(config_h) coding.h composite.h xterm.h -floatfns.o: floatfns.c syssignal.h lisp.h $(config_h) -fns.o: fns.c commands.h lisp.h $(config_h) frame.h buffer.h character.h keyboard.h \ - keymap.h window.h dispextern.h $(INTERVALS_H) coding.h md5.h \ - blockinput.h atimer.h systime.h xterm.h -print.o: print.c process.h frame.h window.h buffer.h keyboard.h character.h \ - lisp.h $(config_h) termchar.h $(INTERVALS_H) msdos.h termhooks.h \ - blockinput.h atimer.h systime.h font.h charset.h coding.h ccl.h -lread.o: lread.c commands.h keyboard.h buffer.h epaths.h character.h \ - charset.h lisp.h $(config_h) $(INTERVALS_H) termhooks.h coding.h msdos.h \ - systime.h frame.h blockinput.h atimer.h - -/* Text properties support */ -composite.o: composite.c buffer.h character.h coding.h font.h ccl.h \ - frame.h termhooks.h $(INTERVALS_H) window.h lisp.h $(config_h) -intervals.o: intervals.c buffer.h $(INTERVALS_H) keyboard.h puresize.h \ - keymap.h lisp.h $(config_h) systime.h coding.h -textprop.o: textprop.c buffer.h window.h $(INTERVALS_H) \ - lisp.h $(config_h) - -#endif /* ! AUTO_DEPEND */ - -/* System-specific programs to be made. - OTHER_FILES - select which of these should be compiled. */ - -#ifdef HAVE_NS -/* In fact, every .o file depends directly or indirectly on dispextern.h - and hence nsgui.h under NS. But the ones that actually use stuff there - are more limited. */ -dispnew.o font.o fontset.o frame.o fringe.o image.o keyboard.o menu.o \ - window.o xdisp.o xfaces.o: nsgui.h - -${ns_appdir}: ${ns_appsrc} - rm -fr ${ns_appdir} - mkdir -p ${ns_appdir} - ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; tar xf - ) - ( cd ${ns_appdir} ; for subdir in `find . -type d ! -name CVS -print` ; do \ - chmod a+rx $${subdir} ; \ - rm -rf $${subdir}/CVS ; \ - rm -f $${subdir}/.cvsignore ; done ; ) - -${ns_appbindir}Emacs: emacs${EXEEXT} - mkdir -p ${ns_appbindir} - cp -f emacs${EXEEXT} ${ns_appbindir}Emacs - -ns-app: ${ns_appdir} ${ns_appbindir}Emacs - -#endif /* HAVE_NS */ + +## If HAVE_NS, some ns-specific rules (for OTHER_FILES) are inserted here. +@ns_frag@ + mostlyclean: - rm -f temacs${EXEEXT} prefix-args${EXEEXT} core *.core \#* *.o libXMenu11.a liblw.a + rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a rm -f ../etc/DOC - rm -f bootstrap-emacs${EXEEXT} emacs-${version}${EXEEXT} + rm -f bootstrap-emacs$(EXEEXT) emacs-$(version)$(EXEEXT) rm -f buildobj.h clean: mostlyclean - rm -f emacs-*.*.*${EXEEXT} emacs${EXEEXT} - -rm -rf deps -#ifdef HAVE_NS - rm -fr ${ns_appdir} -#endif -/* bootstrap-clean is used to clean up just before a bootstrap. - It should remove all files generated during a compilation/bootstrap, - but not things like config.status or TAGS. */ + rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT) + -rm -rf $(DEPDIR) + test "X$(ns_appdir)" = "X" || rm -rf $(ns_appdir) + +## bootstrap-clean is used to clean up just before a bootstrap. +## It should remove all files generated during a compilation/bootstrap, +## but not things like config.status or TAGS. bootstrap-clean: clean - rm -f epaths.h config.h Makefile.c config.stamp stamp-oldxmenu ../etc/DOC-* + rm -f epaths.h config.h config.stamp stamp-oldxmenu ../etc/DOC-* if test -f ./.gdbinit; then \ mv ./.gdbinit ./.gdbinit.save; \ - if test -f "${srcdir}/.gdbinit"; then rm -f ./.gdbinit.save; \ + if test -f "$(srcdir)/.gdbinit"; then rm -f ./.gdbinit.save; \ else mv ./.gdbinit.save ./.gdbinit; fi; \ fi -/**/# This is used in making a distribution. -/**/# Do not use it on development directories! +## This is used in making a distribution. +## Do not use it on development directories! distclean: bootstrap-clean rm -f Makefile maintainer-clean: distclean @@ -1344,84 +721,87 @@ maintainer-clean: distclean @echo "it deletes files that may require special tools to rebuild." rm -f TAGS versionclean: - -rm -f emacs${EXEEXT} emacs-*.*.*${EXEEXT} ../etc/DOC* + -rm -f emacs$(EXEEXT) emacs-*.*.*$(EXEEXT) ../etc/DOC* extraclean: distclean -rm -f *~ \#* m/?*~ s/?*~ -/* Arrange to make a tags table TAGS-LISP for ../lisp, - plus TAGS for the C files, which includes ../lisp/TAGS by reference. */ +## Arrange to make a tags table TAGS-LISP for ../lisp, +## plus TAGS for the C files, which includes ../lisp/TAGS by reference. ctagsfiles1 = [xyzXYZ]*.[hcm] ctagsfiles2 = [a-wA-W]*.[hcm] TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) - ../lib-src/etags --include=TAGS-LISP --include=${lwlibdir}/TAGS \ + ../lib-src/etags --include=TAGS-LISP --include=$(lwlibdir)/TAGS \ --regex='/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/' \ $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) frc: TAGS-LISP: frc - $(MAKE) -f ${lispdir}Makefile TAGS-LISP ETAGS=../lib-src/etags + $(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags -$(lwlibdir)TAGS: - (cd $(lwlibdir); $(MAKE) -f $(lwlibdir)Makefile tags ETAGS=../lib-src/etags) +$(lwlibdir)/TAGS: + (cd $(lwlibdir); $(MAKE) -f $(lwlibdir)/Makefile tags ETAGS=../lib-src/etags) -tags: TAGS TAGS-LISP $(lwlibdir)TAGS +tags: TAGS TAGS-LISP $(lwlibdir)/TAGS .PHONY: tags -/* Bootstrapping. */ -/* Bootstrapping right is difficult because of the circular dependencies. - Furthermore, we have to deal with the fact that many compilation targets - such as loaddefs.el or *.elc can typically be produced by any old - Emacs executable, so we would like to avoid rebuilding them whenever - we build a new Emacs executable. - To solve the circularity, we use 2 different Emacs executables, - "emacs" is the main target and "bootstrap-emacs" is the one used - to build the *.elc and loaddefs.el files. - To solve the freshness issue, we used to use a third file "witness-emacs" - which was used to witness the fact that there is a bootstrap-emacs - executable, and then have dependencies on witness-emacs rather than - bootstrap-emacs, but that lead to problems in parallel builds (because - witness-emacs needed to be free from dependencies (to avoid rebuilding - it), so it was compiled in parallel, leading typically to having 2 - processes dumping bootstrap-emacs at the same time). - So instead, we replace the witness-emacs dependencies by conditional - bootstrap-dependencies (via ${BOOTSTRAPEMACS}). Of course, since we do - not want to rely on GNU Make features, we have to rely on an external - script to do the conditional part of the dependency - (i.e. see the ${SUBDIR} rule ../Makefile.in). */ +### Bootstrapping. + +## Bootstrapping right is difficult because of the circular dependencies. +## Furthermore, we have to deal with the fact that many compilation targets +## such as loaddefs.el or *.elc can typically be produced by any old +## Emacs executable, so we would like to avoid rebuilding them whenever +## we build a new Emacs executable. +## To solve the circularity, we use 2 different Emacs executables, +## "emacs" is the main target and "bootstrap-emacs" is the one used +## to build the *.elc and loaddefs.el files. +## To solve the freshness issue, we used to use a third file "witness-emacs" +## which was used to witness the fact that there is a bootstrap-emacs +## executable, and then have dependencies on witness-emacs rather than +## bootstrap-emacs, but that lead to problems in parallel builds (because +## witness-emacs needed to be free from dependencies (to avoid rebuilding +## it), so it was compiled in parallel, leading typically to having 2 +## processes dumping bootstrap-emacs at the same time). +## So instead, we replace the witness-emacs dependencies by conditional +## bootstrap-dependencies (via $(BOOTSTRAPEMACS)). Of course, since we do +## not want to rely on GNU Make features, we have to rely on an external +## script to do the conditional part of the dependency +## (i.e. see the $(SUBDIR) rule ../Makefile.in). .SUFFIXES: .elc .el -/* These suffix rules do not allow additional dependencies, sadly, so - instead of adding a $(BOOTSTRAPEMACS) dependency here, we add it - separately below. - With GNU Make, we would just say "%.el : %.elc $(BOOTSTRAPEMACS)" */ +## These suffix rules do not allow additional dependencies, sadly, so +## instead of adding a $(BOOTSTRAPEMACS) dependency here, we add it +## separately below. +## With GNU Make, we would just say "%.el : %.elc $(BOOTSTRAPEMACS)" .el.elc: @cd ../lisp; $(MAKE) $(MFLAGS) compile-onefile \ - THEFILE=$< EMACS=${bootstrap_exe} - -/* Since the .el.elc rule cannot specify an extra dependency, we do it here. */ -${lisp} ${SOME_MACHINE_LISP}: $(BOOTSTRAPEMACS) + THEFILE=$< EMACS=$(bootstrap_exe) -${lispsource}loaddefs.el: $(BOOTSTRAPEMACS) - cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=${bootstrap_exe} +## Since the .el.elc rule cannot specify an extra dependency, we do it here. +$(lisp) $(SOME_MACHINE_LISP): $(BOOTSTRAPEMACS) -/* Dump an Emacs executable named bootstrap-emacs containing the - files from loadup.el in source form. */ +## VCSWITNESS points to the file that holds info about the current checkout. +## We use it as a heuristic to decide when to rebuild loaddefs.el. +$(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS) + cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=$(bootstrap_exe) -bootstrap-emacs${EXEEXT}: temacs${EXEEXT} +## Dump an Emacs executable named bootstrap-emacs containing the +## files from loadup.el in source form. +bootstrap-emacs$(EXEEXT): temacs$(EXEEXT) cd ../lisp; $(MAKE) $(MFLAGS) update-subdirs -#ifdef CANNOT_DUMP - ln -f temacs${EXEEXT} bootstrap-emacs${EXEEXT} -#else - $(RUN_TEMACS) --batch --load loadup bootstrap - mv -f emacs${EXEEXT} bootstrap-emacs${EXEEXT} -#endif /* ! defined (CANNOT_DUMP) */ + if test "$(CANNOT_DUMP)" = "yes"; then \ + ln -f temacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \ + else \ + $(RUN_TEMACS) --batch --load loadup bootstrap || exit 1; \ + mv -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \ + fi @: Compile some files earlier to speed up further compilation. - cd ../lisp; $(MAKE) $(MFLAGS) compile-first EMACS=${bootstrap_exe} + cd ../lisp; $(MAKE) $(MFLAGS) compile-first EMACS=$(bootstrap_exe) + +## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk. +@deps_frag@ + -#ifdef AUTO_DEPEND -ALLOBJS=$(STARTFILES) ${obj} ${otherobj} prefix-args.o --include $(ALLOBJS:%.o=deps/%.d) -#endif +### Makefile.in ends here diff --git a/src/README b/src/README index 679fc961e53..b4ce91b150a 100644 --- a/src/README +++ b/src/README @@ -1,5 +1,5 @@ -Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. +Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. See the end of the file for license conditions. @@ -10,12 +10,10 @@ and installed, if the dumped Emacs (on Unix systems) is copied elsewhere. See the files ../README and then ../INSTALL for installation instructions. Under GNU and Unix systems, the file `Makefile.in' is used as a -template by the script `../configure' to produce `Makefile.c'. The -same script then uses `cpp' to produce the machine-dependent -`Makefile' from `Makefile.c'; `Makefile' is the file which actually -controls the compilation of Emacs. Most of this should work -transparently to the user; you should only need to run `../configure', -and then type `make'. +template by the script `../configure' to produce `Makefile'. This +is the file which actually controls the compilation of Emacs. +All of this should work transparently to the user; you should only +need to run `../configure', and then type `make'. This file is part of GNU Emacs. diff --git a/src/alloc.c b/src/alloc.c index da63fe0f82b..fa39c1ee5dc 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -23,10 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <limits.h> /* For CHAR_BIT. */ #include <setjmp.h> -#ifdef STDC_HEADERS -#include <stddef.h> /* For offsetof, used by PSEUDOVECSIZE. */ -#endif - #ifdef ALLOC_DEBUG #undef INLINE #endif @@ -69,16 +65,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ extern POINTER_TYPE *sbrk (); #endif -#ifdef HAVE_FCNTL_H -#define INCLUDED_FCNTL #include <fcntl.h> -#endif -#ifndef O_WRONLY -#define O_WRONLY 1 -#endif #ifdef WINDOWSNT -#include <fcntl.h> #include "w32.h" #endif @@ -219,16 +208,6 @@ int abort_on_gc; int garbage_collection_messages; -#ifndef VIRT_ADDR_VARIES -extern -#endif /* VIRT_ADDR_VARIES */ -int malloc_sbrk_used; - -#ifndef VIRT_ADDR_VARIES -extern -#endif /* VIRT_ADDR_VARIES */ -int malloc_sbrk_unused; - /* Number of live and free conses etc. */ static int total_conses, total_markers, total_symbols, total_vector_size; @@ -257,8 +236,6 @@ Lisp_Object Vpurify_flag; Lisp_Object Vmemory_full; -#ifndef HAVE_SHM - /* Initialize it to a nonzero value to force it into data space (rather than bss space). That way unexec will remap it into text space (pure), on some systems. We have not implemented the @@ -268,13 +245,6 @@ Lisp_Object Vmemory_full; EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,}; #define PUREBEG (char *) pure -#else /* HAVE_SHM */ - -#define pure PURE_SEG_BITS /* Use shared memory segment */ -#define PUREBEG (char *)PURE_SEG_BITS - -#endif /* HAVE_SHM */ - /* Pointer to the pure area, and its size. */ static char *purebeg; @@ -308,7 +278,7 @@ static EMACS_INT pure_bytes_used_non_lisp; /* If nonzero, this is a warning delivered by malloc and not yet displayed. */ -char *pending_malloc_warning; +const char *pending_malloc_warning; /* Pre-computed signal argument for use when memory is exhausted. */ @@ -339,23 +309,23 @@ Lisp_Object Vpost_gc_hook, Qpost_gc_hook; Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */ EMACS_INT gcs_done; /* accumulated GCs */ -static void mark_buffer P_ ((Lisp_Object)); -static void mark_terminals P_ ((void)); -extern void mark_kboards P_ ((void)); -extern void mark_ttys P_ ((void)); -extern void mark_backtrace P_ ((void)); -static void gc_sweep P_ ((void)); -static void mark_glyph_matrix P_ ((struct glyph_matrix *)); -static void mark_face_cache P_ ((struct face_cache *)); +static void mark_buffer (Lisp_Object); +static void mark_terminals (void); +extern void mark_kboards (void); +extern void mark_ttys (void); +extern void mark_backtrace (void); +static void gc_sweep (void); +static void mark_glyph_matrix (struct glyph_matrix *); +static void mark_face_cache (struct face_cache *); #ifdef HAVE_WINDOW_SYSTEM -extern void mark_fringe_data P_ ((void)); +extern void mark_fringe_data (void); #endif /* HAVE_WINDOW_SYSTEM */ -static struct Lisp_String *allocate_string P_ ((void)); -static void compact_small_strings P_ ((void)); -static void free_large_strings P_ ((void)); -static void sweep_strings P_ ((void)); +static struct Lisp_String *allocate_string (void); +static void compact_small_strings (void); +static void free_large_strings (void); +static void sweep_strings (void); extern int message_enable_multibyte; @@ -379,9 +349,9 @@ enum mem_type MEM_TYPE_VECTORLIKE }; -static POINTER_TYPE *lisp_align_malloc P_ ((size_t, enum mem_type)); -static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); -void refill_memory_reserve (); +static POINTER_TYPE *lisp_align_malloc (size_t, enum mem_type); +static POINTER_TYPE *lisp_malloc (size_t, enum mem_type); +void refill_memory_reserve (void); #if GC_MARK_STACK || defined GC_MALLOC_CHECK @@ -462,31 +432,30 @@ static void *min_heap_address, *max_heap_address; static struct mem_node mem_z; #define MEM_NIL &mem_z -static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type)); -static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT)); -static void lisp_free P_ ((POINTER_TYPE *)); -static void mark_stack P_ ((void)); -static int live_vector_p P_ ((struct mem_node *, void *)); -static int live_buffer_p P_ ((struct mem_node *, void *)); -static int live_string_p P_ ((struct mem_node *, void *)); -static int live_cons_p P_ ((struct mem_node *, void *)); -static int live_symbol_p P_ ((struct mem_node *, void *)); -static int live_float_p P_ ((struct mem_node *, void *)); -static int live_misc_p P_ ((struct mem_node *, void *)); -static void mark_maybe_object P_ ((Lisp_Object)); -static void mark_memory P_ ((void *, void *, int)); -static void mem_init P_ ((void)); -static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type)); -static void mem_insert_fixup P_ ((struct mem_node *)); -static void mem_rotate_left P_ ((struct mem_node *)); -static void mem_rotate_right P_ ((struct mem_node *)); -static void mem_delete P_ ((struct mem_node *)); -static void mem_delete_fixup P_ ((struct mem_node *)); -static INLINE struct mem_node *mem_find P_ ((void *)); +static struct Lisp_Vector *allocate_vectorlike (EMACS_INT); +static void lisp_free (POINTER_TYPE *); +static void mark_stack (void); +static int live_vector_p (struct mem_node *, void *); +static int live_buffer_p (struct mem_node *, void *); +static int live_string_p (struct mem_node *, void *); +static int live_cons_p (struct mem_node *, void *); +static int live_symbol_p (struct mem_node *, void *); +static int live_float_p (struct mem_node *, void *); +static int live_misc_p (struct mem_node *, void *); +static void mark_maybe_object (Lisp_Object); +static void mark_memory (void *, void *, int); +static void mem_init (void); +static struct mem_node *mem_insert (void *, void *, enum mem_type); +static void mem_insert_fixup (struct mem_node *); +static void mem_rotate_left (struct mem_node *); +static void mem_rotate_right (struct mem_node *); +static void mem_delete (struct mem_node *); +static void mem_delete_fixup (struct mem_node *); +static INLINE struct mem_node *mem_find (void *); #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS -static void check_gcpros P_ ((void)); +static void check_gcpros (void); #endif #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */ @@ -505,7 +474,7 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; static int staticidx = 0; -static POINTER_TYPE *pure_alloc P_ ((size_t, int)); +static POINTER_TYPE *pure_alloc (size_t, int); /* Value is SZ rounded up to the next multiple of ALIGNMENT. @@ -524,8 +493,7 @@ static POINTER_TYPE *pure_alloc P_ ((size_t, int)); /* Function malloc calls this if it finds we are near exhausting storage. */ void -malloc_warning (str) - char *str; +malloc_warning (const char *str) { pending_malloc_warning = str; } @@ -534,7 +502,7 @@ malloc_warning (str) /* Display an already-pending malloc warning. */ void -display_malloc_warning () +display_malloc_warning (void) { call3 (intern ("display-warning"), intern ("alloc"), @@ -553,7 +521,7 @@ display_malloc_warning () /* Called if we can't allocate relocatable space for a buffer. */ void -buffer_memory_full () +buffer_memory_full (void) { /* If buffers use the relocating allocator, no need to free spare_memory, because we may have plenty of malloc space left @@ -647,10 +615,12 @@ overrun_check_malloc (size) val = (unsigned char *) malloc (size + overhead); if (val && check_depth == 1) { - bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4); + memcpy (val, xmalloc_overrun_check_header, + XMALLOC_OVERRUN_CHECK_SIZE - 4); val += XMALLOC_OVERRUN_CHECK_SIZE; XMALLOC_PUT_SIZE(val, size); - bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE); + memcpy (val + size, xmalloc_overrun_check_trailer, + XMALLOC_OVERRUN_CHECK_SIZE); } --check_depth; return (POINTER_TYPE *)val; @@ -670,28 +640,29 @@ overrun_check_realloc (block, size) if (val && check_depth == 1 - && bcmp (xmalloc_overrun_check_header, - val - XMALLOC_OVERRUN_CHECK_SIZE, - XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) + && memcmp (xmalloc_overrun_check_header, + val - XMALLOC_OVERRUN_CHECK_SIZE, + XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) { size_t osize = XMALLOC_GET_SIZE (val); - if (bcmp (xmalloc_overrun_check_trailer, - val + osize, - XMALLOC_OVERRUN_CHECK_SIZE)) + if (memcmp (xmalloc_overrun_check_trailer, val + osize, + XMALLOC_OVERRUN_CHECK_SIZE)) abort (); - bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE); + memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); val -= XMALLOC_OVERRUN_CHECK_SIZE; - bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); + memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE); } val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead); if (val && check_depth == 1) { - bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4); + memcpy (val, xmalloc_overrun_check_header, + XMALLOC_OVERRUN_CHECK_SIZE - 4); val += XMALLOC_OVERRUN_CHECK_SIZE; XMALLOC_PUT_SIZE(val, size); - bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE); + memcpy (val + size, xmalloc_overrun_check_trailer, + XMALLOC_OVERRUN_CHECK_SIZE); } --check_depth; return (POINTER_TYPE *)val; @@ -708,22 +679,21 @@ overrun_check_free (block) ++check_depth; if (val && check_depth == 1 - && bcmp (xmalloc_overrun_check_header, - val - XMALLOC_OVERRUN_CHECK_SIZE, - XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) + && memcmp (xmalloc_overrun_check_header, + val - XMALLOC_OVERRUN_CHECK_SIZE, + XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0) { size_t osize = XMALLOC_GET_SIZE (val); - if (bcmp (xmalloc_overrun_check_trailer, - val + osize, - XMALLOC_OVERRUN_CHECK_SIZE)) + if (memcmp (xmalloc_overrun_check_trailer, val + osize, + XMALLOC_OVERRUN_CHECK_SIZE)) abort (); #ifdef XMALLOC_CLEAR_FREE_MEMORY val -= XMALLOC_OVERRUN_CHECK_SIZE; memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_SIZE*2); #else - bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE); + memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); val -= XMALLOC_OVERRUN_CHECK_SIZE; - bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); + memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE); #endif } @@ -752,8 +722,7 @@ overrun_check_free (block) /* Like malloc but check for no memory and block interrupt input.. */ POINTER_TYPE * -xmalloc (size) - size_t size; +xmalloc (size_t size) { register POINTER_TYPE *val; @@ -770,9 +739,7 @@ xmalloc (size) /* Like realloc but check for no memory and block interrupt input.. */ POINTER_TYPE * -xrealloc (block, size) - POINTER_TYPE *block; - size_t size; +xrealloc (POINTER_TYPE *block, size_t size) { register POINTER_TYPE *val; @@ -793,8 +760,7 @@ xrealloc (block, size) /* Like free but block interrupt input. */ void -xfree (block) - POINTER_TYPE *block; +xfree (POINTER_TYPE *block) { if (!block) return; @@ -810,12 +776,11 @@ xfree (block) /* Like strdup, but uses xmalloc. */ char * -xstrdup (s) - const char *s; +xstrdup (const char *s) { size_t len = strlen (s) + 1; char *p = (char *) xmalloc (len); - bcopy (s, p, len); + memcpy (p, s, len); return p; } @@ -823,8 +788,7 @@ xstrdup (s) /* Unwind for SAFE_ALLOCA */ Lisp_Object -safe_alloca_unwind (arg) - Lisp_Object arg; +safe_alloca_unwind (Lisp_Object arg) { register struct Lisp_Save_Value *p = XSAVE_VALUE (arg); @@ -845,9 +809,7 @@ static void *lisp_malloc_loser; #endif static POINTER_TYPE * -lisp_malloc (nbytes, type) - size_t nbytes; - enum mem_type type; +lisp_malloc (size_t nbytes, enum mem_type type) { register void *val; @@ -891,8 +853,7 @@ lisp_malloc (nbytes, type) call to lisp_malloc. */ static void -lisp_free (block) - POINTER_TYPE *block; +lisp_free (POINTER_TYPE *block) { MALLOC_BLOCK_INPUT; free (block); @@ -991,9 +952,7 @@ static struct ablock *free_ablock; Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be smaller or equal to BLOCK_BYTES. */ static POINTER_TYPE * -lisp_align_malloc (nbytes, type) - size_t nbytes; - enum mem_type type; +lisp_align_malloc (size_t nbytes, enum mem_type type) { void *base, *val; struct ablocks *abase; @@ -1100,8 +1059,7 @@ lisp_align_malloc (nbytes, type) } static void -lisp_align_free (block) - POINTER_TYPE *block; +lisp_align_free (POINTER_TYPE *block) { struct ablock *ablock = block; struct ablocks *abase = ABLOCK_ABASE (ablock); @@ -1146,7 +1104,7 @@ lisp_align_free (block) a call to lisp_malloc. */ struct buffer * -allocate_buffer () +allocate_buffer (void) { struct buffer *b = (struct buffer *) lisp_malloc (sizeof (struct buffer), @@ -1174,21 +1132,19 @@ allocate_buffer () there's no need to block input around malloc. */ #ifndef DOUG_LEA_MALLOC -extern void * (*__malloc_hook) P_ ((size_t, const void *)); -extern void * (*__realloc_hook) P_ ((void *, size_t, const void *)); -extern void (*__free_hook) P_ ((void *, const void *)); +extern void * (*__malloc_hook) (size_t, const void *); +extern void * (*__realloc_hook) (void *, size_t, const void *); +extern void (*__free_hook) (void *, const void *); /* Else declared in malloc.h, perhaps with an extra arg. */ #endif /* DOUG_LEA_MALLOC */ -static void * (*old_malloc_hook) P_ ((size_t, const void *)); -static void * (*old_realloc_hook) P_ ((void *, size_t, const void*)); -static void (*old_free_hook) P_ ((void*, const void*)); +static void * (*old_malloc_hook) (size_t, const void *); +static void * (*old_realloc_hook) (void *, size_t, const void*); +static void (*old_free_hook) (void*, const void*); /* This function is used as the hook for free to call. */ static void -emacs_blocked_free (ptr, ptr2) - void *ptr; - const void *ptr2; +emacs_blocked_free (void *ptr, const void *ptr2) { BLOCK_INPUT_ALLOC; @@ -1236,9 +1192,7 @@ emacs_blocked_free (ptr, ptr2) /* This function is the malloc hook that Emacs uses. */ static void * -emacs_blocked_malloc (size, ptr) - size_t size; - const void *ptr; +emacs_blocked_malloc (size_t size, const void *ptr) { void *value; @@ -1285,10 +1239,7 @@ emacs_blocked_malloc (size, ptr) /* This function is the realloc hook that Emacs uses. */ static void * -emacs_blocked_realloc (ptr, size, ptr2) - void *ptr; - size_t size; - const void *ptr2; +emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) { void *value; @@ -1362,7 +1313,7 @@ reset_malloc_hooks () /* Called from main to set up malloc to use our hooks. */ void -uninterrupt_malloc () +uninterrupt_malloc (void) { #ifdef HAVE_GTK_AND_PTHREAD #ifdef DOUG_LEA_MALLOC @@ -1374,7 +1325,7 @@ uninterrupt_malloc () pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init (&alloc_mutex, &attr); #else /* !DOUG_LEA_MALLOC */ - /* Some systems such as Solaris 2.6 doesn't have a recursive mutex, + /* Some systems such as Solaris 2.6 don't have a recursive mutex, and the bundled gmalloc.c doesn't require it. */ pthread_mutex_init (&alloc_mutex, NULL); #endif /* !DOUG_LEA_MALLOC */ @@ -1444,7 +1395,7 @@ static int n_interval_blocks; /* Initialize interval allocation. */ static void -init_intervals () +init_intervals (void) { interval_block = NULL; interval_block_index = INTERVAL_BLOCK_SIZE; @@ -1456,7 +1407,7 @@ init_intervals () /* Return a new interval. */ INTERVAL -make_interval () +make_interval (void) { INTERVAL val; @@ -1499,9 +1450,7 @@ make_interval () /* Mark Lisp objects in interval I. */ static void -mark_interval (i, dummy) - register INTERVAL i; - Lisp_Object dummy; +mark_interval (register INTERVAL i, Lisp_Object dummy) { eassert (!i->gcmarkbit); /* Intervals are never shared. */ i->gcmarkbit = 1; @@ -1513,8 +1462,7 @@ mark_interval (i, dummy) use the macro MARK_INTERVAL_TREE instead. */ static void -mark_interval_tree (tree) - register INTERVAL tree; +mark_interval_tree (register INTERVAL tree) { /* No need to test if this tree has been marked already; this function is always called through the MARK_INTERVAL_TREE macro, @@ -1690,7 +1638,7 @@ static int total_strings, total_free_strings; /* Number of bytes used by live strings. */ -static int total_string_size; +static EMACS_INT total_string_size; /* Given a pointer to a Lisp_String S which is on the free-list string_free_list, return a pointer to its successor in the @@ -1761,7 +1709,7 @@ static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = /* Initialize string allocation. Called from init_alloc_once. */ static void -init_strings () +init_strings (void) { total_strings = total_free_strings = total_string_size = 0; oldest_sblock = current_sblock = large_sblocks = NULL; @@ -1777,19 +1725,20 @@ init_strings () static int check_string_bytes_count; -static void check_string_bytes P_ ((int)); -static void check_sblock P_ ((struct sblock *)); +static void check_string_bytes (int); +static void check_sblock (struct sblock *); #define CHECK_STRING_BYTES(S) STRING_BYTES (S) /* Like GC_STRING_BYTES, but with debugging check. */ -int -string_bytes (s) - struct Lisp_String *s; +EMACS_INT +string_bytes (struct Lisp_String *s) { - int nbytes = (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); + EMACS_INT nbytes = + (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); + if (!PURE_POINTER_P (s) && s->data && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) @@ -1811,7 +1760,7 @@ check_sblock (b) { /* Compute the next FROM here because copying below may overwrite data we need to compute it. */ - int nbytes; + EMACS_INT nbytes; /* Check that the string size recorded in the string is the same as the one recorded in the sdata structure. */ @@ -1871,7 +1820,7 @@ check_string_free_list () s = string_free_list; while (s != NULL) { - if ((unsigned)s < 1024) + if ((unsigned long)s < 1024) abort(); s = NEXT_FREE_LISP_STRING (s); } @@ -1883,7 +1832,7 @@ check_string_free_list () /* Return a new Lisp_String. */ static struct Lisp_String * -allocate_string () +allocate_string (void) { struct Lisp_String *s; @@ -1899,7 +1848,7 @@ allocate_string () int i; b = (struct string_block *) lisp_malloc (sizeof *b, MEM_TYPE_STRING); - bzero (b, sizeof *b); + memset (b, 0, sizeof *b); b->next = string_blocks; string_blocks = b; ++n_string_blocks; @@ -1923,7 +1872,7 @@ allocate_string () MALLOC_UNBLOCK_INPUT; /* Probably not strictly necessary, but play it safe. */ - bzero (s, sizeof *s); + memset (s, 0, sizeof *s); --total_free_strings; ++total_strings; @@ -1954,13 +1903,12 @@ allocate_string () S->data if it was initially non-null. */ void -allocate_string_data (s, nchars, nbytes) - struct Lisp_String *s; - int nchars, nbytes; +allocate_string_data (struct Lisp_String *s, + EMACS_INT nchars, EMACS_INT nbytes) { struct sdata *data, *old_data; struct sblock *b; - int needed, old_nbytes; + EMACS_INT needed, old_nbytes; /* Determine the number of bytes needed to store NBYTES bytes of string data. */ @@ -2033,8 +1981,7 @@ allocate_string_data (s, nchars, nbytes) s->size_byte = nbytes; s->data[nbytes] = '\0'; #ifdef GC_CHECK_STRING_OVERRUN - bcopy (string_overrun_cookie, (char *) data + needed, - GC_STRING_OVERRUN_COOKIE_SIZE); + memcpy (data + needed, string_overrun_cookie, GC_STRING_OVERRUN_COOKIE_SIZE); #endif /* If S had already data assigned, mark that as free by setting its @@ -2053,7 +2000,7 @@ allocate_string_data (s, nchars, nbytes) /* Sweep and compact strings. */ static void -sweep_strings () +sweep_strings (void) { struct string_block *b, *next; struct string_block *live_blocks = NULL; @@ -2153,7 +2100,7 @@ sweep_strings () /* Free dead large strings. */ static void -free_large_strings () +free_large_strings (void) { struct sblock *b, *next; struct sblock *live_blocks = NULL; @@ -2179,7 +2126,7 @@ free_large_strings () data of live strings after compaction. */ static void -compact_small_strings () +compact_small_strings (void) { struct sblock *b, *tb, *next; struct sdata *from, *to, *end, *tb_end; @@ -2203,7 +2150,7 @@ compact_small_strings () { /* Compute the next FROM here because copying below may overwrite data we need to compute it. */ - int nbytes; + EMACS_INT nbytes; #ifdef GC_CHECK_STRING_BYTES /* Check that the string size recorded in the string is the @@ -2225,9 +2172,9 @@ compact_small_strings () from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); #ifdef GC_CHECK_STRING_OVERRUN - if (bcmp (string_overrun_cookie, - ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE, - GC_STRING_OVERRUN_COOKIE_SIZE)) + if (memcmp (string_overrun_cookie, + (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, + GC_STRING_OVERRUN_COOKIE_SIZE)) abort (); #endif @@ -2249,7 +2196,7 @@ compact_small_strings () if (from != to) { xassert (tb != b || to <= from); - safe_bcopy ((char *) from, (char *) to, nbytes + GC_STRING_EXTRA); + memmove (to, from, nbytes + GC_STRING_EXTRA); to->string->data = SDATA_DATA (to); } @@ -2277,12 +2224,12 @@ DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0, doc: /* Return a newly created string of length LENGTH, with INIT in each element. LENGTH must be an integer. INIT must be an integer that represents a character. */) - (length, init) - Lisp_Object length, init; + (Lisp_Object length, Lisp_Object init) { register Lisp_Object val; register unsigned char *p, *end; - int c, nbytes; + int c; + EMACS_INT nbytes; CHECK_NATNUM (length); CHECK_NUMBER (init); @@ -2301,14 +2248,17 @@ INIT must be an integer that represents a character. */) { unsigned char str[MAX_MULTIBYTE_LENGTH]; int len = CHAR_STRING (c, str); + EMACS_INT string_len = XINT (length); - nbytes = len * XINT (length); - val = make_uninit_multibyte_string (XINT (length), nbytes); + if (string_len > MOST_POSITIVE_FIXNUM / len) + error ("Maximum string size exceeded"); + nbytes = len * string_len; + val = make_uninit_multibyte_string (string_len, nbytes); p = SDATA (val); end = p + nbytes; while (p != end) { - bcopy (str, p, len); + memcpy (p, str, len); p += len; } } @@ -2321,13 +2271,13 @@ INIT must be an integer that represents a character. */) DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0, doc: /* Return a new bool-vector of length LENGTH, using INIT for each element. LENGTH must be a number. INIT matters only in whether it is t or nil. */) - (length, init) - Lisp_Object length, init; + (Lisp_Object length, Lisp_Object init) { register Lisp_Object val; struct Lisp_Bool_Vector *p; int real_init, i; - int length_in_chars, length_in_elts, bits_per_value; + EMACS_INT length_in_chars, length_in_elts; + int bits_per_value; CHECK_NATNUM (length); @@ -2367,12 +2317,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) multibyte, depending on the contents. */ Lisp_Object -make_string (contents, nbytes) - const char *contents; - int nbytes; +make_string (const char *contents, EMACS_INT nbytes) { register Lisp_Object val; - int nchars, multibyte_nbytes; + EMACS_INT nchars, multibyte_nbytes; parse_str_as_multibyte (contents, nbytes, &nchars, &multibyte_nbytes); if (nbytes == nchars || nbytes != multibyte_nbytes) @@ -2388,13 +2336,11 @@ make_string (contents, nbytes) /* Make an unibyte string from LENGTH bytes at CONTENTS. */ Lisp_Object -make_unibyte_string (contents, length) - const char *contents; - int length; +make_unibyte_string (const char *contents, EMACS_INT length) { register Lisp_Object val; val = make_uninit_string (length); - bcopy (contents, SDATA (val), length); + memcpy (SDATA (val), contents, length); STRING_SET_UNIBYTE (val); return val; } @@ -2404,13 +2350,12 @@ make_unibyte_string (contents, length) bytes at CONTENTS. */ Lisp_Object -make_multibyte_string (contents, nchars, nbytes) - const char *contents; - int nchars, nbytes; +make_multibyte_string (const char *contents, + EMACS_INT nchars, EMACS_INT nbytes) { register Lisp_Object val; val = make_uninit_multibyte_string (nchars, nbytes); - bcopy (contents, SDATA (val), nbytes); + memcpy (SDATA (val), contents, nbytes); return val; } @@ -2419,13 +2364,12 @@ make_multibyte_string (contents, nchars, nbytes) CONTENTS. It is a multibyte string if NBYTES != NCHARS. */ Lisp_Object -make_string_from_bytes (contents, nchars, nbytes) - const char *contents; - int nchars, nbytes; +make_string_from_bytes (const char *contents, + EMACS_INT nchars, EMACS_INT nbytes) { register Lisp_Object val; val = make_uninit_multibyte_string (nchars, nbytes); - bcopy (contents, SDATA (val), nbytes); + memcpy (SDATA (val), contents, nbytes); if (SBYTES (val) == SCHARS (val)) STRING_SET_UNIBYTE (val); return val; @@ -2438,10 +2382,8 @@ make_string_from_bytes (contents, nchars, nbytes) characters by itself. */ Lisp_Object -make_specified_string (contents, nchars, nbytes, multibyte) - const char *contents; - int nchars, nbytes; - int multibyte; +make_specified_string (const char *contents, + EMACS_INT nchars, EMACS_INT nbytes, int multibyte) { register Lisp_Object val; @@ -2453,7 +2395,7 @@ make_specified_string (contents, nchars, nbytes, multibyte) nchars = nbytes; } val = make_uninit_multibyte_string (nchars, nbytes); - bcopy (contents, SDATA (val), nbytes); + memcpy (SDATA (val), contents, nbytes); if (!multibyte) STRING_SET_UNIBYTE (val); return val; @@ -2464,8 +2406,7 @@ make_specified_string (contents, nchars, nbytes, multibyte) data warrants. */ Lisp_Object -build_string (str) - const char *str; +build_string (const char *str) { return make_string (str, strlen (str)); } @@ -2475,8 +2416,7 @@ build_string (str) occupying LENGTH bytes. */ Lisp_Object -make_uninit_string (length) - int length; +make_uninit_string (EMACS_INT length) { Lisp_Object val; @@ -2492,8 +2432,7 @@ make_uninit_string (length) which occupy NBYTES bytes. */ Lisp_Object -make_uninit_multibyte_string (nchars, nbytes) - int nchars, nbytes; +make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes) { Lisp_Object string; struct Lisp_String *s; @@ -2583,7 +2522,7 @@ struct Lisp_Float *float_free_list; /* Initialize float allocation. */ static void -init_float () +init_float (void) { float_block = NULL; float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */ @@ -2592,22 +2531,10 @@ init_float () } -/* Explicitly free a float cell by putting it on the free-list. */ - -static void -free_float (ptr) - struct Lisp_Float *ptr; -{ - ptr->u.chain = float_free_list; - float_free_list = ptr; -} - - /* Return a new float object with value FLOAT_VALUE. */ Lisp_Object -make_float (float_value) - double float_value; +make_float (double float_value) { register Lisp_Object val; @@ -2631,7 +2558,7 @@ make_float (float_value) new = (struct float_block *) lisp_align_malloc (sizeof *new, MEM_TYPE_FLOAT); new->next = float_block; - bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); + memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); float_block = new; float_block_index = 0; n_float_blocks++; @@ -2707,7 +2634,7 @@ static int n_cons_blocks; /* Initialize cons allocation. */ static void -init_cons () +init_cons (void) { cons_block = NULL; cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */ @@ -2719,8 +2646,7 @@ init_cons () /* Explicitly free a cons cell by putting it on the free-list. */ void -free_cons (ptr) - struct Lisp_Cons *ptr; +free_cons (struct Lisp_Cons *ptr) { ptr->u.chain = cons_free_list; #if GC_MARK_STACK @@ -2731,8 +2657,7 @@ free_cons (ptr) DEFUN ("cons", Fcons, Scons, 2, 2, 0, doc: /* Create a new cons, give it CAR and CDR as components, and return it. */) - (car, cdr) - Lisp_Object car, cdr; + (Lisp_Object car, Lisp_Object cdr) { register Lisp_Object val; @@ -2754,7 +2679,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, register struct cons_block *new; new = (struct cons_block *) lisp_align_malloc (sizeof *new, MEM_TYPE_CONS); - bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits); + memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); new->next = cons_block; cons_block = new; cons_block_index = 0; @@ -2776,7 +2701,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, /* Get an error now if there's any junk in the cons free list. */ void -check_cons_list () +check_cons_list (void) { #ifdef GC_CHECK_CONS_LIST struct Lisp_Cons *tail = cons_free_list; @@ -2789,39 +2714,34 @@ check_cons_list () /* Make a list of 1, 2, 3, 4 or 5 specified objects. */ Lisp_Object -list1 (arg1) - Lisp_Object arg1; +list1 (Lisp_Object arg1) { return Fcons (arg1, Qnil); } Lisp_Object -list2 (arg1, arg2) - Lisp_Object arg1, arg2; +list2 (Lisp_Object arg1, Lisp_Object arg2) { return Fcons (arg1, Fcons (arg2, Qnil)); } Lisp_Object -list3 (arg1, arg2, arg3) - Lisp_Object arg1, arg2, arg3; +list3 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) { return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil))); } Lisp_Object -list4 (arg1, arg2, arg3, arg4) - Lisp_Object arg1, arg2, arg3, arg4; +list4 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4) { return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil)))); } Lisp_Object -list5 (arg1, arg2, arg3, arg4, arg5) - Lisp_Object arg1, arg2, arg3, arg4, arg5; +list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, Lisp_Object arg5) { return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Fcons (arg5, Qnil))))); @@ -2832,9 +2752,7 @@ DEFUN ("list", Flist, Slist, 0, MANY, 0, doc: /* Return a newly created list with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (list &rest OBJECTS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { register Lisp_Object val; val = Qnil; @@ -2850,11 +2768,10 @@ usage: (list &rest OBJECTS) */) DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, doc: /* Return a newly created list of length LENGTH, with each element being INIT. */) - (length, init) - register Lisp_Object length, init; + (register Lisp_Object length, Lisp_Object init) { register Lisp_Object val; - register int size; + register EMACS_INT size; CHECK_NATNUM (length); size = XFASTINT (length); @@ -2914,8 +2831,7 @@ static int n_vectors; with room for LEN Lisp_Objects. */ static struct Lisp_Vector * -allocate_vectorlike (len) - EMACS_INT len; +allocate_vectorlike (EMACS_INT len) { struct Lisp_Vector *p; size_t nbytes; @@ -2956,8 +2872,7 @@ allocate_vectorlike (len) /* Allocate a vector with NSLOTS slots. */ struct Lisp_Vector * -allocate_vector (nslots) - EMACS_INT nslots; +allocate_vector (EMACS_INT nslots) { struct Lisp_Vector *v = allocate_vectorlike (nslots); v->size = nslots; @@ -2968,9 +2883,7 @@ allocate_vector (nslots) /* Allocate other vector-like structures. */ struct Lisp_Vector * -allocate_pseudovector (memlen, lisplen, tag) - int memlen, lisplen; - EMACS_INT tag; +allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag) { struct Lisp_Vector *v = allocate_vectorlike (memlen); EMACS_INT i; @@ -2992,38 +2905,38 @@ allocate_hash_table (void) struct window * -allocate_window () +allocate_window (void) { return ALLOCATE_PSEUDOVECTOR(struct window, current_matrix, PVEC_WINDOW); } struct terminal * -allocate_terminal () +allocate_terminal (void) { struct terminal *t = ALLOCATE_PSEUDOVECTOR (struct terminal, next_terminal, PVEC_TERMINAL); /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ - bzero (&(t->next_terminal), - ((char*)(t+1)) - ((char*)&(t->next_terminal))); + memset (&t->next_terminal, 0, + (char*) (t + 1) - (char*) &t->next_terminal); return t; } struct frame * -allocate_frame () +allocate_frame (void) { struct frame *f = ALLOCATE_PSEUDOVECTOR (struct frame, face_cache, PVEC_FRAME); /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ - bzero (&(f->face_cache), - ((char*)(f+1)) - ((char*)&(f->face_cache))); + memset (&f->face_cache, 0, + (char *) (f + 1) - (char *) &f->face_cache); return f; } struct Lisp_Process * -allocate_process () +allocate_process (void) { return ALLOCATE_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS); } @@ -3032,12 +2945,11 @@ allocate_process () DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, doc: /* Return a newly created vector of length LENGTH, with each element being INIT. See also the function `vector'. */) - (length, init) - register Lisp_Object length, init; + (register Lisp_Object length, Lisp_Object init) { Lisp_Object vector; register EMACS_INT sizei; - register int index; + register EMACS_INT index; register struct Lisp_Vector *p; CHECK_NATNUM (length); @@ -3056,9 +2968,7 @@ DEFUN ("vector", Fvector, Svector, 0, MANY, 0, doc: /* Return a newly created vector with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (vector &rest OBJECTS) */) - (nargs, args) - register int nargs; - Lisp_Object *args; + (register int nargs, Lisp_Object *args) { register Lisp_Object len, val; register int index; @@ -3080,9 +2990,7 @@ stack size, (optional) doc string, and (optional) interactive spec. The first four arguments are required; at most six have any significance. usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) - (nargs, args) - register int nargs; - Lisp_Object *args; + (register int nargs, Lisp_Object *args) { register Lisp_Object len, val; register int index; @@ -3152,7 +3060,7 @@ static int n_symbol_blocks; /* Initialize symbol allocation. */ static void -init_symbol () +init_symbol (void) { symbol_block = NULL; symbol_block_index = SYMBOL_BLOCK_SIZE; @@ -3164,8 +3072,7 @@ init_symbol () DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, doc: /* Return a newly allocated uninterned symbol whose name is NAME. Its value and function definition are void, and its property list is nil. */) - (name) - Lisp_Object name; + (Lisp_Object name) { register Lisp_Object val; register struct Lisp_Symbol *p; @@ -3202,13 +3109,13 @@ Its value and function definition are void, and its property list is nil. */) p = XSYMBOL (val); p->xname = name; p->plist = Qnil; - p->value = Qunbound; + p->redirect = SYMBOL_PLAINVAL; + SET_SYMBOL_VAL (p, Qunbound); p->function = Qunbound; p->next = NULL; p->gcmarkbit = 0; p->interned = SYMBOL_UNINTERNED; p->constant = 0; - p->indirect_variable = 0; consing_since_gc += sizeof (struct Lisp_Symbol); symbols_consed++; return val; @@ -3243,7 +3150,7 @@ static union Lisp_Misc *marker_free_list; static int n_marker_blocks; static void -init_marker () +init_marker (void) { marker_block = NULL; marker_block_index = MARKER_BLOCK_SIZE; @@ -3254,7 +3161,7 @@ init_marker () /* Return a newly allocated Lisp_Misc object, with no substructure. */ Lisp_Object -allocate_misc () +allocate_misc (void) { Lisp_Object val; @@ -3296,8 +3203,7 @@ allocate_misc () /* Free a Lisp_Misc object */ void -free_misc (misc) - Lisp_Object misc; +free_misc (Lisp_Object misc) { XMISCTYPE (misc) = Lisp_Misc_Free; XMISC (misc)->u_free.chain = marker_free_list; @@ -3311,9 +3217,7 @@ free_misc (misc) The unwind function can get the C values back using XSAVE_VALUE. */ Lisp_Object -make_save_value (pointer, integer) - void *pointer; - int integer; +make_save_value (void *pointer, int integer) { register Lisp_Object val; register struct Lisp_Save_Value *p; @@ -3329,7 +3233,7 @@ make_save_value (pointer, integer) DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, doc: /* Return a newly allocated marker which does not point at any place. */) - () + (void) { register Lisp_Object val; register struct Lisp_Marker *p; @@ -3348,8 +3252,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0, /* Put MARKER back on the free list after using it temporarily. */ void -free_marker (marker) - Lisp_Object marker; +free_marker (Lisp_Object marker) { unchain_marker (XMARKER (marker)); free_misc (marker); @@ -3363,9 +3266,7 @@ free_marker (marker) Any number of arguments, even zero arguments, are allowed. */ Lisp_Object -make_event_array (nargs, args) - register int nargs; - Lisp_Object *args; +make_event_array (register int nargs, Lisp_Object *args) { int i; @@ -3405,7 +3306,7 @@ make_event_array (nargs, args) /* Called if malloc returns zero. */ void -memory_full () +memory_full (void) { int i; @@ -3445,7 +3346,7 @@ memory_full () and also directly from this file, in case we're not using ralloc.c. */ void -refill_memory_reserve () +refill_memory_reserve (void) { #ifndef SYSTEM_MALLOC if (spare_memory[0] == 0) @@ -3493,7 +3394,7 @@ refill_memory_reserve () /* Initialize this part of alloc.c. */ static void -mem_init () +mem_init (void) { mem_z.left = mem_z.right = MEM_NIL; mem_z.parent = NULL; @@ -3507,8 +3408,7 @@ mem_init () MEM_NIL if there is no node in the tree containing START. */ static INLINE struct mem_node * -mem_find (start) - void *start; +mem_find (void *start) { struct mem_node *p; @@ -3531,9 +3431,7 @@ mem_find (start) pointer to the node that was inserted. */ static struct mem_node * -mem_insert (start, end, type) - void *start, *end; - enum mem_type type; +mem_insert (void *start, void *end, enum mem_type type) { struct mem_node *c, *parent, *x; @@ -3605,8 +3503,7 @@ mem_insert (start, end, type) balance the tree, after node X has been inserted; X is always red. */ static void -mem_insert_fixup (x) - struct mem_node *x; +mem_insert_fixup (struct mem_node *x) { while (x != mem_root && x->parent->color == MEM_RED) { @@ -3684,8 +3581,7 @@ mem_insert_fixup (x) b c a b */ static void -mem_rotate_left (x) - struct mem_node *x; +mem_rotate_left (struct mem_node *x) { struct mem_node *y; @@ -3724,8 +3620,7 @@ mem_rotate_left (x) a b b c */ static void -mem_rotate_right (x) - struct mem_node *x; +mem_rotate_right (struct mem_node *x) { struct mem_node *y = x->left; @@ -3754,8 +3649,7 @@ mem_rotate_right (x) /* Delete node Z from the tree. If Z is null or MEM_NIL, do nothing. */ static void -mem_delete (z) - struct mem_node *z; +mem_delete (struct mem_node *z) { struct mem_node *x, *y; @@ -3809,8 +3703,7 @@ mem_delete (z) deletion. */ static void -mem_delete_fixup (x) - struct mem_node *x; +mem_delete_fixup (struct mem_node *x) { while (x != mem_root && x->color == MEM_BLACK) { @@ -3891,14 +3784,12 @@ mem_delete_fixup (x) the heap. M is a pointer to the mem_block for P. */ static INLINE int -live_string_p (m, p) - struct mem_node *m; - void *p; +live_string_p (struct mem_node *m, void *p) { if (m->type == MEM_TYPE_STRING) { struct string_block *b = (struct string_block *) m->start; - int offset = (char *) p - (char *) &b->strings[0]; + ptrdiff_t offset = (char *) p - (char *) &b->strings[0]; /* P must point to the start of a Lisp_String structure, and it must not be on the free-list. */ @@ -3916,14 +3807,12 @@ live_string_p (m, p) the heap. M is a pointer to the mem_block for P. */ static INLINE int -live_cons_p (m, p) - struct mem_node *m; - void *p; +live_cons_p (struct mem_node *m, void *p) { if (m->type == MEM_TYPE_CONS) { struct cons_block *b = (struct cons_block *) m->start; - int offset = (char *) p - (char *) &b->conses[0]; + ptrdiff_t offset = (char *) p - (char *) &b->conses[0]; /* P must point to the start of a Lisp_Cons, not be one of the unused cells in the current cons block, @@ -3944,14 +3833,12 @@ live_cons_p (m, p) the heap. M is a pointer to the mem_block for P. */ static INLINE int -live_symbol_p (m, p) - struct mem_node *m; - void *p; +live_symbol_p (struct mem_node *m, void *p) { if (m->type == MEM_TYPE_SYMBOL) { struct symbol_block *b = (struct symbol_block *) m->start; - int offset = (char *) p - (char *) &b->symbols[0]; + ptrdiff_t offset = (char *) p - (char *) &b->symbols[0]; /* P must point to the start of a Lisp_Symbol, not be one of the unused cells in the current symbol block, @@ -3972,14 +3859,12 @@ live_symbol_p (m, p) the heap. M is a pointer to the mem_block for P. */ static INLINE int -live_float_p (m, p) - struct mem_node *m; - void *p; +live_float_p (struct mem_node *m, void *p) { if (m->type == MEM_TYPE_FLOAT) { struct float_block *b = (struct float_block *) m->start; - int offset = (char *) p - (char *) &b->floats[0]; + ptrdiff_t offset = (char *) p - (char *) &b->floats[0]; /* P must point to the start of a Lisp_Float and not be one of the unused cells in the current float block. */ @@ -3998,14 +3883,12 @@ live_float_p (m, p) the heap. M is a pointer to the mem_block for P. */ static INLINE int -live_misc_p (m, p) - struct mem_node *m; - void *p; +live_misc_p (struct mem_node *m, void *p) { if (m->type == MEM_TYPE_MISC) { struct marker_block *b = (struct marker_block *) m->start; - int offset = (char *) p - (char *) &b->markers[0]; + ptrdiff_t offset = (char *) p - (char *) &b->markers[0]; /* P must point to the start of a Lisp_Misc, not be one of the unused cells in the current misc block, @@ -4026,9 +3909,7 @@ live_misc_p (m, p) M is a pointer to the mem_block for P. */ static INLINE int -live_vector_p (m, p) - struct mem_node *m; - void *p; +live_vector_p (struct mem_node *m, void *p) { return (p == m->start && m->type == MEM_TYPE_VECTORLIKE); } @@ -4038,9 +3919,7 @@ live_vector_p (m, p) pointer to the mem_block for P. */ static INLINE int -live_buffer_p (m, p) - struct mem_node *m; - void *p; +live_buffer_p (struct mem_node *m, void *p) { /* P must point to the start of the block, and the buffer must not have been killed. */ @@ -4083,7 +3962,7 @@ static double avg_live; DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", doc: /* Show information about live and zombie objects. */) - () + (void) { Lisp_Object args[8], zombie_list = Qnil; int i; @@ -4106,8 +3985,7 @@ DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "", /* Mark OBJ if we can prove it's a Lisp_Object. */ static INLINE void -mark_maybe_object (obj) - Lisp_Object obj; +mark_maybe_object (Lisp_Object obj) { void *po = (void *) XPNTR (obj); struct mem_node *m = mem_find (po); @@ -4170,8 +4048,7 @@ mark_maybe_object (obj) marked. */ static INLINE void -mark_maybe_pointer (p) - void *p; +mark_maybe_pointer (void *p) { struct mem_node *m; @@ -4251,9 +4128,7 @@ mark_maybe_pointer (p) or END+OFFSET..START. */ static void -mark_memory (start, end, offset) - void *start, *end; - int offset; +mark_memory (void *start, void *end, int offset) { Lisp_Object *p; void **pp; @@ -4469,7 +4344,7 @@ dump_zombies () equally on the stack. */ static void -mark_stack () +mark_stack (void) { int i; /* jmp_buf may not be aligned enough on darwin-ppc64 */ @@ -4544,8 +4419,7 @@ mark_stack () /* Determine whether it is safe to access memory at address P. */ static int -valid_pointer_p (p) - void *p; +valid_pointer_p (void *p) { #ifdef WINDOWSNT return w32_valid_pointer_p (p, 16); @@ -4576,8 +4450,7 @@ valid_pointer_p (p) so it should only be used in code for manual debugging. */ int -valid_lisp_object_p (obj) - Lisp_Object obj; +valid_lisp_object_p (Lisp_Object obj) { void *p; #if GC_MARK_STACK @@ -4655,9 +4528,7 @@ valid_lisp_object_p (obj) allocated. TYPE < 0 means it's not used for a Lisp object. */ static POINTER_TYPE * -pure_alloc (size, type) - size_t size; - int type; +pure_alloc (size_t size, int type) { POINTER_TYPE *result; #ifdef USE_LSB_TAG @@ -4711,7 +4582,7 @@ pure_alloc (size, type) /* Print a warning if PURESIZE is too small. */ void -check_pure_size () +check_pure_size (void) { if (pure_bytes_used_before_overflow) message ("emacs:0:Pure Lisp storage overflow (approx. %d bytes needed)", @@ -4724,11 +4595,10 @@ check_pure_size () address. Return NULL if not found. */ static char * -find_string_data_in_pure (data, nbytes) - const char *data; - int nbytes; +find_string_data_in_pure (const char *data, EMACS_INT nbytes) { - int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max; + int i; + EMACS_INT skip, bm_skip[256], last_char_skip, infinity, start, start_max; const unsigned char *p; char *non_lisp_beg; @@ -4795,10 +4665,8 @@ find_string_data_in_pure (data, nbytes) string; then the string is not protected from gc. */ Lisp_Object -make_pure_string (data, nchars, nbytes, multibyte) - const char *data; - int nchars, nbytes; - int multibyte; +make_pure_string (const char *data, + EMACS_INT nchars, EMACS_INT nbytes, int multibyte) { Lisp_Object string; struct Lisp_String *s; @@ -4808,7 +4676,7 @@ make_pure_string (data, nchars, nbytes, multibyte) if (s->data == NULL) { s->data = (unsigned char *) pure_alloc (nbytes + 1, -1); - bcopy (data, s->data, nbytes); + memcpy (s->data, data, nbytes); s->data[nbytes] = '\0'; } s->size = nchars; @@ -4826,7 +4694,7 @@ make_pure_c_string (const char *data) { Lisp_Object string; struct Lisp_String *s; - int nchars = strlen (data); + EMACS_INT nchars = strlen (data); s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); s->size = nchars; @@ -4841,8 +4709,7 @@ make_pure_c_string (const char *data) of CAR as car and CDR as cdr. */ Lisp_Object -pure_cons (car, cdr) - Lisp_Object car, cdr; +pure_cons (Lisp_Object car, Lisp_Object cdr) { register Lisp_Object new; struct Lisp_Cons *p; @@ -4858,8 +4725,7 @@ pure_cons (car, cdr) /* Value is a float object with value NUM allocated from pure space. */ static Lisp_Object -make_pure_float (num) - double num; +make_pure_float (double num) { register Lisp_Object new; struct Lisp_Float *p; @@ -4875,8 +4741,7 @@ make_pure_float (num) pure space. */ Lisp_Object -make_pure_vector (len) - EMACS_INT len; +make_pure_vector (EMACS_INT len) { Lisp_Object new; struct Lisp_Vector *p; @@ -4893,8 +4758,7 @@ DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0, doc: /* Make a copy of object OBJ in pure storage. Recursively copies contents of vectors and cons cells. Does not copy symbols. Copies strings without text properties. */) - (obj) - register Lisp_Object obj; + (register Lisp_Object obj) { if (NILP (Vpurify_flag)) return obj; @@ -4902,18 +4766,25 @@ Does not copy symbols. Copies strings without text properties. */) if (PURE_POINTER_P (XPNTR (obj))) return obj; + if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ + { + Lisp_Object tmp = Fgethash (obj, Vpurify_flag, Qnil); + if (!NILP (tmp)) + return tmp; + } + if (CONSP (obj)) - return pure_cons (XCAR (obj), XCDR (obj)); + obj = pure_cons (XCAR (obj), XCDR (obj)); else if (FLOATP (obj)) - return make_pure_float (XFLOAT_DATA (obj)); + obj = make_pure_float (XFLOAT_DATA (obj)); else if (STRINGP (obj)) - return make_pure_string (SDATA (obj), SCHARS (obj), - SBYTES (obj), - STRING_MULTIBYTE (obj)); + obj = make_pure_string (SDATA (obj), SCHARS (obj), + SBYTES (obj), + STRING_MULTIBYTE (obj)); else if (COMPILEDP (obj) || VECTORP (obj)) { register struct Lisp_Vector *vec; - register int i; + register EMACS_INT i; EMACS_INT size; size = XVECTOR (obj)->size; @@ -4929,10 +4800,15 @@ Does not copy symbols. Copies strings without text properties. */) } else XSETVECTOR (obj, vec); - return obj; } else if (MARKERP (obj)) error ("Attempt to copy a marker to pure storage"); + else + /* Not purified, don't hash-cons. */ + return obj; + + if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ + Fputhash (obj, obj, Vpurify_flag); return obj; } @@ -4947,8 +4823,7 @@ Does not copy symbols. Copies strings without text properties. */) VARADDRESS. */ void -staticpro (varaddress) - Lisp_Object *varaddress; +staticpro (Lisp_Object *varaddress) { staticvec[staticidx++] = varaddress; if (staticidx >= NSTATICS) @@ -4963,7 +4838,7 @@ staticpro (varaddress) /* Temporarily prevent garbage collection. */ int -inhibit_garbage_collection () +inhibit_garbage_collection (void) { int count = SPECPDL_INDEX (); int nbits = min (VALBITS, BITS_PER_INT); @@ -4984,7 +4859,7 @@ Garbage collection happens automatically if you cons more than (USED-STRINGS . FREE-STRINGS)) However, if there was overflow in pure space, `garbage-collect' returns nil, because real GC can't be done. */) - () + (void) { register struct specbinding *bind; struct catchtag *catch; @@ -5067,9 +4942,9 @@ returns nil, because real GC can't be done. */) if (stack_copy) { if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) - bcopy (stack_bottom, stack_copy, i); + memcpy (stack_copy, stack_bottom, i); else - bcopy (&stack_top_variable, stack_copy, i); + memcpy (stack_copy, &stack_top_variable, i); } } } @@ -5102,7 +4977,7 @@ returns nil, because real GC can't be done. */) #ifdef USE_GTK { - extern void xg_mark_data (); + extern void xg_mark_data (void); xg_mark_data (); } #endif @@ -5295,8 +5170,7 @@ returns nil, because real GC can't be done. */) only interesting objects referenced from glyphs are strings. */ static void -mark_glyph_matrix (matrix) - struct glyph_matrix *matrix; +mark_glyph_matrix (struct glyph_matrix *matrix) { struct glyph_row *row = matrix->rows; struct glyph_row *end = row + matrix->nrows; @@ -5322,8 +5196,7 @@ mark_glyph_matrix (matrix) /* Mark Lisp faces in the face cache C. */ static void -mark_face_cache (c) - struct face_cache *c; +mark_face_cache (struct face_cache *c) { if (c) { @@ -5358,11 +5231,10 @@ int last_marked_index; static int mark_object_loop_halt; static void -mark_vectorlike (ptr) - struct Lisp_Vector *ptr; +mark_vectorlike (struct Lisp_Vector *ptr) { - register EMACS_INT size = ptr->size; - register int i; + register EMACS_UINT size = ptr->size; + register EMACS_UINT i; eassert (!VECTOR_MARKED_P (ptr)); VECTOR_MARK (ptr); /* Else mark it */ @@ -5382,11 +5254,10 @@ mark_vectorlike (ptr) symbols. */ static void -mark_char_table (ptr) - struct Lisp_Vector *ptr; +mark_char_table (struct Lisp_Vector *ptr) { - register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; - register int i; + register EMACS_UINT size = ptr->size & PSEUDOVECTOR_SIZE_MASK; + register EMACS_UINT i; eassert (!VECTOR_MARKED_P (ptr)); VECTOR_MARK (ptr); @@ -5407,8 +5278,7 @@ mark_char_table (ptr) } void -mark_object (arg) - Lisp_Object arg; +mark_object (Lisp_Object arg) { register Lisp_Object obj = arg; #ifdef GC_CHECK_MARKED_OBJECTS @@ -5516,8 +5386,8 @@ mark_object (arg) recursion there. */ { register struct Lisp_Vector *ptr = XVECTOR (obj); - register EMACS_INT size = ptr->size; - register int i; + register EMACS_UINT size = ptr->size; + register EMACS_UINT i; CHECK_LIVE (live_vector_p); VECTOR_MARK (ptr); /* Else mark it */ @@ -5578,17 +5448,42 @@ mark_object (arg) break; CHECK_ALLOCATED_AND_LIVE (live_symbol_p); ptr->gcmarkbit = 1; - mark_object (ptr->value); mark_object (ptr->function); mark_object (ptr->plist); - + switch (ptr->redirect) + { + case SYMBOL_PLAINVAL: mark_object (SYMBOL_VAL (ptr)); break; + case SYMBOL_VARALIAS: + { + Lisp_Object tem; + XSETSYMBOL (tem, SYMBOL_ALIAS (ptr)); + mark_object (tem); + break; + } + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr); + /* If the value is forwarded to a buffer or keyboard field, + these are marked when we see the corresponding object. + And if it's forwarded to a C variable, either it's not + a Lisp_Object var, or it's staticpro'd already. */ + mark_object (blv->where); + mark_object (blv->valcell); + mark_object (blv->defcell); + break; + } + case SYMBOL_FORWARDED: + /* If the value is forwarded to a buffer or keyboard field, + these are marked when we see the corresponding object. + And if it's forwarded to a C variable, either it's not + a Lisp_Object var, or it's staticpro'd already. */ + break; + default: abort (); + } if (!PURE_POINTER_P (XSTRING (ptr->xname))) MARK_STRING (XSTRING (ptr->xname)); MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->xname)); - /* Note that we do not mark the obarray of the symbol. - It is safe not to do so because nothing accesses that - slot except to check whether it is nil. */ ptr = ptr->next; if (ptr) { @@ -5607,22 +5502,6 @@ mark_object (arg) switch (XMISCTYPE (obj)) { - case Lisp_Misc_Buffer_Local_Value: - { - register struct Lisp_Buffer_Local_Value *ptr - = XBUFFER_LOCAL_VALUE (obj); - /* If the cdr is nil, avoid recursion for the car. */ - if (EQ (ptr->cdr, Qnil)) - { - obj = ptr->realvalue; - goto loop; - } - mark_object (ptr->realvalue); - mark_object (ptr->buffer); - mark_object (ptr->frame); - obj = ptr->cdr; - goto loop; - } case Lisp_Misc_Marker: /* DO NOT mark thru the marker's chain. @@ -5630,17 +5509,6 @@ mark_object (arg) instead, markers are removed from the chain when freed by gc. */ break; - case Lisp_Misc_Intfwd: - case Lisp_Misc_Boolfwd: - case Lisp_Misc_Objfwd: - case Lisp_Misc_Buffer_Objfwd: - case Lisp_Misc_Kboard_Objfwd: - /* Don't bother with Lisp_Buffer_Objfwd, - since all markable slots in current buffer marked anyway. */ - /* Don't need to do Lisp_Objfwd, since the places they point - are protected with staticpro. */ - break; - case Lisp_Misc_Save_Value: #if GC_MARK_STACK { @@ -5719,8 +5587,7 @@ mark_object (arg) /* Mark the pointers in a buffer structure. */ static void -mark_buffer (buf) - Lisp_Object buf; +mark_buffer (Lisp_Object buf) { register struct buffer *buffer = XBUFFER (buf); register Lisp_Object *ptr, tmp; @@ -5787,8 +5654,7 @@ mark_terminals (void) either marked or does not need to be marked to survive. */ int -survives_gc_p (obj) - Lisp_Object obj; +survives_gc_p (Lisp_Object obj) { int survives_p; @@ -5834,7 +5700,7 @@ survives_gc_p (obj) /* Sweep: find all structures not marked, and free them. */ static void -gc_sweep () +gc_sweep (void) { /* Remove or mark entries in weak hash tables. This must be done before any object is unmarked. */ @@ -6045,6 +5911,8 @@ gc_sweep () if (!sym->gcmarkbit && !pure_p) { + if (sym->redirect == SYMBOL_LOCALIZED) + xfree (SYMBOL_BLV (sym)); sym->next = symbol_free_list; symbol_free_list = sym; #if GC_MARK_STACK @@ -6208,7 +6076,7 @@ DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, doc: /* Return the address of the last byte Emacs has allocated, divided by 1024. This may be helpful in debugging Emacs's memory usage. We divide the value by 1024 to make sure it fits in a Lisp integer. */) - () + (void) { Lisp_Object end; @@ -6230,7 +6098,7 @@ objects consed. MISCS include overlays, markers, and some internal types. Frames, windows, buffers, and subprocesses count as vectors (but the contents of a buffer's text do not count here). */) - () + (void) { Lisp_Object consed[8]; @@ -6249,10 +6117,7 @@ Frames, windows, buffers, and subprocesses count as vectors int suppress_checking; void -die (msg, file, line) - const char *msg; - const char *file; - int line; +die (const char *msg, const char *file, int line) { fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", file, line, msg); @@ -6262,7 +6127,7 @@ die (msg, file, line) /* Initialization */ void -init_alloc_once () +init_alloc_once (void) { /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ purebeg = PUREBEG; @@ -6309,15 +6174,10 @@ init_alloc_once () consing_since_gc = 0; gc_cons_threshold = 100000 * sizeof (Lisp_Object); gc_relative_threshold = 0; - -#ifdef VIRT_ADDR_VARIES - malloc_sbrk_unused = 1<<22; /* A large number */ - malloc_sbrk_used = 100000; /* as reasonable as any number */ -#endif /* VIRT_ADDR_VARIES */ } void -init_alloc () +init_alloc (void) { gcprolist = 0; byte_stack_list = 0; @@ -6331,7 +6191,7 @@ init_alloc () } void -syms_of_alloc () +syms_of_alloc (void) { DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold, doc: /* *Number of bytes of consing between garbage collections. @@ -6380,7 +6240,9 @@ If this portion is smaller than `gc-cons-threshold', this is ignored. */); DEFVAR_LISP ("purify-flag", &Vpurify_flag, doc: /* Non-nil means loading Lisp code in order to dump an executable. -This means that certain objects should be allocated in shared (pure) space. */); +This means that certain objects should be allocated in shared (pure) space. +It can also be set to a hash-table, in which case this table is used to +do hash-consing of the objects allocated to pure space. */); DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, doc: /* Non-nil means display messages at start and end of garbage collection. */); diff --git a/src/atimer.c b/src/atimer.c index 432e2590dad..9fd9dee835e 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -21,11 +21,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> #include <stdio.h> #include <setjmp.h> -#include <lisp.h> -#include <syssignal.h> -#include <systime.h> -#include <blockinput.h> -#include <atimer.h> +#include "lisp.h" +#include "syssignal.h" +#include "systime.h" +#include "blockinput.h" +#include "atimer.h" #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -64,11 +64,11 @@ int pending_atimers; /* Function prototypes. */ -static void set_alarm P_ ((void)); -static void schedule_atimer P_ ((struct atimer *)); -static struct atimer *append_atimer_lists P_ ((struct atimer *, - struct atimer *)); -SIGTYPE alarm_signal_handler (); +static void set_alarm (void); +static void schedule_atimer (struct atimer *); +static struct atimer *append_atimer_lists (struct atimer *, + struct atimer *); +SIGTYPE alarm_signal_handler (int signo); /* Start a new atimer of type TYPE. TIME specifies when the timer is @@ -90,11 +90,8 @@ SIGTYPE alarm_signal_handler (); to cancel_atimer; don't free it yourself. */ struct atimer * -start_atimer (type, time, fn, client_data) - enum atimer_type type; - EMACS_TIME time; - atimer_callback fn; - void *client_data; +start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn, + void *client_data) { struct atimer *t; @@ -119,7 +116,7 @@ start_atimer (type, time, fn, client_data) t = (struct atimer *) xmalloc (sizeof *t); /* Fill the atimer structure. */ - bzero (t, sizeof *t); + memset (t, 0, sizeof *t); t->type = type; t->fn = fn; t->client_data = client_data; @@ -159,8 +156,7 @@ start_atimer (type, time, fn, client_data) /* Cancel and free atimer TIMER. */ void -cancel_atimer (timer) - struct atimer *timer; +cancel_atimer (struct atimer *timer) { int i; @@ -199,8 +195,7 @@ cancel_atimer (timer) result list. */ static struct atimer * -append_atimer_lists (list1, list2) - struct atimer *list1, *list2; +append_atimer_lists (struct atimer *list1, struct atimer *list2) { if (list1 == NULL) return list2; @@ -221,8 +216,7 @@ append_atimer_lists (list1, list2) /* Stop all timers except timer T. T null means stop all timers. */ void -stop_other_atimers (t) - struct atimer *t; +stop_other_atimers (struct atimer *t) { BLOCK_ATIMERS; @@ -257,7 +251,7 @@ stop_other_atimers (t) stop_other_atimers. */ void -run_all_atimers () +run_all_atimers (void) { if (stopped_atimers) { @@ -283,8 +277,7 @@ run_all_atimers () /* A version of run_all_timers suitable for a record_unwind_protect. */ Lisp_Object -unwind_stop_other_atimers (dummy) - Lisp_Object dummy; +unwind_stop_other_atimers (Lisp_Object dummy) { run_all_atimers (); return Qnil; @@ -294,14 +287,8 @@ unwind_stop_other_atimers (dummy) /* Arrange for a SIGALRM to arrive when the next timer is ripe. */ static void -set_alarm () +set_alarm (void) { -#if defined (USG) && !defined (POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time. */ - signal (SIGALRM, alarm_signal_handler); -#endif /* USG */ - if (atimers) { EMACS_TIME now, time; @@ -321,7 +308,7 @@ set_alarm () EMACS_SET_USECS (time, 1000); } - bzero (&it, sizeof it); + memset (&it, 0, sizeof it); it.it_value = time; setitimer (ITIMER_REAL, &it, 0); #else /* not HAVE_SETITIMER */ @@ -336,8 +323,7 @@ set_alarm () already. */ static void -schedule_atimer (t) - struct atimer *t; +schedule_atimer (struct atimer *t) { struct atimer *a = atimers, *prev = NULL; @@ -355,7 +341,7 @@ schedule_atimer (t) } static void -run_timers () +run_timers (void) { EMACS_TIME now; @@ -407,8 +393,7 @@ run_timers () SIGALRM. */ SIGTYPE -alarm_signal_handler (signo) - int signo; +alarm_signal_handler (int signo) { #ifndef SYNC_INPUT SIGNAL_THREAD_CHECK (signo); @@ -426,7 +411,7 @@ alarm_signal_handler (signo) /* Call alarm_signal_handler for pending timers. */ void -do_pending_atimers () +do_pending_atimers (void) { if (pending_atimers) { @@ -441,8 +426,7 @@ do_pending_atimers () some systems like HPUX (see process.c). */ void -turn_on_atimers (on) - int on; +turn_on_atimers (int on) { if (on) { @@ -455,7 +439,7 @@ turn_on_atimers (on) void -init_atimer () +init_atimer (void) { free_atimers = stopped_atimers = atimers = NULL; pending_atimers = 0; diff --git a/src/atimer.h b/src/atimer.h index fd354caf54d..c2245d30e6b 100644 --- a/src/atimer.h +++ b/src/atimer.h @@ -20,13 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef EMACS_ATIMER_H #define EMACS_ATIMER_H -/* Declare the prototype for a general external function. */ -#if defined (PROTOTYPES) || defined (WINDOWSNT) -#define P_(proto) proto -#else -#define P_(proto) () -#endif - #include "systime.h" /* for EMACS_TIME */ /* Forward declaration. */ @@ -49,7 +42,7 @@ enum atimer_type /* Type of timer callback functions. */ -typedef void (* atimer_callback) P_ ((struct atimer *timer)); +typedef void (* atimer_callback) (struct atimer *timer); /* Structure describing an asynchronous timer. */ @@ -77,15 +70,15 @@ struct atimer /* Function prototypes. */ -struct atimer *start_atimer P_ ((enum atimer_type, EMACS_TIME, - atimer_callback, void *)); -void cancel_atimer P_ ((struct atimer *)); -void do_pending_atimers P_ ((void)); -void init_atimer P_ ((void)); -void turn_on_atimers P_ ((int)); -void stop_other_atimers P_ ((struct atimer *)); -void run_all_atimers P_ ((void)); -Lisp_Object unwind_stop_other_atimers P_ ((Lisp_Object)); +struct atimer *start_atimer (enum atimer_type, EMACS_TIME, + atimer_callback, void *); +void cancel_atimer (struct atimer *); +void do_pending_atimers (void); +void init_atimer (void); +void turn_on_atimers (int); +void stop_other_atimers (struct atimer *); +void run_all_atimers (void); +Lisp_Object unwind_stop_other_atimers (Lisp_Object); #endif /* EMACS_ATIMER_H */ diff --git a/src/autodeps.mk b/src/autodeps.mk new file mode 100644 index 00000000000..fb0e21366c7 --- /dev/null +++ b/src/autodeps.mk @@ -0,0 +1,6 @@ +### autodeps.mk --- src/Makefile fragment for GNU Emacs + +## This is inserted in src/Makefile if AUTO_DEPEND=yes. + +ALLOBJS=$(START_FILES) ${obj} ${otherobj} +-include $(ALLOBJS:%.o=${DEPDIR}/%.d) diff --git a/src/bidi.c b/src/bidi.c new file mode 100644 index 00000000000..1f14f6ab840 --- /dev/null +++ b/src/bidi.c @@ -0,0 +1,1811 @@ +/* Low-level bidirectional buffer-scanning functions for GNU Emacs. + Copyright (C) 2000, 2001, 2004, 2005, 2009, 2010 + Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Eli Zaretskii <eliz@gnu.org>. + + A sequential implementation of the Unicode Bidirectional algorithm, + as per UAX#9, a part of the Unicode Standard. + + Unlike the reference and most other implementations, this one is + designed to be called once for every character in the buffer or + string. + + The main entry point is bidi_move_to_visually_next. Each time it + is called, it finds the next character in the visual order, and + returns its information in a special structure. The caller is then + expected to process this character for display or any other + purposes, and call bidi_move_to_visually_next for the next + character. See the comments in bidi_move_to_visually_next for more + details about its algorithm that finds the next visual-order + character by resolving their levels on the fly. + + The two other entry points are bidi_paragraph_init and + bidi_mirror_char. The first determines the base direction of a + paragraph, while the second returns the mirrored version of its + argument character. + + If you want to understand the code, you will have to read it + together with the relevant portions of UAX#9. The comments include + references to UAX#9 rules, for that very reason. + + A note about references to UAX#9 rules: if the reference says + something like "X9/Retaining", it means that you need to refer to + rule X9 and to its modifications decribed in the "Implementation + Notes" section of UAX#9, under "Retaining Format Codes". */ + +#include <config.h> +#include <stdio.h> +#include <setjmp.h> + +#include "lisp.h" +#include "buffer.h" +#include "character.h" +#include "dispextern.h" + +static int bidi_initialized = 0; + +static Lisp_Object bidi_type_table, bidi_mirror_table; + +/* FIXME: Remove these when bidi_explicit_dir_char uses a lookup table. */ +#define LRM_CHAR 0x200E +#define RLM_CHAR 0x200F +#define LRE_CHAR 0x202A +#define RLE_CHAR 0x202B +#define PDF_CHAR 0x202C +#define LRO_CHAR 0x202D +#define RLO_CHAR 0x202E + +#define BIDI_EOB -1 +#define BIDI_BOB -2 /* FIXME: Is this needed? */ + +/* Local data structures. (Look in dispextern.h for the rest.) */ + +/* What we need to know about the current paragraph. */ +struct bidi_paragraph_info { + EMACS_INT start_bytepos; /* byte position where it begins */ + EMACS_INT end_bytepos; /* byte position where it ends */ + int embedding_level; /* its basic embedding level */ + bidi_dir_t base_dir; /* its base direction */ +}; + +/* Data type for describing the bidirectional character categories. */ +typedef enum { + UNKNOWN_BC, + NEUTRAL, + WEAK, + STRONG +} bidi_category_t; + +int bidi_ignore_explicit_marks_for_paragraph_level = 1; + +static Lisp_Object paragraph_start_re, paragraph_separate_re; +static Lisp_Object Qparagraph_start, Qparagraph_separate; + +static void +bidi_initialize (void) +{ + +#include "biditype.h" +#include "bidimirror.h" + + int i; + + bidi_type_table = Fmake_char_table (Qnil, make_number (STRONG_L)); + staticpro (&bidi_type_table); + + for (i = 0; i < sizeof bidi_type / sizeof bidi_type[0]; i++) + char_table_set_range (bidi_type_table, bidi_type[i].from, bidi_type[i].to, + make_number (bidi_type[i].type)); + + bidi_mirror_table = Fmake_char_table (Qnil, Qnil); + staticpro (&bidi_mirror_table); + + for (i = 0; i < sizeof bidi_mirror / sizeof bidi_mirror[0]; i++) + char_table_set (bidi_mirror_table, bidi_mirror[i].from, + make_number (bidi_mirror[i].to)); + + Qparagraph_start = intern ("paragraph-start"); + staticpro (&Qparagraph_start); + paragraph_start_re = Fsymbol_value (Qparagraph_start); + if (!STRINGP (paragraph_start_re)) + paragraph_start_re = build_string ("\f\\|[ \t]*$"); + staticpro (¶graph_start_re); + Qparagraph_separate = intern ("paragraph-separate"); + staticpro (&Qparagraph_separate); + paragraph_separate_re = Fsymbol_value (Qparagraph_separate); + if (!STRINGP (paragraph_separate_re)) + paragraph_separate_re = build_string ("[ \t\f]*$"); + staticpro (¶graph_separate_re); + bidi_initialized = 1; +} + +/* Return the bidi type of a character CH, subject to the current + directional OVERRIDE. */ +static INLINE bidi_type_t +bidi_get_type (int ch, bidi_dir_t override) +{ + bidi_type_t default_type; + + if (ch == BIDI_EOB) + return NEUTRAL_B; + if (ch < 0 || ch > MAX_CHAR) + abort (); + + default_type = (bidi_type_t) XINT (CHAR_TABLE_REF (bidi_type_table, ch)); + + if (override == NEUTRAL_DIR) + return default_type; + + switch (default_type) + { + /* Although UAX#9 does not tell, it doesn't make sense to + override NEUTRAL_B and LRM/RLM characters. */ + case NEUTRAL_B: + case LRE: + case LRO: + case RLE: + case RLO: + case PDF: + return default_type; + default: + switch (ch) + { + case LRM_CHAR: + case RLM_CHAR: + return default_type; + default: + if (override == L2R) /* X6 */ + return STRONG_L; + else if (override == R2L) + return STRONG_R; + else + abort (); /* can't happen: handled above */ + } + } +} + +void +bidi_check_type (bidi_type_t type) +{ + if (type < UNKNOWN_BT || type > NEUTRAL_ON) + abort (); +} + +/* Given a bidi TYPE of a character, return its category. */ +static INLINE bidi_category_t +bidi_get_category (bidi_type_t type) +{ + switch (type) + { + case UNKNOWN_BT: + return UNKNOWN_BC; + case STRONG_L: + case STRONG_R: + case STRONG_AL: + case LRE: + case LRO: + case RLE: + case RLO: + return STRONG; + case PDF: /* ??? really?? */ + case WEAK_EN: + case WEAK_ES: + case WEAK_ET: + case WEAK_AN: + case WEAK_CS: + case WEAK_NSM: + case WEAK_BN: + return WEAK; + case NEUTRAL_B: + case NEUTRAL_S: + case NEUTRAL_WS: + case NEUTRAL_ON: + return NEUTRAL; + default: + abort (); + } +} + +/* Return the mirrored character of C, if it has one. If C has no + mirrored counterpart, return C. + Note: The conditions in UAX#9 clause L4 regarding the surrounding + context must be tested by the caller. */ +int +bidi_mirror_char (int c) +{ + Lisp_Object val; + + if (c == BIDI_EOB) + return c; + if (c < 0 || c > MAX_CHAR) + abort (); + + val = CHAR_TABLE_REF (bidi_mirror_table, c); + if (INTEGERP (val)) + { + int v = XINT (val); + + if (v < 0 || v > MAX_CHAR) + abort (); + + return v; + } + + return c; +} + +/* Copy the bidi iterator from FROM to TO. To save cycles, this only + copies the part of the level stack that is actually in use. */ +static INLINE void +bidi_copy_it (struct bidi_it *to, struct bidi_it *from) +{ + int i; + + /* Copy everything except the level stack and beyond. */ + memcpy (to, from, ((size_t)&((struct bidi_it *)0)->level_stack[0])); + + /* Copy the active part of the level stack. */ + to->level_stack[0] = from->level_stack[0]; /* level zero is always in use */ + for (i = 1; i <= from->stack_idx; i++) + to->level_stack[i] = from->level_stack[i]; +} + +/* Caching the bidi iterator states. */ + +#define BIDI_CACHE_CHUNK 200 +static struct bidi_it *bidi_cache; +static size_t bidi_cache_size = 0; +static size_t elsz = sizeof (struct bidi_it); +static int bidi_cache_idx; /* next unused cache slot */ +static int bidi_cache_last_idx; /* slot of last cache hit */ + +static INLINE void +bidi_cache_reset (void) +{ + bidi_cache_idx = 0; + bidi_cache_last_idx = -1; +} + +static INLINE void +bidi_cache_shrink (void) +{ + if (bidi_cache_size > BIDI_CACHE_CHUNK) + { + bidi_cache_size = BIDI_CACHE_CHUNK; + bidi_cache = + (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); + } + bidi_cache_reset (); +} + +static INLINE void +bidi_cache_fetch_state (int idx, struct bidi_it *bidi_it) +{ + int current_scan_dir = bidi_it->scan_dir; + + if (idx < 0 || idx >= bidi_cache_idx) + abort (); + + bidi_copy_it (bidi_it, &bidi_cache[idx]); + bidi_it->scan_dir = current_scan_dir; + bidi_cache_last_idx = idx; +} + +/* Find a cached state with a given CHARPOS and resolved embedding + level less or equal to LEVEL. if LEVEL is -1, disregard the + resolved levels in cached states. DIR, if non-zero, means search + in that direction from the last cache hit. */ +static INLINE int +bidi_cache_search (EMACS_INT charpos, int level, int dir) +{ + int i, i_start; + + if (bidi_cache_idx) + { + if (charpos < bidi_cache[bidi_cache_last_idx].charpos) + dir = -1; + else if (charpos > bidi_cache[bidi_cache_last_idx].charpos) + dir = 1; + if (dir) + i_start = bidi_cache_last_idx; + else + { + dir = -1; + i_start = bidi_cache_idx - 1; + } + + if (dir < 0) + { + /* Linear search for now; FIXME! */ + for (i = i_start; i >= 0; i--) + if (bidi_cache[i].charpos == charpos + && (level == -1 || bidi_cache[i].resolved_level <= level)) + return i; + } + else + { + for (i = i_start; i < bidi_cache_idx; i++) + if (bidi_cache[i].charpos == charpos + && (level == -1 || bidi_cache[i].resolved_level <= level)) + return i; + } + } + + return -1; +} + +/* Find a cached state where the resolved level changes to a value + that is lower than LEVEL, and return its cache slot index. DIR is + the direction to search, starting with the last used cache slot. + BEFORE, if non-zero, means return the index of the slot that is + ``before'' the level change in the search direction. That is, + given the cached levels like this: + + 1122333442211 + AB C + + and assuming we are at the position cached at the slot marked with + C, searching backwards (DIR = -1) for LEVEL = 2 will return the + index of slot B or A, depending whether BEFORE is, respectively, + non-zero or zero. */ +static int +bidi_cache_find_level_change (int level, int dir, int before) +{ + if (bidi_cache_idx) + { + int i = dir ? bidi_cache_last_idx : bidi_cache_idx - 1; + int incr = before ? 1 : 0; + + if (!dir) + dir = -1; + else if (!incr) + i += dir; + + if (dir < 0) + { + while (i >= incr) + { + if (bidi_cache[i - incr].resolved_level >= 0 + && bidi_cache[i - incr].resolved_level < level) + return i; + i--; + } + } + else + { + while (i < bidi_cache_idx - incr) + { + if (bidi_cache[i + incr].resolved_level >= 0 + && bidi_cache[i + incr].resolved_level < level) + return i; + i++; + } + } + } + + return -1; +} + +static INLINE void +bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) +{ + int idx; + + /* We should never cache on backward scans. */ + if (bidi_it->scan_dir == -1) + abort (); + idx = bidi_cache_search (bidi_it->charpos, -1, 1); + + if (idx < 0) + { + idx = bidi_cache_idx; + /* Enlarge the cache as needed. */ + if (idx >= bidi_cache_size) + { + bidi_cache_size += BIDI_CACHE_CHUNK; + bidi_cache = + (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); + } + /* Character positions should correspond to cache positions 1:1. + If we are outside the range of cached positions, the cache is + useless and must be reset. */ + if (idx > 0 && + (bidi_it->charpos > bidi_cache[idx - 1].charpos + 1 + || bidi_it->charpos < bidi_cache[0].charpos)) + { + bidi_cache_reset (); + idx = 0; + } + bidi_copy_it (&bidi_cache[idx], bidi_it); + if (!resolved) + bidi_cache[idx].resolved_level = -1; + } + else + { + /* Copy only the members which could have changed, to avoid + costly copying of the entire struct. */ + bidi_cache[idx].type = bidi_it->type; + bidi_check_type (bidi_it->type); + bidi_cache[idx].type_after_w1 = bidi_it->type_after_w1; + bidi_check_type (bidi_it->type_after_w1); + if (resolved) + bidi_cache[idx].resolved_level = bidi_it->resolved_level; + else + bidi_cache[idx].resolved_level = -1; + bidi_cache[idx].invalid_levels = bidi_it->invalid_levels; + bidi_cache[idx].invalid_rl_levels = bidi_it->invalid_rl_levels; + bidi_cache[idx].next_for_neutral = bidi_it->next_for_neutral; + bidi_cache[idx].next_for_ws = bidi_it->next_for_ws; + bidi_cache[idx].ignore_bn_limit = bidi_it->ignore_bn_limit; + } + + bidi_cache_last_idx = idx; + if (idx >= bidi_cache_idx) + bidi_cache_idx = idx + 1; +} + +static INLINE bidi_type_t +bidi_cache_find (EMACS_INT charpos, int level, struct bidi_it *bidi_it) +{ + int i = bidi_cache_search (charpos, level, bidi_it->scan_dir); + + if (i >= 0) + { + bidi_dir_t current_scan_dir = bidi_it->scan_dir; + + bidi_copy_it (bidi_it, &bidi_cache[i]); + bidi_cache_last_idx = i; + /* Don't let scan direction from from the cached state override + the current scan direction. */ + bidi_it->scan_dir = current_scan_dir; + return bidi_it->type; + } + + return UNKNOWN_BT; +} + +static INLINE int +bidi_peek_at_next_level (struct bidi_it *bidi_it) +{ + if (bidi_cache_idx == 0 || bidi_cache_last_idx == -1) + abort (); + return bidi_cache[bidi_cache_last_idx + bidi_it->scan_dir].resolved_level; +} + +/* Check if buffer position CHARPOS/BYTEPOS is the end of a paragraph. + Value is the non-negative length of the paragraph separator + following the buffer position, -1 if position is at the beginning + of a new paragraph, or -2 if position is neither at beginning nor + at end of a paragraph. */ +static EMACS_INT +bidi_at_paragraph_end (EMACS_INT charpos, EMACS_INT bytepos) +{ + Lisp_Object sep_re; + Lisp_Object start_re; + EMACS_INT val; + + sep_re = paragraph_separate_re; + start_re = paragraph_start_re; + + val = fast_looking_at (sep_re, charpos, bytepos, ZV, ZV_BYTE, Qnil); + if (val < 0) + { + if (fast_looking_at (start_re, charpos, bytepos, ZV, ZV_BYTE, Qnil) >= 0) + val = -1; + else + val = -2; + } + + return val; +} + +/* Determine the start-of-run (sor) directional type given the two + embedding levels on either side of the run boundary. Also, update + the saved info about previously seen characters, since that info is + generally valid for a single level run. */ +static INLINE void +bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after) +{ + int higher_level = level_before > level_after ? level_before : level_after; + + /* The prev_was_pdf gork is required for when we have several PDFs + in a row. In that case, we want to compute the sor type for the + next level run only once: when we see the first PDF. That's + because the sor type depends only on the higher of the two levels + that we find on the two sides of the level boundary (see UAX#9, + clause X10), and so we don't need to know the final embedding + level to which we descend after processing all the PDFs. */ + if (!bidi_it->prev_was_pdf || level_before < level_after) + /* FIXME: should the default sor direction be user selectable? */ + bidi_it->sor = (higher_level & 1) != 0 ? R2L : L2R; + if (level_before > level_after) + bidi_it->prev_was_pdf = 1; + + bidi_it->prev.type = UNKNOWN_BT; + bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = + bidi_it->last_strong.orig_type = UNKNOWN_BT; + bidi_it->prev_for_neutral.type = bidi_it->sor == R2L ? STRONG_R : STRONG_L; + bidi_it->prev_for_neutral.charpos = bidi_it->charpos; + bidi_it->prev_for_neutral.bytepos = bidi_it->bytepos; + bidi_it->next_for_neutral.type = bidi_it->next_for_neutral.type_after_w1 = + bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->ignore_bn_limit = 0; /* meaning it's unknown */ +} + +static void +bidi_line_init (struct bidi_it *bidi_it) +{ + bidi_it->scan_dir = 1; /* FIXME: do we need to have control on this? */ + bidi_it->resolved_level = bidi_it->level_stack[0].level; + bidi_it->level_stack[0].override = NEUTRAL_DIR; /* X1 */ + bidi_it->invalid_levels = 0; + bidi_it->invalid_rl_levels = -1; + bidi_it->next_en_pos = -1; + bidi_it->next_for_ws.type = UNKNOWN_BT; + bidi_set_sor_type (bidi_it, + bidi_it->paragraph_dir == R2L ? 1 : 0, + bidi_it->level_stack[0].level); /* X10 */ + + bidi_cache_reset (); +} + +/* Find the beginning of this paragraph by looking back in the buffer. + Value is the byte position of the paragraph's beginning. */ +static EMACS_INT +bidi_find_paragraph_start (EMACS_INT pos, EMACS_INT pos_byte) +{ + Lisp_Object re = paragraph_start_re; + EMACS_INT limit = ZV, limit_byte = ZV_BYTE; + + while (pos_byte > BEGV_BYTE + && fast_looking_at (re, pos, pos_byte, limit, limit_byte, Qnil) < 0) + { + pos = find_next_newline_no_quit (pos - 1, -1); + pos_byte = CHAR_TO_BYTE (pos); + } + return pos_byte; +} + +/* Determine the base direction, a.k.a. base embedding level, of the + paragraph we are about to iterate through. If DIR is either L2R or + R2L, just use that. Otherwise, determine the paragraph direction + from the first strong directional character of the paragraph. + + NO_DEFAULT_P non-nil means don't default to L2R if the paragraph + has no strong directional characters and both DIR and + bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back + in the buffer until a paragraph is found with a strong character, + or until hitting BEGV. In the latter case, fall back to L2R. This + flag is used in current-bidi-paragraph-direction. + + Note that this function gives the paragraph separator the same + direction as the preceding paragraph, even though Emacs generally + views the separartor as not belonging to any paragraph. */ +void +bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) +{ + EMACS_INT bytepos = bidi_it->bytepos; + EMACS_INT pstartbyte; + + /* Special case for an empty buffer. */ + if (bytepos == BEGV_BYTE && bytepos == ZV_BYTE) + dir = L2R; + /* We should never be called at EOB or before BEGV. */ + else if (bytepos >= ZV_BYTE || bytepos < BEGV_BYTE) + abort (); + + if (dir == L2R) + { + bidi_it->paragraph_dir = L2R; + bidi_it->new_paragraph = 0; + } + else if (dir == R2L) + { + bidi_it->paragraph_dir = R2L; + bidi_it->new_paragraph = 0; + } + else if (dir == NEUTRAL_DIR) /* P2 */ + { + int ch, ch_len; + EMACS_INT pos; + bidi_type_t type; + + if (!bidi_initialized) + bidi_initialize (); + + /* If we are inside a paragraph separator, we are just waiting + for the separator to be exhausted; use the previous paragraph + direction. But don't do that if we have been just reseated, + because we need to reinitialize below in that case. */ + if (!bidi_it->first_elt + && bidi_it->charpos < bidi_it->separator_limit) + return; + + /* If we are on a newline, get past it to where the next + paragraph might start. But don't do that at BEGV since then + we are potentially in a new paragraph that doesn't yet + exist. */ + pos = bidi_it->charpos; + if (bytepos > BEGV_BYTE && FETCH_CHAR (bytepos) == '\n') + { + bytepos++; + pos++; + } + + /* We are either at the beginning of a paragraph or in the + middle of it. Find where this paragraph starts. */ + pstartbyte = bidi_find_paragraph_start (pos, bytepos); + bidi_it->separator_limit = -1; + bidi_it->new_paragraph = 0; + + /* The following loop is run more than once only if NO_DEFAULT_P + is non-zero. */ + do { + bytepos = pstartbyte; + ch = FETCH_CHAR (bytepos); + ch_len = CHAR_BYTES (ch); + pos = BYTE_TO_CHAR (bytepos); + type = bidi_get_type (ch, NEUTRAL_DIR); + + for (pos++, bytepos += ch_len; + /* NOTE: UAX#9 says to search only for L, AL, or R types + of characters, and ignore RLE, RLO, LRE, and LRO. + However, I'm not sure it makes sense to omit those 4; + should try with and without that to see the effect. */ + (bidi_get_category (type) != STRONG) + || (bidi_ignore_explicit_marks_for_paragraph_level + && (type == RLE || type == RLO + || type == LRE || type == LRO)); + type = bidi_get_type (ch, NEUTRAL_DIR)) + { + if (type == NEUTRAL_B && bidi_at_paragraph_end (pos, bytepos) >= -1) + break; + if (bytepos >= ZV_BYTE) + { + /* Pretend there's a paragraph separator at end of + buffer. */ + type = NEUTRAL_B; + break; + } + FETCH_CHAR_ADVANCE (ch, pos, bytepos); + } + if (type == STRONG_R || type == STRONG_AL) /* P3 */ + bidi_it->paragraph_dir = R2L; + else if (type == STRONG_L) + bidi_it->paragraph_dir = L2R; + if (no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR) + { + /* If this paragraph is at BEGV, default to L2R. */ + if (pstartbyte == BEGV_BYTE) + bidi_it->paragraph_dir = L2R; /* P3 and HL1 */ + else + { + EMACS_INT prevpbyte = pstartbyte; + EMACS_INT p = BYTE_TO_CHAR (pstartbyte), pbyte = pstartbyte; + + /* Find the beginning of the previous paragraph, if any. */ + while (pbyte > BEGV_BYTE && prevpbyte >= pstartbyte) + { + p--; + pbyte = CHAR_TO_BYTE (p); + prevpbyte = bidi_find_paragraph_start (p, pbyte); + } + pstartbyte = prevpbyte; + } + } + } while (no_default_p && bidi_it->paragraph_dir == NEUTRAL_DIR); + } + else + abort (); + + /* Contrary to UAX#9 clause P3, we only default the paragraph + direction to L2R if we have no previous usable paragraph + direction. This is allowed by the HL1 clause. */ + if (bidi_it->paragraph_dir != L2R && bidi_it->paragraph_dir != R2L) + bidi_it->paragraph_dir = L2R; /* P3 and HL1 ``higher-level protocols'' */ + if (bidi_it->paragraph_dir == R2L) + bidi_it->level_stack[0].level = 1; + else + bidi_it->level_stack[0].level = 0; + + bidi_line_init (bidi_it); +} + +/* Do whatever UAX#9 clause X8 says should be done at paragraph's + end. */ +static INLINE void +bidi_set_paragraph_end (struct bidi_it *bidi_it) +{ + bidi_it->invalid_levels = 0; + bidi_it->invalid_rl_levels = -1; + bidi_it->stack_idx = 0; + bidi_it->resolved_level = bidi_it->level_stack[0].level; +} + +/* Initialize the bidi iterator from buffer position CHARPOS. */ +void +bidi_init_it (EMACS_INT charpos, EMACS_INT bytepos, struct bidi_it *bidi_it) +{ + if (! bidi_initialized) + bidi_initialize (); + bidi_it->charpos = charpos; + bidi_it->bytepos = bytepos; + bidi_it->first_elt = 1; + bidi_set_paragraph_end (bidi_it); + bidi_it->new_paragraph = 1; + bidi_it->separator_limit = -1; + bidi_it->type = NEUTRAL_B; + bidi_it->type_after_w1 = NEUTRAL_B; + bidi_it->orig_type = NEUTRAL_B; + bidi_it->prev_was_pdf = 0; + bidi_it->prev.type = bidi_it->prev.type_after_w1 = + bidi_it->prev.orig_type = UNKNOWN_BT; + bidi_it->last_strong.type = bidi_it->last_strong.type_after_w1 = + bidi_it->last_strong.orig_type = UNKNOWN_BT; + bidi_it->next_for_neutral.charpos = -1; + bidi_it->next_for_neutral.type = + bidi_it->next_for_neutral.type_after_w1 = + bidi_it->next_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->prev_for_neutral.charpos = -1; + bidi_it->prev_for_neutral.type = + bidi_it->prev_for_neutral.type_after_w1 = + bidi_it->prev_for_neutral.orig_type = UNKNOWN_BT; + bidi_it->sor = L2R; /* FIXME: should it be user-selectable? */ + bidi_cache_shrink (); +} + +/* Push the current embedding level and override status; reset the + current level to LEVEL and the current override status to OVERRIDE. */ +static INLINE void +bidi_push_embedding_level (struct bidi_it *bidi_it, + int level, bidi_dir_t override) +{ + bidi_it->stack_idx++; + if (bidi_it->stack_idx >= BIDI_MAXLEVEL) + abort (); + bidi_it->level_stack[bidi_it->stack_idx].level = level; + bidi_it->level_stack[bidi_it->stack_idx].override = override; +} + +/* Pop the embedding level and directional override status from the + stack, and return the new level. */ +static INLINE int +bidi_pop_embedding_level (struct bidi_it *bidi_it) +{ + /* UAX#9 says to ignore invalid PDFs. */ + if (bidi_it->stack_idx > 0) + bidi_it->stack_idx--; + return bidi_it->level_stack[bidi_it->stack_idx].level; +} + +/* Record in SAVED_INFO the information about the current character. */ +static INLINE void +bidi_remember_char (struct bidi_saved_info *saved_info, + struct bidi_it *bidi_it) +{ + saved_info->charpos = bidi_it->charpos; + saved_info->bytepos = bidi_it->bytepos; + saved_info->type = bidi_it->type; + bidi_check_type (bidi_it->type); + saved_info->type_after_w1 = bidi_it->type_after_w1; + bidi_check_type (bidi_it->type_after_w1); + saved_info->orig_type = bidi_it->orig_type; + bidi_check_type (bidi_it->orig_type); +} + +/* Resolve the type of a neutral character according to the type of + surrounding strong text and the current embedding level. */ +static INLINE bidi_type_t +bidi_resolve_neutral_1 (bidi_type_t prev_type, bidi_type_t next_type, int lev) +{ + /* N1: European and Arabic numbers are treated as though they were R. */ + if (next_type == WEAK_EN || next_type == WEAK_AN) + next_type = STRONG_R; + if (prev_type == WEAK_EN || prev_type == WEAK_AN) + prev_type = STRONG_R; + + if (next_type == prev_type) /* N1 */ + return next_type; + else if ((lev & 1) == 0) /* N2 */ + return STRONG_L; + else + return STRONG_R; +} + +static INLINE int +bidi_explicit_dir_char (int c) +{ + /* FIXME: this should be replaced with a lookup table with suitable + bits set, like standard C ctype macros do. */ + return (c == LRE_CHAR || c == LRO_CHAR + || c == RLE_CHAR || c == RLO_CHAR || c == PDF_CHAR); +} + +/* A helper function for bidi_resolve_explicit. It advances to the + next character in logical order and determines the new embedding + level and directional override, but does not take into account + empty embeddings. */ +static int +bidi_resolve_explicit_1 (struct bidi_it *bidi_it) +{ + int curchar; + bidi_type_t type; + int current_level; + int new_level; + bidi_dir_t override; + + if (bidi_it->bytepos < BEGV_BYTE /* after reseat to BEGV? */ + || bidi_it->first_elt) + { + bidi_it->first_elt = 0; + if (bidi_it->charpos < BEGV) + bidi_it->charpos = BEGV; + bidi_it->bytepos = CHAR_TO_BYTE (bidi_it->charpos); + } + else if (bidi_it->bytepos < ZV_BYTE) /* don't move at ZV */ + { + bidi_it->charpos++; + if (bidi_it->ch_len == 0) + abort (); + bidi_it->bytepos += bidi_it->ch_len; + } + + current_level = bidi_it->level_stack[bidi_it->stack_idx].level; /* X1 */ + override = bidi_it->level_stack[bidi_it->stack_idx].override; + new_level = current_level; + + /* in case it is a unibyte character (not yet implemented) */ + /* _fetch_multibyte_char_len = 1; */ + if (bidi_it->bytepos >= ZV_BYTE) + { + curchar = BIDI_EOB; + bidi_it->ch_len = 1; + } + else + { + curchar = FETCH_CHAR (bidi_it->bytepos); + bidi_it->ch_len = CHAR_BYTES (curchar); + } + bidi_it->ch = curchar; + + /* Don't apply directional override here, as all the types we handle + below will not be affected by the override anyway, and we need + the original type unaltered. The override will be applied in + bidi_resolve_weak. */ + type = bidi_get_type (curchar, NEUTRAL_DIR); + bidi_it->orig_type = type; + bidi_check_type (bidi_it->orig_type); + + if (type != PDF) + bidi_it->prev_was_pdf = 0; + + bidi_it->type_after_w1 = UNKNOWN_BT; + + switch (type) + { + case RLE: /* X2 */ + case RLO: /* X4 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (current_level <= BIDI_MAXLEVEL - 4) + { + /* Compute the least odd embedding level greater than + the current level. */ + new_level = ((current_level + 1) & ~1) + 1; + if (bidi_it->type_after_w1 == RLE) + override = NEUTRAL_DIR; + else + override = R2L; + if (current_level == BIDI_MAXLEVEL - 4) + bidi_it->invalid_rl_levels = 0; + bidi_push_embedding_level (bidi_it, new_level, override); + } + else + { + bidi_it->invalid_levels++; + /* See the commentary about invalid_rl_levels below. */ + if (bidi_it->invalid_rl_levels < 0) + bidi_it->invalid_rl_levels = 0; + bidi_it->invalid_rl_levels++; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + case LRE: /* X3 */ + case LRO: /* X5 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (current_level <= BIDI_MAXLEVEL - 5) + { + /* Compute the least even embedding level greater than + the current level. */ + new_level = ((current_level + 2) & ~1); + if (bidi_it->type_after_w1 == LRE) + override = NEUTRAL_DIR; + else + override = L2R; + bidi_push_embedding_level (bidi_it, new_level, override); + } + else + { + bidi_it->invalid_levels++; + /* invalid_rl_levels counts invalid levels encountered + while the embedding level was already too high for + LRE/LRO, but not for RLE/RLO. That is because + there may be exactly one PDF which we should not + ignore even though invalid_levels is non-zero. + invalid_rl_levels helps to know what PDF is + that. */ + if (bidi_it->invalid_rl_levels >= 0) + bidi_it->invalid_rl_levels++; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + case PDF: /* X7 */ + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + type = WEAK_BN; /* X9/Retaining */ + if (bidi_it->ignore_bn_limit <= 0) + { + if (!bidi_it->invalid_rl_levels) + { + new_level = bidi_pop_embedding_level (bidi_it); + bidi_it->invalid_rl_levels = -1; + if (bidi_it->invalid_levels) + bidi_it->invalid_levels--; + /* else nothing: UAX#9 says to ignore invalid PDFs */ + } + if (!bidi_it->invalid_levels) + new_level = bidi_pop_embedding_level (bidi_it); + else + { + bidi_it->invalid_levels--; + bidi_it->invalid_rl_levels--; + } + } + else if (bidi_it->prev.type_after_w1 == WEAK_EN /* W5/Retaining */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + break; + default: + /* Nothing. */ + break; + } + + bidi_it->type = type; + bidi_check_type (bidi_it->type); + + return new_level; +} + +/* Given an iterator state in BIDI_IT, advance one character position + in the buffer to the next character (in the logical order), resolve + any explicit embeddings and directional overrides, and return the + embedding level of the character after resolving explicit + directives and ignoring empty embeddings. */ +static int +bidi_resolve_explicit (struct bidi_it *bidi_it) +{ + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + int new_level = bidi_resolve_explicit_1 (bidi_it); + + if (prev_level < new_level + && bidi_it->type == WEAK_BN + && bidi_it->ignore_bn_limit == 0 /* only if not already known */ + && bidi_it->bytepos < ZV_BYTE /* not already at EOB */ + && bidi_explicit_dir_char (FETCH_CHAR (bidi_it->bytepos + + bidi_it->ch_len))) + { + /* Avoid pushing and popping embedding levels if the level run + is empty, as this breaks level runs where it shouldn't. + UAX#9 removes all the explicit embedding and override codes, + so empty embeddings disappear without a trace. We need to + behave as if we did the same. */ + struct bidi_it saved_it; + int level = prev_level; + + bidi_copy_it (&saved_it, bidi_it); + + while (bidi_explicit_dir_char (FETCH_CHAR (bidi_it->bytepos + + bidi_it->ch_len))) + { + level = bidi_resolve_explicit_1 (bidi_it); + } + + if (level == prev_level) /* empty embedding */ + saved_it.ignore_bn_limit = bidi_it->charpos + 1; + else /* this embedding is non-empty */ + saved_it.ignore_bn_limit = -1; + + bidi_copy_it (bidi_it, &saved_it); + if (bidi_it->ignore_bn_limit > 0) + { + /* We pushed a level, but we shouldn't have. Undo that. */ + if (!bidi_it->invalid_rl_levels) + { + new_level = bidi_pop_embedding_level (bidi_it); + bidi_it->invalid_rl_levels = -1; + if (bidi_it->invalid_levels) + bidi_it->invalid_levels--; + } + if (!bidi_it->invalid_levels) + new_level = bidi_pop_embedding_level (bidi_it); + else + { + bidi_it->invalid_levels--; + bidi_it->invalid_rl_levels--; + } + } + } + + if (bidi_it->type == NEUTRAL_B) /* X8 */ + { + bidi_set_paragraph_end (bidi_it); + /* This is needed by bidi_resolve_weak below, and in L1. */ + bidi_it->type_after_w1 = bidi_it->type; + bidi_check_type (bidi_it->type_after_w1); + } + + return new_level; +} + +/* Advance in the buffer, resolve weak types and return the type of + the next character after weak type resolution. */ +static bidi_type_t +bidi_resolve_weak (struct bidi_it *bidi_it) +{ + bidi_type_t type; + bidi_dir_t override; + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + int new_level = bidi_resolve_explicit (bidi_it); + int next_char; + bidi_type_t type_of_next; + struct bidi_it saved_it; + + type = bidi_it->type; + override = bidi_it->level_stack[bidi_it->stack_idx].override; + + if (type == UNKNOWN_BT + || type == LRE + || type == LRO + || type == RLE + || type == RLO + || type == PDF) + abort (); + + if (new_level != prev_level + || bidi_it->type == NEUTRAL_B) + { + /* We've got a new embedding level run, compute the directional + type of sor and initialize per-run variables (UAX#9, clause + X10). */ + bidi_set_sor_type (bidi_it, prev_level, new_level); + } + else if (type == NEUTRAL_S || type == NEUTRAL_WS + || type == WEAK_BN || type == STRONG_AL) + bidi_it->type_after_w1 = type; /* needed in L1 */ + bidi_check_type (bidi_it->type_after_w1); + + /* Level and directional override status are already recorded in + bidi_it, and do not need any change; see X6. */ + if (override == R2L) /* X6 */ + type = STRONG_R; + else if (override == L2R) + type = STRONG_L; + else + { + if (type == WEAK_NSM) /* W1 */ + { + /* Note that we don't need to consider the case where the + prev character has its type overridden by an RLO or LRO, + because then either the type of this NSM would have been + also overridden, or the previous character is outside the + current level run, and thus not relevant to this NSM. + This is why NSM gets the type_after_w1 of the previous + character. */ + if (bidi_it->prev.type_after_w1 != UNKNOWN_BT + /* if type_after_w1 is NEUTRAL_B, this NSM is at sor */ + && bidi_it->prev.type_after_w1 != NEUTRAL_B) + type = bidi_it->prev.type_after_w1; + else if (bidi_it->sor == R2L) + type = STRONG_R; + else if (bidi_it->sor == L2R) + type = STRONG_L; + else /* shouldn't happen! */ + abort (); + } + if (type == WEAK_EN /* W2 */ + && bidi_it->last_strong.type_after_w1 == STRONG_AL) + type = WEAK_AN; + else if (type == STRONG_AL) /* W3 */ + type = STRONG_R; + else if ((type == WEAK_ES /* W4 */ + && bidi_it->prev.type_after_w1 == WEAK_EN + && bidi_it->prev.orig_type == WEAK_EN) + || (type == WEAK_CS + && ((bidi_it->prev.type_after_w1 == WEAK_EN + && bidi_it->prev.orig_type == WEAK_EN) + || bidi_it->prev.type_after_w1 == WEAK_AN))) + { + next_char = + bidi_it->bytepos + bidi_it->ch_len >= ZV_BYTE + ? BIDI_EOB : FETCH_CHAR (bidi_it->bytepos + bidi_it->ch_len); + type_of_next = bidi_get_type (next_char, override); + + if (type_of_next == WEAK_BN + || bidi_explicit_dir_char (next_char)) + { + bidi_copy_it (&saved_it, bidi_it); + while (bidi_resolve_explicit (bidi_it) == new_level + && bidi_it->type == WEAK_BN) + ; + type_of_next = bidi_it->type; + bidi_copy_it (bidi_it, &saved_it); + } + + /* If the next character is EN, but the last strong-type + character is AL, that next EN will be changed to AN when + we process it in W2 above. So in that case, this ES + should not be changed into EN. */ + if (type == WEAK_ES + && type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 != STRONG_AL) + type = WEAK_EN; + else if (type == WEAK_CS) + { + if (bidi_it->prev.type_after_w1 == WEAK_AN + && (type_of_next == WEAK_AN + /* If the next character is EN, but the last + strong-type character is AL, EN will be later + changed to AN when we process it in W2 above. + So in that case, this ES should not be + changed into EN. */ + || (type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 == STRONG_AL))) + type = WEAK_AN; + else if (bidi_it->prev.type_after_w1 == WEAK_EN + && type_of_next == WEAK_EN + && bidi_it->last_strong.type_after_w1 != STRONG_AL) + type = WEAK_EN; + } + } + else if (type == WEAK_ET /* W5: ET with EN before or after it */ + || type == WEAK_BN) /* W5/Retaining */ + { + if (bidi_it->prev.type_after_w1 == WEAK_EN /* ET/BN w/EN before it */ + || bidi_it->next_en_pos > bidi_it->charpos) + type = WEAK_EN; + else /* W5: ET/BN with EN after it. */ + { + EMACS_INT en_pos = bidi_it->charpos + 1; + + next_char = + bidi_it->bytepos + bidi_it->ch_len >= ZV_BYTE + ? BIDI_EOB : FETCH_CHAR (bidi_it->bytepos + bidi_it->ch_len); + type_of_next = bidi_get_type (next_char, override); + + if (type_of_next == WEAK_ET + || type_of_next == WEAK_BN + || bidi_explicit_dir_char (next_char)) + { + bidi_copy_it (&saved_it, bidi_it); + while (bidi_resolve_explicit (bidi_it) == new_level + && (bidi_it->type == WEAK_BN + || bidi_it->type == WEAK_ET)) + ; + type_of_next = bidi_it->type; + en_pos = bidi_it->charpos; + bidi_copy_it (bidi_it, &saved_it); + } + if (type_of_next == WEAK_EN) + { + /* If the last strong character is AL, the EN we've + found will become AN when we get to it (W2). */ + if (bidi_it->last_strong.type_after_w1 != STRONG_AL) + { + type = WEAK_EN; + /* Remember this EN position, to speed up processing + of the next ETs. */ + bidi_it->next_en_pos = en_pos; + } + else if (type == WEAK_BN) + type = NEUTRAL_ON; /* W6/Retaining */ + } + } + } + } + + if (type == WEAK_ES || type == WEAK_ET || type == WEAK_CS /* W6 */ + || (type == WEAK_BN + && (bidi_it->prev.type_after_w1 == WEAK_CS /* W6/Retaining */ + || bidi_it->prev.type_after_w1 == WEAK_ES + || bidi_it->prev.type_after_w1 == WEAK_ET))) + type = NEUTRAL_ON; + + /* Store the type we've got so far, before we clobber it with strong + types in W7 and while resolving neutral types. But leave alone + the original types that were recorded above, because we will need + them for the L1 clause. */ + if (bidi_it->type_after_w1 == UNKNOWN_BT) + bidi_it->type_after_w1 = type; + bidi_check_type (bidi_it->type_after_w1); + + if (type == WEAK_EN) /* W7 */ + { + if ((bidi_it->last_strong.type_after_w1 == STRONG_L) + || (bidi_it->last_strong.type == UNKNOWN_BT && bidi_it->sor == L2R)) + type = STRONG_L; + } + + bidi_it->type = type; + bidi_check_type (bidi_it->type); + return type; +} + +static bidi_type_t +bidi_resolve_neutral (struct bidi_it *bidi_it) +{ + int prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + bidi_type_t type = bidi_resolve_weak (bidi_it); + int current_level = bidi_it->level_stack[bidi_it->stack_idx].level; + + if (!(type == STRONG_R + || type == STRONG_L + || type == WEAK_BN + || type == WEAK_EN + || type == WEAK_AN + || type == NEUTRAL_B + || type == NEUTRAL_S + || type == NEUTRAL_WS + || type == NEUTRAL_ON)) + abort (); + + if (bidi_get_category (type) == NEUTRAL + || (type == WEAK_BN && prev_level == current_level)) + { + if (bidi_it->next_for_neutral.type != UNKNOWN_BT) + type = bidi_resolve_neutral_1 (bidi_it->prev_for_neutral.type, + bidi_it->next_for_neutral.type, + current_level); + else + { + /* Arrrgh!! The UAX#9 algorithm is too deeply entrenched in + the assumption of batch-style processing; see clauses W4, + W5, and especially N1, which require to look far forward + (as well as back) in the buffer. May the fleas of a + thousand camels infest the armpits of those who design + supposedly general-purpose algorithms by looking at their + own implementations, and fail to consider other possible + implementations! */ + struct bidi_it saved_it; + bidi_type_t next_type; + + if (bidi_it->scan_dir == -1) + abort (); + + bidi_copy_it (&saved_it, bidi_it); + /* Scan the text forward until we find the first non-neutral + character, and then use that to resolve the neutral we + are dealing with now. We also cache the scanned iterator + states, to salvage some of the effort later. */ + bidi_cache_iterator_state (bidi_it, 0); + do { + /* Record the info about the previous character, so that + it will be cached below with this state. */ + if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */ + && bidi_it->type != WEAK_BN) + bidi_remember_char (&bidi_it->prev, bidi_it); + type = bidi_resolve_weak (bidi_it); + /* Paragraph separators have their levels fully resolved + at this point, so cache them as resolved. */ + bidi_cache_iterator_state (bidi_it, type == NEUTRAL_B); + /* FIXME: implement L1 here, by testing for a newline and + resetting the level for any sequence of whitespace + characters adjacent to it. */ + } while (!(type == NEUTRAL_B + || (type != WEAK_BN + && bidi_get_category (type) != NEUTRAL) + /* This is all per level run, so stop when we + reach the end of this level run. */ + || bidi_it->level_stack[bidi_it->stack_idx].level != + current_level)); + + bidi_remember_char (&saved_it.next_for_neutral, bidi_it); + + switch (type) + { + case STRONG_L: + case STRONG_R: + case STRONG_AL: + next_type = type; + break; + case WEAK_EN: + case WEAK_AN: + /* N1: ``European and Arabic numbers are treated as + though they were R.'' */ + next_type = STRONG_R; + saved_it.next_for_neutral.type = STRONG_R; + break; + case WEAK_BN: + if (!bidi_explicit_dir_char (bidi_it->ch)) + abort (); /* can't happen: BNs are skipped */ + /* FALLTHROUGH */ + case NEUTRAL_B: + /* Marched all the way to the end of this level run. + We need to use the eor type, whose information is + stored by bidi_set_sor_type in the prev_for_neutral + member. */ + if (saved_it.type != WEAK_BN + || bidi_get_category (bidi_it->prev.type_after_w1) == NEUTRAL) + { + next_type = bidi_it->prev_for_neutral.type; + saved_it.next_for_neutral.type = next_type; + bidi_check_type (next_type); + } + else + { + /* This is a BN which does not adjoin neutrals. + Leave its type alone. */ + bidi_copy_it (bidi_it, &saved_it); + return bidi_it->type; + } + break; + default: + abort (); + } + type = bidi_resolve_neutral_1 (saved_it.prev_for_neutral.type, + next_type, current_level); + saved_it.type = type; + bidi_check_type (type); + bidi_copy_it (bidi_it, &saved_it); + } + } + return type; +} + +/* Given an iterator state in BIDI_IT, advance one character position + in the buffer to the next character (in the logical order), resolve + the bidi type of that next character, and return that type. */ +static bidi_type_t +bidi_type_of_next_char (struct bidi_it *bidi_it) +{ + bidi_type_t type; + + /* This should always be called during a forward scan. */ + if (bidi_it->scan_dir != 1) + abort (); + + /* Reset the limit until which to ignore BNs if we step out of the + area where we found only empty levels. */ + if ((bidi_it->ignore_bn_limit > 0 + && bidi_it->ignore_bn_limit <= bidi_it->charpos) + || (bidi_it->ignore_bn_limit == -1 + && !bidi_explicit_dir_char (bidi_it->ch))) + bidi_it->ignore_bn_limit = 0; + + type = bidi_resolve_neutral (bidi_it); + + return type; +} + +/* Given an iterator state BIDI_IT, advance one character position in + the buffer to the next character (in the logical order), resolve + the embedding and implicit levels of that next character, and + return the resulting level. */ +static int +bidi_level_of_next_char (struct bidi_it *bidi_it) +{ + bidi_type_t type; + int level, prev_level = -1; + struct bidi_saved_info next_for_neutral; + + if (bidi_it->scan_dir == 1) + { + /* There's no sense in trying to advance if we hit end of text. */ + if (bidi_it->bytepos >= ZV_BYTE) + return bidi_it->resolved_level; + + /* Record the info about the previous character. */ + if (bidi_it->type_after_w1 != WEAK_BN /* W1/Retaining */ + && bidi_it->type != WEAK_BN) + bidi_remember_char (&bidi_it->prev, bidi_it); + if (bidi_it->type_after_w1 == STRONG_R + || bidi_it->type_after_w1 == STRONG_L + || bidi_it->type_after_w1 == STRONG_AL) + bidi_remember_char (&bidi_it->last_strong, bidi_it); + /* FIXME: it sounds like we don't need both prev and + prev_for_neutral members, but I'm leaving them both for now. */ + if (bidi_it->type == STRONG_R || bidi_it->type == STRONG_L + || bidi_it->type == WEAK_EN || bidi_it->type == WEAK_AN) + bidi_remember_char (&bidi_it->prev_for_neutral, bidi_it); + + /* If we overstepped the characters used for resolving neutrals + and whitespace, invalidate their info in the iterator. */ + if (bidi_it->charpos >= bidi_it->next_for_neutral.charpos) + bidi_it->next_for_neutral.type = UNKNOWN_BT; + if (bidi_it->next_en_pos >= 0 + && bidi_it->charpos >= bidi_it->next_en_pos) + bidi_it->next_en_pos = -1; + if (bidi_it->next_for_ws.type != UNKNOWN_BT + && bidi_it->charpos >= bidi_it->next_for_ws.charpos) + bidi_it->next_for_ws.type = UNKNOWN_BT; + + /* This must be taken before we fill the iterator with the info + about the next char. If we scan backwards, the iterator + state must be already cached, so there's no need to know the + embedding level of the previous character, since we will be + returning to our caller shortly. */ + prev_level = bidi_it->level_stack[bidi_it->stack_idx].level; + } + next_for_neutral = bidi_it->next_for_neutral; + + /* Perhaps it is already cached. */ + type = bidi_cache_find (bidi_it->charpos + bidi_it->scan_dir, -1, bidi_it); + if (type != UNKNOWN_BT) + { + /* Don't lose the information for resolving neutrals! The + cached states could have been cached before their + next_for_neutral member was computed. If we are on our way + forward, we can simply take the info from the previous + state. */ + if (bidi_it->scan_dir == 1 + && bidi_it->next_for_neutral.type == UNKNOWN_BT) + bidi_it->next_for_neutral = next_for_neutral; + + /* If resolved_level is -1, it means this state was cached + before it was completely resolved, so we cannot return + it. */ + if (bidi_it->resolved_level != -1) + return bidi_it->resolved_level; + } + if (bidi_it->scan_dir == -1) + /* If we are going backwards, the iterator state is already cached + from previous scans, and should be fully resolved. */ + abort (); + + if (type == UNKNOWN_BT) + type = bidi_type_of_next_char (bidi_it); + + if (type == NEUTRAL_B) + return bidi_it->resolved_level; + + level = bidi_it->level_stack[bidi_it->stack_idx].level; + if ((bidi_get_category (type) == NEUTRAL /* && type != NEUTRAL_B */) + || (type == WEAK_BN && prev_level == level)) + { + if (bidi_it->next_for_neutral.type == UNKNOWN_BT) + abort (); + + /* If the cached state shows a neutral character, it was not + resolved by bidi_resolve_neutral, so do it now. */ + type = bidi_resolve_neutral_1 (bidi_it->prev_for_neutral.type, + bidi_it->next_for_neutral.type, + level); + } + + if (!(type == STRONG_R + || type == STRONG_L + || type == WEAK_BN + || type == WEAK_EN + || type == WEAK_AN)) + abort (); + bidi_it->type = type; + bidi_check_type (bidi_it->type); + + /* For L1 below, we need to know, for each WS character, whether + it belongs to a sequence of WS characters preceeding a newline + or a TAB or a paragraph separator. */ + if (bidi_it->orig_type == NEUTRAL_WS + && bidi_it->next_for_ws.type == UNKNOWN_BT) + { + int ch; + int clen = bidi_it->ch_len; + EMACS_INT bpos = bidi_it->bytepos; + EMACS_INT cpos = bidi_it->charpos; + bidi_type_t chtype; + + do { + /*_fetch_multibyte_char_len = 1;*/ + ch = bpos + clen >= ZV_BYTE ? BIDI_EOB : FETCH_CHAR (bpos + clen); + bpos += clen; + cpos++; + clen = (ch == BIDI_EOB ? 1 : CHAR_BYTES (ch)); + if (ch == '\n' || ch == BIDI_EOB /* || ch == LINESEP_CHAR */) + chtype = NEUTRAL_B; + else + chtype = bidi_get_type (ch, NEUTRAL_DIR); + } while (chtype == NEUTRAL_WS || chtype == WEAK_BN + || bidi_explicit_dir_char (ch)); /* L1/Retaining */ + bidi_it->next_for_ws.type = chtype; + bidi_check_type (bidi_it->next_for_ws.type); + bidi_it->next_for_ws.charpos = cpos; + bidi_it->next_for_ws.bytepos = bpos; + } + + /* Resolve implicit levels, with a twist: PDFs get the embedding + level of the enbedding they terminate. See below for the + reason. */ + if (bidi_it->orig_type == PDF + /* Don't do this if this formatting code didn't change the + embedding level due to invalid or empty embeddings. */ + && prev_level != level) + { + /* Don't look in UAX#9 for the reason for this: it's our own + private quirk. The reason is that we want the formatting + codes to be delivered so that they bracket the text of their + embedding. For example, given the text + + {RLO}teST{PDF} + + we want it to be displayed as + + {PDF}STet{RLO} + + not as + + STet{RLO}{PDF} + + which will result because we bump up the embedding level as + soon as we see the RLO and pop it as soon as we see the PDF, + so RLO itself has the same embedding level as "teST", and + thus would be normally delivered last, just before the PDF. + The switch below fiddles with the level of PDF so that this + ugly side effect does not happen. + + (This is, of course, only important if the formatting codes + are actually displayed, but Emacs does need to display them + if the user wants to.) */ + level = prev_level; + } + else if (bidi_it->orig_type == NEUTRAL_B /* L1 */ + || bidi_it->orig_type == NEUTRAL_S + || bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB + /* || bidi_it->ch == LINESEP_CHAR */ + || (bidi_it->orig_type == NEUTRAL_WS + && (bidi_it->next_for_ws.type == NEUTRAL_B + || bidi_it->next_for_ws.type == NEUTRAL_S))) + level = bidi_it->level_stack[0].level; + else if ((level & 1) == 0) /* I1 */ + { + if (type == STRONG_R) + level++; + else if (type == WEAK_EN || type == WEAK_AN) + level += 2; + } + else /* I2 */ + { + if (type == STRONG_L || type == WEAK_EN || type == WEAK_AN) + level++; + } + + bidi_it->resolved_level = level; + return level; +} + +/* Move to the other edge of a level given by LEVEL. If END_FLAG is + non-zero, we are at the end of a level, and we need to prepare to + resume the scan of the lower level. + + If this level's other edge is cached, we simply jump to it, filling + the iterator structure with the iterator state on the other edge. + Otherwise, we walk the buffer until we come back to the same level + as LEVEL. + + Note: we are not talking here about a ``level run'' in the UAX#9 + sense of the term, but rather about a ``level'' which includes + all the levels higher than it. In other words, given the levels + like this: + + 11111112222222333333334443343222222111111112223322111 + A B C + + and assuming we are at point A scanning left to right, this + function moves to point C, whereas the UAX#9 ``level 2 run'' ends + at point B. */ +static void +bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, int end_flag) +{ + int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir; + int idx; + + /* Try the cache first. */ + if ((idx = bidi_cache_find_level_change (level, dir, end_flag)) >= 0) + bidi_cache_fetch_state (idx, bidi_it); + else + { + int new_level; + + if (end_flag) + abort (); /* if we are at end of level, its edges must be cached */ + + bidi_cache_iterator_state (bidi_it, 1); + do { + new_level = bidi_level_of_next_char (bidi_it); + bidi_cache_iterator_state (bidi_it, 1); + } while (new_level >= level); + } +} + +void +bidi_move_to_visually_next (struct bidi_it *bidi_it) +{ + int old_level, new_level, next_level; + struct bidi_it sentinel; + + if (bidi_it->scan_dir == 0) + { + bidi_it->scan_dir = 1; /* default to logical order */ + } + + /* If we just passed a newline, initialize for the next line. */ + if (!bidi_it->first_elt && bidi_it->orig_type == NEUTRAL_B) + bidi_line_init (bidi_it); + + /* Prepare the sentinel iterator state, and cache it. When we bump + into it, scanning backwards, we'll know that the last non-base + level is exhausted. */ + if (bidi_cache_idx == 0) + { + bidi_copy_it (&sentinel, bidi_it); + if (bidi_it->first_elt) + { + sentinel.charpos--; /* cached charpos needs to be monotonic */ + sentinel.bytepos--; + sentinel.ch = '\n'; /* doesn't matter, but why not? */ + sentinel.ch_len = 1; + } + bidi_cache_iterator_state (&sentinel, 1); + } + + old_level = bidi_it->resolved_level; + new_level = bidi_level_of_next_char (bidi_it); + + /* Reordering of resolved levels (clause L2) is implemented by + jumping to the other edge of the level and flipping direction of + scanning the text whenever we find a level change. */ + if (new_level != old_level) + { + int ascending = new_level > old_level; + int level_to_search = ascending ? old_level + 1 : old_level; + int incr = ascending ? 1 : -1; + int expected_next_level = old_level + incr; + + /* Jump (or walk) to the other edge of this level. */ + bidi_find_other_level_edge (bidi_it, level_to_search, !ascending); + /* Switch scan direction and peek at the next character in the + new direction. */ + bidi_it->scan_dir = -bidi_it->scan_dir; + + /* The following loop handles the case where the resolved level + jumps by more than one. This is typical for numbers inside a + run of text with left-to-right embedding direction, but can + also happen in other situations. In those cases the decision + where to continue after a level change, and in what direction, + is tricky. For example, given a text like below: + + abcdefgh + 11336622 + + (where the numbers below the text show the resolved levels), + the result of reordering according to UAX#9 should be this: + + efdcghba + + This is implemented by the loop below which flips direction + and jumps to the other edge of the level each time it finds + the new level not to be the expected one. The expected level + is always one more or one less than the previous one. */ + next_level = bidi_peek_at_next_level (bidi_it); + while (next_level != expected_next_level) + { + expected_next_level += incr; + level_to_search += incr; + bidi_find_other_level_edge (bidi_it, level_to_search, !ascending); + bidi_it->scan_dir = -bidi_it->scan_dir; + next_level = bidi_peek_at_next_level (bidi_it); + } + + /* Finally, deliver the next character in the new direction. */ + next_level = bidi_level_of_next_char (bidi_it); + } + + /* Take note when we have just processed the newline that precedes + the end of the paragraph. The next time we are about to be + called, set_iterator_to_next will automatically reinit the + paragraph direction, if needed. We do this at the newline before + the paragraph separator, because the next character might not be + the first character of the next paragraph, due to the bidi + reordering, whereas we _must_ know the paragraph base direction + _before_ we process the paragraph's text, since the base + direction affects the reordering. */ + if (bidi_it->scan_dir == 1 + && bidi_it->orig_type == NEUTRAL_B + && bidi_it->bytepos < ZV_BYTE) + { + EMACS_INT sep_len = + bidi_at_paragraph_end (bidi_it->charpos + 1, + bidi_it->bytepos + bidi_it->ch_len); + if (sep_len >= 0) + { + bidi_it->new_paragraph = 1; + /* Record the buffer position of the last character of the + paragraph separator. */ + bidi_it->separator_limit = bidi_it->charpos + 1 + sep_len; + } + } + + if (bidi_it->scan_dir == 1 && bidi_cache_idx) + { + /* If we are at paragraph's base embedding level and beyond the + last cached position, the cache's job is done and we can + discard it. */ + if (bidi_it->resolved_level == bidi_it->level_stack[0].level + && bidi_it->charpos > bidi_cache[bidi_cache_idx - 1].charpos) + bidi_cache_reset (); + /* But as long as we are caching during forward scan, we must + cache each state, or else the cache integrity will be + compromised: it assumes cached states correspond to buffer + positions 1:1. */ + else + bidi_cache_iterator_state (bidi_it, 1); + } +} + +/* This is meant to be called from within the debugger, whenever you + wish to examine the cache contents. */ +void +bidi_dump_cached_states (void) +{ + int i; + int ndigits = 1; + + if (bidi_cache_idx == 0) + { + fprintf (stderr, "The cache is empty.\n"); + return; + } + fprintf (stderr, "Total of %d state%s in cache:\n", + bidi_cache_idx, bidi_cache_idx == 1 ? "" : "s"); + + for (i = bidi_cache[bidi_cache_idx - 1].charpos; i > 0; i /= 10) + ndigits++; + fputs ("ch ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*c", ndigits, bidi_cache[i].ch); + fputs ("\n", stderr); + fputs ("lvl ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*d", ndigits, bidi_cache[i].resolved_level); + fputs ("\n", stderr); + fputs ("pos ", stderr); + for (i = 0; i < bidi_cache_idx; i++) + fprintf (stderr, "%*ld", ndigits, (long)bidi_cache[i].charpos); + fputs ("\n", stderr); +} diff --git a/src/bidimirror.h b/src/bidimirror.h new file mode 100644 index 00000000000..477f983ad64 --- /dev/null +++ b/src/bidimirror.h @@ -0,0 +1,365 @@ + struct { + int from, to; + } bidi_mirror[] = { + { 0x0028, 0x0029 }, + { 0x0029, 0x0028 }, + { 0x003C, 0x003E }, + { 0x003E, 0x003C }, + { 0x005B, 0x005D }, + { 0x005D, 0x005B }, + { 0x007B, 0x007D }, + { 0x007D, 0x007B }, + { 0x00AB, 0x00BB }, + { 0x00BB, 0x00AB }, + { 0x0F3A, 0x0F3B }, + { 0x0F3B, 0x0F3A }, + { 0x0F3C, 0x0F3D }, + { 0x0F3D, 0x0F3C }, + { 0x169B, 0x169C }, + { 0x169C, 0x169B }, + { 0x2039, 0x203A }, + { 0x203A, 0x2039 }, + { 0x2045, 0x2046 }, + { 0x2046, 0x2045 }, + { 0x207D, 0x207E }, + { 0x207E, 0x207D }, + { 0x208D, 0x208E }, + { 0x208E, 0x208D }, + { 0x2208, 0x220B }, + { 0x2209, 0x220C }, + { 0x220A, 0x220D }, + { 0x220B, 0x2208 }, + { 0x220C, 0x2209 }, + { 0x220D, 0x220A }, + { 0x2215, 0x29F5 }, + { 0x223C, 0x223D }, + { 0x223D, 0x223C }, + { 0x2243, 0x22CD }, + { 0x2252, 0x2253 }, + { 0x2253, 0x2252 }, + { 0x2254, 0x2255 }, + { 0x2255, 0x2254 }, + { 0x2264, 0x2265 }, + { 0x2265, 0x2264 }, + { 0x2266, 0x2267 }, + { 0x2267, 0x2266 }, + { 0x2268, 0x2269 }, + { 0x2269, 0x2268 }, + { 0x226A, 0x226B }, + { 0x226B, 0x226A }, + { 0x226E, 0x226F }, + { 0x226F, 0x226E }, + { 0x2270, 0x2271 }, + { 0x2271, 0x2270 }, + { 0x2272, 0x2273 }, + { 0x2273, 0x2272 }, + { 0x2274, 0x2275 }, + { 0x2275, 0x2274 }, + { 0x2276, 0x2277 }, + { 0x2277, 0x2276 }, + { 0x2278, 0x2279 }, + { 0x2279, 0x2278 }, + { 0x227A, 0x227B }, + { 0x227B, 0x227A }, + { 0x227C, 0x227D }, + { 0x227D, 0x227C }, + { 0x227E, 0x227F }, + { 0x227F, 0x227E }, + { 0x2280, 0x2281 }, + { 0x2281, 0x2280 }, + { 0x2282, 0x2283 }, + { 0x2283, 0x2282 }, + { 0x2284, 0x2285 }, + { 0x2285, 0x2284 }, + { 0x2286, 0x2287 }, + { 0x2287, 0x2286 }, + { 0x2288, 0x2289 }, + { 0x2289, 0x2288 }, + { 0x228A, 0x228B }, + { 0x228B, 0x228A }, + { 0x228F, 0x2290 }, + { 0x2290, 0x228F }, + { 0x2291, 0x2292 }, + { 0x2292, 0x2291 }, + { 0x2298, 0x29B8 }, + { 0x22A2, 0x22A3 }, + { 0x22A3, 0x22A2 }, + { 0x22A6, 0x2ADE }, + { 0x22A8, 0x2AE4 }, + { 0x22A9, 0x2AE3 }, + { 0x22AB, 0x2AE5 }, + { 0x22B0, 0x22B1 }, + { 0x22B1, 0x22B0 }, + { 0x22B2, 0x22B3 }, + { 0x22B3, 0x22B2 }, + { 0x22B4, 0x22B5 }, + { 0x22B5, 0x22B4 }, + { 0x22B6, 0x22B7 }, + { 0x22B7, 0x22B6 }, + { 0x22C9, 0x22CA }, + { 0x22CA, 0x22C9 }, + { 0x22CB, 0x22CC }, + { 0x22CC, 0x22CB }, + { 0x22CD, 0x2243 }, + { 0x22D0, 0x22D1 }, + { 0x22D1, 0x22D0 }, + { 0x22D6, 0x22D7 }, + { 0x22D7, 0x22D6 }, + { 0x22D8, 0x22D9 }, + { 0x22D9, 0x22D8 }, + { 0x22DA, 0x22DB }, + { 0x22DB, 0x22DA }, + { 0x22DC, 0x22DD }, + { 0x22DD, 0x22DC }, + { 0x22DE, 0x22DF }, + { 0x22DF, 0x22DE }, + { 0x22E0, 0x22E1 }, + { 0x22E1, 0x22E0 }, + { 0x22E2, 0x22E3 }, + { 0x22E3, 0x22E2 }, + { 0x22E4, 0x22E5 }, + { 0x22E5, 0x22E4 }, + { 0x22E6, 0x22E7 }, + { 0x22E7, 0x22E6 }, + { 0x22E8, 0x22E9 }, + { 0x22E9, 0x22E8 }, + { 0x22EA, 0x22EB }, + { 0x22EB, 0x22EA }, + { 0x22EC, 0x22ED }, + { 0x22ED, 0x22EC }, + { 0x22F0, 0x22F1 }, + { 0x22F1, 0x22F0 }, + { 0x22F2, 0x22FA }, + { 0x22F3, 0x22FB }, + { 0x22F4, 0x22FC }, + { 0x22F6, 0x22FD }, + { 0x22F7, 0x22FE }, + { 0x22FA, 0x22F2 }, + { 0x22FB, 0x22F3 }, + { 0x22FC, 0x22F4 }, + { 0x22FD, 0x22F6 }, + { 0x22FE, 0x22F7 }, + { 0x2308, 0x2309 }, + { 0x2309, 0x2308 }, + { 0x230A, 0x230B }, + { 0x230B, 0x230A }, + { 0x2329, 0x232A }, + { 0x232A, 0x2329 }, + { 0x2768, 0x2769 }, + { 0x2769, 0x2768 }, + { 0x276A, 0x276B }, + { 0x276B, 0x276A }, + { 0x276C, 0x276D }, + { 0x276D, 0x276C }, + { 0x276E, 0x276F }, + { 0x276F, 0x276E }, + { 0x2770, 0x2771 }, + { 0x2771, 0x2770 }, + { 0x2772, 0x2773 }, + { 0x2773, 0x2772 }, + { 0x2774, 0x2775 }, + { 0x2775, 0x2774 }, + { 0x27C3, 0x27C4 }, + { 0x27C4, 0x27C3 }, + { 0x27C5, 0x27C6 }, + { 0x27C6, 0x27C5 }, + { 0x27C8, 0x27C9 }, + { 0x27C9, 0x27C8 }, + { 0x27D5, 0x27D6 }, + { 0x27D6, 0x27D5 }, + { 0x27DD, 0x27DE }, + { 0x27DE, 0x27DD }, + { 0x27E2, 0x27E3 }, + { 0x27E3, 0x27E2 }, + { 0x27E4, 0x27E5 }, + { 0x27E5, 0x27E4 }, + { 0x27E6, 0x27E7 }, + { 0x27E7, 0x27E6 }, + { 0x27E8, 0x27E9 }, + { 0x27E9, 0x27E8 }, + { 0x27EA, 0x27EB }, + { 0x27EB, 0x27EA }, + { 0x27EC, 0x27ED }, + { 0x27ED, 0x27EC }, + { 0x27EE, 0x27EF }, + { 0x27EF, 0x27EE }, + { 0x2983, 0x2984 }, + { 0x2984, 0x2983 }, + { 0x2985, 0x2986 }, + { 0x2986, 0x2985 }, + { 0x2987, 0x2988 }, + { 0x2988, 0x2987 }, + { 0x2989, 0x298A }, + { 0x298A, 0x2989 }, + { 0x298B, 0x298C }, + { 0x298C, 0x298B }, + { 0x298D, 0x2990 }, + { 0x298E, 0x298F }, + { 0x298F, 0x298E }, + { 0x2990, 0x298D }, + { 0x2991, 0x2992 }, + { 0x2992, 0x2991 }, + { 0x2993, 0x2994 }, + { 0x2994, 0x2993 }, + { 0x2995, 0x2996 }, + { 0x2996, 0x2995 }, + { 0x2997, 0x2998 }, + { 0x2998, 0x2997 }, + { 0x29B8, 0x2298 }, + { 0x29C0, 0x29C1 }, + { 0x29C1, 0x29C0 }, + { 0x29C4, 0x29C5 }, + { 0x29C5, 0x29C4 }, + { 0x29CF, 0x29D0 }, + { 0x29D0, 0x29CF }, + { 0x29D1, 0x29D2 }, + { 0x29D2, 0x29D1 }, + { 0x29D4, 0x29D5 }, + { 0x29D5, 0x29D4 }, + { 0x29D8, 0x29D9 }, + { 0x29D9, 0x29D8 }, + { 0x29DA, 0x29DB }, + { 0x29DB, 0x29DA }, + { 0x29F5, 0x2215 }, + { 0x29F8, 0x29F9 }, + { 0x29F9, 0x29F8 }, + { 0x29FC, 0x29FD }, + { 0x29FD, 0x29FC }, + { 0x2A2B, 0x2A2C }, + { 0x2A2C, 0x2A2B }, + { 0x2A2D, 0x2A2E }, + { 0x2A2E, 0x2A2D }, + { 0x2A34, 0x2A35 }, + { 0x2A35, 0x2A34 }, + { 0x2A3C, 0x2A3D }, + { 0x2A3D, 0x2A3C }, + { 0x2A64, 0x2A65 }, + { 0x2A65, 0x2A64 }, + { 0x2A79, 0x2A7A }, + { 0x2A7A, 0x2A79 }, + { 0x2A7D, 0x2A7E }, + { 0x2A7E, 0x2A7D }, + { 0x2A7F, 0x2A80 }, + { 0x2A80, 0x2A7F }, + { 0x2A81, 0x2A82 }, + { 0x2A82, 0x2A81 }, + { 0x2A83, 0x2A84 }, + { 0x2A84, 0x2A83 }, + { 0x2A8B, 0x2A8C }, + { 0x2A8C, 0x2A8B }, + { 0x2A91, 0x2A92 }, + { 0x2A92, 0x2A91 }, + { 0x2A93, 0x2A94 }, + { 0x2A94, 0x2A93 }, + { 0x2A95, 0x2A96 }, + { 0x2A96, 0x2A95 }, + { 0x2A97, 0x2A98 }, + { 0x2A98, 0x2A97 }, + { 0x2A99, 0x2A9A }, + { 0x2A9A, 0x2A99 }, + { 0x2A9B, 0x2A9C }, + { 0x2A9C, 0x2A9B }, + { 0x2AA1, 0x2AA2 }, + { 0x2AA2, 0x2AA1 }, + { 0x2AA6, 0x2AA7 }, + { 0x2AA7, 0x2AA6 }, + { 0x2AA8, 0x2AA9 }, + { 0x2AA9, 0x2AA8 }, + { 0x2AAA, 0x2AAB }, + { 0x2AAB, 0x2AAA }, + { 0x2AAC, 0x2AAD }, + { 0x2AAD, 0x2AAC }, + { 0x2AAF, 0x2AB0 }, + { 0x2AB0, 0x2AAF }, + { 0x2AB3, 0x2AB4 }, + { 0x2AB4, 0x2AB3 }, + { 0x2ABB, 0x2ABC }, + { 0x2ABC, 0x2ABB }, + { 0x2ABD, 0x2ABE }, + { 0x2ABE, 0x2ABD }, + { 0x2ABF, 0x2AC0 }, + { 0x2AC0, 0x2ABF }, + { 0x2AC1, 0x2AC2 }, + { 0x2AC2, 0x2AC1 }, + { 0x2AC3, 0x2AC4 }, + { 0x2AC4, 0x2AC3 }, + { 0x2AC5, 0x2AC6 }, + { 0x2AC6, 0x2AC5 }, + { 0x2ACD, 0x2ACE }, + { 0x2ACE, 0x2ACD }, + { 0x2ACF, 0x2AD0 }, + { 0x2AD0, 0x2ACF }, + { 0x2AD1, 0x2AD2 }, + { 0x2AD2, 0x2AD1 }, + { 0x2AD3, 0x2AD4 }, + { 0x2AD4, 0x2AD3 }, + { 0x2AD5, 0x2AD6 }, + { 0x2AD6, 0x2AD5 }, + { 0x2ADE, 0x22A6 }, + { 0x2AE3, 0x22A9 }, + { 0x2AE4, 0x22A8 }, + { 0x2AE5, 0x22AB }, + { 0x2AEC, 0x2AED }, + { 0x2AED, 0x2AEC }, + { 0x2AF7, 0x2AF8 }, + { 0x2AF8, 0x2AF7 }, + { 0x2AF9, 0x2AFA }, + { 0x2AFA, 0x2AF9 }, + { 0x2E02, 0x2E03 }, + { 0x2E03, 0x2E02 }, + { 0x2E04, 0x2E05 }, + { 0x2E05, 0x2E04 }, + { 0x2E09, 0x2E0A }, + { 0x2E0A, 0x2E09 }, + { 0x2E0C, 0x2E0D }, + { 0x2E0D, 0x2E0C }, + { 0x2E1C, 0x2E1D }, + { 0x2E1D, 0x2E1C }, + { 0x2E20, 0x2E21 }, + { 0x2E21, 0x2E20 }, + { 0x2E22, 0x2E23 }, + { 0x2E23, 0x2E22 }, + { 0x2E24, 0x2E25 }, + { 0x2E25, 0x2E24 }, + { 0x2E26, 0x2E27 }, + { 0x2E27, 0x2E26 }, + { 0x2E28, 0x2E29 }, + { 0x2E29, 0x2E28 }, + { 0x3008, 0x3009 }, + { 0x3009, 0x3008 }, + { 0x300A, 0x300B }, + { 0x300B, 0x300A }, + { 0x300C, 0x300D }, + { 0x300D, 0x300C }, + { 0x300E, 0x300F }, + { 0x300F, 0x300E }, + { 0x3010, 0x3011 }, + { 0x3011, 0x3010 }, + { 0x3014, 0x3015 }, + { 0x3015, 0x3014 }, + { 0x3016, 0x3017 }, + { 0x3017, 0x3016 }, + { 0x3018, 0x3019 }, + { 0x3019, 0x3018 }, + { 0x301A, 0x301B }, + { 0x301B, 0x301A }, + { 0xFE59, 0xFE5A }, + { 0xFE5A, 0xFE59 }, + { 0xFE5B, 0xFE5C }, + { 0xFE5C, 0xFE5B }, + { 0xFE5D, 0xFE5E }, + { 0xFE5E, 0xFE5D }, + { 0xFE64, 0xFE65 }, + { 0xFE65, 0xFE64 }, + { 0xFF08, 0xFF09 }, + { 0xFF09, 0xFF08 }, + { 0xFF1C, 0xFF1E }, + { 0xFF1E, 0xFF1C }, + { 0xFF3B, 0xFF3D }, + { 0xFF3D, 0xFF3B }, + { 0xFF5B, 0xFF5D }, + { 0xFF5D, 0xFF5B }, + { 0xFF5F, 0xFF60 }, + { 0xFF60, 0xFF5F }, + { 0xFF62, 0xFF63 }, + { 0xFF63, 0xFF62 } }; diff --git a/src/biditype.h b/src/biditype.h new file mode 100644 index 00000000000..868aabd9ea6 --- /dev/null +++ b/src/biditype.h @@ -0,0 +1,447 @@ + struct { + int from, to; + bidi_type_t type; + } bidi_type[] = { + { 0x0000, 0x0008, WEAK_BN }, + { 0x0009, 0x0009, NEUTRAL_S }, + { 0x000A, 0x000A, NEUTRAL_B }, + { 0x000B, 0x000B, NEUTRAL_S }, + { 0x000C, 0x000C, NEUTRAL_WS }, + { 0x000D, 0x000D, NEUTRAL_B }, + { 0x000E, 0x001B, WEAK_BN }, + { 0x001C, 0x001E, NEUTRAL_B }, + { 0x001F, 0x001F, NEUTRAL_S }, + { 0x0020, 0x0020, NEUTRAL_WS }, + { 0x0021, 0x0022, NEUTRAL_ON }, + { 0x0023, 0x0025, WEAK_ET }, + { 0x0026, 0x002A, NEUTRAL_ON }, + { 0x002B, 0x002B, WEAK_ES }, + { 0x002C, 0x002C, WEAK_CS }, + { 0x002D, 0x002D, WEAK_ES }, + { 0x002E, 0x002F, WEAK_CS }, + { 0x0030, 0x0039, WEAK_EN }, + { 0x003A, 0x003A, WEAK_CS }, + { 0x003B, 0x0040, NEUTRAL_ON }, + { 0x005B, 0x0060, NEUTRAL_ON }, + { 0x007B, 0x007E, NEUTRAL_ON }, + { 0x007F, 0x0084, WEAK_BN }, + { 0x0085, 0x0085, NEUTRAL_B }, + { 0x0086, 0x009F, WEAK_BN }, + { 0x00A0, 0x00A0, WEAK_CS }, + { 0x00A1, 0x00A1, NEUTRAL_ON }, + { 0x00A2, 0x00A5, WEAK_ET }, + { 0x00A6, 0x00A9, NEUTRAL_ON }, + { 0x00AB, 0x00AC, NEUTRAL_ON }, + { 0x00AD, 0x00AD, WEAK_BN }, + { 0x00AE, 0x00AF, NEUTRAL_ON }, + { 0x00B0, 0x00B1, WEAK_ET }, + { 0x00B2, 0x00B3, WEAK_EN }, + { 0x00B4, 0x00B4, NEUTRAL_ON }, + { 0x00B6, 0x00B8, NEUTRAL_ON }, + { 0x00B9, 0x00B9, WEAK_EN }, + { 0x00BB, 0x00BF, NEUTRAL_ON }, + { 0x00D7, 0x00D7, NEUTRAL_ON }, + { 0x00F7, 0x00F7, NEUTRAL_ON }, + { 0x02B9, 0x02BA, NEUTRAL_ON }, + { 0x02C2, 0x02CF, NEUTRAL_ON }, + { 0x02D2, 0x02DF, NEUTRAL_ON }, + { 0x02E5, 0x02ED, NEUTRAL_ON }, + { 0x02EF, 0x02FF, NEUTRAL_ON }, + { 0x0300, 0x036F, WEAK_NSM }, + { 0x0374, 0x0375, NEUTRAL_ON }, + { 0x037E, 0x0385, NEUTRAL_ON }, + { 0x0387, 0x0387, NEUTRAL_ON }, + { 0x03F6, 0x03F6, NEUTRAL_ON }, + { 0x0483, 0x0489, WEAK_NSM }, + { 0x058A, 0x058A, NEUTRAL_ON }, + { 0x0591, 0x05BD, WEAK_NSM }, + { 0x05BE, 0x05BE, STRONG_R }, + { 0x05BF, 0x05BF, WEAK_NSM }, + { 0x05C0, 0x05C0, STRONG_R }, + { 0x05C1, 0x05C2, WEAK_NSM }, + { 0x05C3, 0x05C3, STRONG_R }, + { 0x05C4, 0x05C5, WEAK_NSM }, + { 0x05C6, 0x05C6, STRONG_R }, + { 0x05C7, 0x05C7, WEAK_NSM }, + { 0x05D0, 0x05F4, STRONG_R }, + { 0x0600, 0x0603, WEAK_AN }, + { 0x0606, 0x0607, NEUTRAL_ON }, + { 0x0608, 0x0608, STRONG_AL }, + { 0x0609, 0x060A, WEAK_ET }, + { 0x060B, 0x060B, STRONG_AL }, + { 0x060C, 0x060C, WEAK_CS }, + { 0x060D, 0x060D, STRONG_AL }, + { 0x060E, 0x060F, NEUTRAL_ON }, + { 0x0610, 0x061A, WEAK_NSM }, + { 0x061B, 0x064A, STRONG_AL }, + { 0x064B, 0x065F, WEAK_NSM }, + { 0x0660, 0x0669, WEAK_AN }, + { 0x066A, 0x066A, WEAK_ET }, + { 0x066B, 0x066C, WEAK_AN }, + { 0x066D, 0x066F, STRONG_AL }, + { 0x0670, 0x0670, WEAK_NSM }, + { 0x0671, 0x06D5, STRONG_AL }, + { 0x06D6, 0x06DC, WEAK_NSM }, + { 0x06DD, 0x06DD, WEAK_AN }, + { 0x06DE, 0x06DE, NEUTRAL_ON }, + { 0x06DF, 0x06E4, WEAK_NSM }, + { 0x06E5, 0x06E6, STRONG_AL }, + { 0x06E7, 0x06E8, WEAK_NSM }, + { 0x06E9, 0x06E9, NEUTRAL_ON }, + { 0x06EA, 0x06ED, WEAK_NSM }, + { 0x06EE, 0x06EF, STRONG_AL }, + { 0x06F0, 0x06F9, WEAK_EN }, + { 0x06FA, 0x070D, STRONG_AL }, + { 0x070F, 0x070F, WEAK_AN }, + { 0x0710, 0x0710, STRONG_AL }, + { 0x0711, 0x0711, WEAK_NSM }, + { 0x0712, 0x072F, STRONG_AL }, + { 0x0730, 0x074A, WEAK_NSM }, + { 0x074D, 0x07A5, STRONG_AL }, + { 0x07A6, 0x07B0, WEAK_NSM }, + { 0x07B1, 0x07B1, STRONG_AL }, + { 0x07C0, 0x07EA, STRONG_R }, + { 0x07EB, 0x07F3, WEAK_NSM }, + { 0x07F4, 0x07F5, STRONG_R }, + { 0x07F6, 0x07F9, NEUTRAL_ON }, + { 0x07FA, 0x0815, STRONG_R }, + { 0x0816, 0x0819, WEAK_NSM }, + { 0x081A, 0x081A, STRONG_R }, + { 0x081B, 0x0823, WEAK_NSM }, + { 0x0824, 0x0824, STRONG_R }, + { 0x0825, 0x0827, WEAK_NSM }, + { 0x0828, 0x0828, STRONG_R }, + { 0x0829, 0x082D, WEAK_NSM }, + { 0x0830, 0x0858, STRONG_R }, + { 0x0859, 0x085B, WEAK_NSM }, + { 0x085E, 0x085E, STRONG_R }, + { 0x0900, 0x0902, WEAK_NSM }, + { 0x093A, 0x093A, WEAK_NSM }, + { 0x093C, 0x093C, WEAK_NSM }, + { 0x0941, 0x0948, WEAK_NSM }, + { 0x094D, 0x094D, WEAK_NSM }, + { 0x0951, 0x0957, WEAK_NSM }, + { 0x0962, 0x0963, WEAK_NSM }, + { 0x0981, 0x0981, WEAK_NSM }, + { 0x09BC, 0x09BC, WEAK_NSM }, + { 0x09C1, 0x09C4, WEAK_NSM }, + { 0x09CD, 0x09CD, WEAK_NSM }, + { 0x09E2, 0x09E3, WEAK_NSM }, + { 0x09F2, 0x09F3, WEAK_ET }, + { 0x09FB, 0x09FB, WEAK_ET }, + { 0x0A01, 0x0A02, WEAK_NSM }, + { 0x0A3C, 0x0A3C, WEAK_NSM }, + { 0x0A41, 0x0A51, WEAK_NSM }, + { 0x0A70, 0x0A71, WEAK_NSM }, + { 0x0A75, 0x0A82, WEAK_NSM }, + { 0x0ABC, 0x0ABC, WEAK_NSM }, + { 0x0AC1, 0x0AC8, WEAK_NSM }, + { 0x0ACD, 0x0ACD, WEAK_NSM }, + { 0x0AE2, 0x0AE3, WEAK_NSM }, + { 0x0AF1, 0x0AF1, WEAK_ET }, + { 0x0B01, 0x0B01, WEAK_NSM }, + { 0x0B3C, 0x0B3C, WEAK_NSM }, + { 0x0B3F, 0x0B3F, WEAK_NSM }, + { 0x0B41, 0x0B44, WEAK_NSM }, + { 0x0B4D, 0x0B56, WEAK_NSM }, + { 0x0B62, 0x0B63, WEAK_NSM }, + { 0x0B82, 0x0B82, WEAK_NSM }, + { 0x0BC0, 0x0BC0, WEAK_NSM }, + { 0x0BCD, 0x0BCD, WEAK_NSM }, + { 0x0BF3, 0x0BF8, NEUTRAL_ON }, + { 0x0BF9, 0x0BF9, WEAK_ET }, + { 0x0BFA, 0x0BFA, NEUTRAL_ON }, + { 0x0C3E, 0x0C40, WEAK_NSM }, + { 0x0C46, 0x0C56, WEAK_NSM }, + { 0x0C62, 0x0C63, WEAK_NSM }, + { 0x0C78, 0x0C7E, NEUTRAL_ON }, + { 0x0CBC, 0x0CBC, WEAK_NSM }, + { 0x0CCC, 0x0CCD, WEAK_NSM }, + { 0x0CE2, 0x0CE3, WEAK_NSM }, + { 0x0D41, 0x0D44, WEAK_NSM }, + { 0x0D4D, 0x0D4D, WEAK_NSM }, + { 0x0D62, 0x0D63, WEAK_NSM }, + { 0x0DCA, 0x0DCA, WEAK_NSM }, + { 0x0DD2, 0x0DD6, WEAK_NSM }, + { 0x0E31, 0x0E31, WEAK_NSM }, + { 0x0E34, 0x0E3A, WEAK_NSM }, + { 0x0E3F, 0x0E3F, WEAK_ET }, + { 0x0E47, 0x0E4E, WEAK_NSM }, + { 0x0EB1, 0x0EB1, WEAK_NSM }, + { 0x0EB4, 0x0EBC, WEAK_NSM }, + { 0x0EC8, 0x0ECD, WEAK_NSM }, + { 0x0F18, 0x0F19, WEAK_NSM }, + { 0x0F35, 0x0F35, WEAK_NSM }, + { 0x0F37, 0x0F37, WEAK_NSM }, + { 0x0F39, 0x0F39, WEAK_NSM }, + { 0x0F3A, 0x0F3D, NEUTRAL_ON }, + { 0x0F71, 0x0F7E, WEAK_NSM }, + { 0x0F80, 0x0F84, WEAK_NSM }, + { 0x0F86, 0x0F87, WEAK_NSM }, + { 0x0F8D, 0x0FBC, WEAK_NSM }, + { 0x0FC6, 0x0FC6, WEAK_NSM }, + { 0x102D, 0x1030, WEAK_NSM }, + { 0x1032, 0x1037, WEAK_NSM }, + { 0x1039, 0x103A, WEAK_NSM }, + { 0x103D, 0x103E, WEAK_NSM }, + { 0x1058, 0x1059, WEAK_NSM }, + { 0x105E, 0x1060, WEAK_NSM }, + { 0x1071, 0x1074, WEAK_NSM }, + { 0x1082, 0x1082, WEAK_NSM }, + { 0x1085, 0x1086, WEAK_NSM }, + { 0x108D, 0x108D, WEAK_NSM }, + { 0x109D, 0x109D, WEAK_NSM }, + { 0x135D, 0x135F, WEAK_NSM }, + { 0x1390, 0x1399, NEUTRAL_ON }, + { 0x1400, 0x1400, NEUTRAL_ON }, + { 0x1680, 0x1680, NEUTRAL_WS }, + { 0x169B, 0x169C, NEUTRAL_ON }, + { 0x1712, 0x1714, WEAK_NSM }, + { 0x1732, 0x1734, WEAK_NSM }, + { 0x1752, 0x1753, WEAK_NSM }, + { 0x1772, 0x1773, WEAK_NSM }, + { 0x17B7, 0x17BD, WEAK_NSM }, + { 0x17C6, 0x17C6, WEAK_NSM }, + { 0x17C9, 0x17D3, WEAK_NSM }, + { 0x17DB, 0x17DB, WEAK_ET }, + { 0x17DD, 0x17DD, WEAK_NSM }, + { 0x17F0, 0x180A, NEUTRAL_ON }, + { 0x180B, 0x180D, WEAK_NSM }, + { 0x180E, 0x180E, NEUTRAL_WS }, + { 0x18A9, 0x18A9, WEAK_NSM }, + { 0x1920, 0x1922, WEAK_NSM }, + { 0x1927, 0x1928, WEAK_NSM }, + { 0x1932, 0x1932, WEAK_NSM }, + { 0x1939, 0x193B, WEAK_NSM }, + { 0x1940, 0x1945, NEUTRAL_ON }, + { 0x19DE, 0x19FF, NEUTRAL_ON }, + { 0x1A17, 0x1A18, WEAK_NSM }, + { 0x1A56, 0x1A56, WEAK_NSM }, + { 0x1A58, 0x1A60, WEAK_NSM }, + { 0x1A62, 0x1A62, WEAK_NSM }, + { 0x1A65, 0x1A6C, WEAK_NSM }, + { 0x1A73, 0x1A7F, WEAK_NSM }, + { 0x1B00, 0x1B03, WEAK_NSM }, + { 0x1B34, 0x1B34, WEAK_NSM }, + { 0x1B36, 0x1B3A, WEAK_NSM }, + { 0x1B3C, 0x1B3C, WEAK_NSM }, + { 0x1B42, 0x1B42, WEAK_NSM }, + { 0x1B6B, 0x1B73, WEAK_NSM }, + { 0x1B80, 0x1B81, WEAK_NSM }, + { 0x1BA2, 0x1BA5, WEAK_NSM }, + { 0x1BA8, 0x1BA9, WEAK_NSM }, + { 0x1BE6, 0x1BE6, WEAK_NSM }, + { 0x1BE8, 0x1BE9, WEAK_NSM }, + { 0x1BED, 0x1BED, WEAK_NSM }, + { 0x1BEF, 0x1BF1, WEAK_NSM }, + { 0x1C2C, 0x1C33, WEAK_NSM }, + { 0x1C36, 0x1C37, WEAK_NSM }, + { 0x1CD0, 0x1CD2, WEAK_NSM }, + { 0x1CD4, 0x1CE0, WEAK_NSM }, + { 0x1CE2, 0x1CE8, WEAK_NSM }, + { 0x1CED, 0x1CED, WEAK_NSM }, + { 0x1DC0, 0x1DFF, WEAK_NSM }, + { 0x1FBD, 0x1FBD, NEUTRAL_ON }, + { 0x1FBF, 0x1FC1, NEUTRAL_ON }, + { 0x1FCD, 0x1FCF, NEUTRAL_ON }, + { 0x1FDD, 0x1FDF, NEUTRAL_ON }, + { 0x1FED, 0x1FEF, NEUTRAL_ON }, + { 0x1FFD, 0x1FFE, NEUTRAL_ON }, + { 0x2000, 0x200A, NEUTRAL_WS }, + { 0x200B, 0x200D, WEAK_BN }, + { 0x200F, 0x200F, STRONG_R }, + { 0x2010, 0x2027, NEUTRAL_ON }, + { 0x2028, 0x2028, NEUTRAL_WS }, + { 0x2029, 0x2029, NEUTRAL_B }, + { 0x202A, 0x202A, LRE }, + { 0x202B, 0x202B, RLE }, + { 0x202C, 0x202C, PDF }, + { 0x202D, 0x202D, LRO }, + { 0x202E, 0x202E, RLO }, + { 0x202F, 0x202F, WEAK_CS }, + { 0x2030, 0x2034, WEAK_ET }, + { 0x2035, 0x2043, NEUTRAL_ON }, + { 0x2044, 0x2044, WEAK_CS }, + { 0x2045, 0x205E, NEUTRAL_ON }, + { 0x205F, 0x205F, NEUTRAL_WS }, + { 0x2060, 0x206F, WEAK_BN }, + { 0x2070, 0x2070, WEAK_EN }, + { 0x2074, 0x2079, WEAK_EN }, + { 0x207A, 0x207B, WEAK_ES }, + { 0x207C, 0x207E, NEUTRAL_ON }, + { 0x2080, 0x2089, WEAK_EN }, + { 0x208A, 0x208B, WEAK_ES }, + { 0x208C, 0x208E, NEUTRAL_ON }, + { 0x20A0, 0x20B9, WEAK_ET }, + { 0x20D0, 0x20F0, WEAK_NSM }, + { 0x2100, 0x2101, NEUTRAL_ON }, + { 0x2103, 0x2106, NEUTRAL_ON }, + { 0x2108, 0x2109, NEUTRAL_ON }, + { 0x2114, 0x2114, NEUTRAL_ON }, + { 0x2116, 0x2118, NEUTRAL_ON }, + { 0x211E, 0x2123, NEUTRAL_ON }, + { 0x2125, 0x2125, NEUTRAL_ON }, + { 0x2127, 0x2127, NEUTRAL_ON }, + { 0x2129, 0x2129, NEUTRAL_ON }, + { 0x212E, 0x212E, WEAK_ET }, + { 0x213A, 0x213B, NEUTRAL_ON }, + { 0x2140, 0x2144, NEUTRAL_ON }, + { 0x214A, 0x214D, NEUTRAL_ON }, + { 0x2150, 0x215F, NEUTRAL_ON }, + { 0x2189, 0x2211, NEUTRAL_ON }, + { 0x2212, 0x2212, WEAK_ES }, + { 0x2213, 0x2213, WEAK_ET }, + { 0x2214, 0x2335, NEUTRAL_ON }, + { 0x237B, 0x2394, NEUTRAL_ON }, + { 0x2396, 0x2487, NEUTRAL_ON }, + { 0x2488, 0x249B, WEAK_EN }, + { 0x24EA, 0x26AB, NEUTRAL_ON }, + { 0x26AD, 0x27FF, NEUTRAL_ON }, + { 0x2900, 0x2B59, NEUTRAL_ON }, + { 0x2CE5, 0x2CEA, NEUTRAL_ON }, + { 0x2CEF, 0x2CF1, WEAK_NSM }, + { 0x2CF9, 0x2CFF, NEUTRAL_ON }, + { 0x2D7F, 0x2D7F, WEAK_NSM }, + { 0x2DE0, 0x2DFF, WEAK_NSM }, + { 0x2E00, 0x2FFB, NEUTRAL_ON }, + { 0x3000, 0x3000, NEUTRAL_WS }, + { 0x3001, 0x3004, NEUTRAL_ON }, + { 0x3008, 0x3020, NEUTRAL_ON }, + { 0x302A, 0x302F, WEAK_NSM }, + { 0x3030, 0x3030, NEUTRAL_ON }, + { 0x3036, 0x3037, NEUTRAL_ON }, + { 0x303D, 0x303F, NEUTRAL_ON }, + { 0x3099, 0x309A, WEAK_NSM }, + { 0x309B, 0x309C, NEUTRAL_ON }, + { 0x30A0, 0x30A0, NEUTRAL_ON }, + { 0x30FB, 0x30FB, NEUTRAL_ON }, + { 0x31C0, 0x31E3, NEUTRAL_ON }, + { 0x321D, 0x321E, NEUTRAL_ON }, + { 0x3250, 0x325F, NEUTRAL_ON }, + { 0x327C, 0x327E, NEUTRAL_ON }, + { 0x32B1, 0x32BF, NEUTRAL_ON }, + { 0x32CC, 0x32CF, NEUTRAL_ON }, + { 0x3377, 0x337A, NEUTRAL_ON }, + { 0x33DE, 0x33DF, NEUTRAL_ON }, + { 0x33FF, 0x33FF, NEUTRAL_ON }, + { 0x4DC0, 0x4DFF, NEUTRAL_ON }, + { 0xA490, 0xA4C6, NEUTRAL_ON }, + { 0xA60D, 0xA60F, NEUTRAL_ON }, + { 0xA66F, 0xA672, WEAK_NSM }, + { 0xA673, 0xA673, NEUTRAL_ON }, + { 0xA67C, 0xA67D, WEAK_NSM }, + { 0xA67E, 0xA67F, NEUTRAL_ON }, + { 0xA6F0, 0xA6F1, WEAK_NSM }, + { 0xA700, 0xA721, NEUTRAL_ON }, + { 0xA788, 0xA788, NEUTRAL_ON }, + { 0xA802, 0xA802, WEAK_NSM }, + { 0xA806, 0xA806, WEAK_NSM }, + { 0xA80B, 0xA80B, WEAK_NSM }, + { 0xA825, 0xA826, WEAK_NSM }, + { 0xA828, 0xA82B, NEUTRAL_ON }, + { 0xA838, 0xA839, WEAK_ET }, + { 0xA874, 0xA877, NEUTRAL_ON }, + { 0xA8C4, 0xA8C4, WEAK_NSM }, + { 0xA8E0, 0xA8F1, WEAK_NSM }, + { 0xA926, 0xA92D, WEAK_NSM }, + { 0xA947, 0xA951, WEAK_NSM }, + { 0xA980, 0xA982, WEAK_NSM }, + { 0xA9B3, 0xA9B3, WEAK_NSM }, + { 0xA9B6, 0xA9B9, WEAK_NSM }, + { 0xA9BC, 0xA9BC, WEAK_NSM }, + { 0xAA29, 0xAA2E, WEAK_NSM }, + { 0xAA31, 0xAA32, WEAK_NSM }, + { 0xAA35, 0xAA36, WEAK_NSM }, + { 0xAA43, 0xAA43, WEAK_NSM }, + { 0xAA4C, 0xAA4C, WEAK_NSM }, + { 0xAAB0, 0xAAB0, WEAK_NSM }, + { 0xAAB2, 0xAAB4, WEAK_NSM }, + { 0xAAB7, 0xAAB8, WEAK_NSM }, + { 0xAABE, 0xAABF, WEAK_NSM }, + { 0xAAC1, 0xAAC1, WEAK_NSM }, + { 0xABE5, 0xABE5, WEAK_NSM }, + { 0xABE8, 0xABE8, WEAK_NSM }, + { 0xABED, 0xABED, WEAK_NSM }, + { 0xFB1D, 0xFB1D, STRONG_R }, + { 0xFB1E, 0xFB1E, WEAK_NSM }, + { 0xFB1F, 0xFB28, STRONG_R }, + { 0xFB29, 0xFB29, WEAK_ES }, + { 0xFB2A, 0xFB4F, STRONG_R }, + { 0xFB50, 0xFD3D, STRONG_AL }, + { 0xFD3E, 0xFD3F, NEUTRAL_ON }, + { 0xFD50, 0xFDFC, STRONG_AL }, + { 0xFDFD, 0xFDFD, NEUTRAL_ON }, + { 0xFE00, 0xFE0F, WEAK_NSM }, + { 0xFE10, 0xFE19, NEUTRAL_ON }, + { 0xFE20, 0xFE26, WEAK_NSM }, + { 0xFE30, 0xFE4F, NEUTRAL_ON }, + { 0xFE50, 0xFE50, WEAK_CS }, + { 0xFE51, 0xFE51, NEUTRAL_ON }, + { 0xFE52, 0xFE52, WEAK_CS }, + { 0xFE54, 0xFE54, NEUTRAL_ON }, + { 0xFE55, 0xFE55, WEAK_CS }, + { 0xFE56, 0xFE5E, NEUTRAL_ON }, + { 0xFE5F, 0xFE5F, WEAK_ET }, + { 0xFE60, 0xFE61, NEUTRAL_ON }, + { 0xFE62, 0xFE63, WEAK_ES }, + { 0xFE64, 0xFE68, NEUTRAL_ON }, + { 0xFE69, 0xFE6A, WEAK_ET }, + { 0xFE6B, 0xFE6B, NEUTRAL_ON }, + { 0xFE70, 0xFEFC, STRONG_AL }, + { 0xFEFF, 0xFEFF, WEAK_BN }, + { 0xFF01, 0xFF02, NEUTRAL_ON }, + { 0xFF03, 0xFF05, WEAK_ET }, + { 0xFF06, 0xFF0A, NEUTRAL_ON }, + { 0xFF0B, 0xFF0B, WEAK_ES }, + { 0xFF0C, 0xFF0C, WEAK_CS }, + { 0xFF0D, 0xFF0D, WEAK_ES }, + { 0xFF0E, 0xFF0F, WEAK_CS }, + { 0xFF10, 0xFF19, WEAK_EN }, + { 0xFF1A, 0xFF1A, WEAK_CS }, + { 0xFF1B, 0xFF20, NEUTRAL_ON }, + { 0xFF3B, 0xFF40, NEUTRAL_ON }, + { 0xFF5B, 0xFF65, NEUTRAL_ON }, + { 0xFFE0, 0xFFE1, WEAK_ET }, + { 0xFFE2, 0xFFE4, NEUTRAL_ON }, + { 0xFFE5, 0xFFE6, WEAK_ET }, + { 0xFFE8, 0xFFFD, NEUTRAL_ON }, + { 0x10101, 0x10101, NEUTRAL_ON }, + { 0x10140, 0x1019B, NEUTRAL_ON }, + { 0x101FD, 0x101FD, WEAK_NSM }, + { 0x10800, 0x1091B, STRONG_R }, + { 0x1091F, 0x1091F, NEUTRAL_ON }, + { 0x10920, 0x10A00, STRONG_R }, + { 0x10A01, 0x10A0F, WEAK_NSM }, + { 0x10A10, 0x10A33, STRONG_R }, + { 0x10A38, 0x10A3F, WEAK_NSM }, + { 0x10A40, 0x10B35, STRONG_R }, + { 0x10B39, 0x10B3F, NEUTRAL_ON }, + { 0x10B40, 0x10C48, STRONG_R }, + { 0x10E60, 0x10E7E, WEAK_AN }, + { 0x11001, 0x11001, WEAK_NSM }, + { 0x11038, 0x11046, WEAK_NSM }, + { 0x11052, 0x11065, NEUTRAL_ON }, + { 0x11080, 0x11081, WEAK_NSM }, + { 0x110B3, 0x110B6, WEAK_NSM }, + { 0x110B9, 0x110BA, WEAK_NSM }, + { 0x1D167, 0x1D169, WEAK_NSM }, + { 0x1D173, 0x1D17A, WEAK_BN }, + { 0x1D17B, 0x1D182, WEAK_NSM }, + { 0x1D185, 0x1D18B, WEAK_NSM }, + { 0x1D1AA, 0x1D1AD, WEAK_NSM }, + { 0x1D200, 0x1D241, NEUTRAL_ON }, + { 0x1D242, 0x1D244, WEAK_NSM }, + { 0x1D245, 0x1D356, NEUTRAL_ON }, + { 0x1D6DB, 0x1D6DB, NEUTRAL_ON }, + { 0x1D715, 0x1D715, NEUTRAL_ON }, + { 0x1D74F, 0x1D74F, NEUTRAL_ON }, + { 0x1D789, 0x1D789, NEUTRAL_ON }, + { 0x1D7C3, 0x1D7C3, NEUTRAL_ON }, + { 0x1D7CE, 0x1D7FF, WEAK_EN }, + { 0x1F000, 0x1F0DF, NEUTRAL_ON }, + { 0x1F100, 0x1F10A, WEAK_EN }, + { 0x1F300, 0x1F48B, NEUTRAL_ON }, + { 0x1F48D, 0x1F523, NEUTRAL_ON }, + { 0x1F525, 0x1F773, NEUTRAL_ON }, + { 0xE0001, 0xE007F, WEAK_BN }, + { 0xE0100, 0xE01EF, WEAK_NSM } }; diff --git a/src/blockinput.h b/src/blockinput.h index 890adcbcd86..7ba6fc264fd 100644 --- a/src/blockinput.h +++ b/src/blockinput.h @@ -122,8 +122,7 @@ extern int pending_atimers; #define INPUT_BLOCKED_P (interrupt_input_blocked > 0) /* Defined in keyboard.c */ -/* Don't use a prototype here; it causes trouble in some files. */ -extern void reinvoke_input_signal (); +extern void reinvoke_input_signal (void); #endif /* EMACS_BLOCKINPUT_H */ diff --git a/src/buffer.c b/src/buffer.c index 939e2bb0e19..ed3b7acd2ac 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -28,11 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <setjmp.h> -#ifndef USE_CRT_DLL -extern int errno; -#endif - - #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -83,9 +78,6 @@ static Lisp_Object Vbuffer_defaults; be a DEFVAR_PER_BUFFER for the slot, there is no default value for it; and the corresponding slot in buffer_defaults is not used. - If a slot is -2, then there is no DEFVAR_PER_BUFFER for it, - but there is a default value which is copied into each buffer. - If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is zero, that is a bug */ @@ -99,6 +91,12 @@ DECL_ALIGN (struct buffer, buffer_local_symbols); /* A Lisp_Object pointer to the above, used for staticpro */ static Lisp_Object Vbuffer_local_symbols; +/* Return the symbol of the per-buffer variable at offset OFFSET in + the buffer structure. */ + +#define PER_BUFFER_SYMBOL(OFFSET) \ + (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols)) + /* Flags indicating which built-in buffer-local variables are permanent locals. */ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; @@ -108,13 +106,11 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS]; int last_per_buffer_idx; EXFUN (Fset_buffer, 1); -void set_buffer_internal P_ ((struct buffer *b)); -void set_buffer_internal_1 P_ ((struct buffer *b)); -static void call_overlay_mod_hooks P_ ((Lisp_Object list, Lisp_Object overlay, - int after, Lisp_Object arg1, - Lisp_Object arg2, Lisp_Object arg3)); -static void swap_out_buffer_local_variables P_ ((struct buffer *b)); -static void reset_buffer_local_variables P_ ((struct buffer *b, int permanent_too)); +static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, + int after, Lisp_Object arg1, + Lisp_Object arg2, Lisp_Object arg3); +static void swap_out_buffer_local_variables (struct buffer *b); +static void reset_buffer_local_variables (struct buffer *b, int permanent_too); /* Alist of all buffer names vs the buffers. */ /* This used to be a variable, but is no longer, @@ -164,26 +160,23 @@ Lisp_Object Qget_file_buffer; Lisp_Object Qoverlayp; -Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string; +Lisp_Object Qpriority, Qevaporate, Qbefore_string, Qafter_string; Lisp_Object Qmodification_hooks; Lisp_Object Qinsert_in_front_hooks; Lisp_Object Qinsert_behind_hooks; -static void alloc_buffer_text P_ ((struct buffer *, size_t)); -static void free_buffer_text P_ ((struct buffer *b)); -static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *)); -static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT)); -static Lisp_Object buffer_lisp_local_variables P_ ((struct buffer *)); - -extern char * emacs_strerror P_ ((int)); +static void alloc_buffer_text (struct buffer *, size_t); +static void free_buffer_text (struct buffer *b); +static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); +static void modify_overlay (struct buffer *, EMACS_INT, EMACS_INT); +static Lisp_Object buffer_lisp_local_variables (struct buffer *); /* For debugging; temporary. See set_buffer_internal. */ /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ void -nsberror (spec) - Lisp_Object spec; +nsberror (Lisp_Object spec) { if (STRINGP (spec)) error ("No buffer named %s", SDATA (spec)); @@ -193,8 +186,7 @@ nsberror (spec) DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0, doc: /* Return non-nil if OBJECT is a buffer which has not been killed. Value is nil if OBJECT is not a buffer or if it has been killed. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return ((BUFFERP (object) && ! NILP (XBUFFER (object)->name)) ? Qt : Qnil); @@ -205,8 +197,7 @@ DEFUN ("buffer-list", Fbuffer_list, Sbuffer_list, 0, 1, 0, If the optional arg FRAME is a frame, we return the buffer list in the proper order for that frame: the buffers in FRAME's `buffer-list' frame parameter come first, followed by the rest of the buffers. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object general; general = Fmapcar (Qcdr, Vbuffer_alist); @@ -250,9 +241,7 @@ frame parameter come first, followed by the rest of the buffers. */) and don't ever QUIT. */ static Lisp_Object -assoc_ignore_text_properties (key, list) - register Lisp_Object key; - Lisp_Object list; +assoc_ignore_text_properties (register Lisp_Object key, Lisp_Object list) { register Lisp_Object tail; for (tail = list; CONSP (tail); tail = XCDR (tail)) @@ -271,8 +260,7 @@ DEFUN ("get-buffer", Fget_buffer, Sget_buffer, 1, 1, 0, BUFFER-OR-NAME must be either a string or a buffer. If BUFFER-OR-NAME is a string and there is no buffer with that name, return nil. If BUFFER-OR-NAME is a buffer, return it as given. */) - (buffer_or_name) - register Lisp_Object buffer_or_name; + (register Lisp_Object buffer_or_name) { if (BUFFERP (buffer_or_name)) return buffer_or_name; @@ -286,8 +274,7 @@ DEFUN ("get-file-buffer", Fget_file_buffer, Sget_file_buffer, 1, 1, 0, The buffer's `buffer-file-name' must match exactly the expansion of FILENAME. If there is no such live buffer, return nil. See also `find-buffer-visiting'. */) - (filename) - register Lisp_Object filename; + (register Lisp_Object filename) { register Lisp_Object tail, buf, tem; Lisp_Object handler; @@ -314,8 +301,7 @@ See also `find-buffer-visiting'. */) } Lisp_Object -get_truename_buffer (filename) - register Lisp_Object filename; +get_truename_buffer (register Lisp_Object filename) { register Lisp_Object tail, buf, tem; @@ -343,8 +329,7 @@ buffer does not keep undo information. If BUFFER-OR-NAME is a buffer instead of a string, return it as given, even if it is dead. The return value is never nil. */) - (buffer_or_name) - register Lisp_Object buffer_or_name; + (register Lisp_Object buffer_or_name) { register Lisp_Object buffer, name; register struct buffer *b; @@ -439,9 +424,7 @@ even if it is dead. The return value is never nil. */) LIST, but for buffer B. */ static struct Lisp_Overlay * -copy_overlays (b, list) - struct buffer *b; - struct Lisp_Overlay *list; +copy_overlays (struct buffer *b, struct Lisp_Overlay *list) { Lisp_Object buffer; struct Lisp_Overlay *result = NULL, *tail = NULL; @@ -491,8 +474,7 @@ copy_overlays (b, list) copied. */ static void -clone_per_buffer_values (from, to) - struct buffer *from, *to; +clone_per_buffer_values (struct buffer *from, struct buffer *to) { Lisp_Object to_buffer; int offset; @@ -512,7 +494,7 @@ clone_per_buffer_values (from, to) continue; obj = PER_BUFFER_VALUE (from, offset); - if (MARKERP (obj)) + if (MARKERP (obj) && XMARKER (obj)->buffer == from) { struct Lisp_Marker *m = XMARKER (obj); obj = Fmake_marker (); @@ -523,7 +505,7 @@ clone_per_buffer_values (from, to) PER_BUFFER_VALUE (to, offset) = obj; } - bcopy (from->local_flags, to->local_flags, sizeof to->local_flags); + memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); to->overlays_before = copy_overlays (to, from->overlays_before); to->overlays_after = copy_overlays (to, from->overlays_after); @@ -542,8 +524,7 @@ NAME should be a string which is not the name of an existing buffer. Optional argument CLONE non-nil means preserve BASE-BUFFER's state, such as major and minor modes, in the indirect buffer. CLONE nil means the indirect buffer's state is reset to default values. */) - (base_buffer, name, clone) - Lisp_Object base_buffer, name, clone; + (Lisp_Object base_buffer, Lisp_Object name, Lisp_Object clone) { Lisp_Object buf, tem; struct buffer *b; @@ -660,8 +641,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) } void -delete_all_overlays (b) - struct buffer *b; +delete_all_overlays (struct buffer *b) { Lisp_Object overlay; @@ -691,13 +671,13 @@ delete_all_overlays (b) claims it doesn't belong to it. */ void -reset_buffer (b) - register struct buffer *b; +reset_buffer (register struct buffer *b) { b->filename = Qnil; b->file_truename = Qnil; b->directory = (current_buffer) ? current_buffer->directory : Qnil; b->modtime = 0; + b->modtime_size = -1; XSETFASTINT (b->save_length, 0); b->last_window_start = 1; /* It is more conservative to start out "changed" than "unchanged". */ @@ -735,9 +715,7 @@ reset_buffer (b) we preserve those. */ static void -reset_buffer_local_variables (b, permanent_too) - register struct buffer *b; - int permanent_too; +reset_buffer_local_variables (register struct buffer *b, int permanent_too) { register int offset; int i; @@ -774,9 +752,7 @@ reset_buffer_local_variables (b, permanent_too) { Lisp_Object tmp, prop, last = Qnil; for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp)) - if (CONSP (XCAR (tmp)) - && SYMBOLP (XCAR (XCAR (tmp))) - && !NILP (prop = Fget (XCAR (XCAR (tmp)), Qpermanent_local))) + if (!NILP (prop = Fget (XCAR (XCAR (tmp)), Qpermanent_local))) { /* If permanent-local, keep it. */ last = tmp; @@ -826,9 +802,7 @@ reset_buffer_local_variables (b, permanent_too) int idx = PER_BUFFER_IDX (offset); if ((idx > 0 && (permanent_too - || buffer_permanent_local_flags[idx] == 0)) - /* Is -2 used anywhere? */ - || idx == -2) + || buffer_permanent_local_flags[idx] == 0))) PER_BUFFER_VALUE (b, offset) = PER_BUFFER_DEFAULT (offset); } } @@ -845,8 +819,7 @@ Otherwise modify name by appending `<NUMBER>', incrementing NUMBER \(starting at 2) until an unused name is found, and then return that name. Optional second argument IGNORE specifies a name that is okay to use (if it is in the sequence to be tried) even if a buffer with that name exists. */) - (name, ignore) - register Lisp_Object name, ignore; + (register Lisp_Object name, Lisp_Object ignore) { register Lisp_Object gentemp, tem; int count; @@ -880,8 +853,7 @@ DEFUN ("buffer-name", Fbuffer_name, Sbuffer_name, 0, 1, 0, doc: /* Return the name of BUFFER, as a string. BUFFER defaults to the current buffer. Return nil if BUFFER has been killed. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { if (NILP (buffer)) return current_buffer->name; @@ -892,8 +864,7 @@ Return nil if BUFFER has been killed. */) DEFUN ("buffer-file-name", Fbuffer_file_name, Sbuffer_file_name, 0, 1, 0, doc: /* Return name of file BUFFER is visiting, or nil if none. No argument or nil as argument means use the current buffer. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { if (NILP (buffer)) return current_buffer->filename; @@ -906,8 +877,7 @@ DEFUN ("buffer-base-buffer", Fbuffer_base_buffer, Sbuffer_base_buffer, doc: /* Return the base buffer of indirect buffer BUFFER. If BUFFER is not indirect, return nil. BUFFER defaults to the current buffer. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { struct buffer *base; Lisp_Object base_buffer; @@ -931,9 +901,7 @@ DEFUN ("buffer-local-value", Fbuffer_local_value, doc: /* Return the value of VARIABLE in BUFFER. If VARIABLE does not have a buffer-local binding in BUFFER, the value is the default binding of the variable. */) - (variable, buffer) - register Lisp_Object variable; - register Lisp_Object buffer; + (register Lisp_Object variable, register Lisp_Object buffer) { register struct buffer *buf; register Lisp_Object result; @@ -942,59 +910,49 @@ is the default binding of the variable. */) CHECK_SYMBOL (variable); CHECK_BUFFER (buffer); buf = XBUFFER (buffer); + sym = XSYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); - XSETSYMBOL (variable, sym); - - /* Look in local_var_list */ - result = Fassoc (variable, buf->local_var_alist); - if (NILP (result)) + start: + switch (sym->redirect) { - int offset, idx; - int found = 0; - - /* Look in special slots */ - /* buffer-local Lisp variables start at `undo_list', - tho only the ones from `name' on are GC'd normally. */ - for (offset = PER_BUFFER_VAR_OFFSET (undo_list); - offset < sizeof (struct buffer); - /* sizeof EMACS_INT == sizeof Lisp_Object */ - offset += (sizeof (EMACS_INT))) - { - idx = PER_BUFFER_IDX (offset); - if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) - && SYMBOLP (PER_BUFFER_SYMBOL (offset)) - && EQ (PER_BUFFER_SYMBOL (offset), variable)) - { - result = PER_BUFFER_VALUE (buf, offset); - found = 1; - break; - } - } - - if (!found) - result = Fdefault_value (variable); - } - else - { - Lisp_Object valcontents; - Lisp_Object current_alist_element; - - /* What binding is loaded right now? */ - valcontents = sym->value; - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - - /* The value of the currently loaded binding is not - stored in it, but rather in the realvalue slot. - Store that value into the binding it belongs to - in case that is the one we are about to use. */ + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: result = SYMBOL_VAL (sym); break; + case SYMBOL_LOCALIZED: + { /* Look in local_var_alist. */ + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + XSETSYMBOL (variable, sym); /* Update In case of aliasing. */ + result = Fassoc (variable, buf->local_var_alist); + if (!NILP (result)) + { + if (blv->fwd) + { /* What binding is loaded right now? */ + Lisp_Object current_alist_element = blv->valcell; - Fsetcdr (current_alist_element, - do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); + /* The value of the currently loaded binding is not + stored in it, but rather in the realvalue slot. + Store that value into the binding it belongs to + in case that is the one we are about to use. */ - /* Now get the (perhaps updated) value out of the binding. */ - result = XCDR (result); + XSETCDR (current_alist_element, + do_symval_forwarding (blv->fwd)); + } + /* Now get the (perhaps updated) value out of the binding. */ + result = XCDR (result); + } + else + result = Fdefault_value (variable); + break; + } + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *fwd = SYMBOL_FWD (sym); + if (BUFFER_OBJFWDP (fwd)) + result = PER_BUFFER_VALUE (buf, XBUFFER_OBJFWD (fwd)->offset); + else + result = Fdefault_value (variable); + break; + } + default: abort (); } if (!EQ (result, Qunbound)) @@ -1008,8 +966,7 @@ is the default binding of the variable. */) in special slots in the buffer object. */ static Lisp_Object -buffer_lisp_local_variables (buf) - struct buffer *buf; +buffer_lisp_local_variables (struct buffer *buf) { Lisp_Object result = Qnil; register Lisp_Object tail; @@ -1029,12 +986,7 @@ buffer_lisp_local_variables (buf) if (buf != current_buffer) val = XCDR (elt); - /* If symbol is unbound, put just the symbol in the list. */ - if (EQ (val, Qunbound)) - result = Fcons (XCAR (elt), result); - /* Otherwise, put (symbol . value) in the list. */ - else - result = Fcons (Fcons (XCAR (elt), val), result); + result = Fcons (Fcons (XCAR (elt), val), result); } return result; @@ -1047,8 +999,7 @@ Most elements look like (SYMBOL . VALUE), describing one variable. For a symbol that is locally unbound, just the symbol appears in the value. Note that storing new VALUEs in these elements doesn't change the variables. No argument or nil as argument means use current buffer as BUFFER. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { register struct buffer *buf; register Lisp_Object result; @@ -1090,8 +1041,7 @@ DEFUN ("buffer-modified-p", Fbuffer_modified_p, Sbuffer_modified_p, 0, 1, 0, doc: /* Return t if BUFFER was modified since its file was last read or saved. No argument or nil as argument means use current buffer as BUFFER. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { register struct buffer *buf; if (NILP (buffer)) @@ -1109,8 +1059,7 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p, 1, 1, 0, doc: /* Mark current buffer as modified or unmodified according to FLAG. A non-nil FLAG means mark the buffer modified. */) - (flag) - register Lisp_Object flag; + (register Lisp_Object flag) { register int already; register Lisp_Object fn; @@ -1179,8 +1128,7 @@ DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p, doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay. It is not ensured that mode lines will be updated to show the modified state of the current buffer. Use with care. */) - (flag) - Lisp_Object flag; + (Lisp_Object flag) { #ifdef CLASH_DETECTION Lisp_Object fn; @@ -1210,8 +1158,7 @@ DEFUN ("buffer-modified-tick", Fbuffer_modified_tick, Sbuffer_modified_tick, Each buffer has a tick counter which is incremented each time the text in that buffer is changed. It wraps around occasionally. No argument or nil as argument means use current buffer as BUFFER. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { register struct buffer *buf; if (NILP (buffer)) @@ -1235,8 +1182,7 @@ values returned by two individual calls of `buffer-chars-modified-tick', you can tell whether a character change occurred in that buffer in between these calls. No argument or nil as argument means use current buffer as BUFFER. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { register struct buffer *buf; if (NILP (buffer)) @@ -1262,8 +1208,7 @@ If UNIQUE is non-nil, come up with a new name using Interactively, you can set UNIQUE with a prefix argument. We return the name we actually gave the buffer. This does not change the name of the visited file (if any). */) - (newname, unique) - register Lisp_Object newname, unique; + (register Lisp_Object newname, Lisp_Object unique) { register Lisp_Object tem, buf; @@ -1310,16 +1255,17 @@ If the optional third argument FRAME is non-nil, use that frame's buffer list instead of the selected frame's buffer list. If no other buffer exists, the buffer `*scratch*' is returned. If BUFFER is omitted or nil, some interesting buffer is returned. */) - (buffer, visible_ok, frame) - register Lisp_Object buffer, visible_ok, frame; + (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) { - Lisp_Object Fset_buffer_major_mode (); + Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer); register Lisp_Object tail, buf, notsogood, tem, pred, add_ons; notsogood = Qnil; if (NILP (frame)) frame = selected_frame; + CHECK_FRAME (frame); + tail = Vbuffer_alist; pred = frame_buffer_predicate (frame); @@ -1380,8 +1326,7 @@ DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo, 0, 1, "", doc: /* Start keeping undo information for buffer BUFFER. No argument or nil as argument means do this for the current buffer. */) - (buffer) - register Lisp_Object buffer; + (register Lisp_Object buffer) { Lisp_Object real_buffer; @@ -1422,8 +1367,7 @@ is running. Any processes that have this buffer as the `process-buffer' are killed with SIGHUP. */) - (buffer_or_name) - Lisp_Object buffer_or_name; + (Lisp_Object buffer_or_name) { Lisp_Object buffer; register struct buffer *b; @@ -1636,8 +1580,7 @@ with SIGHUP. */) means that other_buffer is more likely to choose a relevant buffer. */ void -record_buffer (buf) - Lisp_Object buf; +record_buffer (Lisp_Object buf) { register Lisp_Object link, prev; Lisp_Object frame; @@ -1713,8 +1656,7 @@ For the *scratch* buffer, use `initial-major-mode', otherwise choose a mode according to `default-major-mode'. Use this function before selecting the buffer, since it may need to inspect the current buffer's major mode. */) - (buffer) - Lisp_Object buffer; + (Lisp_Object buffer) { int count; Lisp_Object function; @@ -1752,8 +1694,7 @@ the current buffer's major mode. */) If NORECORD is non-nil, don't call record_buffer. */ Lisp_Object -switch_to_buffer_1 (buffer_or_name, norecord) - Lisp_Object buffer_or_name, norecord; +switch_to_buffer_1 (Lisp_Object buffer_or_name, Lisp_Object norecord) { register Lisp_Object buffer; @@ -1802,11 +1743,8 @@ its buffer, use `pop-to-buffer' for displaying the buffer. WARNING: This is NOT the way to work on another buffer temporarily within a Lisp program! Use `set-buffer' instead. That avoids messing with the window-buffer correspondences. */) - (buffer_or_name, norecord) - Lisp_Object buffer_or_name, norecord; + (Lisp_Object buffer_or_name, Lisp_Object norecord) { - char *err; - if (EQ (buffer_or_name, Fwindow_buffer (selected_window))) { /* Basically a NOP. Avoid signalling an error in the case where @@ -1834,7 +1772,7 @@ messing with the window-buffer correspondences. */) DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0, doc: /* Return the current buffer as a Lisp object. */) - () + (void) { register Lisp_Object buf; XSETBUFFER (buf, current_buffer); @@ -1851,8 +1789,7 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0, time, and that increments windows_or_buffers_changed. */ void -set_buffer_internal (b) - register struct buffer *b; +set_buffer_internal (register struct buffer *b) { if (current_buffer != b) set_buffer_internal_1 (b); @@ -1862,12 +1799,10 @@ set_buffer_internal (b) This is used by redisplay. */ void -set_buffer_internal_1 (b) - register struct buffer *b; +set_buffer_internal_1 (register struct buffer *b) { register struct buffer *old_buf; - register Lisp_Object tail, valcontents; - Lisp_Object tem; + register Lisp_Object tail; #ifdef USE_MMAP_FOR_BUFFERS if (b->text->beg == NULL) @@ -1939,42 +1874,28 @@ set_buffer_internal_1 (b) /* Look down buffer's list of local Lisp variables to find and update any that forward into C variables. */ - for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail)) + do { - if (CONSP (XCAR (tail)) - && SYMBOLP (XCAR (XCAR (tail))) - && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))), - (BUFFER_LOCAL_VALUEP (valcontents))) - && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, - (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) - /* Just reference the variable to cause it to become set for - this buffer. */ - Fsymbol_value (XCAR (XCAR (tail))); + for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail)) + { + Lisp_Object var = XCAR (XCAR (tail)); + struct Lisp_Symbol *sym = XSYMBOL (var); + if (sym->redirect == SYMBOL_LOCALIZED /* Just to be sure. */ + && SYMBOL_BLV (sym)->fwd) + /* Just reference the variable + to cause it to become set for this buffer. */ + Fsymbol_value (var); + } } - /* Do the same with any others that were local to the previous buffer */ - - if (old_buf) - for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) - { - if (CONSP (tail) - && SYMBOLP (XCAR (XCAR (tail))) - && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))), - (BUFFER_LOCAL_VALUEP (valcontents))) - && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, - (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem)))) - /* Just reference the variable to cause it to become set for - this buffer. */ - Fsymbol_value (XCAR (XCAR (tail))); - } + while (b != old_buf && (b = old_buf, b)); } /* Switch to buffer B temporarily for redisplay purposes. This avoids certain things that don't need to be done within redisplay. */ void -set_buffer_temp (b) - struct buffer *b; +set_buffer_temp (struct buffer *b) { register struct buffer *old_buf; @@ -2037,8 +1958,7 @@ also `save-excursion' when you want to make a buffer current temporarily. This function does not display the buffer, so its effect ends when the current command terminates. Use `switch-to-buffer' or `pop-to-buffer' to switch buffers permanently. */) - (buffer_or_name) - register Lisp_Object buffer_or_name; + (register Lisp_Object buffer_or_name) { register Lisp_Object buffer; buffer = Fget_buffer (buffer_or_name); @@ -2053,8 +1973,7 @@ ends when the current command terminates. Use `switch-to-buffer' or /* Set the current buffer to BUFFER provided it is alive. */ Lisp_Object -set_buffer_if_live (buffer) - Lisp_Object buffer; +set_buffer_if_live (Lisp_Object buffer) { if (! NILP (XBUFFER (buffer)->name)) Fset_buffer (buffer); @@ -2064,7 +1983,7 @@ set_buffer_if_live (buffer) DEFUN ("barf-if-buffer-read-only", Fbarf_if_buffer_read_only, Sbarf_if_buffer_read_only, 0, 0, 0, doc: /* Signal a `buffer-read-only' error if the current buffer is read-only. */) - () + (void) { if (!NILP (current_buffer->read_only) && NILP (Vinhibit_read_only)) @@ -2084,8 +2003,7 @@ from the selected window if it is displayed there. If the selected window is dedicated to its buffer, delete that window if there are other windows on the same frame. If the selected window is the only window on its frame, iconify that frame. */) - (buffer_or_name) - register Lisp_Object buffer_or_name; + (register Lisp_Object buffer_or_name) { Lisp_Object buffer; @@ -2139,7 +2057,7 @@ DEFUN ("erase-buffer", Ferase_buffer, Serase_buffer, 0, 0, "*", doc: /* Delete the entire contents of the current buffer. Any narrowing restriction in effect (see `narrow-to-region') is removed, so the buffer is truly empty after this. */) - () + (void) { Fwiden (); @@ -2154,8 +2072,7 @@ so the buffer is truly empty after this. */) } void -validate_region (b, e) - register Lisp_Object *b, *e; +validate_region (register Lisp_Object *b, register Lisp_Object *e) { CHECK_NUMBER_COERCE_MARKER (*b); CHECK_NUMBER_COERCE_MARKER (*e); @@ -2175,8 +2092,7 @@ validate_region (b, e) and return the adjusted position. */ static int -advance_to_char_boundary (byte_pos) - int byte_pos; +advance_to_char_boundary (EMACS_INT byte_pos) { int c; @@ -2189,7 +2105,7 @@ advance_to_char_boundary (byte_pos) { /* We should advance BYTE_POS only when C is a constituent of a multibyte sequence. */ - int orig_byte_pos = byte_pos; + EMACS_INT orig_byte_pos = byte_pos; do { @@ -2209,21 +2125,20 @@ advance_to_char_boundary (byte_pos) } #ifdef REL_ALLOC -extern void r_alloc_reset_variable P_ ((POINTER_TYPE *, POINTER_TYPE *)); +extern void r_alloc_reset_variable (POINTER_TYPE *, POINTER_TYPE *); #endif /* REL_ALLOC */ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, 1, 1, 0, doc: /* Swap the text between current buffer and BUFFER. */) - (buffer) - Lisp_Object buffer; + (Lisp_Object buffer) { struct buffer *other_buffer; CHECK_BUFFER (buffer); other_buffer = XBUFFER (buffer); if (NILP (other_buffer->name)) - error ("Cannot swap a dead buffer's text"); + error ("Cannot swap a dead buffer's text"); /* Actually, it probably works just fine. * if (other_buffer == current_buffer) @@ -2279,6 +2194,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, swapfield (undo_list, Lisp_Object); swapfield (mark, Lisp_Object); swapfield (enable_multibyte_characters, Lisp_Object); + swapfield (bidi_display_reordering, Lisp_Object); + swapfield (bidi_paragraph_direction, Lisp_Object); /* FIXME: Not sure what we should do with these *_marker fields. Hopefully they're just nil anyway. */ swapfield (pt_marker, Lisp_Object); @@ -2352,12 +2269,11 @@ If FLAG is `to', this makes the buffer a multibyte buffer by changing all eight-bit bytes to eight-bit characters. If the multibyte flag was really changed, undo information of the current buffer is cleared. */) - (flag) - Lisp_Object flag; + (Lisp_Object flag) { struct Lisp_Marker *tail, *markers; struct buffer *other; - int begv, zv; + EMACS_INT begv, zv; int narrowed = (BEG != BEGV || Z != ZV); int modified_p = !NILP (Fbuffer_modified_p (Qnil)); Lisp_Object old_undo = current_buffer->undo_list; @@ -2389,7 +2305,7 @@ current buffer is cleared. */) if (NILP (flag)) { - int pos, stop; + EMACS_INT pos, stop; unsigned char *p; /* Do this first, so it can use CHAR_TO_BYTE @@ -2429,7 +2345,7 @@ current buffer is cleared. */) { c = STRING_CHAR_AND_LENGTH (p, bytes); /* Delete all bytes for this 8-bit character but the - last one, and change the last one to the charcter + last one, and change the last one to the character code. */ bytes--; del_range_2 (pos, pos, pos + bytes, pos + bytes, 0); @@ -2453,8 +2369,8 @@ current buffer is cleared. */) } else { - int pt = PT; - int pos, stop; + EMACS_INT pt = PT; + EMACS_INT pos, stop; unsigned char *p, *pend; /* Be sure not to have a multibyte sequence striding over the GAP. @@ -2468,9 +2384,9 @@ current buffer is cleared. */) unsigned char *p = GPT_ADDR - 1; while (! CHAR_HEAD_P (*p) && p > BEG_ADDR) p--; - if (BASE_LEADING_CODE_P (*p)) + if (LEADING_CODE_P (*p)) { - int new_gpt = GPT_BYTE - (GPT_ADDR - p); + EMACS_INT new_gpt = GPT_BYTE - (GPT_ADDR - p); move_gap_both (new_gpt, new_gpt); } @@ -2554,8 +2470,8 @@ current buffer is cleared. */) ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG; { - int pt_byte = advance_to_char_boundary (PT_BYTE); - int pt; + EMACS_INT pt_byte = advance_to_char_boundary (PT_BYTE); + EMACS_INT pt; if (pt_byte > GPT_BYTE) pt = chars_in_text (GAP_END_ADDR, pt_byte - GPT_BYTE) + GPT; @@ -2592,7 +2508,6 @@ current buffer is cleared. */) if (!EQ (old_undo, Qt)) { /* Represent all the above changes by a special undo entry. */ - extern Lisp_Object Qapply; current_buffer->undo_list = Fcons (list3 (Qapply, intern ("set-buffer-multibyte"), NILP (flag) ? Qt : Qnil), @@ -2620,7 +2535,6 @@ current buffer is cleared. */) if (!modified_p && !NILP (Fbuffer_modified_p (Qnil))) Fset_buffer_modified_p (Qnil); -#ifdef subprocesses /* Update coding systems of this buffer's process (if any). */ { Lisp_Object process; @@ -2629,7 +2543,6 @@ current buffer is cleared. */) if (PROCESSP (process)) setup_process_coding_systems (process); } -#endif /* subprocesses */ return flag; } @@ -2651,7 +2564,7 @@ a non-nil `permanent-local' property are not eliminated by this function. The first thing this function does is run the normal hook `change-major-mode-hook'. */) - () + (void) { if (!NILP (Vrun_hooks)) call1 (Vrun_hooks, Qchange_major_mode_hook); @@ -2676,26 +2589,24 @@ the normal hook `change-major-mode-hook'. */) for their current values. */ static void -swap_out_buffer_local_variables (b) - struct buffer *b; +swap_out_buffer_local_variables (struct buffer *b) { - Lisp_Object oalist, alist, sym, buffer; + Lisp_Object oalist, alist, buffer; XSETBUFFER (buffer, b); oalist = b->local_var_alist; for (alist = oalist; CONSP (alist); alist = XCDR (alist)) { - if (CONSP (XCAR (alist)) - && (sym = XCAR (XCAR (alist)), SYMBOLP (sym)) - /* Need not do anything if some other buffer's binding is - now encached. */ - && EQ (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer, - buffer)) + Lisp_Object sym = XCAR (XCAR (alist)); + eassert (XSYMBOL (sym)->redirect == SYMBOL_LOCALIZED); + /* Need not do anything if some other buffer's binding is + now encached. */ + if (EQ (SYMBOL_BLV (XSYMBOL (sym))->where, buffer)) { /* Symbol is set up for this buffer's old local value: swap it out! */ - swap_in_global_binding (sym); + swap_in_global_binding (XSYMBOL (sym)); } } } @@ -2723,27 +2634,21 @@ swap_out_buffer_local_variables (b) default (BEGV or ZV). */ int -overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) - EMACS_INT pos; - int extend; - Lisp_Object **vec_ptr; - int *len_ptr; - EMACS_INT *next_ptr; - EMACS_INT *prev_ptr; - int change_req; +overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, int *len_ptr, + EMACS_INT *next_ptr, EMACS_INT *prev_ptr, int change_req) { Lisp_Object overlay, start, end; struct Lisp_Overlay *tail; int idx = 0; int len = *len_ptr; Lisp_Object *vec = *vec_ptr; - int next = ZV; - int prev = BEGV; + EMACS_INT next = ZV; + EMACS_INT prev = BEGV; int inhibit_storing = 0; for (tail = current_buffer->overlays_before; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; XSETMISC (overlay, tail); @@ -2794,7 +2699,7 @@ overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) for (tail = current_buffer->overlays_after; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; XSETMISC (overlay, tail); @@ -2868,27 +2773,23 @@ overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) But we still return the total number of overlays. */ static int -overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) - int beg, end; - int extend; - Lisp_Object **vec_ptr; - int *len_ptr; - int *next_ptr; - int *prev_ptr; +overlays_in (EMACS_INT beg, EMACS_INT end, int extend, + Lisp_Object **vec_ptr, int *len_ptr, + EMACS_INT *next_ptr, EMACS_INT *prev_ptr) { Lisp_Object overlay, ostart, oend; struct Lisp_Overlay *tail; int idx = 0; int len = *len_ptr; Lisp_Object *vec = *vec_ptr; - int next = ZV; - int prev = BEGV; + EMACS_INT next = ZV; + EMACS_INT prev = BEGV; int inhibit_storing = 0; int end_is_Z = end == Z; for (tail = current_buffer->overlays_before; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; XSETMISC (overlay, tail); @@ -2938,7 +2839,7 @@ overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) for (tail = current_buffer->overlays_after; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; XSETMISC (overlay, tail); @@ -2995,11 +2896,10 @@ overlays_in (beg, end, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) `mouse-face' property overlapping OVERLAY. */ int -mouse_face_overlay_overlaps (overlay) - Lisp_Object overlay; +mouse_face_overlay_overlaps (Lisp_Object overlay) { - int start = OVERLAY_POSITION (OVERLAY_START (overlay)); - int end = OVERLAY_POSITION (OVERLAY_END (overlay)); + EMACS_INT start = OVERLAY_POSITION (OVERLAY_START (overlay)); + EMACS_INT end = OVERLAY_POSITION (OVERLAY_END (overlay)); int n, i, size; Lisp_Object *v, tem; @@ -3025,15 +2925,14 @@ mouse_face_overlay_overlaps (overlay) /* Fast function to just test if we're at an overlay boundary. */ int -overlay_touches_p (pos) - int pos; +overlay_touches_p (EMACS_INT pos) { Lisp_Object overlay; struct Lisp_Overlay *tail; for (tail = current_buffer->overlays_before; tail; tail = tail->next) { - int endpos; + EMACS_INT endpos; XSETMISC (overlay ,tail); if (!OVERLAYP (overlay)) @@ -3048,7 +2947,7 @@ overlay_touches_p (pos) for (tail = current_buffer->overlays_after; tail; tail = tail->next) { - int startpos; + EMACS_INT startpos; XSETMISC (overlay, tail); if (!OVERLAYP (overlay)) @@ -3066,13 +2965,12 @@ overlay_touches_p (pos) struct sortvec { Lisp_Object overlay; - int beg, end; + EMACS_INT beg, end; int priority; }; static int -compare_overlays (v1, v2) - const void *v1, *v2; +compare_overlays (const void *v1, const void *v2) { const struct sortvec *s1 = (const struct sortvec *) v1; const struct sortvec *s2 = (const struct sortvec *) v2; @@ -3089,10 +2987,7 @@ compare_overlays (v1, v2) The return value is the new size; this may be smaller than the original size if some of the overlays were invalid or were window-specific. */ int -sort_overlays (overlay_vec, noverlays, w) - Lisp_Object *overlay_vec; - int noverlays; - struct window *w; +sort_overlays (Lisp_Object *overlay_vec, int noverlays, struct window *w) { int i, j; struct sortvec *sortvec; @@ -3157,7 +3052,7 @@ struct sortstrlist struct sortstr *buf; /* An array that expands as needed; never freed. */ int size; /* Allocated length of that array. */ int used; /* How much of the array is currently in use. */ - int bytes; /* Total length of the strings in buf. */ + EMACS_INT bytes; /* Total length of the strings in buf. */ }; /* Buffers for storing information about the overlays touching a given @@ -3168,12 +3063,11 @@ static struct sortstrlist overlay_heads, overlay_tails; static unsigned char *overlay_str_buf; /* Allocated length of overlay_str_buf. */ -static int overlay_str_len; +static EMACS_INT overlay_str_len; /* A comparison function suitable for passing to qsort. */ static int -cmp_for_strings (as1, as2) - char *as1, *as2; +cmp_for_strings (const void *as1, const void *as2) { struct sortstr *s1 = (struct sortstr *)as1; struct sortstr *s2 = (struct sortstr *)as2; @@ -3185,12 +3079,9 @@ cmp_for_strings (as1, as2) } static void -record_overlay_string (ssl, str, str2, pri, size) - struct sortstrlist *ssl; - Lisp_Object str, str2, pri; - int size; +record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, Lisp_Object str2, Lisp_Object pri, int size) { - int nbytes; + EMACS_INT nbytes; if (ssl->used == ssl->size) { @@ -3243,15 +3134,12 @@ record_overlay_string (ssl, str, str2, pri, size) PSTR, if that variable is non-null. The string may be overwritten by subsequent calls. */ -int -overlay_strings (pos, w, pstr) - EMACS_INT pos; - struct window *w; - unsigned char **pstr; +EMACS_INT +overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) { Lisp_Object overlay, window, str; struct Lisp_Overlay *ov; - int startpos, endpos; + EMACS_INT startpos, endpos; int multibyte = ! NILP (current_buffer->enable_multibyte_characters); overlay_heads.used = overlay_heads.bytes = 0; @@ -3321,9 +3209,9 @@ overlay_strings (pos, w, pstr) if (overlay_heads.bytes || overlay_tails.bytes) { Lisp_Object tem; - int i; + EMACS_INT i; unsigned char *p; - int total = overlay_heads.bytes + overlay_tails.bytes; + EMACS_INT total = overlay_heads.bytes + overlay_tails.bytes; if (total > overlay_str_len) { @@ -3334,7 +3222,7 @@ overlay_strings (pos, w, pstr) p = overlay_str_buf; for (i = overlay_tails.used; --i >= 0;) { - int nbytes; + EMACS_INT nbytes; tem = overlay_tails.buf[i].string; nbytes = copy_text (SDATA (tem), p, SBYTES (tem), @@ -3343,7 +3231,7 @@ overlay_strings (pos, w, pstr) } for (i = 0; i < overlay_heads.used; ++i) { - int nbytes; + EMACS_INT nbytes; tem = overlay_heads.buf[i].string; nbytes = copy_text (SDATA (tem), p, SBYTES (tem), @@ -3370,9 +3258,7 @@ overlay_strings (pos, w, pstr) /* Shift overlays in BUF's overlay lists, to center the lists at POS. */ void -recenter_overlay_lists (buf, pos) - struct buffer *buf; - EMACS_INT pos; +recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) { Lisp_Object overlay, beg, end; struct Lisp_Overlay *prev, *tail, *next; @@ -3410,7 +3296,7 @@ recenter_overlay_lists (buf, pos) if (OVERLAY_POSITION (end) > pos) { /* OVERLAY needs to be moved. */ - int where = OVERLAY_POSITION (beg); + EMACS_INT where = OVERLAY_POSITION (beg); struct Lisp_Overlay *other, *other_prev; /* Splice the cons cell TAIL out of overlays_before. */ @@ -3483,7 +3369,7 @@ recenter_overlay_lists (buf, pos) if (OVERLAY_POSITION (end) <= pos) { /* OVERLAY needs to be moved. */ - int where = OVERLAY_POSITION (end); + EMACS_INT where = OVERLAY_POSITION (end); struct Lisp_Overlay *other, *other_prev; /* Splice the cons cell TAIL out of overlays_after. */ @@ -3521,9 +3407,7 @@ recenter_overlay_lists (buf, pos) } void -adjust_overlays_for_insert (pos, length) - EMACS_INT pos; - EMACS_INT length; +adjust_overlays_for_insert (EMACS_INT pos, EMACS_INT length) { /* After an insertion, the lists are still sorted properly, but we may need to update the value of the overlay center. */ @@ -3532,9 +3416,7 @@ adjust_overlays_for_insert (pos, length) } void -adjust_overlays_for_delete (pos, length) - EMACS_INT pos; - EMACS_INT length; +adjust_overlays_for_delete (EMACS_INT pos, EMACS_INT length) { if (current_buffer->overlay_center < pos) /* The deletion was to our right. No change needed; the before- and @@ -3559,8 +3441,7 @@ adjust_overlays_for_delete (pos, length) Such an overlay might even have negative size at this point. If so, we'll make the overlay empty. */ void -fix_start_end_in_overlays (start, end) - register int start, end; +fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end) { Lisp_Object overlay; struct Lisp_Overlay *before_list, *after_list; @@ -3572,7 +3453,7 @@ fix_start_end_in_overlays (start, end) current_buffer->overlays_before or overlays_after, depending which loop we're in. */ struct Lisp_Overlay *tail, *parent; - int startpos, endpos; + EMACS_INT startpos, endpos; /* This algorithm shifts links around instead of consing and GCing. The loop invariant is that before_list (resp. after_list) is a @@ -3706,9 +3587,7 @@ fix_start_end_in_overlays (start, end) was at PREV, and now is at POS. */ void -fix_overlays_before (bp, prev, pos) - struct buffer *bp; - EMACS_INT prev, pos; +fix_overlays_before (struct buffer *bp, EMACS_INT prev, EMACS_INT pos) { /* If parent is nil, replace overlays_before; otherwise, parent->next. */ struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair; @@ -3787,8 +3666,7 @@ fix_overlays_before (bp, prev, pos) DEFUN ("overlayp", Foverlayp, Soverlayp, 1, 1, 0, doc: /* Return t if OBJECT is an overlay. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return (OVERLAYP (object) ? Qt : Qnil); } @@ -3803,9 +3681,7 @@ for the front of the overlay advance when text is inserted there The fifth arg REAR-ADVANCE, if non-nil, makes the marker for the rear of the overlay advance when text is inserted there \(which means the text *is* included in the overlay). */) - (beg, end, buffer, front_advance, rear_advance) - Lisp_Object beg, end, buffer; - Lisp_Object front_advance, rear_advance; + (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, Lisp_Object front_advance, Lisp_Object rear_advance) { Lisp_Object overlay; struct buffer *b; @@ -3874,13 +3750,11 @@ for the rear of the overlay advance when text is inserted there /* Mark a section of BUF as needing redisplay because of overlays changes. */ static void -modify_overlay (buf, start, end) - struct buffer *buf; - EMACS_INT start, end; +modify_overlay (struct buffer *buf, EMACS_INT start, EMACS_INT end) { if (start > end) { - int temp = start; + EMACS_INT temp = start; start = end; end = temp; } @@ -3903,11 +3777,10 @@ modify_overlay (buf, start, end) } -Lisp_Object Fdelete_overlay (); +Lisp_Object Fdelete_overlay (Lisp_Object overlay); static struct Lisp_Overlay * -unchain_overlay (list, overlay) - struct Lisp_Overlay *list, *overlay; +unchain_overlay (struct Lisp_Overlay *list, struct Lisp_Overlay *overlay) { struct Lisp_Overlay *tmp, *prev; for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next) @@ -3928,8 +3801,7 @@ DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0, If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now. If BUFFER is omitted, and OVERLAY is in no buffer, put it in the current buffer. */) - (overlay, beg, end, buffer) - Lisp_Object overlay, beg, end, buffer; + (Lisp_Object overlay, Lisp_Object beg, Lisp_Object end, Lisp_Object buffer) { struct buffer *b, *ob; Lisp_Object obuffer; @@ -3973,8 +3845,8 @@ buffer. */) /* Redisplay where the overlay was. */ if (!NILP (obuffer)) { - int o_beg; - int o_end; + EMACS_INT o_beg; + EMACS_INT o_end; o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); @@ -3988,7 +3860,7 @@ buffer. */) else /* Redisplay the area the overlay has just left, or just enclosed. */ { - int o_beg, o_end; + EMACS_INT o_beg, o_end; o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); @@ -4038,8 +3910,7 @@ buffer. */) DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, doc: /* Delete the overlay OVERLAY from its buffer. */) - (overlay) - Lisp_Object overlay; + (Lisp_Object overlay) { Lisp_Object buffer; struct buffer *b; @@ -4079,8 +3950,7 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, DEFUN ("overlay-start", Foverlay_start, Soverlay_start, 1, 1, 0, doc: /* Return the position at which OVERLAY starts. */) - (overlay) - Lisp_Object overlay; + (Lisp_Object overlay) { CHECK_OVERLAY (overlay); @@ -4089,8 +3959,7 @@ DEFUN ("overlay-start", Foverlay_start, Soverlay_start, 1, 1, 0, DEFUN ("overlay-end", Foverlay_end, Soverlay_end, 1, 1, 0, doc: /* Return the position at which OVERLAY ends. */) - (overlay) - Lisp_Object overlay; + (Lisp_Object overlay) { CHECK_OVERLAY (overlay); @@ -4100,8 +3969,7 @@ DEFUN ("overlay-end", Foverlay_end, Soverlay_end, 1, 1, 0, DEFUN ("overlay-buffer", Foverlay_buffer, Soverlay_buffer, 1, 1, 0, doc: /* Return the buffer OVERLAY belongs to. Return nil if OVERLAY has been deleted. */) - (overlay) - Lisp_Object overlay; + (Lisp_Object overlay) { CHECK_OVERLAY (overlay); @@ -4112,8 +3980,7 @@ DEFUN ("overlay-properties", Foverlay_properties, Soverlay_properties, 1, 1, 0, doc: /* Return a list of the properties on OVERLAY. This is a copy of OVERLAY's plist; modifying its conses has no effect on OVERLAY. */) - (overlay) - Lisp_Object overlay; + (Lisp_Object overlay) { CHECK_OVERLAY (overlay); @@ -4123,8 +3990,7 @@ OVERLAY. */) DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, doc: /* Return a list of the overlays that contain the character at POS. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { int noverlays; Lisp_Object *overlay_vec; @@ -4156,8 +4022,7 @@ and also contained within the specified region. Empty overlays are included in the result if they are located at BEG, between BEG and END, or at END provided END denotes the position at the end of the buffer. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { int noverlays; Lisp_Object *overlay_vec; @@ -4173,7 +4038,7 @@ end of the buffer. */) /* Put all the overlays we want in a vector in overlay_vec. Store the length in len. */ noverlays = overlays_in (XINT (beg), XINT (end), 1, &overlay_vec, &len, - (int *) 0, (int *) 0); + NULL, NULL); /* Make a list of them all. */ result = Flist (noverlays, overlay_vec); @@ -4187,8 +4052,7 @@ DEFUN ("next-overlay-change", Fnext_overlay_change, Snext_overlay_change, doc: /* Return the next position after POS where an overlay starts or ends. If there are no overlay boundaries from POS to (point-max), the value is (point-max). */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { int noverlays; EMACS_INT endpos; @@ -4229,8 +4093,7 @@ DEFUN ("previous-overlay-change", Fprevious_overlay_change, doc: /* Return the previous position before POS where an overlay starts or ends. If there are no overlay boundaries from (point-min) to POS, the value is (point-min). */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { int noverlays; EMACS_INT prevpos; @@ -4266,7 +4129,7 @@ the cdr has all the overlays after the overlay center. Recentering overlays moves overlays between these lists. The lists you get are copies, so that changing them has no effect. However, the overlays you get are the real objects that the buffer uses. */) - () + (void) { struct Lisp_Overlay *ol; Lisp_Object before = Qnil, after = Qnil, tmp; @@ -4287,8 +4150,7 @@ DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0, doc: /* Recenter the overlays of the current buffer around position POS. That makes overlay lookup faster for positions near POS (but perhaps slower for positions far away from POS). */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { CHECK_NUMBER_COERCE_MARKER (pos); @@ -4298,8 +4160,7 @@ for positions far away from POS). */) DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0, doc: /* Get the property of overlay OVERLAY with property name PROP. */) - (overlay, prop) - Lisp_Object overlay, prop; + (Lisp_Object overlay, Lisp_Object prop) { CHECK_OVERLAY (overlay); return lookup_char_property (XOVERLAY (overlay)->plist, prop, 0); @@ -4307,8 +4168,7 @@ DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0, DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, doc: /* Set one property of overlay OVERLAY: give property PROP value VALUE. */) - (overlay, prop, value) - Lisp_Object overlay, prop, value; + (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value) { Lisp_Object tail, buffer; int changed; @@ -4366,13 +4226,12 @@ static int last_overlay_modification_hooks_used; to the end of last_overlay_modification_hooks. */ static void -add_overlay_mod_hooklist (functionlist, overlay) - Lisp_Object functionlist, overlay; +add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay) { int oldsize = XVECTOR (last_overlay_modification_hooks)->size; if (last_overlay_modification_hooks_used == oldsize) - last_overlay_modification_hooks = larger_vector + last_overlay_modification_hooks = larger_vector (last_overlay_modification_hooks, oldsize * 2, Qnil); ASET (last_overlay_modification_hooks, last_overlay_modification_hooks_used, functionlist); last_overlay_modification_hooks_used++; @@ -4395,10 +4254,8 @@ add_overlay_mod_hooklist (functionlist, overlay) and the length of deleted or replaced old text. */ void -report_overlay_modification (start, end, after, arg1, arg2, arg3) - Lisp_Object start, end; - int after; - Lisp_Object arg1, arg2, arg3; +report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, + Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) { Lisp_Object prop, overlay; struct Lisp_Overlay *tail; @@ -4424,7 +4281,7 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3) last_overlay_modification_hooks_used = 0; for (tail = current_buffer->overlays_before; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; Lisp_Object ostart, oend; XSETMISC (overlay, tail); @@ -4461,7 +4318,7 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3) for (tail = current_buffer->overlays_after; tail; tail = tail->next) { - int startpos, endpos; + EMACS_INT startpos, endpos; Lisp_Object ostart, oend; XSETMISC (overlay, tail); @@ -4506,8 +4363,8 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3) Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object)); int i; - bcopy (XVECTOR (last_overlay_modification_hooks)->contents, - copy, size * sizeof (Lisp_Object)); + memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, + size * sizeof (Lisp_Object)); gcpro1.var = copy; gcpro1.nvars = size; @@ -4523,10 +4380,8 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3) } static void -call_overlay_mod_hooks (list, overlay, after, arg1, arg2, arg3) - Lisp_Object list, overlay; - int after; - Lisp_Object arg1, arg2, arg3; +call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, + Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) { struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -4546,8 +4401,7 @@ call_overlay_mod_hooks (list, overlay, after, arg1, arg2, arg3) /* Delete any zero-sized overlays at position POS, if the `evaporate' property is set. */ void -evaporate_overlays (pos) - EMACS_INT pos; +evaporate_overlays (EMACS_INT pos) { Lisp_Object overlay, hit_list; struct Lisp_Overlay *tail; @@ -4556,7 +4410,7 @@ evaporate_overlays (pos) if (pos <= current_buffer->overlay_center) for (tail = current_buffer->overlays_before; tail; tail = tail->next) { - int endpos; + EMACS_INT endpos; XSETMISC (overlay, tail); endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); if (endpos < pos) @@ -4568,7 +4422,7 @@ evaporate_overlays (pos) else for (tail = current_buffer->overlays_after; tail; tail = tail->next) { - int startpos; + EMACS_INT startpos; XSETMISC (overlay, tail); startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); if (startpos > pos) @@ -4585,9 +4439,7 @@ evaporate_overlays (pos) in the slot with offset OFFSET. */ void -buffer_slot_type_mismatch (newval, type) - Lisp_Object newval; - int type; +buffer_slot_type_mismatch (Lisp_Object newval, int type) { Lisp_Object predicate; @@ -4625,7 +4477,6 @@ buffer_slot_type_mismatch (newval, type) #endif #include <stdio.h> -#include <errno.h> #if MAP_ANON == 0 #include <fcntl.h> @@ -4727,13 +4578,13 @@ static int mmap_initialized_p; /* Function prototypes. */ -static int mmap_free_1 P_ ((struct mmap_region *)); -static int mmap_enlarge P_ ((struct mmap_region *, int)); -static struct mmap_region *mmap_find P_ ((POINTER_TYPE *, POINTER_TYPE *)); -static POINTER_TYPE *mmap_alloc P_ ((POINTER_TYPE **, size_t)); -static POINTER_TYPE *mmap_realloc P_ ((POINTER_TYPE **, size_t)); -static void mmap_free P_ ((POINTER_TYPE **ptr)); -static void mmap_init P_ ((void)); +static int mmap_free_1 (struct mmap_region *); +static int mmap_enlarge (struct mmap_region *, int); +static struct mmap_region *mmap_find (POINTER_TYPE *, POINTER_TYPE *); +static POINTER_TYPE *mmap_alloc (POINTER_TYPE **, size_t); +static POINTER_TYPE *mmap_realloc (POINTER_TYPE **, size_t); +static void mmap_free (POINTER_TYPE **ptr); +static void mmap_init (void); /* Return a region overlapping address range START...END, or null if @@ -4976,7 +4827,7 @@ mmap_realloc (var, nbytes) } else if (mmap_alloc (var, nbytes)) { - bcopy (old_ptr, *var, r->nbytes_specified); + memcpy (*var, old_ptr, r->nbytes_specified); mmap_free_1 (MMAP_REGION (old_ptr)); result = *var; r = MMAP_REGION (result); @@ -5066,18 +4917,16 @@ mmap_init () ***********************************************************************/ #ifdef REL_ALLOC -extern POINTER_TYPE *r_alloc P_ ((POINTER_TYPE **, size_t)); -extern POINTER_TYPE *r_re_alloc P_ ((POINTER_TYPE **, size_t)); -extern void r_alloc_free P_ ((POINTER_TYPE **ptr)); +extern POINTER_TYPE *r_alloc (POINTER_TYPE **, size_t); +extern POINTER_TYPE *r_re_alloc (POINTER_TYPE **, size_t); +extern void r_alloc_free (POINTER_TYPE **ptr); #endif /* REL_ALLOC */ /* Allocate NBYTES bytes for buffer B's text buffer. */ static void -alloc_buffer_text (b, nbytes) - struct buffer *b; - size_t nbytes; +alloc_buffer_text (struct buffer *b, size_t nbytes) { POINTER_TYPE *p; @@ -5132,8 +4981,7 @@ enlarge_buffer_text (struct buffer *b, EMACS_INT delta) /* Free buffer B's text buffer. */ static void -free_buffer_text (b) - struct buffer *b; +free_buffer_text (struct buffer *b) { BLOCK_INPUT; @@ -5156,16 +5004,18 @@ free_buffer_text (b) ***********************************************************************/ void -init_buffer_once () +init_buffer_once (void) { int idx; - bzero (buffer_permanent_local_flags, sizeof buffer_permanent_local_flags); + memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); /* Make sure all markable slots in buffer_defaults are initialized reasonably, so mark_buffer won't choke. */ reset_buffer (&buffer_defaults); + eassert (EQ (buffer_defaults.name, make_number (0))); reset_buffer_local_variables (&buffer_defaults, 1); + eassert (EQ (buffer_local_symbols.name, make_number (0))); reset_buffer (&buffer_local_symbols); reset_buffer_local_variables (&buffer_local_symbols, 1); /* Prevent GC from getting confused. */ @@ -5206,7 +5056,8 @@ init_buffer_once () buffer_defaults.truncate_lines = Qnil; buffer_defaults.word_wrap = Qnil; buffer_defaults.ctl_arrow = Qt; - buffer_defaults.direction_reversed = Qnil; + buffer_defaults.bidi_display_reordering = Qnil; + buffer_defaults.bidi_paragraph_direction = Qnil; buffer_defaults.cursor_type = Qt; buffer_defaults.extra_line_spacing = Qnil; buffer_defaults.cursor_in_non_selected_windows = Qt; @@ -5245,7 +5096,7 @@ init_buffer_once () if (sizeof (EMACS_INT) != sizeof (Lisp_Object)) abort (); /* 0 means not a lisp var, -1 means always local, else mask */ - bzero (&buffer_local_flags, sizeof buffer_local_flags); + memset (&buffer_local_flags, 0, sizeof buffer_local_flags); XSETINT (buffer_local_flags.filename, -1); XSETINT (buffer_local_flags.directory, -1); XSETINT (buffer_local_flags.backed_up, -1); @@ -5291,7 +5142,8 @@ init_buffer_once () XSETFASTINT (buffer_local_flags.syntax_table, idx); ++idx; XSETFASTINT (buffer_local_flags.cache_long_line_scans, idx); ++idx; XSETFASTINT (buffer_local_flags.category_table, idx); ++idx; - XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx; + XSETFASTINT (buffer_local_flags.bidi_display_reordering, idx); ++idx; + XSETFASTINT (buffer_local_flags.bidi_paragraph_direction, idx); ++idx; XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx); /* Make this one a permanent local. */ buffer_permanent_local_flags[idx++] = 1; @@ -5348,7 +5200,7 @@ init_buffer_once () } void -init_buffer () +init_buffer (void) { char *pwd; Lisp_Object temp; @@ -5420,33 +5272,37 @@ init_buffer () in the buffer that is current now. */ /* TYPE is nil for a general Lisp variable. - An integer specifies a type; then only LIsp values + An integer specifies a type; then only Lisp values with that type code are allowed (except that nil is allowed too). - LNAME is the LIsp-level variable name. + LNAME is the Lisp-level variable name. VNAME is the name of the buffer slot. DOC is a dummy where you write the doc string as a comment. */ -#define DEFVAR_PER_BUFFER(lname, vname, type, doc) \ - defvar_per_buffer (lname, vname, type, 0) +#define DEFVAR_PER_BUFFER(lname, vname, type, doc) \ + do { \ + static struct Lisp_Buffer_Objfwd bo_fwd; \ + defvar_per_buffer (&bo_fwd, lname, vname, type, 0); \ + } while (0) static void -defvar_per_buffer (namestring, address, type, doc) - char *namestring; - Lisp_Object *address; - Lisp_Object type; - char *doc; +defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, + Lisp_Object *address, Lisp_Object type, char *doc) { - Lisp_Object sym, val; + struct Lisp_Symbol *sym; int offset; - sym = intern (namestring); - val = allocate_misc (); + sym = XSYMBOL (intern (namestring)); offset = (char *)address - (char *)current_buffer; - XMISCTYPE (val) = Lisp_Misc_Buffer_Objfwd; - XBUFFER_OBJFWD (val)->offset = offset; - XBUFFER_OBJFWD (val)->slottype = type; - SET_SYMBOL_VALUE (sym, val); - PER_BUFFER_SYMBOL (offset) = sym; + bo_fwd->type = Lisp_Fwd_Buffer_Obj; + bo_fwd->offset = offset; + bo_fwd->slottype = type; + sym->redirect = SYMBOL_FORWARDED; + { + /* I tried to do the job without a cast, but it seems impossible. + union Lisp_Fwd *fwd; &(fwd->u_buffer_objfwd) = bo_fwd; */ + SET_SYMBOL_FWD (sym, (union Lisp_Fwd *)bo_fwd); + } + XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym); if (PER_BUFFER_IDX (offset) == 0) /* Did a DEFVAR_PER_BUFFER without initializing the corresponding @@ -5457,7 +5313,7 @@ defvar_per_buffer (namestring, address, type, doc) /* initialize the buffer routines */ void -syms_of_buffer () +syms_of_buffer (void) { staticpro (&last_overlay_modification_hooks); last_overlay_modification_hooks @@ -5488,8 +5344,6 @@ syms_of_buffer () staticpro (&Qget_file_buffer); Qpriority = intern_c_string ("priority"); staticpro (&Qpriority); - Qwindow = intern_c_string ("window"); - staticpro (&Qwindow); Qbefore_string = intern_c_string ("before-string"); staticpro (&Qbefore_string); Qafter_string = intern_c_string ("after-string"); @@ -5548,11 +5402,6 @@ This is the same as (default-value 'abbrev-mode). */); doc: /* Default value of `ctl-arrow' for buffers that do not override it. This is the same as (default-value 'ctl-arrow). */); - DEFVAR_LISP_NOPRO ("default-direction-reversed", - &buffer_defaults.direction_reversed, - doc: /* Default value of `direction-reversed' for buffers that do not override it. -This is the same as (default-value 'direction-reversed). */); - DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters", &buffer_defaults.enable_multibyte_characters, doc: /* *Default value of `enable-multibyte-characters' for buffers not overriding it. @@ -5809,11 +5658,23 @@ The variable `coding-system-for-write', if non-nil, overrides this variable. This variable is never applied to a way of decoding a file while reading it. */); - DEFVAR_PER_BUFFER ("direction-reversed", ¤t_buffer->direction_reversed, - Qnil, - doc: /* *Non-nil means lines in the buffer are displayed right to left. */); + DEFVAR_PER_BUFFER ("bidi-display-reordering", + ¤t_buffer->bidi_display_reordering, Qnil, + doc: /* Non-nil means reorder bidirectional text for display in the visual order. */); + + DEFVAR_PER_BUFFER ("bidi-paragraph-direction", + ¤t_buffer->bidi_paragraph_direction, Qnil, + doc: /* *If non-nil, forces directionality of text paragraphs in the buffer. + +If this is nil (the default), the direction of each paragraph is +determined by the first strong directional character of its text. +The values of `right-to-left' and `left-to-right' override that. +Any other value is treated as nil. + +This variable has no effect unless the buffer's value of +\`bidi-display-reordering' is non-nil. */); - DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, Qnil, + DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, Qnil, doc: /* *Non-nil means do not display continuation lines. Instead, give each line of text just one screen line. @@ -6347,7 +6208,7 @@ The function `kill-all-local-variables' runs this before doing anything else. * } void -keys_of_buffer () +keys_of_buffer (void) { initial_define_key (control_x_map, 'b', "switch-to-buffer"); initial_define_key (control_x_map, 'k', "kill-buffer"); diff --git a/src/buffer.h b/src/buffer.h index 5217c6d7298..3a4dd106360 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -107,6 +107,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define BUF_BEG(buf) (BEG) #define BUF_BEG_BYTE(buf) (BEG_BYTE) +/* !!!FIXME: all the BUF_BEGV/BUF_ZV/BUF_PT macros are flawed: + on indirect (or base) buffers, that value is only correct if that buffer + is the current_buffer, or if the buffer's text hasn't been modified (via + an indirect buffer) since it was last current. */ + /* Position of beginning of accessible range of buffer. */ #define BUF_BEGV(buf) ((buf)->begv) #define BUF_BEGV_BYTE(buf) ((buf)->begv_byte) @@ -220,12 +225,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define BUF_TEMP_SET_PT(buffer, position) \ (temp_set_point ((buffer), (position))) -extern void set_point P_ ((EMACS_INT)); -extern INLINE void temp_set_point P_ ((struct buffer *, EMACS_INT)); -extern void set_point_both P_ ((EMACS_INT, EMACS_INT)); -extern INLINE void temp_set_point_both P_ ((struct buffer *, - EMACS_INT, EMACS_INT)); -extern void enlarge_buffer_text P_ ((struct buffer *, EMACS_INT)); +extern void set_point (EMACS_INT); +extern INLINE void temp_set_point (struct buffer *, EMACS_INT); +extern void set_point_both (EMACS_INT, EMACS_INT); +extern INLINE void temp_set_point_both (struct buffer *, + EMACS_INT, EMACS_INT); +extern void enlarge_buffer_text (struct buffer *, EMACS_INT); /* Macros for setting the BEGV, ZV or PT of a given buffer. @@ -313,7 +318,7 @@ while (0) - (ptr - (current_buffer)->text->beg <= (unsigned) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \ + BEG_BYTE) -/* Return character at position POS. */ +/* Return character at byte position POS. */ #define FETCH_CHAR(pos) \ (!NILP (current_buffer->enable_multibyte_characters) \ @@ -327,7 +332,7 @@ while (0) /* Variables used locally in FETCH_MULTIBYTE_CHAR. */ extern unsigned char *_fetch_multibyte_char_p; -/* Return character code of multi-byte form at position POS. If POS +/* Return character code of multi-byte form at byte position POS. If POS doesn't point the head of valid multi-byte form, only the byte at POS is returned. No range checking. */ @@ -336,7 +341,7 @@ extern unsigned char *_fetch_multibyte_char_p; + (pos) + BEG_ADDR - BEG_BYTE), \ STRING_CHAR (_fetch_multibyte_char_p)) -/* Return character at position POS. If the current buffer is unibyte +/* Return character at byte position POS. If the current buffer is unibyte and the character is not ASCII, make the returning character multibyte. */ @@ -447,7 +452,10 @@ struct buffer_text /* The markers that refer to this buffer. This is actually a single marker --- successive elements in its marker `chain' - are the other markers referring to this buffer. */ + are the other markers referring to this buffer. + This is a singly linked unordered list, which means that it's + very cheap to add a marker to the list and it's also very cheap + to move a marker within a buffer. */ struct Lisp_Marker *markers; /* Usually 0. Temporarily set to 1 in decode_coding_gap to @@ -513,6 +521,12 @@ struct buffer 0 means visited file modtime unknown; in no case complain about any mismatch on next save attempt. */ int modtime; + /* Size of the file when modtime was set. This is used to detect the + case where the file grew while we were reading it, so the modtime + is still the same (since it's rounded up to seconds) but we're actually + not up-to-date. -1 means the size is unknown. Only meaningful if + modtime is actually set. */ + EMACS_INT modtime_size; /* The value of text->modiff at the last auto-save. */ int auto_save_modified; /* The value of text->modiff at the last display error. @@ -662,8 +676,13 @@ struct buffer Lisp_Object word_wrap; /* Non-nil means display ctl chars with uparrow. */ Lisp_Object ctl_arrow; - /* Non-nil means display text from right to left. */ - Lisp_Object direction_reversed; + /* Non-nil means reorder bidirectional text for display in the + visual order. */ + Lisp_Object bidi_display_reordering; + /* If non-nil, specifies which direction of text to force in all the + paragraphs of the buffer. Nil means determine paragraph + direction dynamically for each paragraph. */ + Lisp_Object bidi_paragraph_direction; /* Non-nil means do selective display; see doc string in syms_of_buffer (buffer.c) for details. */ Lisp_Object selective_display; @@ -829,6 +848,7 @@ extern struct buffer buffer_defaults; be a Lisp-level local variable for the slot, it has no default value, and the corresponding slot in buffer_defaults is not used. */ + extern struct buffer buffer_local_flags; /* For each buffer slot, this points to the Lisp symbol name @@ -837,23 +857,23 @@ extern struct buffer buffer_local_flags; extern struct buffer buffer_local_symbols; -extern void delete_all_overlays P_ ((struct buffer *)); -extern void reset_buffer P_ ((struct buffer *)); -extern void evaporate_overlays P_ ((EMACS_INT)); -extern int overlays_at P_ ((EMACS_INT pos, int extend, Lisp_Object **vec_ptr, - int *len_ptr, EMACS_INT *next_ptr, - EMACS_INT *prev_ptr, int change_req)); -extern int sort_overlays P_ ((Lisp_Object *, int, struct window *)); -extern void recenter_overlay_lists P_ ((struct buffer *, EMACS_INT)); -extern int overlay_strings P_ ((EMACS_INT, struct window *, unsigned char **)); -extern void validate_region P_ ((Lisp_Object *, Lisp_Object *)); -extern void set_buffer_internal P_ ((struct buffer *)); -extern void set_buffer_internal_1 P_ ((struct buffer *)); -extern void set_buffer_temp P_ ((struct buffer *)); -extern void record_buffer P_ ((Lisp_Object)); -extern void buffer_slot_type_mismatch P_ ((Lisp_Object, int)) NO_RETURN; -extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT)); -extern void mmap_set_vars P_ ((int)); +extern void delete_all_overlays (struct buffer *); +extern void reset_buffer (struct buffer *); +extern void evaporate_overlays (EMACS_INT); +extern int overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, + int *len_ptr, EMACS_INT *next_ptr, + EMACS_INT *prev_ptr, int change_req); +extern int sort_overlays (Lisp_Object *, int, struct window *); +extern void recenter_overlay_lists (struct buffer *, EMACS_INT); +extern EMACS_INT overlay_strings (EMACS_INT, struct window *, unsigned char **); +extern void validate_region (Lisp_Object *, Lisp_Object *); +extern void set_buffer_internal (struct buffer *); +extern void set_buffer_internal_1 (struct buffer *); +extern void set_buffer_temp (struct buffer *); +extern void record_buffer (Lisp_Object); +extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; +extern void fix_overlays_before (struct buffer *, EMACS_INT, EMACS_INT); +extern void mmap_set_vars (int); /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. If NEXTP is non-NULL, return next overlay there. @@ -934,7 +954,7 @@ extern int last_per_buffer_idx; from the start of a buffer structure. */ #define PER_BUFFER_VAR_OFFSET(VAR) \ - ((char *) &buffer_local_flags.VAR - (char *) &buffer_local_flags) + offsetof (struct buffer, VAR) /* Return the index of buffer-local variable VAR. Each per-buffer variable has an index > 0 associated with it, except when it always @@ -999,11 +1019,5 @@ extern int last_per_buffer_idx; #define PER_BUFFER_VALUE(BUFFER, OFFSET) \ (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) -/* Return the symbol of the per-buffer variable at offset OFFSET in - the buffer structure. */ - -#define PER_BUFFER_SYMBOL(OFFSET) \ - (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_symbols)) - /* arch-tag: 679305dd-d41c-4a50-b170-3caf5c97b2d1 (do not change this comment) */ diff --git a/src/bytecode.c b/src/bytecode.c index e95614c72a9..88ac509e4ba 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -272,7 +272,7 @@ struct byte_stack *byte_stack_list; /* Mark objects on byte_stack_list. Called during GC. */ void -mark_byte_stack () +mark_byte_stack (void) { struct byte_stack *stack; Lisp_Object *obj; @@ -301,7 +301,7 @@ mark_byte_stack () counters. Called when GC has completed. */ void -unmark_byte_stack () +unmark_byte_stack (void) { struct byte_stack *stack; @@ -403,8 +403,7 @@ The first argument, BYTESTR, is a string of byte code; the second, VECTOR, a vector of constants; the third, MAXDEPTH, the maximum stack depth used in this function. If the third argument is incorrect, Emacs may crash. */) - (bytestr, vector, maxdepth) - Lisp_Object bytestr, vector, maxdepth; + (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) { int count = SPECPDL_INDEX (); #ifdef BYTE_CODE_METER @@ -505,8 +504,9 @@ If the third argument is incorrect, Emacs may crash. */) v1 = vectorp[op]; if (SYMBOLP (v1)) { - v2 = SYMBOL_VALUE (v1); - if (MISCP (v2) || EQ (v2, Qunbound)) + if (XSYMBOL (v1)->redirect != SYMBOL_PLAINVAL + || (v2 = SYMBOL_VAL (XSYMBOL (v1)), + EQ (v2, Qunbound))) { BEFORE_POTENTIAL_GC (); v2 = Fsymbol_value (v1); @@ -597,14 +597,13 @@ If the third argument is incorrect, Emacs may crash. */) /* Inline the most common case. */ if (SYMBOLP (sym) && !EQ (val, Qunbound) - && !XSYMBOL (sym)->indirect_variable - && !SYMBOL_CONSTANT_P (sym) - && !MISCP (XSYMBOL (sym)->value)) - XSYMBOL (sym)->value = val; + && !XSYMBOL (sym)->redirect + && !SYMBOL_CONSTANT_P (sym)) + XSYMBOL (sym)->val.value = val; else { BEFORE_POTENTIAL_GC (); - set_internal (sym, val, current_buffer, 0); + set_internal (sym, val, Qnil, 0); AFTER_POTENTIAL_GC (); } } @@ -1678,7 +1677,7 @@ If the third argument is incorrect, Emacs may crash. */) } void -syms_of_bytecode () +syms_of_bytecode (void) { Qbytecode = intern_c_string ("byte-code"); staticpro (&Qbytecode); diff --git a/src/callint.c b/src/callint.c index a45f8a372b8..ae11c7cb24d 100644 --- a/src/callint.c +++ b/src/callint.c @@ -29,25 +29,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "window.h" #include "keymap.h" -#ifdef HAVE_INDEX -extern char *index P_ ((const char *, int)); -#endif - -extern Lisp_Object Qcursor_in_echo_area; -extern Lisp_Object Qfile_directory_p; -extern Lisp_Object Qonly; - Lisp_Object Vcurrent_prefix_arg, Qminus, Qplus; Lisp_Object Qcall_interactively; Lisp_Object Vcommand_history; -extern Lisp_Object Vhistory_length; -extern Lisp_Object Vthis_original_command, real_this_command; -extern int history_delete_duplicates; - Lisp_Object Vcommand_debug_status, Qcommand_debug_status; Lisp_Object Qenable_recursive_minibuffers; -extern Lisp_Object Qface, Qminibuffer_prompt; /* Non-nil means treat the mark as active even if mark_active is 0. */ @@ -131,8 +118,7 @@ If the string begins with `^' and `shift-select-mode' is non-nil, You may use `@', `*', and `^' together. They are processed in the order that they appear, before reading any arguments. usage: (interactive &optional ARGS) */) - (args) - Lisp_Object args; + (Lisp_Object args) { return Qnil; } @@ -140,8 +126,7 @@ usage: (interactive &optional ARGS) */) /* Quotify EXP: if EXP is constant, return it. If EXP is not constant, return (quote EXP). */ Lisp_Object -quotify_arg (exp) - register Lisp_Object exp; +quotify_arg (register Lisp_Object exp) { if (!INTEGERP (exp) && !STRINGP (exp) && !NILP (exp) && !EQ (exp, Qt)) @@ -152,8 +137,7 @@ quotify_arg (exp) /* Modify EXP by quotifying each element (except the first). */ Lisp_Object -quotify_args (exp) - Lisp_Object exp; +quotify_args (Lisp_Object exp) { register Lisp_Object tail; Lisp_Object next; @@ -165,12 +149,11 @@ quotify_args (exp) return exp; } -char *callint_argfuns[] +static const char *callint_argfuns[] = {"", "point", "mark", "region-beginning", "region-end"}; static void -check_mark (for_region) - int for_region; +check_mark (int for_region) { Lisp_Object tem; tem = Fmarker_buffer (current_buffer->mark); @@ -191,8 +174,7 @@ check_mark (for_region) of VALUES to do its job. */ static void -fix_command (input, values) - Lisp_Object input, values; +fix_command (Lisp_Object input, Lisp_Object values) { if (CONSP (input)) { @@ -267,8 +249,7 @@ Optional third arg KEYS, if given, specifies the sequence of events to supply, as a vector, if the command inquires which events were used to invoke it. If KEYS is omitted or nil, the return value of `this-command-keys-vector' is used. */) - (function, record_flag, keys) - Lisp_Object function, record_flag, keys; + (Lisp_Object function, Lisp_Object record_flag, Lisp_Object keys) { Lisp_Object *args, *visargs; Lisp_Object specs; @@ -352,8 +333,7 @@ invoke it. If KEYS is omitted or nil, the return value of /* Make a copy of string so that if a GC relocates specs, `string' will still be valid. */ string = (unsigned char *) alloca (SBYTES (specs) + 1); - bcopy (SDATA (specs), string, - SBYTES (specs) + 1); + memcpy (string, SDATA (specs), SBYTES (specs) + 1); } else { @@ -476,7 +456,7 @@ invoke it. If KEYS is omitted or nil, the return value of j += 2; else j++; - tem = (unsigned char *) index (tem, '\n'); + tem = (unsigned char *) strchr (tem, '\n'); if (tem) ++tem; else @@ -507,11 +487,11 @@ invoke it. If KEYS is omitted or nil, the return value of { strncpy (prompt1, tem + 1, sizeof prompt1 - 1); prompt1[sizeof prompt1 - 1] = 0; - tem1 = (char *) index (prompt1, '\n'); + tem1 = strchr (prompt1, '\n'); if (tem1) *tem1 = 0; visargs[0] = build_string (prompt1); - if (index (prompt1, '%')) + if (strchr (prompt1, '%')) callint_message = Fformat (i, visargs); else callint_message = visargs[0]; @@ -816,7 +796,7 @@ invoke it. If KEYS is omitted or nil, the return value of if (NILP (visargs[i]) && STRINGP (args[i])) visargs[i] = args[i]; - tem = (unsigned char *) index (tem, '\n'); + tem = (unsigned char *) strchr (tem, '\n'); if (tem) tem++; else tem = (unsigned char *) ""; } @@ -877,8 +857,7 @@ DEFUN ("prefix-numeric-value", Fprefix_numeric_value, Sprefix_numeric_value, doc: /* Return numeric meaning of raw prefix argument RAW. A raw prefix argument is what you get from `(interactive "P")'. Its numeric meaning is what you would get from `(interactive "p")'. */) - (raw) - Lisp_Object raw; + (Lisp_Object raw) { Lisp_Object val; @@ -897,7 +876,7 @@ Its numeric meaning is what you would get from `(interactive "p")'. */) } void -syms_of_callint () +syms_of_callint (void) { point_marker = Fmake_marker (); staticpro (&point_marker); diff --git a/src/callproc.c b/src/callproc.c index 863d4e41dbd..ee0872b5562 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -24,17 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <stdio.h> #include <setjmp.h> - -#ifndef USE_CRT_DLL -extern int errno; -#endif - -/* Define SIGCHLD as an alias for SIGCLD. */ - -#if !defined (SIGCHLD) && defined (SIGCLD) -#define SIGCHLD SIGCLD -#endif /* SIGCLD */ - #include <sys/types.h> #ifdef HAVE_UNISTD_H @@ -42,36 +31,20 @@ extern int errno; #endif #include <sys/file.h> -#ifdef HAVE_FCNTL_H -#define INCLUDED_FCNTL #include <fcntl.h> -#endif #ifdef WINDOWSNT #define NOMINMAX #include <windows.h> -#include <stdlib.h> /* for proper declaration of environ */ -#include <fcntl.h> #include "w32.h" #define _P_NOWAIT 1 /* from process.h */ #endif #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ -#define INCLUDED_FCNTL -#include <fcntl.h> #include <sys/stat.h> #include <sys/param.h> -#include <errno.h> #endif /* MSDOS */ -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - -#ifndef O_WRONLY -#define O_WRONLY 1 -#endif - #include "lisp.h" #include "commands.h" #include "buffer.h" @@ -96,7 +69,7 @@ extern char **environ; #endif #ifdef HAVE_SETPGID -#if !defined (USG) || defined (BSD_PGRPS) +#if !defined (USG) #undef setpgrp #define setpgrp setpgid #endif @@ -109,8 +82,6 @@ Lisp_Object Vconfigure_info_directory, Vshared_game_score_directory; /* Pattern used by call-process-region to make temp files. */ static Lisp_Object Vtemp_file_name_pattern; -extern Lisp_Object Vtemporary_file_directory; - Lisp_Object Vshell_file_name; Lisp_Object Vprocess_environment, Vinitial_environment; @@ -124,7 +95,7 @@ Lisp_Object Qbuffer_file_type; int synch_process_alive; /* Nonzero => this is a string explaining death of synchronous subprocess. */ -char *synch_process_death; +const char *synch_process_death; /* Nonzero => this is the signal number that terminated the subprocess. */ int synch_process_termsig; @@ -144,8 +115,7 @@ static int call_process_exited; EXFUN (Fgetenv_internal, 2); static Lisp_Object -call_process_kill (fdpid) - Lisp_Object fdpid; +call_process_kill (Lisp_Object fdpid) { emacs_close (XFASTINT (Fcar (fdpid))); EMACS_KILLPG (XFASTINT (Fcdr (fdpid)), SIGKILL); @@ -154,8 +124,7 @@ call_process_kill (fdpid) } Lisp_Object -call_process_cleanup (arg) - Lisp_Object arg; +call_process_cleanup (Lisp_Object arg) { Lisp_Object fdpid = Fcdr (arg); #if defined (MSDOS) @@ -224,9 +193,7 @@ and returns a numeric exit status or a signal description string. If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object infile, buffer, current_dir, path; int display_p; @@ -581,7 +548,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) #ifdef HAVE_SETSID setsid (); #endif -#if defined (USG) && !defined (BSD_PGRPS) +#if defined (USG) setpgrp (); #else setpgrp (pid, pid); @@ -618,12 +585,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) { if (fd[0] >= 0) emacs_close (fd[0]); -#ifndef subprocesses - /* If Emacs has been built with asynchronous subprocess support, - we don't need to do this, I think because it will then have - the facilities for handling SIGCHLD. */ - wait_without_blocking (); -#endif /* subprocesses */ return Qnil; } @@ -692,9 +653,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) QUIT; { - register int nread; + register EMACS_INT nread; int first = 1; - int total_read = 0; + EMACS_INT total_read = 0; int carryover = 0; int display_on_the_fly = display_p; struct coding_system saved_coding; @@ -779,10 +740,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) PT_BYTE + process_coding.produced); carryover = process_coding.carryover_bytes; if (carryover > 0) - /* As CARRYOVER should not be that large, we had - better avoid overhead of bcopy. */ - BCOPY_SHORT (process_coding.carryover, buf, - process_coding.carryover_bytes); + memcpy (buf, process_coding.carryover, + process_coding.carryover_bytes); } } @@ -819,8 +778,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) make_number (total_read)); } +#ifndef MSDOS /* Wait for it to terminate, unless it already has. */ wait_for_termination (pid); +#endif immediate_quit = 0; @@ -832,7 +793,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) if (synch_process_termsig) { - char *signame; + const char *signame; synchronize_system_messages_locale (); signame = strsignal (synch_process_termsig); @@ -850,8 +811,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) } static Lisp_Object -delete_temp_file (name) - Lisp_Object name; +delete_temp_file (Lisp_Object name) { /* Suppress jka-compr handling, etc. */ int count = SPECPDL_INDEX (); @@ -884,9 +844,7 @@ and returns a numeric exit status or a signal description string. If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { struct gcpro gcpro1; Lisp_Object filename_string; @@ -921,7 +879,7 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir); tempfile = (char *) alloca (SBYTES (pattern) + 1); - bcopy (SDATA (pattern), tempfile, SBYTES (pattern) + 1); + memcpy (tempfile, SDATA (pattern), SBYTES (pattern) + 1); coding_systems = Qt; #ifdef HAVE_MKSTEMP @@ -995,7 +953,9 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r RETURN_UNGCPRO (unbind_to (count, Fcall_process (nargs, args))); } -static int relocate_fd (); +#ifndef WINDOWSNT +static int relocate_fd (int fd, int minfd); +#endif static char ** add_env (char **env, char **new_env, char *string) @@ -1050,11 +1010,7 @@ add_env (char **env, char **new_env, char *string) executable directory by the parent. */ int -child_setup (in, out, err, new_argv, set_pgrp, current_dir) - int in, out, err; - register char **new_argv; - int set_pgrp; - Lisp_Object current_dir; +child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, Lisp_Object current_dir) { char **env; char *pwd_var; @@ -1065,19 +1021,9 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) int pid = getpid (); -#ifdef SET_EMACS_PRIORITY - { - extern EMACS_INT emacs_priority; - - if (emacs_priority < 0) - nice (- emacs_priority); - } -#endif - -#ifdef subprocesses /* Close Emacs's descriptors that this process should not have. */ close_process_descs (); -#endif + /* DOS_NT isn't in a vfork, so if we are in the middle of load-file, we will lose if we call close_load_descs here. */ #ifndef DOS_NT @@ -1104,8 +1050,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) pwd_var = (char *) alloca (i + 6); #endif temp = pwd_var + 4; - bcopy ("PWD=", pwd_var, 4); - bcopy (SDATA (current_dir), temp, i); + memcpy (pwd_var, "PWD=", 4); + memcpy (temp, SDATA (current_dir), i); if (!IS_DIRECTORY_SEP (temp[i - 1])) temp[i++] = DIRECTORY_SEP; temp[i] = 0; @@ -1138,7 +1084,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) char **p, **q; register int new_length; Lisp_Object display = Qnil; - + new_length = 0; for (tem = Vprocess_environment; @@ -1174,7 +1120,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) but with corrected value. */ if (egetenv ("PWD")) *new_env++ = pwd_var; - + if (STRINGP (display)) { int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1; @@ -1204,7 +1150,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) } } - + #ifdef WINDOWSNT prepare_standard_handles (in, out, err, handles); set_process_dir (SDATA (current_dir)); @@ -1242,20 +1188,20 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) dup2 (out, 1); dup2 (err, 2); emacs_close (in); - emacs_close (out); - emacs_close (err); + if (out != in) + emacs_close (out); + if (err != in && err != out) + emacs_close (err); #endif /* not MSDOS */ #endif /* not WINDOWSNT */ -#if defined(USG) && !defined(BSD_PGRPS) +#if defined(USG) #ifndef SETPGRP_RELEASES_CTTY setpgrp (); /* No arguments but equivalent in this case */ #endif #else setpgrp (pid, pid); #endif /* USG */ - /* setpgrp_of_tty is incorrect here; it uses input_fd. */ - EMACS_SET_TTY_PGRP (0, &pid); #ifdef MSDOS pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); @@ -1274,6 +1220,9 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) report_file_error ("Spawning child process", Qnil); return cpid; #else /* not WINDOWSNT */ + /* setpgrp_of_tty is incorrect here; it uses input_fd. */ + EMACS_SET_TTY_PGRP (0, &pid); + /* execvp does not accept an environment arg so the only way to pass this environment is to set environ. Our caller is responsible for restoring the ambient value of environ. */ @@ -1288,42 +1237,45 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) #endif /* not MSDOS */ } +#ifndef WINDOWSNT /* Move the file descriptor FD so that its number is not less than MINFD. If the file descriptor is moved at all, the original is freed. */ static int -relocate_fd (fd, minfd) - int fd, minfd; +relocate_fd (int fd, int minfd) { if (fd >= minfd) return fd; else { - int new = dup (fd); + int new; +#ifdef F_DUPFD + new = fcntl (fd, F_DUPFD, minfd); +#else + new = dup (fd); + if (new != -1) + /* Note that we hold the original FD open while we recurse, + to guarantee we'll get a new FD if we need it. */ + new = relocate_fd (new, minfd); +#endif if (new == -1) { - char *message1 = "Error while setting up child: "; - char *errmessage = strerror (errno); - char *message2 = "\n"; + const char *message1 = "Error while setting up child: "; + const char *errmessage = strerror (errno); + const char *message2 = "\n"; emacs_write (2, message1, strlen (message1)); emacs_write (2, errmessage, strlen (errmessage)); emacs_write (2, message2, strlen (message2)); _exit (1); } - /* Note that we hold the original FD open while we recurse, - to guarantee we'll get a new FD if we need it. */ - new = relocate_fd (new, minfd); emacs_close (fd); return new; } } +#endif /* not WINDOWSNT */ static int -getenv_internal_1 (var, varlen, value, valuelen, env) - char *var; - int varlen; - char **value; - int *valuelen; - Lisp_Object env; +getenv_internal_1 (const char *var, int varlen, char **value, int *valuelen, + Lisp_Object env) { for (; CONSP (env); env = XCDR (env)) { @@ -1334,7 +1286,7 @@ getenv_internal_1 (var, varlen, value, valuelen, env) /* NT environment variables are case insensitive. */ && ! strnicmp (SDATA (entry), var, varlen) #else /* not WINDOWSNT */ - && ! bcmp (SDATA (entry), var, varlen) + && ! memcmp (SDATA (entry), var, varlen) #endif /* not WINDOWSNT */ ) { @@ -1357,12 +1309,8 @@ getenv_internal_1 (var, varlen, value, valuelen, env) } static int -getenv_internal (var, varlen, value, valuelen, frame) - char *var; - int varlen; - char **value; - int *valuelen; - Lisp_Object frame; +getenv_internal (const char *var, int varlen, char **value, int *valuelen, + Lisp_Object frame) { /* Try to find VAR in Vprocess_environment first. */ if (getenv_internal_1 (var, varlen, value, valuelen, @@ -1399,8 +1347,7 @@ This function searches `process-environment' for VARIABLE. If optional parameter ENV is a list, then search this list instead of `process-environment', and return t when encountering a negative entry \(an entry for a variable with no value). */) - (variable, env) - Lisp_Object variable, env; + (Lisp_Object variable, Lisp_Object env) { char *value; int valuelen; @@ -1424,8 +1371,7 @@ If optional parameter ENV is a list, then search this list instead of /* A version of getenv that consults the Lisp environment lists, easily callable from C. */ char * -egetenv (var) - char *var; +egetenv (const char *var) { char *value; int valuelen; @@ -1440,7 +1386,7 @@ egetenv (var) /* This is run before init_cmdargs. */ void -init_callproc_1 () +init_callproc_1 (void) { char *data_dir = egetenv ("EMACSDATA"); char *doc_dir = egetenv ("EMACSDOC"); @@ -1462,7 +1408,7 @@ init_callproc_1 () /* This is run after init_cmdargs, when Vinstallation_directory is valid. */ void -init_callproc () +init_callproc (void) { char *data_dir = egetenv ("EMACSDATA"); @@ -1551,16 +1497,15 @@ init_callproc () } void -set_initial_environment () +set_initial_environment (void) { register char **envp; -#ifndef CANNOT_DUMP - if (initialized) - { +#ifdef CANNOT_DUMP + Vprocess_environment = Qnil; #else - { - Vprocess_environment = Qnil; + if (initialized) #endif + { for (envp = environ; *envp; envp++) Vprocess_environment = Fcons (build_string (*envp), Vprocess_environment); @@ -1571,7 +1516,7 @@ set_initial_environment () } void -syms_of_callproc () +syms_of_callproc (void) { #ifdef DOS_NT Qbuffer_file_type = intern ("buffer-file-type"); diff --git a/src/casefiddle.c b/src/casefiddle.c index 30bb457b17d..a9169f79951 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c @@ -33,9 +33,7 @@ enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; Lisp_Object Qidentity; Lisp_Object -casify_object (flag, obj) - enum case_action flag; - Lisp_Object obj; +casify_object (enum case_action flag, Lisp_Object obj) { register int c, c1; register int inword = flag == CASE_DOWN; @@ -130,7 +128,7 @@ casify_object (flag, obj) unsigned char *old_dst = dst; o_size += o_size; /* Probably overkill, but extremely rare. */ SAFE_ALLOCA (dst, void *, o_size); - bcopy (old_dst, dst, o - old_dst); + memcpy (dst, old_dst, o - old_dst); o = dst + (o - old_dst); } c = STRING_CHAR_AND_LENGTH (SDATA (obj) + i_byte, len); @@ -155,8 +153,7 @@ DEFUN ("upcase", Fupcase, Supcase, 1, 1, 0, The argument may be a character or string. The result has the same type. The argument object is not altered--the value is a copy. See also `capitalize', `downcase' and `upcase-initials'. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { return casify_object (CASE_UP, obj); } @@ -165,8 +162,7 @@ DEFUN ("downcase", Fdowncase, Sdowncase, 1, 1, 0, doc: /* Convert argument to lower case and return that. The argument may be a character or string. The result has the same type. The argument object is not altered--the value is a copy. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { return casify_object (CASE_DOWN, obj); } @@ -177,8 +173,7 @@ This means that each word's first character is upper case and the rest is lower case. The argument may be a character or string. The result has the same type. The argument object is not altered--the value is a copy. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { return casify_object (CASE_CAPITALIZE, obj); } @@ -190,8 +185,7 @@ DEFUN ("upcase-initials", Fupcase_initials, Supcase_initials, 1, 1, 0, Do not change the other letters of each word. The argument may be a character or string. The result has the same type. The argument object is not altered--the value is a copy. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { return casify_object (CASE_CAPITALIZE_UP, obj); } @@ -200,9 +194,7 @@ The argument object is not altered--the value is a copy. */) b and e specify range of buffer to operate on. */ void -casify_region (flag, b, e) - enum case_action flag; - Lisp_Object b, e; +casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) { register int c; register int inword = flag == CASE_DOWN; @@ -229,6 +221,8 @@ casify_region (flag, b, e) start_byte = CHAR_TO_BYTE (start); end_byte = CHAR_TO_BYTE (end); + SETUP_BUFFER_SYNTAX_TABLE(); /* For syntax_prefix_flag_p. */ + while (start < end) { int c2, len; @@ -251,7 +245,8 @@ casify_region (flag, b, e) && (!inword || flag != CASE_CAPITALIZE_UP)) c = UPCASE1 (c); if ((int) flag >= (int) CASE_CAPITALIZE) - inword = ((SYNTAX (c) == Sword) && (inword || !SYNTAX_PREFIX (c))); + inword = ((SYNTAX (c) == Sword) + && (inword || !syntax_prefix_flag_p (c))); if (c != c2) { last = start; @@ -310,8 +305,7 @@ These arguments specify the starting and ending character numbers of the region to operate on. When used as a command, the text between point and the mark is operated on. See also `capitalize-region'. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { casify_region (CASE_UP, beg, end); return Qnil; @@ -322,8 +316,7 @@ DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r", These arguments specify the starting and ending character numbers of the region to operate on. When used as a command, the text between point and the mark is operated on. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { casify_region (CASE_DOWN, beg, end); return Qnil; @@ -335,8 +328,7 @@ Capitalized form means each word's first character is upper case and the rest of it is lower case. In programs, give two arguments, the starting and ending character positions to operate on. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { casify_region (CASE_CAPITALIZE, beg, end); return Qnil; @@ -350,21 +342,18 @@ DEFUN ("upcase-initials-region", Fupcase_initials_region, Subsequent letters of each word are not changed. In programs, give two arguments, the starting and ending character positions to operate on. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { casify_region (CASE_CAPITALIZE_UP, beg, end); return Qnil; } static Lisp_Object -operate_on_word (arg, newpoint) - Lisp_Object arg; - EMACS_INT *newpoint; +operate_on_word (Lisp_Object arg, EMACS_INT *newpoint) { Lisp_Object val; - int farend; - int iarg; + EMACS_INT farend; + EMACS_INT iarg; CHECK_NUMBER (arg); iarg = XINT (arg); @@ -382,8 +371,7 @@ DEFUN ("upcase-word", Fupcase_word, Supcase_word, 1, 1, "p", doc: /* Convert following word (or ARG words) to upper case, moving over. With negative argument, convert previous words but do not move. See also `capitalize-word'. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object beg, end; EMACS_INT newpoint; @@ -397,8 +385,7 @@ See also `capitalize-word'. */) DEFUN ("downcase-word", Fdowncase_word, Sdowncase_word, 1, 1, "p", doc: /* Convert following word (or ARG words) to lower case, moving over. With negative argument, convert previous words but do not move. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object beg, end; EMACS_INT newpoint; @@ -414,8 +401,7 @@ DEFUN ("capitalize-word", Fcapitalize_word, Scapitalize_word, 1, 1, "p", This gives the word(s) a first character in upper case and the rest lower case. With negative argument, capitalize previous words but do not move. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object beg, end; EMACS_INT newpoint; @@ -427,7 +413,7 @@ With negative argument, capitalize previous words but do not move. */) } void -syms_of_casefiddle () +syms_of_casefiddle (void) { Qidentity = intern_c_string ("identity"); staticpro (&Qidentity); @@ -445,7 +431,7 @@ syms_of_casefiddle () } void -keys_of_casefiddle () +keys_of_casefiddle (void) { initial_define_key (control_x_map, Ctl('U'), "upcase-region"); Fput (intern ("upcase-region"), Qdisabled, Qt); diff --git a/src/casetab.c b/src/casetab.c index e0a9ec49157..eed6e22087f 100644 --- a/src/casetab.c +++ b/src/casetab.c @@ -34,15 +34,14 @@ Lisp_Object Vascii_canon_table, Vascii_eqv_table; int case_temp1; Lisp_Object case_temp2; -static void set_canon (); -static void set_identity (); -static void shuffle (); +static void set_canon (Lisp_Object case_table, Lisp_Object range, Lisp_Object elt); +static void set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt); +static void shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt); DEFUN ("case-table-p", Fcase_table_p, Scase_table_p, 1, 1, 0, doc: /* Return t if OBJECT is a case table. See `set-case-table' for more information on these data structures. */) - (object) - Lisp_Object object; + (Lisp_Object object) { Lisp_Object up, canon, eqv; @@ -63,8 +62,7 @@ See `set-case-table' for more information on these data structures. */) } static Lisp_Object -check_case_table (obj) - Lisp_Object obj; +check_case_table (Lisp_Object obj) { CHECK_TYPE (!NILP (Fcase_table_p (obj)), Qcase_table_p, obj); return (obj); @@ -72,7 +70,7 @@ check_case_table (obj) DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0, doc: /* Return the case table of the current buffer. */) - () + (void) { return current_buffer->downcase_table; } @@ -80,12 +78,12 @@ DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0, DEFUN ("standard-case-table", Fstandard_case_table, Sstandard_case_table, 0, 0, 0, doc: /* Return the standard case table. This is the one used for new buffers. */) - () + (void) { return Vascii_downcase_table; } -static Lisp_Object set_case_table (); +static Lisp_Object set_case_table (Lisp_Object table, int standard); DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0, doc: /* Select a new case table for the current buffer. @@ -104,8 +102,7 @@ CANONICALIZE maps each character to a canonical equivalent; EQUIVALENCES is a map that cyclicly permutes each equivalence class (of characters with the same canonical equivalent); it may be nil, in which case it is deduced from CANONICALIZE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return set_case_table (table, 0); } @@ -113,16 +110,13 @@ EQUIVALENCES is a map that cyclicly permutes each equivalence class DEFUN ("set-standard-case-table", Fset_standard_case_table, Sset_standard_case_table, 1, 1, 0, doc: /* Select a new standard case table for new buffers. See `set-case-table' for more info on case tables. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return set_case_table (table, 1); } static Lisp_Object -set_case_table (table, standard) - Lisp_Object table; - int standard; +set_case_table (Lisp_Object table, int standard) { Lisp_Object up, canon, eqv; @@ -184,8 +178,7 @@ set_case_table (table, standard) CASE_TABLE. */ static void -set_canon (case_table, range, elt) - Lisp_Object case_table, range, elt; +set_canon (Lisp_Object case_table, Lisp_Object range, Lisp_Object elt) { Lisp_Object up = XCHAR_TABLE (case_table)->extras[0]; Lisp_Object canon = XCHAR_TABLE (case_table)->extras[1]; @@ -200,8 +193,7 @@ set_canon (case_table, range, elt) character. This is called in map_char_table. */ static void -set_identity (table, c, elt) - Lisp_Object table, c, elt; +set_identity (Lisp_Object table, Lisp_Object c, Lisp_Object elt) { if (NATNUMP (elt)) { @@ -225,8 +217,7 @@ set_identity (table, c, elt) operated. */ static void -shuffle (table, c, elt) - Lisp_Object table, c, elt; +shuffle (Lisp_Object table, Lisp_Object c, Lisp_Object elt) { if (NATNUMP (elt)) { @@ -250,7 +241,7 @@ shuffle (table, c, elt) } void -init_casetab_once () +init_casetab_once (void) { register int i; Lisp_Object down, up; @@ -296,7 +287,7 @@ init_casetab_once () } void -syms_of_casetab () +syms_of_casetab (void) { Qcase_table_p = intern_c_string ("case-table-p"); staticpro (&Qcase_table_p); diff --git a/src/category.c b/src/category.c index b56d62b6b80..5c38f351d01 100644 --- a/src/category.c +++ b/src/category.c @@ -59,11 +59,10 @@ Lisp_Object _temp_category_set; /* Category set staff. */ -static Lisp_Object hash_get_category_set P_ ((Lisp_Object, Lisp_Object)); +static Lisp_Object hash_get_category_set (Lisp_Object, Lisp_Object); static Lisp_Object -hash_get_category_set (table, category_set) - Lisp_Object table, category_set; +hash_get_category_set (Lisp_Object table, Lisp_Object category_set) { Lisp_Object val; struct Lisp_Hash_Table *h; @@ -90,8 +89,7 @@ DEFUN ("make-category-set", Fmake_category_set, Smake_category_set, 1, 1, 0, CATEGORIES is a string of category mnemonics. The value is a bool-vector which has t at the indices corresponding to those categories. */) - (categories) - Lisp_Object categories; + (Lisp_Object categories) { Lisp_Object val; int len; @@ -117,7 +115,7 @@ those categories. */) /* Category staff. */ -Lisp_Object check_category_table (); +Lisp_Object check_category_table (Lisp_Object table); DEFUN ("define-category", Fdefine_category, Sdefine_category, 2, 3, 0, doc: /* Define CATEGORY as a category which is described by DOCSTRING. @@ -127,8 +125,7 @@ should be a terse text (preferably less than 16 characters), and the rest lines should be the full description. The category is defined only in category table TABLE, which defaults to the current buffer's category table. */) - (category, docstring, table) - Lisp_Object category, docstring, table; + (Lisp_Object category, Lisp_Object docstring, Lisp_Object table) { CHECK_CATEGORY (category); CHECK_STRING (docstring); @@ -147,8 +144,7 @@ DEFUN ("category-docstring", Fcategory_docstring, Scategory_docstring, 1, 2, 0, doc: /* Return the documentation string of CATEGORY, as defined in TABLE. TABLE should be a category table and defaults to the current buffer's category table. */) - (category, table) - Lisp_Object category, table; + (Lisp_Object category, Lisp_Object table) { CHECK_CATEGORY (category); table = check_category_table (table); @@ -162,8 +158,7 @@ DEFUN ("get-unused-category", Fget_unused_category, Sget_unused_category, If no category remains available, return nil. The optional argument TABLE specifies which category table to modify; it defaults to the current buffer's category table. */) - (table) - Lisp_Object table; + (Lisp_Object table) { int i; @@ -181,8 +176,7 @@ it defaults to the current buffer's category table. */) DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0, doc: /* Return t if ARG is a category table. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { if (CHAR_TABLE_P (arg) && EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table)) @@ -196,8 +190,7 @@ DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0, wrong-type-argument. */ Lisp_Object -check_category_table (table) - Lisp_Object table; +check_category_table (Lisp_Object table) { if (NILP (table)) return current_buffer->category_table; @@ -208,7 +201,7 @@ check_category_table (table) DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0, doc: /* Return the current category table. This is the one specified by the current buffer. */) - () + (void) { return current_buffer->category_table; } @@ -217,15 +210,14 @@ DEFUN ("standard-category-table", Fstandard_category_table, Sstandard_category_table, 0, 0, 0, doc: /* Return the standard category table. This is the one used for new buffers. */) - () + (void) { return Vstandard_category_table; } static void -copy_category_entry (table, c, val) - Lisp_Object table, c, val; +copy_category_entry (Lisp_Object table, Lisp_Object c, Lisp_Object val) { val = Fcopy_sequence (val); if (CONSP (c)) @@ -240,8 +232,7 @@ copy_category_entry (table, c, val) binding TABLE to a sub char table. */ Lisp_Object -copy_category_table (table) - Lisp_Object table; +copy_category_table (Lisp_Object table) { table = copy_char_table (table); @@ -259,8 +250,7 @@ DEFUN ("copy-category-table", Fcopy_category_table, Scopy_category_table, 0, 1, 0, doc: /* Construct a new category table and return it. It is a copy of the TABLE, which defaults to the standard category table. */) - (table) - Lisp_Object table; + (Lisp_Object table) { if (!NILP (table)) check_category_table (table); @@ -273,7 +263,7 @@ It is a copy of the TABLE, which defaults to the standard category table. */) DEFUN ("make-category-table", Fmake_category_table, Smake_category_table, 0, 0, 0, doc: /* Construct a new and empty category table and return it. */) - () + (void) { Lisp_Object val; int i; @@ -290,8 +280,7 @@ DEFUN ("make-category-table", Fmake_category_table, Smake_category_table, DEFUN ("set-category-table", Fset_category_table, Sset_category_table, 1, 1, 0, doc: /* Specify TABLE as the category table for the current buffer. Return TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { int idx; table = check_category_table (table); @@ -304,8 +293,7 @@ Return TABLE. */) Lisp_Object -char_category_set (c) - int c; +char_category_set (int c) { return CHAR_TABLE_REF (current_buffer->category_table, c); } @@ -313,8 +301,7 @@ char_category_set (c) DEFUN ("char-category-set", Fchar_category_set, Schar_category_set, 1, 1, 0, doc: /* Return the category set of CHAR. usage: (char-category-set CHAR) */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { CHECK_NUMBER (ch); return CATEGORY_SET (XFASTINT (ch)); @@ -326,8 +313,7 @@ DEFUN ("category-set-mnemonics", Fcategory_set_mnemonics, CATEGORY-SET is a bool-vector, and the categories \"in\" it are those that are indexes where t occurs in the bool-vector. The return value is a string containing those same categories. */) - (category_set) - Lisp_Object category_set; + (Lisp_Object category_set) { int i, j; char str[96]; @@ -344,8 +330,7 @@ The return value is a string containing those same categories. */) } void -set_category_set (category_set, category, val) - Lisp_Object category_set, category, val; +set_category_set (Lisp_Object category_set, Lisp_Object category, Lisp_Object val) { do { int idx = XINT (category) / 8; @@ -367,8 +352,7 @@ CHARACTER can be either a single character or a cons representing the lower and upper ends of an inclusive character range to modify. If optional fourth argument RESET is non-nil, then delete CATEGORY from the category set instead of adding it. */) - (character, category, table, reset) - Lisp_Object character, category, table, reset; + (Lisp_Object character, Lisp_Object category, Lisp_Object table, Lisp_Object reset) { Lisp_Object set_value; /* Actual value to be set in category sets. */ Lisp_Object category_set; @@ -420,8 +404,7 @@ then delete CATEGORY from the category set instead of adding it. */) directly. */ int -word_boundary_p (c1, c2) - int c1, c2; +word_boundary_p (int c1, int c2) { Lisp_Object category_set1, category_set2; Lisp_Object tail; @@ -466,7 +449,7 @@ word_boundary_p (c1, c2) void -init_category_once () +init_category_once (void) { /* This has to be done here, before we call Fmake_char_table. */ Qcategory_table = intern_c_string ("category-table"); @@ -489,7 +472,7 @@ init_category_once () } void -syms_of_category () +syms_of_category (void) { Qcategoryp = intern_c_string ("categoryp"); staticpro (&Qcategoryp); diff --git a/src/category.h b/src/category.h index b0fca6c7155..e636e32827d 100644 --- a/src/category.h +++ b/src/category.h @@ -113,8 +113,8 @@ extern Lisp_Object _temp_category_set; (!(SINGLE_BYTE_CHAR_P (c1) && SINGLE_BYTE_CHAR_P (c2)) \ && word_boundary_p (c1, c2)) -extern int word_boundary_p P_ ((int, int)); -extern void set_category_set P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); +extern int word_boundary_p (int, int); +extern void set_category_set (Lisp_Object, Lisp_Object, Lisp_Object); /* arch-tag: 309dfe83-c3e2-4d22-8e81-faae5aece0ff (do not change this comment) */ diff --git a/src/ccl.c b/src/ccl.c index ac1d7be621c..ca4a1479091 100644 --- a/src/ccl.c +++ b/src/ccl.c @@ -72,8 +72,6 @@ Lisp_Object Vtranslation_hash_table_vector; #define GET_HASH_TABLE(id) \ (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)]))) -extern int charset_unicode; - /* CCL (Code Conversion Language) is a simple language which has operations on one input buffer, one output buffer, and 7 registers. The syntax of CCL is described in `ccl.el'. Emacs Lisp function @@ -862,11 +860,7 @@ struct ccl_prog_stack static struct ccl_prog_stack ccl_prog_stack_struct[256]; void -ccl_driver (ccl, source, destination, src_size, dst_size, charset_list) - struct ccl_program *ccl; - int *source, *destination; - int src_size, dst_size; - Lisp_Object charset_list; +ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size, int dst_size, Lisp_Object charset_list) { register int *reg = ccl->reg; register int ic = ccl->ic; @@ -1719,7 +1713,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list) msglen = strlen (msg); if (dst + msglen <= (dst_bytes ? dst_end : src)) { - bcopy (msg, dst, msglen); + memcpy (dst, msg, msglen); dst += msglen; } @@ -1732,7 +1726,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list) msglen = strlen (msg); if (dst + msglen > (dst_bytes ? dst_end : src)) break; - bcopy (msg, dst, msglen); + memcpy (dst, msg, msglen); dst += msglen; } goto ccl_finish; @@ -1765,7 +1759,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list) int i = src_end - src; if (dst_bytes && (dst_end - dst) < i) i = dst_end - dst; - bcopy (src, dst, i); + memcpy (dst, src, i); src += i; dst += i; #else @@ -1795,8 +1789,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list) or nil if CCL contains invalid data. */ static Lisp_Object -resolve_symbol_ccl_program (ccl) - Lisp_Object ccl; +resolve_symbol_ccl_program (Lisp_Object ccl) { int i, veclen, unresolved = 0; Lisp_Object result, contents, val; @@ -1867,9 +1860,7 @@ resolve_symbol_ccl_program (ccl) symbols, return Qnil. */ static Lisp_Object -ccl_get_compiled_code (ccl_prog, idx) - Lisp_Object ccl_prog; - int *idx; +ccl_get_compiled_code (Lisp_Object ccl_prog, int *idx) { Lisp_Object val, slot; @@ -1910,9 +1901,7 @@ ccl_get_compiled_code (ccl_prog, idx) If CCL_PROG is nil, we just reset the structure pointed by CCL. */ int -setup_ccl_program (ccl, ccl_prog) - struct ccl_program *ccl; - Lisp_Object ccl_prog; +setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog) { int i; @@ -1953,8 +1942,7 @@ setup_ccl_program (ccl, ccl_prog) /* Check if CCL is updated or not. If not, re-setup members of CCL. */ int -check_ccl_update (ccl) - struct ccl_program *ccl; +check_ccl_update (struct ccl_program *ccl) { Lisp_Object slot, ccl_prog; @@ -1978,8 +1966,7 @@ check_ccl_update (ccl) DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. See the documentation of `define-ccl-program' for the detail of CCL program. */) - (object) - Lisp_Object object; + (Lisp_Object object) { Lisp_Object val; @@ -2013,8 +2000,7 @@ the corresponding register after the execution. See the documentation of `define-ccl-program' for a definition of CCL programs. */) - (ccl_prog, reg) - Lisp_Object ccl_prog, reg; + (Lisp_Object ccl_prog, Lisp_Object reg) { struct ccl_program ccl; int i; @@ -2068,18 +2054,17 @@ is a unibyte string. By default it is a multibyte string. See the documentation of `define-ccl-program' for the detail of CCL program. usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBYTE-P) */) - (ccl_prog, status, str, contin, unibyte_p) - Lisp_Object ccl_prog, status, str, contin, unibyte_p; + (Lisp_Object ccl_prog, Lisp_Object status, Lisp_Object str, Lisp_Object contin, Lisp_Object unibyte_p) { Lisp_Object val; struct ccl_program ccl; int i; int outbufsize; unsigned char *outbuf, *outp; - int str_chars, str_bytes; + EMACS_INT str_chars, str_bytes; #define CCL_EXECUTE_BUF_SIZE 1024 int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE]; - int consumed_chars, consumed_bytes, produced_chars; + EMACS_INT consumed_chars, consumed_bytes, produced_chars; if (setup_ccl_program (&ccl, ccl_prog) < 0) error ("Invalid CCL program"); @@ -2143,7 +2128,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY if (outp - outbuf + MAX_MULTIBYTE_LENGTH * ccl.produced > outbufsize) { - int offset = outp - outbuf; + EMACS_INT offset = outp - outbuf; outbufsize += MAX_MULTIBYTE_LENGTH * ccl.produced; outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); outp = outbuf + offset; @@ -2155,7 +2140,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY { if (outp - outbuf + ccl.produced > outbufsize) { - int offset = outp - outbuf; + EMACS_INT offset = outp - outbuf; outbufsize += ccl.produced; outbuf = (unsigned char *) xrealloc (outbuf, outbufsize); outp = outbuf + offset; @@ -2199,8 +2184,7 @@ DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program, CCL-PROG should be a compiled CCL program (vector), or nil. If it is nil, just reserve NAME as a CCL program name. Return index number of the registered CCL program. */) - (name, ccl_prog) - Lisp_Object name, ccl_prog; + (Lisp_Object name, Lisp_Object ccl_prog) { int len = ASIZE (Vccl_program_table); int idx; @@ -2275,8 +2259,7 @@ DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, 2, 2, 0, doc: /* Register SYMBOL as code conversion map MAP. Return index number of the registered map. */) - (symbol, map) - Lisp_Object symbol, map; + (Lisp_Object symbol, Lisp_Object map) { int len = ASIZE (Vcode_conversion_map_vector); int i; @@ -2315,7 +2298,7 @@ Return index number of the registered map. */) void -syms_of_ccl () +syms_of_ccl (void) { staticpro (&Vccl_program_table); Vccl_program_table = Fmake_vector (make_number (32), Qnil); diff --git a/src/ccl.h b/src/ccl.h index 54fc576c7e0..e4414ddf65c 100644 --- a/src/ccl.h +++ b/src/ccl.h @@ -97,13 +97,13 @@ extern Lisp_Object Vfont_ccl_encoder_alist; /* Setup fields of the structure pointed by CCL appropriately for the execution of ccl program CCL_PROG (symbol or vector). */ -extern int setup_ccl_program P_ ((struct ccl_program *, Lisp_Object)); +extern int setup_ccl_program (struct ccl_program *, Lisp_Object); /* Check if CCL is updated or not. If not, re-setup members of CCL. */ -extern int check_ccl_update P_ ((struct ccl_program *)); +extern int check_ccl_update (struct ccl_program *); -extern void ccl_driver P_ ((struct ccl_program *, int *, int *, int, int, - Lisp_Object)); +extern void ccl_driver (struct ccl_program *, int *, int *, int, int, + Lisp_Object); /* Vector of CCL program names vs corresponding program data. */ extern Lisp_Object Vccl_program_table; diff --git a/src/character.c b/src/character.c index 7cd1eedcef4..1c8fae88176 100644 --- a/src/character.c +++ b/src/character.c @@ -93,8 +93,7 @@ Lisp_Object Vunicode_category_table; character code if possible. Return the resulting code. */ int -char_resolve_modifier_mask (c) - int c; +char_resolve_modifier_mask (int c) { /* A non-ASCII character can't reflect modifier bits to the code. */ if (! ASCII_CHAR_P ((c & ~CHAR_MODIFIER_MASK))) @@ -143,9 +142,7 @@ char_resolve_modifier_mask (c) handle them appropriately. */ int -char_string (c, p) - unsigned c; - unsigned char *p; +char_string (unsigned int c, unsigned char *p) { int bytes; @@ -199,10 +196,7 @@ char_string (c, p) character) of the multibyte form. */ int -string_char (p, advanced, len) - const unsigned char *p; - const unsigned char **advanced; - int *len; +string_char (const unsigned char *p, const unsigned char **advanced, int *len) { int c; const unsigned char *saved_p = p; @@ -245,9 +239,7 @@ string_char (p, advanced, len) case, translace C by all tables. */ int -translate_char (table, c) - Lisp_Object table; - int c; +translate_char (Lisp_Object table, int c) { if (CHAR_TABLE_P (table)) { @@ -272,9 +264,7 @@ translate_char (table, c) future. */ int -multibyte_char_to_unibyte (c, rev_tbl) - int c; - Lisp_Object rev_tbl; +multibyte_char_to_unibyte (int c, Lisp_Object rev_tbl) { if (c < 0x80) return c; @@ -287,8 +277,7 @@ multibyte_char_to_unibyte (c, rev_tbl) by charset_unibyte. */ int -multibyte_char_to_unibyte_safe (c) - int c; +multibyte_char_to_unibyte_safe (int c) { if (c < 0x80) return c; @@ -299,15 +288,14 @@ multibyte_char_to_unibyte_safe (c) DEFUN ("characterp", Fcharacterp, Scharacterp, 1, 2, 0, doc: /* Return non-nil if OBJECT is a character. */) - (object, ignore) - Lisp_Object object, ignore; + (Lisp_Object object, Lisp_Object ignore) { return (CHARACTERP (object) ? Qt : Qnil); } DEFUN ("max-char", Fmax_char, Smax_char, 0, 0, 0, doc: /* Return the character of the maximum code. */) - () + (void) { return make_number (MAX_CHAR); } @@ -315,8 +303,7 @@ DEFUN ("max-char", Fmax_char, Smax_char, 0, 0, 0, DEFUN ("unibyte-char-to-multibyte", Funibyte_char_to_multibyte, Sunibyte_char_to_multibyte, 1, 1, 0, doc: /* Convert the byte CH to multibyte character. */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { int c; @@ -332,8 +319,7 @@ DEFUN ("multibyte-char-to-unibyte", Fmultibyte_char_to_unibyte, Smultibyte_char_to_unibyte, 1, 1, 0, doc: /* Convert the multibyte character CH to a byte. If the multibyte character does not represent a byte, return -1. */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { int cm; @@ -350,24 +336,12 @@ If the multibyte character does not represent a byte, return -1. */) } } -DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0, - doc: /* Return 1 regardless of the argument CHAR. -This is now an obsolete function. We keep it just for backward compatibility. -usage: (char-bytes CHAR) */) - (ch) - Lisp_Object ch; -{ - CHECK_CHARACTER (ch); - return make_number (1); -} - DEFUN ("char-width", Fchar_width, Schar_width, 1, 1, 0, doc: /* Return width of CHAR when displayed in the current buffer. The width is measured by how many columns it occupies on the screen. Tab is taken to occupy `tab-width' columns. usage: (char-width CHAR) */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { Lisp_Object disp; int c, width; @@ -394,11 +368,12 @@ usage: (char-width CHAR) */) characters and bytes of the substring in *NCHARS and *NBYTES respectively. */ -int -c_string_width (const unsigned char *str, int len, int precision, int *nchars, int *nbytes) +EMACS_INT +c_string_width (const unsigned char *str, EMACS_INT len, int precision, + EMACS_INT *nchars, EMACS_INT *nbytes) { - int i = 0, i_byte = 0; - int width = 0; + EMACS_INT i = 0, i_byte = 0; + EMACS_INT width = 0; struct Lisp_Char_Table *dp = buffer_display_table (); while (i_byte < len) @@ -445,10 +420,8 @@ c_string_width (const unsigned char *str, int len, int precision, int *nchars, i current buffer. The width is measured by how many columns it occupies on the screen. */ -int -strwidth (str, len) - unsigned char *str; - int len; +EMACS_INT +strwidth (const unsigned char *str, EMACS_INT len) { return c_string_width (str, len, -1, NULL, NULL); } @@ -460,19 +433,18 @@ strwidth (str, len) PRECISION, and set number of characters and bytes of the substring in *NCHARS and *NBYTES respectively. */ -int -lisp_string_width (string, precision, nchars, nbytes) - Lisp_Object string; - int precision, *nchars, *nbytes; +EMACS_INT +lisp_string_width (Lisp_Object string, int precision, + EMACS_INT *nchars, EMACS_INT *nbytes) { - int len = SCHARS (string); + EMACS_INT len = SCHARS (string); /* This set multibyte to 0 even if STRING is multibyte when it contains only ascii and eight-bit-graphic, but that's intentional. */ int multibyte = len < SBYTES (string); unsigned char *str = SDATA (string); - int i = 0, i_byte = 0; - int width = 0; + EMACS_INT i = 0, i_byte = 0; + EMACS_INT width = 0; struct Lisp_Char_Table *dp = buffer_display_table (); while (i < len) @@ -542,8 +514,7 @@ only the base leading-code is considered; the validity of the following bytes is not checked. Tabs in STRING are always taken to occupy `tab-width' columns. usage: (string-width STRING) */) - (str) - Lisp_Object str; + (Lisp_Object str) { Lisp_Object val; @@ -556,8 +527,7 @@ DEFUN ("char-direction", Fchar_direction, Schar_direction, 1, 1, 0, doc: /* Return the direction of CHAR. The returned value is 0 for left-to-right and 1 for right-to-left. usage: (char-direction CHAR) */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { int c; @@ -573,9 +543,7 @@ usage: (char-direction CHAR) */) nil, we treat each byte as a character. */ EMACS_INT -chars_in_text (ptr, nbytes) - const unsigned char *ptr; - EMACS_INT nbytes; +chars_in_text (const unsigned char *ptr, EMACS_INT nbytes) { /* current_buffer is null at early stages of Emacs initialization. */ if (current_buffer == 0 @@ -591,16 +559,14 @@ chars_in_text (ptr, nbytes) ignores enable-multibyte-characters. */ EMACS_INT -multibyte_chars_in_text (ptr, nbytes) - const unsigned char *ptr; - EMACS_INT nbytes; +multibyte_chars_in_text (const unsigned char *ptr, EMACS_INT nbytes) { const unsigned char *endp = ptr + nbytes; - int chars = 0; + EMACS_INT chars = 0; while (ptr < endp) { - int len = MULTIBYTE_LENGTH (ptr, endp); + EMACS_INT len = MULTIBYTE_LENGTH (ptr, endp); if (len == 0) abort (); @@ -618,12 +584,11 @@ multibyte_chars_in_text (ptr, nbytes) represented by 2-byte in a multibyte text. */ void -parse_str_as_multibyte (str, len, nchars, nbytes) - const unsigned char *str; - int len, *nchars, *nbytes; +parse_str_as_multibyte (const unsigned char *str, EMACS_INT len, + EMACS_INT *nchars, EMACS_INT *nbytes) { const unsigned char *endp = str + len; - int n, chars = 0, bytes = 0; + EMACS_INT n, chars = 0, bytes = 0; if (len >= MAX_MULTIBYTE_LENGTH) { @@ -661,14 +626,13 @@ parse_str_as_multibyte (str, len, nchars, nbytes) area and that is enough. Return the number of bytes of the resulting text. */ -int -str_as_multibyte (str, len, nbytes, nchars) - unsigned char *str; - int len, nbytes, *nchars; +EMACS_INT +str_as_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT nbytes, + EMACS_INT *nchars) { unsigned char *p = str, *endp = str + nbytes; unsigned char *to; - int chars = 0; + EMACS_INT chars = 0; int n; if (nbytes >= MAX_MULTIBYTE_LENGTH) @@ -691,7 +655,7 @@ str_as_multibyte (str, len, nbytes, nchars) to = p; nbytes = endp - p; endp = str + len; - safe_bcopy ((char *) p, (char *) (endp - nbytes), nbytes); + memmove (endp - nbytes, p, nbytes); p = endp - nbytes; if (nbytes >= MAX_MULTIBYTE_LENGTH) @@ -739,13 +703,11 @@ str_as_multibyte (str, len, nbytes, nchars) bytes it may ocupy when converted to multibyte string by `str_to_multibyte'. */ -int -parse_str_to_multibyte (str, len) - unsigned char *str; - int len; +EMACS_INT +parse_str_to_multibyte (const unsigned char *str, EMACS_INT len) { - unsigned char *endp = str + len; - int bytes; + const unsigned char *endp = str + len; + EMACS_INT bytes; for (bytes = 0; str < endp; str++) bytes += (*str < 0x80) ? 1 : 2; @@ -759,10 +721,8 @@ parse_str_to_multibyte (str, len) that we can use LEN bytes at STR as a work area and that is enough. */ -int -str_to_multibyte (str, len, bytes) - unsigned char *str; - int len, bytes; +EMACS_INT +str_to_multibyte (unsigned char *str, EMACS_INT len, EMACS_INT bytes) { unsigned char *p = str, *endp = str + bytes; unsigned char *to; @@ -773,7 +733,7 @@ str_to_multibyte (str, len, bytes) to = p; bytes = endp - p; endp = str + len; - safe_bcopy ((char *) p, (char *) (endp - bytes), bytes); + memmove (endp - bytes, p, bytes); p = endp - bytes; while (p < endp) { @@ -790,10 +750,8 @@ str_to_multibyte (str, len, bytes) actually converts characters in the range 0x80..0xFF to unibyte. */ -int -str_as_unibyte (str, bytes) - unsigned char *str; - int bytes; +EMACS_INT +str_as_unibyte (unsigned char *str, EMACS_INT bytes) { const unsigned char *p = str, *endp = str + bytes; unsigned char *to; @@ -835,11 +793,7 @@ str_as_unibyte (str, bytes) Note: Currently the arg ACCEPT_LATIN_1 is not used. */ EMACS_INT -str_to_unibyte (src, dst, chars, accept_latin_1) - const unsigned char *src; - unsigned char *dst; - EMACS_INT chars; - int accept_latin_1; +str_to_unibyte (const unsigned char *src, unsigned char *dst, EMACS_INT chars, int accept_latin_1) { EMACS_INT i; @@ -858,15 +812,14 @@ str_to_unibyte (src, dst, chars, accept_latin_1) } -int -string_count_byte8 (string) - Lisp_Object string; +EMACS_INT +string_count_byte8 (Lisp_Object string) { int multibyte = STRING_MULTIBYTE (string); - int nbytes = SBYTES (string); + EMACS_INT nbytes = SBYTES (string); unsigned char *p = SDATA (string); unsigned char *pend = p + nbytes; - int count = 0; + EMACS_INT count = 0; int c, len; if (multibyte) @@ -890,13 +843,12 @@ string_count_byte8 (string) Lisp_Object -string_escape_byte8 (string) - Lisp_Object string; +string_escape_byte8 (Lisp_Object string) { - int nchars = SCHARS (string); - int nbytes = SBYTES (string); + EMACS_INT nchars = SCHARS (string); + EMACS_INT nbytes = SBYTES (string); int multibyte = STRING_MULTIBYTE (string); - int byte8_count; + EMACS_INT byte8_count; const unsigned char *src, *src_end; unsigned char *dst; Lisp_Object val; @@ -911,12 +863,22 @@ string_escape_byte8 (string) return string; if (multibyte) - /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ - val = make_uninit_multibyte_string (nchars + byte8_count * 3, - nbytes + byte8_count * 2); + { + if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count + || (MOST_POSITIVE_FIXNUM - nbytes) / 2 < byte8_count) + error ("Maximum string size exceeded"); + + /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ + val = make_uninit_multibyte_string (nchars + byte8_count * 3, + nbytes + byte8_count * 2); + } else - /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ - val = make_uninit_string (nbytes + byte8_count * 3); + { + if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count) + error ("Maximum string size exceeded"); + /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ + val = make_uninit_string (nbytes + byte8_count * 3); + } src = SDATA (string); src_end = src + nbytes; @@ -957,9 +919,7 @@ DEFUN ("string", Fstring, Sstring, 0, MANY, 0, doc: /* Concatenate all the argument characters and make the result a string. usage: (string &rest CHARACTERS) */) - (n, args) - int n; - Lisp_Object *args; + (int n, Lisp_Object *args) { int i, c; unsigned char *buf, *p; @@ -984,9 +944,7 @@ usage: (string &rest CHARACTERS) */) DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, doc: /* Concatenate all the argument bytes and make the result a unibyte string. usage: (unibyte-string &rest BYTES) */) - (n, args) - int n; - Lisp_Object *args; + (int n, Lisp_Object *args) { int i, c; unsigned char *buf, *p; @@ -1016,8 +974,7 @@ DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, The value is a character with modifiers resolved into the character code. Unresolved modifiers are kept in the value. usage: (char-resolve-modifiers CHAR) */) - (character) - Lisp_Object character; + (Lisp_Object character) { int c; @@ -1036,8 +993,7 @@ non-nil, is an index of a target character in the string. If the current buffer (or STRING) is multibyte, and the target character is not ASCII nor 8-bit character, an error is signalled. */) - (position, string) - Lisp_Object position, string; + (Lisp_Object position, Lisp_Object string) { int c; EMACS_INT pos; @@ -1088,14 +1044,14 @@ character is not ASCII nor 8-bit character, an error is signalled. */) void -init_character_once () +init_character_once (void) { } #ifdef emacs void -syms_of_character () +syms_of_character (void) { DEFSYM (Qcharacterp, "characterp"); DEFSYM (Qauto_fill_chars, "auto-fill-chars"); @@ -1107,7 +1063,6 @@ syms_of_character () defsubr (&Scharacterp); defsubr (&Sunibyte_char_to_multibyte); defsubr (&Smultibyte_char_to_unibyte); - defsubr (&Schar_bytes); defsubr (&Schar_width); defsubr (&Sstring_width); defsubr (&Schar_direction); diff --git a/src/character.h b/src/character.h index dee846dbb9a..aea1a47a1f6 100644 --- a/src/character.h +++ b/src/character.h @@ -221,10 +221,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ (ASCII_BYTE_P (byte) || LEADING_CODE_P (byte)) */ #define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80) -/* Kept for backward compatibility. This macro will be removed in the - future. */ -#define BASE_LEADING_CODE_P LEADING_CODE_P - /* How many bytes a character that starts with BYTE occupies in a multibyte form. */ #define BYTES_BY_CHAR_HEAD(byte) \ @@ -235,23 +231,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ : 5) -/* Return the length of the multi-byte form at string STR of length - LEN while assuming that STR points a valid multi-byte form. As - this macro isn't necessary anymore, all callers will be changed to - use BYTES_BY_CHAR_HEAD directly in the future. */ - -#define MULTIBYTE_FORM_LENGTH(str, len) \ - BYTES_BY_CHAR_HEAD (*(str)) - -/* Parse multibyte string STR of length LENGTH and set BYTES to the - byte length of a character at STR while assuming that STR points a - valid multibyte form. As this macro isn't necessary anymore, all - callers will be changed to use BYTES_BY_CHAR_HEAD directly in the - future. */ - -#define PARSE_MULTIBYTE_SEQ(str, length, bytes) \ - (bytes) = BYTES_BY_CHAR_HEAD (*(str)) - /* The byte length of multibyte form at unibyte string P ending at PEND. If STR doesn't point to a valid multibyte form, return 0. */ @@ -617,24 +596,27 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ : 0) -extern int char_resolve_modifier_mask P_ ((int)); -extern int char_string P_ ((unsigned, unsigned char *)); -extern int string_char P_ ((const unsigned char *, - const unsigned char **, int *)); - -extern int translate_char P_ ((Lisp_Object, int c)); -extern int char_printable_p P_ ((int c)); -extern void parse_str_as_multibyte P_ ((const unsigned char *, int, int *, - int *)); -extern int parse_str_to_multibyte P_ ((unsigned char *, int)); -extern int str_as_multibyte P_ ((unsigned char *, int, int, int *)); -extern int str_to_multibyte P_ ((unsigned char *, int, int)); -extern int str_as_unibyte P_ ((unsigned char *, int)); -extern EMACS_INT str_to_unibyte P_ ((const unsigned char *, unsigned char *, - EMACS_INT, int)); -extern int strwidth P_ ((unsigned char *, int)); -extern int c_string_width P_ ((const unsigned char *, int, int, int *, int *)); -extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *)); +extern int char_resolve_modifier_mask (int); +extern int char_string (unsigned, unsigned char *); +extern int string_char (const unsigned char *, + const unsigned char **, int *); + +extern int translate_char (Lisp_Object, int c); +extern int char_printable_p (int c); +extern void parse_str_as_multibyte (const unsigned char *, + EMACS_INT, EMACS_INT *, EMACS_INT *); +extern EMACS_INT parse_str_to_multibyte (const unsigned char *, EMACS_INT); +extern EMACS_INT str_as_multibyte (unsigned char *, EMACS_INT, EMACS_INT, + EMACS_INT *); +extern EMACS_INT str_to_multibyte (unsigned char *, EMACS_INT, EMACS_INT); +extern EMACS_INT str_as_unibyte (unsigned char *, EMACS_INT); +extern EMACS_INT str_to_unibyte (const unsigned char *, unsigned char *, + EMACS_INT, int); +extern EMACS_INT strwidth (const unsigned char *, EMACS_INT); +extern EMACS_INT c_string_width (const unsigned char *, EMACS_INT, int, + EMACS_INT *, EMACS_INT *); +extern EMACS_INT lisp_string_width (Lisp_Object, int, + EMACS_INT *, EMACS_INT *); extern Lisp_Object Vprintable_chars; @@ -645,7 +627,7 @@ extern Lisp_Object Vchar_direction_table; extern Lisp_Object Vchar_unify_table; extern Lisp_Object Vunicode_category_table; -extern Lisp_Object string_escape_byte8 P_ ((Lisp_Object)); +extern Lisp_Object string_escape_byte8 (Lisp_Object); /* Return a translation table of id number ID. */ #define GET_TRANSLATION_TABLE(id) \ @@ -657,18 +639,6 @@ extern Lisp_Object Vauto_fill_chars; extern Lisp_Object Vchar_script_table; extern Lisp_Object Vscript_representative_chars; -/* Copy LEN bytes from FROM to TO. This macro should be used only - when a caller knows that LEN is short and the obvious copy loop is - faster than calling bcopy which has some overhead. Copying a - multibyte sequence of a character is the typical case. */ - -#define BCOPY_SHORT(from, to, len) \ - do { \ - int i = len; \ - unsigned char *from_p = from, *to_p = to; \ - while (i--) *to_p++ = *from_p++; \ - } while (0) - #define DEFSYM(sym, name) \ do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0) diff --git a/src/charset.c b/src/charset.c index 3b45dc348ed..0ab776b6914 100644 --- a/src/charset.c +++ b/src/charset.c @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/types.h> @@ -128,13 +127,6 @@ int inhibit_load_charset_map; Lisp_Object Vcurrent_iso639_language; -/* Defined in chartab.c */ -extern void -map_char_table_for_charset P_ ((void (*c_function) (Lisp_Object, Lisp_Object), - Lisp_Object function, Lisp_Object table, - Lisp_Object arg, struct charset *charset, - unsigned from, unsigned to)); - #define CODE_POINT_TO_INDEX(charset, code) \ ((charset)->code_linear_p \ ? (code) - (charset)->min_code \ @@ -268,11 +260,7 @@ struct charset_map_entries */ static void -load_charset_map (charset, entries, n_entries, control_flag) - struct charset *charset; - struct charset_map_entries *entries; - int n_entries; - int control_flag; +load_charset_map (struct charset *charset, struct charset_map_entries *entries, int n_entries, int control_flag) { Lisp_Object vec, table; unsigned max_code = CHARSET_MAX_CODE (charset); @@ -438,12 +426,10 @@ load_charset_map (charset, entries, n_entries, control_flag) /* Read a hexadecimal number (preceded by "0x") from the file FP while - paying attention to comment charcter '#'. */ + paying attention to comment character '#'. */ static INLINE unsigned -read_hex (fp, eof) - FILE *fp; - int *eof; +read_hex (FILE *fp, int *eof) { int c; unsigned n; @@ -479,8 +465,6 @@ read_hex (fp, eof) return n; } -extern Lisp_Object Qfile_name_handler_alist; - /* Return a mapping vector for CHARSET loaded from MAPFILE. Each line of MAPFILE has this form 0xAAAA 0xCCCC @@ -498,13 +482,8 @@ extern Lisp_Object Qfile_name_handler_alist; Note that this function uses `openp' to open MAPFILE but ignores `file-name-handler-alist' to avoid running any Lisp code. */ -extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object)); - static void -load_charset_map_from_file (charset, mapfile, control_flag) - struct charset *charset; - Lisp_Object mapfile; - int control_flag; +load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int control_flag) { unsigned min_code = CHARSET_MIN_CODE (charset); unsigned max_code = CHARSET_MAX_CODE (charset); @@ -532,7 +511,7 @@ load_charset_map_from_file (charset, mapfile, control_flag) SAFE_ALLOCA (head, struct charset_map_entries *, sizeof (struct charset_map_entries)); entries = head; - bzero (entries, sizeof (struct charset_map_entries)); + memset (entries, 0, sizeof (struct charset_map_entries)); n_entries = 0; eof = 0; @@ -559,7 +538,7 @@ load_charset_map_from_file (charset, mapfile, control_flag) SAFE_ALLOCA (entries->next, struct charset_map_entries *, sizeof (struct charset_map_entries)); entries = entries->next; - bzero (entries, sizeof (struct charset_map_entries)); + memset (entries, 0, sizeof (struct charset_map_entries)); } idx = n_entries % 0x10000; entries->entry[idx].from = from; @@ -568,17 +547,13 @@ load_charset_map_from_file (charset, mapfile, control_flag) n_entries++; } fclose (fp); - close (fd); load_charset_map (charset, head, n_entries, control_flag); SAFE_FREE (); } static void -load_charset_map_from_vector (charset, vec, control_flag) - struct charset *charset; - Lisp_Object vec; - int control_flag; +load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int control_flag) { unsigned min_code = CHARSET_MIN_CODE (charset); unsigned max_code = CHARSET_MAX_CODE (charset); @@ -599,7 +574,7 @@ load_charset_map_from_vector (charset, vec, control_flag) SAFE_ALLOCA (head, struct charset_map_entries *, sizeof (struct charset_map_entries)); entries = head; - bzero (entries, sizeof (struct charset_map_entries)); + memset (entries, 0, sizeof (struct charset_map_entries)); n_entries = 0; for (i = 0; i < len; i += 2) @@ -636,7 +611,7 @@ load_charset_map_from_vector (charset, vec, control_flag) SAFE_ALLOCA (entries->next, struct charset_map_entries *, sizeof (struct charset_map_entries)); entries = entries->next; - bzero (entries, sizeof (struct charset_map_entries)); + memset (entries, 0, sizeof (struct charset_map_entries)); } idx = n_entries % 0x10000; entries->entry[idx].from = from; @@ -654,9 +629,7 @@ load_charset_map_from_vector (charset, vec, control_flag) map it is (see the comment of load_charset_map for the detail). */ static void -load_charset (charset, control_flag) - struct charset *charset; - int control_flag; +load_charset (struct charset *charset, int control_flag) { Lisp_Object map; @@ -679,22 +652,18 @@ load_charset (charset, control_flag) DEFUN ("charsetp", Fcharsetp, Scharsetp, 1, 1, 0, doc: /* Return non-nil if and only if OBJECT is a charset.*/) - (object) - Lisp_Object object; + (Lisp_Object object) { return (CHARSETP (object) ? Qt : Qnil); } -void map_charset_for_dump P_ ((void (*c_function) (Lisp_Object, Lisp_Object), - Lisp_Object function, Lisp_Object arg, - unsigned from, unsigned to)); +void map_charset_for_dump (void (*c_function) (Lisp_Object, Lisp_Object), + Lisp_Object function, Lisp_Object arg, + unsigned from, unsigned to); void -map_charset_for_dump (c_function, function, arg, from, to) - void (*c_function) (Lisp_Object, Lisp_Object); - Lisp_Object function, arg; - unsigned from, to; +map_charset_for_dump (void (*c_function) (Lisp_Object, Lisp_Object), Lisp_Object function, Lisp_Object arg, unsigned int from, unsigned int to) { int from_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, from); int to_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, to); @@ -750,12 +719,8 @@ map_charset_for_dump (c_function, function, arg, from, to) } void -map_charset_chars (c_function, function, arg, - charset, from, to) - void (*c_function) P_ ((Lisp_Object, Lisp_Object)); - Lisp_Object function, arg; - struct charset *charset; - unsigned from, to; +map_charset_chars (void (*c_function)(Lisp_Object, Lisp_Object), Lisp_Object function, + Lisp_Object arg, struct charset *charset, unsigned from, unsigned to) { Lisp_Object range; int partial; @@ -849,8 +814,7 @@ characters contained in CHARSET. The optional 4th and 5th arguments FROM-CODE and TO-CODE specify the range of code points (in CHARSET) of target characters. */) - (function, charset, arg, from_code, to_code) - Lisp_Object function, charset, arg, from_code, to_code; + (Lisp_Object function, Lisp_Object charset, Lisp_Object arg, Lisp_Object from_code, Lisp_Object to_code) { struct charset *cs; unsigned from, to; @@ -888,9 +852,7 @@ DEFUN ("define-charset-internal", Fdefine_charset_internal, Sdefine_charset_internal, charset_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-charset-internal ...) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { /* Charset attr vector. */ Lisp_Object attrs; @@ -954,7 +916,7 @@ usage: (define-charset-internal ...) */) if (! charset.code_linear_p) { charset.code_space_mask = (unsigned char *) xmalloc (256); - bzero (charset.code_space_mask, 256); + memset (charset.code_space_mask, 0, 256); for (i = 0; i < 4; i++) for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1]; j++) @@ -1077,7 +1039,7 @@ usage: (define-charset-internal ...) */) charset.unified_p = 0; - bzero (charset.fast_map, sizeof (charset.fast_map)); + memset (charset.fast_map, 0, sizeof (charset.fast_map)); if (! NILP (args[charset_arg_code_offset])) { @@ -1210,8 +1172,8 @@ usage: (define-charset-internal ...) */) struct charset *new_table = (struct charset *) xmalloc (sizeof (struct charset) * (charset_table_size + 16)); - bcopy (charset_table, new_table, - sizeof (struct charset) * charset_table_size); + memcpy (new_table, charset_table, + sizeof (struct charset) * charset_table_size); charset_table_size += 16; charset_table = new_table; } @@ -1301,17 +1263,13 @@ usage: (define-charset-internal ...) */) charset. */ static int -define_charset_internal (name, dimension, code_space, min_code, max_code, - iso_final, iso_revision, emacs_mule_id, - ascii_compatible, supplementary, - code_offset) - Lisp_Object name; - int dimension; - unsigned char *code_space; - unsigned min_code, max_code; - int iso_final, iso_revision, emacs_mule_id; - int ascii_compatible, supplementary; - int code_offset; +define_charset_internal (Lisp_Object name, + int dimension, + const unsigned char *code_space, + unsigned min_code, unsigned max_code, + int iso_final, int iso_revision, int emacs_mule_id, + int ascii_compatible, int supplementary, + int code_offset) { Lisp_Object args[charset_arg_max]; Lisp_Object plist[14]; @@ -1365,8 +1323,7 @@ define_charset_internal (name, dimension, code_space, min_code, max_code, DEFUN ("define-charset-alias", Fdefine_charset_alias, Sdefine_charset_alias, 2, 2, 0, doc: /* Define ALIAS as an alias for charset CHARSET. */) - (alias, charset) - Lisp_Object alias, charset; + (Lisp_Object alias, Lisp_Object charset) { Lisp_Object attr; @@ -1379,8 +1336,7 @@ DEFUN ("define-charset-alias", Fdefine_charset_alias, DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0, doc: /* Return the property list of CHARSET. */) - (charset) - Lisp_Object charset; + (Lisp_Object charset) { Lisp_Object attrs; @@ -1391,8 +1347,7 @@ DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0, DEFUN ("set-charset-plist", Fset_charset_plist, Sset_charset_plist, 2, 2, 0, doc: /* Set CHARSET's property list to PLIST. */) - (charset, plist) - Lisp_Object charset, plist; + (Lisp_Object charset, Lisp_Object plist) { Lisp_Object attrs; @@ -1412,8 +1367,7 @@ the same meaning as the `:unify-map' attribute in the function `define-charset' (which see). Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */) - (charset, unify_map, deunify) - Lisp_Object charset, unify_map, deunify; + (Lisp_Object charset, Lisp_Object unify_map, Lisp_Object deunify) { int id; struct charset *cs; @@ -1468,8 +1422,7 @@ CHARS is the number of characters in a dimension: 94 or 96. This final char is for private use, thus the range is `0' (48) .. `?' (63). If there's no unused final char for the specified kind of charset, return nil. */) - (dimension, chars) - Lisp_Object dimension, chars; + (Lisp_Object dimension, Lisp_Object chars) { int final_char; @@ -1486,8 +1439,7 @@ return nil. */) } static void -check_iso_charset_parameter (dimension, chars, final_char) - Lisp_Object dimension, chars, final_char; +check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) { CHECK_NATNUM (dimension); CHECK_NATNUM (chars); @@ -1509,8 +1461,7 @@ DEFUN ("declare-equiv-charset", Fdeclare_equiv_charset, Sdeclare_equiv_charset, On decoding by an ISO-2022 base coding system, when a charset specified by DIMENSION, CHARS, and FINAL-CHAR is designated, behave as if CHARSET is designated instead. */) - (dimension, chars, final_char, charset) - Lisp_Object dimension, chars, final_char, charset; + (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset) { int id; int chars_flag; @@ -1537,8 +1488,7 @@ if CHARSET is designated instead. */) */ int -string_xstring_p (string) - Lisp_Object string; +string_xstring_p (Lisp_Object string) { const unsigned char *p = SDATA (string); const unsigned char *endp = p + SBYTES (string); @@ -1565,11 +1515,7 @@ string_xstring_p (string) It may lookup a translation table TABLE if supplied. */ static void -find_charsets_in_text (ptr, nchars, nbytes, charsets, table, multibyte) - const unsigned char *ptr; - EMACS_INT nchars, nbytes; - Lisp_Object charsets, table; - int multibyte; +find_charsets_in_text (const unsigned char *ptr, EMACS_INT nchars, EMACS_INT nbytes, Lisp_Object charsets, Lisp_Object table, int multibyte) { const unsigned char *pend = ptr + nbytes; @@ -1613,8 +1559,7 @@ Optional arg TABLE if non-nil is a translation table to look up. If the current buffer is unibyte, the returned list may contain only `ascii', `eight-bit-control', and `eight-bit-graphic'. */) - (beg, end, table) - Lisp_Object beg, end, table; + (Lisp_Object beg, Lisp_Object end, Lisp_Object table) { Lisp_Object charsets; EMACS_INT from, from_byte, to, stop, stop_byte; @@ -1665,8 +1610,7 @@ Optional arg TABLE if non-nil is a translation table to look up. If STR is unibyte, the returned list may contain only `ascii', `eight-bit-control', and `eight-bit-graphic'. */) - (str, table) - Lisp_Object str, table; + (Lisp_Object str, Lisp_Object table) { Lisp_Object charsets; int i; @@ -1691,9 +1635,7 @@ only `ascii', `eight-bit-control', and `eight-bit-graphic'. */) value of Vchar_unify_table for C; i.e. it is nil, an integer, or a charset symbol. */ int -maybe_unify_char (c, val) - int c; - Lisp_Object val; +maybe_unify_char (int c, Lisp_Object val) { struct charset *charset; @@ -1726,9 +1668,7 @@ maybe_unify_char (c, val) CHARSET. */ int -decode_char (charset, code) - struct charset *charset; - unsigned code; +decode_char (struct charset *charset, unsigned int code) { int c, char_index; enum charset_method method = CHARSET_METHOD (charset); @@ -1807,9 +1747,7 @@ Lisp_Object charset_work; use CHARSET's strict_max_char instead of max_char. */ unsigned -encode_char (charset, c) - struct charset *charset; - int c; +encode_char (struct charset *charset, int c) { unsigned code; enum charset_method method = CHARSET_METHOD (charset); @@ -1923,8 +1861,7 @@ CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE). Optional argument RESTRICTION specifies a way to map the pair of CCS and CODE-POINT to a character. Currently not supported and just ignored. */) - (charset, code_point, restriction) - Lisp_Object charset, code_point, restriction; + (Lisp_Object charset, Lisp_Object code_point, Lisp_Object restriction) { int c, id; unsigned code; @@ -1954,8 +1891,7 @@ Return nil if CHARSET doesn't include CH. Optional argument RESTRICTION specifies a way to map CH to a code-point in CCS. Currently not supported and just ignored. */) - (ch, charset, restriction) - Lisp_Object ch, charset, restriction; + (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction) { int id; unsigned code; @@ -1980,8 +1916,7 @@ DEFUN ("make-char", Fmake_char, Smake_char, 1, 5, 0, CODE1 through CODE4 are optional, but if you don't supply sufficient position codes, it is assumed that the minimum code in each dimension is specified. */) - (charset, code1, code2, code3, code4) - Lisp_Object charset, code1, code2, code3, code4; + (Lisp_Object charset, Lisp_Object code1, Lisp_Object code2, Lisp_Object code3, Lisp_Object code4) { int id, dimension; struct charset *charsetp; @@ -2059,10 +1994,7 @@ is specified. */) Vcharset_ordered_list. */ struct charset * -char_charset (c, charset_list, code_return) - int c; - Lisp_Object charset_list; - unsigned *code_return; +char_charset (int c, Lisp_Object charset_list, unsigned int *code_return) { int maybe_null = 0; @@ -2083,8 +2015,9 @@ char_charset (c, charset_list, code_return) return charset; } charset_list = XCDR (charset_list); - if (c <= MAX_UNICODE_CHAR - && EQ (charset_list, Vcharset_non_preferred_head)) + if (! maybe_null + && c <= MAX_UNICODE_CHAR + && EQ (charset_list, Vcharset_non_preferred_head)) return CHARSET_FROM_ID (charset_unicode); } return (maybe_null ? NULL @@ -2099,8 +2032,7 @@ DEFUN ("split-char", Fsplit_char, Ssplit_char, 1, 1, 0, The charset is decided by the current priority order of charsets. A position-code is a byte value of each dimension of the code-point of CH in the charset. */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { struct charset *charset; int c, dimension; @@ -2130,8 +2062,7 @@ DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 2, 0, If optional 2nd arg RESTRICTION is non-nil, it is a list of charsets from which to find the charset. It may also be a coding system. In that case, find the charset from what supported by that coding system. */) - (ch, restriction) - Lisp_Object ch, restriction; + (Lisp_Object ch, Lisp_Object restriction) { struct charset *charset; @@ -2168,8 +2099,7 @@ DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0, Return charset of a character in the current buffer at position POS. If POS is nil, it defauls to the current point. If POS is out of range, the value is nil. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { Lisp_Object ch; struct charset *charset; @@ -2191,8 +2121,7 @@ by their DIMENSION, CHARS, and FINAL-CHAR, whereas Emacs distinguishes them by charset symbol. See the documentation of the function `charset-info' for the meanings of DIMENSION, CHARS, and FINAL-CHAR. */) - (dimension, chars, final_char) - Lisp_Object dimension, chars, final_char; + (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) { int id; int chars_flag; @@ -2211,7 +2140,7 @@ DEFUN ("clear-charset-maps", Fclear_charset_maps, Sclear_charset_maps, Internal use only. Clear temporary charset mapping tables. It should be called only from temacs invoked for dumping. */) - () + (void) { if (temp_charset_work) { @@ -2229,8 +2158,7 @@ DEFUN ("charset-priority-list", Fcharset_priority_list, Scharset_priority_list, 0, 1, 0, doc: /* Return the list of charsets ordered by priority. HIGHESTP non-nil means just return the highest priority one. */) - (highestp) - Lisp_Object highestp; + (Lisp_Object highestp) { Lisp_Object val = Qnil, list = Vcharset_ordered_list; @@ -2249,9 +2177,7 @@ DEFUN ("set-charset-priority", Fset_charset_priority, Sset_charset_priority, 1, MANY, 0, doc: /* Assign higher priority to the charsets given as arguments. usage: (set-charset-priority &rest charsets) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object new_head, old_list, arglist[2]; Lisp_Object list_2022, list_emacs_mule; @@ -2303,8 +2229,7 @@ DEFUN ("charset-id-internal", Fcharset_id_internal, Scharset_id_internal, 0, 1, 0, doc: /* Internal use only. Return charset identification number of CHARSET. */) - (charset) - Lisp_Object charset; + (Lisp_Object charset) { int id; @@ -2377,7 +2302,7 @@ See also `charset-priority-list' and `set-charset-priority'. */) void -init_charset () +init_charset (void) { Lisp_Object tempdir; tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory); @@ -2395,7 +2320,7 @@ Please check your installation!\n", void -init_charset_once () +init_charset_once (void) { int i, j, k; @@ -2416,7 +2341,7 @@ init_charset_once () #ifdef emacs void -syms_of_charset () +syms_of_charset (void) { DEFSYM (Qcharsetp, "charsetp"); @@ -2439,8 +2364,8 @@ syms_of_charset () Vemacs_mule_charset_list = Qnil; /* Don't staticpro them here. It's done in syms_of_fns. */ - QCtest = intern (":test"); - Qeq = intern ("eq"); + QCtest = intern_c_string (":test"); + Qeq = intern_c_string ("eq"); staticpro (&Vcharset_hash_table); { diff --git a/src/charset.h b/src/charset.h index 718859929df..dbe9c776a0d 100644 --- a/src/charset.h +++ b/src/charset.h @@ -517,8 +517,6 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL]; #define EMACS_MULE_LEADING_CODE_PRIVATE_21 0x9C /* 2/2 */ #define EMACS_MULE_LEADING_CODE_PRIVATE_22 0x9D /* 2/2 */ -extern struct charset *emacs_mule_charset[256]; - extern Lisp_Object Qcharsetp; @@ -534,17 +532,17 @@ extern int charset_ksc5601; extern int charset_unibyte; -extern struct charset *char_charset P_ ((int, Lisp_Object, unsigned *)); -extern Lisp_Object charset_attributes P_ ((int)); +extern struct charset *char_charset (int, Lisp_Object, unsigned *); +extern Lisp_Object charset_attributes (int); -extern int maybe_unify_char P_ ((int, Lisp_Object)); -extern int decode_char P_ ((struct charset *, unsigned)); -extern unsigned encode_char P_ ((struct charset *, int)); -extern int string_xstring_p P_ ((Lisp_Object)); +extern int maybe_unify_char (int, Lisp_Object); +extern int decode_char (struct charset *, unsigned); +extern unsigned encode_char (struct charset *, int); +extern int string_xstring_p (Lisp_Object); -extern void map_charset_chars P_ ((void (*) (Lisp_Object, Lisp_Object), - Lisp_Object, Lisp_Object, - struct charset *, unsigned, unsigned)); +extern void map_charset_chars (void (*) (Lisp_Object, Lisp_Object), + Lisp_Object, Lisp_Object, + struct charset *, unsigned, unsigned); EXFUN (Funify_charset, 3); diff --git a/src/chartab.c b/src/chartab.c index 2b547184b21..fddd8a3d406 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -62,8 +62,7 @@ PURPOSE should be a symbol. If it has a `char-table-extra-slots' property, the property's value should be an integer between 0 and 10 that specifies how many extra slots the char-table has. Otherwise, the char-table has no extra slot. */) - (purpose, init) - register Lisp_Object purpose, init; + (register Lisp_Object purpose, Lisp_Object init) { Lisp_Object vector; Lisp_Object n; @@ -92,9 +91,7 @@ the char-table has no extra slot. */) } static Lisp_Object -make_sub_char_table (depth, min_char, defalt) - int depth, min_char; - Lisp_Object defalt; +make_sub_char_table (int depth, int min_char, Lisp_Object defalt) { Lisp_Object table; int size = VECSIZE (struct Lisp_Sub_Char_Table) - 1 + chartab_size[depth]; @@ -108,8 +105,7 @@ make_sub_char_table (depth, min_char, defalt) } static Lisp_Object -char_table_ascii (table) - Lisp_Object table; +char_table_ascii (Lisp_Object table) { Lisp_Object sub; @@ -123,8 +119,7 @@ char_table_ascii (table) } Lisp_Object -copy_sub_char_table (table) - Lisp_Object table; +copy_sub_char_table (Lisp_Object table) { Lisp_Object copy; int depth = XINT (XSUB_CHAR_TABLE (table)->depth); @@ -148,8 +143,7 @@ copy_sub_char_table (table) Lisp_Object -copy_char_table (table) - Lisp_Object table; +copy_char_table (Lisp_Object table) { Lisp_Object copy; int size = XCHAR_TABLE (table)->size & PSEUDOVECTOR_SIZE_MASK; @@ -175,9 +169,7 @@ copy_char_table (table) } Lisp_Object -sub_char_table_ref (table, c) - Lisp_Object table; - int c; +sub_char_table_ref (Lisp_Object table, int c) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -191,9 +183,7 @@ sub_char_table_ref (table, c) } Lisp_Object -char_table_ref (table, c) - Lisp_Object table; - int c; +char_table_ref (Lisp_Object table, int c) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); Lisp_Object val; @@ -220,11 +210,7 @@ char_table_ref (table, c) } static Lisp_Object -sub_char_table_ref_and_range (table, c, from, to, defalt) - Lisp_Object table; - int c; - int *from, *to; - Lisp_Object defalt; +sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, Lisp_Object defalt) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -286,10 +272,7 @@ sub_char_table_ref_and_range (table, c, from, to, defalt) 1) are different from that of C. */ Lisp_Object -char_table_ref_and_range (table, c, from, to) - Lisp_Object table; - int c; - int *from, *to; +char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); int index = CHARTAB_IDX (c, 0, 0), idx; @@ -363,10 +346,7 @@ char_table_ref_and_range (table, c, from, to) static void -sub_char_table_set (table, c, val) - Lisp_Object table; - int c; - Lisp_Object val; +sub_char_table_set (Lisp_Object table, int c, Lisp_Object val) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT ((tbl)->depth); @@ -390,10 +370,7 @@ sub_char_table_set (table, c, val) } Lisp_Object -char_table_set (table, c, val) - Lisp_Object table; - int c; - Lisp_Object val; +char_table_set (Lisp_Object table, int c, Lisp_Object val) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); @@ -421,12 +398,7 @@ char_table_set (table, c, val) } static void -sub_char_table_set_range (table, depth, min_char, from, to, val) - Lisp_Object *table; - int depth; - int min_char; - int from, to; - Lisp_Object val; +sub_char_table_set_range (Lisp_Object *table, int depth, int min_char, int from, int to, Lisp_Object val) { int max_char = min_char + chartab_chars[depth] - 1; @@ -454,10 +426,7 @@ sub_char_table_set_range (table, depth, min_char, from, to, val) Lisp_Object -char_table_set_range (table, from, to, val) - Lisp_Object table; - int from, to; - Lisp_Object val; +char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val) { struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); Lisp_Object *contents = tbl->contents; @@ -482,8 +451,7 @@ DEFUN ("char-table-subtype", Fchar_table_subtype, Schar_table_subtype, 1, 1, 0, doc: /* Return the subtype of char-table CHAR-TABLE. The value is a symbol. */) - (char_table) - Lisp_Object char_table; + (Lisp_Object char_table) { CHECK_CHAR_TABLE (char_table); @@ -497,8 +465,7 @@ The value is either nil or another char-table. If CHAR-TABLE holds nil for a given character, then the actual applicable value is inherited from the parent char-table \(or from its parents, if necessary). */) - (char_table) - Lisp_Object char_table; + (Lisp_Object char_table) { CHECK_CHAR_TABLE (char_table); @@ -509,8 +476,7 @@ DEFUN ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent, 2, 2, 0, doc: /* Set the parent char-table of CHAR-TABLE to PARENT. Return PARENT. PARENT must be either nil or another char-table. */) - (char_table, parent) - Lisp_Object char_table, parent; + (Lisp_Object char_table, Lisp_Object parent) { Lisp_Object temp; @@ -533,8 +499,7 @@ Return PARENT. PARENT must be either nil or another char-table. */) DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot, 2, 2, 0, doc: /* Return the value of CHAR-TABLE's extra-slot number N. */) - (char_table, n) - Lisp_Object char_table, n; + (Lisp_Object char_table, Lisp_Object n) { CHECK_CHAR_TABLE (char_table); CHECK_NUMBER (n); @@ -549,8 +514,7 @@ DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, Sset_char_table_extra_slot, 3, 3, 0, doc: /* Set CHAR-TABLE's extra-slot number N to VALUE. */) - (char_table, n, value) - Lisp_Object char_table, n, value; + (Lisp_Object char_table, Lisp_Object n, Lisp_Object value) { CHECK_CHAR_TABLE (char_table); CHECK_NUMBER (n); @@ -566,8 +530,7 @@ DEFUN ("char-table-range", Fchar_table_range, Schar_table_range, doc: /* Return the value in CHAR-TABLE for a range of characters RANGE. RANGE should be nil (for the default value), a cons of character codes (for characters in the range), or a character code. */) - (char_table, range) - Lisp_Object char_table, range; + (Lisp_Object char_table, Lisp_Object range) { Lisp_Object val; CHECK_CHAR_TABLE (char_table); @@ -597,8 +560,7 @@ DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range, RANGE should be t (for all characters), nil (for the default value), a cons of character codes (for characters in the range), or a character code. Return VALUE. */) - (char_table, range, value) - Lisp_Object char_table, range, value; + (Lisp_Object char_table, Lisp_Object range, Lisp_Object value) { CHECK_CHAR_TABLE (char_table); if (EQ (range, Qt)) @@ -630,8 +592,7 @@ DEFUN ("set-char-table-default", Fset_char_table_default, Sset_char_table_default, 3, 3, 0, doc: /* This function is obsolete and has no effect. */) - (char_table, ch, value) - Lisp_Object char_table, ch, value; + (Lisp_Object char_table, Lisp_Object ch, Lisp_Object value) { return Qnil; } @@ -640,9 +601,7 @@ This function is obsolete and has no effect. */) integer. If the element is not a character, return CH itself. */ int -char_table_translate (table, ch) - Lisp_Object table; - int ch; +char_table_translate (Lisp_Object table, int ch) { Lisp_Object value; value = Faref (table, make_number (ch)); @@ -652,8 +611,7 @@ char_table_translate (table, ch) } static Lisp_Object -optimize_sub_char_table (table, test) - Lisp_Object table, test; +optimize_sub_char_table (Lisp_Object table, Lisp_Object test) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -686,8 +644,7 @@ DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table, doc: /* Optimize CHAR-TABLE. TEST is the comparison function used to decide whether two entries are equivalent and can be merged. It defaults to `equal'. */) - (char_table, test) - Lisp_Object char_table, test; + (Lisp_Object char_table, Lisp_Object test) { Lisp_Object elt; int i; @@ -723,10 +680,9 @@ equivalent and can be merged. It defaults to `equal'. */) following characters in TABLE have the same value. */ static Lisp_Object -map_sub_char_table (c_function, function, table, arg, val, range, - default_val, parent) - void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); - Lisp_Object function, table, arg, val, range, default_val, parent; +map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), + Lisp_Object function, Lisp_Object table, Lisp_Object arg, Lisp_Object val, + Lisp_Object range, Lisp_Object default_val, Lisp_Object parent) { /* Pointer to the elements of TABLE. */ Lisp_Object *contents; @@ -840,9 +796,7 @@ map_sub_char_table (c_function, function, table, arg, val, range, ARG is passed to C_FUNCTION when that is called. */ void -map_char_table (c_function, function, table, arg) - void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); - Lisp_Object function, table, arg; +map_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object), Lisp_Object function, Lisp_Object table, Lisp_Object arg) { Lisp_Object range, val; struct gcpro gcpro1, gcpro2, gcpro3; @@ -902,8 +856,7 @@ Call FUNCTION for each character in CHAR-TABLE that has non-nil value. FUNCTION is called with two arguments--a key and a value. The key is a character code or a cons of character codes specifying a range of characters that have the same value. */) - (function, char_table) - Lisp_Object function, char_table; + (Lisp_Object function, Lisp_Object char_table) { CHECK_CHAR_TABLE (char_table); @@ -913,12 +866,10 @@ range of characters that have the same value. */) static void -map_sub_char_table_for_charset (c_function, function, table, arg, range, - charset, from, to) - void (*c_function) P_ ((Lisp_Object, Lisp_Object)); - Lisp_Object function, table, arg, range; - struct charset *charset; - unsigned from, to; +map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), + Lisp_Object function, Lisp_Object table, Lisp_Object arg, + Lisp_Object range, struct charset *charset, + unsigned from, unsigned to) { struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); int depth = XINT (tbl->depth); @@ -1000,12 +951,10 @@ map_sub_char_table_for_charset (c_function, function, table, arg, range, map_charset_chars. */ void -map_char_table_for_charset (c_function, function, table, arg, - charset, from, to) - void (*c_function) P_ ((Lisp_Object, Lisp_Object)); - Lisp_Object function, table, arg; - struct charset *charset; - unsigned from, to; +map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), + Lisp_Object function, Lisp_Object table, Lisp_Object arg, + struct charset *charset, + unsigned from, unsigned to) { Lisp_Object range; int c, i; @@ -1049,7 +998,7 @@ map_char_table_for_charset (c_function, function, table, arg, void -syms_of_chartab () +syms_of_chartab (void) { defsubr (&Smake_char_table); defsubr (&Schar_table_parent); @@ -33,13 +33,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* For now, don't try to include termcap.h. On some systems, configure finds a non-standard termcap.h that the main build won't find. */ - -#if defined HAVE_TERMCAP_H && 0 -#include <termcap.h> -#else -extern void tputs P_ ((const char *, int, int (*)(int))); -extern char *tgoto P_ ((const char *, int, int)); -#endif +extern void tputs (const char *, int, int (*)(int)); +extern char *tgoto (const char *, int, int); #define BIG 9999 /* 9999 good on VAXen. For 16 bit machines use about 2000.... */ @@ -50,8 +45,7 @@ int cost; /* sums up costs */ /* ARGSUSED */ int -evalcost (c) - char c; +evalcost (int c) { cost++; return c; @@ -61,8 +55,7 @@ evalcost (c) struct tty_display_info *current_tty; int -cmputc (c) - char c; +cmputc (int c) { if (current_tty->termscript) putc (c & 0177, current_tty->termscript); @@ -331,9 +324,7 @@ losecursor () #define USECR 3 void -cmgoto (tty, row, col) - struct tty_display_info *tty; - int row, col; +cmgoto (struct tty_display_info *tty, int row, int col) { int homecost, crcost, @@ -439,7 +430,7 @@ cmgoto (tty, row, col) void Wcm_clear (struct tty_display_info *tty) { - bzero (tty->Wcm, sizeof (struct cm)); + memset (tty->Wcm, 0, sizeof (struct cm)); UP = 0; BC = 0; } @@ -158,17 +158,17 @@ extern char PC; /* Pad character */ #define losecursor(tty) (curX(tty) = -1, curY(tty) = -1) extern int cost; -extern int evalcost (); +extern int evalcost (int c); #define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc)) extern struct tty_display_info *current_tty; -extern void cmcheckmagic P_ ((struct tty_display_info *)); -extern int cmputc P_ ((int)); -extern void cmcostinit P_ ((struct tty_display_info *)); -extern void cmgoto P_ ((struct tty_display_info *, int, int)); -extern void Wcm_clear P_ ((struct tty_display_info *)); -extern int Wcm_init P_ ((struct tty_display_info *)); +extern void cmcheckmagic (struct tty_display_info *); +extern int cmputc (int); +extern void cmcostinit (struct tty_display_info *); +extern void cmgoto (struct tty_display_info *, int, int); +extern void Wcm_clear (struct tty_display_info *); +extern int Wcm_init (struct tty_display_info *); /* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b (do not change this comment) */ diff --git a/src/cmds.c b/src/cmds.c index 3ad6f988b2d..e12d7c370d9 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -32,24 +32,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "dispextern.h" #include "frame.h" -Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function; +Lisp_Object Qkill_forward_chars, Qkill_backward_chars; /* A possible value for a buffer's overwrite-mode variable. */ Lisp_Object Qoverwrite_mode_binary; -/* Non-nil means put this face on the next self-inserting character. */ -Lisp_Object Vself_insert_face; - -/* This is the command that set up Vself_insert_face. */ -Lisp_Object Vself_insert_face_command; - -extern Lisp_Object Qface; -extern Lisp_Object Vtranslation_table_for_input; +static int internal_self_insert (int, EMACS_INT); DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, doc: /* Return buffer position N characters after (before if N negative) point. */) - (n) - Lisp_Object n; + (Lisp_Object n) { CHECK_NUMBER (n); @@ -57,10 +49,13 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0, } DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "^p", - doc: /* Move point right N characters (left if N is negative). -On reaching end of buffer, stop and signal error. */) - (n) - Lisp_Object n; + doc: /* Move point N characters forward (backward if N is negative). +On reaching end or beginning of buffer, stop and signal error. + +Depending on the bidirectional context, the movement may be to the +right or to the left on the screen. This is in contrast with +\\[right-char], which see. */) + (Lisp_Object n) { if (NILP (n)) XSETFASTINT (n, 1); @@ -73,7 +68,7 @@ On reaching end of buffer, stop and signal error. */) hooks, etcetera), that's not a good approach. So we validate the proposed position, then set point. */ { - int new_point = PT + XINT (n); + EMACS_INT new_point = PT + XINT (n); if (new_point < BEGV) { @@ -93,10 +88,13 @@ On reaching end of buffer, stop and signal error. */) } DEFUN ("backward-char", Fbackward_char, Sbackward_char, 0, 1, "^p", - doc: /* Move point left N characters (right if N is negative). -On attempt to pass beginning or end of buffer, stop and signal error. */) - (n) - Lisp_Object n; + doc: /* Move point N characters backward (forward if N is negative). +On attempt to pass beginning or end of buffer, stop and signal error. + +Depending on the bidirectional context, the movement may be to the +right or to the left on the screen. This is in contrast with +\\[left-char], which see. */) + (Lisp_Object n) { if (NILP (n)) XSETFASTINT (n, 1); @@ -109,18 +107,18 @@ On attempt to pass beginning or end of buffer, stop and signal error. */) DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 1, "^p", doc: /* Move N lines forward (backward if N is negative). -Precisely, if point is on line I, move to the start of line I + N. +Precisely, if point is on line I, move to the start of line I + N +\("start of line" in the logical order). If there isn't room, go as far as possible (no error). Returns the count of lines left to move. If moving forward, that is N - number of lines moved; if backward, N + number moved. With positive N, a non-empty line at the end counts as one line - successfully moved (for the return value). */) - (n) - Lisp_Object n; +successfully moved (for the return value). */) + (Lisp_Object n) { - int opoint = PT, opoint_byte = PT_BYTE; - int pos, pos_byte; - int count, shortage; + EMACS_INT opoint = PT, opoint_byte = PT_BYTE; + EMACS_INT pos, pos_byte; + EMACS_INT count, shortage; if (NILP (n)) count = 1; @@ -154,19 +152,18 @@ With positive N, a non-empty line at the end counts as one line } DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p", - doc: /* Move point to beginning of current line. + doc: /* Move point to beginning of current line (in the logical order). With argument N not nil or 1, move forward N - 1 lines first. If point reaches the beginning or end of buffer, it stops there. This function constrains point to the current field unless this moves -point to a different line than the original, unconstrained result. If -N is nil or 1, and a front-sticky field starts at point, the point +point to a different line than the original, unconstrained result. +If N is nil or 1, and a front-sticky field starts at point, the point does not move. To ignore field boundaries bind `inhibit-field-text-motion' to t, or use the `forward-line' function instead. For instance, `(forward-line 0)' does the same thing as `(beginning-of-line)', except that it ignores field boundaries. */) - (n) - Lisp_Object n; + (Lisp_Object n) { if (NILP (n)) XSETFASTINT (n, 1); @@ -179,7 +176,7 @@ instead. For instance, `(forward-line 0)' does the same thing as } DEFUN ("end-of-line", Fend_of_line, Send_of_line, 0, 1, "^p", - doc: /* Move point to end of current line. + doc: /* Move point to end of current line (in the logical order). With argument N not nil or 1, move forward N - 1 lines first. If point reaches the beginning or end of buffer, it stops there. To ignore intangibility, bind `inhibit-point-motion-hooks' to t. @@ -189,10 +186,9 @@ point to a different line than the original, unconstrained result. If N is nil or 1, and a rear-sticky field ends at point, the point does not move. To ignore field boundaries bind `inhibit-field-text-motion' to t. */) - (n) - Lisp_Object n; + (Lisp_Object n) { - int newpos; + EMACS_INT newpos; if (NILP (n)) XSETFASTINT (n, 1); @@ -232,11 +228,12 @@ DEFUN ("delete-char", Fdelete_char, Sdelete_char, 1, 2, "p\nP", doc: /* Delete the following N characters (previous if N is negative). Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). Interactively, N is the prefix arg, and KILLFLAG is set if -N was explicitly specified. */) - (n, killflag) - Lisp_Object n, killflag; +N was explicitly specified. + +The command `delete-forward' is preferable for interactive use. */) + (Lisp_Object n, Lisp_Object killflag) { - int pos; + EMACS_INT pos; CHECK_NUMBER (n); @@ -265,61 +262,7 @@ N was explicitly specified. */) return Qnil; } -DEFUN ("delete-backward-char", Fdelete_backward_char, Sdelete_backward_char, - 1, 2, "p\nP", - doc: /* Delete the previous N characters (following if N is negative). -Optional second arg KILLFLAG non-nil means kill instead (save in kill ring). -Interactively, N is the prefix arg, and KILLFLAG is set if -N was explicitly specified. -This is meant for interactive use only; from Lisp, better use `delete-char' -with a negated argument. */) - (n, killflag) - Lisp_Object n, killflag; -{ - Lisp_Object value; - int deleted_special = 0; - int pos, pos_byte, i; - - CHECK_NUMBER (n); - - /* See if we are about to delete a tab or newline backwards. */ - pos = PT; - pos_byte = PT_BYTE; - for (i = 0; i < XINT (n) && pos_byte > BEGV_BYTE; i++) - { - int c; - - DEC_BOTH (pos, pos_byte); - c = FETCH_BYTE (pos_byte); - if (c == '\t' || c == '\n') - { - deleted_special = 1; - break; - } - } - - /* In overwrite mode, back over columns while clearing them out, - unless at end of line. */ - if (XINT (n) > 0 - && ! NILP (current_buffer->overwrite_mode) - && ! deleted_special - && ! (PT == ZV || FETCH_BYTE (PT_BYTE) == '\n')) - { - int column = (int) current_column (); /* iftc */ - - value = Fdelete_char (make_number (-XINT (n)), killflag); - i = column - (int) current_column (); /* iftc */ - Finsert_char (make_number (' '), make_number (i), Qnil); - /* Whitespace chars are ASCII chars, so we can simply subtract. */ - SET_PT_BOTH (PT - i, PT_BYTE - i); - } - else - value = Fdelete_char (make_number (-XINT (n)), killflag); - - return value; -} - -int nonundocount; +static int nonundocount; /* Note that there's code in command_loop_1 which typically avoids calling this. */ @@ -330,8 +273,7 @@ Before insertion, `expand-abbrev' is executed if the inserted character does not have word syntax and the previous character in the buffer does. After insertion, the value of `auto-fill-function' is called if the `auto-fill-chars' table has a non-nil value for the inserted character. */) - (n) - Lisp_Object n; + (Lisp_Object n) { int remove_boundary = 1; CHECK_NUMBER (n); @@ -361,59 +303,38 @@ After insertion, the value of `auto-fill-function' is called if the bitch_at_user (); { int character = translate_char (Vtranslation_table_for_input, - XINT (last_command_event)); - if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode)) - { - XSETFASTINT (n, XFASTINT (n) - 2); - /* The first one might want to expand an abbrev. */ - internal_self_insert (character, 1); - /* The bulk of the copies of this char can be inserted simply. - We don't have to handle a user-specified face specially - because it will get inherited from the first char inserted. */ - Finsert_char (make_number (character), n, Qt); - /* The last one might want to auto-fill. */ - internal_self_insert (character, 0); - } - else - while (XINT (n) > 0) - { - int val; - /* Ok since old and new vals both nonneg */ - XSETFASTINT (n, XFASTINT (n) - 1); - val = internal_self_insert (character, XFASTINT (n) != 0); - if (val == 2) - nonundocount = 0; - frame_make_pointer_invisible (); - } + (int) XINT (last_command_event)); + int val = internal_self_insert (character, XFASTINT (n)); + if (val == 2) + nonundocount = 0; + frame_make_pointer_invisible (); } return Qnil; } -/* Insert character C. If NOAUTOFILL is nonzero, don't do autofill - even if it is enabled. +/* Insert N times character C If this insertion is suitable for direct output (completely simple), return 0. A value of 1 indicates this *might* not have been simple. A value of 2 means this did things that call for an undo boundary. */ static Lisp_Object Qexpand_abbrev; +static Lisp_Object Qpost_self_insert_hook, Vpost_self_insert_hook; -int -internal_self_insert (c, noautofill) - int c; - int noautofill; +static int +internal_self_insert (int c, EMACS_INT n) { int hairy = 0; Lisp_Object tem; register enum syntaxcode synt; - Lisp_Object overwrite, string; + Lisp_Object overwrite; /* Length of multi-byte form of C. */ int len; /* Working buffer and pointer for multi-byte form of C. */ unsigned char str[MAX_MULTIBYTE_LENGTH]; - int chars_to_delete = 0; - int spaces_to_insert = 0; + EMACS_INT chars_to_delete = 0; + EMACS_INT spaces_to_insert = 0; overwrite = current_buffer->overwrite_mode; if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)) @@ -450,51 +371,46 @@ internal_self_insert (c, noautofill) /* This is the character after point. */ int c2 = FETCH_CHAR (PT_BYTE); - /* Column the cursor should be placed at after this insertion. - The correct value should be calculated only when necessary. */ - int target_clm = 0; - /* Overwriting in binary-mode always replaces C2 by C. Overwriting in textual-mode doesn't always do that. It inserts newlines in the usual way, and inserts any character at end of line or before a tab if it doesn't use the whole width of the tab. */ - if (EQ (overwrite, Qoverwrite_mode_binary) - || (c != '\n' - && c2 != '\n' - && ! (c2 == '\t' - && XINT (current_buffer->tab_width) > 0 - && XFASTINT (current_buffer->tab_width) < 20 - && (target_clm = ((int) current_column () /* iftc */ - + XINT (Fchar_width (make_number (c)))), - target_clm % XFASTINT (current_buffer->tab_width))))) + if (EQ (overwrite, Qoverwrite_mode_binary)) + chars_to_delete = n; + else if (c != '\n' && c2 != '\n') { - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; + /* Column the cursor should be placed at after this insertion. + The correct value should be calculated only when necessary. */ + int target_clm = ((int) current_column () /* iftc */ + + n * (int) XINT (Fchar_width (make_number (c)))); - if (target_clm == 0) - chars_to_delete = 1; - else - { /* The actual cursor position after the trial of moving to column TARGET_CLM. It is greater than TARGET_CLM if the TARGET_CLM is middle of multi-column character. In that case, the new point is set after that character. */ int actual_clm - = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil)); + = (int) XFASTINT (Fmove_to_column (make_number (target_clm), + Qnil)); chars_to_delete = PT - pos; if (actual_clm > target_clm) - { - /* We will delete too many columns. Let's fill columns + { /* We will delete too many columns. Let's fill columns by spaces so that the remaining text won't move. */ + EMACS_INT actual = PT_BYTE; + DEC_POS (actual); + if (FETCH_CHAR (actual) == '\t') + /* Rather than add spaces, let's just keep the tab. */ + chars_to_delete--; + else spaces_to_insert = actual_clm - target_clm; } - } + SET_PT_BOTH (pos, pos_byte); - hairy = 2; } hairy = 2; } @@ -505,10 +421,10 @@ internal_self_insert (c, noautofill) && synt != Sword && NILP (current_buffer->read_only) && PT > BEGV - && (!NILP (current_buffer->enable_multibyte_characters) - ? SYNTAX (XFASTINT (Fprevious_char ())) == Sword - : (SYNTAX (UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) - == Sword))) + && (SYNTAX (!NILP (current_buffer->enable_multibyte_characters) + ? XFASTINT (Fprevious_char ()) + : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) + == Sword)) { int modiff = MODIFF; Lisp_Object sym; @@ -533,16 +449,30 @@ internal_self_insert (c, noautofill) if (chars_to_delete) { - string = make_string_from_bytes (str, 1, len); + int mc = ((NILP (current_buffer->enable_multibyte_characters) + && SINGLE_BYTE_CHAR_P (c)) + ? UNIBYTE_TO_CHAR (c) : c); + Lisp_Object string = Fmake_string (make_number (n), make_number (mc)); + if (spaces_to_insert) { tem = Fmake_string (make_number (spaces_to_insert), make_number (' ')); - string = concat2 (tem, string); + string = concat2 (string, tem); } replace_range (PT, PT + chars_to_delete, string, 1, 1, 1); - Fforward_char (make_number (1 + spaces_to_insert)); + Fforward_char (make_number (n + spaces_to_insert)); + } + else if (n > 1) + { + USE_SAFE_ALLOCA; + unsigned char *strn, *p; + SAFE_ALLOCA (strn, unsigned char*, n * len); + for (p = strn; n > 0; n--, p += len) + memcpy (p, str, len); + insert_and_inherit (strn, p - strn); + SAFE_FREE (); } else insert_and_inherit (str, len); @@ -550,7 +480,6 @@ internal_self_insert (c, noautofill) if ((CHAR_TABLE_P (Vauto_fill_chars) ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c)) : (c == ' ' || c == '\n')) - && !noautofill && !NILP (current_buffer->auto_fill_function)) { Lisp_Object tem; @@ -568,29 +497,16 @@ internal_self_insert (c, noautofill) hairy = 2; } - /* If previous command specified a face to use, use it. */ - if (!NILP (Vself_insert_face) - && EQ (current_kboard->Vlast_command, Vself_insert_face_command)) - { - Fput_text_property (make_number (PT - 1), make_number (PT), - Qface, Vself_insert_face, Qnil); - Vself_insert_face = Qnil; - } + /* Run hooks for electric keys. */ + call1 (Vrun_hooks, Qpost_self_insert_hook); - if ((synt == Sclose || synt == Smath) - && !NILP (Vblink_paren_function) && INTERACTIVE - && !noautofill) - { - call0 (Vblink_paren_function); - hairy = 2; - } return hairy; } /* module initialization */ void -syms_of_cmds () +syms_of_cmds (void) { Qkill_backward_chars = intern_c_string ("kill-backward-chars"); staticpro (&Qkill_backward_chars); @@ -604,20 +520,13 @@ syms_of_cmds () Qexpand_abbrev = intern_c_string ("expand-abbrev"); staticpro (&Qexpand_abbrev); - DEFVAR_LISP ("self-insert-face", &Vself_insert_face, - doc: /* If non-nil, set the face of the next self-inserting character to this. -See also `self-insert-face-command'. */); - Vself_insert_face = Qnil; + Qpost_self_insert_hook = intern_c_string ("post-self-insert-hook"); + staticpro (&Qpost_self_insert_hook); - DEFVAR_LISP ("self-insert-face-command", &Vself_insert_face_command, - doc: /* This is the command that set up `self-insert-face'. -If `last-command' does not equal this value, we ignore `self-insert-face'. */); - Vself_insert_face_command = Qnil; - - DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function, - doc: /* Function called, if non-nil, whenever a close parenthesis is inserted. -More precisely, a char with closeparen syntax is self-inserted. */); - Vblink_paren_function = Qnil; + DEFVAR_LISP ("post-self-insert-hook", &Vpost_self_insert_hook, + doc: /* Hook run at the end of `self-insert-command'. +This is run after inserting the character. */); + Vpost_self_insert_hook = Qnil; defsubr (&Sforward_point); defsubr (&Sforward_char); @@ -627,13 +536,11 @@ More precisely, a char with closeparen syntax is self-inserted. */); defsubr (&Send_of_line); defsubr (&Sdelete_char); - defsubr (&Sdelete_backward_char); - defsubr (&Sself_insert_command); } void -keys_of_cmds () +keys_of_cmds (void) { int n; @@ -650,10 +557,8 @@ keys_of_cmds () initial_define_key (global_map, Ctl ('A'), "beginning-of-line"); initial_define_key (global_map, Ctl ('B'), "backward-char"); - initial_define_key (global_map, Ctl ('D'), "delete-char"); initial_define_key (global_map, Ctl ('E'), "end-of-line"); initial_define_key (global_map, Ctl ('F'), "forward-char"); - initial_define_key (global_map, 0177, "delete-backward-char"); } /* arch-tag: 022ba3cd-67f9-4978-9c5d-7d2b18d8644e diff --git a/src/coding.c b/src/coding.c index 137e72a0ba4..7a3bc40b9c7 100644 --- a/src/coding.c +++ b/src/coding.c @@ -154,9 +154,8 @@ STRUCT CODING_SYSTEM #if 0 static int -detect_coding_XXX (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_XXX (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -203,8 +202,7 @@ detect_coding_XXX (coding, detect_info) #if 0 static void -decode_coding_XXXX (coding) - struct coding_system *coding; +decode_coding_XXXX (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -261,8 +259,7 @@ decode_coding_XXXX (coding) Below is a template of these functions. */ #if 0 static void -encode_coding_XXX (coding) - struct coding_system *coding; +encode_coding_XXX (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -306,7 +303,6 @@ Lisp_Object Vcoding_system_hash_table; Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type; Lisp_Object Qunix, Qdos; -extern Lisp_Object Qmac; /* frame.c */ Lisp_Object Qbuffer_file_coding_system; Lisp_Object Qpost_read_conversion, Qpre_write_conversion; Lisp_Object Qdefault_char; @@ -320,7 +316,6 @@ Lisp_Object QCdecode_translation_table, QCencode_translation_table; Lisp_Object QCpost_read_conversion, QCpre_write_conversion; Lisp_Object QCascii_compatible_p; -extern Lisp_Object Qinsert_file_contents, Qwrite_region; Lisp_Object Qcall_process, Qcall_process_region; Lisp_Object Qstart_process, Qopen_network_stream; Lisp_Object Qtarget_idx; @@ -328,8 +323,6 @@ Lisp_Object Qtarget_idx; Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source; Lisp_Object Qinterrupted, Qinsufficient_memory; -extern Lisp_Object Qcompletion_ignore_case; - /* If a symbol has this property, evaluate the value to define the symbol as a coding system. */ static Lisp_Object Qcoding_system_define_form; @@ -896,80 +889,80 @@ static struct coding_system coding_categories[coding_category_max]; /* Prototypes for static functions. */ -static void record_conversion_result P_ ((struct coding_system *coding, - enum coding_result_code result)); -static int detect_coding_utf_8 P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_utf_8 P_ ((struct coding_system *)); -static int encode_coding_utf_8 P_ ((struct coding_system *)); - -static int detect_coding_utf_16 P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_utf_16 P_ ((struct coding_system *)); -static int encode_coding_utf_16 P_ ((struct coding_system *)); - -static int detect_coding_iso_2022 P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_iso_2022 P_ ((struct coding_system *)); -static int encode_coding_iso_2022 P_ ((struct coding_system *)); - -static int detect_coding_emacs_mule P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_emacs_mule P_ ((struct coding_system *)); -static int encode_coding_emacs_mule P_ ((struct coding_system *)); - -static int detect_coding_sjis P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_sjis P_ ((struct coding_system *)); -static int encode_coding_sjis P_ ((struct coding_system *)); - -static int detect_coding_big5 P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_big5 P_ ((struct coding_system *)); -static int encode_coding_big5 P_ ((struct coding_system *)); - -static int detect_coding_ccl P_ ((struct coding_system *, - struct coding_detection_info *info)); -static void decode_coding_ccl P_ ((struct coding_system *)); -static int encode_coding_ccl P_ ((struct coding_system *)); - -static void decode_coding_raw_text P_ ((struct coding_system *)); -static int encode_coding_raw_text P_ ((struct coding_system *)); - -static void coding_set_source P_ ((struct coding_system *)); -static void coding_set_destination P_ ((struct coding_system *)); -static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT)); -static void coding_alloc_by_making_gap P_ ((struct coding_system *, - EMACS_INT, EMACS_INT)); -static unsigned char *alloc_destination P_ ((struct coding_system *, - EMACS_INT, unsigned char *)); -static void setup_iso_safe_charsets P_ ((Lisp_Object)); -static unsigned char *encode_designation_at_bol P_ ((struct coding_system *, - int *, int *, - unsigned char *)); -static int detect_eol P_ ((const unsigned char *, - EMACS_INT, enum coding_category)); -static Lisp_Object adjust_coding_eol_type P_ ((struct coding_system *, int)); -static void decode_eol P_ ((struct coding_system *)); -static Lisp_Object get_translation_table P_ ((Lisp_Object, int, int *)); -static Lisp_Object get_translation P_ ((Lisp_Object, int *, int *)); -static int produce_chars P_ ((struct coding_system *, Lisp_Object, int)); -static INLINE void produce_charset P_ ((struct coding_system *, int *, - EMACS_INT)); -static void produce_annotation P_ ((struct coding_system *, EMACS_INT)); -static int decode_coding P_ ((struct coding_system *)); -static INLINE int *handle_composition_annotation P_ ((EMACS_INT, EMACS_INT, - struct coding_system *, - int *, EMACS_INT *)); -static INLINE int *handle_charset_annotation P_ ((EMACS_INT, EMACS_INT, - struct coding_system *, - int *, EMACS_INT *)); -static void consume_chars P_ ((struct coding_system *, Lisp_Object, int)); -static int encode_coding P_ ((struct coding_system *)); -static Lisp_Object make_conversion_work_buffer P_ ((int)); -static Lisp_Object code_conversion_restore P_ ((Lisp_Object)); -static INLINE int char_encodable_p P_ ((int, Lisp_Object)); -static Lisp_Object make_subsidiaries P_ ((Lisp_Object)); +static void record_conversion_result (struct coding_system *coding, + enum coding_result_code result); +static int detect_coding_utf_8 (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_utf_8 (struct coding_system *); +static int encode_coding_utf_8 (struct coding_system *); + +static int detect_coding_utf_16 (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_utf_16 (struct coding_system *); +static int encode_coding_utf_16 (struct coding_system *); + +static int detect_coding_iso_2022 (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_iso_2022 (struct coding_system *); +static int encode_coding_iso_2022 (struct coding_system *); + +static int detect_coding_emacs_mule (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_emacs_mule (struct coding_system *); +static int encode_coding_emacs_mule (struct coding_system *); + +static int detect_coding_sjis (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_sjis (struct coding_system *); +static int encode_coding_sjis (struct coding_system *); + +static int detect_coding_big5 (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_big5 (struct coding_system *); +static int encode_coding_big5 (struct coding_system *); + +static int detect_coding_ccl (struct coding_system *, + struct coding_detection_info *info); +static void decode_coding_ccl (struct coding_system *); +static int encode_coding_ccl (struct coding_system *); + +static void decode_coding_raw_text (struct coding_system *); +static int encode_coding_raw_text (struct coding_system *); + +static void coding_set_source (struct coding_system *); +static void coding_set_destination (struct coding_system *); +static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); +static void coding_alloc_by_making_gap (struct coding_system *, + EMACS_INT, EMACS_INT); +static unsigned char *alloc_destination (struct coding_system *, + EMACS_INT, unsigned char *); +static void setup_iso_safe_charsets (Lisp_Object); +static unsigned char *encode_designation_at_bol (struct coding_system *, + int *, int *, + unsigned char *); +static int detect_eol (const unsigned char *, + EMACS_INT, enum coding_category); +static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); +static void decode_eol (struct coding_system *); +static Lisp_Object get_translation_table (Lisp_Object, int, int *); +static Lisp_Object get_translation (Lisp_Object, int *, int *); +static int produce_chars (struct coding_system *, Lisp_Object, int); +static INLINE void produce_charset (struct coding_system *, int *, + EMACS_INT); +static void produce_annotation (struct coding_system *, EMACS_INT); +static int decode_coding (struct coding_system *); +static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT, + struct coding_system *, + int *, EMACS_INT *); +static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT, + struct coding_system *, + int *, EMACS_INT *); +static void consume_chars (struct coding_system *, Lisp_Object, int); +static int encode_coding (struct coding_system *); +static Lisp_Object make_conversion_work_buffer (int); +static Lisp_Object code_conversion_restore (Lisp_Object); +static INLINE int char_encodable_p (int, Lisp_Object); +static Lisp_Object make_subsidiaries (Lisp_Object); static void record_conversion_result (struct coding_system *coding, @@ -1106,8 +1099,7 @@ record_conversion_result (struct coding_system *coding, static void -coding_set_source (coding) - struct coding_system *coding; +coding_set_source (struct coding_system *coding) { if (BUFFERP (coding->src_object)) { @@ -1129,8 +1121,7 @@ coding_set_source (coding) } static void -coding_set_destination (coding) - struct coding_system *coding; +coding_set_destination (struct coding_system *coding) { if (BUFFERP (coding->dst_object)) { @@ -1159,9 +1150,7 @@ coding_set_destination (coding) static void -coding_alloc_by_realloc (coding, bytes) - struct coding_system *coding; - EMACS_INT bytes; +coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) { coding->destination = (unsigned char *) xrealloc (coding->destination, coding->dst_bytes + bytes); @@ -1169,9 +1158,8 @@ coding_alloc_by_realloc (coding, bytes) } static void -coding_alloc_by_making_gap (coding, gap_head_used, bytes) - struct coding_system *coding; - EMACS_INT gap_head_used, bytes; +coding_alloc_by_making_gap (struct coding_system *coding, + EMACS_INT gap_head_used, EMACS_INT bytes) { if (EQ (coding->src_object, coding->dst_object)) { @@ -1200,10 +1188,8 @@ coding_alloc_by_making_gap (coding, gap_head_used, bytes) static unsigned char * -alloc_destination (coding, nbytes, dst) - struct coding_system *coding; - EMACS_INT nbytes; - unsigned char *dst; +alloc_destination (struct coding_system *coding, EMACS_INT nbytes, + unsigned char *dst) { EMACS_INT offset = dst - coding->destination; @@ -1301,9 +1287,8 @@ alloc_destination (coding, nbytes, dst) #define UTF_8_BOM_3 0xBF static int -detect_coding_utf_8 (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_utf_8 (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -1386,8 +1371,7 @@ detect_coding_utf_8 (coding, detect_info) static void -decode_coding_utf_8 (coding) - struct coding_system *coding; +decode_coding_utf_8 (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -1435,8 +1419,6 @@ decode_coding_utf_8 (coding) } CODING_UTF_8_BOM (coding) = utf_without_bom; - - while (1) { int c, c1, c2, c3, c4, c5; @@ -1459,7 +1441,7 @@ decode_coding_utf_8 (coding) { c = - c1; } - else if (UTF_8_1_OCTET_P(c1)) + else if (UTF_8_1_OCTET_P (c1)) { if (eol_crlf && c1 == '\r') ONE_MORE_BYTE (byte_after_cr); @@ -1543,8 +1525,7 @@ decode_coding_utf_8 (coding) static int -encode_coding_utf_8 (coding) - struct coding_system *coding; +encode_coding_utf_8 (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -1623,9 +1604,8 @@ encode_coding_utf_8 (coding) static int -detect_coding_utf_16 (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_utf_16 (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base = src; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -1708,8 +1688,7 @@ detect_coding_utf_16 (coding, detect_info) } static void -decode_coding_utf_16 (coding) - struct coding_system *coding; +decode_coding_utf_16 (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -1837,8 +1816,7 @@ decode_coding_utf_16 (coding) } static int -encode_coding_utf_16 (coding) - struct coding_system *coding; +encode_coding_utf_16 (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -1979,9 +1957,8 @@ char emacs_mule_bytes[256]; else return 0. */ static int -detect_coding_emacs_mule (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_emacs_mule (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -2069,11 +2046,9 @@ detect_coding_emacs_mule (coding, detect_info) -1. If SRC is too short, return -2. */ int -emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status) - struct coding_system *coding; - const unsigned char *src; - int *nbytes, *nchars, *id; - struct composition_status *cmp_status; +emacs_mule_char (struct coding_system *coding, const unsigned char *src, + int *nbytes, int *nchars, int *id, + struct composition_status *cmp_status) { const unsigned char *src_end = coding->source + coding->src_bytes; const unsigned char *src_base = src; @@ -2210,7 +2185,7 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status) (3) alt&rule composition: 0x80 0xF5 BYTES CHARS | ALT RULE ... ALT CHAR ... and these old form: - + (4) relative composition: 0x80 | MSEQ ... MSEQ (5) rulebase composition: 0x80 0xFF | MSEQ MRULE ... MSEQ @@ -2391,9 +2366,8 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status) static int -emacs_mule_finish_composition (charbuf, cmp_status) - int *charbuf; - struct composition_status *cmp_status; +emacs_mule_finish_composition (int *charbuf, + struct composition_status *cmp_status) { int idx = - cmp_status->length; int new_chars; @@ -2448,8 +2422,7 @@ emacs_mule_finish_composition (charbuf, cmp_status) static void -decode_coding_emacs_mule (coding) - struct coding_system *coding; +decode_coding_emacs_mule (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -2713,8 +2686,7 @@ decode_coding_emacs_mule (coding) static int -encode_coding_emacs_mule (coding) - struct coding_system *coding; +encode_coding_emacs_mule (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -3007,8 +2979,7 @@ enum iso_code_class_type iso_code_class[256]; (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) static void -setup_iso_safe_charsets (attrs) - Lisp_Object attrs; +setup_iso_safe_charsets (Lisp_Object attrs) { Lisp_Object charset_list, safe_charsets; Lisp_Object request; @@ -3076,9 +3047,8 @@ setup_iso_safe_charsets (attrs) If it is, return 1, else return 0. */ static int -detect_coding_iso_2022 (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_iso_2022 (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base = src; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -3442,12 +3412,10 @@ detect_coding_iso_2022 (coding, detect_info) /* Finish the current composition as invalid. */ -static int finish_composition P_ ((int *, struct composition_status *)); +static int finish_composition (int *, struct composition_status *); static int -finish_composition (charbuf, cmp_status) - int *charbuf; - struct composition_status *cmp_status; +finish_composition (int *charbuf, struct composition_status *cmp_status) { int idx = - cmp_status->length; int new_chars; @@ -3584,8 +3552,7 @@ finish_composition (charbuf, cmp_status) /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ static void -decode_coding_iso_2022 (coding) - struct coding_system *coding; +decode_coding_iso_2022 (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -4130,8 +4097,8 @@ decode_coding_iso_2022 (coding) #define ENCODE_DESIGNATION(charset, reg, coding) \ do { \ unsigned char final_char = CHARSET_ISO_FINAL (charset); \ - char *intermediate_char_94 = "()*+"; \ - char *intermediate_char_96 = ",-./"; \ + const char *intermediate_char_94 = "()*+"; \ + const char *intermediate_char_96 = ",-./"; \ int revision = -1; \ int c; \ \ @@ -4317,7 +4284,7 @@ decode_coding_iso_2022 (coding) #define ENCODE_ISO_CHARACTER(charset, c) \ do { \ - int code = ENCODE_CHAR ((charset),(c)); \ + int code = ENCODE_CHAR ((charset), (c)); \ \ if (CHARSET_DIMENSION (charset) == 1) \ ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ @@ -4331,11 +4298,9 @@ decode_coding_iso_2022 (coding) Return new DST. */ unsigned char * -encode_invocation_designation (charset, coding, dst, p_nchars) - struct charset *charset; - struct coding_system *coding; - unsigned char *dst; - int *p_nchars; +encode_invocation_designation (struct charset *charset, + struct coding_system *coding, + unsigned char *dst, int *p_nchars) { int multibytep = coding->dst_multibyte; int produced_chars = *p_nchars; @@ -4447,10 +4412,8 @@ encode_invocation_designation (charset, coding, dst, p_nchars) find all the necessary designations. */ static unsigned char * -encode_designation_at_bol (coding, charbuf, charbuf_end, dst) - struct coding_system *coding; - int *charbuf, *charbuf_end; - unsigned char *dst; +encode_designation_at_bol (struct coding_system *coding, int *charbuf, + int *charbuf_end, unsigned char *dst) { struct charset *charset; /* Table of charsets to be designated to each graphic register. */ @@ -4500,8 +4463,7 @@ encode_designation_at_bol (coding, charbuf, charbuf_end, dst) /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ static int -encode_coding_iso_2022 (coding) - struct coding_system *coding; +encode_coding_iso_2022 (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -4694,9 +4656,8 @@ encode_coding_iso_2022 (coding) CATEGORY_MASK_SJIS, else return 0. */ static int -detect_coding_sjis (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_sjis (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -4752,9 +4713,8 @@ detect_coding_sjis (coding, detect_info) CATEGORY_MASK_BIG5, else return 0. */ static int -detect_coding_big5 (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_big5 (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -4800,8 +4760,7 @@ detect_coding_big5 (coding, detect_info) If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ static void -decode_coding_sjis (coding) - struct coding_system *coding; +decode_coding_sjis (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -4919,8 +4878,7 @@ decode_coding_sjis (coding) } static void -decode_coding_big5 (coding) - struct coding_system *coding; +decode_coding_big5 (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -5024,8 +4982,7 @@ decode_coding_big5 (coding) SJIS text, else encode BIG5 text. */ static int -encode_coding_sjis (coding) - struct coding_system *coding; +encode_coding_sjis (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -5117,8 +5074,7 @@ encode_coding_sjis (coding) } static int -encode_coding_big5 (coding) - struct coding_system *coding; +encode_coding_big5 (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -5196,9 +5152,8 @@ encode_coding_big5 (coding) CATEGORY_MASK_CCL, else return 0. */ static int -detect_coding_ccl (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_ccl (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -5237,8 +5192,7 @@ detect_coding_ccl (coding, detect_info) } static void -decode_coding_ccl (coding) - struct coding_system *coding; +decode_coding_ccl (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -5307,8 +5261,7 @@ decode_coding_ccl (coding) } static int -encode_coding_ccl (coding) - struct coding_system *coding; +encode_coding_ccl (struct coding_system *coding) { struct ccl_program *ccl = &coding->spec.ccl->ccl; int multibytep = coding->dst_multibyte; @@ -5377,8 +5330,7 @@ encode_coding_ccl (coding) /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ static void -decode_coding_raw_text (coding) - struct coding_system *coding; +decode_coding_raw_text (struct coding_system *coding) { int eol_crlf = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -5397,8 +5349,7 @@ decode_coding_raw_text (coding) } static int -encode_coding_raw_text (coding) - struct coding_system *coding; +encode_coding_raw_text (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -5481,9 +5432,8 @@ encode_coding_raw_text (coding) is, return 1, else return 0. */ static int -detect_coding_charset (coding, detect_info) - struct coding_system *coding; - struct coding_detection_info *detect_info; +detect_coding_charset (struct coding_system *coding, + struct coding_detection_info *detect_info) { const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -5585,8 +5535,7 @@ detect_coding_charset (coding, detect_info) } static void -decode_coding_charset (coding) - struct coding_system *coding; +decode_coding_charset (struct coding_system *coding) { const unsigned char *src = coding->source + coding->consumed; const unsigned char *src_end = coding->source + coding->src_bytes; @@ -5714,8 +5663,7 @@ decode_coding_charset (coding) } static int -encode_coding_charset (coding) - struct coding_system *coding; +encode_coding_charset (struct coding_system *coding) { int multibytep = coding->dst_multibyte; int *charbuf = coding->charbuf; @@ -5785,9 +5733,7 @@ encode_coding_charset (coding) CODING_SYSTEM is invalid, signal an error. */ void -setup_coding_system (coding_system, coding) - Lisp_Object coding_system; - struct coding_system *coding; +setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) { Lisp_Object attrs; Lisp_Object eol_type; @@ -5990,8 +5936,7 @@ setup_coding_system (coding_system, coding) /* Return a list of charsets supported by CODING. */ Lisp_Object -coding_charset_list (coding) - struct coding_system *coding; +coding_charset_list (struct coding_system *coding) { Lisp_Object attrs, charset_list; @@ -6014,8 +5959,7 @@ coding_charset_list (coding) /* Return a list of charsets supported by CODING-SYSTEM. */ Lisp_Object -coding_system_charset_list (coding_system) - Lisp_Object coding_system; +coding_system_charset_list (Lisp_Object coding_system) { int id; Lisp_Object attrs, charset_list; @@ -6048,8 +5992,7 @@ coding_system_charset_list (coding_system) eol_type as CODING-SYSTEM. */ Lisp_Object -raw_text_coding_system (coding_system) - Lisp_Object coding_system; +raw_text_coding_system (Lisp_Object coding_system) { Lisp_Object spec, attrs; Lisp_Object eol_type, raw_text_eol_type; @@ -6079,8 +6022,7 @@ raw_text_coding_system (coding_system) (system_eol_type). */ Lisp_Object -coding_inherit_eol_type (coding_system, parent) - Lisp_Object coding_system, parent; +coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent) { Lisp_Object spec, eol_type; @@ -6099,7 +6041,7 @@ coding_inherit_eol_type (coding_system, parent) parent_spec = CODING_SYSTEM_SPEC (parent); parent_eol_type = AREF (parent_spec, 2); if (VECTORP (parent_eol_type)) - parent_eol_type = system_eol_type; + parent_eol_type = system_eol_type; } else parent_eol_type = system_eol_type; @@ -6119,8 +6061,7 @@ coding_inherit_eol_type (coding_system, parent) return a new coding system. */ Lisp_Object -complement_process_encoding_system (coding_system) - Lisp_Object coding_system; +complement_process_encoding_system (Lisp_Object coding_system) { Lisp_Object coding_base = Qnil, eol_base = Qnil; Lisp_Object spec, attrs; @@ -6277,10 +6218,8 @@ complement_process_encoding_system (coding_system) #define MAX_EOL_CHECK_COUNT 3 static int -detect_eol (source, src_bytes, category) - const unsigned char *source; - EMACS_INT src_bytes; - enum coding_category category; +detect_eol (const unsigned char *source, EMACS_INT src_bytes, + enum coding_category category) { const unsigned char *src = source, *src_end = src + src_bytes; unsigned char c; @@ -6378,9 +6317,7 @@ detect_eol (source, src_bytes, category) static Lisp_Object -adjust_coding_eol_type (coding, eol_seen) - struct coding_system *coding; - int eol_seen; +adjust_coding_eol_type (struct coding_system *coding, int eol_seen) { Lisp_Object eol_type; @@ -6408,8 +6345,7 @@ adjust_coding_eol_type (coding, eol_seen) system. */ void -detect_coding (coding) - struct coding_system *coding; +detect_coding (struct coding_system *coding) { const unsigned char *src, *src_end; int saved_mode = coding->mode; @@ -6452,7 +6388,7 @@ detect_coding (coding) { /* We didn't find an 8-bit code. We may have found a null-byte, but it's very - rare that a binary file confirm to + rare that a binary file conforms to ISO-2022. */ src = src_end; coding->head_ascii = src - coding->source; @@ -6588,8 +6524,7 @@ detect_coding (coding) static void -decode_eol (coding) - struct coding_system *coding; +decode_eol (struct coding_system *coding) { Lisp_Object eol_type; unsigned char *p, *pbeg, *pend; @@ -6654,7 +6589,7 @@ decode_eol (coding) for (p = pend - 2; p >= pbeg; p--) if (*p == '\r') { - safe_bcopy ((char *) (p + 1), (char *) p, pend-- - p - 1); + memmove (p, p + 1, pend-- - p - 1); n++; } } @@ -6691,9 +6626,7 @@ decode_eol (coding) decoding (ENCODEP is zero). */ static Lisp_Object -get_translation_table (attrs, encodep, max_lookup) - Lisp_Object attrs; - int encodep, *max_lookup; +get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) { Lisp_Object standard, translation_table; Lisp_Object val; @@ -6795,9 +6728,7 @@ get_translation_table (attrs, encodep, max_lookup) If BUF is too short to lookup characters in FROM, return Qt. */ static Lisp_Object -get_translation (trans, buf, buf_end) - Lisp_Object trans; - int *buf, *buf_end; +get_translation (Lisp_Object trans, int *buf, int *buf_end) { if (INTEGERP (trans)) @@ -6824,10 +6755,8 @@ get_translation (trans, buf, buf_end) static int -produce_chars (coding, translation_table, last_block) - struct coding_system *coding; - Lisp_Object translation_table; - int last_block; +produce_chars (struct coding_system *coding, Lisp_Object translation_table, + int last_block) { unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; @@ -7025,10 +6954,7 @@ produce_chars (coding, translation_table, last_block) */ static INLINE void -produce_composition (coding, charbuf, pos) - struct coding_system *coding; - int *charbuf; - EMACS_INT pos; +produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) { int len; EMACS_INT to; @@ -7072,10 +6998,7 @@ produce_composition (coding, charbuf, pos) */ static INLINE void -produce_charset (coding, charbuf, pos) - struct coding_system *coding; - int *charbuf; - EMACS_INT pos; +produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) { EMACS_INT from = pos - charbuf[2]; struct charset *charset = CHARSET_FROM_ID (charbuf[3]); @@ -7110,9 +7033,7 @@ produce_charset (coding, charbuf, pos) static void -produce_annotation (coding, pos) - struct coding_system *coding; - EMACS_INT pos; +produce_annotation (struct coding_system *coding, EMACS_INT pos) { int *charbuf = coding->charbuf; int *charbuf_end = charbuf + coding->charbuf_used; @@ -7167,8 +7088,7 @@ produce_annotation (coding, pos) */ static int -decode_coding (coding) - struct coding_system *coding; +decode_coding (struct coding_system *coding) { Lisp_Object attrs; Lisp_Object undo_list; @@ -7306,11 +7226,9 @@ decode_coding (coding) return BUF. */ static INLINE int * -handle_composition_annotation (pos, limit, coding, buf, stop) - EMACS_INT pos, limit; - struct coding_system *coding; - int *buf; - EMACS_INT *stop; +handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, + struct coding_system *coding, int *buf, + EMACS_INT *stop) { EMACS_INT start, end; Lisp_Object prop; @@ -7391,11 +7309,9 @@ handle_composition_annotation (pos, limit, coding, buf, stop) property value is non-nil (limiting by LIMIT), and return BUF. */ static INLINE int * -handle_charset_annotation (pos, limit, coding, buf, stop) - EMACS_INT pos, limit; - struct coding_system *coding; - int *buf; - EMACS_INT *stop; +handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, + struct coding_system *coding, int *buf, + EMACS_INT *stop) { Lisp_Object val, next; int id; @@ -7415,10 +7331,8 @@ handle_charset_annotation (pos, limit, coding, buf, stop) static void -consume_chars (coding, translation_table, max_lookup) - struct coding_system *coding; - Lisp_Object translation_table; - int max_lookup; +consume_chars (struct coding_system *coding, Lisp_Object translation_table, + int max_lookup) { int *buf = coding->charbuf; int *buf_end = coding->charbuf + coding->charbuf_size; @@ -7574,8 +7488,7 @@ consume_chars (coding, translation_table, max_lookup) memory area specified by CODING->destination. */ static int -encode_coding (coding) - struct coding_system *coding; +encode_coding (struct coding_system *coding) { Lisp_Object attrs; Lisp_Object translation_table; @@ -7639,8 +7552,7 @@ static int reused_workbuf_in_use; multibyteness of returning buffer. */ static Lisp_Object -make_conversion_work_buffer (multibyte) - int multibyte; +make_conversion_work_buffer (int multibyte) { Lisp_Object name, workbuf; struct buffer *current; @@ -7672,8 +7584,7 @@ make_conversion_work_buffer (multibyte) static Lisp_Object -code_conversion_restore (arg) - Lisp_Object arg; +code_conversion_restore (Lisp_Object arg) { Lisp_Object current, workbuf; struct gcpro gcpro1; @@ -7694,8 +7605,7 @@ code_conversion_restore (arg) } Lisp_Object -code_conversion_save (with_work_buf, multibyte) - int with_work_buf, multibyte; +code_conversion_save (int with_work_buf, int multibyte) { Lisp_Object workbuf = Qnil; @@ -7707,11 +7617,10 @@ code_conversion_save (with_work_buf, multibyte) } int -decode_coding_gap (coding, chars, bytes) - struct coding_system *coding; - EMACS_INT chars, bytes; +decode_coding_gap (struct coding_system *coding, + EMACS_INT chars, EMACS_INT bytes) { - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); Lisp_Object attrs; code_conversion_save (0, 0); @@ -7754,11 +7663,10 @@ decode_coding_gap (coding, chars, bytes) } int -encode_coding_gap (coding, chars, bytes) - struct coding_system *coding; - EMACS_INT chars, bytes; +encode_coding_gap (struct coding_system *coding, + EMACS_INT chars, EMACS_INT bytes) { - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); code_conversion_save (0, 0); @@ -7809,14 +7717,13 @@ encode_coding_gap (coding, chars, bytes) */ void -decode_coding_object (coding, src_object, from, from_byte, to, to_byte, - dst_object) - struct coding_system *coding; - Lisp_Object src_object; - EMACS_INT from, from_byte, to, to_byte; - Lisp_Object dst_object; +decode_coding_object (struct coding_system *coding, + Lisp_Object src_object, + EMACS_INT from, EMACS_INT from_byte, + EMACS_INT to, EMACS_INT to_byte, + Lisp_Object dst_object) { - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); unsigned char *destination; EMACS_INT dst_bytes; EMACS_INT chars = to - from; @@ -7946,7 +7853,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte, } if (BEGV < GPT && GPT < BEGV + coding->produced_char) move_gap_both (BEGV, BEGV_BYTE); - bcopy (BEGV_ADDR, destination, coding->produced); + memcpy (destination, BEGV_ADDR, coding->produced); coding->destination = destination; } } @@ -8000,14 +7907,13 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte, void -encode_coding_object (coding, src_object, from, from_byte, to, to_byte, - dst_object) - struct coding_system *coding; - Lisp_Object src_object; - EMACS_INT from, from_byte, to, to_byte; - Lisp_Object dst_object; +encode_coding_object (struct coding_system *coding, + Lisp_Object src_object, + EMACS_INT from, EMACS_INT from_byte, + EMACS_INT to, EMACS_INT to_byte, + Lisp_Object dst_object) { - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); EMACS_INT chars = to - from; EMACS_INT bytes = to_byte - from_byte; Lisp_Object attrs; @@ -8209,7 +8115,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte, Lisp_Object -preferred_coding_system () +preferred_coding_system (void) { int id = coding_categories[coding_priorities[0]].id; @@ -8224,8 +8130,7 @@ DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0, doc: /* Return t if OBJECT is nil or a coding-system. See the documentation of `define-coding-system' for information about coding-system objects. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NILP (object) || CODING_SYSTEM_ID (object) >= 0) @@ -8239,8 +8144,7 @@ about coding-system objects. */) DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system, Sread_non_nil_coding_system, 1, 1, 0, doc: /* Read a coding system from the minibuffer, prompting with string PROMPT. */) - (prompt) - Lisp_Object prompt; + (Lisp_Object prompt) { Lisp_Object val; do @@ -8257,8 +8161,7 @@ DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0, If the user enters null input, return second argument DEFAULT-CODING-SYSTEM. Ignores case when completing coding systems (all Emacs coding systems are lower-case). */) - (prompt, default_coding_system) - Lisp_Object prompt, default_coding_system; + (Lisp_Object prompt, Lisp_Object default_coding_system) { Lisp_Object val; int count = SPECPDL_INDEX (); @@ -8279,8 +8182,7 @@ DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system, If valid, return CODING-SYSTEM, else signal a `coding-system-error' error. It is valid if it is nil or a symbol defined as a coding system by the function `define-coding-system'. */) - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { Lisp_Object define_form; @@ -8313,13 +8215,10 @@ function `define-coding-system'. */) detect only text-format. */ Lisp_Object -detect_coding_system (src, src_chars, src_bytes, highest, multibytep, - coding_system) - const unsigned char *src; - EMACS_INT src_chars, src_bytes; - int highest; - int multibytep; - Lisp_Object coding_system; +detect_coding_system (const unsigned char *src, + EMACS_INT src_chars, EMACS_INT src_bytes, + int highest, int multibytep, + Lisp_Object coding_system) { const unsigned char *src_end = src + src_bytes; Lisp_Object attrs, eol_type; @@ -8635,8 +8534,7 @@ format. If optional argument HIGHEST is non-nil, return the coding system of highest priority. */) - (start, end, highest) - Lisp_Object start, end, highest; + (Lisp_Object start, Lisp_Object end, Lisp_Object highest) { int from, to; int from_byte, to_byte; @@ -8674,8 +8572,7 @@ format. If optional argument HIGHEST is non-nil, return the coding system of highest priority. */) - (string, highest) - Lisp_Object string, highest; + (Lisp_Object string, Lisp_Object highest) { CHECK_STRING (string); @@ -8687,9 +8584,7 @@ highest priority. */) static INLINE int -char_encodable_p (c, attrs) - int c; - Lisp_Object attrs; +char_encodable_p (int c, Lisp_Object attrs) { Lisp_Object tail; struct charset *charset; @@ -8719,8 +8614,7 @@ DEFUN ("find-coding-systems-region-internal", Ffind_coding_systems_region_internal, Sfind_coding_systems_region_internal, 2, 3, 0, doc: /* Internal use only. */) - (start, end, exclude) - Lisp_Object start, end, exclude; + (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) { Lisp_Object coding_attrs_list, safe_codings; EMACS_INT start_byte, end_byte; @@ -8853,8 +8747,7 @@ list of positions. If optional 5th argument STRING is non-nil, it is a string to search for un-encodable characters. In that case, START and END are indexes to the string. */) - (start, end, coding_system, count, string) - Lisp_Object start, end, coding_system, count, string; + (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) { int n; struct coding_system coding; @@ -8969,8 +8862,7 @@ buffer positions. END is ignored. If the current buffer (or START if it is a string) is unibyte, the value is nil. */) - (start, end, coding_system_list) - Lisp_Object start, end, coding_system_list; + (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) { Lisp_Object list; EMACS_INT start_byte, end_byte; @@ -9075,9 +8967,9 @@ is nil. */) Lisp_Object -code_convert_region (start, end, coding_system, dst_object, encodep, norecord) - Lisp_Object start, end, coding_system, dst_object; - int encodep, norecord; +code_convert_region (Lisp_Object start, Lisp_Object end, + Lisp_Object coding_system, Lisp_Object dst_object, + int encodep, int norecord) { struct coding_system coding; EMACS_INT from, from_byte, to, to_byte; @@ -9136,8 +9028,7 @@ If DESTINATION is t, the decoded text is returned. This function sets `last-coding-system-used' to the precise coding system used (which may be different from CODING-SYSTEM if CODING-SYSTEM is not fully specified.) */) - (start, end, coding_system, destination) - Lisp_Object start, end, coding_system, destination; + (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination) { return code_convert_region (start, end, coding_system, destination, 0, 0); } @@ -9159,17 +9050,14 @@ If DESTINATION is t, the encoded text is returned. This function sets `last-coding-system-used' to the precise coding system used (which may be different from CODING-SYSTEM if CODING-SYSTEM is not fully specified.) */) - (start, end, coding_system, destination) - Lisp_Object start, end, coding_system, destination; + (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination) { return code_convert_region (start, end, coding_system, destination, 1, 0); } Lisp_Object -code_convert_string (string, coding_system, dst_object, - encodep, nocopy, norecord) - Lisp_Object string, coding_system, dst_object; - int encodep, nocopy, norecord; +code_convert_string (Lisp_Object string, Lisp_Object coding_system, + Lisp_Object dst_object, int encodep, int nocopy, int norecord) { struct coding_system coding; EMACS_INT chars, bytes; @@ -9216,9 +9104,8 @@ code_convert_string (string, coding_system, dst_object, ENCODE_FILE, thus we ignore character composition. */ Lisp_Object -code_convert_string_norecord (string, coding_system, encodep) - Lisp_Object string, coding_system; - int encodep; +code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, + int encodep) { return code_convert_string (string, coding_system, Qt, encodep, 0, 1); } @@ -9238,8 +9125,7 @@ case, the return value is the length of the decoded text. This function sets `last-coding-system-used' to the precise coding system used (which may be different from CODING-SYSTEM if CODING-SYSTEM is not fully specified.) */) - (string, coding_system, nocopy, buffer) - Lisp_Object string, coding_system, nocopy, buffer; + (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) { return code_convert_string (string, coding_system, buffer, 0, ! NILP (nocopy), 0); @@ -9259,8 +9145,7 @@ case, the return value is the length of the encoded text. This function sets `last-coding-system-used' to the precise coding system used (which may be different from CODING-SYSTEM if CODING-SYSTEM is not fully specified.) */) - (string, coding_system, nocopy, buffer) - Lisp_Object string, coding_system, nocopy, buffer; + (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer) { return code_convert_string (string, coding_system, buffer, 1, ! NILP (nocopy), 1); @@ -9270,8 +9155,7 @@ not fully specified.) */) DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, doc: /* Decode a Japanese character which has CODE in shift_jis encoding. Return the corresponding character. */) - (code) - Lisp_Object code; + (Lisp_Object code) { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_kanji, *charset_kana, *charset; @@ -9318,8 +9202,7 @@ Return the corresponding character. */) DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, doc: /* Encode a Japanese character CH to shift_jis encoding. Return the corresponding code in SJIS. */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { Lisp_Object spec, attrs, charset_list; int c; @@ -9347,8 +9230,7 @@ Return the corresponding code in SJIS. */) DEFUN ("decode-big5-char", Fdecode_big5_char, Sdecode_big5_char, 1, 1, 0, doc: /* Decode a Big5 character which has CODE in BIG5 coding system. Return the corresponding character. */) - (code) - Lisp_Object code; + (Lisp_Object code) { Lisp_Object spec, attrs, val; struct charset *charset_roman, *charset_big5, *charset; @@ -9386,8 +9268,7 @@ Return the corresponding character. */) DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0, doc: /* Encode the Big5 character CH to BIG5 coding system. Return the corresponding character code in Big5. */) - (ch) - Lisp_Object ch; + (Lisp_Object ch) { Lisp_Object spec, attrs, charset_list; struct charset *charset; @@ -9414,9 +9295,7 @@ Return the corresponding character code in Big5. */) DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal, Sset_terminal_coding_system_internal, 1, 2, 0, doc: /* Internal use only. */) - (coding_system, terminal) - Lisp_Object coding_system; - Lisp_Object terminal; + (Lisp_Object coding_system, Lisp_Object terminal) { struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); CHECK_SYMBOL (coding_system); @@ -9434,8 +9313,7 @@ DEFUN ("set-safe-terminal-coding-system-internal", Fset_safe_terminal_coding_system_internal, Sset_safe_terminal_coding_system_internal, 1, 1, 0, doc: /* Internal use only. */) - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { CHECK_SYMBOL (coding_system); setup_coding_system (Fcheck_coding_system (coding_system), @@ -9452,8 +9330,7 @@ DEFUN ("terminal-coding-system", Fterminal_coding_system, doc: /* Return coding system specified for terminal output on the given terminal. TERMINAL may be a terminal object, a frame, or nil for the selected frame's terminal device. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1)); @@ -9466,9 +9343,7 @@ frame's terminal device. */) DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal, Sset_keyboard_coding_system_internal, 1, 2, 0, doc: /* Internal use only. */) - (coding_system, terminal) - Lisp_Object coding_system; - Lisp_Object terminal; + (Lisp_Object coding_system, Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); CHECK_SYMBOL (coding_system); @@ -9486,8 +9361,7 @@ DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_intern DEFUN ("keyboard-coding-system", Fkeyboard_coding_system, Skeyboard_coding_system, 0, 1, 0, doc: /* Return coding system specified for decoding keyboard input. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING (get_terminal (terminal, 1))->id); @@ -9535,9 +9409,7 @@ function to call for FILENAME, that function should examine the contents of BUFFER instead of reading the file. usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object operation, target_idx, target, val; register Lisp_Object chain; @@ -9613,15 +9485,13 @@ If multiple coding systems belong to the same category, all but the first one are ignored. usage: (set-coding-system-priority &rest coding-systems) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { int i, j; int changed[coding_category_max]; enum coding_category priorities[coding_category_max]; - bzero (changed, sizeof changed); + memset (changed, 0, sizeof changed); for (i = j = 0; i < nargs; i++) { @@ -9656,7 +9526,7 @@ usage: (set-coding-system-priority &rest coding-systems) */) priorities[i] = coding_priorities[j]; } - bcopy (priorities, coding_priorities, sizeof priorities); + memcpy (coding_priorities, priorities, sizeof priorities); /* Update `coding-category-list'. */ Vcoding_category_list = Qnil; @@ -9675,8 +9545,7 @@ The list contains a subset of coding systems; i.e. coding systems assigned to each coding category (see `coding-category-list'). HIGHESTP non-nil means just return the highest priority one. */) - (highestp) - Lisp_Object highestp; + (Lisp_Object highestp) { int i; Lisp_Object val; @@ -9700,19 +9569,18 @@ HIGHESTP non-nil means just return the highest priority one. */) static const char *const suffixes[] = { "-unix", "-dos", "-mac" }; static Lisp_Object -make_subsidiaries (base) - Lisp_Object base; +make_subsidiaries (Lisp_Object base) { Lisp_Object subsidiaries; int base_name_len = SBYTES (SYMBOL_NAME (base)); char *buf = (char *) alloca (base_name_len + 6); int i; - bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); + memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); subsidiaries = Fmake_vector (make_number (3), Qnil); for (i = 0; i < 3; i++) { - bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); + memcpy (buf + base_name_len, suffixes[i], strlen (suffixes[i]) + 1); ASET (subsidiaries, i, intern (buf)); } return subsidiaries; @@ -9723,9 +9591,7 @@ DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, Sdefine_coding_system_internal, coding_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-coding-system-internal ...) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object name; Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ @@ -10254,8 +10120,7 @@ usage: (define-coding-system-internal ...) */) DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, 3, 3, 0, doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) - (coding_system, prop, val) - Lisp_Object coding_system, prop, val; + (Lisp_Object coding_system, Lisp_Object prop, Lisp_Object val) { Lisp_Object spec, attrs; @@ -10311,8 +10176,7 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, Sdefine_coding_system_alias, 2, 2, 0, doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) - (alias, coding_system) - Lisp_Object alias, coding_system; + (Lisp_Object alias, Lisp_Object coding_system) { Lisp_Object spec, aliases, eol_type, val; @@ -10352,8 +10216,7 @@ DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base, 1, 1, 0, doc: /* Return the base of CODING-SYSTEM. Any alias or subsidiary coding system is not a base coding system. */) - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { Lisp_Object spec, attrs; @@ -10367,8 +10230,7 @@ Any alias or subsidiary coding system is not a base coding system. */) DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, 1, 1, 0, doc: "Return the property list of CODING-SYSTEM.") - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { Lisp_Object spec, attrs; @@ -10383,8 +10245,7 @@ DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist, DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases, 1, 1, 0, doc: /* Return the list of aliases of CODING-SYSTEM. */) - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { Lisp_Object spec; @@ -10405,8 +10266,7 @@ and CR respectively. A vector value indicates that a format of end-of-line should be detected automatically. Nth element of the vector is the subsidiary coding system whose eol-type is N. */) - (coding_system) - Lisp_Object coding_system; + (Lisp_Object coding_system) { Lisp_Object spec, eol_type; int n; @@ -10429,7 +10289,7 @@ coding system whose eol-type is N. */) /*** 9. Post-amble ***/ void -init_coding_once () +init_coding_once (void) { int i; @@ -10471,7 +10331,7 @@ init_coding_once () #ifdef emacs void -syms_of_coding () +syms_of_coding (void) { staticpro (&Vcoding_system_hash_table); { @@ -11012,7 +10872,7 @@ character."); for (i = 0; i < coding_category_max; i++) Fset (AREF (Vcoding_category_table, i), Qno_conversion); } -#if defined (MSDOS) || defined (WINDOWSNT) +#if defined (DOS_NT) system_eol_type = Qdos; #else system_eol_type = Qunix; @@ -11021,8 +10881,7 @@ character."); } char * -emacs_strerror (error_number) - int error_number; +emacs_strerror (int error_number) { char *str; diff --git a/src/coding.h b/src/coding.h index 58d70644124..7233726a250 100644 --- a/src/coding.h +++ b/src/coding.h @@ -499,10 +499,10 @@ struct coding_system int default_char; - int (*detector) P_ ((struct coding_system *, - struct coding_detection_info *)); - void (*decoder) P_ ((struct coding_system *)); - int (*encoder) P_ ((struct coding_system *)); + int (*detector) (struct coding_system *, + struct coding_detection_info *); + void (*decoder) (struct coding_system *); + int (*encoder) (struct coding_system *); }; /* Meanings of bits in the member `common_flags' of the structure @@ -691,34 +691,34 @@ struct coding_system #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) /* Extern declarations. */ -extern Lisp_Object code_conversion_save P_ ((int, int)); -extern int decoding_buffer_size P_ ((struct coding_system *, int)); -extern int encoding_buffer_size P_ ((struct coding_system *, int)); -extern void setup_coding_system P_ ((Lisp_Object, struct coding_system *)); -extern Lisp_Object coding_charset_list P_ ((struct coding_system *)); -extern Lisp_Object coding_system_charset_list P_ ((Lisp_Object)); -extern void detect_coding P_ ((struct coding_system *)); -extern Lisp_Object code_convert_region P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - int, int)); -extern Lisp_Object code_convert_string P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, int, int, int)); -extern Lisp_Object code_convert_string_norecord P_ ((Lisp_Object, Lisp_Object, - int)); -extern Lisp_Object raw_text_coding_system P_ ((Lisp_Object)); -extern Lisp_Object coding_inherit_eol_type P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object complement_process_encoding_system P_ ((Lisp_Object)); - -extern int decode_coding_gap P_ ((struct coding_system *, - EMACS_INT, EMACS_INT)); -extern int encode_coding_gap P_ ((struct coding_system *, - EMACS_INT, EMACS_INT)); -extern void decode_coding_object P_ ((struct coding_system *, - Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, Lisp_Object)); -extern void encode_coding_object P_ ((struct coding_system *, - Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, Lisp_Object)); +extern Lisp_Object code_conversion_save (int, int); +extern int decoding_buffer_size (struct coding_system *, int); +extern int encoding_buffer_size (struct coding_system *, int); +extern void setup_coding_system (Lisp_Object, struct coding_system *); +extern Lisp_Object coding_charset_list (struct coding_system *); +extern Lisp_Object coding_system_charset_list (Lisp_Object); +extern void detect_coding (struct coding_system *); +extern Lisp_Object code_convert_region (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + int, int); +extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, + Lisp_Object, int, int, int); +extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, + int); +extern Lisp_Object raw_text_coding_system (Lisp_Object); +extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); +extern Lisp_Object complement_process_encoding_system (Lisp_Object); + +extern int decode_coding_gap (struct coding_system *, + EMACS_INT, EMACS_INT); +extern int encode_coding_gap (struct coding_system *, + EMACS_INT, EMACS_INT); +extern void decode_coding_object (struct coding_system *, + Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, Lisp_Object); +extern void encode_coding_object (struct coding_system *, + Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, Lisp_Object); /* Macros for backward compatibility. */ @@ -754,7 +754,7 @@ extern void encode_coding_object P_ ((struct coding_system *, } while (0) -extern Lisp_Object preferred_coding_system P_ (()); +extern Lisp_Object preferred_coding_system (void); extern Lisp_Object Qutf_8, Qutf_8_emacs; @@ -781,7 +781,7 @@ extern Lisp_Object Qcall_process, Qcall_process_region; extern Lisp_Object Qstart_process, Qopen_network_stream; extern Lisp_Object Qwrite_region; -extern char *emacs_strerror P_ ((int)); +extern char *emacs_strerror (int); /* Coding-system for reading files and receiving data from process. */ extern Lisp_Object Vcoding_system_for_read; @@ -803,6 +803,9 @@ extern struct coding_system safe_terminal_coding; /* Default coding systems used for process I/O. */ extern Lisp_Object Vdefault_process_coding_system; +/* Char table for translating Quail and self-inserting input. */ +extern Lisp_Object Vtranslation_table_for_input; + /* Function to call to force a user to force select a propert coding system. */ extern Lisp_Object Vselect_safe_coding_system_function; @@ -824,7 +827,7 @@ extern Lisp_Object Vdefault_file_name_coding_system; extern Lisp_Object Qcoding_system_error; extern char emacs_mule_bytes[256]; -extern int emacs_mule_string_char P_ ((unsigned char *)); +extern int emacs_mule_string_char (unsigned char *); #endif /* EMACS_CODING_H */ diff --git a/src/commands.h b/src/commands.h index 52136428eee..6b22da8ba15 100644 --- a/src/commands.h +++ b/src/commands.h @@ -74,7 +74,7 @@ extern Lisp_Object Vthis_command; extern Lisp_Object unread_switch_frame; /* The value of point when the last command was started. */ -extern int last_point_position; +extern EMACS_INT last_point_position; /* The buffer that was current when the last command was started. */ extern Lisp_Object last_point_position_buffer; diff --git a/src/composite.c b/src/composite.c index 1295a03e9f6..be9aafbeacc 100644 --- a/src/composite.c +++ b/src/composite.c @@ -74,8 +74,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ composition rules to tell how to compose (2N+2)th element with the previously composed 2N glyphs. - COMPONENTS-VEC -- Vector of integers. In relative composition, the - elements are characters to be composed. In rule-base + COMPONENTS-VEC -- Vector of integers. In a relative composition, + the elements are the characters to be composed. In a rule-base composition, the elements are characters or encoded composition rules. @@ -95,13 +95,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ get_composition_id checks the validity of `composition' property, and, if valid, assigns a new ID, registers the information in composition_hash_table and composition_table, and changes the form - of the property value. If the property is invalid, return -1 - without changing the property value. + of the property value. If the property is invalid, + get_composition_id returns -1 without changing the property value. - We use two tables to keep information about composition; + We use two tables to keep the information about composition; composition_hash_table and composition_table. - The former is a hash table in which keys are COMPONENTS-VECs and + The former is a hash table whose keys are COMPONENTS-VECs and values are the corresponding COMPOSITION-IDs. This hash table is weak, but as each key (COMPONENTS-VEC) is also kept as a value of the `composition' property, it won't be collected as garbage until all @@ -162,8 +162,8 @@ Lisp_Object Vauto_composition_function; Lisp_Object Qauto_composition_function; Lisp_Object Vcomposition_function_table; -/* Maxinum number of characters to lookback to check - auto-composition. */ +/* Maximum number of characters to look back for + auto-compositions. */ #define MAX_AUTO_COMPOSITION_LOOKBACK 3 EXFUN (Fremove_list_of_text_properties, 4); @@ -180,9 +180,8 @@ Lisp_Object composition_temp; If the composition is invalid, return -1. */ int -get_composition_id (charpos, bytepos, nchars, prop, string) - int charpos, bytepos, nchars; - Lisp_Object prop, string; +get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars, + Lisp_Object prop, Lisp_Object string) { Lisp_Object id, length, components, key, *key_contents; int glyph_len; @@ -190,7 +189,8 @@ get_composition_id (charpos, bytepos, nchars, prop, string) int hash_index; unsigned hash_code; struct composition *cmp; - int i, ch; + EMACS_INT i; + int ch; /* PROP should be Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC) @@ -292,7 +292,7 @@ get_composition_id (charpos, bytepos, nchars, prop, string) && VECTORP (AREF (components, 0))) { /* COMPONENTS is a glyph-string. */ - int len = ASIZE (key); + EMACS_UINT len = ASIZE (key); for (i = 1; i < len; i++) if (! VECTORP (AREF (key, i))) @@ -300,7 +300,7 @@ get_composition_id (charpos, bytepos, nchars, prop, string) } else if (VECTORP (components) || CONSP (components)) { - int len = XVECTOR (key)->size; + EMACS_UINT len = XVECTOR (key)->size; /* The number of elements should be odd. */ if ((len % 2) == 0) @@ -429,10 +429,9 @@ get_composition_id (charpos, bytepos, nchars, prop, string) This doesn't check the validity of composition. */ int -find_composition (pos, limit, start, end, prop, object) - int pos, limit; - EMACS_INT *start, *end; - Lisp_Object *prop, object; +find_composition (EMACS_INT pos, EMACS_INT limit, + EMACS_INT *start, EMACS_INT *end, + Lisp_Object *prop, Lisp_Object object) { Lisp_Object val; @@ -470,9 +469,7 @@ find_composition (pos, limit, start, end, prop, object) FROM and TO with property PROP. */ static void -run_composition_function (from, to, prop) - int from, to; - Lisp_Object prop; +run_composition_function (EMACS_INT from, EMACS_INT to, Lisp_Object prop) { Lisp_Object func; EMACS_INT start, end; @@ -504,9 +501,7 @@ run_composition_function (from, to, prop) change is deletion, FROM == TO. Otherwise, FROM < TO. */ void -update_compositions (from, to, check_mask) - EMACS_INT from, to; - int check_mask; +update_compositions (EMACS_INT from, EMACS_INT to, int check_mask) { Lisp_Object prop; EMACS_INT start, end; @@ -612,8 +607,7 @@ update_compositions (from, to, check_mask) top-level copies of them so that none of them are `eq'. */ void -make_composition_value_copy (list) - Lisp_Object list; +make_composition_value_copy (Lisp_Object list) { Lisp_Object plist, val; @@ -638,9 +632,8 @@ make_composition_value_copy (list) indices START and END in STRING. */ void -compose_text (start, end, components, modification_func, string) - int start, end; - Lisp_Object components, modification_func, string; +compose_text (EMACS_INT start, EMACS_INT end, Lisp_Object components, + Lisp_Object modification_func, Lisp_Object string) { Lisp_Object prop; @@ -651,9 +644,9 @@ compose_text (start, end, components, modification_func, string) } -static Lisp_Object autocmp_chars P_ ((Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, struct window *, - struct face *, Lisp_Object)); +static Lisp_Object autocmp_chars (Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, struct window *, + struct face *, Lisp_Object); /* Lisp glyph-string handlers */ @@ -664,11 +657,10 @@ static Lisp_Object autocmp_chars P_ ((Lisp_Object, EMACS_INT, EMACS_INT, static Lisp_Object gstring_hash_table; -static Lisp_Object gstring_lookup_cache P_ ((Lisp_Object)); +static Lisp_Object gstring_lookup_cache (Lisp_Object); static Lisp_Object -gstring_lookup_cache (header) - Lisp_Object header; +gstring_lookup_cache (Lisp_Object header) { struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); int i = hash_lookup (h, header, NULL); @@ -677,9 +669,7 @@ gstring_lookup_cache (header) } Lisp_Object -composition_gstring_put_cache (gstring, len) - Lisp_Object gstring; - int len; +composition_gstring_put_cache (Lisp_Object gstring, int len) { struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); unsigned hash; @@ -707,21 +697,19 @@ composition_gstring_put_cache (gstring, len) } Lisp_Object -composition_gstring_from_id (id) - int id; +composition_gstring_from_id (int id) { struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); return HASH_VALUE (h, id); } -static Lisp_Object fill_gstring_header P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - Lisp_Object)); +static Lisp_Object fill_gstring_header (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + Lisp_Object); int -composition_gstring_p (gstring) - Lisp_Object gstring; +composition_gstring_p (Lisp_Object gstring) { Lisp_Object header; int i; @@ -752,10 +740,8 @@ composition_gstring_p (gstring) } int -composition_gstring_width (gstring, from, to, metrics) - Lisp_Object gstring; - int from, to; - struct font_metrics *metrics; +composition_gstring_width (Lisp_Object gstring, EMACS_INT from, EMACS_INT to, + struct font_metrics *metrics) { Lisp_Object *glyph; int width = 0; @@ -811,8 +797,7 @@ static Lisp_Object gstring_work; static Lisp_Object gstring_work_headers; static Lisp_Object -fill_gstring_header (header, start, end, font_object, string) - Lisp_Object header, start, end, font_object, string; +fill_gstring_header (Lisp_Object header, Lisp_Object start, Lisp_Object end, Lisp_Object font_object, Lisp_Object string) { EMACS_INT from, to, from_byte; EMACS_INT len, i; @@ -869,11 +854,8 @@ fill_gstring_header (header, start, end, font_object, string) return header; } -extern void font_fill_lglyph_metrics P_ ((Lisp_Object, Lisp_Object)); - static void -fill_gstring_body (gstring) - Lisp_Object gstring; +fill_gstring_body (Lisp_Object gstring) { Lisp_Object font_object = LGSTRING_FONT (gstring); Lisp_Object header = AREF (gstring, 0); @@ -915,181 +897,317 @@ fill_gstring_body (gstring) } -/* Try to compose the characters at CHARPOS according to CFT_ELEMENT - which is an element of composition-function-table (which see). - LIMIT limits the characters to compose. STRING, if not nil, is a - target string. WIN is a window where the characters are being - displayed. */ +/* Try to compose the characters at CHARPOS according to composition + rule RULE ([PATTERN PREV-CHARS FUNC]). LIMIT limits the characters + to compose. STRING, if not nil, is a target string. WIN is a + window where the characters are being displayed. If characters are + successfully composed, return the composition as a glyph-string + object. Otherwise return nil. */ static Lisp_Object -autocmp_chars (cft_element, charpos, bytepos, limit, win, face, string) - Lisp_Object cft_element; - EMACS_INT charpos, bytepos, limit; - struct window *win; - struct face *face; - Lisp_Object string; +autocmp_chars (Lisp_Object rule, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT limit, struct window *win, struct face *face, Lisp_Object string) { int count = SPECPDL_INDEX (); FRAME_PTR f = XFRAME (win->frame); Lisp_Object pos = make_number (charpos); + EMACS_INT to; EMACS_INT pt = PT, pt_byte = PT_BYTE; - int lookback; + Lisp_Object re, font_object, lgstring; + EMACS_INT len; record_unwind_save_match_data (); - for (lookback = -1; CONSP (cft_element); cft_element = XCDR (cft_element)) + re = AREF (rule, 0); + if (NILP (re)) + len = 1; + else if (! STRINGP (re)) + return unbind_to (count, Qnil); + else if ((len = fast_looking_at (re, charpos, bytepos, limit, -1, string)) + > 0) { - Lisp_Object elt = XCAR (cft_element); - Lisp_Object re; - Lisp_Object font_object = Qnil, gstring; - EMACS_INT len, to; - - if (! VECTORP (elt) || ASIZE (elt) != 3) - continue; - if (lookback < 0) - { - lookback = XFASTINT (AREF (elt, 1)); - if (limit > charpos + MAX_COMPOSITION_COMPONENTS) - limit = charpos + MAX_COMPOSITION_COMPONENTS; - } - else if (lookback != XFASTINT (AREF (elt, 1))) - break; - re = AREF (elt, 0); - if (NILP (re)) - len = 1; - else if ((len = fast_looking_at (re, charpos, bytepos, limit, -1, string)) - > 0) - { - if (NILP (string)) - len = BYTE_TO_CHAR (bytepos + len) - charpos; - else - len = string_byte_to_char (string, bytepos + len) - charpos; - } - if (len > 0) - { - limit = to = charpos + len; + if (NILP (string)) + len = BYTE_TO_CHAR (bytepos + len) - charpos; + else + len = string_byte_to_char (string, bytepos + len) - charpos; + } + if (len <= 0) + return unbind_to (count, Qnil); + to = limit = charpos + len; #ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (f)) - { - font_object = font_range (charpos, &to, win, face, string); - if (! FONT_OBJECT_P (font_object) - || (! NILP (re) - && to < limit - && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0))) - { - if (NILP (string)) - TEMP_SET_PT_BOTH (pt, pt_byte); - return unbind_to (count, Qnil); - } - } - else + if (FRAME_WINDOW_P (f)) + { + font_object = font_range (charpos, &to, win, face, string); + if (! FONT_OBJECT_P (font_object) + || (! NILP (re) + && to < limit + && (fast_looking_at (re, charpos, bytepos, to, -1, string) <= 0))) + return unbind_to (count, Qnil); + } + else #endif /* not HAVE_WINDOW_SYSTEM */ - font_object = win->frame; - gstring = Fcomposition_get_gstring (pos, make_number (to), - font_object, string); - if (NILP (LGSTRING_ID (gstring))) - { - Lisp_Object args[6]; - - /* Save point as marker before calling out to lisp. */ - if (NILP (string)) - { - Lisp_Object m = Fmake_marker (); - set_marker_both (m, Qnil, pt, pt_byte); - record_unwind_protect (restore_point_unwind, m); - } + font_object = win->frame; + lgstring = Fcomposition_get_gstring (pos, make_number (to), font_object, + string); + if (NILP (LGSTRING_ID (lgstring))) + { + Lisp_Object args[6]; - args[0] = Vauto_composition_function; - args[1] = AREF (elt, 2); - args[2] = pos; - args[3] = make_number (to); - args[4] = font_object; - args[5] = string; - gstring = safe_call (6, args); - } - else if (NILP (string)) - { - TEMP_SET_PT_BOTH (pt, pt_byte); - } - return unbind_to (count, gstring); + /* Save point as marker before calling out to lisp. */ + if (NILP (string)) + { + Lisp_Object m = Fmake_marker (); + set_marker_both (m, Qnil, pt, pt_byte); + record_unwind_protect (restore_point_unwind, m); } + + args[0] = Vauto_composition_function; + args[1] = AREF (rule, 2); + args[2] = pos; + args[3] = make_number (to); + args[4] = font_object; + args[5] = string; + lgstring = safe_call (6, args); + if (NILP (string)) + TEMP_SET_PT_BOTH (pt, pt_byte); } - if (NILP (string)) - TEMP_SET_PT_BOTH (pt, pt_byte); - return unbind_to (count, Qnil); + return unbind_to (count, lgstring); } +static Lisp_Object _work_val; +static int _work_char; + +/* 1 iff the character C is composable. Characters of general + category Z? or C? are not composable except for ZWNJ and ZWJ. */ + +#define CHAR_COMPOSABLE_P(C) \ + ((C) == 0x200C || (C) == 0x200D \ + || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ + (SYMBOLP (_work_val) \ + && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \ + && _work_char != 'Z'))) /* Update cmp_it->stop_pos to the next position after CHARPOS (and BYTEPOS) where character composition may happen. If BYTEPOS is - negative, compoute it. If it is a static composition, set - cmp_it->ch to -1. Otherwise, set cmp_it->ch to the character that - triggers a automatic composition. */ + negative, compute it. ENDPOS is a limit of searching. If it is + less than CHARPOS, search backward to ENDPOS+1 assuming that + set_iterator_to_next works in reverse order. In this case, if a + composition closest to CHARPOS is found, set cmp_it->stop_pos to + the last character of the composition. + + If no composition is found, set cmp_it->ch to -2. If a static + composition is found, set cmp_it->ch to -1. Otherwise, set + cmp_it->ch to the character that triggers the automatic + composition. */ void -composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string) - struct composition_it *cmp_it; - EMACS_INT charpos, bytepos, endpos; - Lisp_Object string; +composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, Lisp_Object string) { EMACS_INT start, end, c; Lisp_Object prop, val; /* This is from forward_to_next_line_start in xdisp.c. */ const int MAX_NEWLINE_DISTANCE = 500; - if (endpos > charpos + MAX_NEWLINE_DISTANCE) - endpos = charpos + MAX_NEWLINE_DISTANCE; - cmp_it->stop_pos = endpos; + if (charpos < endpos) + { + if (endpos > charpos + MAX_NEWLINE_DISTANCE) + endpos = charpos + MAX_NEWLINE_DISTANCE; + } + else if (endpos < charpos) + { + /* We search backward for a position to check composition. */ + if (endpos < 0) + { + /* But we don't know where to stop the searching. */ + endpos = NILP (string) ? BEGV - 1 : -1; + /* Usually we don't reach ENDPOS because we stop searching + at an uncomposable character (NL, LRE, etc). */ + } + } cmp_it->id = -1; cmp_it->ch = -2; - if (find_composition (charpos, endpos, &start, &end, &prop, string) + cmp_it->reversed_p = 0; + cmp_it->stop_pos = endpos; + if (charpos == endpos) + return; + /* FIXME: Bidi is not yet handled well in static composition. */ + if (charpos < endpos + && find_composition (charpos, endpos, &start, &end, &prop, string) && COMPOSITION_VALID_P (start, end, prop)) { cmp_it->stop_pos = endpos = start; cmp_it->ch = -1; } - if (NILP (string) && PT > charpos && PT < endpos) - cmp_it->stop_pos = PT; if (NILP (current_buffer->enable_multibyte_characters) || NILP (Vauto_composition_mode)) return; if (bytepos < 0) { - if (STRINGP (string)) - bytepos = string_char_to_byte (string, charpos); - else + if (NILP (string)) bytepos = CHAR_TO_BYTE (charpos); + else + bytepos = string_char_to_byte (string, charpos); } start = charpos; - while (charpos < endpos) + if (charpos < endpos) { - if (STRINGP (string)) - FETCH_STRING_CHAR_ADVANCE (c, string, charpos, bytepos); - else - FETCH_CHAR_ADVANCE (c, charpos, bytepos); - if (c == '\n') + /* Forward search. */ + while (charpos < endpos) { - cmp_it->ch = -2; - break; + if (STRINGP (string)) + FETCH_STRING_CHAR_ADVANCE (c, string, charpos, bytepos); + else + FETCH_CHAR_ADVANCE (c, charpos, bytepos); + if (c == '\n') + { + cmp_it->ch = -2; + break; + } + val = CHAR_TABLE_REF (Vcomposition_function_table, c); + if (! NILP (val)) + { + Lisp_Object elt; + int ridx; + + for (ridx = 0; CONSP (val); val = XCDR (val), ridx++) + { + elt = XCAR (val); + if (VECTORP (elt) && ASIZE (elt) == 3 + && NATNUMP (AREF (elt, 1)) + && charpos - 1 - XFASTINT (AREF (elt, 1)) >= start) + break; + } + if (CONSP (val)) + { + cmp_it->rule_idx = ridx; + cmp_it->lookback = XFASTINT (AREF (elt, 1)); + cmp_it->stop_pos = charpos - 1 - cmp_it->lookback; + cmp_it->ch = c; + return; + } + } } - val = CHAR_TABLE_REF (Vcomposition_function_table, c); - if (! NILP (val)) + if (charpos == endpos) { - Lisp_Object elt; + /* We couldn't find a composition point before ENDPOS. But, + some character after ENDPOS may be composed with + characters before ENDPOS. So, we should stop at the safe + point. */ + charpos = endpos - MAX_AUTO_COMPOSITION_LOOKBACK; + if (charpos < start) + charpos = start; + } + } + else if (charpos > endpos) + { + /* Search backward for a pattern that may be composed and the + position of (possibly) the last character of the match is + closest to (but not after) START. The reason for the last + character is that set_iterator_to_next works in reverse order, + and thus we must stop at the last character for composition + check. */ + unsigned char *p; + int len; + /* Limit byte position used in fast_looking_at. This is the + byte position of the character after START. */ + EMACS_INT limit; - for (; CONSP (val); val = XCDR (val)) + if (NILP (string)) + p = BYTE_POS_ADDR (bytepos); + else + p = SDATA (string) + bytepos; + c = STRING_CHAR_AND_LENGTH (p, len); + limit = bytepos + len; + while (CHAR_COMPOSABLE_P (c)) + { + val = CHAR_TABLE_REF (Vcomposition_function_table, c); + if (! NILP (val)) { - elt = XCAR (val); - if (VECTORP (elt) && ASIZE (elt) == 3 && NATNUMP (AREF (elt, 1)) - && charpos - 1 - XFASTINT (AREF (elt, 1)) >= start) - break; + Lisp_Object elt; + int ridx, back, len; + + for (ridx = 0; CONSP (val); val = XCDR (val), ridx++) + { + elt = XCAR (val); + if (VECTORP (elt) && ASIZE (elt) == 3 + && NATNUMP (AREF (elt, 1)) + && charpos - (back = XFASTINT (AREF (elt, 1))) > endpos) + { + EMACS_INT cpos = charpos - back, bpos; + + if (back == 0) + bpos = bytepos; + else + bpos = (NILP (string) ? CHAR_TO_BYTE (cpos) + : string_char_to_byte (string, cpos)); + if (STRINGP (AREF (elt, 0))) + len = fast_looking_at (AREF (elt, 0), cpos, bpos, + start + 1, limit, string); + else + len = 1; + if (len > 0) + { + /* Make CPOS point to the last character of + match. Note that LEN is byte-length. */ + if (len > 1) + { + bpos += len; + if (NILP (string)) + cpos = BYTE_TO_CHAR (bpos) - 1; + else + cpos = string_byte_to_char (string, bpos) - 1; + } + back = cpos - (charpos - back); + if (cmp_it->stop_pos < cpos + || (cmp_it->stop_pos == cpos + && cmp_it->lookback < back)) + { + cmp_it->rule_idx = ridx; + cmp_it->stop_pos = cpos; + cmp_it->ch = c; + cmp_it->lookback = back; + cmp_it->nchars = back + 1; + } + } + } + } + } + if (charpos - 1 == endpos) + break; + if (STRINGP (string)) + { + p--, bytepos--; + while (! CHAR_HEAD_P (*p)) + p--, bytepos--; + charpos--; + } + else + { + DEC_BOTH (charpos, bytepos); + p = BYTE_POS_ADDR (bytepos); + } + c = STRING_CHAR (p); + } + if (cmp_it->ch >= 0) + /* We found a position to check. */ + return; + /* Skip all uncomposable characters. */ + if (NILP (string)) + { + while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) + { + DEC_BOTH (charpos, bytepos); + c = FETCH_MULTIBYTE_CHAR (bytepos); } - if (CONSP (val)) + } + else + { + while (charpos - 1 > endpos && ! CHAR_COMPOSABLE_P (c)) { - cmp_it->lookback = XFASTINT (AREF (elt, 1)); - cmp_it->stop_pos = charpos - 1 - cmp_it->lookback; - cmp_it->ch = c; - return; + p--; + while (! CHAR_HEAD_P (*p)) + p--; + charpos--; + c = STRING_CHAR (p); } } } @@ -1104,24 +1222,20 @@ composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string) string. In that case, FACE must not be NULL. If the character is composed, setup members of CMP_IT (id, nglyphs, - and from), and return 1. Otherwise, update CMP_IT->stop_pos, and - return 0. */ + from, to, reversed_p), and return 1. Otherwise, update + CMP_IT->stop_pos, and return 0. */ int -composition_reseat_it (cmp_it, charpos, bytepos, endpos, w, face, string) - struct composition_it *cmp_it; - EMACS_INT charpos, bytepos, endpos; - struct window *w; - struct face *face; - Lisp_Object string; +composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, struct window *w, struct face *face, Lisp_Object string) { - if (NILP (string) && charpos < PT && PT < endpos) - endpos = PT; + if (endpos < 0) + endpos = NILP (string) ? BEGV : 0; if (cmp_it->ch == -2) { composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); - if (cmp_it->ch == -2) + if (cmp_it->ch == -2 || cmp_it->stop_pos != charpos) + /* The current position is not composed. */ return 0; } @@ -1141,57 +1255,131 @@ composition_reseat_it (cmp_it, charpos, bytepos, endpos, w, face, string) } else if (w) { - Lisp_Object val, elt; - int i; + Lisp_Object lgstring = Qnil; + Lisp_Object val, elt, re; + int len, i; val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); - for (; CONSP (val); val = XCDR (val)) + for (i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)); + if (charpos < endpos) { - elt = XCAR (val); - if (cmp_it->lookback == XFASTINT (AREF (elt, 1))) - break; + for (; CONSP (val); val = XCDR (val)) + { + elt = XCAR (val); + if (! VECTORP (elt) || ASIZE (elt) != 3 + || ! INTEGERP (AREF (elt, 1))) + continue; + if (XFASTINT (AREF (elt, 1)) != cmp_it->lookback) + goto no_composition; + lgstring = autocmp_chars (elt, charpos, bytepos, endpos, + w, face, string); + if (composition_gstring_p (lgstring)) + break; + lgstring = Qnil; + /* Composition failed perhaps because the font doesn't + support sufficient range of characters. Try the + other composition rules if any. */ + } + cmp_it->reversed_p = 0; } - if (NILP (val)) - goto no_composition; + else + { + EMACS_INT cpos = charpos, bpos = bytepos; - val = autocmp_chars (val, charpos, bytepos, endpos, w, face, string); - if (! composition_gstring_p (val)) + while (1) + { + elt = XCAR (val); + if (cmp_it->lookback > 0) + { + cpos = charpos - cmp_it->lookback; + if (STRINGP (string)) + bpos = string_char_to_byte (string, cpos); + else + bpos = CHAR_TO_BYTE (cpos); + } + lgstring = autocmp_chars (elt, cpos, bpos, charpos + 1, w, face, + string); + if (composition_gstring_p (lgstring) + && cpos + LGSTRING_CHAR_LEN (lgstring) - 1 == charpos) + break; + /* Composition failed or didn't cover the current + character. */ + if (cmp_it->lookback == 0) + goto no_composition; + lgstring = Qnil; + /* Try to find a shorter compostion that starts after CPOS. */ + composition_compute_stop_pos (cmp_it, charpos, bytepos, cpos, + string); + if (cmp_it->ch == -2 || cmp_it->stop_pos < charpos) + goto no_composition; + val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); + for (i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)); + } + cmp_it->reversed_p = 1; + } + if (NILP (lgstring)) goto no_composition; - if (NILP (LGSTRING_ID (val))) - val = composition_gstring_put_cache (val, -1); - cmp_it->id = XINT (LGSTRING_ID (val)); - for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++) - if (NILP (LGSTRING_GLYPH (val, i))) + if (NILP (LGSTRING_ID (lgstring))) + lgstring = composition_gstring_put_cache (lgstring, -1); + cmp_it->id = XINT (LGSTRING_ID (lgstring)); + for (i = 0; i < LGSTRING_GLYPH_LEN (lgstring); i++) + if (NILP (LGSTRING_GLYPH (lgstring, i))) break; cmp_it->nglyphs = i; + cmp_it->from = 0; + cmp_it->to = i; } else goto no_composition; - cmp_it->from = 0; return 1; no_composition: - charpos++; - if (STRINGP (string)) - bytepos += MULTIBYTE_LENGTH_NO_CHECK (SDATA (string) + bytepos); + if (charpos == endpos) + return 0; + if (charpos < endpos) + { + charpos++; + if (NILP (string)) + INC_POS (bytepos); + else + bytepos += BYTES_BY_CHAR_HEAD (*(SDATA (string) + bytepos)); + } else - INC_POS (bytepos); + { + charpos--; + /* BYTEPOS is calculated in composition_compute_stop_pos */ + bytepos = -1; + } composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string); return 0; } +/* Update charpos, nchars, nbytes, and width of the current grapheme + cluster. + + If the composition is static or automatic in L2R context, the + cluster is identified by CMP_IT->from, and CHARPOS is the position + of the first character of the cluster. In this case, update + CMP_IT->to too. + + If the composition is automatic in R2L context, the cluster is + identified by CMP_IT->to, and CHARPOS is the position of the last + character of the cluster. In this case, update CMP_IT->from too. + + The return value is the character code of the first character of + the cluster, or -1 if the composition is somehow broken. */ + int -composition_update_it (cmp_it, charpos, bytepos, string) - struct composition_it *cmp_it; - EMACS_INT charpos, bytepos; - Lisp_Object string; +composition_update_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, Lisp_Object string) { int i, c; if (cmp_it->ch < 0) { + /* static composition */ struct composition *cmp = composition_table[cmp_it->id]; + cmp_it->charpos = charpos; cmp_it->to = cmp_it->nglyphs; if (cmp_it->nglyphs == 0) c = -1; @@ -1204,43 +1392,63 @@ composition_update_it (cmp_it, charpos, bytepos, string) c = ' '; } cmp_it->width = cmp->width; + charpos += cmp_it->nchars; + if (STRINGP (string)) + cmp_it->nbytes = string_char_to_byte (string, charpos) - bytepos; + else + cmp_it->nbytes = CHAR_TO_BYTE (charpos) - bytepos; } else { + /* automatic composition */ Lisp_Object gstring = composition_gstring_from_id (cmp_it->id); + Lisp_Object glyph; + EMACS_INT from; if (cmp_it->nglyphs == 0) { - c = -1; cmp_it->nchars = LGSTRING_CHAR_LEN (gstring); cmp_it->width = 0; + cmp_it->from = cmp_it->to = 0; + return -1; } - else + if (! cmp_it->reversed_p) { - Lisp_Object glyph = LGSTRING_GLYPH (gstring, cmp_it->from); - int from = LGLYPH_FROM (glyph); - - c = XINT (LGSTRING_CHAR (gstring, from)); - cmp_it->nchars = LGLYPH_TO (glyph) - from + 1; - cmp_it->width = (LGLYPH_WIDTH (glyph) > 0 - ? CHAR_WIDTH (LGLYPH_CHAR (glyph)) : 0); + glyph = LGSTRING_GLYPH (gstring, cmp_it->from); + from = LGLYPH_FROM (glyph); for (cmp_it->to = cmp_it->from + 1; cmp_it->to < cmp_it->nglyphs; cmp_it->to++) { glyph = LGSTRING_GLYPH (gstring, cmp_it->to); if (LGLYPH_FROM (glyph) != from) break; - if (LGLYPH_WIDTH (glyph) > 0) - cmp_it->width += CHAR_WIDTH (LGLYPH_CHAR (glyph)); } + cmp_it->charpos = charpos; + } + else + { + glyph = LGSTRING_GLYPH (gstring, cmp_it->to - 1); + from = LGLYPH_FROM (glyph); + cmp_it->charpos = charpos - (LGLYPH_TO (glyph) - from); + for (cmp_it->from = cmp_it->to - 1; cmp_it->from > 0; + cmp_it->from--) + { + glyph = LGSTRING_GLYPH (gstring, cmp_it->from - 1); + if (LGLYPH_FROM (glyph) != from) + break; + } + } + glyph = LGSTRING_GLYPH (gstring, cmp_it->from); + cmp_it->nchars = LGLYPH_TO (glyph) + 1 - from; + cmp_it->nbytes = 0; + cmp_it->width = 0; + for (i = cmp_it->nchars - 1; i >= 0; i--) + { + c = XINT (LGSTRING_CHAR (gstring, i)); + cmp_it->nbytes += CHAR_BYTES (c); + cmp_it->width += CHAR_WIDTH (c); } } - - charpos += cmp_it->nchars; - if (STRINGP (string)) - cmp_it->nbytes = string_char_to_byte (string, charpos) - bytepos; - else - cmp_it->nbytes = CHAR_TO_BYTE (charpos) - bytepos; return c; } @@ -1251,7 +1459,7 @@ struct position_record unsigned char *p; }; -/* Update the members of POSTION to the next character boundary. */ +/* Update the members of POSITION to the next character boundary. */ #define FORWARD_CHAR(POSITION, STOP) \ do { \ (POSITION).pos++; \ @@ -1267,7 +1475,7 @@ struct position_record } \ } while (0) -/* Update the members of POSTION to the previous character boundary. */ +/* Update the members of POSITION to the previous character boundary. */ #define BACKWARD_CHAR(POSITION, STOP) \ do { \ if ((POSITION).pos == STOP) \ @@ -1279,25 +1487,12 @@ struct position_record (POSITION).pos--; \ } while (0) -static Lisp_Object _work_val; -static int _work_char; - -/* 1 iff the character C is composable. */ -#define CHAR_COMPOSABLE_P(C) \ - ((C) == 0x200C || (C) == 0x200D \ - || (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \ - (SYMBOLP (_work_val) \ - && (_work_char = SDATA (SYMBOL_NAME (_work_val))[0]) != 'C' \ - && _work_char != 'Z'))) - /* This is like find_composition, but find an automatic composition instead. If found, set *GSTRING to the glyph-string representing the composition, and return 1. Otherwise, return 0. */ static int -find_automatic_composition (pos, limit, start, end, gstring, string) - EMACS_INT pos, limit, *start, *end; - Lisp_Object *gstring, string; +find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EMACS_INT *end, Lisp_Object *gstring, Lisp_Object string) { EMACS_INT head, tail, stop; /* Limit to check a composition after POS. */ @@ -1420,7 +1615,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string) check.pos_byte = cur.pos_byte; else check.pos_byte = CHAR_TO_BYTE (check.pos); - val = autocmp_chars (check_val, check.pos, check.pos_byte, + val = autocmp_chars (elt, check.pos, check.pos_byte, tail, w, NULL, string); need_adjustment = 1; if (! NILP (val)) @@ -1439,7 +1634,7 @@ find_automatic_composition (pos, limit, start, end, gstring, string) } if (need_adjustment) { - /* As we have called Lisp, there's a possibilily that + /* As we have called Lisp, there's a possibility that buffer/string is relocated. */ if (NILP (string)) cur.p = BYTE_POS_ADDR (cur.pos_byte); @@ -1467,9 +1662,8 @@ find_automatic_composition (pos, limit, start, end, gstring, string) /* Return the adjusted point provided that point is moved from LAST_PT to NEW_PT. */ -int -composition_adjust_point (last_pt, new_pt) - EMACS_INT last_pt, new_pt; +EMACS_INT +composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt) { EMACS_INT charpos, bytepos, startpos, beg, end, pos; Lisp_Object val; @@ -1551,16 +1745,13 @@ where If GLYPH is nil, the remaining elements of the glyph-string vector should be ignored. */) - (from, to, font_object, string) - Lisp_Object font_object, from, to, string; + (Lisp_Object from, Lisp_Object to, Lisp_Object font_object, Lisp_Object string) { Lisp_Object gstring, header; EMACS_INT frompos, topos; CHECK_NATNUM (from); CHECK_NATNUM (to); - if (XINT (to) > XINT (from) + MAX_COMPOSITION_COMPONENTS) - to = make_number (XINT (from) + MAX_COMPOSITION_COMPONENTS); if (! FONT_OBJECT_P (font_object)) { struct coding_system *coding; @@ -1597,8 +1788,7 @@ DEFUN ("compose-region-internal", Fcompose_region_internal, Compose text in the region between START and END. Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC for the composition. See `compose-region' for more details. */) - (start, end, components, modification_func) - Lisp_Object start, end, components, modification_func; + (Lisp_Object start, Lisp_Object end, Lisp_Object components, Lisp_Object modification_func) { validate_region (&start, &end); if (!NILP (components) @@ -1618,8 +1808,7 @@ DEFUN ("compose-string-internal", Fcompose_string_internal, Compose text between indices START and END of STRING. Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC for the composition. See `compose-string' for more details. */) - (string, start, end, components, modification_func) - Lisp_Object string, start, end, components, modification_func; + (Lisp_Object string, Lisp_Object start, Lisp_Object end, Lisp_Object components, Lisp_Object modification_func) { CHECK_STRING (string); CHECK_NUMBER (start); @@ -1640,8 +1829,7 @@ DEFUN ("find-composition-internal", Ffind_composition_internal, Return information about composition at or nearest to position POS. See `find-composition' for more details. */) - (pos, limit, string, detail_p) - Lisp_Object pos, limit, string, detail_p; + (Lisp_Object pos, Lisp_Object limit, Lisp_Object string, Lisp_Object detail_p) { Lisp_Object prop, tail, gstring; EMACS_INT start, end, from, to; @@ -1684,7 +1872,7 @@ See `find-composition' for more details. */) if (find_automatic_composition (from, to, &s, &e, &gstring, string) && (e <= XINT (pos) ? e > end : s < start)) - return list3 (make_number (start), make_number (end), gstring); + return list3 (make_number (s), make_number (e), gstring); } if (!COMPOSITION_VALID_P (start, end, prop)) return Fcons (make_number (start), Fcons (make_number (end), @@ -1697,9 +1885,9 @@ See `find-composition' for more details. */) id = COMPOSITION_ID (prop); else { - int start_byte = (NILP (string) - ? CHAR_TO_BYTE (start) - : string_char_to_byte (string, start)); + EMACS_INT start_byte = (NILP (string) + ? CHAR_TO_BYTE (start) + : string_char_to_byte (string, start)); id = get_composition_id (start, start_byte, end - start, prop, string); } @@ -1726,7 +1914,7 @@ See `find-composition' for more details. */) void -syms_of_composite () +syms_of_composite (void) { int i; @@ -1736,7 +1924,6 @@ syms_of_composite () /* Make a hash table for static composition. */ { Lisp_Object args[6]; - extern Lisp_Object QCsize; args[0] = QCtest; args[1] = Qequal; @@ -1756,8 +1943,6 @@ syms_of_composite () /* Make a hash table for glyph-string. */ { Lisp_Object args[6]; - extern Lisp_Object QCsize; - args[0] = QCtest; args[1] = Qequal; args[2] = QCweakness; @@ -1824,7 +2009,7 @@ preceding and/or following characters, this char-table contains a function to call to compose that character. The element at index C in the table, if non-nil, is a list of -this form: ([PATTERN PREV-CHARS FUNC] ...) +composition rules of this form: ([PATTERN PREV-CHARS FUNC] ...) PATTERN is a regular expression which C and the surrounding characters must match. diff --git a/src/composite.h b/src/composite.h index 59c237c8de2..5c8ade39596 100644 --- a/src/composite.h +++ b/src/composite.h @@ -212,16 +212,17 @@ extern Lisp_Object Vauto_composition_function; extern Lisp_Object Qauto_composition_function; extern Lisp_Object Vcomposition_function_table; -extern int get_composition_id P_ ((int, int, int, Lisp_Object, Lisp_Object)); -extern int find_composition P_ ((int, int, EMACS_INT *, EMACS_INT *, Lisp_Object *, - Lisp_Object)); -extern void update_compositions P_ ((EMACS_INT, EMACS_INT, int)); -extern void make_composition_value_copy P_ ((Lisp_Object)); -extern void compose_region P_ ((int, int, Lisp_Object, Lisp_Object, - Lisp_Object)); -extern void syms_of_composite P_ ((void)); -extern void compose_text P_ ((int, int, Lisp_Object, Lisp_Object, - Lisp_Object)); +extern int get_composition_id (EMACS_INT, EMACS_INT, EMACS_INT, + Lisp_Object, Lisp_Object); +extern int find_composition (EMACS_INT, EMACS_INT, EMACS_INT *, EMACS_INT *, + Lisp_Object *, Lisp_Object); +extern void update_compositions (EMACS_INT, EMACS_INT, int); +extern void make_composition_value_copy (Lisp_Object); +extern void compose_region (int, int, Lisp_Object, Lisp_Object, + Lisp_Object); +extern void syms_of_composite (void); +extern void compose_text (EMACS_INT, EMACS_INT, Lisp_Object, Lisp_Object, + Lisp_Object); /* Macros for lispy glyph-string. This is completely different from struct glyph_string. */ @@ -303,23 +304,23 @@ struct composition_it; struct face; struct font_metrics; -extern Lisp_Object composition_gstring_put_cache P_ ((Lisp_Object, int)); -extern Lisp_Object composition_gstring_from_id P_ ((int)); -extern int composition_gstring_p P_ ((Lisp_Object)); -extern int composition_gstring_width P_ ((Lisp_Object, int, int, - struct font_metrics *)); - -extern void composition_compute_stop_pos P_ ((struct composition_it *, - EMACS_INT, EMACS_INT, EMACS_INT, - Lisp_Object)); -extern int composition_reseat_it P_ ((struct composition_it *, - EMACS_INT, EMACS_INT, EMACS_INT, - struct window *, struct face *, - Lisp_Object)); -extern int composition_update_it P_ ((struct composition_it *, - EMACS_INT, EMACS_INT, Lisp_Object)); - -extern int composition_adjust_point P_ ((EMACS_INT, EMACS_INT)); +extern Lisp_Object composition_gstring_put_cache (Lisp_Object, int); +extern Lisp_Object composition_gstring_from_id (int); +extern int composition_gstring_p (Lisp_Object); +extern int composition_gstring_width (Lisp_Object, EMACS_INT, EMACS_INT, + struct font_metrics *); + +extern void composition_compute_stop_pos (struct composition_it *, + EMACS_INT, EMACS_INT, EMACS_INT, + Lisp_Object); +extern int composition_reseat_it (struct composition_it *, + EMACS_INT, EMACS_INT, EMACS_INT, + struct window *, struct face *, + Lisp_Object); +extern int composition_update_it (struct composition_it *, + EMACS_INT, EMACS_INT, Lisp_Object); + +extern EMACS_INT composition_adjust_point (EMACS_INT, EMACS_INT); EXFUN (Fcompose_region_internal, 4); EXFUN (Fcompose_string_internal, 5); diff --git a/src/config.in b/src/config.in index 4667c0feb28..add2ac73d55 100644 --- a/src/config.in +++ b/src/config.in @@ -27,12 +27,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define EMACS_CONFIG_H -/* Generate dependencies with gcc. */ -#undef AUTO_DEPEND +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if the mktime function is broken. */ #undef BROKEN_MKTIME +/* Define if Emacs cannot be dumped on your system. */ +#undef CANNOT_DUMP + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -44,12 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if using `getloadavg.c'. */ #undef C_GETLOADAVG -/* Define C_SWITCH_X_SITE to contain any special flags your compiler may need - to deal with X Windows. For instance, if you've defined HAVE_X_WINDOWS - above and your X include files aren't in a place that your compiler can - find on its own, you might want to add "-I/..." or something similar. */ -#undef C_SWITCH_X_SITE - /* Define to 1 for DGUX with <sys/dg_sys_info.h>. */ #undef DGUX @@ -108,15 +105,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if ALSA is available. */ #undef HAVE_ALSA -/* Define to 1 if you have the `bcmp' function. */ -#undef HAVE_BCMP - -/* Define to 1 if you have the `bcopy' function. */ -#undef HAVE_BCOPY - -/* Define to 1 if you have the `bzero' function. */ -#undef HAVE_BZERO - /* Define to 1 if you have the `cbrt' function. */ #undef HAVE_CBRT @@ -135,8 +123,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <com_err.h> header file. */ #undef HAVE_COM_ERR_H -/* Define to 1 if you have /usr/lib/crti.o. */ -#undef HAVE_CRTIN +/* Define to 1 if you have the `copysign' function. */ +#undef HAVE_COPYSIGN /* Define to 1 if using D-Bus. */ #undef HAVE_DBUS @@ -165,6 +153,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the `difftime' function. */ #undef HAVE_DIFFTIME +/* Define to 1 if you have the <dirent.h> header file. */ +#undef HAVE_DIRENT_H + /* Define to 1 if you have the `dup2' function. */ #undef HAVE_DUP2 @@ -204,9 +195,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if using GConf. */ #undef HAVE_GCONF -/* Define to 1 if you have the `gdk_display_open' function. */ -#undef HAVE_GDK_DISPLAY_OPEN - /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO @@ -264,24 +252,26 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the `get_current_dir_name' function. */ #undef HAVE_GET_CURRENT_DIR_NAME -/* Define to 1 if you have a gif library (default -lgif; otherwise specify - with LIBGIF). */ +/* Define to 1 if you have a gif (or ungif) library. */ #undef HAVE_GIF +/* Define if using GnuTLS. */ +#undef HAVE_GNUTLS + /* Define to 1 if you have the gpm library (-lgpm). */ #undef HAVE_GPM /* Define to 1 if you have the `grantpt' function. */ #undef HAVE_GRANTPT +/* Define to 1 if you have the `gtk_adjustment_get_page_size' function. */ +#undef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE + /* Define to 1 if you have GTK and pthread (-lpthread). */ #undef HAVE_GTK_AND_PTHREAD -/* Define to 1 if GTK has both file selection and chooser dialog. */ -#undef HAVE_GTK_FILE_BOTH - -/* Define to 1 if you have the `gtk_file_chooser_dialog_new' function. */ -#undef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW +/* Define to 1 if you have the `gtk_dialog_get_action_area' function. */ +#undef HAVE_GTK_DIALOG_GET_ACTION_AREA /* Define to 1 if you have the `gtk_file_selection_new' function. */ #undef HAVE_GTK_FILE_SELECTION_NEW @@ -289,14 +279,26 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the `gtk_main' function. */ #undef HAVE_GTK_MAIN -/* Define to 1 if GTK can handle more than one display. */ -#undef HAVE_GTK_MULTIDISPLAY +/* Define to 1 if you have the `gtk_orientable_set_orientation' function. */ +#undef HAVE_GTK_ORIENTABLE_SET_ORIENTATION + +/* Define to 1 if you have the `gtk_widget_get_mapped' function. */ +#undef HAVE_GTK_WIDGET_GET_MAPPED + +/* Define to 1 if you have the `gtk_widget_get_sensitive' function. */ +#undef HAVE_GTK_WIDGET_GET_SENSITIVE + +/* Define to 1 if you have the `gtk_widget_get_window' function. */ +#undef HAVE_GTK_WIDGET_GET_WINDOW + +/* Define to 1 if you have the `gtk_widget_set_has_window' function. */ +#undef HAVE_GTK_WIDGET_SET_HAS_WINDOW /* Define to 1 if netdb.h declares h_errno. */ #undef HAVE_H_ERRNO -/* Define to 1 if you have the `index' function. */ -#undef HAVE_INDEX +/* Define to 1 if using imagemagick. */ +#undef HAVE_IMAGEMAGICK /* Define to 1 if you have inet sockets. */ #undef HAVE_INET_SOCKETS @@ -304,6 +306,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `isnan' function. */ +#undef HAVE_ISNAN + /* Define to 1 if you have the jpeg library (-ljpeg). */ #undef HAVE_JPEG @@ -334,9 +339,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET -/* Define to 1 if the directory /usr/lib64 exists. */ -#undef HAVE_LIB64_DIR - /* Define to 1 if you have the `com_err' library (-lcom_err). */ #undef HAVE_LIBCOM_ERR @@ -400,15 +402,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the resolv library (-lresolv). */ #undef HAVE_LIBRESOLV +/* Define to 1 if using SELinux. */ +#undef HAVE_LIBSELINUX + /* Define to 1 if you have the `Xext' library (-lXext). */ #undef HAVE_LIBXEXT +/* Define to 1 if you have the libxml library (-lxml2). */ +#undef HAVE_LIBXML2 + /* Define to 1 if you have the `Xmu' library (-lXmu). */ #undef HAVE_LIBXMU -/* Define to 1 if you have the Xp library (-lXp). */ -#undef HAVE_LIBXP - /* Define to 1 if you have the <limits.h> header file. */ #undef HAVE_LIMITS_H @@ -436,6 +441,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <mach/mach.h> header file. */ #undef HAVE_MACH_MACH_H +/* Define to 1 if you have the `MagickExportImagePixels' function. */ +#undef HAVE_MAGICKEXPORTIMAGEPIXELS + /* Define to 1 if you have the <maillock.h> header file. */ #undef HAVE_MAILLOCK_H @@ -489,8 +497,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP -/* Define to 1 if you have Motif 2.1 or newer. */ -#undef HAVE_MOTIF_2_1 +/* Define if you have mouse support. */ +#undef HAVE_MOUSE /* Define to 1 if you have the `mremap' function. */ #undef HAVE_MREMAP @@ -544,9 +552,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if res_init is available. */ #undef HAVE_RES_INIT -/* Define to 1 if you have the `rindex' function. */ -#undef HAVE_RINDEX - /* Define to 1 if you have the `rint' function. */ #undef HAVE_RINT @@ -586,6 +591,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if the system has the type `size_t'. */ #undef HAVE_SIZE_T +/* Define to 1 if you have sound support. */ +#undef HAVE_SOUND + /* Define to 1 if you have the <soundcard.h> header file. */ #undef HAVE_SOUNDCARD_H @@ -601,6 +609,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR @@ -613,6 +624,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + /* Define to 1 if you have the `strsignal' function. */ #undef HAVE_STRSIGNAL @@ -697,9 +711,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <sys/_mbstate_t.h> header file. */ #undef HAVE_SYS__MBSTATE_T_H -/* Define to 1 if you have the <termcap.h> header file. */ -#undef HAVE_TERMCAP_H - /* Define to 1 if you have the <termios.h> header file. */ #undef HAVE_TERMIOS_H @@ -735,6 +746,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the <util.h> header file. */ +#undef HAVE_UTIL_H + /* Define to 1 if you have the `utimes' function. */ #undef HAVE_UTIMES @@ -750,6 +764,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the <vfork.h> header file. */ #undef HAVE_VFORK_H +/* Define if you have a window system. */ +#undef HAVE_WINDOW_SYSTEM + /* Define to 1 if `fork' works. */ #undef HAVE_WORKING_FORK @@ -763,6 +780,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the X11R6 or newer version of Xlib. */ #undef HAVE_X11R6 +/* Define if you have usable X11R6-style XIM support. */ +#undef HAVE_X11R6_XIM + /* Define to 1 if you have the X11R6 or newer version of Xt. */ #undef HAVE_X11XTR6 @@ -793,12 +813,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you have the `XSetWMProtocols' function. */ #undef HAVE_XSETWMPROTOCOLS +/* Define if you have usable i18n support. */ +#undef HAVE_X_I18N + /* Define to 1 if you have the SM library (-lSM). */ #undef HAVE_X_SM /* Define to 1 if you want to use the X window system. */ #undef HAVE_X_WINDOWS +/* Define to 1 if you have the `__executable_start' function. */ +#undef HAVE___EXECUTABLE_START + /* Define to 1 if you have the `__fpending' function. */ #undef HAVE___FPENDING @@ -811,21 +837,23 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to use Kerberos 5 instead of Kerberos 4. */ #undef KERBEROS5 -/* Define LD_SWITCH_X_SITE to contain any special flags your loader may need - to deal with X Windows. For instance, if you've defined HAVE_X_WINDOWS - above and your X libraries aren't in a place that your loader can find on - its own, you might want to add "-L/..." or something similar. */ -#undef LD_SWITCH_X_SITE +/* Define to 1 if localtime caches TZ. */ +#undef LOCALTIME_CACHE -/* Define LD_SWITCH_X_SITE_AUX with an -R option in case it's needed (for - Solaris, for example). */ -#undef LD_SWITCH_X_SITE_AUX +/* String giving fallback POP mail host. */ +#undef MAILHOST -/* Compiler option to link with the gif library (if not -lgif). */ -#undef LIBGIF +/* Define to unlink, rather than empty, mail spool after reading. */ +#undef MAIL_UNLINK_SPOOL -/* Define to 1 if localtime caches TZ. */ -#undef LOCALTIME_CACHE +/* Define if the mailer uses flock to interlock the mail spool. */ +#undef MAIL_USE_FLOCK + +/* Define if the mailer uses lockf to interlock the mail spool. */ +#undef MAIL_USE_LOCKF + +/* Define to support MMDF mailboxes in movemail. */ +#undef MAIL_USE_MMDF /* Define to support POP mail retrieval. */ #undef MAIL_USE_POP @@ -846,6 +874,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if you are using NS windowing under GNUstep. */ #undef NS_IMPL_GNUSTEP +/* Define if the C compiler is the linker. */ +#undef ORDINARY_LINK + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT @@ -895,6 +926,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Process async input synchronously. */ #undef SYNC_INPUT +/* Define to use system malloc. */ +#undef SYSTEM_MALLOC + +/* Define to 1 if you use terminfo instead of termcap. */ +#undef TERMINFO + /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #undef TIME_WITH_SYS_TIME @@ -908,15 +945,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ <sys/cpustats.h>. */ #undef UMAX4_3 -/* Define to the unexec source file name. */ -#undef UNEXEC_SRC - /* Define to 1 if using GTK. */ #undef USE_GTK +/* Define this to use a lisp union for the Lisp_Object data type. */ +#undef USE_LISP_UNION_TYPE + /* Define to 1 if using the Lucid X toolkit. */ #undef USE_LUCID +/* Define to use mmap to allocate buffer text. */ +#undef USE_MMAP_FOR_BUFFERS + /* Define to 1 if using the Motif X toolkit. */ #undef USE_MOTIF @@ -951,6 +991,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Define to 1 if using an X toolkit. */ #undef USE_X_TOOLKIT +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + /* Define this to check for malloc buffer overrun. */ #undef XMALLOC_OVERRUN_CHECK @@ -1018,37 +1070,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef volatile -/* If we're using X11/Carbon/GNUstep, define some consequences. */ -#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS) -#define HAVE_WINDOW_SYSTEM -#define HAVE_MOUSE -#endif - /* Define AMPERSAND_FULL_NAME if you use the convention that & in the full name stands for the login id. */ /* Turned on June 1996 supposing nobody will mind it. */ #define AMPERSAND_FULL_NAME -/* Define HAVE_SOUND if we have sound support. We know it works - and compiles only on the specified platforms. For others, - it probably doesn't make sense to try. */ - -#if defined __FreeBSD__ || defined __NetBSD__ || defined __linux__ -#ifdef HAVE_MACHINE_SOUNDCARD_H -#define HAVE_SOUND 1 -#endif -#ifdef HAVE_SYS_SOUNDCARD_H -#define HAVE_SOUND 1 -#endif -#ifdef HAVE_SOUNDCARD_H -#define HAVE_SOUND 1 -#endif -#ifdef HAVE_ALSA -#define HAVE_SOUND 1 -#endif -#endif /* __FreeBSD__ || __NetBSD__ || __linux__ */ - -/* If using GNU, then support inline function declarations. */ +/* If using GNU, then support inline function declarations. */ /* Don't try to switch on inline handling as detected by AC_C_INLINE generally, because even if non-gcc compilers accept `inline', they may reject `extern inline'. */ @@ -1073,12 +1100,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Set up some defines, C and LD flags for NeXTstep interface on GNUstep. (There is probably a better place to do this, but right now the Cocoa side does this in s/darwin.h and we cannot - parallel this exactly since GNUstep is multi-OS. */ + parallel this exactly since GNUstep is multi-OS. */ #ifdef HAVE_NS # ifdef NS_IMPL_GNUSTEP -/* See also .m.o rule in Makefile.in */ -/* FIXME: are all these flags really needed? Document here why. */ -# define C_SWITCH_X_SYSTEM -D_REENTRANT -fPIC -fno-strict-aliasing /* GNUstep needs a bit more pure memory. Of the existing knobs, SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ # define SYSTEM_PURESIZE_EXTRA 30000 @@ -1110,24 +1134,6 @@ SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ #define my_strftime nstrftime /* for strftime.c */ -/* The rest of the code currently tests the CPP symbol BSTRING. - Override any claims made by the system-description files. - Note that on some SCO version it is possible to have bcopy and not bcmp. */ -#undef BSTRING -#if defined (HAVE_BCOPY) && defined (HAVE_BCMP) -#define BSTRING -#endif - -/* Some of the files of Emacs which are intended for use with other - programs assume that if you have a config.h file, you must declare - the type of getenv. - - This declaration shouldn't appear when alloca.s or Makefile.in - includes config.h. */ -#ifndef NOT_C_CODE -extern char *getenv (); -#endif - /* These default definitions are good for almost all machines. The exceptions override them in m/MACHINE.h. */ @@ -1154,56 +1160,37 @@ extern char *getenv (); #endif #endif -/* Define if the compiler supports function prototypes. It may do so - but not define __STDC__ (e.g. DEC C by default) or may define it as - zero. */ +/* Define if the compiler supports function prototypes. It may do so but + not define __STDC__ (e.g. DEC C by default) or may define it as zero. */ #undef PROTOTYPES -/* For mktime.c: */ -#ifndef __P -# if defined PROTOTYPES -# define __P(args) args -# else -# define __P(args) () -# endif /* GCC. */ -#endif /* __P */ - -/* Don't include "string.h" or <stdlib.h> in non-C code. */ -#ifndef NOT_C_CODE -#ifdef HAVE_STRING_H -#include "string.h" -#endif -#ifdef HAVE_STRINGS_H -#include "strings.h" /* May be needed for bcopy & al. */ -#endif -#ifdef HAVE_STDLIB_H + +#include <string.h> #include <stdlib.h> + +#ifdef HAVE_ALLOCA_H +# include <alloca.h> +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#else +# include <stddef.h> +# ifdef __cplusplus +extern "C" +# endif +void *alloca (size_t); #endif -#ifndef __GNUC__ -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# else /* AIX files deal with #pragma. */ -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif /* HAVE_ALLOCA_H */ -#endif /* __GNUC__ */ + #ifndef HAVE_SIZE_T typedef unsigned size_t; #endif -#endif /* NOT_C_CODE */ -/* Define HAVE_X_I18N if we have usable i18n support. */ - -#ifdef HAVE_X11R6 -#define HAVE_X_I18N -#elif !defined X11R5_INHIBIT_I18N -#define HAVE_X_I18N +#ifndef HAVE_STRCHR +#define strchr(a, b) index (a, b) #endif -/* Define HAVE_X11R6_XIM if we have usable X11R6-style XIM support. */ - -#if defined HAVE_X11R6 && !defined INHIBIT_X11R6_XIM -#define HAVE_X11R6_XIM +#ifndef HAVE_STRRCHR +#define strrchr(a, b) rindex (a, b) #endif #if defined __GNUC__ && (__GNUC__ > 2 \ @@ -1213,15 +1200,22 @@ typedef unsigned size_t; #define NO_RETURN /* nothing */ #endif +#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ +#define NO_INLINE __attribute__((noinline)) +#else +#define NO_INLINE +#endif + +/* Some versions of GNU/Linux define noinline in their headers. */ +#ifdef noinline +#undef noinline +#endif + /* These won't be used automatically yet. We also need to know, at least, that the stack is continuous. */ #ifdef __GNUC__ # ifndef GC_SETJMP_WORKS - /* GC_SETJMP_WORKS is nearly always appropriate for GCC -- - see NON_SAVING_SETJMP in the target descriptions. */ - /* Exceptions (see NON_SAVING_SETJMP in target description) are - SCO5 non-ELF (but Emacs specifies ELF) and SVR3 on x86. - Fixme: Deal with SVR3. */ + /* GC_SETJMP_WORKS is nearly always appropriate for GCC. */ # define GC_SETJMP_WORKS 1 # endif # ifndef GC_LISP_OBJECT_ALIGNMENT @@ -1229,16 +1223,6 @@ typedef unsigned size_t; # endif #endif -#ifndef HAVE_BCOPY -#define bcopy(a,b,s) memcpy (b,a,s) -#endif -#ifndef HAVE_BZERO -#define bzero(a,s) memset (a,0,s) -#endif -#ifndef HAVE_BCMP -#define BCMP memcmp -#endif - #endif /* EMACS_CONFIG_H */ /* diff --git a/src/data.c b/src/data.c index e405ca6af9e..c28dc9b4bae 100644 --- a/src/data.c +++ b/src/data.c @@ -50,7 +50,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <math.h> #if !defined (atof) -extern double atof (); +extern double atof (const char *); #endif /* !atof */ Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; @@ -82,7 +82,8 @@ Lisp_Object Qnumberp, Qnumber_or_marker_p; Lisp_Object Qinteger; static Lisp_Object Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; -static Lisp_Object Qfloat, Qwindow_configuration, Qwindow; +Lisp_Object Qwindow; +static Lisp_Object Qfloat, Qwindow_configuration; Lisp_Object Qprocess; static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; @@ -91,22 +92,20 @@ Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; Lisp_Object Qinteractive_form; -static Lisp_Object swap_in_symval_forwarding P_ ((Lisp_Object, Lisp_Object)); +static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *); Lisp_Object Vmost_positive_fixnum, Vmost_negative_fixnum; void -circular_list_error (list) - Lisp_Object list; +circular_list_error (Lisp_Object list) { xsignal (Qcircular_list, list); } Lisp_Object -wrong_type_argument (predicate, value) - register Lisp_Object predicate, value; +wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) { /* If VALUE is not even a valid Lisp object, we'd want to abort here where we can get a backtrace showing where it came from. We used @@ -119,21 +118,19 @@ wrong_type_argument (predicate, value) } void -pure_write_error () +pure_write_error (void) { error ("Attempt to modify read-only object"); } void -args_out_of_range (a1, a2) - Lisp_Object a1, a2; +args_out_of_range (Lisp_Object a1, Lisp_Object a2) { xsignal2 (Qargs_out_of_range, a1, a2); } void -args_out_of_range_3 (a1, a2, a3) - Lisp_Object a1, a2, a3; +args_out_of_range_3 (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3) { xsignal3 (Qargs_out_of_range, a1, a2, a3); } @@ -146,8 +143,7 @@ int sign_extend_temp; /* On a few machines, XINT can only be done by calling this. */ int -sign_extend_lisp_int (num) - EMACS_INT num; +sign_extend_lisp_int (EMACS_INT num) { if (num & (((EMACS_INT) 1) << (VALBITS - 1))) return num | (((EMACS_INT) (-1)) << VALBITS); @@ -159,8 +155,7 @@ sign_extend_lisp_int (num) DEFUN ("eq", Feq, Seq, 2, 2, 0, doc: /* Return t if the two args are the same Lisp object. */) - (obj1, obj2) - Lisp_Object obj1, obj2; + (Lisp_Object obj1, Lisp_Object obj2) { if (EQ (obj1, obj2)) return Qt; @@ -169,8 +164,7 @@ DEFUN ("eq", Feq, Seq, 2, 2, 0, DEFUN ("null", Fnull, Snull, 1, 1, 0, doc: /* Return t if OBJECT is nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NILP (object)) return Qt; @@ -181,8 +175,7 @@ DEFUN ("type-of", Ftype_of, Stype_of, 1, 1, 0, doc: /* Return a symbol representing the type of OBJECT. The symbol returned names the object's basic type; for example, (type-of 1) returns `integer'. */) - (object) - Lisp_Object object; + (Lisp_Object object) { switch (XTYPE (object)) { @@ -249,8 +242,7 @@ for example, (type-of 1) returns `integer'. */) DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, doc: /* Return t if OBJECT is a cons cell. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CONSP (object)) return Qt; @@ -259,8 +251,7 @@ DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, DEFUN ("atom", Fatom, Satom, 1, 1, 0, doc: /* Return t if OBJECT is not a cons cell. This includes nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CONSP (object)) return Qnil; @@ -270,8 +261,7 @@ DEFUN ("atom", Fatom, Satom, 1, 1, 0, DEFUN ("listp", Flistp, Slistp, 1, 1, 0, doc: /* Return t if OBJECT is a list, that is, a cons cell or nil. Otherwise, return nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CONSP (object) || NILP (object)) return Qt; @@ -280,8 +270,7 @@ Otherwise, return nil. */) DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, doc: /* Return t if OBJECT is not a list. Lists include nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CONSP (object) || NILP (object)) return Qnil; @@ -290,8 +279,7 @@ DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, doc: /* Return t if OBJECT is a symbol. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (SYMBOLP (object)) return Qt; @@ -304,8 +292,7 @@ DEFUN ("keywordp", Fkeywordp, Skeywordp, 1, 1, 0, doc: /* Return t if OBJECT is a keyword. This means that it is a symbol with a print name beginning with `:' interned in the initial obarray. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (SYMBOLP (object) && SREF (SYMBOL_NAME (object), 0) == ':' @@ -316,8 +303,7 @@ interned in the initial obarray. */) DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, doc: /* Return t if OBJECT is a vector. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (VECTORP (object)) return Qt; @@ -326,8 +312,7 @@ DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, doc: /* Return t if OBJECT is a string. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (STRINGP (object)) return Qt; @@ -337,8 +322,7 @@ DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p, 1, 1, 0, doc: /* Return t if OBJECT is a multibyte string. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (STRINGP (object) && STRING_MULTIBYTE (object)) return Qt; @@ -347,8 +331,7 @@ DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p, DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, doc: /* Return t if OBJECT is a char-table. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CHAR_TABLE_P (object)) return Qt; @@ -358,8 +341,7 @@ DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0, DEFUN ("vector-or-char-table-p", Fvector_or_char_table_p, Svector_or_char_table_p, 1, 1, 0, doc: /* Return t if OBJECT is a char-table or vector. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (VECTORP (object) || CHAR_TABLE_P (object)) return Qt; @@ -368,8 +350,7 @@ DEFUN ("vector-or-char-table-p", Fvector_or_char_table_p, DEFUN ("bool-vector-p", Fbool_vector_p, Sbool_vector_p, 1, 1, 0, doc: /* Return t if OBJECT is a bool-vector. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (BOOL_VECTOR_P (object)) return Qt; @@ -378,8 +359,7 @@ DEFUN ("bool-vector-p", Fbool_vector_p, Sbool_vector_p, 1, 1, 0, DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, doc: /* Return t if OBJECT is an array (string or vector). */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (ARRAYP (object)) return Qt; @@ -388,8 +368,7 @@ DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, doc: /* Return t if OBJECT is a sequence (list or array). */) - (object) - register Lisp_Object object; + (register Lisp_Object object) { if (CONSP (object) || NILP (object) || ARRAYP (object)) return Qt; @@ -398,8 +377,7 @@ DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, doc: /* Return t if OBJECT is an editor buffer. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (BUFFERP (object)) return Qt; @@ -408,8 +386,7 @@ DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, doc: /* Return t if OBJECT is a marker (editor pointer). */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (MARKERP (object)) return Qt; @@ -418,8 +395,7 @@ DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, doc: /* Return t if OBJECT is a built-in function. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (SUBRP (object)) return Qt; @@ -429,8 +405,7 @@ DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p, 1, 1, 0, doc: /* Return t if OBJECT is a byte-compiled function object. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (COMPILEDP (object)) return Qt; @@ -439,8 +414,7 @@ DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p, DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, doc: /* Return t if OBJECT is a character or a string. */) - (object) - register Lisp_Object object; + (register Lisp_Object object) { if (CHARACTERP (object) || STRINGP (object)) return Qt; @@ -449,8 +423,7 @@ DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, doc: /* Return t if OBJECT is an integer. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (INTEGERP (object)) return Qt; @@ -459,8 +432,7 @@ DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, doc: /* Return t if OBJECT is an integer or a marker (editor pointer). */) - (object) - register Lisp_Object object; + (register Lisp_Object object) { if (MARKERP (object) || INTEGERP (object)) return Qt; @@ -469,8 +441,7 @@ DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, doc: /* Return t if OBJECT is a nonnegative integer. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NATNUMP (object)) return Qt; @@ -479,8 +450,7 @@ DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, doc: /* Return t if OBJECT is a number (floating point or integer). */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NUMBERP (object)) return Qt; @@ -491,8 +461,7 @@ DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, DEFUN ("number-or-marker-p", Fnumber_or_marker_p, Snumber_or_marker_p, 1, 1, 0, doc: /* Return t if OBJECT is a number or a marker. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NUMBERP (object) || MARKERP (object)) return Qt; @@ -501,8 +470,7 @@ DEFUN ("number-or-marker-p", Fnumber_or_marker_p, DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, doc: /* Return t if OBJECT is a floating point number. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (FLOATP (object)) return Qt; @@ -518,16 +486,14 @@ Error if arg is not nil and not a cons cell. See also `car-safe'. See Info node `(elisp)Cons Cells' for a discussion of related basic Lisp concepts such as car, cdr, cons cell and list. */) - (list) - register Lisp_Object list; + (register Lisp_Object list) { return CAR (list); } DEFUN ("car-safe", Fcar_safe, Scar_safe, 1, 1, 0, doc: /* Return the car of OBJECT if it is a cons cell, or else nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return CAR_SAFE (object); } @@ -538,24 +504,21 @@ Error if arg is not nil and not a cons cell. See also `cdr-safe'. See Info node `(elisp)Cons Cells' for a discussion of related basic Lisp concepts such as cdr, car, cons cell and list. */) - (list) - register Lisp_Object list; + (register Lisp_Object list) { return CDR (list); } DEFUN ("cdr-safe", Fcdr_safe, Scdr_safe, 1, 1, 0, doc: /* Return the cdr of OBJECT if it is a cons cell, or else nil. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return CDR_SAFE (object); } DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0, doc: /* Set the car of CELL to be NEWCAR. Returns NEWCAR. */) - (cell, newcar) - register Lisp_Object cell, newcar; + (register Lisp_Object cell, Lisp_Object newcar) { CHECK_CONS (cell); CHECK_IMPURE (cell); @@ -565,8 +528,7 @@ DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0, DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, doc: /* Set the cdr of CELL to be NEWCDR. Returns NEWCDR. */) - (cell, newcdr) - register Lisp_Object cell, newcdr; + (register Lisp_Object cell, Lisp_Object newcdr) { CHECK_CONS (cell); CHECK_IMPURE (cell); @@ -578,24 +540,45 @@ DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, doc: /* Return t if SYMBOL's value is not void. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { Lisp_Object valcontents; + struct Lisp_Symbol *sym; CHECK_SYMBOL (symbol); + sym = XSYMBOL (symbol); - valcontents = SYMBOL_VALUE (symbol); - - if (BUFFER_LOCAL_VALUEP (valcontents)) - valcontents = swap_in_symval_forwarding (symbol, valcontents); + start: + switch (sym->redirect) + { + case SYMBOL_PLAINVAL: valcontents = SYMBOL_VAL (sym); break; + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + if (blv->fwd) + /* In set_internal, we un-forward vars when their value is + set to Qunbound. */ + return Qt; + else + { + swap_in_symval_forwarding (sym, blv); + valcontents = BLV_VALUE (blv); + } + break; + } + case SYMBOL_FORWARDED: + /* In set_internal, we un-forward vars when their value is + set to Qunbound. */ + return Qt; + default: abort (); + } return (EQ (valcontents, Qunbound) ? Qnil : Qt); } DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, doc: /* Return t if SYMBOL's function definition is not void. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); return (EQ (XSYMBOL (symbol)->function, Qunbound) ? Qnil : Qt); @@ -604,8 +587,7 @@ DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, doc: /* Make SYMBOL's value be void. Return SYMBOL. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); if (SYMBOL_CONSTANT_P (symbol)) @@ -617,8 +599,7 @@ Return SYMBOL. */) DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, doc: /* Make SYMBOL's function definition be void. Return SYMBOL. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); if (NILP (symbol) || EQ (symbol, Qt)) @@ -629,8 +610,7 @@ Return SYMBOL. */) DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, doc: /* Return SYMBOL's function definition. Error if that is void. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); if (!EQ (XSYMBOL (symbol)->function, Qunbound)) @@ -640,8 +620,7 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, doc: /* Return SYMBOL's property list. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { CHECK_SYMBOL (symbol); return XSYMBOL (symbol)->plist; @@ -649,8 +628,7 @@ DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, doc: /* Return SYMBOL's name, a string. */) - (symbol) - register Lisp_Object symbol; + (register Lisp_Object symbol) { register Lisp_Object name; @@ -661,8 +639,7 @@ DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, DEFUN ("fset", Ffset, Sfset, 2, 2, 0, doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. */) - (symbol, definition) - register Lisp_Object symbol, definition; + (register Lisp_Object symbol, Lisp_Object definition) { register Lisp_Object function; @@ -688,16 +665,13 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, return definition; } -extern Lisp_Object Qfunction_documentation; - DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0, doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION. Associates the function with the current load file, if any. The optional third argument DOCSTRING specifies the documentation string for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string determined by DEFINITION. */) - (symbol, definition, docstring) - register Lisp_Object symbol, definition, docstring; + (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring) { CHECK_SYMBOL (symbol); if (CONSP (XSYMBOL (symbol)->function) @@ -712,8 +686,7 @@ determined by DEFINITION. */) DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, doc: /* Set SYMBOL's property list to NEWPLIST, and return NEWPLIST. */) - (symbol, newplist) - register Lisp_Object symbol, newplist; + (register Lisp_Object symbol, Lisp_Object newplist) { CHECK_SYMBOL (symbol); XSYMBOL (symbol)->plist = newplist; @@ -726,8 +699,7 @@ SUBR must be a built-in function. The returned value is a pair (MIN . MAX). MIN is the minimum number of args. MAX is the maximum number or the symbol `many', for a function with `&rest' args, or `unevalled' for a special form. */) - (subr) - Lisp_Object subr; + (Lisp_Object subr) { short minargs, maxargs; CHECK_SUBR (subr); @@ -744,8 +716,7 @@ function with `&rest' args, or `unevalled' for a special form. */) DEFUN ("subr-name", Fsubr_name, Ssubr_name, 1, 1, 0, doc: /* Return name of subroutine SUBR. SUBR must be a built-in function. */) - (subr) - Lisp_Object subr; + (Lisp_Object subr) { const char *name; CHECK_SUBR (subr); @@ -757,8 +728,7 @@ DEFUN ("interactive-form", Finteractive_form, Sinteractive_form, 1, 1, 0, doc: /* Return the interactive form of CMD or nil if none. If CMD is not a command, the return value is nil. Value, if non-nil, is a list \(interactive SPEC). */) - (cmd) - Lisp_Object cmd; + (Lisp_Object cmd) { Lisp_Object fun = indirect_function (cmd); /* Check cycles. */ @@ -779,7 +749,7 @@ Value, if non-nil, is a list \(interactive SPEC). */) if (SUBRP (fun)) { - char *spec = XSUBR (fun)->intspec; + const char *spec = XSUBR (fun)->intspec; if (spec) return list2 (Qinteractive, (*spec != '(') ? build_string (spec) : @@ -817,21 +787,20 @@ Value, if non-nil, is a list \(interactive SPEC). */) indirections contains a loop. */ struct Lisp_Symbol * -indirect_variable (symbol) - struct Lisp_Symbol *symbol; +indirect_variable (struct Lisp_Symbol *symbol) { struct Lisp_Symbol *tortoise, *hare; hare = tortoise = symbol; - while (hare->indirect_variable) + while (hare->redirect == SYMBOL_VARALIAS) { - hare = XSYMBOL (hare->value); - if (!hare->indirect_variable) + hare = SYMBOL_ALIAS (hare); + if (hare->redirect != SYMBOL_VARALIAS) break; - hare = XSYMBOL (hare->value); - tortoise = XSYMBOL (tortoise->value); + hare = SYMBOL_ALIAS (hare); + tortoise = SYMBOL_ALIAS (tortoise); if (hare == tortoise) { @@ -851,8 +820,7 @@ If OBJECT is a symbol, follow all variable indirections and return the final variable. If OBJECT is not a symbol, just return it. Signal a cyclic-variable-indirection error if there is a loop in the variable chain of symbols. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (SYMBOLP (object)) XSETSYMBOL (object, indirect_variable (XSYMBOL (object))); @@ -865,44 +833,45 @@ variable chain of symbols. */) This does not handle buffer-local variables; use swap_in_symval_forwarding for that. */ +#define do_blv_forwarding(blv) \ + ((blv)->forwarded ? do_symval_forwarding (BLV_FWD (blv)) : BLV_VALUE (blv)) + Lisp_Object -do_symval_forwarding (valcontents) - register Lisp_Object valcontents; +do_symval_forwarding (register union Lisp_Fwd *valcontents) { register Lisp_Object val; - if (MISCP (valcontents)) - switch (XMISCTYPE (valcontents)) - { - case Lisp_Misc_Intfwd: - XSETINT (val, *XINTFWD (valcontents)->intvar); - return val; - - case Lisp_Misc_Boolfwd: - return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); - - case Lisp_Misc_Objfwd: - return *XOBJFWD (valcontents)->objvar; - - case Lisp_Misc_Buffer_Objfwd: - return PER_BUFFER_VALUE (current_buffer, - XBUFFER_OBJFWD (valcontents)->offset); - - case Lisp_Misc_Kboard_Objfwd: - /* We used to simply use current_kboard here, but from Lisp - code, it's value is often unexpected. It seems nicer to - allow constructions like this to work as intuitively expected: - - (with-selected-frame frame - (define-key local-function-map "\eOP" [f1])) - - On the other hand, this affects the semantics of - last-command and real-last-command, and people may rely on - that. I took a quick look at the Lisp codebase, and I - don't think anything will break. --lorentey */ - return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset - + (char *)FRAME_KBOARD (SELECTED_FRAME ())); - } - return valcontents; + switch (XFWDTYPE (valcontents)) + { + case Lisp_Fwd_Int: + XSETINT (val, *XINTFWD (valcontents)->intvar); + return val; + + case Lisp_Fwd_Bool: + return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); + + case Lisp_Fwd_Obj: + return *XOBJFWD (valcontents)->objvar; + + case Lisp_Fwd_Buffer_Obj: + return PER_BUFFER_VALUE (current_buffer, + XBUFFER_OBJFWD (valcontents)->offset); + + case Lisp_Fwd_Kboard_Obj: + /* We used to simply use current_kboard here, but from Lisp + code, it's value is often unexpected. It seems nicer to + allow constructions like this to work as intuitively expected: + + (with-selected-frame frame + (define-key local-function-map "\eOP" [f1])) + + On the other hand, this affects the semantics of + last-command and real-last-command, and people may rely on + that. I took a quick look at the Lisp codebase, and I + don't think anything will break. --lorentey */ + return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset + + (char *)FRAME_KBOARD (SELECTED_FRAME ())); + default: abort (); + } } /* Store NEWVAL into SYMBOL, where VALCONTENTS is found in the value cell @@ -913,102 +882,89 @@ do_symval_forwarding (valcontents) BUF non-zero means set the value in buffer BUF instead of the current buffer. This only plays a role for per-buffer variables. */ -void -store_symval_forwarding (symbol, valcontents, newval, buf) - Lisp_Object symbol; - register Lisp_Object valcontents, newval; - struct buffer *buf; +#define store_blv_forwarding(blv, newval, buf) \ + do { \ + if ((blv)->forwarded) \ + store_symval_forwarding (BLV_FWD (blv), (newval), (buf)); \ + else \ + SET_BLV_VALUE (blv, newval); \ + } while (0) + +static void +store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newval, struct buffer *buf) { - switch (SWITCH_ENUM_CAST (XTYPE (valcontents))) + switch (XFWDTYPE (valcontents)) { - case Lisp_Misc: - switch (XMISCTYPE (valcontents)) - { - case Lisp_Misc_Intfwd: - CHECK_NUMBER (newval); - *XINTFWD (valcontents)->intvar = XINT (newval); - /* This can never happen since intvar points to an EMACS_INT - which is at least large enough to hold a Lisp_Object. - if (*XINTFWD (valcontents)->intvar != XINT (newval)) - error ("Value out of range for variable `%s'", - SDATA (SYMBOL_NAME (symbol))); */ - break; + case Lisp_Fwd_Int: + CHECK_NUMBER (newval); + *XINTFWD (valcontents)->intvar = XINT (newval); + break; - case Lisp_Misc_Boolfwd: - *XBOOLFWD (valcontents)->boolvar = !NILP (newval); - break; + case Lisp_Fwd_Bool: + *XBOOLFWD (valcontents)->boolvar = !NILP (newval); + break; - case Lisp_Misc_Objfwd: - *XOBJFWD (valcontents)->objvar = newval; + case Lisp_Fwd_Obj: + *XOBJFWD (valcontents)->objvar = newval; - /* If this variable is a default for something stored - in the buffer itself, such as default-fill-column, - find the buffers that don't have local values for it - and update them. */ - if (XOBJFWD (valcontents)->objvar > (Lisp_Object *) &buffer_defaults - && XOBJFWD (valcontents)->objvar < (Lisp_Object *) (&buffer_defaults + 1)) - { - int offset = ((char *) XOBJFWD (valcontents)->objvar - - (char *) &buffer_defaults); - int idx = PER_BUFFER_IDX (offset); + /* If this variable is a default for something stored + in the buffer itself, such as default-fill-column, + find the buffers that don't have local values for it + and update them. */ + if (XOBJFWD (valcontents)->objvar > (Lisp_Object *) &buffer_defaults + && XOBJFWD (valcontents)->objvar < (Lisp_Object *) (&buffer_defaults + 1)) + { + int offset = ((char *) XOBJFWD (valcontents)->objvar + - (char *) &buffer_defaults); + int idx = PER_BUFFER_IDX (offset); - Lisp_Object tail; + Lisp_Object tail; - if (idx <= 0) - break; + if (idx <= 0) + break; - for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) - { - Lisp_Object buf; - struct buffer *b; + for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) + { + Lisp_Object buf; + struct buffer *b; - buf = Fcdr (XCAR (tail)); - if (!BUFFERP (buf)) continue; - b = XBUFFER (buf); + buf = Fcdr (XCAR (tail)); + if (!BUFFERP (buf)) continue; + b = XBUFFER (buf); - if (! PER_BUFFER_VALUE_P (b, idx)) - PER_BUFFER_VALUE (b, offset) = newval; - } + if (! PER_BUFFER_VALUE_P (b, idx)) + PER_BUFFER_VALUE (b, offset) = newval; } - break; - - case Lisp_Misc_Buffer_Objfwd: - { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype; - - if (!(NILP (type) || NILP (newval) - || (XINT (type) == LISP_INT_TAG - ? INTEGERP (newval) - : XTYPE (newval) == XINT (type)))) - buffer_slot_type_mismatch (newval, XINT (type)); - - if (buf == NULL) - buf = current_buffer; - PER_BUFFER_VALUE (buf, offset) = newval; - } - break; + } + break; - case Lisp_Misc_Kboard_Objfwd: - { - char *base = (char *) FRAME_KBOARD (SELECTED_FRAME ()); - char *p = base + XKBOARD_OBJFWD (valcontents)->offset; - *(Lisp_Object *) p = newval; - } - break; + case Lisp_Fwd_Buffer_Obj: + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype; + + if (!(NILP (type) || NILP (newval) + || (XINT (type) == LISP_INT_TAG + ? INTEGERP (newval) + : XTYPE (newval) == XINT (type)))) + buffer_slot_type_mismatch (newval, XINT (type)); + + if (buf == NULL) + buf = current_buffer; + PER_BUFFER_VALUE (buf, offset) = newval; + } + break; - default: - goto def; - } + case Lisp_Fwd_Kboard_Obj: + { + char *base = (char *) FRAME_KBOARD (SELECTED_FRAME ()); + char *p = base + XKBOARD_OBJFWD (valcontents)->offset; + *(Lisp_Object *) p = newval; + } break; default: - def: - valcontents = SYMBOL_VALUE (symbol); - if (BUFFER_LOCAL_VALUEP (valcontents)) - XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval; - else - SET_SYMBOL_VALUE (symbol, newval); + abort (); /* goto def; */ } } @@ -1016,26 +972,22 @@ store_symval_forwarding (symbol, valcontents, newval, buf) This makes it safe to alter the status of other bindings. */ void -swap_in_global_binding (symbol) - Lisp_Object symbol; +swap_in_global_binding (struct Lisp_Symbol *symbol) { - Lisp_Object valcontents = SYMBOL_VALUE (symbol); - struct Lisp_Buffer_Local_Value *blv = XBUFFER_LOCAL_VALUE (valcontents); - Lisp_Object cdr = blv->cdr; + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (symbol); /* Unload the previously loaded binding. */ - Fsetcdr (XCAR (cdr), - do_symval_forwarding (blv->realvalue)); + if (blv->fwd) + SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); /* Select the global binding in the symbol. */ - XSETCAR (cdr, cdr); - store_symval_forwarding (symbol, blv->realvalue, XCDR (cdr), NULL); + blv->valcell = blv->defcell; + if (blv->fwd) + store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL); /* Indicate that the global binding is set up now. */ - blv->frame = Qnil; - blv->buffer = Qnil; - blv->found_for_frame = 0; - blv->found_for_buffer = 0; + blv->where = Qnil; + SET_BLV_FOUND (blv, 0); } /* Set up the buffer-local symbol SYMBOL for validity in the current buffer. @@ -1045,55 +997,48 @@ swap_in_global_binding (symbol) Return the value forwarded one step past the buffer-local stage. This could be another forwarding pointer. */ -static Lisp_Object -swap_in_symval_forwarding (symbol, valcontents) - Lisp_Object symbol, valcontents; +static void +swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_Value *blv) { register Lisp_Object tem1; - tem1 = XBUFFER_LOCAL_VALUE (valcontents)->buffer; + eassert (blv == SYMBOL_BLV (symbol)); + + tem1 = blv->where; if (NILP (tem1) - || current_buffer != XBUFFER (tem1) - || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame - && ! EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))) + || (blv->frame_local + ? !EQ (selected_frame, tem1) + : current_buffer != XBUFFER (tem1))) { - struct Lisp_Symbol *sym = XSYMBOL (symbol); - if (sym->indirect_variable) - { - sym = indirect_variable (sym); - XSETSYMBOL (symbol, sym); - } /* Unload the previously loaded binding. */ - tem1 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - Fsetcdr (tem1, - do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); + tem1 = blv->valcell; + if (blv->fwd) + SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); /* Choose the new binding. */ - tem1 = assq_no_quit (symbol, current_buffer->local_var_alist); - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; - if (NILP (tem1)) - { - if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) - tem1 = assq_no_quit (symbol, XFRAME (selected_frame)->param_alist); - if (! NILP (tem1)) - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1; - else - tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; - } - else - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; + { + Lisp_Object var; + XSETSYMBOL (var, symbol); + if (blv->frame_local) + { + tem1 = assq_no_quit (var, XFRAME (selected_frame)->param_alist); + blv->where = selected_frame; + } + else + { + tem1 = assq_no_quit (var, current_buffer->local_var_alist); + XSETBUFFER (blv->where, current_buffer); + } + } + if (!(blv->found = !NILP (tem1))) + tem1 = blv->defcell; /* Load the new binding. */ - XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1); - XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer); - XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; - store_symval_forwarding (symbol, - XBUFFER_LOCAL_VALUE (valcontents)->realvalue, - Fcdr (tem1), NULL); + blv->valcell = tem1; + if (blv->fwd) + store_symval_forwarding (blv->fwd, BLV_VALUE (blv), NULL); } - return XBUFFER_LOCAL_VALUE (valcontents)->realvalue; } /* Find the value of a symbol, returning Qunbound if it's not bound. @@ -1103,25 +1048,34 @@ swap_in_symval_forwarding (symbol, valcontents) within this function. Great care is required for this. */ Lisp_Object -find_symbol_value (symbol) - Lisp_Object symbol; +find_symbol_value (Lisp_Object symbol) { - register Lisp_Object valcontents; - register Lisp_Object val; + struct Lisp_Symbol *sym; CHECK_SYMBOL (symbol); - valcontents = SYMBOL_VALUE (symbol); + sym = XSYMBOL (symbol); - if (BUFFER_LOCAL_VALUEP (valcontents)) - valcontents = swap_in_symval_forwarding (symbol, valcontents); - - return do_symval_forwarding (valcontents); + start: + switch (sym->redirect) + { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym); + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + swap_in_symval_forwarding (sym, blv); + return blv->fwd ? do_symval_forwarding (blv->fwd) : BLV_VALUE (blv); + } + /* FALLTHROUGH */ + case SYMBOL_FORWARDED: + return do_symval_forwarding (SYMBOL_FWD (sym)); + default: abort (); + } } DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, doc: /* Return SYMBOL's value. Error if that is void. */) - (symbol) - Lisp_Object symbol; + (Lisp_Object symbol) { Lisp_Object val; @@ -1134,29 +1088,27 @@ DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, DEFUN ("set", Fset, Sset, 2, 2, 0, doc: /* Set SYMBOL's value to NEWVAL, and return NEWVAL. */) - (symbol, newval) - register Lisp_Object symbol, newval; + (register Lisp_Object symbol, Lisp_Object newval) { - return set_internal (symbol, newval, current_buffer, 0); + set_internal (symbol, newval, Qnil, 0); + return newval; } /* Return 1 if SYMBOL currently has a let-binding which was made in the buffer that is now current. */ static int -let_shadows_buffer_binding_p (symbol) - struct Lisp_Symbol *symbol; +let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) { - volatile struct specbinding *p; + struct specbinding *p; for (p = specpdl_ptr - 1; p >= specpdl; p--) if (p->func == NULL && CONSP (p->symbol)) { struct Lisp_Symbol *let_bound_symbol = XSYMBOL (XCAR (p->symbol)); - if ((symbol == let_bound_symbol - || (let_bound_symbol->indirect_variable - && symbol == indirect_variable (let_bound_symbol))) + eassert (let_bound_symbol->redirect != SYMBOL_VARALIAS); + if (symbol == let_bound_symbol && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer) break; } @@ -1164,141 +1116,170 @@ let_shadows_buffer_binding_p (symbol) return p >= specpdl; } +static int +let_shadows_global_binding_p (Lisp_Object symbol) +{ + struct specbinding *p; + + for (p = specpdl_ptr - 1; p >= specpdl; p--) + if (p->func == NULL && EQ (p->symbol, symbol)) + break; + + return p >= specpdl; +} + /* Store the value NEWVAL into SYMBOL. - If buffer-locality is an issue, BUF specifies which buffer to use. - (0 stands for the current buffer.) + If buffer/frame-locality is an issue, WHERE specifies which context to use. + (nil stands for the current buffer/frame). If BINDFLAG is zero, then if this symbol is supposed to become local in every buffer where it is set, then we make it local. If BINDFLAG is nonzero, we don't do that. */ -Lisp_Object -set_internal (symbol, newval, buf, bindflag) - register Lisp_Object symbol, newval; - struct buffer *buf; - int bindflag; +void +set_internal (register Lisp_Object symbol, register Lisp_Object newval, register Lisp_Object where, int bindflag) { int voide = EQ (newval, Qunbound); - - register Lisp_Object valcontents, innercontents, tem1, current_alist_element; - - if (buf == 0) - buf = current_buffer; + struct Lisp_Symbol *sym; + Lisp_Object tem1; /* If restoring in a dead buffer, do nothing. */ - if (NILP (buf->name)) - return newval; + /* if (BUFFERP (where) && NILP (XBUFFER (where)->name)) + return; */ CHECK_SYMBOL (symbol); - if (SYMBOL_CONSTANT_P (symbol) - && (NILP (Fkeywordp (symbol)) - || !EQ (newval, SYMBOL_VALUE (symbol)))) - xsignal1 (Qsetting_constant, symbol); - - innercontents = valcontents = SYMBOL_VALUE (symbol); - - if (BUFFER_OBJFWDP (valcontents)) + if (SYMBOL_CONSTANT_P (symbol)) { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - if (idx > 0 - && !bindflag - && !let_shadows_buffer_binding_p (XSYMBOL (symbol))) - SET_PER_BUFFER_VALUE_P (buf, idx, 1); + if (NILP (Fkeywordp (symbol)) + || !EQ (newval, Fsymbol_value (symbol))) + xsignal1 (Qsetting_constant, symbol); + else + /* Allow setting keywords to their own value. */ + return; } - else if (BUFFER_LOCAL_VALUEP (valcontents)) - { - /* valcontents is a struct Lisp_Buffer_Local_Value. */ - if (XSYMBOL (symbol)->indirect_variable) - XSETSYMBOL (symbol, indirect_variable (XSYMBOL (symbol))); - - /* What binding is loaded right now? */ - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - - /* If the current buffer is not the buffer whose binding is - loaded, or if there may be frame-local bindings and the frame - isn't the right one, or if it's a Lisp_Buffer_Local_Value and - the default binding is loaded, the loaded binding may be the - wrong one. */ - if (!BUFFERP (XBUFFER_LOCAL_VALUE (valcontents)->buffer) - || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) - || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame - && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)) - /* Also unload a global binding (if the var is local_if_set). */ - || (EQ (XCAR (current_alist_element), - current_alist_element))) - { - /* The currently loaded binding is not necessarily valid. - We need to unload it, and choose a new binding. */ - /* Write out `realvalue' to the old loaded binding. */ - Fsetcdr (current_alist_element, - do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); + sym = XSYMBOL (symbol); - /* Find the new binding. */ - tem1 = Fassq (symbol, buf->local_var_alist); - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; - - if (NILP (tem1)) - { - /* This buffer still sees the default value. */ - - /* If the variable is not local_if_set, - or if this is `let' rather than `set', - make CURRENT-ALIST-ELEMENT point to itself, - indicating that we're seeing the default value. - Likewise if the variable has been let-bound - in the current buffer. */ - if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set - || let_shadows_buffer_binding_p (XSYMBOL (symbol))) - { - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; - - if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) - tem1 = Fassq (symbol, - XFRAME (selected_frame)->param_alist); - - if (! NILP (tem1)) - XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1; - else - tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; - } - /* If it's a Lisp_Buffer_Local_Value, being set not bound, - and we're not within a let that was made for this buffer, - create a new buffer-local binding for the variable. - That means, give this buffer a new assoc for a local value - and load that binding. */ - else - { - tem1 = Fcons (symbol, XCDR (current_alist_element)); - buf->local_var_alist - = Fcons (tem1, buf->local_var_alist); - } - } + start: + switch (sym->redirect) + { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: SET_SYMBOL_VAL (sym , newval); return; + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + if (NILP (where)) + { + if (blv->frame_local) + where = selected_frame; + else + XSETBUFFER (where, current_buffer); + } + /* If the current buffer is not the buffer whose binding is + loaded, or if there may be frame-local bindings and the frame + isn't the right one, or if it's a Lisp_Buffer_Local_Value and + the default binding is loaded, the loaded binding may be the + wrong one. */ + if (!EQ (blv->where, where) + /* Also unload a global binding (if the var is local_if_set). */ + || (EQ (blv->valcell, blv->defcell))) + { + /* The currently loaded binding is not necessarily valid. + We need to unload it, and choose a new binding. */ + + /* Write out `realvalue' to the old loaded binding. */ + if (blv->fwd) + SET_BLV_VALUE (blv, do_symval_forwarding (blv->fwd)); + + /* Find the new binding. */ + XSETSYMBOL (symbol, sym); /* May have changed via aliasing. */ + tem1 = Fassq (symbol, + (blv->frame_local + ? XFRAME (where)->param_alist + : XBUFFER (where)->local_var_alist)); + blv->where = where; + blv->found = 1; + + if (NILP (tem1)) + { + /* This buffer still sees the default value. */ + + /* If the variable is a Lisp_Some_Buffer_Local_Value, + or if this is `let' rather than `set', + make CURRENT-ALIST-ELEMENT point to itself, + indicating that we're seeing the default value. + Likewise if the variable has been let-bound + in the current buffer. */ + if (bindflag || !blv->local_if_set + || let_shadows_buffer_binding_p (sym)) + { + blv->found = 0; + tem1 = blv->defcell; + } + /* If it's a local_if_set, being set not bound, + and we're not within a let that was made for this buffer, + create a new buffer-local binding for the variable. + That means, give this buffer a new assoc for a local value + and load that binding. */ + else + { + /* local_if_set is only supported for buffer-local + bindings, not for frame-local bindings. */ + eassert (!blv->frame_local); + tem1 = Fcons (symbol, XCDR (blv->defcell)); + XBUFFER (where)->local_var_alist + = Fcons (tem1, XBUFFER (where)->local_var_alist); + } + } + + /* Record which binding is now loaded. */ + blv->valcell = tem1; + } - /* Record which binding is now loaded. */ - XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1); + /* Store the new value in the cons cell. */ + SET_BLV_VALUE (blv, newval); - /* Set `buffer' and `frame' slots for the binding now loaded. */ - XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); - XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; - } - innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; + if (blv->fwd) + { + if (voide) + /* If storing void (making the symbol void), forward only through + buffer-local indicator, not through Lisp_Objfwd, etc. */ + blv->fwd = NULL; + else + store_symval_forwarding (blv->fwd, newval, + BUFFERP (where) + ? XBUFFER (where) : current_buffer); + } + break; + } + case SYMBOL_FORWARDED: + { + struct buffer *buf + = BUFFERP (where) ? XBUFFER (where) : current_buffer; + union Lisp_Fwd *innercontents = SYMBOL_FWD (sym); + if (BUFFER_OBJFWDP (innercontents)) + { + int offset = XBUFFER_OBJFWD (innercontents)->offset; + int idx = PER_BUFFER_IDX (offset); + if (idx > 0 + && !bindflag + && !let_shadows_buffer_binding_p (sym)) + SET_PER_BUFFER_VALUE_P (buf, idx, 1); + } - /* Store the new value in the cons-cell. */ - XSETCDR (XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr), newval); + if (voide) + { /* If storing void (making the symbol void), forward only through + buffer-local indicator, not through Lisp_Objfwd, etc. */ + sym->redirect = SYMBOL_PLAINVAL; + SET_SYMBOL_VAL (sym, newval); + } + else + store_symval_forwarding (/* sym, */ innercontents, newval, buf); + break; + } + default: abort (); } - - /* If storing void (making the symbol void), forward only through - buffer-local indicator, not through Lisp_Objfwd, etc. */ - if (voide) - store_symval_forwarding (symbol, Qnil, newval, buf); - else - store_symval_forwarding (symbol, innercontents, newval, buf); - - return newval; + return; } /* Access or set a buffer-local symbol's default value. */ @@ -1307,49 +1288,55 @@ set_internal (symbol, newval, buf, bindflag) Return Qunbound if it is void. */ Lisp_Object -default_value (symbol) - Lisp_Object symbol; +default_value (Lisp_Object symbol) { - register Lisp_Object valcontents; + struct Lisp_Symbol *sym; CHECK_SYMBOL (symbol); - valcontents = SYMBOL_VALUE (symbol); + sym = XSYMBOL (symbol); - /* For a built-in buffer-local variable, get the default value - rather than letting do_symval_forwarding get the current value. */ - if (BUFFER_OBJFWDP (valcontents)) + start: + switch (sym->redirect) { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - if (PER_BUFFER_IDX (offset) != 0) - return PER_BUFFER_DEFAULT (offset); - } + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym); + case SYMBOL_LOCALIZED: + { + /* If var is set up for a buffer that lacks a local value for it, + the current value is nominally the default value. + But the `realvalue' slot may be more up to date, since + ordinary setq stores just that slot. So use that. */ + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + if (blv->fwd && EQ (blv->valcell, blv->defcell)) + return do_symval_forwarding (blv->fwd); + else + return XCDR (blv->defcell); + } + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); - /* Handle user-created local variables. */ - if (BUFFER_LOCAL_VALUEP (valcontents)) - { - /* If var is set up for a buffer that lacks a local value for it, - the current value is nominally the default value. - But the `realvalue' slot may be more up to date, since - ordinary setq stores just that slot. So use that. */ - Lisp_Object current_alist_element, alist_element_car; - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - alist_element_car = XCAR (current_alist_element); - if (EQ (alist_element_car, current_alist_element)) - return do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue); - else - return XCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); + /* For a built-in buffer-local variable, get the default value + rather than letting do_symval_forwarding get the current value. */ + if (BUFFER_OBJFWDP (valcontents)) + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + if (PER_BUFFER_IDX (offset) != 0) + return PER_BUFFER_DEFAULT (offset); + } + + /* For other variables, get the current value. */ + return do_symval_forwarding (valcontents); + } + default: abort (); } - /* For other variables, get the current value. */ - return do_symval_forwarding (valcontents); } DEFUN ("default-boundp", Fdefault_boundp, Sdefault_boundp, 1, 1, 0, doc: /* Return t if SYMBOL has a non-void default value. This is the value that is seen in buffers that do not have their own values for this variable. */) - (symbol) - Lisp_Object symbol; + (Lisp_Object symbol) { register Lisp_Object value; @@ -1362,8 +1349,7 @@ DEFUN ("default-value", Fdefault_value, Sdefault_value, 1, 1, 0, This is the value that is seen in buffers that do not have their own values for this variable. The default value is meaningful for variables with local bindings in certain buffers. */) - (symbol) - Lisp_Object symbol; + (Lisp_Object symbol) { register Lisp_Object value; @@ -1378,53 +1364,70 @@ DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0, doc: /* Set SYMBOL's default value to VALUE. SYMBOL and VALUE are evaluated. The default value is seen in buffers that do not have their own values for this variable. */) - (symbol, value) - Lisp_Object symbol, value; + (Lisp_Object symbol, Lisp_Object value) { - register Lisp_Object valcontents, current_alist_element, alist_element_buffer; + struct Lisp_Symbol *sym; CHECK_SYMBOL (symbol); - valcontents = SYMBOL_VALUE (symbol); - - /* Handle variables like case-fold-search that have special slots - in the buffer. Make them work apparently like Lisp_Buffer_Local_Value - variables. */ - if (BUFFER_OBJFWDP (valcontents)) + if (SYMBOL_CONSTANT_P (symbol)) { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); + if (NILP (Fkeywordp (symbol)) + || !EQ (value, Fdefault_value (symbol))) + xsignal1 (Qsetting_constant, symbol); + else + /* Allow setting keywords to their own value. */ + return value; + } + sym = XSYMBOL (symbol); - PER_BUFFER_DEFAULT (offset) = value; + start: + switch (sym->redirect) + { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return Fset (symbol, value); + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); - /* If this variable is not always local in all buffers, - set it in the buffers that don't nominally have a local value. */ - if (idx > 0) - { - struct buffer *b; + /* Store new value into the DEFAULT-VALUE slot. */ + XSETCDR (blv->defcell, value); - for (b = all_buffers; b; b = b->next) - if (!PER_BUFFER_VALUE_P (b, idx)) - PER_BUFFER_VALUE (b, offset) = value; - } - return value; - } + /* If the default binding is now loaded, set the REALVALUE slot too. */ + if (blv->fwd && EQ (blv->defcell, blv->valcell)) + store_symval_forwarding (blv->fwd, value, NULL); + return value; + } + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); - if (!BUFFER_LOCAL_VALUEP (valcontents)) - return Fset (symbol, value); + /* Handle variables like case-fold-search that have special slots + in the buffer. + Make them work apparently like Lisp_Buffer_Local_Value variables. */ + if (BUFFER_OBJFWDP (valcontents)) + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + int idx = PER_BUFFER_IDX (offset); - /* Store new value into the DEFAULT-VALUE slot. */ - XSETCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, value); + PER_BUFFER_DEFAULT (offset) = value; - /* If the default binding is now loaded, set the REALVALUE slot too. */ - current_alist_element - = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); - alist_element_buffer = Fcar (current_alist_element); - if (EQ (alist_element_buffer, current_alist_element)) - store_symval_forwarding (symbol, - XBUFFER_LOCAL_VALUE (valcontents)->realvalue, - value, NULL); + /* If this variable is not always local in all buffers, + set it in the buffers that don't nominally have a local value. */ + if (idx > 0) + { + struct buffer *b; - return value; + for (b = all_buffers; b; b = b->next) + if (!PER_BUFFER_VALUE_P (b, idx)) + PER_BUFFER_VALUE (b, offset) = value; + } + return value; + } + else + return Fset (symbol, value); + } + default: abort (); + } } DEFUN ("setq-default", Fsetq_default, Ssetq_default, 0, UNEVALLED, 0, @@ -1440,8 +1443,7 @@ This sets each VAR's default value to the corresponding VALUE. The VALUE for the Nth VAR can refer to the new default values of previous VARs. usage: (setq-default [VAR VALUE]...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object args_left; register Lisp_Object val, symbol; @@ -1468,6 +1470,39 @@ usage: (setq-default [VAR VALUE]...) */) /* Lisp functions for creating and removing buffer-local variables. */ +union Lisp_Val_Fwd + { + Lisp_Object value; + union Lisp_Fwd *fwd; + }; + +static struct Lisp_Buffer_Local_Value * +make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) +{ + struct Lisp_Buffer_Local_Value *blv + = xmalloc (sizeof (struct Lisp_Buffer_Local_Value)); + Lisp_Object symbol; + Lisp_Object tem; + + XSETSYMBOL (symbol, sym); + tem = Fcons (symbol, (forwarded + ? do_symval_forwarding (valcontents.fwd) + : valcontents.value)); + + /* Buffer_Local_Values cannot have as realval a buffer-local + or keyboard-local forwarding. */ + eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd))); + eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd))); + blv->fwd = forwarded ? valcontents.fwd : NULL; + blv->where = Qnil; + blv->frame_local = 0; + blv->local_if_set = 0; + blv->defcell = tem; + blv->valcell = tem; + SET_BLV_FOUND (blv, 0); + return blv; +} + DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, Smake_variable_buffer_local, 1, 1, "vMake Variable Buffer Local: ", doc: /* Make VARIABLE become buffer-local whenever it is set. @@ -1482,45 +1517,60 @@ In most cases it is better to use `make-local-variable', which makes a variable local in just one buffer. The function `default-value' gets the default value and `set-default' sets it. */) - (variable) - register Lisp_Object variable; + (register Lisp_Object variable) { - register Lisp_Object tem, valcontents, newval; struct Lisp_Symbol *sym; + struct Lisp_Buffer_Local_Value *blv = NULL; + union Lisp_Val_Fwd valcontents; + int forwarded; CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); - - valcontents = sym->value; - if (sym->constant || KBOARD_OBJFWDP (valcontents)) - error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); + sym = XSYMBOL (variable); - if (BUFFER_OBJFWDP (valcontents)) - return variable; - else if (BUFFER_LOCAL_VALUEP (valcontents)) + start: + switch (sym->redirect) { - if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) - error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); - newval = valcontents; + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: + forwarded = 0; valcontents.value = SYMBOL_VAL (sym); + if (EQ (valcontents.value, Qunbound)) + valcontents.value = Qnil; + break; + case SYMBOL_LOCALIZED: + blv = SYMBOL_BLV (sym); + if (blv->frame_local) + error ("Symbol %s may not be buffer-local", + SDATA (SYMBOL_NAME (variable))); + break; + case SYMBOL_FORWARDED: + forwarded = 1; valcontents.fwd = SYMBOL_FWD (sym); + if (KBOARD_OBJFWDP (valcontents.fwd)) + error ("Symbol %s may not be buffer-local", + SDATA (SYMBOL_NAME (variable))); + else if (BUFFER_OBJFWDP (valcontents.fwd)) + return variable; + break; + default: abort (); } - else + + if (sym->constant) + error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); + + if (!blv) { - if (EQ (valcontents, Qunbound)) - sym->value = Qnil; - tem = Fcons (Qnil, Fsymbol_value (variable)); - XSETCAR (tem, tem); - newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; - XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); - XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; - XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - sym->value = newval; + blv = make_blv (sym, forwarded, valcontents); + sym->redirect = SYMBOL_LOCALIZED; + SET_SYMBOL_BLV (sym, blv); + { + Lisp_Object symbol; + XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ + if (let_shadows_global_binding_p (symbol)) + message ("Making %s buffer-local while let-bound!", + SDATA (SYMBOL_NAME (variable))); + } } - XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1; + + blv->local_if_set = 1; return variable; } @@ -1544,85 +1594,99 @@ See also `make-variable-buffer-local'. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. */) - (variable) - register Lisp_Object variable; + (register Lisp_Object variable) { - register Lisp_Object tem, valcontents; + register Lisp_Object tem; + int forwarded; + union Lisp_Val_Fwd valcontents; struct Lisp_Symbol *sym; + struct Lisp_Buffer_Local_Value *blv = NULL; CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); + sym = XSYMBOL (variable); - valcontents = sym->value; - if (sym->constant || KBOARD_OBJFWDP (valcontents) - || (BUFFER_LOCAL_VALUEP (valcontents) - && (XBUFFER_LOCAL_VALUE (valcontents)->check_frame))) - error ("Symbol %s may not be buffer-local", SDATA (sym->xname)); + start: + switch (sym->redirect) + { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: + forwarded = 0; valcontents.value = SYMBOL_VAL (sym); break; + case SYMBOL_LOCALIZED: + blv = SYMBOL_BLV (sym); + if (blv->frame_local) + error ("Symbol %s may not be buffer-local", + SDATA (SYMBOL_NAME (variable))); + break; + case SYMBOL_FORWARDED: + forwarded = 1; valcontents.fwd = SYMBOL_FWD (sym); + if (KBOARD_OBJFWDP (valcontents.fwd)) + error ("Symbol %s may not be buffer-local", + SDATA (SYMBOL_NAME (variable))); + break; + default: abort (); + } - if ((BUFFER_LOCAL_VALUEP (valcontents) - && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set) - || BUFFER_OBJFWDP (valcontents)) + if (sym->constant) + error ("Symbol %s may not be buffer-local", + SDATA (SYMBOL_NAME (variable))); + + if (blv ? blv->local_if_set + : (forwarded && BUFFER_OBJFWDP (valcontents.fwd))) { tem = Fboundp (variable); - /* Make sure the symbol has a local value in this particular buffer, by setting it to the same value it already has. */ Fset (variable, (EQ (tem, Qt) ? Fsymbol_value (variable) : Qunbound)); return variable; } - /* Make sure symbol is set up to hold per-buffer values. */ - if (!BUFFER_LOCAL_VALUEP (valcontents)) + if (!blv) { - Lisp_Object newval; - tem = Fcons (Qnil, do_symval_forwarding (valcontents)); - XSETCAR (tem, tem); - newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; - XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; - XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; - XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - sym->value = newval; + blv = make_blv (sym, forwarded, valcontents); + sym->redirect = SYMBOL_LOCALIZED; + SET_SYMBOL_BLV (sym, blv); + { + Lisp_Object symbol; + XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ + if (let_shadows_global_binding_p (symbol)) + message ("Making %s local to %s while let-bound!", + SDATA (SYMBOL_NAME (variable)), + SDATA (current_buffer->name)); + } } + /* Make sure this buffer has its own value of symbol. */ - XSETSYMBOL (variable, sym); /* Propagate variable indirections. */ + XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ tem = Fassq (variable, current_buffer->local_var_alist); if (NILP (tem)) { + if (let_shadows_buffer_binding_p (sym)) + message ("Making %s buffer-local while locally let-bound!", + SDATA (SYMBOL_NAME (variable))); + /* Swap out any local binding for some other buffer, and make sure the current value is permanently recorded, if it's the default value. */ find_symbol_value (variable); current_buffer->local_var_alist - = Fcons (Fcons (variable, XCDR (XBUFFER_LOCAL_VALUE (sym->value)->cdr)), + = Fcons (Fcons (variable, XCDR (blv->defcell)), current_buffer->local_var_alist); /* Make sure symbol does not think it is set up for this buffer; force it to look once again for this buffer's value. */ - { - Lisp_Object *pvalbuf; - - valcontents = sym->value; - - pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; - if (current_buffer == XBUFFER (*pvalbuf)) - *pvalbuf = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; - } + if (current_buffer == XBUFFER (blv->where)) + blv->where = Qnil; + /* blv->valcell = blv->defcell; + * SET_BLV_FOUND (blv, 0); */ + blv->found = 0; } /* If the symbol forwards into a C variable, then load the binding for this buffer now. If C code modifies the variable before we load the binding in, then that new value will clobber the default binding the next time we unload it. */ - valcontents = XBUFFER_LOCAL_VALUE (sym->value)->realvalue; - if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) - swap_in_symval_forwarding (variable, sym->value); + if (blv->fwd) + swap_in_symval_forwarding (sym, blv); return variable; } @@ -1631,34 +1695,45 @@ DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable, 1, 1, "vKill Local Variable: ", doc: /* Make VARIABLE no longer have a separate value in the current buffer. From now on the default value will apply in this buffer. Return VARIABLE. */) - (variable) - register Lisp_Object variable; + (register Lisp_Object variable) { - register Lisp_Object tem, valcontents; + register Lisp_Object tem; + struct Lisp_Buffer_Local_Value *blv; struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); - - valcontents = sym->value; + sym = XSYMBOL (variable); - if (BUFFER_OBJFWDP (valcontents)) + start: + switch (sym->redirect) { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - - if (idx > 0) - { - SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0); - PER_BUFFER_VALUE (current_buffer, offset) - = PER_BUFFER_DEFAULT (offset); - } - return variable; + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return variable; + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); + if (BUFFER_OBJFWDP (valcontents)) + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + int idx = PER_BUFFER_IDX (offset); + + if (idx > 0) + { + SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0); + PER_BUFFER_VALUE (current_buffer, offset) + = PER_BUFFER_DEFAULT (offset); + } + } + return variable; + } + case SYMBOL_LOCALIZED: + blv = SYMBOL_BLV (sym); + if (blv->frame_local) + return variable; + break; + default: abort (); } - if (!BUFFER_LOCAL_VALUEP (valcontents)) - return variable; - /* Get rid of this buffer's alist element, if any. */ XSETSYMBOL (variable, sym); /* Propagate variable indirection. */ tem = Fassq (variable, current_buffer->local_var_alist); @@ -1670,14 +1745,13 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) loaded, recompute its value. We have to do it now, or else forwarded objects won't work right. */ { - Lisp_Object *pvalbuf, buf; - valcontents = sym->value; - pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; - XSETBUFFER (buf, current_buffer); - if (EQ (buf, *pvalbuf)) + Lisp_Object buf; XSETBUFFER (buf, current_buffer); + if (EQ (buf, blv->where)) { - *pvalbuf = Qnil; - XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; + blv->where = Qnil; + /* blv->valcell = blv->defcell; + * SET_BLV_FOUND (blv, 0); */ + blv->found = 0; find_symbol_value (variable); } } @@ -1709,42 +1783,54 @@ is to set the VARIABLE frame parameter of that frame. See Note that since Emacs 23.1, variables cannot be both buffer-local and frame-local any more (buffer-local bindings used to take precedence over frame-local bindings). */) - (variable) - register Lisp_Object variable; + (register Lisp_Object variable) { - register Lisp_Object tem, valcontents, newval; + int forwarded; + union Lisp_Val_Fwd valcontents; struct Lisp_Symbol *sym; + struct Lisp_Buffer_Local_Value *blv = NULL; CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); + sym = XSYMBOL (variable); - valcontents = sym->value; - if (sym->constant || KBOARD_OBJFWDP (valcontents) - || BUFFER_OBJFWDP (valcontents)) - error ("Symbol %s may not be frame-local", SDATA (sym->xname)); - - if (BUFFER_LOCAL_VALUEP (valcontents)) + start: + switch (sym->redirect) { - if (!XBUFFER_LOCAL_VALUE (valcontents)->check_frame) - error ("Symbol %s may not be frame-local", SDATA (sym->xname)); - return variable; + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: + forwarded = 0; valcontents.value = SYMBOL_VAL (sym); + if (EQ (valcontents.value, Qunbound)) + valcontents.value = Qnil; + break; + case SYMBOL_LOCALIZED: + if (SYMBOL_BLV (sym)->frame_local) + return variable; + else + error ("Symbol %s may not be frame-local", + SDATA (SYMBOL_NAME (variable))); + case SYMBOL_FORWARDED: + forwarded = 1; valcontents.fwd = SYMBOL_FWD (sym); + if (KBOARD_OBJFWDP (valcontents.fwd) || BUFFER_OBJFWDP (valcontents.fwd)) + error ("Symbol %s may not be frame-local", + SDATA (SYMBOL_NAME (variable))); + break; + default: abort (); } - if (EQ (valcontents, Qunbound)) - sym->value = Qnil; - tem = Fcons (Qnil, Fsymbol_value (variable)); - XSETCAR (tem, tem); - newval = allocate_misc (); - XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; - XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value; - XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; - XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; - XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; - XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; - XBUFFER_LOCAL_VALUE (newval)->check_frame = 1; - XBUFFER_LOCAL_VALUE (newval)->cdr = tem; - sym->value = newval; + if (sym->constant) + error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); + + blv = make_blv (sym, forwarded, valcontents); + blv->frame_local = 1; + sym->redirect = SYMBOL_LOCALIZED; + SET_SYMBOL_BLV (sym, blv); + { + Lisp_Object symbol; + XSETSYMBOL (symbol, sym); /* In case `variable' is aliased. */ + if (let_shadows_global_binding_p (symbol)) + message ("Making %s frame-local while let-bound!", + SDATA (SYMBOL_NAME (variable))); + } return variable; } @@ -1752,10 +1838,8 @@ DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, 1, 2, 0, doc: /* Non-nil if VARIABLE has a local binding in buffer BUFFER. BUFFER defaults to the current buffer. */) - (variable, buffer) - register Lisp_Object variable, buffer; + (register Lisp_Object variable, Lisp_Object buffer) { - Lisp_Object valcontents; register struct buffer *buf; struct Lisp_Symbol *sym; @@ -1768,29 +1852,47 @@ BUFFER defaults to the current buffer. */) } CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); - XSETSYMBOL (variable, sym); + sym = XSYMBOL (variable); - valcontents = sym->value; - if (BUFFER_LOCAL_VALUEP (valcontents)) + start: + switch (sym->redirect) { - Lisp_Object tail, elt; + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return Qnil; + case SYMBOL_LOCALIZED: + { + Lisp_Object tail, elt, tmp; + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + XSETBUFFER (tmp, buf); + XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ - for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) - { - elt = XCAR (tail); - if (EQ (variable, XCAR (elt))) - return Qt; - } - } - if (BUFFER_OBJFWDP (valcontents)) - { - int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) - return Qt; + for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) + { + elt = XCAR (tail); + if (EQ (variable, XCAR (elt))) + { + eassert (!blv->frame_local); + eassert (BLV_FOUND (blv) || !EQ (blv->where, tmp)); + return Qt; + } + } + eassert (!BLV_FOUND (blv) || !EQ (blv->where, tmp)); + return Qnil; + } + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); + if (BUFFER_OBJFWDP (valcontents)) + { + int offset = XBUFFER_OBJFWD (valcontents)->offset; + int idx = PER_BUFFER_IDX (offset); + if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) + return Qt; + } + return Qnil; + } + default: abort (); } - return Qnil; } DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, @@ -1801,43 +1903,31 @@ while it does not have a `let'-style binding that was made in BUFFER, will produce a buffer local binding. See Info node `(elisp)Creating Buffer-Local'. BUFFER defaults to the current buffer. */) - (variable, buffer) - register Lisp_Object variable, buffer; + (register Lisp_Object variable, Lisp_Object buffer) { - Lisp_Object valcontents; - register struct buffer *buf; struct Lisp_Symbol *sym; - if (NILP (buffer)) - buf = current_buffer; - else - { - CHECK_BUFFER (buffer); - buf = XBUFFER (buffer); - } - CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); - XSETSYMBOL (variable, sym); + sym = XSYMBOL (variable); - valcontents = sym->value; - - if (BUFFER_OBJFWDP (valcontents)) - /* All these slots become local if they are set. */ - return Qt; - else if (BUFFER_LOCAL_VALUEP (valcontents)) + start: + switch (sym->redirect) { - Lisp_Object tail, elt; - if (XBUFFER_LOCAL_VALUE (valcontents)->local_if_set) - return Qt; - for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) - { - elt = XCAR (tail); - if (EQ (variable, XCAR (elt))) - return Qt; - } + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return Qnil; + case SYMBOL_LOCALIZED: + { + struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); + if (blv->local_if_set) + return Qt; + XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ + return Flocal_variable_p (variable, buffer); + } + case SYMBOL_FORWARDED: + /* All BUFFER_OBJFWD slots become local if they are set. */ + return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); + default: abort (); } - return Qnil; } DEFUN ("variable-binding-locus", Fvariable_binding_locus, Svariable_binding_locus, @@ -1846,39 +1936,48 @@ DEFUN ("variable-binding-locus", Fvariable_binding_locus, Svariable_binding_locu If the current binding is buffer-local, the value is the current buffer. If the current binding is frame-local, the value is the selected frame. If the current binding is global (the default), the value is nil. */) - (variable) - register Lisp_Object variable; + (register Lisp_Object variable) { - Lisp_Object valcontents; struct Lisp_Symbol *sym; CHECK_SYMBOL (variable); - sym = indirect_variable (XSYMBOL (variable)); + sym = XSYMBOL (variable); /* Make sure the current binding is actually swapped in. */ find_symbol_value (variable); - valcontents = sym->value; - - if (BUFFER_LOCAL_VALUEP (valcontents) - || BUFFER_OBJFWDP (valcontents)) + start: + switch (sym->redirect) { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: return Qnil; + case SYMBOL_FORWARDED: + { + union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); + if (KBOARD_OBJFWDP (valcontents)) + return Fframe_terminal (Fselected_frame ()); + else if (!BUFFER_OBJFWDP (valcontents)) + return Qnil; + } + /* FALLTHROUGH */ + case SYMBOL_LOCALIZED: /* For a local variable, record both the symbol and which buffer's or frame's value we are saving. */ if (!NILP (Flocal_variable_p (variable, Qnil))) return Fcurrent_buffer (); - else if (BUFFER_LOCAL_VALUEP (valcontents) - && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) - return XBUFFER_LOCAL_VALUE (valcontents)->frame; + else if (sym->redirect == SYMBOL_LOCALIZED + && BLV_FOUND (SYMBOL_BLV (sym))) + return SYMBOL_BLV (sym)->where; + else + return Qnil; + default: abort (); } - - return Qnil; } /* This code is disabled now that we use the selected frame to return keyboard-local-values. */ #if 0 -extern struct terminal *get_terminal P_ ((Lisp_Object display, int)); +extern struct terminal *get_terminal (Lisp_Object display, int); DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0, doc: /* Return the terminal-local value of SYMBOL on TERMINAL. @@ -1887,9 +1986,7 @@ value, like `symbol-value'. TERMINAL may be a terminal object, a frame, or nil (meaning the selected frame's terminal device). */) - (symbol, terminal) - Lisp_Object symbol; - Lisp_Object terminal; + (Lisp_Object symbol, Lisp_Object terminal) { Lisp_Object result; struct terminal *t = get_terminal (terminal, 1); @@ -1906,10 +2003,7 @@ binding, like `set'. TERMINAL may be a terminal object, a frame, or nil (meaning the selected frame's terminal device). */) - (symbol, terminal, value) - Lisp_Object symbol; - Lisp_Object terminal; - Lisp_Object value; + (Lisp_Object symbol, Lisp_Object terminal, Lisp_Object value) { Lisp_Object result; struct terminal *t = get_terminal (terminal, 1); @@ -1930,8 +2024,7 @@ selected frame's terminal device). */) This is like Findirect_function, except that it doesn't signal an error if the chain ends up unbound. */ Lisp_Object -indirect_function (object) - register Lisp_Object object; +indirect_function (register Lisp_Object object) { Lisp_Object tortoise, hare; @@ -1963,9 +2056,7 @@ If the final symbol in the chain is unbound, signal a void-function error. Optional arg NOERROR non-nil means to return nil instead of signalling. Signal a cyclic-function-indirection error if there is a loop in the function chain of symbols. */) - (object, noerror) - register Lisp_Object object; - Lisp_Object noerror; + (register Lisp_Object object, Lisp_Object noerror) { Lisp_Object result; @@ -1989,17 +2080,16 @@ DEFUN ("aref", Faref, Saref, 2, 2, 0, doc: /* Return the element of ARRAY at index IDX. ARRAY may be a vector, a string, a char-table, a bool-vector, or a byte-code object. IDX starts at 0. */) - (array, idx) - register Lisp_Object array; - Lisp_Object idx; + (register Lisp_Object array, Lisp_Object idx) { - register int idxval; + register EMACS_INT idxval; CHECK_NUMBER (idx); idxval = XINT (idx); if (STRINGP (array)) { - int c, idxval_byte; + int c; + EMACS_INT idxval_byte; if (idxval < 0 || idxval >= SCHARS (array)) args_out_of_range (array, idx); @@ -2045,11 +2135,9 @@ DEFUN ("aset", Faset, Saset, 3, 3, 0, doc: /* Store into the element of ARRAY at index IDX the value NEWELT. Return NEWELT. ARRAY may be a vector, a string, a char-table or a bool-vector. IDX starts at 0. */) - (array, idx, newelt) - register Lisp_Object array; - Lisp_Object idx, newelt; + (register Lisp_Object array, Lisp_Object idx, Lisp_Object newelt) { - register int idxval; + register EMACS_INT idxval; CHECK_NUMBER (idx); idxval = XINT (idx); @@ -2084,7 +2172,7 @@ bool-vector. IDX starts at 0. */) } else if (STRING_MULTIBYTE (array)) { - int idxval_byte, prev_bytes, new_bytes, nbytes; + EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; if (idxval < 0 || idxval >= SCHARS (array)) @@ -2095,23 +2183,23 @@ bool-vector. IDX starts at 0. */) idxval_byte = string_char_to_byte (array, idxval); p1 = SDATA (array) + idxval_byte; - PARSE_MULTIBYTE_SEQ (p1, nbytes - idxval_byte, prev_bytes); + prev_bytes = BYTES_BY_CHAR_HEAD (*p1); new_bytes = CHAR_STRING (XINT (newelt), p0); if (prev_bytes != new_bytes) { /* We must relocate the string data. */ - int nchars = SCHARS (array); + EMACS_INT nchars = SCHARS (array); unsigned char *str; USE_SAFE_ALLOCA; SAFE_ALLOCA (str, unsigned char *, nbytes); - bcopy (SDATA (array), str, nbytes); + memcpy (str, SDATA (array), nbytes); allocate_string_data (XSTRING (array), nchars, nbytes + new_bytes - prev_bytes); - bcopy (str, SDATA (array), idxval_byte); + memcpy (SDATA (array), str, idxval_byte); p1 = SDATA (array) + idxval_byte; - bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, - nbytes - (idxval_byte + prev_bytes)); + memcpy (p1 + new_bytes, str + idxval_byte + prev_bytes, + nbytes - (idxval_byte + prev_bytes)); SAFE_FREE (); clear_string_char_byte_cache (); } @@ -2147,9 +2235,7 @@ bool-vector. IDX starts at 0. */) enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; Lisp_Object -arithcompare (num1, num2, comparison) - Lisp_Object num1, num2; - enum comparison comparison; +arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) { double f1 = 0, f2 = 0; int floatp = 0; @@ -2203,24 +2289,21 @@ arithcompare (num1, num2, comparison) DEFUN ("=", Feqlsign, Seqlsign, 2, 2, 0, doc: /* Return t if two args, both numbers or markers, are equal. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, equal); } DEFUN ("<", Flss, Slss, 2, 2, 0, doc: /* Return t if first arg is less than second arg. Both must be numbers or markers. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, less); } DEFUN (">", Fgtr, Sgtr, 2, 2, 0, doc: /* Return t if first arg is greater than second arg. Both must be numbers or markers. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, grtr); } @@ -2228,8 +2311,7 @@ DEFUN (">", Fgtr, Sgtr, 2, 2, 0, DEFUN ("<=", Fleq, Sleq, 2, 2, 0, doc: /* Return t if first arg is less than or equal to second arg. Both must be numbers or markers. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, less_or_equal); } @@ -2237,24 +2319,21 @@ Both must be numbers or markers. */) DEFUN (">=", Fgeq, Sgeq, 2, 2, 0, doc: /* Return t if first arg is greater than or equal to second arg. Both must be numbers or markers. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, grtr_or_equal); } DEFUN ("/=", Fneq, Sneq, 2, 2, 0, doc: /* Return t if first arg is not equal to second arg. Both must be numbers or markers. */) - (num1, num2) - register Lisp_Object num1, num2; + (register Lisp_Object num1, Lisp_Object num2) { return arithcompare (num1, num2, notequal); } DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, doc: /* Return t if NUMBER is zero. */) - (number) - register Lisp_Object number; + (register Lisp_Object number) { CHECK_NUMBER_OR_FLOAT (number); @@ -2275,8 +2354,7 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, when the value fits in one. */ Lisp_Object -long_to_cons (i) - unsigned long i; +long_to_cons (long unsigned int i) { unsigned long top = i >> 16; unsigned int bot = i & 0xFFFF; @@ -2288,8 +2366,7 @@ long_to_cons (i) } unsigned long -cons_to_long (c) - Lisp_Object c; +cons_to_long (Lisp_Object c) { Lisp_Object top, bot; if (INTEGERP (c)) @@ -2305,8 +2382,7 @@ DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, doc: /* Return the decimal representation of NUMBER as a string. Uses a minus sign if negative. NUMBER may be an integer or a floating point number. */) - (number) - Lisp_Object number; + (Lisp_Object number) { char buffer[VALBITS]; @@ -2330,8 +2406,7 @@ NUMBER may be an integer or a floating point number. */) } INLINE static int -digit_to_number (character, base) - int character, base; +digit_to_number (int character, int base) { int digit; @@ -2358,8 +2433,7 @@ It ignores leading spaces and tabs, and all trailing chars. If BASE, interpret STRING as a number in that base. If BASE isn't present, base 10 is used. BASE must be between 2 and 16 (inclusive). If the base used is not 10, STRING is always parsed as integer. */) - (string, base) - register Lisp_Object string, base; + (register Lisp_Object string, Lisp_Object base) { register unsigned char *p; register int b; @@ -2426,15 +2500,10 @@ enum arithop Amin }; -static Lisp_Object float_arith_driver P_ ((double, int, enum arithop, - int, Lisp_Object *)); -extern Lisp_Object fmod_float (); - +static Lisp_Object float_arith_driver (double, int, enum arithop, + int, Lisp_Object *); Lisp_Object -arith_driver (code, nargs, args) - enum arithop code; - int nargs; - register Lisp_Object *args; +arith_driver (enum arithop code, int nargs, register Lisp_Object *args) { register Lisp_Object val; register int argnum; @@ -2519,12 +2588,7 @@ arith_driver (code, nargs, args) #define isnan(x) ((x) != (x)) static Lisp_Object -float_arith_driver (accum, argnum, code, nargs, args) - double accum; - register int argnum; - enum arithop code; - int nargs; - register Lisp_Object *args; +float_arith_driver (double accum, register int argnum, enum arithop code, int nargs, register Lisp_Object *args) { register Lisp_Object val; double next; @@ -2586,9 +2650,7 @@ float_arith_driver (accum, argnum, code, nargs, args) DEFUN ("+", Fplus, Splus, 0, MANY, 0, doc: /* Return sum of any number of arguments, which are numbers or markers. usage: (+ &rest NUMBERS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Aadd, nargs, args); } @@ -2598,9 +2660,7 @@ DEFUN ("-", Fminus, Sminus, 0, MANY, 0, With one arg, negates it. With more than one arg, subtracts all but the first from the first. usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Asub, nargs, args); } @@ -2608,9 +2668,7 @@ usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, doc: /* Return product of any number of arguments, which are numbers or markers. usage: (* &rest NUMBERS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Amult, nargs, args); } @@ -2619,9 +2677,7 @@ DEFUN ("/", Fquo, Squo, 2, MANY, 0, doc: /* Return first argument divided by all the remaining arguments. The arguments must be numbers or markers. usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { int argnum; for (argnum = 2; argnum < nargs; argnum++) @@ -2633,8 +2689,7 @@ usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) DEFUN ("%", Frem, Srem, 2, 2, 0, doc: /* Return remainder of X divided by Y. Both must be integers or markers. */) - (x, y) - register Lisp_Object x, y; + (register Lisp_Object x, Lisp_Object y) { Lisp_Object val; @@ -2675,8 +2730,7 @@ DEFUN ("mod", Fmod, Smod, 2, 2, 0, doc: /* Return X modulo Y. The result falls between zero (inclusive) and Y (exclusive). Both X and Y must be numbers or markers. */) - (x, y) - register Lisp_Object x, y; + (register Lisp_Object x, Lisp_Object y) { Lisp_Object val; EMACS_INT i1, i2; @@ -2707,9 +2761,7 @@ DEFUN ("max", Fmax, Smax, 1, MANY, 0, doc: /* Return largest of all the arguments (which must be numbers or markers). The value is always a number; markers are converted to numbers. usage: (max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Amax, nargs, args); } @@ -2718,9 +2770,7 @@ DEFUN ("min", Fmin, Smin, 1, MANY, 0, doc: /* Return smallest of all the arguments (which must be numbers or markers). The value is always a number; markers are converted to numbers. usage: (min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Amin, nargs, args); } @@ -2729,9 +2779,7 @@ DEFUN ("logand", Flogand, Slogand, 0, MANY, 0, doc: /* Return bitwise-and of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logand &rest INTS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Alogand, nargs, args); } @@ -2740,9 +2788,7 @@ DEFUN ("logior", Flogior, Slogior, 0, MANY, 0, doc: /* Return bitwise-or of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logior &rest INTS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Alogior, nargs, args); } @@ -2751,9 +2797,7 @@ DEFUN ("logxor", Flogxor, Slogxor, 0, MANY, 0, doc: /* Return bitwise-exclusive-or of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logxor &rest INTS-OR-MARKERS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return arith_driver (Alogxor, nargs, args); } @@ -2762,8 +2806,7 @@ DEFUN ("ash", Fash, Sash, 2, 2, 0, doc: /* Return VALUE with its bits shifted left by COUNT. If COUNT is negative, shifting is actually to the right. In this case, the sign bit is duplicated. */) - (value, count) - register Lisp_Object value, count; + (register Lisp_Object value, Lisp_Object count) { register Lisp_Object val; @@ -2785,8 +2828,7 @@ DEFUN ("lsh", Flsh, Slsh, 2, 2, 0, doc: /* Return VALUE with its bits shifted left by COUNT. If COUNT is negative, shifting is actually to the right. In this case, zeros are shifted in on the left. */) - (value, count) - register Lisp_Object value, count; + (register Lisp_Object value, Lisp_Object count) { register Lisp_Object val; @@ -2807,8 +2849,7 @@ In this case, zeros are shifted in on the left. */) DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0, doc: /* Return NUMBER plus one. NUMBER may be a number or a marker. Markers are converted to integers. */) - (number) - register Lisp_Object number; + (register Lisp_Object number) { CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (number); @@ -2822,8 +2863,7 @@ Markers are converted to integers. */) DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0, doc: /* Return NUMBER minus one. NUMBER may be a number or a marker. Markers are converted to integers. */) - (number) - register Lisp_Object number; + (register Lisp_Object number) { CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (number); @@ -2836,8 +2876,7 @@ Markers are converted to integers. */) DEFUN ("lognot", Flognot, Slognot, 1, 1, 0, doc: /* Return the bitwise complement of NUMBER. NUMBER must be an integer. */) - (number) - register Lisp_Object number; + (register Lisp_Object number) { CHECK_NUMBER (number); XSETINT (number, ~XINT (number)); @@ -2848,7 +2887,7 @@ DEFUN ("byteorder", Fbyteorder, Sbyteorder, 0, 0, 0, doc: /* Return the byteorder for the machine. Returns 66 (ASCII uppercase B) for big endian machines or 108 (ASCII lowercase l) for small endian machines. */) - () + (void) { unsigned i = 0x04030201; int order = *(char *)&i == 1 ? 108 : 66; @@ -2859,7 +2898,7 @@ lowercase l) for small endian machines. */) void -syms_of_data () +syms_of_data (void) { Lisp_Object error_tail, arith_tail; @@ -3288,14 +3327,8 @@ syms_of_data () } SIGTYPE -arith_error (signo) - int signo; -{ -#if defined(USG) && !defined(POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time */ - signal (signo, arith_error); -#endif /* USG */ +arith_error (int signo) +{ sigsetmask (SIGEMPTYMASK); SIGNAL_THREAD_CHECK (signo); @@ -3303,7 +3336,7 @@ arith_error (signo) } void -init_data () +init_data (void) { /* Don't do this if just dumping out. We don't want to call `signal' in this case diff --git a/src/dbusbind.c b/src/dbusbind.c index 60697c8a4e9..683b7cb583b 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -16,10 +16,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" +#include <config.h> #ifdef HAVE_DBUS -#include <stdlib.h> #include <stdio.h> #include <dbus/dbus.h> #include <setjmp.h> @@ -27,10 +26,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "frame.h" #include "termhooks.h" #include "keyboard.h" +#include "process.h" /* Subroutines. */ Lisp_Object Qdbus_init_bus; +Lisp_Object Qdbus_close_bus; Lisp_Object Qdbus_get_unique_name; Lisp_Object Qdbus_call_method; Lisp_Object Qdbus_call_method_asynchronously; @@ -59,6 +60,9 @@ Lisp_Object QCdbus_type_object_path, QCdbus_type_signature; Lisp_Object QCdbus_type_array, QCdbus_type_variant; Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; +/* Registered buses. */ +Lisp_Object Vdbus_registered_buses; + /* Hash table which keeps function definitions. */ Lisp_Object Vdbus_registered_objects_table; @@ -111,7 +115,7 @@ int xd_in_read_queued_messages = 0; } while (0) /* Macros for debugging. In order to enable them, build with - "make MYCPPFLAGS='-DDBUS_DEBUG -Wall'". */ + "MYCPPFLAGS='-DDBUS_DEBUG -Wall' make". */ #ifdef DBUS_DEBUG #define XD_DEBUG_MESSAGE(...) \ do { \ @@ -163,8 +167,7 @@ int xd_in_read_queued_messages = 0; /* Determine the DBusType of a given Lisp symbol. OBJECT must be one of the predefined D-Bus type symbols. */ static int -xd_symbol_to_dbus_type (object) - Lisp_Object object; +xd_symbol_to_dbus_type (Lisp_Object object) { return ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE @@ -221,10 +224,7 @@ xd_symbol_to_dbus_type (object) signature is embedded, or DBUS_TYPE_INVALID. It is needed for the check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ static void -xd_signature (signature, dtype, parent_type, object) - char *signature; - unsigned int dtype, parent_type; - Lisp_Object object; +xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lisp_Object object) { unsigned int subtype; Lisp_Object elt; @@ -393,10 +393,7 @@ xd_signature (signature, dtype, parent_type, object) `dbus-send-signal', into corresponding C values appended as arguments to a D-Bus message. */ static void -xd_append_arg (dtype, object, iter) - unsigned int dtype; - Lisp_Object object; - DBusMessageIter *iter; +xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) { char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; DBusMessageIter subiter; @@ -604,9 +601,7 @@ xd_append_arg (dtype, object, iter) D-Bus message must be a valid DBusType. Compound D-Bus types result always in a Lisp list. */ static Lisp_Object -xd_retrieve_arg (dtype, iter) - unsigned int dtype; - DBusMessageIter *iter; +xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) { switch (dtype) @@ -722,37 +717,79 @@ xd_retrieve_arg (dtype, iter) } } -/* Initialize D-Bus connection. BUS is a Lisp symbol, either :system - or :session. It tells which D-Bus to be initialized. */ +/* Initialize D-Bus connection. BUS is either a Lisp symbol, :system + or :session, or a string denoting the bus address. It tells which + D-Bus to initialize. If RAISE_ERROR is non-zero, signal an error + when the connection cannot be initialized. */ static DBusConnection * -xd_initialize (bus) - Lisp_Object bus; +xd_initialize (Lisp_Object bus, int raise_error) { DBusConnection *connection; DBusError derror; /* Parameter check. */ - CHECK_SYMBOL (bus); - if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus))) - XD_SIGNAL2 (build_string ("Wrong bus name"), bus); + if (!STRINGP (bus)) + { + CHECK_SYMBOL (bus); + if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus))) + { + if (raise_error) + XD_SIGNAL2 (build_string ("Wrong bus name"), bus); + else + return NULL; + } - /* We do not want to have an autolaunch for the session bus. */ - if (EQ (bus, QCdbus_session_bus) - && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL) - XD_SIGNAL2 (build_string ("No connection to bus"), bus); + /* We do not want to have an autolaunch for the session bus. */ + if (EQ (bus, QCdbus_session_bus) + && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL) + { + if (raise_error) + XD_SIGNAL2 (build_string ("No connection to bus"), bus); + else + return NULL; + } + } /* Open a connection to the bus. */ dbus_error_init (&derror); - if (EQ (bus, QCdbus_system_bus)) - connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); + if (STRINGP (bus)) + connection = dbus_connection_open (SDATA (bus), &derror); else - connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); + if (EQ (bus, QCdbus_system_bus)) + connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); + else + connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); if (dbus_error_is_set (&derror)) - XD_ERROR (derror); + { + if (raise_error) + XD_ERROR (derror); + else + connection = NULL; + } + + /* If it is not the system or session bus, we must register + ourselves. Otherwise, we have called dbus_bus_get, which has + configured us to exit if the connection closes - we undo this + setting. */ + if (connection != NULL) + { + if (STRINGP (bus)) + dbus_bus_register (connection, &derror); + else + dbus_connection_set_exit_on_disconnect (connection, FALSE); + } + + if (dbus_error_is_set (&derror)) + { + if (raise_error) + XD_ERROR (derror); + else + connection = NULL; + } - if (connection == NULL) + if (connection == NULL && raise_error) XD_SIGNAL2 (build_string ("No connection to bus"), bus); /* Cleanup. */ @@ -762,98 +799,107 @@ xd_initialize (bus) return connection; } - -/* Add connection file descriptor to input_wait_mask, in order to - let select() detect, whether a new message has been arrived. */ -dbus_bool_t -xd_add_watch (watch, data) - DBusWatch *watch; - void *data; +/* Return the file descriptor for WATCH, -1 if not found. */ +static int +xd_find_watch_fd (DBusWatch *watch) { - /* We check only for incoming data. */ - if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) - { #if HAVE_DBUS_WATCH_GET_UNIX_FD - /* TODO: Reverse these on Win32, which prefers the opposite. */ - int fd = dbus_watch_get_unix_fd(watch); - if (fd == -1) - fd = dbus_watch_get_socket(watch); + /* TODO: Reverse these on Win32, which prefers the opposite. */ + int fd = dbus_watch_get_unix_fd (watch); + if (fd == -1) + fd = dbus_watch_get_socket (watch); #else - int fd = dbus_watch_get_fd(watch); + int fd = dbus_watch_get_fd (watch); #endif - XD_DEBUG_MESSAGE ("fd %d", fd); + return fd; +} + +/* Prototype. */ +static void +xd_read_queued_messages (int fd, void *data, int for_read); - if (fd == -1) - return FALSE; +/* Start monitoring WATCH for possible I/O. */ +static dbus_bool_t +xd_add_watch (DBusWatch *watch, void *data) +{ + unsigned int flags = dbus_watch_get_flags (watch); + int fd = xd_find_watch_fd (watch); - /* Add the file descriptor to input_wait_mask. */ - add_keyboard_wait_descriptor (fd); - } + XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d", + fd, flags & DBUS_WATCH_WRITABLE, + dbus_watch_get_enabled (watch)); - /* Return. */ + if (fd == -1) + return FALSE; + + if (dbus_watch_get_enabled (watch)) + { + if (flags & DBUS_WATCH_WRITABLE) + add_write_fd (fd, xd_read_queued_messages, data); + if (flags & DBUS_WATCH_READABLE) + add_read_fd (fd, xd_read_queued_messages, data); + } return TRUE; } -/* Remove connection file descriptor from input_wait_mask. DATA is - the used bus, either QCdbus_system_bus or QCdbus_session_bus. */ -void -xd_remove_watch (watch, data) - DBusWatch *watch; - void *data; +/* Stop monitoring WATCH for possible I/O. + DATA is the used bus, either a string or QCdbus_system_bus or + QCdbus_session_bus. */ +static void +xd_remove_watch (DBusWatch *watch, void *data) { - /* We check only for incoming data. */ - if (dbus_watch_get_flags (watch) & DBUS_WATCH_READABLE) - { -#if HAVE_DBUS_WATCH_GET_UNIX_FD - /* TODO: Reverse these on Win32, which prefers the opposite. */ - int fd = dbus_watch_get_unix_fd(watch); - if (fd == -1) - fd = dbus_watch_get_socket(watch); -#else - int fd = dbus_watch_get_fd(watch); -#endif - XD_DEBUG_MESSAGE ("fd %d", fd); + unsigned int flags = dbus_watch_get_flags (watch); + int fd = xd_find_watch_fd (watch); - if (fd == -1) - return; + XD_DEBUG_MESSAGE ("fd %d", fd); - /* Unset session environment. */ - if ((data != NULL) && (data == (void*) XHASH (QCdbus_session_bus))) - { - XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); - unsetenv ("DBUS_SESSION_BUS_ADDRESS"); - } + if (fd == -1) + return; - /* Remove the file descriptor from input_wait_mask. */ - delete_keyboard_wait_descriptor (fd); + /* Unset session environment. */ + if (data != NULL && data == (void*) XHASH (QCdbus_session_bus)) + { + XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); + unsetenv ("DBUS_SESSION_BUS_ADDRESS"); } - /* Return. */ - return; + if (flags & DBUS_WATCH_WRITABLE) + delete_write_fd (fd); + if (flags & DBUS_WATCH_READABLE) + delete_read_fd (fd); +} + +/* Toggle monitoring WATCH for possible I/O. */ +static void +xd_toggle_watch (DBusWatch *watch, void *data) +{ + if (dbus_watch_get_enabled (watch)) + xd_add_watch (watch, data); + else + xd_remove_watch (watch, data); } DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, - doc: /* Initialize connection to D-Bus BUS. -This is an internal function, it shall not be used outside dbus.el. */) - (bus) - Lisp_Object bus; + doc: /* Initialize connection to D-Bus BUS. */) + (Lisp_Object bus) { DBusConnection *connection; - /* Check parameters. */ - CHECK_SYMBOL (bus); - /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Add the watch functions. We pass also the bus as data, in order to distinguish between the busses in xd_remove_watch. */ if (!dbus_connection_set_watch_functions (connection, xd_add_watch, xd_remove_watch, - NULL, (void*) XHASH (bus), NULL)) + xd_toggle_watch, + (void*) XHASH (bus), NULL)) XD_SIGNAL1 (build_string ("Cannot add watch functions")); + /* Add bus to list of registered buses. */ + Vdbus_registered_buses = Fcons (bus, Vdbus_registered_buses); + /* We do not want to abort. */ putenv ("DBUS_FATAL_WARNINGS=0"); @@ -861,20 +907,35 @@ This is an internal function, it shall not be used outside dbus.el. */) return Qnil; } +DEFUN ("dbus-close-bus", Fdbus_close_bus, Sdbus_close_bus, 1, 1, 0, + doc: /* Close connection to D-Bus BUS. */) + (Lisp_Object bus) +{ + DBusConnection *connection; + + /* Open a connection to the bus. */ + connection = xd_initialize (bus, TRUE); + + /* Decrement reference count to the bus. */ + dbus_connection_unref (connection); + + /* Remove bus from list of registered buses. */ + Vdbus_registered_buses = Fdelete (bus, Vdbus_registered_buses); + + /* Return. */ + return Qnil; +} + DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, 1, 1, 0, doc: /* Return the unique name of Emacs registered at D-Bus BUS. */) - (bus) - Lisp_Object bus; + (Lisp_Object bus) { DBusConnection *connection; const char *name; - /* Check parameters. */ - CHECK_SYMBOL (bus); - /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Request the name. */ name = dbus_bus_get_unique_name (connection); @@ -888,7 +949,8 @@ DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, DEFUN ("dbus-call-method", Fdbus_call_method, Sdbus_call_method, 5, MANY, 0, doc: /* Call METHOD on the D-Bus BUS. -BUS is either the symbol `:system' or the symbol `:session'. +BUS is either a Lisp symbol, `:system' or `:session', or a string +denoting the bus address. SERVICE is the D-Bus service name to be used. PATH is the D-Bus object path SERVICE is registered at. INTERFACE is an interface @@ -953,9 +1015,7 @@ object is returned instead of a list containing this single Lisp object. => "i686" usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, service, path, interface, method; Lisp_Object result; @@ -977,7 +1037,6 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI interface = args[3]; method = args[4]; - CHECK_SYMBOL (bus); CHECK_STRING (service); CHECK_STRING (path); CHECK_STRING (interface); @@ -991,7 +1050,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI SDATA (method)); /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create the message. */ dmessage = dbus_message_new_method_call (SDATA (service), @@ -1092,7 +1151,8 @@ DEFUN ("dbus-call-method-asynchronously", Fdbus_call_method_asynchronously, Sdbus_call_method_asynchronously, 6, MANY, 0, doc: /* Call METHOD on the D-Bus BUS asynchronously. -BUS is either the symbol `:system' or the symbol `:session'. +BUS is either a Lisp symbol, `:system' or `:session', or a string +denoting the bus address. SERVICE is the D-Bus service name to be used. PATH is the D-Bus object path SERVICE is registered at. INTERFACE is an interface @@ -1137,9 +1197,7 @@ Example: -| i686 usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, service, path, interface, method, handler; Lisp_Object result; @@ -1160,7 +1218,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE method = args[4]; handler = args[5]; - CHECK_SYMBOL (bus); CHECK_STRING (service); CHECK_STRING (path); CHECK_STRING (interface); @@ -1176,7 +1233,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE SDATA (method)); /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create the message. */ dmessage = dbus_message_new_method_call (SDATA (service), @@ -1248,9 +1305,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE result = Qnil; } - /* Flush connection to ensure the message is handled. */ - dbus_connection_flush (connection); - XD_DEBUG_MESSAGE ("Message sent"); /* Cleanup. */ @@ -1267,9 +1321,7 @@ DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal, This is an internal function, it shall not be used outside dbus.el. usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, serial, service; struct gcpro gcpro1, gcpro2, gcpro3; @@ -1285,7 +1337,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) serial = args[1]; service = args[2]; - CHECK_SYMBOL (bus); CHECK_NUMBER (serial); CHECK_STRING (service); GCPRO3 (bus, serial, service); @@ -1293,7 +1344,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service)); /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create the message. */ dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); @@ -1342,9 +1393,6 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) if (!dbus_connection_send (connection, dmessage, NULL)) XD_SIGNAL1 (build_string ("Cannot send message")); - /* Flush connection to ensure the message is handled. */ - dbus_connection_flush (connection); - XD_DEBUG_MESSAGE ("Message sent"); /* Cleanup. */ @@ -1361,9 +1409,7 @@ DEFUN ("dbus-method-error-internal", Fdbus_method_error_internal, This is an internal function, it shall not be used outside dbus.el. usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, serial, service; struct gcpro gcpro1, gcpro2, gcpro3; @@ -1379,7 +1425,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) serial = args[1]; service = args[2]; - CHECK_SYMBOL (bus); CHECK_NUMBER (serial); CHECK_STRING (service); GCPRO3 (bus, serial, service); @@ -1387,7 +1432,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service)); /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create the message. */ dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); @@ -1437,9 +1482,6 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) if (!dbus_connection_send (connection, dmessage, NULL)) XD_SIGNAL1 (build_string ("Cannot send message")); - /* Flush connection to ensure the message is handled. */ - dbus_connection_flush (connection); - XD_DEBUG_MESSAGE ("Message sent"); /* Cleanup. */ @@ -1452,7 +1494,8 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) DEFUN ("dbus-send-signal", Fdbus_send_signal, Sdbus_send_signal, 5, MANY, 0, doc: /* Send signal SIGNAL on the D-Bus BUS. -BUS is either the symbol `:system' or the symbol `:session'. +BUS is either a Lisp symbol, `:system' or `:session', or a string +denoting the bus address. SERVICE is the D-Bus service name SIGNAL is sent from. PATH is the D-Bus object path SERVICE is registered at. INTERFACE is an interface @@ -1478,9 +1521,7 @@ Example: "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs") usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, service, path, interface, signal; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; @@ -1498,7 +1539,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) interface = args[3]; signal = args[4]; - CHECK_SYMBOL (bus); CHECK_STRING (service); CHECK_STRING (path); CHECK_STRING (interface); @@ -1512,7 +1552,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) SDATA (signal)); /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create the message. */ dmessage = dbus_message_new_signal (SDATA (path), @@ -1557,9 +1597,6 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) if (!dbus_connection_send (connection, dmessage, NULL)) XD_SIGNAL1 (build_string ("Cannot send message")); - /* Flush connection to ensure the message is handled. */ - dbus_connection_flush (connection); - XD_DEBUG_MESSAGE ("Signal sent"); /* Cleanup. */ @@ -1569,80 +1606,26 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) return Qt; } -/* Check, whether there is pending input in the message queue of the - D-Bus BUS. BUS is a Lisp symbol, either :system or :session. */ -static Lisp_Object -xd_get_dispatch_status (bus) - Lisp_Object bus; -{ - DBusConnection *connection; - - /* Open a connection to the bus. */ - connection = xd_initialize (bus); - - /* Non blocking read of the next available message. */ - dbus_connection_read_write (connection, 0); - - /* Return. */ - return - (dbus_connection_get_dispatch_status (connection) - == DBUS_DISPATCH_DATA_REMAINS) - ? Qt : Qnil; -} - -/* Check for queued incoming messages from the system and session buses. */ -int -xd_pending_messages () -{ - int ret = FALSE; - xd_in_read_queued_messages = 1; - - /* Vdbus_registered_objects_table will be initialized as hash table - in dbus.el. When this package isn't loaded yet, it doesn't make - sense to handle D-Bus messages. */ - if (HASH_TABLE_P (Vdbus_registered_objects_table)) - { - ret = (!NILP (internal_catch (Qdbus_error, xd_get_dispatch_status, - QCdbus_system_bus))); - if (ret) goto theend; - - ret = ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL) && - (!NILP (internal_catch (Qdbus_error, xd_get_dispatch_status, - QCdbus_session_bus)))); - } - - /* Return. */ - theend: - xd_in_read_queued_messages = 0; - return ret; -} - -/* Read queued incoming message of the D-Bus BUS. BUS is a Lisp - symbol, either :system or :session. */ -static Lisp_Object -xd_read_message (bus) - Lisp_Object bus; +/* Read one queued incoming message of the D-Bus BUS. + BUS is either a Lisp symbol, :system or :session, or a string denoting + the bus address. */ +static void +xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) { Lisp_Object args, key, value; struct gcpro gcpro1; struct input_event event; - DBusConnection *connection; DBusMessage *dmessage; DBusMessageIter iter; unsigned int dtype; int mtype, serial; const char *uname, *path, *interface, *member; - /* Open a connection to the bus. */ - connection = xd_initialize (bus); - - /* Non blocking read of the next available message. */ - dbus_connection_read_write (connection, 0); dmessage = dbus_connection_pop_message (connection); /* Return if there is no queued message. */ if (dmessage == NULL) - return Qnil; + return; /* Collect the parameters. */ args = Qnil; @@ -1773,32 +1756,58 @@ xd_read_message (bus) cleanup: dbus_message_unref (dmessage); - RETURN_UNGCPRO (Qnil); + UNGCPRO; } -/* Read queued incoming messages from the system and session buses. */ -void -xd_read_queued_messages () +/* Read queued incoming messages of the D-Bus BUS. + BUS is either a Lisp symbol, :system or :session, or a string denoting + the bus address. */ +static Lisp_Object +xd_read_message (Lisp_Object bus) { + /* Open a connection to the bus. */ + DBusConnection *connection = xd_initialize (bus, TRUE); - /* Vdbus_registered_objects_table will be initialized as hash table - in dbus.el. When this package isn't loaded yet, it doesn't make - sense to handle D-Bus messages. Furthermore, we ignore all Lisp - errors during the call. */ - if (HASH_TABLE_P (Vdbus_registered_objects_table)) - { - xd_in_read_queued_messages = 1; - internal_catch (Qdbus_error, xd_read_message, QCdbus_system_bus); - internal_catch (Qdbus_error, xd_read_message, QCdbus_session_bus); - xd_in_read_queued_messages = 0; - } + /* Non blocking read of the next available message. */ + dbus_connection_read_write (connection, 0); + + while (dbus_connection_get_dispatch_status (connection) + != DBUS_DISPATCH_COMPLETE) + xd_read_message_1 (connection, bus); + return Qnil; +} + +/* Callback called when something is ready to read or write. */ +static void +xd_read_queued_messages (int fd, void *data, int for_read) +{ + Lisp_Object busp = Vdbus_registered_buses; + Lisp_Object bus = Qnil; + + /* Find bus related to fd. */ + if (data != NULL) + while (!NILP (busp)) + { + if (data == (void*) XHASH (CAR_SAFE (busp))) + bus = CAR_SAFE (busp); + busp = CDR_SAFE (busp); + } + + if (NILP(bus)) + return; + + /* We ignore all Lisp errors during the call. */ + xd_in_read_queued_messages = 1; + internal_catch (Qdbus_error, xd_read_message, bus); + xd_in_read_queued_messages = 0; } DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, 6, MANY, 0, doc: /* Register for signal SIGNAL on the D-Bus BUS. -BUS is either the symbol `:system' or the symbol `:session'. +BUS is either a Lisp symbol, `:system' or `:session', or a string +denoting the bus address. SERVICE is the D-Bus service name used by the sending D-Bus object. It can be either a known name or the unique name of the D-Bus object @@ -1833,9 +1842,7 @@ INTERFACE, SIGNAL and HANDLER must not be nil. Example: `dbus-unregister-object' for removing the registration. usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object bus, service, path, interface, signal, handler; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; @@ -1854,7 +1861,6 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG signal = args[4]; handler = args[5]; - CHECK_SYMBOL (bus); if (!NILP (service)) CHECK_STRING (service); if (!NILP (path)) CHECK_STRING (path); CHECK_STRING (interface); @@ -1886,7 +1892,7 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG if (NILP (uname) || (SBYTES (uname) > 0)) { /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Create a rule to receive related signals. */ sprintf (rule, @@ -1947,7 +1953,8 @@ DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method, 6, 6, 0, doc: /* Register for method METHOD on the D-Bus BUS. -BUS is either the symbol `:system' or the symbol `:session'. +BUS is either a Lisp symbol, `:system' or `:session', or a string +denoting the bus address. SERVICE is the D-Bus service name of the D-Bus object METHOD is registered for. It must be a known name. @@ -1957,8 +1964,7 @@ interface offered by SERVICE. It must provide METHOD. HANDLER is a Lisp function to be called when a method call is received. It must accept the input arguments of METHOD. The return value of HANDLER is used for composing the returning D-Bus message. */) - (bus, service, path, interface, method, handler) - Lisp_Object bus, service, path, interface, method, handler; + (Lisp_Object bus, Lisp_Object service, Lisp_Object path, Lisp_Object interface, Lisp_Object method, Lisp_Object handler) { Lisp_Object key, key1, value; DBusConnection *connection; @@ -1966,7 +1972,6 @@ used for composing the returning D-Bus message. */) DBusError derror; /* Check parameters. */ - CHECK_SYMBOL (bus); CHECK_STRING (service); CHECK_STRING (path); CHECK_STRING (interface); @@ -1977,7 +1982,7 @@ used for composing the returning D-Bus message. */) a segmentation fault. */ /* Open a connection to the bus. */ - connection = xd_initialize (bus); + connection = xd_initialize (bus, TRUE); /* Request the known name from the bus. We can ignore the result, it is set to -1 if there is an error - kind of redundancy. */ @@ -2004,13 +2009,17 @@ used for composing the returning D-Bus message. */) void -syms_of_dbusbind () +syms_of_dbusbind (void) { Qdbus_init_bus = intern_c_string ("dbus-init-bus"); staticpro (&Qdbus_init_bus); defsubr (&Sdbus_init_bus); + Qdbus_close_bus = intern_c_string ("dbus-close-bus"); + staticpro (&Qdbus_close_bus); + defsubr (&Sdbus_close_bus); + Qdbus_get_unique_name = intern_c_string ("dbus-get-unique-name"); staticpro (&Qdbus_get_unique_name); defsubr (&Sdbus_get_unique_name); @@ -2107,18 +2116,25 @@ syms_of_dbusbind () QCdbus_type_dict_entry = intern_c_string (":dict-entry"); staticpro (&QCdbus_type_dict_entry); + DEFVAR_LISP ("dbus-registered-buses", + &Vdbus_registered_buses, + doc: /* List of D-Bus buses we are polling for messages. */); + Vdbus_registered_buses = Qnil; + DEFVAR_LISP ("dbus-registered-objects-table", &Vdbus_registered_objects_table, doc: /* Hash table of registered functions for D-Bus. + There are two different uses of the hash table: for accessing registered interfaces properties, targeted by signals or method calls, and for calling handlers in case of non-blocking method call returns. In the first case, the key in the hash table is the list (BUS -INTERFACE MEMBER). BUS is either the symbol `:system' or the symbol -`:session'. INTERFACE is a string which denotes a D-Bus interface, -and MEMBER, also a string, is either a method, a signal or a property -INTERFACE is offering. All arguments but BUS must not be nil. +INTERFACE MEMBER). BUS is either a Lisp symbol, `:system' or +`:session', or a string denoting the bus address. INTERFACE is a +string which denotes a D-Bus interface, and MEMBER, also a string, is +either a method, a signal or a property INTERFACE is offering. All +arguments but BUS must not be nil. The value in the hash table is a list of quadruple lists \((UNAME SERVICE PATH OBJECT) (UNAME SERVICE PATH OBJECT) ...). @@ -2130,15 +2146,18 @@ be called when a D-Bus message, which matches the key criteria, arrives (methods and signals), or a cons cell containing the value of the property. -In the second case, the key in the hash table is the list (BUS SERIAL). -BUS is either the symbol `:system' or the symbol `:session'. SERIAL -is the serial number of the non-blocking method call, a reply is -expected. Both arguments must not be nil. The value in the hash -table is HANDLER, the function to be called when the D-Bus reply -message arrives. */); - /* We initialize Vdbus_registered_objects_table in dbus.el, because - we need to define a hash table function first. */ - Vdbus_registered_objects_table = Qnil; +In the second case, the key in the hash table is the list (BUS +SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a +string denoting the bus address. SERIAL is the serial number of the +non-blocking method call, a reply is expected. Both arguments must +not be nil. The value in the hash table is HANDLER, the function to +be called when the D-Bus reply message arrives. */); + { + Lisp_Object args[2]; + args[0] = QCtest; + args[1] = Qequal; + Vdbus_registered_objects_table = Fmake_hash_table (2, args); + } DEFVAR_LISP ("dbus-debug", &Vdbus_debug, doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); diff --git a/src/deps.mk b/src/deps.mk new file mode 100644 index 00000000000..eebf98ec003 --- /dev/null +++ b/src/deps.mk @@ -0,0 +1,281 @@ +### deps.mk --- src/Makefile fragment for GNU Emacs + +## Copyright (C) 1985, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, 2002, +## 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +## Free Software Foundation, Inc. + +## This file is part of GNU Emacs. + +## GNU Emacs is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## GNU Emacs is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +## Commentary: +## +## This file is inserted in src/Makefile if AUTO_DEPEND=no. +## It defines static dependencies between the various source files. + +## FIXME some of these dependencies are platform-specific. +## Eg callproc.c only depends on w32.h for WINDOWSNT builds. +## One way to fix this would be to replace w32.h (etc) by $(W32_H), +## a variable set by configure. Does not seem worth the trouble. +## Since the w32 build does not even use this file, you might ask +## why these dependencies are here at all... + +## nsgui.h: In fact, every .o file depends directly or indirectly on +## dispextern.h and hence nsgui.h under NS. But the ones that actually +## use stuff there are more limited. + +### Code: + +atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \ + $(config_h) +bidi.o: bidi.c buffer.h character.h dispextern.h lisp.h \ + biditype.h bidimirror.h $(config_h) +buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \ + $(INTERVALS_H) blockinput.h atimer.h systime.h character.h \ + indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h) +callint.o: callint.c window.h commands.h buffer.h keymap.h \ + keyboard.h dispextern.h systime.h coding.h composite.h lisp.h $(config_h) +callproc.o: callproc.c epaths.h buffer.h commands.h lisp.h $(config_h) \ + process.h systty.h syssignal.h character.h coding.h ccl.h msdos.h \ + composite.h w32.h blockinput.h atimer.h systime.h frame.h termhooks.h \ + buffer.h +casefiddle.o: casefiddle.c syntax.h commands.h buffer.h character.h \ + composite.h keymap.h lisp.h $(config_h) +casetab.o: casetab.c buffer.h character.h lisp.h $(config_h) +category.o: category.c category.h buffer.h charset.h keymap.h \ + character.h lisp.h $(config_h) +ccl.o: ccl.c ccl.h charset.h character.h coding.h composite.h lisp.h $(config_h) +character.o: character.c character.h buffer.h charset.h composite.h disptab.h \ + lisp.h $(config_h) +charset.o: charset.c charset.h character.h buffer.h coding.h composite.h \ + disptab.h lisp.h $(config_h) +chartab.o: charset.h character.h ccl.h lisp.h $(config_h) +coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \ + window.h dispextern.h frame.h termhooks.h lisp.h $(config_h) +cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h lisp.h $(config_h) +cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \ + $(config_h) msdos.h dispextern.h keyboard.h keymap.h systime.h \ + coding.h frame.h composite.h +pre-crt0.o: pre-crt0.c +dbusbind.o: dbusbind.c termhooks.h frame.h keyboard.h lisp.h $(config_h) +dired.o: dired.c commands.h buffer.h lisp.h $(config_h) character.h charset.h \ + coding.h regex.h systime.h blockinput.h atimer.h composite.h +dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \ + window.h buffer.h termchar.h termopts.h termhooks.h cm.h \ + disptab.h indent.h $(INTERVALS_H) nsgui.h \ + xterm.h blockinput.h atimer.h character.h msdos.h keyboard.h \ + syssignal.h lisp.h $(config_h) +doc.o: doc.c lisp.h $(config_h) epaths.h buffer.h keyboard.h keymap.h \ + character.h systime.h coding.h composite.h +doprnt.o: doprnt.c character.h lisp.h $(config_h) +dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \ + msdos.h dosfns.h dispextern.h charset.h coding.h atimer.h systime.h \ + lisp.h $(config_h) +editfns.o: editfns.c window.h buffer.h systime.h $(INTERVALS_H) character.h \ + coding.h frame.h blockinput.h atimer.h lisp.h $(config_h) +emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \ + termhooks.h buffer.h atimer.h systime.h $(INTERVALS_H) lisp.h $(config_h) \ + window.h dispextern.h keyboard.h keymap.h frame.h coding.h +fileio.o: fileio.c window.h buffer.h systime.h $(INTERVALS_H) character.h \ + coding.h msdos.h blockinput.h atimer.h lisp.h $(config_h) frame.h commands.h +filelock.o: filelock.c buffer.h character.h coding.h systime.h composite.h \ + lisp.h $(config_h) +filemode.o: filemode.c $(config_h) +frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \ + blockinput.h atimer.h systime.h buffer.h character.h fontset.h font.h \ + msdos.h dosfns.h dispextern.h w32term.h nsgui.h termchar.h coding.h \ + composite.h lisp.h $(config_h) termhooks.h ccl.h +fringe.o: fringe.c dispextern.h nsgui.h frame.h window.h buffer.h termhooks.h \ + blockinput.h atimer.h systime.h lisp.h $(config_h) +font.o: font.c dispextern.h frame.h window.h ccl.h character.h charset.h \ + font.h lisp.h $(config_h) buffer.h composite.h fontset.h xterm.h nsgui.h +ftfont.o: dispextern.h frame.h character.h charset.h composite.h font.h \ + lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h fontset.h \ + ccl.h ftfont.h +fontset.o: fontset.c fontset.h ccl.h buffer.h character.h \ + charset.h frame.h keyboard.h termhooks.h font.h lisp.h $(config_h) \ + blockinput.h atimer.h systime.h coding.h $(INTERVALS_H) nsgui.h \ + window.h xterm.h +getloadavg.o: getloadavg.c $(config_h) +gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \ + blockinput.h window.h atimer.h systime.h termhooks.h keyboard.h \ + charset.h coding.h syssignal.h dispextern.h composite.h +image.o: image.c frame.h window.h dispextern.h blockinput.h atimer.h \ + systime.h xterm.h w32term.h w32gui.h font.h epaths.h character.h coding.h \ + nsterm.h nsgui.h lisp.h $(config_h) composite.h termhooks.h ccl.h +indent.o: indent.c frame.h window.h indent.h buffer.h lisp.h $(config_h) \ + termchar.h termopts.h disptab.h region-cache.h character.h category.h \ + keyboard.h systime.h coding.h $(INTERVALS_H) +insdel.o: insdel.c window.h buffer.h $(INTERVALS_H) blockinput.h character.h \ + dispextern.h atimer.h systime.h region-cache.h lisp.h $(config_h) +keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h character.h \ + commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \ + systime.h syntax.h $(INTERVALS_H) blockinput.h atimer.h composite.h \ + xterm.h puresize.h msdos.h keymap.h w32term.h nsterm.h nsgui.h coding.h \ + lisp.h $(config_h) +keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \ + atimer.h systime.h puresize.h character.h charset.h $(INTERVALS_H) \ + keymap.h window.h coding.h frame.h lisp.h $(config_h) +lastfile.o: lastfile.c $(config_h) +macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \ + dispextern.h lisp.h $(config_h) systime.h coding.h composite.h +gmalloc.o: gmalloc.c $(config_h) +ralloc.o: ralloc.c lisp.h $(config_h) +vm-limit.o: vm-limit.c mem-limits.h lisp.h $(config_h) +marker.o: marker.c buffer.h character.h lisp.h $(config_h) +md5.o: md5.c md5.h $(config_h) +minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \ + buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \ + termhooks.h lisp.h $(config_h) coding.h +mktime.o: mktime.c $(config_h) +msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \ + termopts.h termchar.h character.h coding.h ccl.h disptab.h window.h \ + keyboard.h $(INTERVALS_H) buffer.h commands.h blockinput.h atimer.h \ + lisp.h sysselect.h $(config_h) +nsfns.o: nsfns.m charset.h nsterm.h nsgui.h frame.h window.h buffer.h \ + dispextern.h fontset.h $(INTERVALS_H) keyboard.h blockinput.h \ + atimer.h systime.h epaths.h termhooks.h coding.h systime.h lisp.h $(config_h) +nsfont.o: nsterm.h dispextern.h frame.h lisp.h lisp.h $(config_h) +nsimage.o: nsimage.m nsterm.h lisp.h $(config_h) +nsmenu.o: nsmenu.m termhooks.h frame.h window.h dispextern.h \ + nsgui.h keyboard.h blockinput.h atimer.h systime.h buffer.h \ + nsterm.h lisp.h $(config_h) +nsterm.o: nsterm.m blockinput.h atimer.h systime.h syssignal.h nsterm.h \ + nsgui.h frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h \ + termopts.h termchar.h disptab.h buffer.h window.h keyboard.h \ + $(INTERVALS_H) process.h coding.h lisp.h $(config_h) +nsselect.o: nsselect.m blockinput.h nsterm.h nsgui.h frame.h lisp.h $(config_h) +process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \ + commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \ + blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \ + keyboard.h lisp.h $(config_h) character.h xgselect.h sysselect.h +regex.o: regex.c syntax.h buffer.h lisp.h $(config_h) regex.h \ + category.h character.h +region-cache.o: region-cache.c buffer.h region-cache.h lisp.h $(config_h) +scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \ + termhooks.h lisp.h $(config_h) systime.h coding.h composite.h window.h +search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \ + blockinput.h atimer.h systime.h category.h character.h charset.h \ + $(INTERVALS_H) \ + lisp.h $(config_h) +sound.o: sound.c dispextern.h syssignal.h lisp.h $(config_h) atimer.h systime.h +strftime.o: strftime.c $(config_h) +syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \ + keymap.h regex.h $(INTERVALS_H) lisp.h $(config_h) +sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ + process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \ + frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \ + $(config_h) composite.h sysselect.h +term.o: term.c termchar.h termhooks.h termopts.h lisp.h $(config_h) \ + cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ + xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ + systty.h syssignal.h $(INTERVALS_H) buffer.h +termcap.o: termcap.c lisp.h $(config_h) +terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ + keyboard.h lisp.h $(config_h) dispextern.h composite.h systime.h +terminfo.o: terminfo.c lisp.h $(config_h) +tparam.o: tparam.c lisp.h $(config_h) +undo.o: undo.c buffer.h commands.h window.h dispextern.h lisp.h $(config_h) +unexaix.o: unexaix.c lisp.h $(config_h) +unexalpha.o: unexalpha.c $(config_h) +unexcw.o: unexcw.c lisp.h $(config_h) +unexcoff.o: unexcoff.c lisp.h $(config_h) +unexelf.o: unexelf.c $(config_h) +unexhp9k800.o: unexhp9k800.c $(config_h) +unexmacosx.o: unexmacosx.c $(config_h) +unexsol.o: unexsol.c lisp.h $(config_h) +unexw32.o: unexw32.c $(config_h) +w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \ + msdos.h buffer.h charset.h coding.h composite.h lisp.h $(config_h) +widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \ + $(srcdir)/../lwlib/lwlib.h lisp.h $(config_h) +window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \ + disptab.h keyboard.h msdos.h coding.h termhooks.h \ + keymap.h blockinput.h atimer.h systime.h $(INTERVALS_H) \ + xterm.h w32term.h nsterm.h nsgui.h lisp.h $(config_h) +xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h \ + coding.h termchar.h frame.h window.h disptab.h termhooks.h character.h \ + charset.h lisp.h $(config_h) keyboard.h $(INTERVALS_H) region-cache.h \ + xterm.h w32term.h nsterm.h nsgui.h msdos.h composite.h fontset.h ccl.h \ + blockinput.h atimer.h systime.h keymap.h font.h +xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \ + window.h character.h charset.h msdos.h dosfns.h composite.h atimer.h \ + systime.h keyboard.h fontset.h w32term.h nsterm.h coding.h ccl.h \ + $(INTERVALS_H) nsgui.h termchar.h termhooks.h font.h lisp.h $(config_h) +xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \ + $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \ + character.h charset.h coding.h gtkutil.h lisp.h $(config_h) termhooks.h \ + fontset.h termchar.h font.h xsettings.h $(INTERVALS_H) ccl.h +xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ + font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h +xftfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ + font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h ftfont.h +ftxfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \ + font.h lisp.h $(config_h) atimer.h systime.h fontset.h ccl.h +menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \ + dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \ + lisp.h $(config_h) systime.h coding.h composite.h window.h atimer.h nsgui.h +xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \ + charset.h keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h \ + systime.h gtkutil.h msdos.h coding.h menu.h lisp.h $(config_h) composite.h \ + keymap.h sysselect.h +xml.o: xml.c buffer.h lisp.h $(config_h) +xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h buffer.h \ + dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \ + keyboard.h emacs-icon.h character.h charset.h ccl.h fontset.h composite.h \ + coding.h process.h gtkutil.h font.h fontset.h lisp.h $(config_h) \ + xsettings.h intervals.h keymap.h xgselect.h sysselect.h +xselect.o: xselect.c process.h dispextern.h frame.h xterm.h blockinput.h \ + buffer.h atimer.h systime.h termhooks.h lisp.h $(config_h) keyboard.h \ + coding.h composite.h +xgselect.o: xgselect.h systime.h sysselect.h lisp.h $(config_h) +xrdb.o: xrdb.c lisp.h $(config_h) epaths.h +xsmfns.o: xsmfns.c lisp.h $(config_h) systime.h sysselect.h termhooks.h \ + xterm.h lisp.h termopts.h frame.h dispextern.h +xsettings.o: xterm.h xsettings.h lisp.h frame.h termhooks.h $(config_h) \ + dispextern.h keyboard.h systime.h coding.h composite.h blockinput.h \ + atimer.h termopts.h + +## The files of Lisp proper. +alloc.o: alloc.c process.h frame.h window.h buffer.h puresize.h syssignal.h \ + keyboard.h blockinput.h atimer.h systime.h character.h lisp.h $(config_h) \ + $(INTERVALS_H) termhooks.h +bytecode.o: bytecode.c buffer.h syntax.h character.h window.h dispextern.h \ + frame.h xterm.h lisp.h $(config_h) +data.o: data.c buffer.h puresize.h character.h syssignal.h keyboard.h frame.h \ + termhooks.h systime.h coding.h composite.h dispextern.h font.h ccl.h \ + lisp.h $(config_h) +eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \ + dispextern.h lisp.h $(config_h) coding.h composite.h xterm.h +floatfns.o: floatfns.c syssignal.h lisp.h $(config_h) +fns.o: fns.c commands.h lisp.h $(config_h) frame.h buffer.h character.h \ + keyboard.h keymap.h window.h dispextern.h $(INTERVALS_H) coding.h md5.h \ + blockinput.h atimer.h systime.h xterm.h +print.o: print.c process.h frame.h window.h buffer.h keyboard.h character.h \ + lisp.h $(config_h) termchar.h $(INTERVALS_H) msdos.h termhooks.h \ + blockinput.h atimer.h systime.h font.h charset.h coding.h ccl.h +lread.o: lread.c commands.h keyboard.h buffer.h epaths.h character.h \ + charset.h lisp.h $(config_h) $(INTERVALS_H) termhooks.h coding.h msdos.h \ + systime.h frame.h blockinput.h atimer.h + +## Text properties support. +composite.o: composite.c buffer.h character.h coding.h font.h ccl.h \ + frame.h termhooks.h $(INTERVALS_H) window.h lisp.h $(config_h) +intervals.o: intervals.c buffer.h $(INTERVALS_H) keyboard.h puresize.h \ + keymap.h lisp.h $(config_h) systime.h coding.h +textprop.o: textprop.c buffer.h window.h $(INTERVALS_H) \ + lisp.h $(config_h) + + +### deps.mk ends here diff --git a/src/dired.c b/src/dired.c index 92a768da5be..d72ea54a518 100644 --- a/src/dired.c +++ b/src/dired.c @@ -48,29 +48,22 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ Since applying strlen to the name always works, we'll just do that. */ #define NAMLEN(p) strlen (p->d_name) -#ifdef SYSV_SYSTEM_DIR +#ifdef HAVE_DIRENT_H #include <dirent.h> #define DIRENTRY struct dirent -#else /* not SYSV_SYSTEM_DIR */ +#else /* not HAVE_DIRENT_H */ -#ifdef MSDOS -#include <dirent.h> -#else #include <sys/dir.h> -#endif - #include <sys/stat.h> -#ifndef MSDOS #define DIRENTRY struct direct -extern DIR *opendir (); -extern struct direct *readdir (); +extern DIR *opendir (char *); +extern struct direct *readdir (DIR *); -#endif /* not MSDOS */ -#endif /* not SYSV_SYSTEM_DIR */ +#endif /* HAVE_DIRENT_H */ #ifdef MSDOS #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0) @@ -89,10 +82,12 @@ extern struct direct *readdir (); #include "blockinput.h" /* Returns a search buffer, with a fastmap allocated and ready to go. */ -extern struct re_pattern_buffer *compile_pattern (); +extern struct re_pattern_buffer *compile_pattern (Lisp_Object, + struct re_registers *, + Lisp_Object, int, int); /* From filemode.c. Can't go in Lisp.h because of `stat'. */ -extern void filemodestring P_ ((struct stat *, char *)); +extern void filemodestring (struct stat *, char *); /* if system does not have symbolic links, it does not have lstat. In that case, use ordinary stat instead. */ @@ -101,9 +96,6 @@ extern void filemodestring P_ ((struct stat *, char *)); #define lstat stat #endif -extern int completion_ignore_case; -extern Lisp_Object Qcompletion_ignore_case; -extern Lisp_Object Vcompletion_regexp_list; extern Lisp_Object Vw32_get_true_file_attributes; Lisp_Object Vcompletion_ignored_extensions; @@ -114,7 +106,7 @@ Lisp_Object Qfile_name_all_completions; Lisp_Object Qfile_attributes; Lisp_Object Qfile_attributes_lessp; -static int scmp P_ ((unsigned char *, unsigned char *, int)); +static int scmp (const unsigned char *, const unsigned char *, int); #ifdef WINDOWSNT Lisp_Object @@ -126,8 +118,7 @@ directory_files_internal_w32_unwind (Lisp_Object arg) #endif Lisp_Object -directory_files_internal_unwind (dh) - Lisp_Object dh; +directory_files_internal_unwind (Lisp_Object dh) { DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer; BLOCK_INPUT; @@ -142,10 +133,7 @@ directory_files_internal_unwind (dh) In the latter case, ID_FORMAT is passed to Ffile_attributes. */ Lisp_Object -directory_files_internal (directory, full, match, nosort, attrs, id_format) - Lisp_Object directory, full, match, nosort; - int attrs; - Lisp_Object id_format; +directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, int attrs, Lisp_Object id_format) { DIR *d; int directory_nbytes; @@ -209,7 +197,6 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) #ifdef WINDOWSNT if (attrs) { - extern Lisp_Object Qlocal; extern int is_slow_fs (const char *); /* Do this only once to avoid doing it (in w32.c:stat) for each @@ -292,15 +279,14 @@ directory_files_internal (directory, full, match, nosort, attrs, id_format) int nchars; fullname = make_uninit_multibyte_string (nbytes, nbytes); - bcopy (SDATA (directory), SDATA (fullname), - directory_nbytes); + memcpy (SDATA (fullname), SDATA (directory), + directory_nbytes); if (needsep) SSET (fullname, directory_nbytes, DIRECTORY_SEP); - bcopy (SDATA (name), - SDATA (fullname) + directory_nbytes + needsep, - len); + memcpy (SDATA (fullname) + directory_nbytes + needsep, + SDATA (name), len); nchars = chars_in_text (SDATA (fullname), nbytes); @@ -370,8 +356,7 @@ If MATCH is non-nil, mention only file names that match the regexp MATCH. If NOSORT is non-nil, the list is not sorted--its order is unpredictable. Otherwise, the list returned is sorted with `string-lessp'. NOSORT is useful if you plan to sort the result yourself. */) - (directory, full, match, nosort) - Lisp_Object directory, full, match, nosort; + (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort) { Lisp_Object handler; directory = Fexpand_file_name (directory, Qnil); @@ -399,8 +384,7 @@ ID-FORMAT specifies the preferred format of attributes uid and gid, see `file-attributes' for further documentation. On MS-Windows, performance depends on `w32-get-true-file-attributes', which see. */) - (directory, full, match, nosort, id_format) - Lisp_Object directory, full, match, nosort, id_format; + (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, Lisp_Object id_format) { Lisp_Object handler; directory = Fexpand_file_name (directory, Qnil); @@ -416,7 +400,7 @@ which see. */) } -Lisp_Object file_name_completion (); +Lisp_Object file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate); DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, 2, 3, 0, @@ -431,8 +415,7 @@ completion (in absolute form) and ignore it if PREDICATE returns nil. This function ignores some of the possible completions as determined by the variable `completion-ignored-extensions', which see. */) - (file, directory, predicate) - Lisp_Object file, directory, predicate; + (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate) { Lisp_Object handler; @@ -455,8 +438,7 @@ DEFUN ("file-name-all-completions", Ffile_name_all_completions, Sfile_name_all_completions, 2, 2, 0, doc: /* Return a list of all completions of file name FILE in directory DIRECTORY. These are all file names in directory DIRECTORY which begin with FILE. */) - (file, directory) - Lisp_Object file, directory; + (Lisp_Object file, Lisp_Object directory) { Lisp_Object handler; @@ -475,14 +457,11 @@ These are all file names in directory DIRECTORY which begin with FILE. */) return file_name_completion (file, directory, 1, 0, Qnil); } -static int file_name_completion_stat (); +static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); Lisp_Object Qdefault_directory; Lisp_Object -file_name_completion (file, dirname, all_flag, ver_flag, predicate) - Lisp_Object file, dirname; - int all_flag, ver_flag; - Lisp_Object predicate; +file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate) { DIR *d; int bestmatchsize = 0; @@ -824,9 +803,7 @@ file_name_completion (file, dirname, all_flag, ver_flag, predicate) else number of chars that match at the beginning. */ static int -scmp (s1, s2, len) - register unsigned char *s1, *s2; - int len; +scmp (const unsigned char *s1, const unsigned char *s2, int len) { register int l = len; @@ -847,10 +824,7 @@ scmp (s1, s2, len) } static int -file_name_completion_stat (dirname, dp, st_addr) - Lisp_Object dirname; - DIRENTRY *dp; - struct stat *st_addr; +file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr) { int len = NAMLEN (dp); int pos = SCHARS (dirname); @@ -858,7 +832,6 @@ file_name_completion_stat (dirname, dp, st_addr) char *fullname = (char *) alloca (len + pos + 2); #ifdef MSDOS -#if __DJGPP__ > 1 /* Some fields of struct stat are *very* expensive to compute on MS-DOS, but aren't required here. Avoid computing the following fields: st_inode, st_size and st_nlink for directories, and the execute bits @@ -867,14 +840,13 @@ file_name_completion_stat (dirname, dp, st_addr) unsigned short save_djstat_flags = _djstat_flags; _djstat_flags = _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE; -#endif /* __DJGPP__ > 1 */ #endif /* MSDOS */ - bcopy (SDATA (dirname), fullname, pos); + memcpy (fullname, SDATA (dirname), pos); if (!IS_DIRECTORY_SEP (fullname[pos - 1])) fullname[pos++] = DIRECTORY_SEP; - bcopy (dp->d_name, fullname + pos, len); + memcpy (fullname + pos, dp->d_name, len); fullname[pos + len] = 0; #ifdef S_IFLNK @@ -887,17 +859,14 @@ file_name_completion_stat (dirname, dp, st_addr) #else value = stat (fullname, st_addr); #ifdef MSDOS -#if __DJGPP__ > 1 _djstat_flags = save_djstat_flags; -#endif /* __DJGPP__ > 1 */ #endif /* MSDOS */ return value; #endif /* S_IFLNK */ } Lisp_Object -make_time (time) - time_t time; +make_time (time_t time) { return Fcons (make_number (time >> 16), Fcons (make_number (time & 0177777), Qnil)); @@ -976,16 +945,15 @@ which see. On some FAT-based filesystems, only the date of last access is recorded, so last access time will always be midnight of that day. */) - (filename, id_format) - Lisp_Object filename, id_format; + (Lisp_Object filename, Lisp_Object id_format) { Lisp_Object values[12]; Lisp_Object encoded; struct stat s; -#if defined (BSD4_2) || defined (BSD4_3) +#ifdef BSD4_2 Lisp_Object dirname; struct stat sdir; -#endif +#endif /* BSD4_2 */ char modes[10]; Lisp_Object handler; struct gcpro gcpro1; @@ -1052,7 +1020,7 @@ so last access time will always be midnight of that day. */) filemodestring (&s, modes); values[8] = make_string (modes, 10); -#if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ +#ifdef BSD4_2 /* file gid will be dir gid */ dirname = Ffile_name_directory (filename); if (! NILP (dirname)) encoded = ENCODE_FILE (dirname); @@ -1062,7 +1030,7 @@ so last access time will always be midnight of that day. */) values[9] = Qt; #else /* file gid will be egid */ values[9] = (s.st_gid != getegid ()) ? Qt : Qnil; -#endif /* BSD4_2 (or BSD4_3) */ +#endif /* not BSD4_2 */ if (!FIXNUM_OVERFLOW_P (s.st_ino)) /* Keep the most common cases as integers. */ values[10] = make_number (s.st_ino); @@ -1099,14 +1067,13 @@ so last access time will always be midnight of that day. */) DEFUN ("file-attributes-lessp", Ffile_attributes_lessp, Sfile_attributes_lessp, 2, 2, 0, doc: /* Return t if first arg file attributes list is less than second. Comparison is in lexicographic order and case is significant. */) - (f1, f2) - Lisp_Object f1, f2; + (Lisp_Object f1, Lisp_Object f2) { return Fstring_lessp (Fcar (f1), Fcar (f2)); } void -syms_of_dired () +syms_of_dired (void) { Qdirectory_files = intern_c_string ("directory-files"); Qdirectory_files_and_attributes = intern_c_string ("directory-files-and-attributes"); diff --git a/src/dispextern.h b/src/dispextern.h index ca91c5b6812..20e074d2393 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -372,6 +372,16 @@ struct glyph /* Non-zero means don't display cursor here. */ unsigned avoid_cursor_p : 1; + /* Resolved bidirectional level of this character [0..63]. */ + unsigned resolved_level : 5; + + /* Resolved bidirectional type of this character, see enum + bidi_type_t below. Note that according to UAX#9, only some + values (STRONG_L, STRONG_R, WEAK_AN, WEAK_EN, WEAK_BN, and + NEUTRAL_B) can appear in the resolved type, so we only reserve + space for those that can. */ + unsigned bidi_type : 3; + #define FACE_ID_BITS 20 /* Face of the glyph. This is a realized face ID, @@ -384,7 +394,15 @@ struct glyph w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */ unsigned font_type : 3; - struct glyph_slice slice; + /* A union of sub-structures for different glyph types. */ + union + { + /* Metrics of a partial glyph of an image (type == IMAGE_GLYPH). */ + struct glyph_slice img; + /* Start and end indices of glyphs of a graphme cluster of a + composition (type == COMPOSITE_GLYPH). */ + struct { int from, to; } cmp; + } slice; /* A union of sub-structures for different glyph types. */ union @@ -392,16 +410,13 @@ struct glyph /* Character code for character glyphs (type == CHAR_GLYPH). */ unsigned ch; - /* Sub-structures for type == COMPOSITION_GLYPH. */ + /* Sub-structures for type == COMPOSITE_GLYPH. */ struct { /* Flag to tell if the composition is automatic or not. */ unsigned automatic : 1; /* ID of the composition. */ - unsigned id : 23; - /* Start and end indices of glyphs of the composition. */ - unsigned from : 4; - unsigned to : 4; + unsigned id : 31; } cmp; /* Image ID for image glyphs (type == IMAGE_GLYPH). */ @@ -433,13 +448,21 @@ struct glyph #define CHAR_GLYPH_SPACE_P(GLYPH) \ ((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID) -/* Are glyph slices of glyphs *X and *Y equal */ +/* Are glyph slices of glyphs *X and *Y equal? It assumes that both + glyphs have the same type. + + Note: for composition glyphs, we don't have to compare slice.cmp.to + because they should be the same if and only if slice.cmp.from are + the same. */ -#define GLYPH_SLICE_EQUAL_P(X, Y) \ - ((X)->slice.x == (Y)->slice.x \ - && (X)->slice.y == (Y)->slice.y \ - && (X)->slice.width == (Y)->slice.width \ - && (X)->slice.height == (Y)->slice.height) +#define GLYPH_SLICE_EQUAL_P(X, Y) \ + ((X)->type == IMAGE_GLYPH \ + ? ((X)->slice.img.x == (Y)->slice.img.x \ + && (X)->slice.img.y == (Y)->slice.img.y \ + && (X)->slice.img.width == (Y)->slice.img.width \ + && (X)->slice.img.height == (Y)->slice.img.height) \ + : ((X)->type != COMPOSITE_GLYPH \ + || (X)->slice.cmp.from == (Y)->slice.cmp.from)) /* Are glyphs *X and *Y displayed equal? */ @@ -634,7 +657,7 @@ struct glyph_matrix This aborts if any pointer is found twice. */ #if GLYPH_DEBUG -void check_matrix_pointer_lossage P_ ((struct glyph_matrix *)); +void check_matrix_pointer_lossage (struct glyph_matrix *); #define CHECK_MATRIX(MATRIX) check_matrix_pointer_lossage ((MATRIX)) #else #define CHECK_MATRIX(MATRIX) (void) 0 @@ -740,17 +763,29 @@ struct glyph_row /* First position in this row. This is the text position, including overlay position information etc, where the display of this row - started, and can thus be less the position of the first glyph - (e.g. due to invisible text or horizontal scrolling). */ + started, and can thus be less than the position of the first + glyph (e.g. due to invisible text or horizontal scrolling). + BIDI Note: In R2L rows, that have its reversed_p flag set, this + position is at or beyond the right edge of the row. */ struct display_pos start; /* Text position at the end of this row. This is the position after the last glyph on this row. It can be greater than the last - glyph position + 1, due to truncation, invisible text etc. In an - up-to-date display, this should always be equal to the start - position of the next row. */ + glyph position + 1, due to a newline that ends the line, + truncation, invisible text etc. In an up-to-date display, this + should always be equal to the start position of the next row. + BIDI Note: In R2L rows, this position is at or beyond the left + edge of the row. */ struct display_pos end; + /* The smallest and the largest buffer positions that contributed to + glyphs in this row. Note that due to bidi reordering, these are + in general different from the text positions stored in `start' + and `end' members above, and also different from the buffer + positions recorded in the glyphs displayed the leftmost and + rightmost on the screen. */ + struct text_pos minpos, maxpos; + /* Non-zero means the overlay arrow bitmap is on this line. -1 means use default overlay arrow bitmap, else it specifies actual fringe bitmap number. */ @@ -880,6 +915,10 @@ struct glyph_row the bottom line of the window, but not end of the buffer. */ unsigned indicate_bottom_line_p : 1; + /* Non-zero means the row was reversed to display text in a + right-to-left paragraph. */ + unsigned reversed_p : 1; + /* Continuation lines width at the start of the row. */ int continuation_lines_width; @@ -896,7 +935,7 @@ struct glyph_row we don't try to access rows that are out of bounds. */ #if GLYPH_DEBUG -struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int)); +struct glyph_row *matrix_row (struct glyph_matrix *, int); #define MATRIX_ROW(MATRIX, ROW) matrix_row ((MATRIX), (ROW)) #else #define MATRIX_ROW(MATRIX, ROW) ((MATRIX)->rows + (ROW)) @@ -932,15 +971,21 @@ struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int)); (MATRIX_ROW ((MATRIX), (ROW))->used[TEXT_AREA]) /* Return the character/ byte position at which the display of ROW - starts. */ + starts. BIDI Note: this is the smallest character/byte position + among characters in ROW, i.e. the first logical-order character + displayed by ROW, which is not necessarily the smallest horizontal + position. */ -#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->start.pos.charpos) -#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->start.pos.bytepos) +#define MATRIX_ROW_START_CHARPOS(ROW) ((ROW)->minpos.charpos) +#define MATRIX_ROW_START_BYTEPOS(ROW) ((ROW)->minpos.bytepos) -/* Return the character/ byte position at which ROW ends. */ +/* Return the character/ byte position at which ROW ends. BIDI Note: + this is the largest character/byte position among characters in + ROW, i.e. the last logical-order character displayed by ROW, which + is not necessarily the largest horizontal position. */ -#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->end.pos.charpos) -#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->end.pos.bytepos) +#define MATRIX_ROW_END_CHARPOS(ROW) ((ROW)->maxpos.charpos) +#define MATRIX_ROW_END_BYTEPOS(ROW) ((ROW)->maxpos.bytepos) /* Return the vertical position of ROW in MATRIX. */ @@ -1086,17 +1131,9 @@ extern int cursor_in_echo_area; extern int display_completed; -/* Non-zero means redisplay has been performed directly (see also - direct_output_for_insert and direct_output_forward_char), so that - no further updating has to be performed. The function - redisplay_internal checks this flag, and does nothing but reset it - to zero if it is non-zero. */ - -extern int redisplay_performed_directly_p; - /* A temporary storage area, including a row of glyphs. Initialized in xdisp.c. Used for various purposes, as an example see - direct_output_for_insert. */ + get_overlay_arrow_glyph_row. */ extern struct glyph_row scratch_glyph_row; @@ -1710,7 +1747,93 @@ struct face_cache extern int face_change_count; +/* For reordering of bidirectional text. */ +#define BIDI_MAXLEVEL 64 + +/* Data type for describing the bidirectional character types. The + first 7 must be at the beginning, because they are the only values + valid in the `bidi_type' member of `struct glyph'; we only reserve + 3 bits for it, so we cannot use there values larger than 7. */ +typedef enum { + UNKNOWN_BT = 0, + STRONG_L, /* strong left-to-right */ + STRONG_R, /* strong right-to-left */ + WEAK_EN, /* european number */ + WEAK_AN, /* arabic number */ + WEAK_BN, /* boundary neutral */ + NEUTRAL_B, /* paragraph separator */ + STRONG_AL, /* arabic right-to-left letter */ + LRE, /* left-to-right embedding */ + LRO, /* left-to-right override */ + RLE, /* right-to-left embedding */ + RLO, /* right-to-left override */ + PDF, /* pop directional format */ + WEAK_ES, /* european number separator */ + WEAK_ET, /* european number terminator */ + WEAK_CS, /* common separator */ + WEAK_NSM, /* non-spacing mark */ + NEUTRAL_S, /* segment separator */ + NEUTRAL_WS, /* whitespace */ + NEUTRAL_ON /* other neutrals */ +} bidi_type_t; + +/* The basic directionality data type. */ +typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t; + +/* Data type for storing information about characters we need to + remember. */ +struct bidi_saved_info { + EMACS_INT bytepos, charpos; /* character's buffer position */ + bidi_type_t type; /* character's resolved bidi type */ + bidi_type_t type_after_w1; /* original type of the character, after W1 */ + bidi_type_t orig_type; /* type as we found it in the buffer */ +}; + +/* Data type for keeping track of saved embedding levels and override + status information. */ +struct bidi_stack { + int level; + bidi_dir_t override; +}; + +/* Data type for iterating over bidi text. */ +struct bidi_it { + EMACS_INT bytepos; /* iterator's position in buffer */ + EMACS_INT charpos; + int ch; /* character itself */ + int ch_len; /* length of its multibyte sequence */ + bidi_type_t type; /* bidi type of this character, after + resolving weak and neutral types */ + bidi_type_t type_after_w1; /* original type, after overrides and W1 */ + bidi_type_t orig_type; /* original type, as found in the buffer */ + int resolved_level; /* final resolved level of this character */ + int invalid_levels; /* how many PDFs to ignore */ + int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */ + int prev_was_pdf; /* if non-zero, previous char was PDF */ + struct bidi_saved_info prev; /* info about previous character */ + struct bidi_saved_info last_strong; /* last-seen strong directional char */ + struct bidi_saved_info next_for_neutral; /* surrounding characters for... */ + struct bidi_saved_info prev_for_neutral; /* ...resolving neutrals */ + struct bidi_saved_info next_for_ws; /* character after sequence of ws */ + EMACS_INT next_en_pos; /* position of next EN char for ET */ + EMACS_INT ignore_bn_limit; /* position until which to ignore BNs */ + bidi_dir_t sor; /* direction of start-of-run in effect */ + int scan_dir; /* direction of text scan, 1: forw, -1: back */ + int stack_idx; /* index of current data on the stack */ + /* Note: Everything from here on is not copied/saved when the bidi + iterator state is saved, pushed, or popped. So only put here + stuff that is not part of the bidi iterator's state! */ + struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */ + int first_elt; /* if non-zero, examine current char first */ + bidi_dir_t paragraph_dir; /* current paragraph direction */ + int new_paragraph; /* if non-zero, we expect a new paragraph */ + EMACS_INT separator_limit; /* where paragraph separator should end */ +}; +/* Value is non-zero when the bidi iterator is at base paragraph + embedding level. */ +#define BIDI_AT_BASE_LEVEL(BIDI_IT) \ + ((BIDI_IT).resolved_level == (BIDI_IT).level_stack[0].level) /*********************************************************************** @@ -1862,7 +1985,8 @@ enum it_method { NUM_IT_METHODS }; -#define IT_STACK_SIZE 4 +/* FIXME: What is this? Why 5? */ +#define IT_STACK_SIZE 5 /* Iterator for composition (both for static and automatic). */ struct composition_it @@ -1878,12 +2002,26 @@ struct composition_it temporarily if searching of composition reach a limit or a newline. */ int ch; - /* If this an automatic composition, how many characters to look back - from the position where a character triggering the composition - exists. */ + /* If this is an automatic composition, index of a rule for making + the automatic composition. Provided that ELT is an element of + Vcomposition_function_table for CH, (nth ELT RULE_IDX) is the + rule for the composition. */ + int rule_idx; + /* If this is an automatic composition, how many characters to look + back from the position where a character triggering the + composition exists. */ int lookback; /* If non-negative, number of glyphs of the glyph-string. */ int nglyphs; + /* Nonzero iff the composition is created while buffer is scanned in + reverse order, and thus the grapheme clusters must be rendered + from the last to the first. */ + int reversed_p; + + /** The following members contain information about the current + grapheme cluster. */ + /* Position of the first character of the current grapheme cluster. */ + EMACS_INT charpos; /* Number of characters and bytes of the current grapheme cluster. */ int nchars, nbytes; /* Indices of the glyphs for the current grapheme cluster. */ @@ -1910,6 +2048,14 @@ struct it text, overlay strings, end of text etc., which see. */ EMACS_INT stop_charpos; + /* Previous stop position, i.e. the last one before the current + iterator position in `current'. */ + EMACS_INT prev_stop; + + /* Last stop position iterated across whose bidi embedding level is + equal to the current paragraph's base embedding level. */ + EMACS_INT base_level_stop; + /* Maximum string or buffer position + 1. ZV when iterating over current_buffer. */ EMACS_INT end_charpos; @@ -1917,11 +2063,11 @@ struct it /* C string to iterate over. Non-null means get characters from this string, otherwise characters are read from current_buffer or it->string. */ - unsigned char *s; + const unsigned char *s; /* Number of characters in the string (s, or it->string) we iterate over. */ - int string_nchars; + EMACS_INT string_nchars; /* Start and end of a visible region; -1 if the region is not visible in the window. */ @@ -2016,6 +2162,8 @@ struct it int string_nchars; EMACS_INT end_charpos; EMACS_INT stop_charpos; + EMACS_INT prev_stop; + EMACS_INT base_level_stop; struct composition_it cmp_it; int face_id; @@ -2118,13 +2266,22 @@ struct it MODE_LINE_FACE_ID, etc, depending on what we are displaying. */ int base_face_id; - /* If what == IT_CHARACTER, character and length in bytes. This is - a character from a buffer or string. It may be different from - the character displayed in case that - unibyte_display_via_language_environment is set. + /* If `what' == IT_CHARACTER, the character and the length in bytes + of its multibyte sequence. The character comes from a buffer or + a string. It may be different from the character displayed in + case that unibyte_display_via_language_environment is set. + + If `what' == IT_COMPOSITION, the first component of a composition + and length in bytes of the composition. - If what == IT_COMPOSITION, the first component of a composition - and length in bytes of the composition. */ + If `what' is anything else, these two are undefined (will + probably hold values for the last IT_CHARACTER or IT_COMPOSITION + traversed by the iterator. + + The values are updated by get_next_display_element, so they are + out of sync with the value returned by IT_CHARPOS between the + time set_iterator_to_next advances the position and the time + get_next_display_element loads the new values into c and len. */ int c, len; /* If what == IT_COMPOSITION, iterator substructure for the @@ -2217,6 +2374,14 @@ struct it incremented/reset by display_line, move_it_to etc. */ int continuation_lines_width; + /* Buffer position that ends the buffer text line being iterated. + This is normally the position after the newline at EOL. If this + is the last line of the buffer and it doesn't have a newline, + value is ZV/ZV_BYTE. Set and used only if IT->bidi_p, for + setting the end position of glyph rows produced for continuation + lines, see display_line. */ + struct text_pos eol_pos; + /* Current y-position. Automatically incremented by the height of glyph_row in move_it_to and display_line. */ int current_y; @@ -2243,6 +2408,14 @@ struct it /* Face of the right fringe glyph. */ unsigned right_user_fringe_face_id : FACE_ID_BITS; + + /* Non-zero means we need to reorder bidirectional text for display + in the visual order. */ + int bidi_p; + + /* For iterating over bidirectional text. */ + struct bidi_it bidi_it; + bidi_dir_t paragraph_embedding; }; @@ -2272,7 +2445,13 @@ struct it #define PRODUCE_GLYPHS(IT) \ do { \ - extern int inhibit_free_realized_faces; \ + if ((IT)->glyph_row != NULL && (IT)->bidi_p) \ + { \ + if ((IT)->bidi_it.paragraph_dir == R2L) \ + (IT)->glyph_row->reversed_p = 1; \ + else \ + (IT)->glyph_row->reversed_p = 0; \ + } \ if (FRAME_RIF ((IT)->f) != NULL) \ FRAME_RIF ((IT)->f)->produce_glyphs ((IT)); \ else \ @@ -2321,7 +2500,7 @@ struct run /* Handlers for setting frame parameters. */ -typedef void (*frame_parm_handler) P_ ((struct frame *, Lisp_Object, Lisp_Object)); +typedef void (*frame_parm_handler) (struct frame *, Lisp_Object, Lisp_Object); /* Structure holding system-dependent interface functions needed @@ -2334,110 +2513,110 @@ struct redisplay_interface /* Produce glyphs/get display metrics for the display element IT is loaded with. */ - void (*produce_glyphs) P_ ((struct it *it)); + void (*produce_glyphs) (struct it *it); /* Write or insert LEN glyphs from STRING at the nominal output position. */ - void (*write_glyphs) P_ ((struct glyph *string, int len)); - void (*insert_glyphs) P_ ((struct glyph *start, int len)); + void (*write_glyphs) (struct glyph *string, int len); + void (*insert_glyphs) (struct glyph *start, int len); /* Clear from nominal output position to X. X < 0 means clear to right end of display. */ - void (*clear_end_of_line) P_ ((int x)); + void (*clear_end_of_line) (int x); /* Function to call to scroll the display as described by RUN on window W. */ - void (*scroll_run_hook) P_ ((struct window *w, struct run *run)); + void (*scroll_run_hook) (struct window *w, struct run *run); /* Function to call after a line in a display has been completely updated. Used to draw truncation marks and alike. DESIRED_ROW is the desired row which has been updated. */ - void (*after_update_window_line_hook) P_ ((struct glyph_row *desired_row)); + void (*after_update_window_line_hook) (struct glyph_row *desired_row); /* Function to call before beginning to update window W in window-based redisplay. */ - void (*update_window_begin_hook) P_ ((struct window *w)); + void (*update_window_begin_hook) (struct window *w); /* Function to call after window W has been updated in window-based redisplay. CURSOR_ON_P non-zero means switch cursor on. MOUSE_FACE_OVERWRITTEN_P non-zero means that some lines in W that contained glyphs in mouse-face were overwritten, so we have to update the mouse highlight. */ - void (*update_window_end_hook) P_ ((struct window *w, int cursor_on_p, - int mouse_face_overwritten_p)); + void (*update_window_end_hook) (struct window *w, int cursor_on_p, + int mouse_face_overwritten_p); /* Move cursor to row/column position VPOS/HPOS, pixel coordinates Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y are window-relative pixel positions. */ - void (*cursor_to) P_ ((int vpos, int hpos, int y, int x)); + void (*cursor_to) (int vpos, int hpos, int y, int x); /* Flush the display of frame F. For X, this is XFlush. */ - void (*flush_display) P_ ((struct frame *f)); + void (*flush_display) (struct frame *f); /* Flush the display of frame F if non-NULL. This is called during redisplay, and should be NULL on systems which flushes automatically before reading input. */ - void (*flush_display_optional) P_ ((struct frame *f)); + void (*flush_display_optional) (struct frame *f); /* Clear the mouse hightlight in window W, if there is any. */ - void (*clear_window_mouse_face) P_ ((struct window *w)); + void (*clear_window_mouse_face) (struct window *w); /* Set *LEFT and *RIGHT to the left and right overhang of GLYPH on frame F. */ - void (*get_glyph_overhangs) P_ ((struct glyph *glyph, struct frame *f, - int *left, int *right)); + void (*get_glyph_overhangs) (struct glyph *glyph, struct frame *f, + int *left, int *right); /* Fix the display of AREA of ROW in window W for overlapping rows. This function is called from redraw_overlapping_rows after desired rows have been made current. */ - void (*fix_overlapping_area) P_ ((struct window *w, struct glyph_row *row, - enum glyph_row_area area, int)); + void (*fix_overlapping_area) (struct window *w, struct glyph_row *row, + enum glyph_row_area area, int); #ifdef HAVE_WINDOW_SYSTEM /* Draw a fringe bitmap in window W of row ROW using parameters P. */ - void (*draw_fringe_bitmap) P_ ((struct window *w, struct glyph_row *row, - struct draw_fringe_bitmap_params *p)); + void (*draw_fringe_bitmap) (struct window *w, struct glyph_row *row, + struct draw_fringe_bitmap_params *p); /* Define and destroy fringe bitmap no. WHICH. */ - void (*define_fringe_bitmap) P_ ((int which, unsigned short *bits, - int h, int wd)); - void (*destroy_fringe_bitmap) P_ ((int which)); + void (*define_fringe_bitmap) (int which, unsigned short *bits, + int h, int wd); + void (*destroy_fringe_bitmap) (int which); /* Compute left and right overhang of glyph string S. A NULL pointer if platform does not support this. */ - void (*compute_glyph_string_overhangs) P_ ((struct glyph_string *s)); + void (*compute_glyph_string_overhangs) (struct glyph_string *s); /* Draw a glyph string S. */ - void (*draw_glyph_string) P_ ((struct glyph_string *s)); + void (*draw_glyph_string) (struct glyph_string *s); /* Define cursor CURSOR on frame F. */ - void (*define_frame_cursor) P_ ((struct frame *f, Cursor cursor)); + void (*define_frame_cursor) (struct frame *f, Cursor cursor); /* Clear the area at (X,Y,WIDTH,HEIGHT) of frame F. */ - void (*clear_frame_area) P_ ((struct frame *f, int x, int y, - int width, int height)); + void (*clear_frame_area) (struct frame *f, int x, int y, + int width, int height); /* Draw specified cursor CURSOR_TYPE of width CURSOR_WIDTH at row GLYPH_ROW on window W if ON_P is 1. If ON_P is 0, don't draw cursor. If ACTIVE_P is 1, system caret should track this cursor (when applicable). */ - void (*draw_window_cursor) P_ ((struct window *w, - struct glyph_row *glyph_row, - int x, int y, - int cursor_type, int cursor_width, - int on_p, int active_p)); + void (*draw_window_cursor) (struct window *w, + struct glyph_row *glyph_row, + int x, int y, + int cursor_type, int cursor_width, + int on_p, int active_p); /* Draw vertical border for window W from (X,Y0) to (X,Y1). */ - void (*draw_vertical_window_border) P_ ((struct window *w, - int x, int y0, int y1)); + void (*draw_vertical_window_border) (struct window *w, + int x, int y0, int y1); /* Shift display of frame F to make room for inserted glyphs. The area at pixel (X,Y) of width WIDTH and height HEIGHT is shifted right by SHIFT_BY pixels. */ - void (*shift_glyphs_for_insert) P_ ((struct frame *f, - int x, int y, int width, - int height, int shift_by)); + void (*shift_glyphs_for_insert) (struct frame *f, + int x, int y, int width, + int height, int shift_by); #endif /* HAVE_WINDOW_SYSTEM */ }; @@ -2464,14 +2643,14 @@ struct image_type /* Check that SPEC is a valid image specification for the given image type. Value is non-zero if SPEC is valid. */ - int (* valid_p) P_ ((Lisp_Object spec)); + int (* valid_p) (Lisp_Object spec); /* Load IMG which is used on frame F from information contained in IMG->spec. Value is non-zero if successful. */ - int (* load) P_ ((struct frame *f, struct image *img)); + int (* load) (struct frame *f, struct image *img); /* Free resources of image IMG which is used on frame F. */ - void (* free) P_ ((struct frame *f, struct image *img)); + void (* free) (struct frame *f, struct image *img); /* Next in list of all supported image types. */ struct image_type *next; @@ -2658,6 +2837,9 @@ enum tool_bar_item_idx /* Icon file name of right to left image when an RTL locale is used. */ TOOL_BAR_ITEM_RTL_IMAGE, + /* Label to show when text labels are enabled. */ + TOOL_BAR_ITEM_LABEL, + /* Sentinel = number of slots in tool_bar_items occupied by one tool-bar item. */ TOOL_BAR_ITEM_NSLOTS @@ -2679,6 +2861,15 @@ enum tool_bar_item_image extern Lisp_Object Vtool_bar_button_margin; +/* Tool bar style */ + +extern Lisp_Object Vtool_bar_style; + +/* Maximum number of characters a label can have to be shown. */ + +extern EMACS_INT tool_bar_max_label_size; +#define DEFAULT_TOOL_BAR_LABEL_SIZE 14 + /* Thickness of relief to draw around tool-bar buttons. */ extern EMACS_INT tool_bar_button_relief; @@ -2714,237 +2905,250 @@ extern EMACS_INT tool_bar_button_relief; Function Prototypes ***********************************************************************/ +/* Defined in bidi.c */ + +extern void bidi_init_it (EMACS_INT, EMACS_INT, struct bidi_it *); +extern void bidi_move_to_visually_next (struct bidi_it *); +extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, int); +extern int bidi_mirror_char (int); + /* Defined in xdisp.c */ -struct glyph_row *row_containing_pos P_ ((struct window *, int, - struct glyph_row *, - struct glyph_row *, int)); -int string_buffer_position P_ ((struct window *, Lisp_Object, int)); -int line_bottom_y P_ ((struct it *)); -int display_prop_intangible_p P_ ((Lisp_Object)); -void resize_echo_area_exactly P_ ((void)); -int resize_mini_window P_ ((struct window *, int)); -int try_window P_ ((Lisp_Object, struct text_pos, int)); -void window_box P_ ((struct window *, int, int *, int *, int *, int *)); -int window_box_height P_ ((struct window *)); -int window_text_bottom_y P_ ((struct window *)); -int window_box_width P_ ((struct window *, int)); -int window_box_left P_ ((struct window *, int)); -int window_box_left_offset P_ ((struct window *, int)); -int window_box_right P_ ((struct window *, int)); -int window_box_right_offset P_ ((struct window *, int)); -void window_box_edges P_ ((struct window *, int, int *, int *, int *, int *)); -int estimate_mode_line_height P_ ((struct frame *, enum face_id)); -void pixel_to_glyph_coords P_ ((struct frame *, int, int, int *, int *, - NativeRectangle *, int)); -int glyph_to_pixel_coords P_ ((struct window *, int, int, int *, int *)); -void remember_mouse_glyph P_ ((struct frame *, int, int, NativeRectangle *)); - -void mark_window_display_accurate P_ ((Lisp_Object, int)); -void redisplay_preserve_echo_area P_ ((int)); -int set_cursor_from_row P_ ((struct window *, struct glyph_row *, - struct glyph_matrix *, int, int, int, int)); -void init_iterator P_ ((struct it *, struct window *, int, - int, struct glyph_row *, enum face_id)); -void init_iterator_to_row_start P_ ((struct it *, struct window *, - struct glyph_row *)); -int get_next_display_element P_ ((struct it *)); -void set_iterator_to_next P_ ((struct it *, int)); -void start_display P_ ((struct it *, struct window *, struct text_pos)); -void move_it_to P_ ((struct it *, int, int, int, int, int)); -void move_it_vertically P_ ((struct it *, int)); -void move_it_vertically_backward P_ ((struct it *, int)); -void move_it_by_lines P_ ((struct it *, int, int)); -void move_it_past_eol P_ ((struct it *)); +struct glyph_row *row_containing_pos (struct window *, EMACS_INT, + struct glyph_row *, + struct glyph_row *, int); +EMACS_INT string_buffer_position (struct window *, Lisp_Object, + EMACS_INT); +int line_bottom_y (struct it *); +int display_prop_intangible_p (Lisp_Object); +void resize_echo_area_exactly (void); +int resize_mini_window (struct window *, int); +int try_window (Lisp_Object, struct text_pos, int); +void window_box (struct window *, int, int *, int *, int *, int *); +int window_box_height (struct window *); +int window_text_bottom_y (struct window *); +int window_box_width (struct window *, int); +int window_box_left (struct window *, int); +int window_box_left_offset (struct window *, int); +int window_box_right (struct window *, int); +int window_box_right_offset (struct window *, int); +void window_box_edges (struct window *, int, int *, int *, int *, int *); +int estimate_mode_line_height (struct frame *, enum face_id); +void pixel_to_glyph_coords (struct frame *, int, int, int *, int *, + NativeRectangle *, int); +int glyph_to_pixel_coords (struct window *, int, int, int *, int *); +void remember_mouse_glyph (struct frame *, int, int, NativeRectangle *); + +void mark_window_display_accurate (Lisp_Object, int); +void redisplay_preserve_echo_area (int); +int set_cursor_from_row (struct window *, struct glyph_row *, + struct glyph_matrix *, EMACS_INT, EMACS_INT, + int, int); +void init_iterator (struct it *, struct window *, EMACS_INT, + EMACS_INT, struct glyph_row *, enum face_id); +void init_iterator_to_row_start (struct it *, struct window *, + struct glyph_row *); +int get_next_display_element (struct it *); +void set_iterator_to_next (struct it *, int); +void start_display (struct it *, struct window *, struct text_pos); +void move_it_to (struct it *, EMACS_INT, int, int, int, int); +void move_it_vertically (struct it *, int); +void move_it_vertically_backward (struct it *, int); +void move_it_by_lines (struct it *, int, int); +void move_it_past_eol (struct it *); void move_it_in_display_line (struct it *it, EMACS_INT to_charpos, int to_x, enum move_operation_enum op); -int in_display_vector_p P_ ((struct it *)); -int frame_mode_line_height P_ ((struct frame *)); -void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *)); +int in_display_vector_p (struct it *); +int frame_mode_line_height (struct frame *); +void highlight_trailing_whitespace (struct frame *, struct glyph_row *); extern Lisp_Object Qtool_bar; extern Lisp_Object Vshow_trailing_whitespace; extern int mode_line_in_non_selected_windows; extern int redisplaying_p; -extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object)); extern int help_echo_showing_p; extern int current_mode_line_height, current_header_line_height; extern Lisp_Object help_echo_string, help_echo_window; extern Lisp_Object help_echo_object, previous_help_echo_string; -extern int help_echo_pos; +extern EMACS_INT help_echo_pos; extern struct frame *last_mouse_frame; extern int last_tool_bar_item; extern Lisp_Object Vmouse_autoselect_window; extern int unibyte_display_via_language_environment; extern EMACS_INT underline_minimum_offset; -extern void reseat_at_previous_visible_line_start P_ ((struct it *)); +extern void reseat_at_previous_visible_line_start (struct it *); -extern int calc_pixel_width_or_height P_ ((double *, struct it *, Lisp_Object, - struct font *, int, int *)); +extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, + struct font *, int, int *); #ifdef HAVE_WINDOW_SYSTEM #if GLYPH_DEBUG -extern void dump_glyph_string P_ ((struct glyph_string *)); +extern void dump_glyph_string (struct glyph_string *); #endif -extern void x_get_glyph_overhangs P_ ((struct glyph *, struct frame *, - int *, int *)); -extern void x_produce_glyphs P_ ((struct it *)); +extern void x_get_glyph_overhangs (struct glyph *, struct frame *, + int *, int *); +extern void x_produce_glyphs (struct it *); -extern void x_write_glyphs P_ ((struct glyph *, int)); -extern void x_insert_glyphs P_ ((struct glyph *, int len)); -extern void x_clear_end_of_line P_ ((int)); +extern void x_write_glyphs (struct glyph *, int); +extern void x_insert_glyphs (struct glyph *, int len); +extern void x_clear_end_of_line (int); extern int x_stretch_cursor_p; extern struct cursor_pos output_cursor; -extern void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *, - enum glyph_row_area, int)); -extern void draw_phys_cursor_glyph P_ ((struct window *, - struct glyph_row *, - enum draw_glyphs_face)); -extern void get_phys_cursor_geometry P_ ((struct window *, struct glyph_row *, - struct glyph *, int *, int *, int *)); -extern void erase_phys_cursor P_ ((struct window *)); -extern void display_and_set_cursor P_ ((struct window *, - int, int, int, int, int)); - -extern void set_output_cursor P_ ((struct cursor_pos *)); -extern void x_cursor_to P_ ((int, int, int, int)); - -extern void x_update_cursor P_ ((struct frame *, int)); -extern void x_clear_cursor P_ ((struct window *)); -extern void x_draw_vertical_border P_ ((struct window *w)); - -extern void frame_to_window_pixel_xy P_ ((struct window *, int *, int *)); -extern int get_glyph_string_clip_rects P_ ((struct glyph_string *, - NativeRectangle *, int)); -extern void get_glyph_string_clip_rect P_ ((struct glyph_string *, - NativeRectangle *nr)); -extern Lisp_Object find_hot_spot P_ ((Lisp_Object, int, int)); -extern void note_mouse_highlight P_ ((struct frame *, int, int)); -extern void x_clear_window_mouse_face P_ ((struct window *)); -extern void cancel_mouse_face P_ ((struct frame *)); - -extern void handle_tool_bar_click P_ ((struct frame *, - int, int, int, unsigned int)); +extern void x_fix_overlapping_area (struct window *, struct glyph_row *, + enum glyph_row_area, int); +extern void draw_phys_cursor_glyph (struct window *, + struct glyph_row *, + enum draw_glyphs_face); +extern void get_phys_cursor_geometry (struct window *, struct glyph_row *, + struct glyph *, int *, int *, int *); +extern void erase_phys_cursor (struct window *); +extern void display_and_set_cursor (struct window *, + int, int, int, int, int); + +extern void set_output_cursor (struct cursor_pos *); +extern void x_cursor_to (int, int, int, int); + +extern void x_update_cursor (struct frame *, int); +extern void x_clear_cursor (struct window *); +extern void x_draw_vertical_border (struct window *w); + +extern void frame_to_window_pixel_xy (struct window *, int *, int *); +extern int get_glyph_string_clip_rects (struct glyph_string *, + NativeRectangle *, int); +extern void get_glyph_string_clip_rect (struct glyph_string *, + NativeRectangle *nr); +extern Lisp_Object find_hot_spot (Lisp_Object, int, int); +extern void note_mouse_highlight (struct frame *, int, int); +extern void x_clear_window_mouse_face (struct window *); +extern void cancel_mouse_face (struct frame *); + +extern void handle_tool_bar_click (struct frame *, + int, int, int, unsigned int); /* msdos.c defines its own versions of these functions. */ -extern int clear_mouse_face P_ ((Display_Info *)); -extern void show_mouse_face P_ ((Display_Info *, enum draw_glyphs_face)); -extern int cursor_in_mouse_face_p P_ ((struct window *w)); +extern int clear_mouse_face (Display_Info *); +extern void show_mouse_face (Display_Info *, enum draw_glyphs_face); +extern int cursor_in_mouse_face_p (struct window *w); -extern void expose_frame P_ ((struct frame *, int, int, int, int)); -extern int x_intersect_rectangles P_ ((XRectangle *, XRectangle *, - XRectangle *)); +extern void expose_frame (struct frame *, int, int, int, int); +extern int x_intersect_rectangles (XRectangle *, XRectangle *, + XRectangle *); #endif +/* Flags passed to try_window. */ +#define TRY_WINDOW_CHECK_MARGINS (1 << 0) +#define TRY_WINDOW_IGNORE_FONTS_CHANGE (1 << 1) + /* Defined in fringe.c */ +extern Lisp_Object Voverflow_newline_into_fringe; int lookup_fringe_bitmap (Lisp_Object); -void draw_fringe_bitmap P_ ((struct window *, struct glyph_row *, int)); -void draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *)); -int draw_window_fringes P_ ((struct window *, int)); -int update_window_fringes P_ ((struct window *, int)); -void compute_fringe_widths P_ ((struct frame *, int)); +void draw_fringe_bitmap (struct window *, struct glyph_row *, int); +void draw_row_fringe_bitmaps (struct window *, struct glyph_row *); +int draw_window_fringes (struct window *, int); +int update_window_fringes (struct window *, int); +void compute_fringe_widths (struct frame *, int); #ifdef WINDOWSNT -void w32_init_fringe P_ ((struct redisplay_interface *)); -void w32_reset_fringes P_ ((void)); +void w32_init_fringe (struct redisplay_interface *); +void w32_reset_fringes (void); #endif /* Defined in image.c */ #ifdef HAVE_WINDOW_SYSTEM -extern int x_bitmap_height P_ ((struct frame *, int)); -extern int x_bitmap_width P_ ((struct frame *, int)); -extern int x_bitmap_pixmap P_ ((struct frame *, int)); -extern void x_reference_bitmap P_ ((struct frame *, int)); -extern int x_create_bitmap_from_data P_ ((struct frame *, char *, - unsigned int, unsigned int)); -extern int x_create_bitmap_from_file P_ ((struct frame *, Lisp_Object)); +extern int x_bitmap_height (struct frame *, int); +extern int x_bitmap_width (struct frame *, int); +extern int x_bitmap_pixmap (struct frame *, int); +extern void x_reference_bitmap (struct frame *, int); +extern int x_create_bitmap_from_data (struct frame *, char *, + unsigned int, unsigned int); +extern int x_create_bitmap_from_file (struct frame *, Lisp_Object); #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) -extern int x_create_bitmap_from_xpm_data P_ ((struct frame *f, char **bits)); +extern int x_create_bitmap_from_xpm_data (struct frame *f, char **bits); #endif #ifndef x_destroy_bitmap -extern void x_destroy_bitmap P_ ((struct frame *, int)); +extern void x_destroy_bitmap (struct frame *, int); #endif -extern void x_destroy_all_bitmaps P_ ((Display_Info *)); -extern int x_create_bitmap_mask P_ ((struct frame * , int)); -extern Lisp_Object x_find_image_file P_ ((Lisp_Object)); - -void x_kill_gs_process P_ ((Pixmap, struct frame *)); -struct image_cache *make_image_cache P_ ((void)); -void free_image_cache P_ ((struct frame *)); -void clear_image_caches P_ ((Lisp_Object)); -void mark_image_cache P_ ((struct image_cache *)); -int valid_image_p P_ ((Lisp_Object)); -void prepare_image_for_display P_ ((struct frame *, struct image *)); -int lookup_image P_ ((struct frame *, Lisp_Object)); - -unsigned long image_background P_ ((struct image *, struct frame *, - XImagePtr_or_DC ximg)); -int image_background_transparent P_ ((struct image *, struct frame *, - XImagePtr_or_DC mask)); - -int image_ascent P_ ((struct image *, struct face *, struct glyph_slice *)); +extern void x_destroy_all_bitmaps (Display_Info *); +extern int x_create_bitmap_mask (struct frame * , int); +extern Lisp_Object x_find_image_file (Lisp_Object); + +void x_kill_gs_process (Pixmap, struct frame *); +struct image_cache *make_image_cache (void); +void free_image_cache (struct frame *); +void clear_image_caches (Lisp_Object); +void mark_image_cache (struct image_cache *); +int valid_image_p (Lisp_Object); +void prepare_image_for_display (struct frame *, struct image *); +int lookup_image (struct frame *, Lisp_Object); + +unsigned long image_background (struct image *, struct frame *, + XImagePtr_or_DC ximg); +int image_background_transparent (struct image *, struct frame *, + XImagePtr_or_DC mask); + +int image_ascent (struct image *, struct face *, struct glyph_slice *); #endif /* Defined in sysdep.c */ -void get_tty_size P_ ((int, int *, int *)); -void request_sigio P_ ((void)); -void unrequest_sigio P_ ((void)); -int tabs_safe_p P_ ((int)); -void init_baud_rate P_ ((int)); -void init_sigio P_ ((int)); +void get_tty_size (int, int *, int *); +void request_sigio (void); +void unrequest_sigio (void); +int tabs_safe_p (int); +void init_baud_rate (int); +void init_sigio (int); /* Defined in xfaces.c */ #ifdef HAVE_X_WINDOWS -void x_free_colors P_ ((struct frame *, unsigned long *, int)); +void x_free_colors (struct frame *, unsigned long *, int); #endif -void update_face_from_frame_parameter P_ ((struct frame *, Lisp_Object, - Lisp_Object)); -Lisp_Object tty_color_name P_ ((struct frame *, int)); -void clear_face_cache P_ ((int)); -unsigned long load_color P_ ((struct frame *, struct face *, Lisp_Object, - enum lface_attribute_index)); -void unload_color P_ ((struct frame *, unsigned long)); -char *choose_face_font P_ ((struct frame *, Lisp_Object *, Lisp_Object, - int *)); -int ascii_face_of_lisp_face P_ ((struct frame *, int)); -void prepare_face_for_display P_ ((struct frame *, struct face *)); -int xstrcasecmp P_ ((const unsigned char *, const unsigned char *)); -int lookup_face P_ ((struct frame *, Lisp_Object *)); -int lookup_named_face P_ ((struct frame *, Lisp_Object, int)); -int lookup_basic_face P_ ((struct frame *, int)); -int smaller_face P_ ((struct frame *, int, int)); -int face_with_height P_ ((struct frame *, int, int)); -int lookup_derived_face P_ ((struct frame *, Lisp_Object, int, int)); -void init_frame_faces P_ ((struct frame *)); -void free_frame_faces P_ ((struct frame *)); -void recompute_basic_faces P_ ((struct frame *)); -int face_at_buffer_position P_ ((struct window *w, EMACS_INT pos, - EMACS_INT region_beg, EMACS_INT region_end, - EMACS_INT *endptr, EMACS_INT limit, - int mouse, int base_face_id)); -int face_for_overlay_string P_ ((struct window *w, EMACS_INT pos, - EMACS_INT region_beg, EMACS_INT region_end, - EMACS_INT *endptr, EMACS_INT limit, - int mouse, Lisp_Object overlay)); -int face_at_string_position P_ ((struct window *w, Lisp_Object string, - EMACS_INT pos, EMACS_INT bufpos, - EMACS_INT region_beg, EMACS_INT region_end, - EMACS_INT *endptr, enum face_id, int mouse)); -int merge_faces P_ ((struct frame *, Lisp_Object, int, int)); -int compute_char_face P_ ((struct frame *, int, Lisp_Object)); -void free_all_realized_faces P_ ((Lisp_Object)); -void free_realized_face P_ ((struct frame *, struct face *)); +void update_face_from_frame_parameter (struct frame *, Lisp_Object, + Lisp_Object); +Lisp_Object tty_color_name (struct frame *, int); +void clear_face_cache (int); +unsigned long load_color (struct frame *, struct face *, Lisp_Object, + enum lface_attribute_index); +void unload_color (struct frame *, unsigned long); +char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object, + int *); +int ascii_face_of_lisp_face (struct frame *, int); +void prepare_face_for_display (struct frame *, struct face *); +int xstrcasecmp (const unsigned char *, const unsigned char *); +int lookup_face (struct frame *, Lisp_Object *); +int lookup_named_face (struct frame *, Lisp_Object, int); +int lookup_basic_face (struct frame *, int); +int smaller_face (struct frame *, int, int); +int face_with_height (struct frame *, int, int); +int lookup_derived_face (struct frame *, Lisp_Object, int, int); +void init_frame_faces (struct frame *); +void free_frame_faces (struct frame *); +void recompute_basic_faces (struct frame *); +int face_at_buffer_position (struct window *w, EMACS_INT pos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, EMACS_INT limit, + int mouse, int base_face_id); +int face_for_overlay_string (struct window *w, EMACS_INT pos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, EMACS_INT limit, + int mouse, Lisp_Object overlay); +int face_at_string_position (struct window *w, Lisp_Object string, + EMACS_INT pos, EMACS_INT bufpos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, enum face_id, int mouse); +int merge_faces (struct frame *, Lisp_Object, int, int); +int compute_char_face (struct frame *, int, Lisp_Object); +void free_all_realized_faces (Lisp_Object); +void free_realized_face (struct frame *, struct face *); extern Lisp_Object Qforeground_color, Qbackground_color; extern Lisp_Object Qframe_set_background_mode; extern char unspecified_fg[], unspecified_bg[]; @@ -2954,24 +3158,24 @@ extern Lisp_Object Vface_remapping_alist; /* Defined in xfns.c */ #ifdef HAVE_X_WINDOWS -void gamma_correct P_ ((struct frame *, XColor *)); +void gamma_correct (struct frame *, XColor *); #endif #ifdef WINDOWSNT -void gamma_correct P_ ((struct frame *, COLORREF *)); +void gamma_correct (struct frame *, COLORREF *); #endif #ifdef HAVE_WINDOW_SYSTEM -int x_screen_planes P_ ((struct frame *)); -void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); +int x_screen_planes (struct frame *); +void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); extern Lisp_Object tip_frame; extern Window tip_window; EXFUN (Fx_show_tip, 6); EXFUN (Fx_hide_tip, 0); -extern void start_hourglass P_ ((void)); -extern void cancel_hourglass P_ ((void)); -extern int hourglass_started P_ ((void)); +extern void start_hourglass (void); +extern void cancel_hourglass (void); +extern int hourglass_started (void); extern int display_hourglass_p; extern int hourglass_shown_p; struct atimer; /* Defined in atimer.h. */ @@ -2980,8 +3184,8 @@ struct atimer; /* Defined in atimer.h. */ extern struct atimer *hourglass_atimer; /* Each GUI implements these. FIXME: move into RIF. */ -extern void show_hourglass P_ ((struct atimer *)); -extern void hide_hourglass P_ ((void)); +extern void show_hourglass (struct atimer *); +extern void hide_hourglass (void); /* Returns the background color of IMG, calculating one heuristically if necessary. If non-zero, XIMG is an existing XImage object to use for @@ -3006,120 +3210,110 @@ extern void hide_hourglass P_ ((void)); /* Defined in xmenu.c */ -int popup_activated P_ ((void)); +int popup_activated (void); /* Defined in dispnew.c */ extern int inverse_video; -extern int required_matrix_width P_ ((struct window *)); -extern int required_matrix_height P_ ((struct window *)); -extern Lisp_Object buffer_posn_from_coords P_ ((struct window *, - int *, int *, - struct display_pos *, - Lisp_Object *, - int *, int *, int *, int *)); -extern Lisp_Object mode_line_string P_ ((struct window *, enum window_part, - int *, int *, int *, - Lisp_Object *, - int *, int *, int *, int *)); -extern Lisp_Object marginal_area_string P_ ((struct window *, enum window_part, - int *, int *, int *, - Lisp_Object *, - int *, int *, int *, int *)); -extern void redraw_frame P_ ((struct frame *)); -extern void redraw_garbaged_frames P_ ((void)); -extern void cancel_line P_ ((int, struct frame *)); -extern void init_desired_glyphs P_ ((struct frame *)); -extern int scroll_frame_lines P_ ((struct frame *, int, int, int, int)); -extern int direct_output_for_insert P_ ((int)); -extern int direct_output_forward_char P_ ((int)); -extern int update_frame P_ ((struct frame *, int, int)); -extern int scrolling P_ ((struct frame *)); -extern void bitch_at_user P_ ((void)); -void adjust_glyphs P_ ((struct frame *)); -void free_glyphs P_ ((struct frame *)); -void free_window_matrices P_ ((struct window *)); -void check_glyph_memory P_ ((void)); -void mirrored_line_dance P_ ((struct glyph_matrix *, int, int, int *, char *)); -void clear_glyph_matrix P_ ((struct glyph_matrix *)); -void clear_current_matrices P_ ((struct frame *f)); -void clear_desired_matrices P_ ((struct frame *)); -void shift_glyph_matrix P_ ((struct window *, struct glyph_matrix *, - int, int, int)); -void rotate_matrix P_ ((struct glyph_matrix *, int, int, int)); -void increment_matrix_positions P_ ((struct glyph_matrix *, - int, int, int, int)); -void blank_row P_ ((struct window *, struct glyph_row *, int)); -void increment_row_positions P_ ((struct glyph_row *, int, int)); -void enable_glyph_matrix_rows P_ ((struct glyph_matrix *, int, int, int)); -void clear_glyph_row P_ ((struct glyph_row *)); -void prepare_desired_row P_ ((struct glyph_row *)); -int line_hash_code P_ ((struct glyph_row *)); -void set_window_update_flags P_ ((struct window *, int)); -void redraw_frame P_ ((struct frame *)); -void redraw_garbaged_frames P_ ((void)); -int scroll_cost P_ ((struct frame *, int, int, int)); -int direct_output_for_insert P_ ((int)); -int direct_output_forward_char P_ ((int)); -int update_frame P_ ((struct frame *, int, int)); -void update_single_window P_ ((struct window *, int)); -int scrolling P_ ((struct frame *)); -void do_pending_window_change P_ ((int)); -void change_frame_size P_ ((struct frame *, int, int, int, int, int)); -void bitch_at_user P_ ((void)); -void init_display P_ ((void)); -void syms_of_display P_ ((void)); +extern int required_matrix_width (struct window *); +extern int required_matrix_height (struct window *); +extern Lisp_Object buffer_posn_from_coords (struct window *, + int *, int *, + struct display_pos *, + Lisp_Object *, + int *, int *, int *, int *); +extern Lisp_Object mode_line_string (struct window *, enum window_part, + int *, int *, EMACS_INT *, + Lisp_Object *, + int *, int *, int *, int *); +extern Lisp_Object marginal_area_string (struct window *, enum window_part, + int *, int *, EMACS_INT *, + Lisp_Object *, + int *, int *, int *, int *); +extern void redraw_frame (struct frame *); +extern void redraw_garbaged_frames (void); +extern void cancel_line (int, struct frame *); +extern void init_desired_glyphs (struct frame *); +extern int scroll_frame_lines (struct frame *, int, int, int, int); +extern int update_frame (struct frame *, int, int); +extern int scrolling (struct frame *); +extern void bitch_at_user (void); +void adjust_glyphs (struct frame *); +void free_glyphs (struct frame *); +void free_window_matrices (struct window *); +void check_glyph_memory (void); +void mirrored_line_dance (struct glyph_matrix *, int, int, int *, char *); +void clear_glyph_matrix (struct glyph_matrix *); +void clear_current_matrices (struct frame *f); +void clear_desired_matrices (struct frame *); +void shift_glyph_matrix (struct window *, struct glyph_matrix *, + int, int, int); +void rotate_matrix (struct glyph_matrix *, int, int, int); +void increment_matrix_positions (struct glyph_matrix *, + int, int, EMACS_INT, EMACS_INT); +void blank_row (struct window *, struct glyph_row *, int); +void increment_row_positions (struct glyph_row *, EMACS_INT, EMACS_INT); +void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); +void clear_glyph_row (struct glyph_row *); +void prepare_desired_row (struct glyph_row *); +int line_hash_code (struct glyph_row *); +void set_window_update_flags (struct window *, int); +void update_single_window (struct window *, int); +void do_pending_window_change (int); +void change_frame_size (struct frame *, int, int, int, int, int); +void init_display (void); +void syms_of_display (void); extern Lisp_Object Qredisplay_dont_pause; -void spec_glyph_lookup_face P_ ((struct window *, GLYPH *)); +void spec_glyph_lookup_face (struct window *, GLYPH *); /* Defined in terminal.c */ -extern void ring_bell P_ ((struct frame *)); -extern void update_begin P_ ((struct frame *)); -extern void update_end P_ ((struct frame *)); -extern void set_terminal_window P_ ((struct frame *, int)); -extern void cursor_to P_ ((struct frame *, int, int)); -extern void raw_cursor_to P_ ((struct frame *, int, int)); -extern void clear_to_end P_ ((struct frame *)); -extern void clear_frame P_ ((struct frame *)); -extern void clear_end_of_line P_ ((struct frame *, int)); -extern void write_glyphs P_ ((struct frame *, struct glyph *, int)); -extern void insert_glyphs P_ ((struct frame *, struct glyph *, int)); -extern void delete_glyphs P_ ((struct frame *, int)); -extern void ins_del_lines P_ ((struct frame *, int, int)); +extern void ring_bell (struct frame *); +extern void update_begin (struct frame *); +extern void update_end (struct frame *); +extern void set_terminal_window (struct frame *, int); +extern void cursor_to (struct frame *, int, int); +extern void raw_cursor_to (struct frame *, int, int); +extern void clear_to_end (struct frame *); +extern void clear_frame (struct frame *); +extern void clear_end_of_line (struct frame *, int); +extern void write_glyphs (struct frame *, struct glyph *, int); +extern void insert_glyphs (struct frame *, struct glyph *, int); +extern void delete_glyphs (struct frame *, int); +extern void ins_del_lines (struct frame *, int, int); -extern struct terminal *init_initial_terminal P_ ((void)); +extern struct terminal *init_initial_terminal (void); /* Defined in term.c */ -extern void tty_set_terminal_modes P_ ((struct terminal *)); -extern void tty_reset_terminal_modes P_ ((struct terminal *)); -extern void tty_turn_off_insert P_ ((struct tty_display_info *)); -extern void tty_turn_off_highlight P_ ((struct tty_display_info *)); -extern int string_cost P_ ((char *)); -extern int per_line_cost P_ ((char *)); -extern void calculate_costs P_ ((struct frame *)); -extern void produce_glyphs P_ ((struct it *)); -extern void produce_special_glyphs P_ ((struct it *, enum display_element_type)); -extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); +extern void tty_set_terminal_modes (struct terminal *); +extern void tty_reset_terminal_modes (struct terminal *); +extern void tty_turn_off_insert (struct tty_display_info *); +extern void tty_turn_off_highlight (struct tty_display_info *); +extern int string_cost (const char *); +extern int per_line_cost (const char *); +extern void calculate_costs (struct frame *); +extern void produce_glyphs (struct it *); +extern void produce_special_glyphs (struct it *, enum display_element_type); +extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, unsigned long); extern void set_tty_color_mode (struct tty_display_info *, struct frame *); -extern struct terminal *get_tty_terminal P_ ((Lisp_Object, int)); -extern struct terminal *get_named_tty P_ ((char *)); +extern struct terminal *get_tty_terminal (Lisp_Object, int); +extern struct terminal *get_named_tty (const char *); EXFUN (Ftty_type, 1); -extern void create_tty_output P_ ((struct frame *)); -extern struct terminal *init_tty P_ ((char *, char *, int)); +extern void create_tty_output (struct frame *); +extern struct terminal *init_tty (const char *, const char *, int); /* Defined in scroll.c */ -extern int scrolling_max_lines_saved P_ ((int, int, int *, int *, int *)); -extern int scroll_cost P_ ((struct frame *, int, int, int)); -extern void do_line_insertion_deletion_costs P_ ((struct frame *, char *, - char *, char *, char *, - char *, char *, int)); -void scrolling_1 P_ ((struct frame *, int, int, int, int *, int *, int *, - int *, int)); +extern int scrolling_max_lines_saved (int, int, int *, int *, int *); +extern int scroll_cost (struct frame *, int, int, int); +extern void do_line_insertion_deletion_costs (struct frame *, char *, + char *, char *, char *, + char *, char *, int); +void scrolling_1 (struct frame *, int, int, int, int *, int *, int *, + int *, int); /* Defined in frame.c */ @@ -3136,20 +3330,20 @@ enum resource_types RES_TYPE_BOOLEAN_NUMBER }; -extern Lisp_Object x_get_arg P_ ((Display_Info *, Lisp_Object, - Lisp_Object, char *, char *class, - enum resource_types)); -extern Lisp_Object x_frame_get_arg P_ ((struct frame *, Lisp_Object, - Lisp_Object, char *, char *, - enum resource_types)); -extern Lisp_Object x_frame_get_and_record_arg P_ (( - struct frame *, Lisp_Object, - Lisp_Object, char *, char *, - enum resource_types)); -extern Lisp_Object x_default_parameter P_ ((struct frame *, Lisp_Object, - Lisp_Object, Lisp_Object, - char *, char *, - enum resource_types)); +extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object, + Lisp_Object, const char *, const char *class, + enum resource_types); +extern Lisp_Object x_frame_get_arg (struct frame *, Lisp_Object, + Lisp_Object, const char *, const char *, + enum resource_types); +extern Lisp_Object x_frame_get_and_record_arg (struct frame *, Lisp_Object, + Lisp_Object, + const char *, const char *, + enum resource_types); +extern Lisp_Object x_default_parameter (struct frame *, Lisp_Object, + Lisp_Object, Lisp_Object, + const char *, const char *, + enum resource_types); #endif /* HAVE_WINDOW_SYSTEM */ diff --git a/src/dispnew.c b/src/dispnew.c index d32ce48cce6..f9729fc28cb 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -47,9 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "blockinput.h" #include "process.h" -/* I don't know why DEC Alpha OSF1 fail to compile this file if we - include the following file. */ -/* #include "systty.h" */ #include "syssignal.h" #ifdef HAVE_X_WINDOWS @@ -69,12 +66,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "systime.h" #include <errno.h> -/* To get the prototype for `sleep'. */ - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - /* Get number of chars of output now in the buffer of a stdio stream. This ought to be built in in stdio, but it isn't. Some s- files override this because their stdio internals differ. */ @@ -117,73 +108,73 @@ struct dim /* Function prototypes. */ -static struct glyph_matrix *save_current_matrix P_ ((struct frame *)); -static void restore_current_matrix P_ ((struct frame *, struct glyph_matrix *)); -static int showing_window_margins_p P_ ((struct window *)); -static void fake_current_matrices P_ ((Lisp_Object)); -static void redraw_overlapping_rows P_ ((struct window *, int)); -static void redraw_overlapped_rows P_ ((struct window *, int)); -static int count_blanks P_ ((struct glyph *, int)); -static int count_match P_ ((struct glyph *, struct glyph *, - struct glyph *, struct glyph *)); -static unsigned line_draw_cost P_ ((struct glyph_matrix *, int)); -static void update_frame_line P_ ((struct frame *, int)); +static struct glyph_matrix *save_current_matrix (struct frame *); +static void restore_current_matrix (struct frame *, struct glyph_matrix *); +static int showing_window_margins_p (struct window *); +static void fake_current_matrices (Lisp_Object); +static void redraw_overlapping_rows (struct window *, int); +static void redraw_overlapped_rows (struct window *, int); +static int count_blanks (struct glyph *, int); +static int count_match (struct glyph *, struct glyph *, + struct glyph *, struct glyph *); +static unsigned line_draw_cost (struct glyph_matrix *, int); +static void update_frame_line (struct frame *, int); static struct dim allocate_matrices_for_frame_redisplay - P_ ((Lisp_Object, int, int, int, int *)); -static void allocate_matrices_for_window_redisplay P_ ((struct window *)); -static int realloc_glyph_pool P_ ((struct glyph_pool *, struct dim)); -static void adjust_frame_glyphs P_ ((struct frame *)); -struct glyph_matrix *new_glyph_matrix P_ ((struct glyph_pool *)); -static void free_glyph_matrix P_ ((struct glyph_matrix *)); -static void adjust_glyph_matrix P_ ((struct window *, struct glyph_matrix *, - int, int, struct dim)); -static void change_frame_size_1 P_ ((struct frame *, int, int, int, int, int)); -static void swap_glyph_pointers P_ ((struct glyph_row *, struct glyph_row *)); + (Lisp_Object, int, int, int, int *); +static void allocate_matrices_for_window_redisplay (struct window *); +static int realloc_glyph_pool (struct glyph_pool *, struct dim); +static void adjust_frame_glyphs (struct frame *); +struct glyph_matrix *new_glyph_matrix (struct glyph_pool *); +static void free_glyph_matrix (struct glyph_matrix *); +static void adjust_glyph_matrix (struct window *, struct glyph_matrix *, + int, int, struct dim); +static void change_frame_size_1 (struct frame *, int, int, int, int, int); +static void swap_glyph_pointers (struct glyph_row *, struct glyph_row *); #if GLYPH_DEBUG -static int glyph_row_slice_p P_ ((struct glyph_row *, struct glyph_row *)); +static int glyph_row_slice_p (struct glyph_row *, struct glyph_row *); #endif -static void fill_up_frame_row_with_spaces P_ ((struct glyph_row *, int)); -static void build_frame_matrix_from_window_tree P_ ((struct glyph_matrix *, - struct window *)); -static void build_frame_matrix_from_leaf_window P_ ((struct glyph_matrix *, - struct window *)); -static struct glyph_pool *new_glyph_pool P_ ((void)); -static void free_glyph_pool P_ ((struct glyph_pool *)); -static void adjust_frame_glyphs_initially P_ ((void)); -static void adjust_frame_message_buffer P_ ((struct frame *)); -static void adjust_decode_mode_spec_buffer P_ ((struct frame *)); -static void fill_up_glyph_row_with_spaces P_ ((struct glyph_row *)); -static void build_frame_matrix P_ ((struct frame *)); -void clear_current_matrices P_ ((struct frame *)); -void scroll_glyph_matrix_range P_ ((struct glyph_matrix *, int, int, - int, int)); -static void clear_window_matrices P_ ((struct window *, int)); -static void fill_up_glyph_row_area_with_spaces P_ ((struct glyph_row *, int)); -static int scrolling_window P_ ((struct window *, int)); -static int update_window_line P_ ((struct window *, int, int *)); -static void update_marginal_area P_ ((struct window *, int, int)); -static int update_text_area P_ ((struct window *, int)); -static void make_current P_ ((struct glyph_matrix *, struct glyph_matrix *, - int)); -static void mirror_make_current P_ ((struct window *, int)); -void check_window_matrix_pointers P_ ((struct window *)); +static void fill_up_frame_row_with_spaces (struct glyph_row *, int); +static void build_frame_matrix_from_window_tree (struct glyph_matrix *, + struct window *); +static void build_frame_matrix_from_leaf_window (struct glyph_matrix *, + struct window *); +static struct glyph_pool *new_glyph_pool (void); +static void free_glyph_pool (struct glyph_pool *); +static void adjust_frame_glyphs_initially (void); +static void adjust_frame_message_buffer (struct frame *); +static void adjust_decode_mode_spec_buffer (struct frame *); +static void fill_up_glyph_row_with_spaces (struct glyph_row *); +static void build_frame_matrix (struct frame *); +void clear_current_matrices (struct frame *); +void scroll_glyph_matrix_range (struct glyph_matrix *, int, int, + int, int); +static void clear_window_matrices (struct window *, int); +static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int); +static int scrolling_window (struct window *, int); +static int update_window_line (struct window *, int, int *); +static void update_marginal_area (struct window *, int, int); +static int update_text_area (struct window *, int); +static void make_current (struct glyph_matrix *, struct glyph_matrix *, + int); +static void mirror_make_current (struct window *, int); +void check_window_matrix_pointers (struct window *); #if GLYPH_DEBUG -static void check_matrix_pointers P_ ((struct glyph_matrix *, - struct glyph_matrix *)); +static void check_matrix_pointers (struct glyph_matrix *, + struct glyph_matrix *); #endif -static void mirror_line_dance P_ ((struct window *, int, int, int *, char *)); -static int update_window_tree P_ ((struct window *, int)); -static int update_window P_ ((struct window *, int)); -static int update_frame_1 P_ ((struct frame *, int, int)); -static void set_window_cursor_after_update P_ ((struct window *)); -static int row_equal_p P_ ((struct window *, struct glyph_row *, - struct glyph_row *, int)); -static void adjust_frame_glyphs_for_window_redisplay P_ ((struct frame *)); -static void adjust_frame_glyphs_for_frame_redisplay P_ ((struct frame *)); -static void reverse_rows P_ ((struct glyph_matrix *, int, int)); -static int margin_glyphs_to_reserve P_ ((struct window *, int, Lisp_Object)); -static void sync_window_with_frame_matrix_rows P_ ((struct window *)); -struct window *frame_row_to_window P_ ((struct window *, int)); +static void mirror_line_dance (struct window *, int, int, int *, char *); +static int update_window_tree (struct window *, int); +static int update_window (struct window *, int); +static int update_frame_1 (struct frame *, int, int); +static void set_window_cursor_after_update (struct window *); +static int row_equal_p (struct window *, struct glyph_row *, + struct glyph_row *, int); +static void adjust_frame_glyphs_for_window_redisplay (struct frame *); +static void adjust_frame_glyphs_for_frame_redisplay (struct frame *); +static void reverse_rows (struct glyph_matrix *, int, int); +static int margin_glyphs_to_reserve (struct window *, int, Lisp_Object); +static void sync_window_with_frame_matrix_rows (struct window *); +struct window *frame_row_to_window (struct window *, int); /* Non-zero means don't pause redisplay for pending input. (This is @@ -302,12 +293,6 @@ int updated_area; struct glyph space_glyph; -/* Non-zero means update has been performed directly, so that there's - no need for redisplay_internal to do much work. Set by - direct_output_for_insert. */ - -int redisplay_performed_directly_p; - /* Counts of allocated structures. These counts serve to diagnose memory leaks and double frees. */ @@ -334,8 +319,8 @@ int fonts_changed_p; #if GLYPH_DEBUG -static int window_to_frame_vpos P_ ((struct window *, int)); -static int window_to_frame_hpos P_ ((struct window *, int)); +static int window_to_frame_vpos (struct window *, int); +static int window_to_frame_hpos (struct window *, int); #define WINDOW_TO_FRAME_VPOS(W, VPOS) window_to_frame_vpos ((W), (VPOS)) #define WINDOW_TO_FRAME_HPOS(W, HPOS) window_to_frame_hpos ((W), (HPOS)) @@ -364,8 +349,8 @@ static int history_idx; static unsigned history_tick; -static void add_frame_display_history P_ ((struct frame *, int)); -static void add_window_display_history P_ ((struct window *, char *, int)); +static void add_frame_display_history (struct frame *, int); +static void add_window_display_history (struct window *, char *, int); /* Add to the redisplay history how window W has been displayed. MSG is a trace containing the information how W's glyph matrix @@ -422,7 +407,7 @@ add_frame_display_history (f, paused_p) DEFUN ("dump-redisplay-history", Fdump_redisplay_history, Sdump_redisplay_history, 0, 0, "", doc: /* Dump redisplay history to stderr. */) - () + (void) { int i; @@ -445,65 +430,15 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history, #endif /* GLYPH_DEBUG == 0 */ -/* Like bcopy except never gets confused by overlap. Let this be the - first function defined in this file, or change emacs.c where the - address of this function is used. */ +#if defined PROFILING && !HAVE___EXECUTABLE_START +/* FIXME: only used to find text start for profiling. */ void -safe_bcopy (from, to, size) - const char *from; - char *to; - int size; +safe_bcopy (const char *from, char *to, int size) { - if (size <= 0 || from == to) - return; - - /* If the source and destination don't overlap, then bcopy can - handle it. If they do overlap, but the destination is lower in - memory than the source, we'll assume bcopy can handle that. */ - if (to < from || from + size <= to) - bcopy (from, to, size); - - /* Otherwise, we'll copy from the end. */ - else - { - register const char *endf = from + size; - register char *endt = to + size; - - /* If TO - FROM is large, then we should break the copy into - nonoverlapping chunks of TO - FROM bytes each. However, if - TO - FROM is small, then the bcopy function call overhead - makes this not worth it. The crossover point could be about - anywhere. Since I don't think the obvious copy loop is too - bad, I'm trying to err in its favor. */ - if (to - from < 64) - { - do - *--endt = *--endf; - while (endf != from); - } - else - { - for (;;) - { - endt -= (to - from); - endf -= (to - from); - - if (endt < to) - break; - - bcopy (endf, endt, to - from); - } - - /* If SIZE wasn't a multiple of TO - FROM, there will be a - little left over. The amount left over is (endt + (to - - from)) - to, which is endt - from. */ - bcopy (from, to, endt - from); - } - } + abort (); } - - +#endif /*********************************************************************** Glyph Matrices @@ -516,14 +451,13 @@ safe_bcopy (from, to, size) POOL, the structure is otherwise zeroed. */ struct glyph_matrix * -new_glyph_matrix (pool) - struct glyph_pool *pool; +new_glyph_matrix (struct glyph_pool *pool) { struct glyph_matrix *result; /* Allocate and clear. */ result = (struct glyph_matrix *) xmalloc (sizeof *result); - bzero (result, sizeof *result); + memset (result, 0, sizeof *result); /* Increment number of allocated matrices. This count is used to detect memory leaks. */ @@ -547,8 +481,7 @@ new_glyph_matrix (pool) matrix also frees the glyph memory in this case. */ static void -free_glyph_matrix (matrix) - struct glyph_matrix *matrix; +free_glyph_matrix (struct glyph_matrix *matrix) { if (matrix) { @@ -578,10 +511,7 @@ free_glyph_matrix (matrix) or a float. */ static int -margin_glyphs_to_reserve (w, total_glyphs, margin) - struct window *w; - int total_glyphs; - Lisp_Object margin; +margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin) { int n; @@ -622,11 +552,7 @@ margin_glyphs_to_reserve (w, total_glyphs, margin) leads to screen flickering. */ static void -adjust_glyph_matrix (w, matrix, x, y, dim) - struct window *w; - struct glyph_matrix *matrix; - int x, y; - struct dim dim; +adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y, struct dim dim) { int i; int new_rows; @@ -676,8 +602,8 @@ adjust_glyph_matrix (w, matrix, x, y, dim) int size = dim.height * sizeof (struct glyph_row); new_rows = dim.height - matrix->rows_allocated; matrix->rows = (struct glyph_row *) xrealloc (matrix->rows, size); - bzero (matrix->rows + matrix->rows_allocated, - new_rows * sizeof *matrix->rows); + memset (matrix->rows + matrix->rows_allocated, 0, + new_rows * sizeof *matrix->rows); matrix->rows_allocated = dim.height; } else @@ -869,9 +795,7 @@ adjust_glyph_matrix (w, matrix, x, y, dim) below). */ static void -reverse_rows (matrix, start, end) - struct glyph_matrix *matrix; - int start, end; +reverse_rows (struct glyph_matrix *matrix, int start, int end) { int i, j; @@ -900,9 +824,7 @@ reverse_rows (matrix, start, end) rotating right. */ void -rotate_matrix (matrix, first, last, by) - struct glyph_matrix *matrix; - int first, last, by; +rotate_matrix (struct glyph_matrix *matrix, int first, int last, int by) { if (by < 0) { @@ -927,9 +849,8 @@ rotate_matrix (matrix, first, last, by) DELTA_BYTES. */ void -increment_matrix_positions (matrix, start, end, delta, delta_bytes) - struct glyph_matrix *matrix; - int start, end, delta, delta_bytes; +increment_matrix_positions (struct glyph_matrix *matrix, int start, int end, + EMACS_INT delta, EMACS_INT delta_bytes) { /* Check that START and END are reasonable values. */ xassert (start >= 0 && start <= matrix->nrows); @@ -946,10 +867,7 @@ increment_matrix_positions (matrix, start, end, delta, delta_bytes) ENABLED_P is non-zero, enabled_p flags in rows will be set to 1. */ void -enable_glyph_matrix_rows (matrix, start, end, enabled_p) - struct glyph_matrix *matrix; - int start, end; - int enabled_p; +enable_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end, int enabled_p) { xassert (start <= end); xassert (start >= 0 && start < matrix->nrows); @@ -971,8 +889,7 @@ enable_glyph_matrix_rows (matrix, start, end, enabled_p) currently present is the flag MATRIX->no_scrolling_p. */ void -clear_glyph_matrix (matrix) - struct glyph_matrix *matrix; +clear_glyph_matrix (struct glyph_matrix *matrix) { if (matrix) { @@ -987,10 +904,7 @@ clear_glyph_matrix (matrix) and recompute their visible height. */ void -shift_glyph_matrix (w, matrix, start, end, dy) - struct window *w; - struct glyph_matrix *matrix; - int start, end, dy; +shift_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int start, int end, int dy) { int min_y, max_y; @@ -1021,8 +935,7 @@ shift_glyph_matrix (w, matrix, start, end, dy) current matrix. */ void -clear_current_matrices (f) - register struct frame *f; +clear_current_matrices (register struct frame *f) { /* Clear frame current matrix, if we have one. */ if (f->current_matrix) @@ -1047,8 +960,7 @@ clear_current_matrices (f) /* Clear out all display lines of F for a coming redisplay. */ void -clear_desired_matrices (f) - register struct frame *f; +clear_desired_matrices (register struct frame *f) { if (f->desired_matrix) clear_glyph_matrix (f->desired_matrix); @@ -1069,9 +981,7 @@ clear_desired_matrices (f) non-zero clear desired matrices, otherwise clear current matrices. */ static void -clear_window_matrices (w, desired_p) - struct window *w; - int desired_p; +clear_window_matrices (struct window *w, int desired_p) { while (w) { @@ -1115,8 +1025,7 @@ clear_window_matrices (w, desired_p) static struct glyph_row null_row; void -clear_glyph_row (row) - struct glyph_row *row; +clear_glyph_row (struct glyph_row *row) { struct glyph *p[1 + LAST_AREA]; @@ -1142,7 +1051,7 @@ clear_glyph_row (row) returned by xmalloc. If flickering happens again, activate the code below. If the flickering is gone with that, chances are that the flickering has the same reason as here. */ - bzero (p[0], (char *) p[LAST_AREA] - (char *) p[0]); + memset (p[0], 0, (char *) p[LAST_AREA] - (char *) p[0]); #endif } @@ -1151,10 +1060,7 @@ clear_glyph_row (row) in window W starting at y-position Y. */ void -blank_row (w, row, y) - struct window *w; - struct glyph_row *row; - int y; +blank_row (struct window *w, struct glyph_row *row, int y) { int min_y, max_y; @@ -1183,9 +1089,8 @@ blank_row (w, row, y) ends. */ void -increment_row_positions (row, delta, delta_bytes) - struct glyph_row *row; - int delta, delta_bytes; +increment_row_positions (struct glyph_row *row, + EMACS_INT delta, EMACS_INT delta_bytes) { int area, i; @@ -1194,6 +1099,10 @@ increment_row_positions (row, delta, delta_bytes) MATRIX_ROW_START_BYTEPOS (row) += delta_bytes; MATRIX_ROW_END_CHARPOS (row) += delta; MATRIX_ROW_END_BYTEPOS (row) += delta_bytes; + CHARPOS (row->start.pos) += delta; + BYTEPOS (row->start.pos) += delta_bytes; + CHARPOS (row->end.pos) += delta; + BYTEPOS (row->end.pos) += delta_bytes; if (!row->enabled_p) return; @@ -1256,8 +1165,7 @@ swap_glyphs_in_rows (a, b) /* Exchange pointers to glyph memory between glyph rows A and B. */ static INLINE void -swap_glyph_pointers (a, b) - struct glyph_row *a, *b; +swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b) { int i; for (i = 0; i < LAST_AREA + 1; ++i) @@ -1273,19 +1181,18 @@ swap_glyph_pointers (a, b) that glyph pointers in the structures are left unchanged. */ INLINE void -copy_row_except_pointers (to, from) - struct glyph_row *to, *from; +copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from) { struct glyph *pointers[1 + LAST_AREA]; /* Save glyph pointers of TO. */ - bcopy (to->glyphs, pointers, sizeof to->glyphs); + memcpy (pointers, to->glyphs, sizeof to->glyphs); /* Do a structure assignment. */ *to = *from; /* Restore original pointers of TO. */ - bcopy (pointers, to->glyphs, sizeof to->glyphs); + memcpy (to->glyphs, pointers, sizeof to->glyphs); } @@ -1295,9 +1202,8 @@ copy_row_except_pointers (to, from) positions in row TO by DELTA/ DELTA_BYTES. */ void -copy_glyph_row_contents (to, from, delta, delta_bytes) - struct glyph_row *to, *from; - int delta, delta_bytes; +copy_glyph_row_contents (struct glyph_row *to, struct glyph_row *from, + EMACS_INT delta, EMACS_INT delta_bytes) { int area; @@ -1308,8 +1214,8 @@ copy_glyph_row_contents (to, from, delta, delta_bytes) /* Copy glyphs from FROM to TO. */ for (area = 0; area < LAST_AREA; ++area) if (from->used[area]) - bcopy (from->glyphs[area], to->glyphs[area], - from->used[area] * sizeof (struct glyph)); + memcpy (to->glyphs[area], from->glyphs[area], + from->used[area] * sizeof (struct glyph)); /* Increment buffer positions in TO by DELTA. */ increment_row_positions (to, delta, delta_bytes); @@ -1322,8 +1228,7 @@ copy_glyph_row_contents (to, from, delta, delta_bytes) a memory leak. */ static INLINE void -assign_row (to, from) - struct glyph_row *to, *from; +assign_row (struct glyph_row *to, struct glyph_row *from) { swap_glyph_pointers (to, from); copy_row_except_pointers (to, from); @@ -1383,13 +1288,15 @@ find_glyph_row_slice (window_matrix, frame_matrix, row) call to this function really clears it. */ void -prepare_desired_row (row) - struct glyph_row *row; +prepare_desired_row (struct glyph_row *row) { if (!row->enabled_p) { + unsigned rp = row->reversed_p; + clear_glyph_row (row); row->enabled_p = 1; + row->reversed_p = rp; } } @@ -1397,8 +1304,7 @@ prepare_desired_row (row) /* Return a hash code for glyph row ROW. */ int -line_hash_code (row) - struct glyph_row *row; +line_hash_code (struct glyph_row *row) { int hash = 0; @@ -1431,9 +1337,7 @@ line_hash_code (row) zero, leading and trailing spaces are ignored. */ static unsigned int -line_draw_cost (matrix, vpos) - struct glyph_matrix *matrix; - int vpos; +line_draw_cost (struct glyph_matrix *matrix, int vpos) { struct glyph_row *row = matrix->rows + vpos; struct glyph *beg = row->glyphs[TEXT_AREA]; @@ -1494,10 +1398,7 @@ line_draw_cost (matrix, vpos) flags of A and B, too. */ static INLINE int -row_equal_p (w, a, b, mouse_face_p) - struct window *w; - struct glyph_row *a, *b; - int mouse_face_p; +row_equal_p (struct window *w, struct glyph_row *a, struct glyph_row *b, int mouse_face_p) { if (a == b) return 1; @@ -1540,6 +1441,7 @@ row_equal_p (w, a, b, mouse_face_p) || a->overlapped_p != b->overlapped_p || (MATRIX_ROW_CONTINUATION_LINE_P (a) != MATRIX_ROW_CONTINUATION_LINE_P (b)) + || a->reversed_p != b->reversed_p /* Different partially visible characters on left margin. */ || a->x != b->x /* Different height. */ @@ -1566,13 +1468,13 @@ row_equal_p (w, a, b, mouse_face_p) incremented for each pool allocated. */ static struct glyph_pool * -new_glyph_pool () +new_glyph_pool (void) { struct glyph_pool *result; /* Allocate a new glyph_pool and clear it. */ result = (struct glyph_pool *) xmalloc (sizeof *result); - bzero (result, sizeof *result); + memset (result, 0, sizeof *result); /* For memory leak and double deletion checking. */ ++glyph_pool_count; @@ -1589,8 +1491,7 @@ new_glyph_pool () was passed to free_glyph_pool. */ static void -free_glyph_pool (pool) - struct glyph_pool *pool; +free_glyph_pool (struct glyph_pool *pool) { if (pool) { @@ -1614,9 +1515,7 @@ free_glyph_pool (pool) re-adjusting window glyph matrices necessary. */ static int -realloc_glyph_pool (pool, matrix_dim) - struct glyph_pool *pool; - struct dim matrix_dim; +realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) { int needed; int changed_p; @@ -1632,11 +1531,15 @@ realloc_glyph_pool (pool, matrix_dim) int size = needed * sizeof (struct glyph); if (pool->glyphs) - pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size); + { + pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size); + memset (pool->glyphs + pool->nglyphs, 0, + size - pool->nglyphs * sizeof (struct glyph)); + } else { pool->glyphs = (struct glyph *) xmalloc (size); - bzero (pool->glyphs, size); + memset (pool->glyphs, 0, size); } pool->nglyphs = needed; @@ -1750,13 +1653,19 @@ check_matrix_invariants (w) /* Check that character and byte positions are in sync. */ xassert (MATRIX_ROW_START_BYTEPOS (row) == CHAR_TO_BYTE (MATRIX_ROW_START_CHARPOS (row))); + xassert (BYTEPOS (row->start.pos) + == CHAR_TO_BYTE (CHARPOS (row->start.pos))); /* CHAR_TO_BYTE aborts when invoked for a position > Z. We can have such a position temporarily in case of a minibuffer displaying something like `[Sole completion]' at its end. */ if (MATRIX_ROW_END_CHARPOS (row) < BUF_ZV (current_buffer)) - xassert (MATRIX_ROW_END_BYTEPOS (row) - == CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row))); + { + xassert (MATRIX_ROW_END_BYTEPOS (row) + == CHAR_TO_BYTE (MATRIX_ROW_END_CHARPOS (row))); + xassert (BYTEPOS (row->end.pos) + == CHAR_TO_BYTE (CHARPOS (row->end.pos))); + } /* Check that end position of `row' is equal to start position of next row. */ @@ -1766,6 +1675,8 @@ check_matrix_invariants (w) == MATRIX_ROW_START_CHARPOS (next)); xassert (MATRIX_ROW_END_BYTEPOS (row) == MATRIX_ROW_START_BYTEPOS (next)); + xassert (CHARPOS (row->end.pos) == CHARPOS (next->start.pos)); + xassert (BYTEPOS (row->end.pos) == BYTEPOS (next->start.pos)); } row = next; } @@ -1866,12 +1777,8 @@ check_matrix_invariants (w) #define CHANGED_LEAF_MATRIX (1 << 1) static struct dim -allocate_matrices_for_frame_redisplay (window, x, y, dim_only_p, - window_change_flags) - Lisp_Object window; - int x, y; - int dim_only_p; - int *window_change_flags; +allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, + int dim_only_p, int *window_change_flags) { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); int x0 = x, y0 = y; @@ -1987,8 +1894,7 @@ allocate_matrices_for_frame_redisplay (window, x, y, dim_only_p, /* Return the required height of glyph matrices for window W. */ int -required_matrix_height (w) - struct window *w; +required_matrix_height (struct window *w) { #ifdef HAVE_WINDOW_SYSTEM struct frame *f = XFRAME (w->frame); @@ -2014,8 +1920,7 @@ required_matrix_height (w) /* Return the required width of glyph matrices for window W. */ int -required_matrix_width (w) - struct window *w; +required_matrix_width (struct window *w) { #ifdef HAVE_WINDOW_SYSTEM struct frame *f = XFRAME (w->frame); @@ -2043,8 +1948,7 @@ required_matrix_width (w) window whose matrices must be allocated/reallocated. */ static void -allocate_matrices_for_window_redisplay (w) - struct window *w; +allocate_matrices_for_window_redisplay (struct window *w) { while (w) { @@ -2081,8 +1985,7 @@ allocate_matrices_for_window_redisplay (w) changes, or its window configuration changes. */ void -adjust_glyphs (f) - struct frame *f; +adjust_glyphs (struct frame *f) { /* Block input so that expose events and other events that access glyph matrices are not processed while we are changing them. */ @@ -2114,7 +2017,7 @@ adjust_glyphs (f) windows to estimated values. */ static void -adjust_frame_glyphs_initially () +adjust_frame_glyphs_initially (void) { struct frame *sf = SELECTED_FRAME (); struct window *root = XWINDOW (sf->root_window); @@ -2141,8 +2044,7 @@ adjust_frame_glyphs_initially () /* Allocate/reallocate glyph matrices of a single frame F. */ static void -adjust_frame_glyphs (f) - struct frame *f; +adjust_frame_glyphs (struct frame *f) { if (FRAME_WINDOW_P (f)) adjust_frame_glyphs_for_window_redisplay (f); @@ -2160,8 +2062,7 @@ adjust_frame_glyphs (f) /* Return 1 if any window in the tree has nonzero window margins. See the hack at the end of adjust_frame_glyphs_for_frame_redisplay. */ static int -showing_window_margins_p (w) - struct window *w; +showing_window_margins_p (struct window *w) { while (w) { @@ -2189,8 +2090,7 @@ showing_window_margins_p (w) windows from the frame's current matrix. */ static void -fake_current_matrices (window) - Lisp_Object window; +fake_current_matrices (Lisp_Object window) { struct window *w; @@ -2240,18 +2140,17 @@ fake_current_matrices (window) a glyph matrix holding the contents of F's current frame matrix. */ static struct glyph_matrix * -save_current_matrix (f) - struct frame *f; +save_current_matrix (struct frame *f) { int i; struct glyph_matrix *saved; saved = (struct glyph_matrix *) xmalloc (sizeof *saved); - bzero (saved, sizeof *saved); + memset (saved, 0, sizeof *saved); saved->nrows = f->current_matrix->nrows; saved->rows = (struct glyph_row *) xmalloc (saved->nrows * sizeof *saved->rows); - bzero (saved->rows, saved->nrows * sizeof *saved->rows); + memset (saved->rows, 0, saved->nrows * sizeof *saved->rows); for (i = 0; i < saved->nrows; ++i) { @@ -2259,7 +2158,7 @@ save_current_matrix (f) struct glyph_row *to = saved->rows + i; size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); - bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); + memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); to->used[TEXT_AREA] = from->used[TEXT_AREA]; } @@ -2271,9 +2170,7 @@ save_current_matrix (f) and free memory associated with SAVED. */ static void -restore_current_matrix (f, saved) - struct frame *f; - struct glyph_matrix *saved; +restore_current_matrix (struct frame *f, struct glyph_matrix *saved) { int i; @@ -2282,7 +2179,7 @@ restore_current_matrix (f, saved) struct glyph_row *from = saved->rows + i; struct glyph_row *to = f->current_matrix->rows + i; size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); - bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); + memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); to->used[TEXT_AREA] = from->used[TEXT_AREA]; xfree (from->glyphs[TEXT_AREA]); } @@ -2297,8 +2194,7 @@ restore_current_matrix (f, saved) frame-based redisplay. */ static void -adjust_frame_glyphs_for_frame_redisplay (f) - struct frame *f; +adjust_frame_glyphs_for_frame_redisplay (struct frame *f) { struct dim matrix_dim; int pool_changed_p; @@ -2398,8 +2294,7 @@ adjust_frame_glyphs_for_frame_redisplay (f) window-based redisplay. */ static void -adjust_frame_glyphs_for_window_redisplay (f) - struct frame *f; +adjust_frame_glyphs_for_window_redisplay (struct frame *f) { struct window *w; @@ -2467,8 +2362,7 @@ adjust_frame_glyphs_for_window_redisplay (f) eventually without causing trouble). */ static void -adjust_frame_message_buffer (f) - struct frame *f; +adjust_frame_message_buffer (struct frame *f) { int size = FRAME_MESSAGE_BUF_SIZE (f) + 1; @@ -2486,8 +2380,7 @@ adjust_frame_message_buffer (f) /* Re-allocate buffer for decode_mode_spec on frame F. */ static void -adjust_decode_mode_spec_buffer (f) - struct frame *f; +adjust_decode_mode_spec_buffer (struct frame *f) { f->decode_mode_spec_buffer = (char *) xrealloc (f->decode_mode_spec_buffer, @@ -2506,8 +2399,7 @@ adjust_decode_mode_spec_buffer (f) the function is called when F is destroyed. */ void -free_glyphs (f) - struct frame *f; +free_glyphs (struct frame *f) { if (f && f->glyphs_initialized_p) { @@ -2568,8 +2460,7 @@ free_glyphs (f) the same tree more than once. */ void -free_window_matrices (w) - struct window *w; +free_window_matrices (struct window *w) { while (w) { @@ -2599,7 +2490,7 @@ free_window_matrices (w) explicitly and check that nothing is left allocated. */ void -check_glyph_memory () +check_glyph_memory (void) { Lisp_Object tail, frame; @@ -2683,8 +2574,7 @@ check_glyph_memory () sure not to touch them in this function. */ static void -build_frame_matrix (f) - struct frame *f; +build_frame_matrix (struct frame *f) { int i; @@ -2706,9 +2596,7 @@ build_frame_matrix (f) matrices. W is the root of a window tree. */ static void -build_frame_matrix_from_window_tree (matrix, w) - struct glyph_matrix *matrix; - struct window *w; +build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window *w) { while (w) { @@ -2736,9 +2624,7 @@ build_frame_matrix_from_window_tree (matrix, w) preserve_other_columns in the old redisplay. */ static void -build_frame_matrix_from_leaf_window (frame_matrix, w) - struct glyph_matrix *frame_matrix; - struct window *w; +build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct window *w) { struct glyph_matrix *window_matrix; int window_y, frame_y; @@ -2804,9 +2690,9 @@ build_frame_matrix_from_leaf_window (frame_matrix, w) if (current_row_p) { /* Copy window row to frame row. */ - bcopy (window_row->glyphs[0], - frame_row->glyphs[TEXT_AREA] + window_matrix->matrix_x, - window_matrix->matrix_w * sizeof (struct glyph)); + memcpy (frame_row->glyphs[TEXT_AREA] + window_matrix->matrix_x, + window_row->glyphs[0], + window_matrix->matrix_w * sizeof (struct glyph)); } else { @@ -2855,9 +2741,7 @@ build_frame_matrix_from_leaf_window (frame_matrix, w) for instance, vertical separators, truncation markers, etc. */ void -spec_glyph_lookup_face (w, glyph) - struct window *w; - GLYPH *glyph; +spec_glyph_lookup_face (struct window *w, GLYPH *glyph) { int lface_id = GLYPH_FACE (*glyph); /* Convert the glyph's specified face to a realized (cache) face. */ @@ -2886,8 +2770,7 @@ spec_glyph_lookup_face (w, glyph) To be called for frame-based redisplay, only. */ static void -fill_up_glyph_row_with_spaces (row) - struct glyph_row *row; +fill_up_glyph_row_with_spaces (struct glyph_row *row) { fill_up_glyph_row_area_with_spaces (row, LEFT_MARGIN_AREA); fill_up_glyph_row_area_with_spaces (row, TEXT_AREA); @@ -2899,9 +2782,7 @@ fill_up_glyph_row_with_spaces (row) frame-based redisplay only. */ static void -fill_up_glyph_row_area_with_spaces (row, area) - struct glyph_row *row; - int area; +fill_up_glyph_row_area_with_spaces (struct glyph_row *row, int area) { if (row->glyphs[area] < row->glyphs[area + 1]) { @@ -2919,9 +2800,7 @@ fill_up_glyph_row_area_with_spaces (row, area) reached. In frame matrices only one area, TEXT_AREA, is used. */ static void -fill_up_frame_row_with_spaces (row, upto) - struct glyph_row *row; - int upto; +fill_up_frame_row_with_spaces (struct glyph_row *row, int upto) { int i = row->used[TEXT_AREA]; struct glyph *glyph = row->glyphs[TEXT_AREA]; @@ -2943,8 +2822,7 @@ fill_up_frame_row_with_spaces (row, upto) working on frame matrices or not. */ static INLINE void -set_frame_matrix_frame (f) - struct frame *f; +set_frame_matrix_frame (struct frame *f) { frame_matrix_frame = f; } @@ -2959,9 +2837,7 @@ set_frame_matrix_frame (f) operations in window matrices of frame_matrix_frame. */ static INLINE void -make_current (desired_matrix, current_matrix, row) - struct glyph_matrix *desired_matrix, *current_matrix; - int row; +make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_matrix, int row) { struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); @@ -2988,9 +2864,7 @@ make_current (desired_matrix, current_matrix, row) matrices of leaf windows in the window tree rooted at W. */ static void -mirror_make_current (w, frame_row) - struct window *w; - int frame_row; +mirror_make_current (struct window *w, int frame_row) { while (w) { @@ -3038,12 +2912,8 @@ mirror_make_current (w, frame_row) This function is called from do_scrolling and do_direct_scrolling. */ void -mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from, - retained_p) - struct glyph_matrix *matrix; - int unchanged_at_top, nlines; - int *copy_from; - char *retained_p; +mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlines, + int *copy_from, char *retained_p) { /* A copy of original rows. */ struct glyph_row *old_rows; @@ -3055,7 +2925,7 @@ mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from, /* Make a copy of the original rows. */ old_rows = (struct glyph_row *) alloca (nlines * sizeof *old_rows); - bcopy (new_rows, old_rows, nlines * sizeof *old_rows); + memcpy (old_rows, new_rows, nlines * sizeof *old_rows); /* Assign new rows, maybe clear lines. */ for (i = 0; i < nlines; ++i) @@ -3083,8 +2953,7 @@ mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from, the current frame matrix. */ static void -sync_window_with_frame_matrix_rows (w) - struct window *w; +sync_window_with_frame_matrix_rows (struct window *w) { struct frame *f = XFRAME (w->frame); struct glyph_row *window_row, *window_row_end, *frame_row; @@ -3121,9 +2990,7 @@ sync_window_with_frame_matrix_rows (w) row ROW. Value is null if none is found. */ struct window * -frame_row_to_window (w, row) - struct window *w; - int row; +frame_row_to_window (struct window *w, int row) { struct window *found = NULL; @@ -3156,11 +3023,7 @@ frame_row_to_window (w, row) which is empty. */ static void -mirror_line_dance (w, unchanged_at_top, nlines, copy_from, retained_p) - struct window *w; - int unchanged_at_top, nlines; - int *copy_from; - char *retained_p; +mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy_from, char *retained_p) { while (w) { @@ -3180,7 +3043,7 @@ mirror_line_dance (w, unchanged_at_top, nlines, copy_from, retained_p) /* Make a copy of the original rows of matrix m. */ old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows); - bcopy (m->rows, old_rows, m->nrows * sizeof *old_rows); + memcpy (old_rows, m->rows, m->nrows * sizeof *old_rows); for (i = 0; i < nlines; ++i) { @@ -3374,8 +3237,7 @@ window_to_frame_hpos (w, hpos) DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, doc: /* Clear frame FRAME and output again what is supposed to appear on it. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -3412,8 +3274,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, function redraw-frame. */ void -redraw_frame (f) - struct frame *f; +redraw_frame (struct frame *f) { Lisp_Object frame; XSETFRAME (frame, f); @@ -3423,7 +3284,7 @@ redraw_frame (f) DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", doc: /* Clear and redisplay all visible frames. */) - () + (void) { Lisp_Object tail, frame; @@ -3439,7 +3300,7 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "", visible frames marked as garbaged. */ void -redraw_garbaged_frames () +redraw_garbaged_frames (void) { Lisp_Object tail, frame; @@ -3452,395 +3313,6 @@ redraw_garbaged_frames () /*********************************************************************** - Direct Operations - ***********************************************************************/ - -/* Try to update display and current glyph matrix directly. - - This function is called after a character G has been inserted into - current_buffer. It tries to update the current glyph matrix and - perform appropriate screen output to reflect the insertion. If it - succeeds, the global flag redisplay_performed_directly_p will be - set to 1, and thereby prevent the more costly general redisplay - from running (see redisplay_internal). - - This function is not called for `hairy' character insertions. - In particular, it is not called when after or before change - functions exist, like they are used by font-lock. See keyboard.c - for details where this function is called. */ - -int -direct_output_for_insert (g) - int g; -{ - register struct frame *f = SELECTED_FRAME (); - struct window *w = XWINDOW (selected_window); - struct it it, it2; - struct glyph_row *glyph_row; - struct glyph *glyphs, *glyph, *end; - int n; - /* Non-null means that redisplay of W is based on window matrices. */ - int window_redisplay_p = FRAME_WINDOW_P (f); - /* Non-null means we are in overwrite mode. */ - int overwrite_p = !NILP (current_buffer->overwrite_mode); - int added_width; - struct text_pos pos; - int delta, delta_bytes; - - /* Not done directly. */ - redisplay_performed_directly_p = 0; - - /* Quickly give up for some common cases. */ - if (cursor_in_echo_area - /* Give up if fonts have changed. */ - || fonts_changed_p - /* Give up if face attributes have been changed. */ - || face_change_count - /* Give up if cursor position not really known. */ - || !display_completed - /* Give up if buffer appears in two places. */ - || buffer_shared > 1 - /* Give up if currently displaying a message instead of the - minibuffer contents. */ - || (EQ (selected_window, minibuf_window) - && EQ (minibuf_window, echo_area_window)) - /* Give up for hscrolled mini-buffer because display of the prompt - is handled specially there (see display_line). */ - || (MINI_WINDOW_P (w) && XFASTINT (w->hscroll)) - /* Give up if overwriting in the middle of a line. */ - || (overwrite_p - && PT != ZV - && FETCH_BYTE (PT) != '\n') - /* Give up for tabs and line ends. */ - || g == '\t' - || g == '\n' - || g == '\r' - || (g == ' ' && !NILP (current_buffer->word_wrap)) - /* Give up if unable to display the cursor in the window. */ - || w->cursor.vpos < 0 - /* Give up if we are showing a message or just cleared the message - because we might need to resize the echo area window. */ - || !NILP (echo_area_buffer[0]) - || !NILP (echo_area_buffer[1]) - || (glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos), - /* Can't do it in a continued line because continuation - lines would change. */ - (glyph_row->continued_p - || glyph_row->exact_window_width_line_p - /* Can't use this method if the line overlaps others or is - overlapped by others because these other lines would - have to be redisplayed. */ - || glyph_row->overlapping_p - || glyph_row->overlapped_p)) - /* Can't do it for partial width windows on terminal frames - because we can't clear to eol in such a window. */ - || (!window_redisplay_p && !WINDOW_FULL_WIDTH_P (w))) - return 0; - - /* If we can't insert glyphs, we can use this method only - at the end of a line. */ - if (!FRAME_CHAR_INS_DEL_OK (f)) - if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n') - return 0; - - /* Set up a display iterator structure for W. Glyphs will be - produced in scratch_glyph_row. Current position is W's cursor - position. */ - clear_glyph_row (&scratch_glyph_row); - SET_TEXT_POS (pos, PT, PT_BYTE); - DEC_TEXT_POS (pos, !NILP (current_buffer->enable_multibyte_characters)); - init_iterator (&it, w, CHARPOS (pos), BYTEPOS (pos), &scratch_glyph_row, - DEFAULT_FACE_ID); - - glyph_row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); - if (glyph_row->mouse_face_p) - return 0; - - /* Give up if highlighting trailing whitespace and we have trailing - whitespace in glyph_row. We would have to remove the trailing - whitespace face in that case. */ - if (!NILP (Vshow_trailing_whitespace) - && glyph_row->used[TEXT_AREA]) - { - struct glyph *last; - - last = glyph_row->glyphs[TEXT_AREA] + glyph_row->used[TEXT_AREA] - 1; - if (last->type == STRETCH_GLYPH - || (last->type == CHAR_GLYPH - && last->u.ch == ' ')) - return 0; - } - - /* Give up if there are overlay strings at pos. This would fail - if the overlay string has newlines in it. */ - if (STRINGP (it.string)) - return 0; - - it.hpos = w->cursor.hpos; - it.vpos = w->cursor.vpos; - it.current_x = w->cursor.x + it.first_visible_x; - it.current_y = w->cursor.y; - it.end_charpos = PT; - it.stop_charpos = min (PT, it.stop_charpos); - it.stop_charpos = max (IT_CHARPOS (it), it.stop_charpos); - - /* More than one display element may be returned for PT - 1 if - (i) it's a control character which is translated into `\003' or - `^C', or (ii) it has a display table entry, or (iii) it's a - combination of both. */ - delta = delta_bytes = 0; - while (get_next_display_element (&it)) - { - PRODUCE_GLYPHS (&it); - - /* Give up if glyph doesn't fit completely on the line. */ - if (it.current_x >= it.last_visible_x) - return 0; - - /* Give up if new glyph has different ascent or descent than - the original row, or if it is not a character glyph. */ - if (glyph_row->ascent != it.ascent - || glyph_row->height != it.ascent + it.descent - || glyph_row->phys_ascent != it.phys_ascent - || glyph_row->phys_height != it.phys_ascent + it.phys_descent - || it.what != IT_CHARACTER) - return 0; - - delta += 1; - delta_bytes += it.len; - set_iterator_to_next (&it, 1); - } - - /* Give up if we hit the right edge of the window. We would have - to insert truncation or continuation glyphs. */ - added_width = it.current_x - (w->cursor.x + it.first_visible_x); - if (glyph_row->pixel_width + added_width >= it.last_visible_x) - return 0; - - /* Give up if there is a \t following in the line. */ - it2 = it; - it2.end_charpos = ZV; - it2.stop_charpos = min (it2.stop_charpos, ZV); - while (get_next_display_element (&it2) - && !ITERATOR_AT_END_OF_LINE_P (&it2)) - { - if (it2.c == '\t') - return 0; - set_iterator_to_next (&it2, 1); - } - - /* Number of new glyphs produced. */ - n = it.glyph_row->used[TEXT_AREA]; - - /* Start and end of glyphs in original row. */ - glyphs = glyph_row->glyphs[TEXT_AREA] + w->cursor.hpos; - end = glyph_row->glyphs[1 + TEXT_AREA]; - - /* Make room for new glyphs, then insert them. */ - xassert (end - glyphs - n >= 0); - safe_bcopy ((char *) glyphs, (char *) (glyphs + n), - (end - glyphs - n) * sizeof (*end)); - bcopy (it.glyph_row->glyphs[TEXT_AREA], glyphs, n * sizeof *glyphs); - glyph_row->used[TEXT_AREA] = min (glyph_row->used[TEXT_AREA] + n, - end - glyph_row->glyphs[TEXT_AREA]); - - /* Compute new line width. */ - glyph = glyph_row->glyphs[TEXT_AREA]; - end = glyph + glyph_row->used[TEXT_AREA]; - glyph_row->pixel_width = glyph_row->x; - while (glyph < end) - { - glyph_row->pixel_width += glyph->pixel_width; - ++glyph; - } - - /* Increment buffer positions for glyphs following the newly - inserted ones. */ - for (glyph = glyphs + n; glyph < end; ++glyph) - if (glyph->charpos > 0 && BUFFERP (glyph->object)) - glyph->charpos += delta; - - if (MATRIX_ROW_END_CHARPOS (glyph_row) > 0) - { - MATRIX_ROW_END_CHARPOS (glyph_row) += delta; - MATRIX_ROW_END_BYTEPOS (glyph_row) += delta_bytes; - } - - /* Adjust positions in lines following the one we are in. */ - increment_matrix_positions (w->current_matrix, - w->cursor.vpos + 1, - w->current_matrix->nrows, - delta, delta_bytes); - - glyph_row->contains_overlapping_glyphs_p - |= it.glyph_row->contains_overlapping_glyphs_p; - - glyph_row->displays_text_p = 1; - w->window_end_vpos = make_number (max (w->cursor.vpos, - XFASTINT (w->window_end_vpos))); - - if (!NILP (Vshow_trailing_whitespace)) - highlight_trailing_whitespace (it.f, glyph_row); - - /* Write glyphs. If at end of row, we can simply call write_glyphs. - In the middle, we have to insert glyphs. Note that this is now - implemented for X frames. The implementation uses updated_window - and updated_row. */ - updated_row = glyph_row; - updated_area = TEXT_AREA; - update_begin (f); - if (FRAME_RIF (f)) - { - FRAME_RIF (f)->update_window_begin_hook (w); - - if (glyphs == end - n - /* In front of a space added by append_space. */ - || (glyphs == end - n - 1 - && (end - n)->charpos <= 0)) - FRAME_RIF (f)->write_glyphs (glyphs, n); - else - FRAME_RIF (f)->insert_glyphs (glyphs, n); - } - else - { - if (glyphs == end - n) - write_glyphs (f, glyphs, n); - else - insert_glyphs (f, glyphs, n); - } - - w->cursor.hpos += n; - w->cursor.x = it.current_x - it.first_visible_x; - xassert (w->cursor.hpos >= 0 - && w->cursor.hpos < w->desired_matrix->matrix_w); - - /* How to set the cursor differs depending on whether we are - using a frame matrix or a window matrix. Note that when - a frame matrix is used, cursor_to expects frame coordinates, - and the X and Y parameters are not used. */ - if (window_redisplay_p) - FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); - else - { - int x, y; - x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) - + (INTEGERP (w->left_margin_cols) - ? XFASTINT (w->left_margin_cols) - : 0)); - y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); - cursor_to (f, y, x); - } - -#ifdef HAVE_WINDOW_SYSTEM - update_window_fringes (w, 0); -#endif - - if (FRAME_RIF (f)) - FRAME_RIF (f)->update_window_end_hook (w, 1, 0); - update_end (f); - updated_row = NULL; - if (FRAME_TERMCAP_P (f)) - fflush (FRAME_TTY (f)->output); - - TRACE ((stderr, "direct output for insert\n")); - mark_window_display_accurate (it.window, 1); - redisplay_performed_directly_p = 1; - return 1; -} - - -/* Perform a direct display update for moving PT by N positions - left or right. N < 0 means a movement backwards. This function - is currently only called for N == 1 or N == -1. */ - -int -direct_output_forward_char (n) - int n; -{ - struct frame *f = SELECTED_FRAME (); - struct window *w = XWINDOW (selected_window); - struct glyph_row *row; - - /* Give up if point moved out of or into a composition. */ - if (check_point_in_composition (current_buffer, XINT (w->last_point), - current_buffer, PT)) - return 0; - - /* Give up if face attributes have been changed. */ - if (face_change_count) - return 0; - - /* Give up if current matrix is not up to date or we are - displaying a message. */ - if (!display_completed || cursor_in_echo_area) - return 0; - - /* Give up if the buffer's direction is reversed. */ - if (!NILP (XBUFFER (w->buffer)->direction_reversed)) - return 0; - - /* Can't use direct output if highlighting a region. */ - if (!NILP (Vtransient_mark_mode) && !NILP (current_buffer->mark_active)) - return 0; - - /* Can't use direct output if highlighting trailing whitespace. */ - if (!NILP (Vshow_trailing_whitespace)) - return 0; - - /* Give up if we are showing a message or just cleared the message - because we might need to resize the echo area window. */ - if (!NILP (echo_area_buffer[0]) || !NILP (echo_area_buffer[1])) - return 0; - - /* Give up if currently displaying a message instead of the - minibuffer contents. */ - if (XWINDOW (minibuf_window) == w - && EQ (minibuf_window, echo_area_window)) - return 0; - - /* Give up if we don't know where the cursor is. */ - if (w->cursor.vpos < 0) - return 0; - - row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); - - /* Give up if PT is outside of the last known cursor row. */ - if (PT <= MATRIX_ROW_START_CHARPOS (row) - || PT >= MATRIX_ROW_END_CHARPOS (row)) - return 0; - - set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); - - w->last_cursor = w->cursor; - XSETFASTINT (w->last_point, PT); - - xassert (w->cursor.hpos >= 0 - && w->cursor.hpos < w->desired_matrix->matrix_w); - - if (FRAME_WINDOW_P (f)) - FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos, - w->cursor.y, w->cursor.x); - else - { - int x, y; - x = (WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos) - + (INTEGERP (w->left_margin_cols) - ? XFASTINT (w->left_margin_cols) - : 0)); - y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos); - cursor_to (f, y, x); - } - - if (FRAME_TERMCAP_P (f)) - fflush (FRAME_TTY (f)->output); - redisplay_performed_directly_p = 1; - return 1; -} - - - -/*********************************************************************** Frame Update ***********************************************************************/ @@ -3853,10 +3325,7 @@ direct_output_forward_char (n) Value is non-zero if redisplay was stopped due to pending input. */ int -update_frame (f, force_p, inhibit_hairy_id_p) - struct frame *f; - int force_p; - int inhibit_hairy_id_p; +update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p) { /* 1 means display has been paused because of pending input. */ int paused_p; @@ -3988,9 +3457,7 @@ update_frame (f, force_p, inhibit_hairy_id_p) don't stop updating when input is pending. */ static int -update_window_tree (w, force_p) - struct window *w; - int force_p; +update_window_tree (struct window *w, int force_p) { int paused_p = 0; @@ -4014,9 +3481,7 @@ update_window_tree (w, force_p) FORCE_P is non-zero, don't stop updating if input is pending. */ void -update_single_window (w, force_p) - struct window *w; - int force_p; +update_single_window (struct window *w, int force_p) { if (w->must_be_updated_p) { @@ -4061,9 +3526,7 @@ update_single_window (w, force_p) overlapped by other rows. YB is bottom-most y-position in W. */ static void -redraw_overlapped_rows (w, yb) - struct window *w; - int yb; +redraw_overlapped_rows (struct window *w, int yb) { int i; struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -4111,9 +3574,7 @@ redraw_overlapped_rows (w, yb) others. YB is bottom-most y-position in W. */ static void -redraw_overlapping_rows (w, yb) - struct window *w; - int yb; +redraw_overlapping_rows (struct window *w, int yb) { int i, bottom_y; struct glyph_row *row; @@ -4175,8 +3636,7 @@ redraw_overlapping_rows (w, yb) which is below what's displayed in the window. */ void -check_current_matrix_flags (w) - struct window *w; +check_current_matrix_flags (struct window *w) { int last_seen_p = 0; int i, yb = window_text_bottom_y (w); @@ -4198,17 +3658,13 @@ check_current_matrix_flags (w) not stop when detecting pending input. */ static int -update_window (w, force_p) - struct window *w; - int force_p; +update_window (struct window *w, int force_p) { struct glyph_matrix *desired_matrix = w->desired_matrix; int paused_p; #if !PERIODIC_PREEMPTION_CHECKING int preempt_count = baud_rate / 2400 + 1; #endif - extern int input_pending; - extern Lisp_Object do_mouse_tracking; struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); #if GLYPH_DEBUG /* Check that W's frame doesn't have glyph matrices. */ @@ -4392,9 +3848,7 @@ update_window (w, force_p) AREA can be either LEFT_MARGIN_AREA or RIGHT_MARGIN_AREA. */ static void -update_marginal_area (w, area, vpos) - struct window *w; - int area, vpos; +update_marginal_area (struct window *w, int area, int vpos) { struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); @@ -4417,9 +3871,7 @@ update_marginal_area (w, area, vpos) Value is non-zero if display has changed. */ static int -update_text_area (w, vpos) - struct window *w; - int vpos; +update_text_area (struct window *w, int vpos) { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); @@ -4642,7 +4094,9 @@ update_text_area (w, vpos) doesn't work with lbearing/rbearing), so we must do it this way. */ if (vpos == w->phys_cursor.vpos - && w->phys_cursor.hpos >= desired_row->used[TEXT_AREA]) + && (desired_row->reversed_p + ? (w->phys_cursor.hpos < 0) + : (w->phys_cursor.hpos >= desired_row->used[TEXT_AREA]))) { w->phys_cursor_on_p = 0; x = -1; @@ -4662,9 +4116,7 @@ update_text_area (w, vpos) changed. */ static int -update_window_line (w, vpos, mouse_face_overwritten_p) - struct window *w; - int vpos, *mouse_face_overwritten_p; +update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p) { struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); @@ -4733,8 +4185,7 @@ update_window_line (w, vpos, mouse_face_overwritten_p) be called from update_window. */ static void -set_window_cursor_after_update (w) - struct window *w; +set_window_cursor_after_update (struct window *w) { struct frame *f = XFRAME (w->frame); struct redisplay_interface *rif = FRAME_RIF (f); @@ -4806,7 +4257,7 @@ set_window_cursor_after_update (w) } /* Window cursor can be out of sync for horizontally split windows. */ - hpos = max (0, hpos); + hpos = max (-1, hpos); /* -1 is for when cursor is on the left fringe */ hpos = min (w->current_matrix->matrix_w - 1, hpos); vpos = max (0, vpos); vpos = min (w->current_matrix->nrows - 1, vpos); @@ -4818,9 +4269,7 @@ set_window_cursor_after_update (w) tree rooted at W. */ void -set_window_update_flags (w, on_p) - struct window *w; - int on_p; +set_window_update_flags (struct window *w, int on_p) { while (w) { @@ -4898,9 +4347,7 @@ static struct run **runs; of window W. */ static INLINE struct row_entry * -add_row_entry (w, row) - struct window *w; - struct glyph_row *row; +add_row_entry (struct window *w, struct glyph_row *row) { struct row_entry *entry; int i = row->hash % row_table_size; @@ -4951,9 +4398,7 @@ add_row_entry (w, row) 1 if we did scroll. */ static int -scrolling_window (w, header_line_p) - struct window *w; - int header_line_p; +scrolling_window (struct window *w, int header_line_p) { struct glyph_matrix *desired_matrix = w->desired_matrix; struct glyph_matrix *current_matrix = w->current_matrix; @@ -5061,7 +4506,7 @@ scrolling_window (w, header_line_p) row_table_size = next_almost_prime (3 * n); nbytes = row_table_size * sizeof *row_table; row_table = (struct row_entry **) xrealloc (row_table, nbytes); - bzero (row_table, nbytes); + memset (row_table, 0, nbytes); } if (n > row_entry_pool_size) @@ -5256,10 +4701,7 @@ scrolling_window (w, header_line_p) Value is non-zero if update was stopped due to pending input. */ static int -update_frame_1 (f, force_p, inhibit_id_p) - struct frame *f; - int force_p; - int inhibit_id_p; +update_frame_1 (struct frame *f, int force_p, int inhibit_id_p) { /* Frame matrices to work on. */ struct glyph_matrix *current_matrix = f->current_matrix; @@ -5267,7 +4709,6 @@ update_frame_1 (f, force_p, inhibit_id_p) int i; int pause; int preempt_count = baud_rate / 2400 + 1; - extern int input_pending; xassert (current_matrix && desired_matrix); @@ -5469,8 +4910,7 @@ update_frame_1 (f, force_p, inhibit_id_p) /* Do line insertions/deletions on frame F for frame-based redisplay. */ int -scrolling (frame) - struct frame *frame; +scrolling (struct frame *frame) { int unchanged_at_top, unchanged_at_bottom; int window_size; @@ -5564,9 +5004,7 @@ scrolling (frame) which is LEN glyphs long. */ static int -count_blanks (r, len) - struct glyph *r; - int len; +count_blanks (struct glyph *r, int len) { int i; @@ -5583,8 +5021,7 @@ count_blanks (r, len) of STR2. Value is the number of equal glyphs equal at the start. */ static int -count_match (str1, end1, str2, end2) - struct glyph *str1, *end1, *str2, *end2; +count_match (struct glyph *str1, struct glyph *end1, struct glyph *str2, struct glyph *end2) { struct glyph *p1 = str1; struct glyph *p2 = str2; @@ -5600,16 +5037,13 @@ count_match (str1, end1, str2, end2) /* Char insertion/deletion cost vector, from term.c */ -extern int *char_ins_del_vector; #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_TOTAL_COLS((f))]) /* Perform a frame-based update on line VPOS in frame FRAME. */ static void -update_frame_line (f, vpos) - struct frame *f; - int vpos; +update_frame_line (struct frame *f, int vpos) { struct glyph *obody, *nbody, *op1, *op2, *np1, *nend; int tem; @@ -5920,18 +5354,18 @@ update_frame_line (f, vpos) ***********************************************************************/ /* Determine what's under window-relative pixel position (*X, *Y). - Return the object (string or buffer) that's there. + Return the OBJECT (string or buffer) that's there. Return in *POS the position in that object. - Adjust *X and *Y to character positions. */ + Adjust *X and *Y to character positions. + Return in *DX and *DY the pixel coordinates of the click, + relative to the top left corner of OBJECT, or relative to + the top left corner of the character glyph at (*X, *Y) + if OBJECT is nil. + Return WIDTH and HEIGHT of the object at (*X, *Y), or zero + if the coordinates point to an empty area of the display. */ Lisp_Object -buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) - struct window *w; - int *x, *y; - struct display_pos *pos; - Lisp_Object *object; - int *dx, *dy; - int *width, *height; +buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *pos, Lisp_Object *object, int *dx, int *dy, int *width, int *height) { struct it it; Lisp_Object old_current_buffer = Fcurrent_buffer (); @@ -5941,7 +5375,7 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) #ifdef HAVE_WINDOW_SYSTEM struct image *img = 0; #endif - int x0, x1; + int x0, x1, to_x; /* We used to set current_buffer directly here, but that does the wrong thing with `face-remapping-alist' (bug#2044). */ @@ -5952,8 +5386,33 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) start_display (&it, w, startp); x0 = *x - WINDOW_LEFT_MARGIN_WIDTH (w); - move_it_to (&it, -1, x0 + it.first_visible_x, *y, -1, - MOVE_TO_X | MOVE_TO_Y); + + /* First, move to the beginning of the row corresponding to *Y. We + need to be in that row to get the correct value of base paragraph + direction for the text at (*X, *Y). */ + move_it_to (&it, -1, 0, *y, -1, MOVE_TO_X | MOVE_TO_Y); + + /* TO_X is the pixel position that the iterator will compute for the + glyph at *X. We add it.first_visible_x because iterator + positions include the hscroll. */ + to_x = x0 + it.first_visible_x; + if (it.bidi_it.paragraph_dir == R2L) + /* For lines in an R2L paragraph, we need to mirror TO_X wrt the + text area. This is because the iterator, even in R2L + paragraphs, delivers glyphs as if they started at the left + margin of the window. (When we actually produce glyphs for + display, we reverse their order in PRODUCE_GLYPHS, but the + iterator doesn't know about that.) The following line adjusts + the pixel position to the iterator geometry, which is what + move_it_* routines use. (The -1 is because in a window whose + text-area width is W, the rightmost pixel position is W-1, and + it should be mirrored into zero pixel position.) */ + to_x = window_box_width (w, TEXT_AREA) - to_x - 1; + + /* Now move horizontally in the row to the glyph under *X. Second + argument is ZV to prevent move_it_in_display_line from matching + based on buffer positions. */ + move_it_in_display_line (&it, ZV, to_x, MOVE_TO_X); Fset_buffer (old_current_buffer); @@ -5964,6 +5423,22 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) if (STRINGP (it.string)) string = it.string; *pos = it.current; + if (it.what == IT_COMPOSITION + && it.cmp_it.nchars > 1 + && it.cmp_it.reversed_p) + { + /* The current display element is a grapheme cluster in a + composition. In that case, we need the position of the first + character of the cluster. But, as it.cmp_it.reversed_p is 1, + it.current points to the last character of the cluster, thus + we must move back to the first character of the same + cluster. */ + CHARPOS (pos->pos) -= it.cmp_it.nchars - 1; + if (STRINGP (it.string)) + BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); + else + BYTEPOS (pos->pos) = CHAR_TO_BYTE (CHARPOS (pos->pos)); + } #ifdef HAVE_WINDOW_SYSTEM if (it.what == IT_IMAGE) @@ -5985,8 +5460,8 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) if (img) { *dy -= row->ascent - glyph->ascent; - *dx += glyph->slice.x; - *dy += glyph->slice.y; + *dx += glyph->slice.img.x; + *dy += glyph->slice.img.y; /* Image slices positions are still relative to the entire image */ *width = img->width; *height = img->height; @@ -6026,14 +5501,9 @@ buffer_posn_from_coords (w, x, y, pos, object, dx, dy, width, height) *CHARPOS is set to the position in the string returned. */ Lisp_Object -mode_line_string (w, part, x, y, charpos, object, dx, dy, width, height) - struct window *w; - enum window_part part; - int *x, *y; - int *charpos; - Lisp_Object *object; - int *dx, *dy; - int *width, *height; +mode_line_string (struct window *w, enum window_part part, + int *x, int *y, EMACS_INT *charpos, Lisp_Object *object, + int *dx, int *dy, int *width, int *height) { struct glyph_row *row; struct glyph *glyph, *end; @@ -6100,14 +5570,9 @@ mode_line_string (w, part, x, y, charpos, object, dx, dy, width, height) the string returned. */ Lisp_Object -marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height) - struct window *w; - enum window_part part; - int *x, *y; - int *charpos; - Lisp_Object *object; - int *dx, *dy; - int *width, *height; +marginal_area_string (struct window *w, enum window_part part, + int *x, int *y, EMACS_INT *charpos, Lisp_Object *object, + int *dx, int *dy, int *width, int *height) { struct glyph_row *row = w->current_matrix->rows; struct glyph *glyph, *end; @@ -6162,8 +5627,8 @@ marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height) if (img != NULL) *object = img->spec; y0 -= row->ascent - glyph->ascent; - x0 += glyph->slice.x; - y0 += glyph->slice.y; + x0 += glyph->slice.img.x; + y0 += glyph->slice.img.y; } #endif } @@ -6196,13 +5661,10 @@ marginal_area_string (w, part, x, y, charpos, object, dx, dy, width, height) #ifdef SIGWINCH SIGTYPE -window_change_signal (signalnum) /* If we don't have an argument, */ - int signalnum; /* some compilers complain in signal calls. */ +window_change_signal (int signalnum) /* If we don't have an argument, */ + /* some compilers complain in signal calls. */ { int width, height; -#ifndef USE_CRT_DLL - extern int errno; -#endif int old_errno = errno; struct tty_display_info *tty; @@ -6248,8 +5710,7 @@ window_change_signal (signalnum) /* If we don't have an argument, */ safe to change frame sizes while a redisplay is in progress. */ void -do_pending_window_change (safe) - int safe; +do_pending_window_change (int safe) { /* If window_change_signal should have run before, run it now. */ if (redisplaying_p && !safe) @@ -6285,9 +5746,7 @@ do_pending_window_change (safe) safe to change frame sizes while a redisplay is in progress. */ void -change_frame_size (f, newheight, newwidth, pretend, delay, safe) - register struct frame *f; - int newheight, newwidth, pretend, delay, safe; +change_frame_size (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) { Lisp_Object tail, frame; @@ -6306,9 +5765,7 @@ change_frame_size (f, newheight, newwidth, pretend, delay, safe) } static void -change_frame_size_1 (f, newheight, newwidth, pretend, delay, safe) - register struct frame *f; - int newheight, newwidth, pretend, delay, safe; +change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) { int new_frame_total_cols; int count = SPECPDL_INDEX (); @@ -6437,8 +5894,7 @@ DEFUN ("open-termscript", Fopen_termscript, Sopen_termscript, 1, 1, "FOpen termscript file: ", doc: /* Start writing all terminal output to FILE as well as the terminal. FILE = nil means just close any termscript file currently open. */) - (file) - Lisp_Object file; + (Lisp_Object file) { struct tty_display_info *tty; @@ -6476,9 +5932,7 @@ Optional parameter TERMINAL specifies the tty terminal device to use. It may be a terminal object, a frame, or nil for the terminal used by the currently selected frame. In batch mode, STRING is sent to stdout when TERMINAL is nil. */) - (string, terminal) - Lisp_Object string; - Lisp_Object terminal; + (Lisp_Object string, Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); FILE *out; @@ -6519,8 +5973,7 @@ DEFUN ("ding", Fding, Sding, 0, 1, 0, doc: /* Beep, or flash the screen. Also, unless an argument is given, terminate any keyboard macro currently executing. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { if (!NILP (arg)) { @@ -6536,7 +5989,7 @@ terminate any keyboard macro currently executing. */) } void -bitch_at_user () +bitch_at_user (void) { if (noninteractive) putchar (07); @@ -6559,8 +6012,7 @@ fraction of a second. Optional second arg MILLISECONDS specifies an additional wait period, in milliseconds; this may be useful if your Emacs was built without floating point support. \(Not all operating systems support waiting for a fraction of a second.) */) - (seconds, milliseconds) - Lisp_Object seconds, milliseconds; + (Lisp_Object seconds, Lisp_Object milliseconds) { int sec, usec; @@ -6613,9 +6065,7 @@ Emacs was built without floating point support. */ Lisp_Object -sit_for (timeout, reading, do_display) - Lisp_Object timeout; - int reading, do_display; +sit_for (Lisp_Object timeout, int reading, int do_display) { int sec, usec; @@ -6666,8 +6116,7 @@ DEFUN ("redisplay", Fredisplay, Sredisplay, 0, 1, 0, If optional arg FORCE is non-nil or `redisplay-dont-pause' is non-nil, perform a full redisplay even if input is available. Return t if redisplay was performed, nil otherwise. */) - (force) - Lisp_Object force; + (Lisp_Object force) { int count; @@ -6711,8 +6160,7 @@ the current state. If VARIABLE is nil, an internal variable is used. Users should not pass nil for VARIABLE. */) - (variable) - Lisp_Object variable; + (Lisp_Object variable) { Lisp_Object state, tail, frame, buf; Lisp_Object *vecp, *end; @@ -6831,14 +6279,10 @@ pass nil for VARIABLE. */) decoding routine to set up variables in the terminal package. */ void -init_display () +init_display (void) { char *terminal_type; -#ifdef HAVE_X_WINDOWS - extern int display_arg; -#endif - /* Construct the space glyph. */ space_glyph.type = CHAR_GLYPH; SET_CHAR_GLYPH (space_glyph, ' ', DEFAULT_FACE_ID, 0); @@ -7038,8 +6482,7 @@ DEFUN ("internal-show-cursor", Finternal_show_cursor, WINDOW nil means use the selected window. SHOW non-nil means show a cursor in WINDOW in the next redisplay. SHOW nil means don't show a cursor. */) - (window, show) - Lisp_Object window, show; + (Lisp_Object window, Lisp_Object show) { /* Don't change cursor state while redisplaying. This could confuse output routines. */ @@ -7061,8 +6504,7 @@ DEFUN ("internal-show-cursor-p", Finternal_show_cursor_p, Sinternal_show_cursor_p, 0, 1, 0, doc: /* Value is non-nil if next redisplay will display a cursor in WINDOW. WINDOW nil or omitted means report on the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w; @@ -7078,7 +6520,7 @@ WINDOW nil or omitted means report on the selected window. */) DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame, Slast_nonminibuf_frame, 0, 0, 0, doc: /* Value is last nonminibuffer frame. */) - () + (void) { Lisp_Object frame = Qnil; @@ -7093,7 +6535,7 @@ DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame, ***********************************************************************/ void -syms_of_display () +syms_of_display (void) { defsubr (&Sredraw_frame); defsubr (&Sredraw_display); diff --git a/src/disptab.h b/src/disptab.h index e0f603346df..1a7f63050b6 100644 --- a/src/disptab.h +++ b/src/disptab.h @@ -32,7 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define DISP_INVIS_VECTOR(dp) ((dp)->extras[4]) #define DISP_BORDER_GLYPH(dp) ((dp)->extras[5]) -extern Lisp_Object disp_char_vector P_ ((struct Lisp_Char_Table *, int)); +extern Lisp_Object disp_char_vector (struct Lisp_Char_Table *, int); #define DISP_CHAR_VECTOR(dp, c) \ (ASCII_CHAR_P(c) \ @@ -44,10 +44,10 @@ extern Lisp_Object disp_char_vector P_ ((struct Lisp_Char_Table *, int)); : disp_char_vector ((dp), (c))) /* Defined in window.c. */ -extern struct Lisp_Char_Table *window_display_table P_ ((struct window *)); +extern struct Lisp_Char_Table *window_display_table (struct window *); /* Defined in indent.c. */ -extern struct Lisp_Char_Table *buffer_display_table P_ ((void)); +extern struct Lisp_Char_Table *buffer_display_table (void); /* Display table to use for vectors that don't specify their own. */ extern Lisp_Object Vstandard_display_table; diff --git a/src/doc.c b/src/doc.c index d1cc6e48fcf..7caa88a7b5e 100644 --- a/src/doc.c +++ b/src/doc.c @@ -25,19 +25,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/file.h> /* Must be after sys/types.h for USG*/ #include <ctype.h> #include <setjmp.h> - -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - #include "lisp.h" #include "buffer.h" #include "keyboard.h" @@ -45,10 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keymap.h" #include "buildobj.h" -#ifdef HAVE_INDEX -extern char *index P_ ((const char *, int)); -#endif - Lisp_Object Vdoc_file_name; Lisp_Object Qfunction_documentation; @@ -56,23 +45,18 @@ Lisp_Object Qfunction_documentation; /* A list of files used to build this Emacs binary. */ static Lisp_Object Vbuild_files; -extern Lisp_Object Voverriding_local_map; - -extern Lisp_Object Qremap; - /* Buffer used for reading from documentation file. */ static char *get_doc_string_buffer; static int get_doc_string_buffer_size; static unsigned char *read_bytecode_pointer; -Lisp_Object Fsnarf_documentation P_ ((Lisp_Object)); +Lisp_Object Fsnarf_documentation (Lisp_Object); /* readchar in lread.c calls back here to fetch the next byte. If UNREADFLAG is 1, we unread a byte. */ int -read_bytecode_char (unreadflag) - int unreadflag; +read_bytecode_char (int unreadflag) { if (unreadflag) { @@ -102,16 +86,14 @@ read_bytecode_char (unreadflag) and return a cons cell. */ Lisp_Object -get_doc_string (filepos, unibyte, definition) - Lisp_Object filepos; - int unibyte, definition; +get_doc_string (Lisp_Object filepos, int unibyte, int definition) { char *from, *to; register int fd; register char *name; register char *p, *p1; - int minsize; - int offset, position; + EMACS_INT minsize; + EMACS_INT offset, position; Lisp_Object file, tem; if (INTEGERP (filepos)) @@ -190,14 +172,14 @@ get_doc_string (filepos, unibyte, definition) p = get_doc_string_buffer; while (1) { - int space_left = (get_doc_string_buffer_size - - (p - get_doc_string_buffer)); + EMACS_INT space_left = (get_doc_string_buffer_size + - (p - get_doc_string_buffer)); int nread; /* Allocate or grow the buffer if we need to. */ if (space_left == 0) { - int in_buffer = p - get_doc_string_buffer; + EMACS_INT in_buffer = p - get_doc_string_buffer; get_doc_string_buffer_size += 16 * 1024; get_doc_string_buffer = (char *) xrealloc (get_doc_string_buffer, @@ -221,9 +203,9 @@ get_doc_string (filepos, unibyte, definition) if (!nread) break; if (p == get_doc_string_buffer) - p1 = (char *) index (p + offset, '\037'); + p1 = strchr (p + offset, '\037'); else - p1 = (char *) index (p, '\037'); + p1 = strchr (p, '\037'); if (p1) { *p1 = 0; @@ -296,10 +278,9 @@ get_doc_string (filepos, unibyte, definition) to - (get_doc_string_buffer + offset)); else { - /* Let the data determine whether the string is multibyte, - even if Emacs is running in --unibyte mode. */ - int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, - to - (get_doc_string_buffer + offset)); + /* The data determines whether the string is multibyte. */ + EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset, + to - (get_doc_string_buffer + offset)); return make_string_from_bytes (get_doc_string_buffer + offset, nchars, to - (get_doc_string_buffer + offset)); @@ -311,15 +292,13 @@ get_doc_string (filepos, unibyte, definition) of a compiled function from the .elc file. */ Lisp_Object -read_doc_string (filepos) - Lisp_Object filepos; +read_doc_string (Lisp_Object filepos) { return get_doc_string (filepos, 0, 1); } static int -reread_doc_file (file) - Lisp_Object file; +reread_doc_file (Lisp_Object file) { #if 0 Lisp_Object reply, prompt[3]; @@ -346,8 +325,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, doc: /* Return the documentation string of FUNCTION. Unless a non-nil second argument RAW is given, the string is passed through `substitute-command-keys'. */) - (function, raw) - Lisp_Object function, raw; + (Lisp_Object function, Lisp_Object raw) { Lisp_Object fun; Lisp_Object funcar; @@ -474,8 +452,7 @@ Third argument RAW omitted or nil means pass the result through This differs from `get' in that it can refer to strings stored in the `etc/DOC' file; and that it evaluates documentation properties that aren't strings. */) - (symbol, prop, raw) - Lisp_Object symbol, prop, raw; + (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw) { int try_reload = 1; Lisp_Object tem; @@ -515,10 +492,8 @@ aren't strings. */) /* Scanning the DOC files and placing docstring offsets into functions. */ static void -store_function_docstring (fun, offset) - Lisp_Object fun; - /* Use EMACS_INT because we get this from pointer subtraction. */ - EMACS_INT offset; +store_function_docstring (Lisp_Object fun, EMACS_INT offset) +/* Use EMACS_INT because we get offset from pointer subtraction. */ { fun = indirect_function (fun); @@ -538,7 +513,7 @@ store_function_docstring (fun, offset) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) - XSETCARFASTINT (tem, offset); + XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) store_function_docstring (XCDR (fun), offset); @@ -565,13 +540,12 @@ The function takes one argument, FILENAME, a string; it specifies the file name (without a directory) of the DOC file. That file is found in `../etc' now; later, when the dumped Emacs is run, the same file name is found in the `doc-directory'. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { int fd; char buf[1024 + 1]; - register int filled; - register int pos; + register EMACS_INT filled; + register EMACS_INT pos; register char *p, *end; Lisp_Object sym; char *name; @@ -605,7 +579,7 @@ the same file name is found in the `doc-directory'. */) for (beg = buildobj; *beg; beg = end) { - int len; + EMACS_INT len; while (*beg && isspace (*beg)) ++beg; @@ -643,7 +617,7 @@ the same file name is found in the `doc-directory'. */) /* p points to ^_Ffunctionname\n or ^_Vvarname\n or ^_Sfilename\n. */ if (p != end) { - end = (char *) index (p, '\n'); + end = strchr (p, '\n'); /* See if this is a file name, and if it is a file in build-files. */ if (p[1] == 'S') @@ -652,7 +626,7 @@ the same file name is found in the `doc-directory'. */) if (end - p > 4 && end[-2] == '.' && (end[-1] == 'o' || end[-1] == 'c')) { - int len = end - p - 2; + EMACS_INT len = end - p - 2; char *fromfile = alloca (len + 1); strncpy (fromfile, &p[2], len); fromfile[len] = 0; @@ -697,7 +671,7 @@ the same file name is found in the `doc-directory'. */) } pos += end - buf; filled -= end - buf; - bcopy (end, buf, filled); + memmove (buf, end, filled); } emacs_close (fd); return Qnil; @@ -718,23 +692,22 @@ thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ int Returns original STRING if no substitutions were made. Otherwise, a new string, without any text properties, is returned. */) - (string) - Lisp_Object string; + (Lisp_Object string) { unsigned char *buf; int changed = 0; register unsigned char *strp; register unsigned char *bufp; - int idx; - int bsize; + EMACS_INT idx; + EMACS_INT bsize; Lisp_Object tem; Lisp_Object keymap; unsigned char *start; - int length, length_byte; + EMACS_INT length, length_byte; Lisp_Object name; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; int multibyte; - int nchars; + EMACS_INT nchars; if (NILP (string)) return Qnil; @@ -776,7 +749,7 @@ a new string, without any text properties, is returned. */) if (len == 1) *bufp = *strp; else - bcopy (strp, bufp, len); + memcpy (bufp, strp, len); strp += len; bufp += len; nchars++; @@ -786,7 +759,7 @@ a new string, without any text properties, is returned. */) } else if (strp[0] == '\\' && strp[1] == '[') { - int start_idx; + EMACS_INT start_idx; int follow_remap = 1; changed = 1; @@ -825,10 +798,10 @@ a new string, without any text properties, is returned. */) if (NILP (tem)) /* but not on any keys */ { - int offset = bufp - buf; + EMACS_INT offset = bufp - buf; buf = (unsigned char *) xrealloc (buf, bsize += 4); bufp = buf + offset; - bcopy ("M-x ", bufp, 4); + memcpy (bufp, "M-x ", 4); bufp += 4; nchars += 4; if (multibyte) @@ -848,7 +821,7 @@ a new string, without any text properties, is returned. */) else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<')) { struct buffer *oldbuf; - int start_idx; + EMACS_INT start_idx; /* This is for computing the SHADOWS arg for describe_map_tree. */ Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil); Lisp_Object earlier_maps; @@ -919,10 +892,10 @@ a new string, without any text properties, is returned. */) length_byte = SBYTES (tem); subst: { - int offset = bufp - buf; + EMACS_INT offset = bufp - buf; buf = (unsigned char *) xrealloc (buf, bsize += length_byte); bufp = buf + offset; - bcopy (start, bufp, length_byte); + memcpy (bufp, start, length_byte); bufp += length_byte; nchars += length; /* Check STRING again in case gc relocated it. */ @@ -939,7 +912,7 @@ a new string, without any text properties, is returned. */) if (len == 1) *bufp = *strp; else - bcopy (strp, bufp, len); + memcpy (bufp, strp, len); strp += len; bufp += len; nchars++; @@ -955,7 +928,7 @@ a new string, without any text properties, is returned. */) } void -syms_of_doc () +syms_of_doc (void) { Qfunction_documentation = intern_c_string ("function-documentation"); staticpro (&Qfunction_documentation); diff --git a/src/doprnt.c b/src/doprnt.c index cf8a9280863..02adc51f1e5 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -33,22 +33,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - #include "lisp.h" -#ifndef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 /* IEEE double */ -#endif - /* Since we use the macro CHAR_HEAD_P, we have to include this, but don't have to include others because CHAR_HEAD_P does not contains another macro. */ #include "character.h" -static int doprnt1 (); +#ifndef DBL_MAX_10_EXP +#define DBL_MAX_10_EXP 308 /* IEEE double */ +#endif /* Generate output from a format-spec FORMAT, terminated at position FORMAT_END. @@ -60,17 +54,11 @@ static int doprnt1 (); String arguments are passed as C strings. Integers are passed as C integers. */ -int -doprnt (buffer, bufsize, format, format_end, nargs, args) - char *buffer; - register int bufsize; - char *format; - char *format_end; - int nargs; - char **args; +EMACS_INT +doprnt (char *buffer, register int bufsize, const char *format, + const char *format_end, va_list ap) { - int cnt = 0; /* Number of arg to gobble next */ - register char *fmt = format; /* Pointer into format string */ + const char *fmt = format; /* Pointer into format string */ register char *bufptr = buffer; /* Pointer into output buffer.. */ /* Use this for sprintf unless we need something really big. */ @@ -108,7 +96,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) if (*fmt == '%') /* Check for a '%' character */ { unsigned size_bound = 0; - int width; /* Columns occupied by STRING. */ + EMACS_INT width; /* Columns occupied by STRING. */ fmt++; /* Copy this one %-spec into fmtcpy. */ @@ -169,8 +157,6 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) case 'd': case 'o': case 'x': - if (cnt == nargs) - error ("Not enough arguments for format string"); if (sizeof (int) == sizeof (EMACS_INT)) ; else if (sizeof (long) == sizeof (EMACS_INT)) @@ -181,7 +167,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) string++; else abort (); - sprintf (sprintf_buffer, fmtcpy, args[cnt++]); + sprintf (sprintf_buffer, fmtcpy, va_arg(ap, char *)); /* Now copy into final output, truncating as nec. */ string = (unsigned char *) sprintf_buffer; goto doit; @@ -190,12 +176,8 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) case 'e': case 'g': { - union { double d; char *half[2]; } u; - if (cnt + 1 == nargs) - error ("Not enough arguments for format string"); - u.half[0] = args[cnt++]; - u.half[1] = args[cnt++]; - sprintf (sprintf_buffer, fmtcpy, u.d); + double d = va_arg(ap, double); + sprintf (sprintf_buffer, fmtcpy, d); /* Now copy into final output, truncating as nec. */ string = (unsigned char *) sprintf_buffer; goto doit; @@ -204,11 +186,9 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) case 'S': string[-1] = 's'; case 's': - if (cnt == nargs) - error ("Not enough arguments for format string"); if (fmtcpy[1] != 's') minlen = atoi (&fmtcpy[1]); - string = (unsigned char *) args[cnt++]; + string = va_arg(ap, unsigned char *); tem = strlen (string); width = strwidth (string, tem); goto doit1; @@ -237,12 +217,12 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) /* Truncate the string at character boundary. */ tem = bufsize; while (!CHAR_HEAD_P (string[tem - 1])) tem--; - bcopy (string, bufptr, tem); + memcpy (bufptr, string, tem); /* We must calculate WIDTH again. */ width = strwidth (bufptr, tem); } else - bcopy (string, bufptr, tem); + memcpy (bufptr, string, tem); bufptr += tem; bufsize -= tem; if (minlen < 0) @@ -258,16 +238,21 @@ doprnt (buffer, bufsize, format, format_end, nargs, args) continue; case 'c': - if (cnt == nargs) - error ("Not enough arguments for format string"); - tem = CHAR_STRING ((int) (EMACS_INT) args[cnt], charbuf); - string = charbuf; - cnt++; - string[tem] = 0; - width = strwidth (string, tem); - if (fmtcpy[1] != 'c') - minlen = atoi (&fmtcpy[1]); - goto doit1; + { + /* Sometimes for %c we pass a char, which would widen + to int. Sometimes we pass XFASTINT() or XINT() + values, which would be EMACS_INT. Let's hope that + both are passed the same way, otherwise we'll need + to rewrite callers. */ + EMACS_INT chr = va_arg(ap, EMACS_INT); + tem = CHAR_STRING ((int) chr, charbuf); + string = charbuf; + string[tem] = 0; + width = strwidth (string, tem); + if (fmtcpy[1] != 'c') + minlen = atoi (&fmtcpy[1]); + goto doit1; + } case '%': fmt--; /* Drop thru and this % will be treated as normal */ diff --git a/src/dosfns.c b/src/dosfns.c index d04c28b3156..fea70386f18 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* The entire file is within this conditional */ #include <stdio.h> -#include <string.h> #include <dos.h> #include <setjmp.h> #include "lisp.h" @@ -48,10 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <grp.h> #include <crt0.h> -#ifndef __DJGPP_MINOR__ -# define __tb _go32_info_block.linear_address_of_transfer_buffer; -#endif - DEFUN ("int86", Fint86, Sint86, 2, 2, 0, doc: /* Call specific MS-DOS interrupt number INTERRUPT with REGISTERS. Return the updated REGISTER vector. @@ -59,13 +54,11 @@ Return the updated REGISTER vector. INTERRUPT should be an integer in the range 0 to 255. REGISTERS should be a vector produced by `make-register' and `set-register-value'. */) - (interrupt, registers) - Lisp_Object interrupt, registers; + (Lisp_Object interrupt, Lisp_Object registers) { register int i; int no; union REGS inregs, outregs; - Lisp_Object val; CHECK_NUMBER (interrupt); no = (unsigned long) XINT (interrupt); @@ -101,13 +94,11 @@ REGISTERS should be a vector produced by `make-register' and DEFUN ("msdos-memget", Fdos_memget, Sdos_memget, 2, 2, 0, doc: /* Read DOS memory at offset ADDRESS into VECTOR. Return the updated VECTOR. */) - (address, vector) - Lisp_Object address, vector; + (Lisp_Object address, Lisp_Object vector) { register int i; int offs, len; char *buf; - Lisp_Object val; CHECK_NUMBER (address); offs = (unsigned long) XINT (address); @@ -126,13 +117,11 @@ Return the updated VECTOR. */) DEFUN ("msdos-memput", Fdos_memput, Sdos_memput, 2, 2, 0, doc: /* Write DOS memory at offset ADDRESS from VECTOR. */) - (address, vector) - Lisp_Object address, vector; + (Lisp_Object address, Lisp_Object vector) { register int i; int offs, len; char *buf; - Lisp_Object val; CHECK_NUMBER (address); offs = (unsigned long) XINT (address); @@ -157,8 +146,7 @@ DEFUN ("msdos-set-keyboard", Fmsdos_set_keyboard, Smsdos_set_keyboard, 1, 2, 0, If the optional argument ALLKEYS is non-nil, the keyboard is mapped for all keys; otherwise it is only used when the ALT key is pressed. The current keyboard layout is available in dos-keyboard-code. */) - (country_code, allkeys) - Lisp_Object country_code, allkeys; + (Lisp_Object country_code, Lisp_Object allkeys) { CHECK_NUMBER (country_code); if (!dos_set_keyboard (XINT (country_code), !NILP (allkeys))) @@ -172,7 +160,7 @@ The current keyboard layout is available in dos-keyboard-code. */) DEFUN ("msdos-mouse-p", Fmsdos_mouse_p, Smsdos_mouse_p, 0, 0, 0, doc: /* Report whether a mouse is present. */) - () + (void) { if (have_mouse) return Qt; @@ -183,7 +171,7 @@ DEFUN ("msdos-mouse-p", Fmsdos_mouse_p, Smsdos_mouse_p, 0, 0, 0, DEFUN ("msdos-mouse-init", Fmsdos_mouse_init, Smsdos_mouse_init, 0, 0, "", doc: /* Initialize and enable mouse if available. */) - () + (void) { if (have_mouse) { @@ -196,7 +184,7 @@ DEFUN ("msdos-mouse-init", Fmsdos_mouse_init, Smsdos_mouse_init, 0, 0, "", DEFUN ("msdos-mouse-enable", Fmsdos_mouse_enable, Smsdos_mouse_enable, 0, 0, "", doc: /* Enable mouse if available. */) - () + (void) { if (have_mouse) { @@ -208,7 +196,7 @@ DEFUN ("msdos-mouse-enable", Fmsdos_mouse_enable, Smsdos_mouse_enable, 0, 0, "", DEFUN ("msdos-mouse-disable", Fmsdos_mouse_disable, Smsdos_mouse_disable, 0, 0, "", doc: /* Disable mouse if available. */) - () + (void) { mouse_off (); if (have_mouse) have_mouse = -1; @@ -218,7 +206,7 @@ DEFUN ("msdos-mouse-disable", Fmsdos_mouse_disable, Smsdos_mouse_disable, 0, 0, DEFUN ("insert-startup-screen", Finsert_startup_screen, Sinsert_startup_screen, 0, 0, "", doc: /* Insert copy of screen contents prior to starting Emacs. Return nil if startup screen is not available. */) - () + (void) { char *s; int rows, cols, i, j; @@ -287,13 +275,15 @@ restore_parent_vm_title (void) #endif /* !HAVE_X_WINDOWS */ void -init_dosfns () +init_dosfns (void) { union REGS regs; _go32_dpmi_registers dpmiregs; unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; #ifndef SYSTEM_MALLOC + extern void get_lim_data (void); + get_lim_data (); /* why the hell isn't this called elsewhere? */ #endif @@ -385,8 +375,6 @@ init_dosfns () } #endif /* !HAVE_X_WINDOWS */ -#if __DJGPP__ >= 2 - /* Without this, we never see hidden files. Don't OR it with the previous value, so the value recorded at dump time, possibly with `preserve-case' flags set, won't get through. */ @@ -398,7 +386,6 @@ init_dosfns () if (!NILP (Fmsdos_long_file_names ())) __opendir_flags |= __OPENDIR_PRESERVE_CASE; #endif /* __DJGPP_MINOR__ == 0 */ -#endif /* __DJGPP__ >= 2 */ } #ifndef HAVE_X_WINDOWS @@ -488,9 +475,7 @@ w95_set_virtual_machine_title (const char *title_string) sets the name in the frame struct, but has no other effects. */ void -x_set_title (f, name) - struct frame *f; - Lisp_Object name; +x_set_title (struct frame *f, Lisp_Object name) { /* Don't change the title if it's already NAME. */ if (EQ (name, f->title)) @@ -518,8 +503,7 @@ Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total storage of the file system, FREE is the free storage, and AVAIL is the storage available to a non-superuser. All 3 numbers are in bytes. If the underlying system call fails, value is nil. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { struct statfs stfs; Lisp_Object encoded, value; @@ -543,7 +527,7 @@ If the underlying system call fails, value is nil. */) (There are no other processes on DOS, right?) */ Lisp_Object -list_system_processes () +list_system_processes (void) { Lisp_Object proclist = Qnil; @@ -572,6 +556,7 @@ system_process_attributes (Lisp_Object pid) int i; Lisp_Object cmd_str, decoded_cmd, tem; double pmem; + EXFUN (Fget_internal_run_time, 0); #ifndef SYSTEM_MALLOC extern unsigned long ret_lim_data (); #endif @@ -696,7 +681,8 @@ dos_cleanup (void) /* * Define everything */ -syms_of_dosfns () +void +syms_of_dosfns (void) { defsubr (&Sint86); defsubr (&Sdos_memget); diff --git a/src/dosfns.h b/src/dosfns.h index 1759ffd8a90..d31401247b4 100644 --- a/src/dosfns.h +++ b/src/dosfns.h @@ -38,8 +38,9 @@ extern Lisp_Object Vdos_windows_version; #ifndef HAVE_X_WINDOWS extern Lisp_Object Vdos_display_scancodes; -extern int msdos_stdcolor_idx P_ ((const char *)); -extern Lisp_Object msdos_stdcolor_name P_ ((int)); +extern int msdos_stdcolor_idx (const char *); +extern Lisp_Object msdos_stdcolor_name (int); +extern void x_set_title (struct frame *, Lisp_Object); #endif /* arch-tag: a83b8c4c-63c8-451e-9e94-bc72e3e2f8bc diff --git a/src/ecrt0.c b/src/ecrt0.c deleted file mode 100644 index 7dbbd6c5ef1..00000000000 --- a/src/ecrt0.c +++ /dev/null @@ -1,173 +0,0 @@ -/* C code startup routine. - Copyright (C) 1985, 1986, 1992, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - - -/* The standard Vax 4.2 Unix crt0.c cannot be used for Emacs - because it makes `environ' an initialized variable. - It is easiest to have a special crt0.c on all machines - though I don't know whether other machines actually need it. */ - -/* On the vax and 68000, in BSD4.2 and USG5.2, - this is the data format on startup: - (vax) ap and fp are unpredictable as far as I know; don't use them. - sp -> word containing argc - word pointing to first arg string - [word pointing to next arg string]... 0 or more times - 0 -Optionally: - [word pointing to environment variable]... 1 or more times - ... - 0 -And always: - first arg string - [next arg string]... 0 or more times -*/ - -#ifdef emacs -#include <config.h> -#endif - -/* ******** WARNING ******** - Do not insert any data definitions before data_start! - Since this is the first file linked, the address of the following - variable should correspond to the start of initialized data space. - On some systems this is a constant that is independent of the text - size for shared executables. On others, it is a function of the - text size. In short, this seems to be the most portable way to - discover the start of initialized data space dynamically at runtime, - for either shared or unshared executables, on either swapping or - virtual systems. It only requires that the linker allocate objects - in the order encountered, a reasonable model for most Unix systems. - Similarly, note that the address of _start() should be the start - of text space. Fred Fish, UniSoft Systems Inc. */ - -int data_start = 0; - -#ifdef NEED_ERRNO -int errno; -#endif - -#ifndef MSDOS -char **environ; -#endif - -#ifndef static -/* On systems where the static storage class is usable, this function - should be declared as static. Otherwise, the static keyword has - been defined to be something else, and code for those systems must - take care of this declaration appropriately. */ -static start1 (); -#endif - -#ifdef CRT0_DUMMIES - -/* Define symbol "start": here; some systems want that symbol. */ -asm(" .text "); -asm(" .globl start "); -asm(" start: "); - -_start () -{ -/* On vax, nothing is pushed here */ - start1 (); -} - -static -start1 (CRT0_DUMMIES argc, xargv) - int argc; - char *xargv; -{ - register char **argv = &xargv; - environ = argv + argc + 1; - - if ((char *)environ == xargv) - environ--; - exit (main (argc, argv, environ)); - - /* Refer to `start1' so GCC will not think it is never called - and optimize it out. */ - (void) &start1; -} -#else /* not CRT0_DUMMIES */ - -/* This is a kludge. Now that the CRT0_DUMMIES mechanism above exists, - most of these machines could use the vax code above - with some suitable definition of CRT0_DUMMIES. - Then the symbol m68k could be flushed. - But I don't want to risk breaking these machines - in a version 17 patch release, so that change is being put off. */ - -#ifdef m68k /* Can't do it all from C */ - asm (" global _start"); - asm (" text"); - asm ("_start:"); - asm (" comm splimit%,4"); - asm (" global exit"); - asm (" text"); - asm (" mov.l %d0,splimit%"); - asm (" jsr start1"); - asm (" mov.l %d0,(%sp)"); - asm (" jsr exit"); - asm (" mov.l &1,%d0"); /* d0 = 1 => exit */ - asm (" trap &0"); - -/* ignore takes care of skipping the a6 value pushed in start. */ -static -start1 (argc, xargv) - int argc; - char *xargv; -{ - register char **argv = &xargv; - environ = argv + argc + 1; - - if ((char *)environ == xargv) - environ--; - exit (main (argc, argv, environ)); -} - -#endif /* m68k */ - -#endif /* not CRT0_DUMMIES */ - -#ifdef __sparc__ -asm (".global __start"); -asm (".text"); -asm ("__start:"); -asm (" mov 0, %fp"); -asm (" ld [%sp + 64], %o0"); -asm (" add %sp, 68, %o1"); -asm (" sll %o0, 2, %o2"); -asm (" add %o2, 4, %o2"); -asm (" add %o1, %o2, %o2"); -asm (" sethi %hi(_environ), %o3"); -asm (" st %o2, [%o3+%lo(_environ)]"); -asm (" andn %sp, 7, %sp"); -asm (" call _main"); -asm (" sub %sp, 24, %sp"); -asm (" call __exit"); -asm (" nop"); - -#endif /* __sparc__ */ - -#if __FreeBSD__ == 2 -char *__progname; -#endif - -/* arch-tag: 4025c2fb-d6b1-4d29-b1b6-8100b6bd1e74 - (do not change this comment) */ diff --git a/src/editfns.c b/src/editfns.c index ea279a462f2..f76beb5e678 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -86,38 +86,35 @@ extern char **environ; (1000 - TM_YEAR_BASE <= (tm_year) && (tm_year) <= 9999 - TM_YEAR_BASE) #endif -extern size_t emacs_strftimeu P_ ((char *, size_t, const char *, - const struct tm *, int)); +extern size_t emacs_strftimeu (char *, size_t, const char *, + const struct tm *, int); #ifdef WINDOWSNT -extern Lisp_Object w32_get_internal_run_time (); +extern Lisp_Object w32_get_internal_run_time (void); #endif -static int tm_diff P_ ((struct tm *, struct tm *)); -static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *)); -static void update_buffer_properties P_ ((int, int)); -static Lisp_Object region_limit P_ ((int)); -int lisp_time_argument P_ ((Lisp_Object, time_t *, int *)); -static size_t emacs_memftimeu P_ ((char *, size_t, const char *, - size_t, const struct tm *, int)); +static int tm_diff (struct tm *, struct tm *); +static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, + EMACS_INT *, Lisp_Object, EMACS_INT *); +static void update_buffer_properties (EMACS_INT, EMACS_INT); +static Lisp_Object region_limit (int); +static size_t emacs_memftimeu (char *, size_t, const char *, + size_t, const struct tm *, int); static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), void (*) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int), int, int, Lisp_Object *); -static Lisp_Object subst_char_in_region_unwind P_ ((Lisp_Object)); -static Lisp_Object subst_char_in_region_unwind_1 P_ ((Lisp_Object)); -static void transpose_markers P_ ((int, int, int, int, int, int, int, int)); - -#ifdef HAVE_INDEX -extern char *index P_ ((const char *, int)); -#endif +static Lisp_Object subst_char_in_region_unwind (Lisp_Object); +static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object); +static void transpose_markers (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT); Lisp_Object Vbuffer_access_fontify_functions; Lisp_Object Qbuffer_access_fontify_functions; Lisp_Object Vbuffer_access_fontified_property; -Lisp_Object Fuser_full_name P_ ((Lisp_Object)); +Lisp_Object Fuser_full_name (Lisp_Object); /* Non-nil means don't stop at field boundary in text motion commands. */ @@ -141,7 +138,7 @@ Lisp_Object Qboundary; void -init_editfns () +init_editfns (void) { char *user_name; register unsigned char *p; @@ -209,8 +206,7 @@ init_editfns () DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0, doc: /* Convert arg CHAR to a string containing that character. usage: (char-to-string CHAR) */) - (character) - Lisp_Object character; + (Lisp_Object character) { int len; unsigned char str[MAX_MULTIBYTE_LENGTH]; @@ -223,8 +219,7 @@ usage: (char-to-string CHAR) */) DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0, doc: /* Convert arg BYTE to a string containing that byte. */) - (byte) - Lisp_Object byte; + (Lisp_Object byte) { unsigned char b; CHECK_NUMBER (byte); @@ -235,8 +230,7 @@ DEFUN ("byte-to-string", Fbyte_to_string, Sbyte_to_string, 1, 1, 0, DEFUN ("string-to-char", Fstring_to_char, Sstring_to_char, 1, 1, 0, doc: /* Convert arg STRING to a character, the first character of that string. A multibyte character is handled correctly. */) - (string) - register Lisp_Object string; + (register Lisp_Object string) { register Lisp_Object val; CHECK_STRING (string); @@ -253,8 +247,7 @@ A multibyte character is handled correctly. */) } static Lisp_Object -buildmark (charpos, bytepos) - int charpos, bytepos; +buildmark (EMACS_INT charpos, EMACS_INT bytepos) { register Lisp_Object mark; mark = Fmake_marker (); @@ -265,7 +258,7 @@ buildmark (charpos, bytepos) DEFUN ("point", Fpoint, Spoint, 0, 0, 0, doc: /* Return value of point, as an integer. Beginning of buffer is position (point-min). */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, PT); @@ -274,14 +267,13 @@ Beginning of buffer is position (point-min). */) DEFUN ("point-marker", Fpoint_marker, Spoint_marker, 0, 0, 0, doc: /* Return value of point, as a marker object. */) - () + (void) { return buildmark (PT, PT_BYTE); } -int -clip_to_bounds (lower, num, upper) - int lower, num, upper; +EMACS_INT +clip_to_bounds (EMACS_INT lower, EMACS_INT num, EMACS_INT upper) { if (num < lower) return lower; @@ -296,10 +288,9 @@ DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ", Beginning of buffer is position (point-min), end is (point-max). The return value is POSITION. */) - (position) - register Lisp_Object position; + (register Lisp_Object position) { - int pos; + EMACS_INT pos; if (MARKERP (position) && current_buffer == XMARKER (position)->buffer) @@ -328,10 +319,8 @@ The return value is POSITION. */) If there is no region active, signal an error. */ static Lisp_Object -region_limit (beginningp) - int beginningp; +region_limit (int beginningp) { - extern Lisp_Object Vmark_even_if_inactive; /* Defined in callint.c. */ Lisp_Object m; if (!NILP (Vtransient_mark_mode) @@ -349,15 +338,15 @@ region_limit (beginningp) } DEFUN ("region-beginning", Fregion_beginning, Sregion_beginning, 0, 0, 0, - doc: /* Return position of beginning of region, as an integer. */) - () + doc: /* Return the integer value of point or mark, whichever is smaller. */) + (void) { return region_limit (1); } DEFUN ("region-end", Fregion_end, Sregion_end, 0, 0, 0, - doc: /* Return position of end of region, as an integer. */) - () + doc: /* Return the integer value of point or mark, whichever is larger. */) + (void) { return region_limit (0); } @@ -366,7 +355,7 @@ DEFUN ("mark-marker", Fmark_marker, Smark_marker, 0, 0, 0, doc: /* Return this buffer's mark, as a marker object. Watch out! Moving this marker changes the mark position. If you set the marker not to point anywhere, the buffer will have no mark. */) - () + (void) { return current_buffer->mark; } @@ -377,14 +366,11 @@ If you set the marker not to point anywhere, the buffer will have no mark. */) of length LEN. */ static int -overlays_around (pos, vec, len) - int pos; - Lisp_Object *vec; - int len; +overlays_around (EMACS_INT pos, Lisp_Object *vec, int len) { Lisp_Object overlay, start, end; struct Lisp_Overlay *tail; - int startpos, endpos; + EMACS_INT startpos, endpos; int idx = 0; for (tail = current_buffer->overlays_before; tail; tail = tail->next) @@ -436,9 +422,7 @@ overlays_around (pos, vec, len) window-specific overlays are considered only if they are associated with OBJECT. */ Lisp_Object -get_pos_property (position, prop, object) - Lisp_Object position, object; - register Lisp_Object prop; +get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object object) { CHECK_NUMBER_COERCE_MARKER (position); @@ -454,7 +438,7 @@ get_pos_property (position, prop, object) return Fget_text_property (position, prop, object); else { - int posn = XINT (position); + EMACS_INT posn = XINT (position); int noverlays; Lisp_Object *overlay_vec, tem; struct buffer *obuf = current_buffer; @@ -533,11 +517,9 @@ get_pos_property (position, prop, object) is not stored. */ static void -find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end) - Lisp_Object pos; - Lisp_Object merge_at_boundary; - Lisp_Object beg_limit, end_limit; - int *beg, *end; +find_field (Lisp_Object pos, Lisp_Object merge_at_boundary, + Lisp_Object beg_limit, + EMACS_INT *beg, Lisp_Object end_limit, EMACS_INT *end) { /* Fields right before and after the point. */ Lisp_Object before_field, after_field; @@ -651,10 +633,9 @@ DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, doc: /* Delete the field surrounding POS. A field is a region of text with the same `field' property. If POS is nil, the value of point is used for POS. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { - int beg, end; + EMACS_INT beg, end; find_field (pos, Qnil, Qnil, &beg, Qnil, &end); if (beg != end) del_range (beg, end); @@ -665,10 +646,9 @@ DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, doc: /* Return the contents of the field surrounding POS as a string. A field is a region of text with the same `field' property. If POS is nil, the value of point is used for POS. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { - int beg, end; + EMACS_INT beg, end; find_field (pos, Qnil, Qnil, &beg, Qnil, &end); return make_buffer_string (beg, end, 1); } @@ -677,10 +657,9 @@ DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_ doc: /* Return the contents of the field around POS, without text properties. A field is a region of text with the same `field' property. If POS is nil, the value of point is used for POS. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { - int beg, end; + EMACS_INT beg, end; find_field (pos, Qnil, Qnil, &beg, Qnil, &end); return make_buffer_string (beg, end, 0); } @@ -693,10 +672,9 @@ If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its field, then the beginning of the *previous* field is returned. If LIMIT is non-nil, it is a buffer position; if the beginning of the field is before LIMIT, then LIMIT will be returned instead. */) - (pos, escape_from_edge, limit) - Lisp_Object pos, escape_from_edge, limit; + (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) { - int beg; + EMACS_INT beg; find_field (pos, escape_from_edge, limit, &beg, Qnil, 0); return make_number (beg); } @@ -709,10 +687,9 @@ If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, then the end of the *following* field is returned. If LIMIT is non-nil, it is a buffer position; if the end of the field is after LIMIT, then LIMIT will be returned instead. */) - (pos, escape_from_edge, limit) - Lisp_Object pos, escape_from_edge, limit; + (Lisp_Object pos, Lisp_Object escape_from_edge, Lisp_Object limit) { - int end; + EMACS_INT end; find_field (pos, escape_from_edge, Qnil, 0, limit, &end); return make_number (end); } @@ -744,12 +721,10 @@ If the optional argument INHIBIT-CAPTURE-PROPERTY is non-nil, and OLD-POS has a non-nil property of that name, then any field boundaries are ignored. Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) - (new_pos, old_pos, escape_from_edge, only_in_line, inhibit_capture_property) - Lisp_Object new_pos, old_pos; - Lisp_Object escape_from_edge, only_in_line, inhibit_capture_property; + (Lisp_Object new_pos, Lisp_Object old_pos, Lisp_Object escape_from_edge, Lisp_Object only_in_line, Lisp_Object inhibit_capture_property) { /* If non-zero, then the original point, before re-positioning. */ - int orig_point = 0; + EMACS_INT orig_point = 0; int fwd; Lisp_Object prev_old, prev_new; @@ -834,6 +809,9 @@ DEFUN ("line-beginning-position", With argument N not nil or 1, move forward N - 1 lines first. If scan reaches end of buffer, return that position. +The returned position is of the first character in the logical order, +i.e. the one that has the smallest character position. + This function constrains the returned position to the current field unless that would be on a different line than the original, unconstrained result. If N is nil or 1, and a front-sticky field @@ -841,10 +819,9 @@ starts at point, the scan stops as soon as it starts. To ignore field boundaries bind `inhibit-field-text-motion' to t. This function does not move point. */) - (n) - Lisp_Object n; + (Lisp_Object n) { - int orig, orig_byte, end; + EMACS_INT orig, orig_byte, end; int count = SPECPDL_INDEX (); specbind (Qinhibit_point_motion_hooks, Qt); @@ -873,6 +850,9 @@ DEFUN ("line-end-position", Fline_end_position, Sline_end_position, 0, 1, 0, With argument N not nil or 1, move forward N - 1 lines first. If scan reaches end of buffer, return that position. +The returned position is of the last character in the logical order, +i.e. the character whose buffer position is the largest one. + This function constrains the returned position to the current field unless that would be on a different line than the original, unconstrained result. If N is nil or 1, and a rear-sticky field ends @@ -880,11 +860,10 @@ at point, the scan stops as soon as it starts. To ignore field boundaries bind `inhibit-field-text-motion' to t. This function does not move point. */) - (n) - Lisp_Object n; + (Lisp_Object n) { - int end_pos; - int orig = PT; + EMACS_INT end_pos; + EMACS_INT orig = PT; if (NILP (n)) XSETFASTINT (n, 1); @@ -900,7 +879,7 @@ This function does not move point. */) Lisp_Object -save_excursion_save () +save_excursion_save (void) { int visible = (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer); @@ -913,8 +892,7 @@ save_excursion_save () } Lisp_Object -save_excursion_restore (info) - Lisp_Object info; +save_excursion_restore (Lisp_Object info) { Lisp_Object tem, tem1, omark, nmark; struct gcpro gcpro1, gcpro2, gcpro3; @@ -1013,8 +991,7 @@ If you only want to save the current buffer but not point nor mark, then just use `save-current-buffer', or even `with-current-buffer'. usage: (save-excursion &rest BODY) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object val; int count = SPECPDL_INDEX (); @@ -1029,8 +1006,7 @@ DEFUN ("save-current-buffer", Fsave_current_buffer, Ssave_current_buffer, 0, UNE doc: /* Save the current buffer; execute BODY; restore the current buffer. Executes BODY just like `progn'. usage: (save-current-buffer &rest BODY) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object val; int count = SPECPDL_INDEX (); @@ -1044,8 +1020,7 @@ usage: (save-current-buffer &rest BODY) */) DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, doc: /* Return the number of characters in the current buffer. If BUFFER, return the number of characters in that buffer instead. */) - (buffer) - Lisp_Object buffer; + (Lisp_Object buffer) { if (NILP (buffer)) return make_number (Z - BEG); @@ -1060,7 +1035,7 @@ If BUFFER, return the number of characters in that buffer instead. */) DEFUN ("point-min", Fpoint_min, Spoint_min, 0, 0, 0, doc: /* Return the minimum permissible value of point in the current buffer. This is 1, unless narrowing (a buffer restriction) is in effect. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, BEGV); @@ -1070,7 +1045,7 @@ This is 1, unless narrowing (a buffer restriction) is in effect. */) DEFUN ("point-min-marker", Fpoint_min_marker, Spoint_min_marker, 0, 0, 0, doc: /* Return a marker to the minimum permissible value of point in this buffer. This is the beginning, unless narrowing (a buffer restriction) is in effect. */) - () + (void) { return buildmark (BEGV, BEGV_BYTE); } @@ -1079,7 +1054,7 @@ DEFUN ("point-max", Fpoint_max, Spoint_max, 0, 0, 0, doc: /* Return the maximum permissible value of point in the current buffer. This is (1+ (buffer-size)), unless narrowing (a buffer restriction) is in effect, in which case it is less. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, ZV); @@ -1090,7 +1065,7 @@ DEFUN ("point-max-marker", Fpoint_max_marker, Spoint_max_marker, 0, 0, 0, doc: /* Return a marker to the maximum permissible value of point in this buffer. This is (1+ (buffer-size)), unless narrowing (a buffer restriction) is in effect, in which case it is less. */) - () + (void) { return buildmark (ZV, ZV_BYTE); } @@ -1098,7 +1073,7 @@ is in effect, in which case it is less. */) DEFUN ("gap-position", Fgap_position, Sgap_position, 0, 0, 0, doc: /* Return the position of the gap, in the current buffer. See also `gap-size'. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, GPT); @@ -1108,7 +1083,7 @@ See also `gap-size'. */) DEFUN ("gap-size", Fgap_size, Sgap_size, 0, 0, 0, doc: /* Return the size of the current buffer's gap. See also `gap-position'. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, GAP_SIZE); @@ -1118,8 +1093,7 @@ See also `gap-position'. */) DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0, doc: /* Return the byte position for character position POSITION. If POSITION is out of range, the value is nil. */) - (position) - Lisp_Object position; + (Lisp_Object position) { CHECK_NUMBER_COERCE_MARKER (position); if (XINT (position) < BEG || XINT (position) > Z) @@ -1130,8 +1104,7 @@ If POSITION is out of range, the value is nil. */) DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, doc: /* Return the character position for byte position BYTEPOS. If BYTEPOS is out of range, the value is nil. */) - (bytepos) - Lisp_Object bytepos; + (Lisp_Object bytepos) { CHECK_NUMBER (bytepos); if (XINT (bytepos) < BEG_BYTE || XINT (bytepos) > Z_BYTE) @@ -1142,7 +1115,7 @@ If BYTEPOS is out of range, the value is nil. */) DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 0, 0, doc: /* Return the character following point, as a number. At the end of the buffer or accessible region, return 0. */) - () + (void) { Lisp_Object temp; if (PT >= ZV) @@ -1155,14 +1128,14 @@ At the end of the buffer or accessible region, return 0. */) DEFUN ("preceding-char", Fprevious_char, Sprevious_char, 0, 0, 0, doc: /* Return the character preceding point, as a number. At the beginning of the buffer or accessible region, return 0. */) - () + (void) { Lisp_Object temp; if (PT <= BEGV) XSETFASTINT (temp, 0); else if (!NILP (current_buffer->enable_multibyte_characters)) { - int pos = PT_BYTE; + EMACS_INT pos = PT_BYTE; DEC_POS (pos); XSETFASTINT (temp, FETCH_CHAR (pos)); } @@ -1174,7 +1147,7 @@ At the beginning of the buffer or accessible region, return 0. */) DEFUN ("bobp", Fbobp, Sbobp, 0, 0, 0, doc: /* Return t if point is at the beginning of the buffer. If the buffer is narrowed, this means the beginning of the narrowed part. */) - () + (void) { if (PT == BEGV) return Qt; @@ -1184,7 +1157,7 @@ If the buffer is narrowed, this means the beginning of the narrowed part. */) DEFUN ("eobp", Feobp, Seobp, 0, 0, 0, doc: /* Return t if point is at the end of the buffer. If the buffer is narrowed, this means the end of the narrowed part. */) - () + (void) { if (PT == ZV) return Qt; @@ -1193,7 +1166,7 @@ If the buffer is narrowed, this means the end of the narrowed part. */) DEFUN ("bolp", Fbolp, Sbolp, 0, 0, 0, doc: /* Return t if point is at the beginning of a line. */) - () + (void) { if (PT == BEGV || FETCH_BYTE (PT_BYTE - 1) == '\n') return Qt; @@ -1203,7 +1176,7 @@ DEFUN ("bolp", Fbolp, Sbolp, 0, 0, 0, DEFUN ("eolp", Feolp, Seolp, 0, 0, 0, doc: /* Return t if point is at the end of a line. `End of a line' includes point being at the end of the buffer. */) - () + (void) { if (PT == ZV || FETCH_BYTE (PT_BYTE) == '\n') return Qt; @@ -1214,10 +1187,9 @@ DEFUN ("char-after", Fchar_after, Schar_after, 0, 1, 0, doc: /* Return character in current buffer at position POS. POS is an integer or a marker and defaults to point. If POS is out of range, the value is nil. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { - register int pos_byte; + register EMACS_INT pos_byte; if (NILP (pos)) { @@ -1247,11 +1219,10 @@ DEFUN ("char-before", Fchar_before, Schar_before, 0, 1, 0, doc: /* Return character in current buffer preceding position POS. POS is an integer or a marker and defaults to point. If POS is out of range, the value is nil. */) - (pos) - Lisp_Object pos; + (Lisp_Object pos) { register Lisp_Object val; - register int pos_byte; + register EMACS_INT pos_byte; if (NILP (pos)) { @@ -1297,8 +1268,7 @@ that determines the value of this function. If optional argument UID is an integer or a float, return the login name of the user with that uid, or nil if there is no such user. */) - (uid) - Lisp_Object uid; + (Lisp_Object uid) { struct passwd *pw; uid_t id; @@ -1324,7 +1294,7 @@ DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name, doc: /* Return the name of the user's real uid, as a string. This ignores the environment variables LOGNAME and USER, so it differs from `user-login-name' when running under `su'. */) - () + (void) { /* Set up the user name info if we didn't do it before. (That can happen if Emacs is dumpable @@ -1337,7 +1307,7 @@ This ignores the environment variables LOGNAME and USER, so it differs from DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, doc: /* Return the effective uid of Emacs. Value is an integer or a float, depending on the value. */) - () + (void) { /* Assignment to EMACS_INT stops GCC whining about limited range of data type. */ @@ -1353,7 +1323,7 @@ Value is an integer or a float, depending on the value. */) DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0, doc: /* Return the real uid of Emacs. Value is an integer or a float, depending on the value. */) - () + (void) { /* Assignment to EMACS_INT stops GCC whining about limited range of data type. */ @@ -1375,8 +1345,7 @@ If optional argument UID is an integer or float, return the full name of the user with that uid, or nil if there is no such user. If UID is a string, return the full name of the user with that login name, or nil if there is no such user. */) - (uid) - Lisp_Object uid; + (Lisp_Object uid) { struct passwd *pw; register unsigned char *p, *q; @@ -1404,12 +1373,12 @@ name, or nil if there is no such user. */) p = (unsigned char *) USER_FULL_NAME; /* Chop off everything after the first comma. */ - q = (unsigned char *) index (p, ','); + q = (unsigned char *) strchr (p, ','); full = make_string (p, q ? q - p : strlen (p)); #ifdef AMPERSAND_FULL_NAME p = SDATA (full); - q = (unsigned char *) index (p, '&'); + q = (unsigned char *) strchr (p, '&'); /* Substitute the login name for the &, upcasing the first character. */ if (q) { @@ -1418,7 +1387,7 @@ name, or nil if there is no such user. */) login = Fuser_login_name (make_number (pw->pw_uid)); r = (unsigned char *) alloca (strlen (p) + SCHARS (login) + 1); - bcopy (p, r, q - p); + memcpy (r, p, q - p); r[q - p] = 0; strcat (r, SDATA (login)); r[q - p] = UPCASE (r[q - p]); @@ -1432,24 +1401,24 @@ name, or nil if there is no such user. */) DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, doc: /* Return the host name of the machine you are running on, as a string. */) - () + (void) { return Vsystem_name; } /* For the benefit of callers who don't want to include lisp.h */ -char * -get_system_name () +const char * +get_system_name (void) { if (STRINGP (Vsystem_name)) - return (char *) SDATA (Vsystem_name); + return (const char *) SDATA (Vsystem_name); else return ""; } -char * -get_operating_system_release() +const char * +get_operating_system_release (void) { if (STRINGP (Voperating_system_release)) return (char *) SDATA (Voperating_system_release); @@ -1459,7 +1428,7 @@ get_operating_system_release() DEFUN ("emacs-pid", Femacs_pid, Semacs_pid, 0, 0, 0, doc: /* Return the process ID of Emacs, as an integer. */) - () + (void) { return make_number (getpid ()); } @@ -1473,7 +1442,7 @@ count. The microsecond count is zero on systems that do not provide resolution finer than a second. */) - () + (void) { EMACS_TIME t; @@ -1494,7 +1463,7 @@ count. On systems that can't determine the run time, `get-internal-run-time' does the same thing as `current-time'. The microsecond count is zero on systems that do not provide resolution finer than a second. */) - () + (void) { #ifdef HAVE_GETRUSAGE struct rusage usage; @@ -1527,10 +1496,7 @@ on systems that do not provide resolution finer than a second. */) int -lisp_time_argument (specified_time, result, usec) - Lisp_Object specified_time; - time_t *result; - int *usec; +lisp_time_argument (Lisp_Object specified_time, time_t *result, int *usec) { if (NILP (specified_time)) { @@ -1588,8 +1554,7 @@ have the form (HIGH . LOW), but this is considered obsolete. WARNING: Since the result is floating point, it may not be exact. If precise time stamps are required, use either `current-time', or (if you need time as a string) `format-time-string'. */) - (specified_time) - Lisp_Object specified_time; + (Lisp_Object specified_time) { time_t sec; int usec; @@ -1611,13 +1576,7 @@ or (if you need time as a string) `format-time-string'. */) This function behaves like emacs_strftimeu, except it allows null bytes in FORMAT. */ static size_t -emacs_memftimeu (s, maxsize, format, format_len, tp, ut) - char *s; - size_t maxsize; - const char *format; - size_t format_len; - const struct tm *tp; - int ut; +emacs_memftimeu (char *s, size_t maxsize, const char *format, size_t format_len, const struct tm *tp, int ut) { size_t total = 0; @@ -1705,8 +1664,7 @@ The modifiers are `E' and `O'. For certain characters X, %OX is like %X, but uses the locale's number symbols. For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) - (format_string, time, universal) - Lisp_Object format_string, time, universal; + (Lisp_Object format_string, Lisp_Object time, Lisp_Object universal) { time_t value; int size; @@ -1773,8 +1731,7 @@ where 0 is Sunday. DST is t if daylight saving time is in effect, otherwise nil. ZONE is an integer indicating the number of seconds east of Greenwich. (Note that Common Lisp has different meanings for DOW and ZONE.) */) - (specified_time) - Lisp_Object specified_time; + (Lisp_Object specified_time) { time_t time_spec; struct tm save_tm; @@ -1834,9 +1791,7 @@ Years before 1970 are not guaranteed to work. On some systems, year values as low as 1901 do work. usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { time_t time; struct tm tm; @@ -1868,7 +1823,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) else { char tzbuf[100]; - char *tzstring; + const char *tzstring; char **oldenv = environ, **newenv; if (EQ (zone, Qt)) @@ -1922,8 +1877,7 @@ current time. The argument should have the form (HIGH LOW . IGNORED). Thus, you can use times obtained from `current-time' and from `file-attributes'. SPECIFIED-TIME can also have the form (HIGH . LOW), but this is considered obsolete. */) - (specified_time) - Lisp_Object specified_time; + (Lisp_Object specified_time) { time_t value; struct tm *tm; @@ -1950,8 +1904,7 @@ but this is considered obsolete. */) /* Yield A - B, measured in seconds. This function is copied from the GNU C Library. */ static int -tm_diff (a, b) - struct tm *a, *b; +tm_diff (struct tm *a, struct tm *b) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations, @@ -1986,8 +1939,7 @@ have the form (HIGH . LOW), but this is considered obsolete. Some operating systems cannot provide all this information to Emacs; in this case, `current-time-zone' returns a list containing nil for the data it can't find. */) - (specified_time) - Lisp_Object specified_time; + (Lisp_Object specified_time) { time_t value; struct tm *t; @@ -2051,10 +2003,9 @@ DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, doc: /* Set the local time zone using TZ, a string specifying a time zone rule. If TZ is nil, use implementation-defined default time zone information. If TZ is t, use Universal Time. */) - (tz) - Lisp_Object tz; + (Lisp_Object tz) { - char *tzstring; + const char *tzstring; /* When called for the first time, save the original TZ. */ if (!environbuf) @@ -2098,8 +2049,7 @@ static char set_time_zone_rule_tz2[] = "TZ=GMT+1"; responsibility to free. */ void -set_time_zone_rule (tzstring) - char *tzstring; +set_time_zone_rule (const char *tzstring) { int envptrs; char **from, **to, **newenv; @@ -2221,8 +2171,7 @@ general_insert_function (void (*insert_func) } void -insert1 (arg) - Lisp_Object arg; +insert1 (Lisp_Object arg) { Finsert (1, &arg); } @@ -2250,9 +2199,7 @@ buffer; to accomplish this, apply `string-as-multibyte' to the string and insert the result. usage: (insert &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { general_insert_function (insert, insert_from_string, 0, nargs, args); return Qnil; @@ -2271,9 +2218,7 @@ If the current buffer is unibyte, multibyte strings are converted to unibyte for insertion. usage: (insert-and-inherit &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { general_insert_function (insert_and_inherit, insert_from_string, 1, nargs, args); @@ -2290,9 +2235,7 @@ If the current buffer is unibyte, multibyte strings are converted to unibyte for insertion. usage: (insert-before-markers &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { general_insert_function (insert_before_markers, insert_from_string_before_markers, 0, @@ -2311,9 +2254,7 @@ If the current buffer is unibyte, multibyte strings are converted to unibyte for insertion. usage: (insert-before-markers-and-inherit &rest ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { general_insert_function (insert_before_markers_and_inherit, insert_from_string_before_markers, 1, @@ -2326,12 +2267,12 @@ DEFUN ("insert-char", Finsert_char, Sinsert_char, 2, 3, 0, Point, and before-insertion markers, are relocated as in the function `insert'. The optional third arg INHERIT, if non-nil, says to inherit text properties from adjoining text, if those properties are sticky. */) - (character, count, inherit) - Lisp_Object character, count, inherit; + (Lisp_Object character, Lisp_Object count, Lisp_Object inherit) { register unsigned char *string; - register int strlen; - register int i, n; + register EMACS_INT strlen; + register int i; + register EMACS_INT n; int len; unsigned char str[MAX_MULTIBYTE_LENGTH]; @@ -2342,6 +2283,8 @@ from adjoining text, if those properties are sticky. */) len = CHAR_STRING (XFASTINT (character), str); else str[0] = XFASTINT (character), len = 1; + if (MOST_POSITIVE_FIXNUM / len < XINT (count)) + error ("Maximum buffer size would be exceeded"); n = XINT (count) * len; if (n <= 0) return Qnil; @@ -2379,8 +2322,7 @@ corresponding eight-bit character is inserted. Point, and before-insertion markers, are relocated as in the function `insert'. The optional third arg INHERIT, if non-nil, says to inherit text properties from adjoining text, if those properties are sticky. */) - (byte, count, inherit) - Lisp_Object byte, count, inherit; + (Lisp_Object byte, Lisp_Object count, Lisp_Object inherit) { CHECK_NUMBER (byte); if (XINT (byte) < 0 || XINT (byte) > 255) @@ -2408,12 +2350,10 @@ from adjoining text, if those properties are sticky. */) buffer substrings. */ Lisp_Object -make_buffer_string (start, end, props) - int start, end; - int props; +make_buffer_string (EMACS_INT start, EMACS_INT end, int props) { - int start_byte = CHAR_TO_BYTE (start); - int end_byte = CHAR_TO_BYTE (end); + EMACS_INT start_byte = CHAR_TO_BYTE (start); + EMACS_INT end_byte = CHAR_TO_BYTE (end); return make_buffer_string_both (start, start_byte, end, end_byte, props); } @@ -2434,9 +2374,8 @@ make_buffer_string (start, end, props) buffer substrings. */ Lisp_Object -make_buffer_string_both (start, start_byte, end, end_byte, props) - int start, start_byte, end, end_byte; - int props; +make_buffer_string_both (EMACS_INT start, EMACS_INT start_byte, + EMACS_INT end, EMACS_INT end_byte, int props) { Lisp_Object result, tem, tem1; @@ -2447,8 +2386,7 @@ make_buffer_string_both (start, start_byte, end, end_byte, props) result = make_uninit_multibyte_string (end - start, end_byte - start_byte); else result = make_uninit_string (end - start); - bcopy (BYTE_POS_ADDR (start_byte), SDATA (result), - end_byte - start_byte); + memcpy (SDATA (result), BYTE_POS_ADDR (start_byte), end_byte - start_byte); /* If desired, update and copy the text properties. */ if (props) @@ -2470,8 +2408,7 @@ make_buffer_string_both (start, start_byte, end, end_byte, props) in the current buffer, if necessary. */ static void -update_buffer_properties (start, end) - int start, end; +update_buffer_properties (EMACS_INT start, EMACS_INT end) { /* If this buffer has some access functions, call them, specifying the range of the buffer being accessed. */ @@ -2508,10 +2445,9 @@ The string returned is multibyte if the buffer is multibyte. This function copies the text properties of that part of the buffer into the result string; if you don't want the text properties, use `buffer-substring-no-properties' instead. */) - (start, end) - Lisp_Object start, end; + (Lisp_Object start, Lisp_Object end) { - register int b, e; + register EMACS_INT b, e; validate_region (&start, &end); b = XINT (start); @@ -2525,10 +2461,9 @@ DEFUN ("buffer-substring-no-properties", Fbuffer_substring_no_properties, doc: /* Return the characters of part of the buffer, without the text properties. The two arguments START and END are character positions; they can be in either order. */) - (start, end) - Lisp_Object start, end; + (Lisp_Object start, Lisp_Object end) { - register int b, e; + register EMACS_INT b, e; validate_region (&start, &end); b = XINT (start); @@ -2541,7 +2476,7 @@ DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0, doc: /* Return the contents of the current buffer as a string. If narrowing is in effect, this function returns only the visible part of the buffer. */) - () + (void) { return make_buffer_string (BEGV, ZV, 1); } @@ -2552,10 +2487,9 @@ DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_subst BUFFER may be a buffer or a buffer name. Arguments START and END are character positions specifying the substring. They default to the values of (point-min) and (point-max) in BUFFER. */) - (buffer, start, end) - Lisp_Object buffer, start, end; + (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) { - register int b, e, temp; + register EMACS_INT b, e, temp; register struct buffer *bp, *obuf; Lisp_Object buf; @@ -2606,16 +2540,15 @@ That makes six args in all, three for each substring. The value of `case-fold-search' in the current buffer determines whether case is significant or ignored. */) - (buffer1, start1, end1, buffer2, start2, end2) - Lisp_Object buffer1, start1, end1, buffer2, start2, end2; + (Lisp_Object buffer1, Lisp_Object start1, Lisp_Object end1, Lisp_Object buffer2, Lisp_Object start2, Lisp_Object end2) { - register int begp1, endp1, begp2, endp2, temp; + register EMACS_INT begp1, endp1, begp2, endp2, temp; register struct buffer *bp1, *bp2; register Lisp_Object trt = (!NILP (current_buffer->case_fold_search) ? current_buffer->case_canon_table : Qnil); - int chars = 0; - int i1, i2, i1_byte, i2_byte; + EMACS_INT chars = 0; + EMACS_INT i1, i2, i1_byte, i2_byte; /* Find the first buffer and its substring. */ @@ -2757,15 +2690,13 @@ determines whether case is significant or ignored. */) } static Lisp_Object -subst_char_in_region_unwind (arg) - Lisp_Object arg; +subst_char_in_region_unwind (Lisp_Object arg) { return current_buffer->undo_list = arg; } static Lisp_Object -subst_char_in_region_unwind_1 (arg) - Lisp_Object arg; +subst_char_in_region_unwind_1 (Lisp_Object arg) { return current_buffer->filename = arg; } @@ -2776,15 +2707,14 @@ DEFUN ("subst-char-in-region", Fsubst_char_in_region, If optional arg NOUNDO is non-nil, don't record this change for undo and don't mark the buffer as really changed. Both characters must have the same length of multi-byte form. */) - (start, end, fromchar, tochar, noundo) - Lisp_Object start, end, fromchar, tochar, noundo; + (Lisp_Object start, Lisp_Object end, Lisp_Object fromchar, Lisp_Object tochar, Lisp_Object noundo) { - register int pos, pos_byte, stop, i, len, end_byte; + register EMACS_INT pos, pos_byte, stop, i, len, end_byte; /* Keep track of the first change in the buffer: if 0 we haven't found it yet. if < 0 we've found it and we've run the before-change-function. if > 0 we've actually performed it and the value is its position. */ - int changed = 0; + EMACS_INT changed = 0; unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; unsigned char *p; int count = SPECPDL_INDEX (); @@ -2793,7 +2723,7 @@ Both characters must have the same length of multi-byte form. */) #define COMBINING_AFTER 2 #define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) int maybe_byte_combining = COMBINING_NO; - int last_changed = 0; + EMACS_INT last_changed = 0; int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); restart: @@ -2850,7 +2780,7 @@ Both characters must have the same length of multi-byte form. */) stop = min (stop, GPT_BYTE); while (1) { - int pos_byte_next = pos_byte; + EMACS_INT pos_byte_next = pos_byte; if (pos_byte >= stop) { @@ -2953,7 +2883,8 @@ Both characters must have the same length of multi-byte form. */) } -static Lisp_Object check_translation P_ ((int, int, int, Lisp_Object)); +static Lisp_Object check_translation (EMACS_INT, EMACS_INT, EMACS_INT, + Lisp_Object); /* Helper function for Ftranslate_region_internal. @@ -2962,9 +2893,8 @@ static Lisp_Object check_translation P_ ((int, int, int, Lisp_Object)); element is found, return it. Otherwise return Qnil. */ static Lisp_Object -check_translation (pos, pos_byte, end, val) - int pos, pos_byte, end; - Lisp_Object val; +check_translation (EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT end, + Lisp_Object val) { int buf_size = 16, buf_used = 0; int *buf = alloca (sizeof (int) * buf_size); @@ -2972,7 +2902,7 @@ check_translation (pos, pos_byte, end, val) for (; CONSP (val); val = XCDR (val)) { Lisp_Object elt; - int len, i; + EMACS_INT len, i; elt = XCAR (val); if (! CONSP (elt)) @@ -2988,7 +2918,7 @@ check_translation (pos, pos_byte, end, val) if (buf_used <= i) { unsigned char *p = BYTE_POS_ADDR (pos_byte); - int len; + int len1; if (buf_used == buf_size) { @@ -2999,8 +2929,8 @@ check_translation (pos, pos_byte, end, val) memcpy (newbuf, buf, sizeof (int) * buf_used); buf = newbuf; } - buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len); - pos_byte += len; + buf[buf_used++] = STRING_CHAR_AND_LENGTH (p, len1); + pos_byte += len1; } if (XINT (AREF (elt, i)) != buf[i]) break; @@ -3020,16 +2950,13 @@ From START to END, translate characters according to TABLE. TABLE is a string or a char-table; the Nth character in it is the mapping for the character with code N. It returns the number of characters changed. */) - (start, end, table) - Lisp_Object start; - Lisp_Object end; - register Lisp_Object table; + (Lisp_Object start, Lisp_Object end, register Lisp_Object table) { register unsigned char *tt; /* Trans table. */ register int nc; /* New character. */ int cnt; /* Number of changes made. */ - int size; /* Size of translate table. */ - int pos, pos_byte, end_pos; + EMACS_INT size; /* Size of translate table. */ + EMACS_INT pos, pos_byte, end_pos; int multibyte = !NILP (current_buffer->enable_multibyte_characters); int string_multibyte; Lisp_Object val; @@ -3099,7 +3026,7 @@ It returns the number of characters changed. */) } else { - int c; + EMACS_INT c; nc = oc; val = CHAR_TABLE_REF (table, oc); @@ -3189,8 +3116,7 @@ DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 2, "r", When called from a program, expects two arguments, positions (integers or markers) specifying the stretch to be deleted. */) - (start, end) - Lisp_Object start, end; + (Lisp_Object start, Lisp_Object end) { validate_region (&start, &end); del_range (XINT (start), XINT (end)); @@ -3200,8 +3126,7 @@ positions (integers or markers) specifying the stretch to be deleted. */) DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, Sdelete_and_extract_region, 2, 2, 0, doc: /* Delete the text between START and END and return it. */) - (start, end) - Lisp_Object start, end; + (Lisp_Object start, Lisp_Object end) { validate_region (&start, &end); if (XINT (start) == XINT (end)) @@ -3212,7 +3137,7 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, DEFUN ("widen", Fwiden, Swiden, 0, 0, "", doc: /* Remove restrictions (narrowing) from current buffer. This allows the buffer's full text to be seen and edited. */) - () + (void) { if (BEG != BEGV || Z != ZV) current_buffer->clip_changed = 1; @@ -3233,8 +3158,7 @@ See also `save-restriction'. When calling from a program, pass two arguments; positions (integers or markers) bounding the text that should remain visible. */) - (start, end) - register Lisp_Object start, end; + (register Lisp_Object start, Lisp_Object end) { CHECK_NUMBER_COERCE_MARKER (start); CHECK_NUMBER_COERCE_MARKER (end); @@ -3263,7 +3187,7 @@ or markers) bounding the text that should remain visible. */) } Lisp_Object -save_restriction_save () +save_restriction_save (void) { if (BEGV == BEG && ZV == Z) /* The common case that the buffer isn't narrowed. @@ -3287,8 +3211,7 @@ save_restriction_save () } Lisp_Object -save_restriction_restore (data) - Lisp_Object data; +save_restriction_restore (Lisp_Object data) { struct buffer *cur = NULL; struct buffer *buf = (CONSP (data) @@ -3316,7 +3239,7 @@ save_restriction_restore (data) /* The restriction has changed from the saved one, so restore the saved restriction. */ { - int pt = BUF_PT (buf); + EMACS_INT pt = BUF_PT (buf); SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos); SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos); @@ -3368,8 +3291,7 @@ use `save-excursion' outermost: (save-excursion (save-restriction ...)) usage: (save-restriction &rest BODY) */) - (body) - Lisp_Object body; + (Lisp_Object body) { register Lisp_Object val; int count = SPECPDL_INDEX (); @@ -3402,9 +3324,7 @@ any existing message; this lets the minibuffer contents show. See also `current-message'. usage: (message FORMAT-STRING &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { if (NILP (args[0]) || (STRINGP (args[0]) @@ -3432,9 +3352,7 @@ If the first argument is nil or the empty string, clear any existing message; let the minibuffer contents show. usage: (message-box FORMAT-STRING &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { if (NILP (args[0])) { @@ -3472,15 +3390,12 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) message_length = SBYTES (val); message_text = (char *)xrealloc (message_text, message_length); } - bcopy (SDATA (val), message_text, SBYTES (val)); + memcpy (message_text, SDATA (val), SBYTES (val)); message2 (message_text, SBYTES (val), STRING_MULTIBYTE (val)); return val; } } -#ifdef HAVE_MENUS -extern Lisp_Object last_nonmenu_event; -#endif DEFUN ("message-or-box", Fmessage_or_box, Smessage_or_box, 1, MANY, 0, doc: /* Display a message in a dialog box or in the echo area. @@ -3494,9 +3409,7 @@ If the first argument is nil or the empty string, clear any existing message; let the minibuffer contents show. usage: (message-or-box FORMAT-STRING &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { #ifdef HAVE_MENUS if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) @@ -3508,7 +3421,7 @@ usage: (message-or-box FORMAT-STRING &rest ARGS) */) DEFUN ("current-message", Fcurrent_message, Scurrent_message, 0, 0, 0, doc: /* Return the string currently displayed in the echo area, or nil if none. */) - () + (void) { return current_message (); } @@ -3520,9 +3433,7 @@ First argument is the string to copy. Remaining arguments form a sequence of PROPERTY VALUE pairs for text properties to add to the result. usage: (propertize STRING &rest PROPERTIES) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object properties, string; struct gcpro gcpro1, gcpro2; @@ -3604,12 +3515,10 @@ decimal point itself is omitted. For %s and %S, the precision specifier truncates the string to the given width. usage: (format STRING &rest OBJECTS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { register int n; /* The number of the next arg to substitute */ - register int total; /* An estimate of the final length */ + register EMACS_INT total; /* An estimate of the final length */ char *buf, *p; register unsigned char *format, *end, *format_start; int nchars; @@ -3618,7 +3527,7 @@ usage: (format STRING &rest OBJECTS) */) int multibyte = 0; /* When we make a multibyte string, we must pay attention to the byte combining problem, i.e., a byte may be combined with a - multibyte charcter of the previous string. This flag tells if we + multibyte character of the previous string. This flag tells if we must consider such a situation or not. */ int maybe_combine_byte; unsigned char *this_format; @@ -3627,7 +3536,7 @@ usage: (format STRING &rest OBJECTS) */) string itself, will not be used. Element NARGS, corresponding to no argument, *will* be assigned to in the case that a `%' and `.' occur after the final format specifier. */ - int *precision = (int *) (alloca((nargs + 1) * sizeof (int))); + int *precision = (int *) (alloca ((nargs + 1) * sizeof (int))); int longest_format; Lisp_Object val; int arg_intervals = 0; @@ -3689,12 +3598,12 @@ usage: (format STRING &rest OBJECTS) */) int i; if (!info) info = (struct info *) alloca (nbytes); - bzero (info, nbytes); + memset (info, 0, nbytes); for (i = 0; i <= nargs; i++) info[i].start = -1; if (!discarded) SAFE_ALLOCA (discarded, char *, SBYTES (args[0])); - bzero (discarded, SBYTES (args[0])); + memset (discarded, 0, SBYTES (args[0])); } /* Add to TOTAL enough space to hold the converted arguments. */ @@ -3703,8 +3612,8 @@ usage: (format STRING &rest OBJECTS) */) while (format != end) if (*format++ == '%') { - int thissize = 0; - int actual_width = 0; + EMACS_INT thissize = 0; + EMACS_INT actual_width = 0; unsigned char *this_format_start = format - 1; int field_width = 0; @@ -3798,7 +3707,7 @@ usage: (format STRING &rest OBJECTS) */) string will finally appear (Bug#5710). */ actual_width = lisp_string_width (args[n], -1, NULL, NULL); if (precision[n] != -1) - actual_width = min(actual_width,precision[n]); + actual_width = min (actual_width, precision[n]); } /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ else if (INTEGERP (args[n]) && *format != 's') @@ -3911,7 +3820,7 @@ usage: (format STRING &rest OBJECTS) */) discarded[format - format_start] = 1; format++; - while (index("-+0# ", *format)) + while (strchr ("-+0# ", *format)) { if (*format == '-') { @@ -3946,8 +3855,8 @@ usage: (format STRING &rest OBJECTS) */) /* handle case (precision[n] >= 0) */ int width, padding; - int nbytes, start, end; - int nchars_string; + EMACS_INT nbytes, start, end; + EMACS_INT nchars_string; /* lisp_string_width ignores a precision of 0, but GNU libc functions print 0 characters when the precision @@ -3958,7 +3867,8 @@ usage: (format STRING &rest OBJECTS) */) if (precision[n] == 0) width = nchars_string = nbytes = 0; else if (precision[n] > 0) - width = lisp_string_width (args[n], precision[n], &nchars_string, &nbytes); + width = lisp_string_width (args[n], precision[n], + &nchars_string, &nbytes); else { /* no precision spec given for this argument */ width = lisp_string_width (args[n], -1, NULL, NULL); @@ -4008,8 +3918,8 @@ usage: (format STRING &rest OBJECTS) */) { int this_nchars; - bcopy (this_format_start, this_format, - format - this_format_start); + memcpy (this_format, this_format_start, + format - this_format_start); this_format[format - this_format_start] = 0; if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') @@ -4117,7 +4027,8 @@ usage: (format STRING &rest OBJECTS) */) if (CONSP (props)) { - int bytepos = 0, position = 0, translated = 0, argn = 1; + EMACS_INT bytepos = 0, position = 0, translated = 0; + int argn = 1; Lisp_Object list; /* Adjust the bounds of each text property @@ -4135,7 +4046,7 @@ usage: (format STRING &rest OBJECTS) */) for (list = props; CONSP (list); list = XCDR (list)) { Lisp_Object item; - int pos; + EMACS_INT pos; item = XCAR (list); @@ -4209,9 +4120,7 @@ usage: (format STRING &rest OBJECTS) */) } Lisp_Object -format2 (string1, arg0, arg1) - char *string1; - Lisp_Object arg0, arg1; +format2 (const char *string1, Lisp_Object arg0, Lisp_Object arg1) { Lisp_Object args[3]; args[0] = build_string (string1); @@ -4224,8 +4133,7 @@ DEFUN ("char-equal", Fchar_equal, Schar_equal, 2, 2, 0, doc: /* Return t if two characters match, optionally ignoring case. Both arguments must be characters (i.e. integers). Case is ignored if `case-fold-search' is non-nil in the current buffer. */) - (c1, c2) - register Lisp_Object c1, c2; + (register Lisp_Object c1, Lisp_Object c2) { int i1, i2; /* Check they're chars, not just integers, otherwise we could get array @@ -4274,12 +4182,12 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer. */) It's the caller's job to ensure that START1 <= END1 <= START2 <= END2. */ static void -transpose_markers (start1, end1, start2, end2, - start1_byte, end1_byte, start2_byte, end2_byte) - register int start1, end1, start2, end2; - register int start1_byte, end1_byte, start2_byte, end2_byte; +transpose_markers (EMACS_INT start1, EMACS_INT end1, + EMACS_INT start2, EMACS_INT end2, + EMACS_INT start1_byte, EMACS_INT end1_byte, + EMACS_INT start2_byte, EMACS_INT end2_byte) { - register int amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos; + register EMACS_INT amt1, amt1_byte, amt2, amt2_byte, diff, diff_byte, mpos; register struct Lisp_Marker *marker; /* Update point as if it were a marker. */ @@ -4351,8 +4259,7 @@ Optional fifth arg LEAVE-MARKERS, if non-nil, means don't update any markers that happen to be located in the regions. Transposing beyond buffer boundaries is an error. */) - (startr1, endr1, startr2, endr2, leave_markers) - Lisp_Object startr1, endr1, startr2, endr2, leave_markers; + (Lisp_Object startr1, Lisp_Object endr1, Lisp_Object startr2, Lisp_Object endr2, Lisp_Object leave_markers) { register EMACS_INT start1, end1, start2, end2; EMACS_INT start1_byte, start2_byte, len1_byte, len2_byte; @@ -4377,7 +4284,7 @@ Transposing beyond buffer boundaries is an error. */) /* Swap the regions if they're reversed. */ if (start2 < end1) { - register int glumph = start1; + register EMACS_INT glumph = start1; start1 = start2; start2 = glumph; glumph = end1; @@ -4488,9 +4395,9 @@ Transposing beyond buffer boundaries is an error. */) start1_addr = BYTE_POS_ADDR (start1_byte); start2_addr = BYTE_POS_ADDR (start2_byte); - bcopy (start2_addr, temp, len2_byte); - bcopy (start1_addr, start1_addr + len2_byte, len1_byte); - bcopy (temp, start1_addr, len2_byte); + memcpy (temp, start2_addr, len2_byte); + memcpy (start1_addr + len2_byte, start1_addr, len1_byte); + memcpy (start1_addr, temp, len2_byte); SAFE_FREE (); } else @@ -4501,9 +4408,9 @@ Transposing beyond buffer boundaries is an error. */) SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); start2_addr = BYTE_POS_ADDR (start2_byte); - bcopy (start1_addr, temp, len1_byte); - bcopy (start2_addr, start1_addr, len2_byte); - bcopy (temp, start1_addr + len2_byte, len1_byte); + memcpy (temp, start1_addr, len1_byte); + memcpy (start1_addr, start2_addr, len2_byte); + memcpy (start1_addr + len2_byte, temp, len1_byte); SAFE_FREE (); } graft_intervals_into_buffer (tmp_interval1, start1 + len2, @@ -4541,9 +4448,9 @@ Transposing beyond buffer boundaries is an error. */) SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); start2_addr = BYTE_POS_ADDR (start2_byte); - bcopy (start1_addr, temp, len1_byte); - bcopy (start2_addr, start1_addr, len2_byte); - bcopy (temp, start2_addr, len1_byte); + memcpy (temp, start1_addr, len1_byte); + memcpy (start1_addr, start2_addr, len2_byte); + memcpy (start2_addr, temp, len1_byte); SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, start2, @@ -4571,10 +4478,10 @@ Transposing beyond buffer boundaries is an error. */) SAFE_ALLOCA (temp, unsigned char *, len2_byte); start1_addr = BYTE_POS_ADDR (start1_byte); start2_addr = BYTE_POS_ADDR (start2_byte); - bcopy (start2_addr, temp, len2_byte); - bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); - safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); - bcopy (temp, start1_addr, len2_byte); + memcpy (temp, start2_addr, len2_byte); + memcpy (start1_addr + len_mid + len2_byte, start1_addr, len1_byte); + memmove (start1_addr + len2_byte, start1_addr + len1_byte, len_mid); + memcpy (start1_addr, temp, len2_byte); SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, end2 - len1, @@ -4604,10 +4511,10 @@ Transposing beyond buffer boundaries is an error. */) SAFE_ALLOCA (temp, unsigned char *, len1_byte); start1_addr = BYTE_POS_ADDR (start1_byte); start2_addr = BYTE_POS_ADDR (start2_byte); - bcopy (start1_addr, temp, len1_byte); - bcopy (start2_addr, start1_addr, len2_byte); - bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); - bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); + memcpy (temp, start1_addr, len1_byte); + memcpy (start1_addr, start2_addr, len2_byte); + memcpy (start1_addr + len2_byte, start1_addr + len1_byte, len_mid); + memcpy (start1_addr + len2_byte + len_mid, temp, len1_byte); SAFE_FREE (); graft_intervals_into_buffer (tmp_interval1, end2 - len1, @@ -4639,7 +4546,7 @@ Transposing beyond buffer boundaries is an error. */) void -syms_of_editfns () +syms_of_editfns (void) { environbuf = 0; initial_tz = 0; @@ -4661,7 +4568,6 @@ of the buffer being accessed. */); { Lisp_Object obuf; - extern Lisp_Object Vprin1_to_string_buffer; obuf = Fcurrent_buffer (); /* Do this here, because init_buffer_once is too early--it won't work. */ Fset_buffer (Vprin1_to_string_buffer); diff --git a/src/emacs-icon.h b/src/emacs-icon.h index 42c7d80bbe0..82f0a6e701c 100644 --- a/src/emacs-icon.h +++ b/src/emacs-icon.h @@ -23,7 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Note that the GTK port uses gdk to display the icon, so Emacs need not have XPM support compiled in. */ #if (defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)) || defined (USE_GTK) -static char * gnu_xpm_bits[] = { +static const char * gnu_xpm_bits[] = { /* width height ncolors chars_per_pixel */ "32 32 255 2", /* colors */ diff --git a/src/emacs.c b/src/emacs.c index 71ffa998bfe..70a0fae4ebf 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -32,10 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif -#ifdef BSD_SYSTEM -#include <sys/ioctl.h> -#endif - #ifdef WINDOWSNT #include <fcntl.h> #include <windows.h> /* just for w32.h */ @@ -63,6 +59,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "keyboard.h" #include "keymap.h" +#ifdef HAVE_GNUTLS +#include "gnutls.h" +#endif + +#ifdef HAVE_NS +#include "nsterm.h" +#endif + #ifdef HAVE_SETLOCALE #include <locale.h> #endif @@ -81,17 +85,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #ifdef HAVE_SETPGID -#if !defined (USG) || defined (BSD_PGRPS) +#if !defined (USG) #undef setpgrp #define setpgrp setpgid #endif #endif -extern void malloc_warning P_ ((char *)); -extern void set_time_zone_rule P_ ((char *)); -#ifdef HAVE_INDEX -extern char *index P_ ((const char *, int)); -#endif +/* If you change the following line, remember to update + msdos/mainmake.v2 which gleans the Emacs version from it! */ +static const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc."; +static const char emacs_version[] = "24.0.50"; /* Make these values available in GDB, which doesn't see macros. */ @@ -154,9 +157,9 @@ int initialized; static data inside glibc's malloc. */ void *malloc_state_ptr; /* From glibc, a routine that returns a copy of the malloc internal state. */ -extern void *malloc_get_state (); +extern void *malloc_get_state (void); /* From glibc, a routine that overwrites the malloc internal state. */ -extern int malloc_set_state (); +extern int malloc_set_state (void*); /* Non-zero if the MALLOC_CHECK_ environment variable was set while dumping. Used to work around a bug in glibc's malloc. */ int malloc_using_checking; @@ -180,6 +183,13 @@ Lisp_Object Vprevious_system_messages_locale; Lisp_Object Vsystem_time_locale; Lisp_Object Vprevious_system_time_locale; +/* Copyright and version info. The version number may be updated by + Lisp code. */ +Lisp_Object Vemacs_copyright, Vemacs_version; + +/* Alist of external libraries and files implementing them. */ +Lisp_Object Vdynamic_library_alist; + /* If non-zero, emacs should not attempt to use a window-specific code, but instead should use the virtual terminal under which it was started. */ int inhibit_window_system; @@ -193,11 +203,6 @@ EMACS_INT emacs_priority; data on the first attempt to change it inside asynchronous code. */ int running_asynch_code; -#ifdef BSD_PGRPS -/* See sysdep.c. */ -extern int inherited_pgroup; -#endif - #if defined(HAVE_X_WINDOWS) || defined(HAVE_NS) /* If non-zero, -d was specified, meaning we're using some window system. */ int display_arg; @@ -217,15 +222,6 @@ static unsigned long heap_bss_diff; output a warning in dump-emacs. */ #define MAX_HEAP_BSS_DIFF (1024*1024) - -#ifdef HAVE_WINDOW_SYSTEM -extern Lisp_Object Vinitial_window_system; -#endif /* HAVE_WINDOW_SYSTEM */ - -extern Lisp_Object Vauto_save_list_file_name; - -extern Lisp_Object Vinhibit_redisplay; - /* Nonzero means running Emacs without interactive terminal. */ int noninteractive; @@ -250,8 +246,8 @@ int daemon_pipe[2]; char **initial_argv; int initial_argc; -static void sort_args (); -void syms_of_emacs (); +static void sort_args (int argc, char **argv); +void syms_of_emacs (void); /* MSVC needs each string be shorter than 2048 bytes, so the usage strings below are split to not overflow this limit. */ @@ -268,6 +264,7 @@ read the main documentation for these command-line arguments.\n\ Initialization options:\n\ \n\ --batch do not do interactive display; implies -q\n\ +--chdir DIR change to directory DIR\n\ --daemon start a server in the background\n\ --debug-init enable Emacs Lisp debugger for init file\n\ --display, -d DISPLAY use X server DISPLAY\n\ @@ -345,7 +342,7 @@ abbreviation for a --option.\n\ Various environment variables and window system resources also affect\n\ Emacs' operation. See the main documentation.\n\ \n\ -Report bugs to %s. First, please see the Bugs\n\ +Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\ section of the Emacs manual or the file BUGS.\n" @@ -358,7 +355,7 @@ int fatal_error_in_progress; /* If non-null, call this function from fatal_error_signal before committing suicide. */ -void (*fatal_error_signal_hook) P_ ((void)); +void (*fatal_error_signal_hook) (void); #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD /* When compiled with GTK and running under Gnome, @@ -371,8 +368,7 @@ pthread_t main_thread; /* Handle bus errors, invalid instruction, etc. */ SIGTYPE -fatal_error_signal (sig) - int sig; +fatal_error_signal (int sig) { SIGNAL_THREAD_CHECK (sig); fatal_error_code = sig; @@ -385,6 +381,9 @@ fatal_error_signal (sig) { fatal_error_in_progress = 1; + if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) + Fkill_emacs (make_number (sig)); + shut_down_emacs (sig, 0, Qnil); } @@ -426,7 +425,7 @@ memory_warning_signal (sig) #if ! defined (DOS_NT) && ! defined (NO_ABORT) void -abort () +abort (void) { kill (getpid (), SIGABRT); /* This shouldn't be executed, but it prevents a warning. */ @@ -438,10 +437,7 @@ abort () /* Code for dealing with Lisp access to the Unix command line. */ static void -init_cmdargs (argc, argv, skip_args) - int argc; - char **argv; - int skip_args; +init_cmdargs (int argc, char **argv, int skip_args) { register int i; Lisp_Object name, dir, tem; @@ -583,7 +579,7 @@ init_cmdargs (argc, argv, skip_args) DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0, doc: /* Return the program name that was used to run Emacs. Any directory names are omitted. */) - () + (void) { return Fcopy_sequence (Vinvocation_name); } @@ -591,7 +587,7 @@ Any directory names are omitted. */) DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory, 0, 0, 0, doc: /* Return the directory name in which the Emacs executable was located. */) - () + (void) { return Fcopy_sequence (Vinvocation_directory); } @@ -610,11 +606,11 @@ static char dump_tz[] = "UtC0"; (We don't have any real constructors or destructors.) */ #ifdef __GNUC__ #ifndef GCC_CTORS_IN_LIBC -void __do_global_ctors () +void __do_global_ctors (void) {} -void __do_global_ctors_aux () +void __do_global_ctors_aux (void) {} -void __do_global_dtors () +void __do_global_dtors (void) {} /* GNU/Linux has a bug in its library; avoid an error. */ #ifndef GNU_LINUX @@ -622,7 +618,7 @@ char * __CTOR_LIST__[2] = { (char *) (-1), 0 }; #endif char * __DTOR_LIST__[2] = { (char *) (-1), 0 }; #endif /* GCC_CTORS_IN_LIBC */ -void __main () +void __main (void) {} #endif /* __GNUC__ */ #endif /* ORDINARY_LINK */ @@ -638,14 +634,7 @@ void __main () enough information to do it right. */ static int -argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr) - char **argv; - int argc; - char *sstr; - char *lstr; - int minlen; - char **valptr; - int *skipptr; +argmatch (char **argv, int argc, const char *sstr, const char *lstr, int minlen, char **valptr, int *skipptr) { char *p = NULL; int arglen; @@ -669,7 +658,7 @@ argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr) *skipptr += 1; return 1; } - arglen = (valptr != NULL && (p = index (arg, '=')) != NULL + arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL ? p - arg : strlen (arg)); if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0) return 0; @@ -703,7 +692,7 @@ argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr) possible using this special hook. */ static void -malloc_initialize_hook () +malloc_initialize_hook (void) { #ifndef USE_CRT_DLL extern char **environ; @@ -741,46 +730,11 @@ malloc_initialize_hook () } } -void (*__malloc_initialize_hook) () = malloc_initialize_hook; +void (*__malloc_initialize_hook) (void) = malloc_initialize_hook; #endif /* DOUG_LEA_MALLOC */ -#define REPORT_EMACS_BUG_ADDRESS "bug-gnu-emacs@gnu.org" -#define REPORT_EMACS_BUG_PRETEST_ADDRESS "bug-gnu-emacs@gnu.org" - -/* This function is used to determine an address to which bug report should - be sent. */ - -char * -bug_reporting_address () -{ - int count = 0; - Lisp_Object temp; - char *string; - - temp = Fsymbol_value (intern ("emacs-version")); - - /* When `emacs-version' is invalid, use normal address. */ - if (!STRINGP(temp)) - return REPORT_EMACS_BUG_ADDRESS; - - string = SDATA (temp); - - /* Count dots in `emacs-version'. */ - while (*string) - { - if (*string == '.') - count++; - string++; - } - - /* When `emacs-version' has at least three dots, it is development or - pretest version of Emacs. */ - return count >= 3 ? REPORT_EMACS_BUG_PRETEST_ADDRESS : REPORT_EMACS_BUG_ADDRESS; -} - - /* ARGSUSED */ int main (int argc, char **argv) @@ -791,9 +745,6 @@ main (int argc, char **argv) char stack_bottom_variable; int do_initial_setlocale; int skip_args = 0; -#ifndef USE_CRT_DLL - extern int errno; -#endif #ifdef HAVE_SETRLIMIT struct rlimit rlim; #endif @@ -803,9 +754,9 @@ main (int argc, char **argv) #ifdef NS_IMPL_COCOA char dname_arg2[80]; #endif + char *ch_to_dir; #if GC_MARK_STACK - extern Lisp_Object *stack_base; stack_base = &dummy; #endif @@ -825,11 +776,6 @@ main (int argc, char **argv) heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static); } -#ifdef LINUX_SBRK_BUG - /* This is only used GNU/LINUX running on alpha when using libc5 */ - __sbrk (1); -#endif - #ifdef RUN_TIME_REMAP if (initialized) run_time_remap (argv[0]); @@ -845,36 +791,52 @@ main (int argc, char **argv) argc = 0; while (argv[argc]) argc++; - if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args) - /* We don't know the version number unless this is a dumped Emacs. - So ignore --version otherwise. */ - && initialized) + if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args)) { - Lisp_Object tem, tem2; - tem = Fsymbol_value (intern_c_string ("emacs-version")); - tem2 = Fsymbol_value (intern_c_string ("emacs-copyright")); - if (!STRINGP (tem)) - { - fprintf (stderr, "Invalid value of `emacs-version'\n"); - exit (1); - } - if (!STRINGP (tem2)) + const char *version, *copyright; + if (initialized) { - fprintf (stderr, "Invalid value of `emacs-copyright'\n"); - exit (1); + Lisp_Object tem, tem2; + tem = Fsymbol_value (intern_c_string ("emacs-version")); + tem2 = Fsymbol_value (intern_c_string ("emacs-copyright")); + if (!STRINGP (tem)) + { + fprintf (stderr, "Invalid value of `emacs-version'\n"); + exit (1); + } + if (!STRINGP (tem2)) + { + fprintf (stderr, "Invalid value of `emacs-copyright'\n"); + exit (1); + } + else + { + version = SDATA (tem); + copyright = SDATA (tem2); + } } else { - printf ("GNU Emacs %s\n", SDATA (tem)); - printf ("%s\n", SDATA(tem2)); - printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n"); - printf ("You may redistribute copies of Emacs\n"); - printf ("under the terms of the GNU General Public License.\n"); - printf ("For more information about these matters, "); - printf ("see the file named COPYING.\n"); - exit (0); + version = emacs_version; + copyright = emacs_copyright; } + printf ("GNU Emacs %s\n", version); + printf ("%s\n", copyright); + printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n"); + printf ("You may redistribute copies of Emacs\n"); + printf ("under the terms of the GNU General Public License.\n"); + printf ("For more information about these matters, "); + printf ("see the file named COPYING.\n"); + exit (0); } + if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args)) + if (chdir (ch_to_dir) == -1) + { + fprintf (stderr, "%s: Can't chdir to %s: %s\n", + argv[0], ch_to_dir, strerror (errno)); + exit (1); + } + #ifdef HAVE_PERSONALITY_LINUX32 if (!initialized @@ -882,8 +844,9 @@ main (int argc, char **argv) || strcmp (argv[argc-1], "bootstrap") == 0) && ! getenv ("EMACS_HEAP_EXEC")) { + static char heapexec[] = "EMACS_HEAP_EXEC=true"; /* Set this so we only do this once. */ - putenv("EMACS_HEAP_EXEC=true"); + putenv(heapexec); /* A flag to turn off address randomization which is introduced in linux kernel shipped with fedora core 4 */ @@ -898,23 +861,6 @@ main (int argc, char **argv) } #endif /* HAVE_PERSONALITY_LINUX32 */ - -/* Map in shared memory, if we are using that. */ -#ifdef HAVE_SHM - if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) - { - map_in_data (0); - /* The shared memory was just restored, which clobbered this. */ - skip_args = 1; - } - else - { - map_in_data (1); - /* The shared memory was just restored, which clobbered this. */ - skip_args = 0; - } -#endif - #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) /* Extend the stack space available. Don't do that if dumping, since some systems (e.g. DJGPP) @@ -985,7 +931,6 @@ main (int argc, char **argv) #endif /* MSDOS || WINDOWSNT */ #ifdef MSDOS -#if __DJGPP__ >= 2 if (!isatty (fileno (stdin))) setmode (fileno (stdin), O_BINARY); if (!isatty (fileno (stdout))) @@ -993,19 +938,8 @@ main (int argc, char **argv) fflush (stdout); setmode (fileno (stdout), O_BINARY); } -#else /* not __DJGPP__ >= 2 */ - (stdin)->_flag &= ~_IOTEXT; - (stdout)->_flag &= ~_IOTEXT; - (stderr)->_flag &= ~_IOTEXT; -#endif /* not __DJGPP__ >= 2 */ #endif /* MSDOS */ -#ifdef SET_EMACS_PRIORITY - if (emacs_priority) - nice (emacs_priority); - setuid (getuid ()); -#endif /* SET_EMACS_PRIORITY */ - /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case. The build procedure uses this while dumping, to ensure that the dumped Emacs does not have its system locale tables initialized, @@ -1082,7 +1016,7 @@ main (int argc, char **argv) { printf (USAGE1, argv[0], USAGE2); printf (USAGE3); - printf (USAGE4, bug_reporting_address ()); + printf (USAGE4); exit (0); } @@ -1223,20 +1157,12 @@ main (int argc, char **argv) if (! noninteractive) { -#ifdef BSD_PGRPS - if (initialized) - { - inherited_pgroup = EMACS_GETPGRP (0); - setpgrp (0, getpid ()); - } -#else #if defined (USG5) && defined (INTERRUPT_INPUT) setpgrp (); #endif -#endif #if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC) { - extern void malloc_enable_thread P_ ((void)); + extern void malloc_enable_thread (void); malloc_enable_thread (); } @@ -1317,6 +1243,12 @@ main (int argc, char **argv) #ifdef SIGSYS signal (SIGSYS, fatal_error_signal); #endif + /* May need special treatment on MS-Windows. See + http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html + Please update the doc of kill-emacs, kill-emacs-hook, and + NEWS if you change this. + */ + if (noninteractive) signal (SIGINT, fatal_error_signal); signal (SIGTERM, fatal_error_signal); #ifdef SIGXCPU signal (SIGXCPU, fatal_error_signal); @@ -1333,9 +1265,7 @@ main (int argc, char **argv) #ifdef AIX /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */ signal (SIGXCPU, fatal_error_signal); -#ifndef _I386 signal (SIGIOINT, fatal_error_signal); -#endif signal (SIGGRANT, fatal_error_signal); signal (SIGRETRACT, fatal_error_signal); signal (SIGSOUND, fatal_error_signal); @@ -1411,68 +1341,6 @@ main (int argc, char **argv) init_atimer (); running_asynch_code = 0; - /* Handle --unibyte and the EMACS_UNIBYTE envvar, - but not while dumping. */ - if (1) - { - int inhibit_unibyte = 0; - - /* --multibyte overrides EMACS_UNIBYTE. */ - if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args) - || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args) - /* Ignore EMACS_UNIBYTE before dumping. */ - || (!initialized && noninteractive)) - inhibit_unibyte = 1; - - /* --unibyte requests that we set up to do everything with single-byte - buffers and strings. We need to handle this before calling - init_lread, init_editfns and other places that generate Lisp strings - from text in the environment. */ - /* Actually this shouldn't be needed as of 20.4 in a generally - unibyte environment. As handa says, environment values - aren't now decoded; also existing buffers are now made - unibyte during startup if .emacs sets unibyte. Tested with - 8-bit data in environment variables and /etc/passwd, setting - unibyte and Latin-1 in .emacs. -- Dave Love */ - if (argmatch (argv, argc, "-unibyte", "--unibyte", 4, NULL, &skip_args) - || argmatch (argv, argc, "-no-multibyte", "--no-multibyte", 4, NULL, &skip_args) - || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte)) - { - Lisp_Object old_log_max; - Lisp_Object symbol, tail; - - symbol = intern_c_string ("enable-multibyte-characters"); - Fset_default (symbol, Qnil); - - if (initialized) - { - /* Erase pre-dump messages in *Messages* now so no abort. */ - old_log_max = Vmessage_log_max; - XSETFASTINT (Vmessage_log_max, 0); - message_dolog ("", 0, 1, 0); - Vmessage_log_max = old_log_max; - } - - for (tail = Vbuffer_alist; CONSP (tail); - tail = XCDR (tail)) - { - Lisp_Object buffer; - - buffer = Fcdr (XCAR (tail)); - /* Make a multibyte buffer unibyte. */ - if (BUF_Z_BYTE (XBUFFER (buffer)) > BUF_Z (XBUFFER (buffer))) - { - struct buffer *current = current_buffer; - - set_buffer_temp (XBUFFER (buffer)); - Fset_buffer_multibyte (Qnil); - set_buffer_temp (current); - } - } - message ("Warning: unibyte sessions are obsolete and will disappear"); - } - } - no_loadup = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); @@ -1577,6 +1445,11 @@ main (int argc, char **argv) ns_init_paths (); #endif + /* Initialize and GC-protect Vinitial_environment and + Vprocess_environment before set_initial_environment fills them + in. */ + if (!initialized) + syms_of_callproc (); /* egetenv is a pretty low-level facility, which may get called in many circumstances; it seems flimsy to put off initializing it until calling init_callproc. */ @@ -1626,14 +1499,11 @@ main (int argc, char **argv) syms_of_callint (); syms_of_casefiddle (); syms_of_casetab (); - syms_of_callproc (); syms_of_category (); syms_of_ccl (); syms_of_character (); syms_of_cmds (); -#ifndef NO_DIR_LIBRARY syms_of_dired (); -#endif /* not NO_DIR_LIBRARY */ syms_of_display (); syms_of_doc (); syms_of_editfns (); @@ -1683,6 +1553,10 @@ main (int argc, char **argv) #endif #endif /* HAVE_X_WINDOWS */ +#ifdef HAVE_LIBXML2 + syms_of_xml (); +#endif + syms_of_menu (); #ifdef HAVE_NTGUI @@ -1695,6 +1569,9 @@ main (int argc, char **argv) #ifdef MSDOS syms_of_xmenu (); + syms_of_dosfns(); + syms_of_msdos(); + syms_of_win16select(); #endif /* MSDOS */ #ifdef HAVE_NS @@ -1705,17 +1582,17 @@ main (int argc, char **argv) syms_of_fontset (); #endif /* HAVE_NS */ +#ifdef HAVE_GNUTLS + syms_of_gnutls (); +#endif + #ifdef HAVE_DBUS syms_of_dbusbind (); #endif /* HAVE_DBUS */ -#ifdef SYMS_SYSTEM - SYMS_SYSTEM; -#endif - -#ifdef SYMS_MACHINE - SYMS_MACHINE; -#endif +#ifdef WINDOWSNT + syms_of_ntterm (); +#endif /* WINDOWSNT */ keys_of_casefiddle (); keys_of_cmds (); @@ -1755,7 +1632,7 @@ main (int argc, char **argv) #endif init_window (); init_font (); - + if (!initialized) { char *file; @@ -1803,15 +1680,26 @@ main (int argc, char **argv) #else extern char etext; #endif +#ifdef HAVE___EXECUTABLE_START + /* This symbol is defined by GNU ld to the start of the text + segment. */ + extern char __executable_start[]; +#else extern void safe_bcopy (); - extern void dump_opcode_frequencies (); +#endif atexit (_mcleanup); +#ifdef HAVE___EXECUTABLE_START + monstartup (__executable_start, &etext); +#else /* This uses safe_bcopy because that function comes first in the Emacs executable. It might be better to use something that gives the start of the text segment, but start_of_text is not defined on all systems now. */ + /* FIXME: Does not work on architectures with function + descriptors. */ monstartup (safe_bcopy, &etext); +#endif } else moncontrol (0); @@ -1851,9 +1739,7 @@ struct standard_args const struct standard_args standard_args[] = { { "-version", "--version", 150, 0 }, -#ifdef HAVE_SHM - { "-nl", "--no-shared-memory", 140, 0 }, -#endif + { "-chdir", "--chdir", 130, 1 }, { "-t", "--terminal", 120, 1 }, { "-nw", "--no-window-system", 110, 0 }, { "-nw", "--no-windows", 110, 0 }, @@ -1861,10 +1747,6 @@ const struct standard_args standard_args[] = { "-script", "--script", 100, 1 }, { "-daemon", "--daemon", 99, 0 }, { "-help", "--help", 90, 0 }, - { "-no-unibyte", "--no-unibyte", 83, 0 }, - { "-multibyte", "--multibyte", 82, 0 }, - { "-unibyte", "--unibyte", 81, 0 }, - { "-no-multibyte", "--no-multibyte", 80, 0 }, { "-nl", "--no-loadup", 70, 0 }, /* -d must come last before the options handled in startup.el. */ { "-d", "--display", 60, 1 }, @@ -1962,9 +1844,7 @@ const struct standard_args standard_args[] = than once, eliminate all but one copy of it. */ static void -sort_args (argc, argv) - int argc; - char **argv; +sort_args (int argc, char **argv) { char **new = (char **) xmalloc (sizeof (char *) * argc); /* For each element of argv, @@ -2022,7 +1902,7 @@ sort_args (argc, argv) { match = -1; thislen = strlen (argv[from]); - equals = index (argv[from], '='); + equals = strchr (argv[from], '='); if (equals != 0) thislen = equals - argv[from]; @@ -2105,7 +1985,7 @@ sort_args (argc, argv) while (to < argc) new[to++] = 0; - bcopy (new, argv, sizeof (char *) * argc); + memcpy (argv, new, sizeof (char *) * argc); xfree (options); xfree (new); @@ -2117,11 +1997,13 @@ DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", If ARG is an integer, return ARG as the exit program code. If ARG is a string, stuff it as keyboard input. +This function is called upon receipt of the signals SIGTERM +or SIGHUP, and upon SIGINT in batch mode. + The value of `kill-emacs-hook', if not void, is a list of functions (of no args), all of which are called before Emacs is actually killed. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { struct gcpro gcpro1; @@ -2130,7 +2012,7 @@ all of which are called before Emacs is actually killed. */) if (feof (stdin)) arg = Qt; - if (!NILP (Vrun_hooks) && !noninteractive) + if (!NILP (Vrun_hooks)) call1 (Vrun_hooks, intern ("kill-emacs-hook")); UNGCPRO; @@ -2144,8 +2026,6 @@ all of which are called before Emacs is actually killed. */) unlink (SDATA (Vauto_save_list_file_name)); exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS); - /* NOTREACHED */ - return Qnil; } @@ -2161,9 +2041,7 @@ all of which are called before Emacs is actually killed. */) and Fkill_emacs. */ void -shut_down_emacs (sig, no_x, stuff) - int sig, no_x; - Lisp_Object stuff; +shut_down_emacs (int sig, int no_x, Lisp_Object stuff) { /* Prevent running of hooks from now on. */ Vrun_hooks = Qnil; @@ -2172,7 +2050,7 @@ shut_down_emacs (sig, no_x, stuff) Vinhibit_redisplay = Qt; /* If we are controlling the terminal, reset terminal modes. */ -#ifdef EMACS_HAVE_TTY_PGRP +#ifndef DOS_NT { int pgrp = EMACS_GETPGRP (0); @@ -2192,9 +2070,7 @@ shut_down_emacs (sig, no_x, stuff) stuff_buffered_input (stuff); -#ifdef subprocesses inhibit_sentinels = 1; -#endif kill_buffer_processes (Qnil); Fdo_auto_save (Qt, Qnil); @@ -2245,38 +2121,9 @@ shut_down_emacs (sig, no_x, stuff) #ifndef CANNOT_DUMP -#ifdef HAVE_SHM - -DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0, - doc: /* Dump current state of Emacs into data file FILENAME. -This function exists on systems that use HAVE_SHM. */) - (filename) - Lisp_Object filename; -{ - extern char my_edata[]; - Lisp_Object tem; - - check_pure_size (); - CHECK_STRING (filename); - filename = Fexpand_file_name (filename, Qnil); - - tem = Vpurify_flag; - Vpurify_flag = Qnil; - - fflush (stdout); - /* Tell malloc where start of impure now is. */ - /* Also arrange for warnings when nearly out of space. */ -#ifndef SYSTEM_MALLOC - memory_warnings (my_edata, malloc_warning); -#endif - map_out_data (SDATA (filename)); - - Vpurify_flag = tem; - - return Qnil; -} - -#else /* not HAVE_SHM */ +/* FIXME: maybe this should go into header file, config.h seems the + only one appropriate. */ +extern int unexec (const char *, const char *); DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0, doc: /* Dump current state of Emacs into executable file FILENAME. @@ -2284,8 +2131,7 @@ Take symbols from SYMFILE (presumably the file you executed to run Emacs). This is used in the file `loadup.el' when building Emacs. You must run Emacs in batch mode in order to dump it. */) - (filename, symfile) - Lisp_Object filename, symfile; + (Lisp_Object filename, Lisp_Object symfile) { extern char my_edata[]; Lisp_Object tem; @@ -2346,13 +2192,13 @@ You must run Emacs in batch mode in order to dump it. */) Meanwhile, my_edata is not valid on Windows. */ memory_warnings (my_edata, malloc_warning); #endif /* not WINDOWSNT */ -#endif -#if !defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT +#if defined (HAVE_GTK_AND_PTHREAD) && !defined SYNC_INPUT /* Pthread may call malloc before main, and then we will get an endless loop, because pthread_self (see alloc.c) calls malloc the first time it is called on some systems. */ reset_malloc_hooks (); #endif +#endif /* not SYSTEM_MALLOC */ #ifdef DOUG_LEA_MALLOC malloc_state_ptr = malloc_get_state (); #endif @@ -2360,8 +2206,7 @@ You must run Emacs in batch mode in order to dump it. */) #ifdef USE_MMAP_FOR_BUFFERS mmap_set_vars (0); #endif - unexec (SDATA (filename), - !NILP (symfile) ? SDATA (symfile) : 0, my_edata, 0, 0); + unexec (SDATA (filename), !NILP (symfile) ? SDATA (symfile) : 0); #ifdef USE_MMAP_FOR_BUFFERS mmap_set_vars (1); #endif @@ -2374,14 +2219,12 @@ You must run Emacs in batch mode in order to dump it. */) return unbind_to (count, Qnil); } -#endif /* not HAVE_SHM */ - #endif /* not CANNOT_DUMP */ #if HAVE_SETLOCALE /* Recover from setlocale (LC_ALL, ""). */ void -fixup_locale () +fixup_locale (void) { /* The Emacs Lisp reader needs LC_NUMERIC to be "C", so that numbers are read and printed properly for Emacs Lisp. */ @@ -2391,10 +2234,7 @@ fixup_locale () /* Set system locale CATEGORY, with previous locale *PLOCALE, to DESIRED_LOCALE. */ static void -synchronize_locale (category, plocale, desired_locale) - int category; - Lisp_Object *plocale; - Lisp_Object desired_locale; +synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_locale) { if (! EQ (*plocale, desired_locale)) { @@ -2407,7 +2247,7 @@ synchronize_locale (category, plocale, desired_locale) /* Set system time locale to match Vsystem_time_locale, if possible. */ void -synchronize_system_time_locale () +synchronize_system_time_locale (void) { synchronize_locale (LC_TIME, &Vprevious_system_time_locale, Vsystem_time_locale); @@ -2416,7 +2256,7 @@ synchronize_system_time_locale () /* Set system messages locale to match Vsystem_messages_locale, if possible. */ void -synchronize_system_messages_locale () +synchronize_system_messages_locale (void) { #ifdef LC_MESSAGES synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale, @@ -2430,17 +2270,16 @@ synchronize_system_messages_locale () #endif Lisp_Object -decode_env_path (evarname, defalt) - char *evarname, *defalt; +decode_env_path (const char *evarname, const char *defalt) { - register char *path, *p; + const char *path, *p; Lisp_Object lpath, element, tem; /* It's okay to use getenv here, because this function is only used to initialize variables when Emacs starts up, and isn't called after that. */ if (evarname != 0) - path = (char *) getenv (evarname); + path = getenv (evarname); else path = 0; if (!path) @@ -2449,21 +2288,18 @@ decode_env_path (evarname, defalt) /* Ensure values from the environment use the proper directory separator. */ if (path) { - p = alloca (strlen (path) + 1); - strcpy (p, path); - path = p; - - if ('/' == DIRECTORY_SEP) - dostounix_filename (path); - else - unixtodos_filename (path); + char *path_copy = alloca (strlen (path) + 1); + strcpy (path_copy, path); + dostounix_filename (path_copy); + path = path_copy; } #endif lpath = Qnil; while (1) { - p = index (path, SEPCHAR); - if (!p) p = path + strlen (path); + p = strchr (path, SEPCHAR); + if (!p) + p = path + strlen (path); element = (p - path ? make_string (path, p - path) : build_string (".")); @@ -2496,7 +2332,7 @@ decode_env_path (evarname, defalt) DEFUN ("daemonp", Fdaemonp, Sdaemonp, 0, 0, 0, doc: /* Return non-nil if the current emacs process is a daemon. If the daemon was given a name argument, return that name. */) - () + (void) { if (IS_DAEMON) if (daemon_name) @@ -2511,7 +2347,7 @@ DEFUN ("daemon-initialized", Fdaemon_initialized, Sdaemon_initialized, 0, 0, 0, doc: /* Mark the Emacs daemon as being initialized. This finishes the daemonization process by doing the other half of detaching from the parent process and its tty file descriptors. */) - () + (void) { int nfd; @@ -2546,18 +2382,14 @@ from the parent process and its tty file descriptors. */) } void -syms_of_emacs () +syms_of_emacs (void) { Qfile_name_handler_alist = intern_c_string ("file-name-handler-alist"); staticpro (&Qfile_name_handler_alist); #ifndef CANNOT_DUMP -#ifdef HAVE_SHM - defsubr (&Sdump_emacs_data); -#else defsubr (&Sdump_emacs); #endif -#endif defsubr (&Skill_emacs); @@ -2604,7 +2436,8 @@ in other similar situations), functions placed on this hook should not expect to be able to interact with the user. To ask for confirmation, see `kill-emacs-query-functions' instead. -The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */); +Before Emacs 24.1, the hook was not run in batch mode, i.e., if +`noninteractive' was non-nil. */); Vkill_emacs_hook = Qnil; DEFVAR_INT ("emacs-priority", &emacs_priority, @@ -2669,6 +2502,32 @@ This is nil during initialization. */); doc: /* If non-nil, X resources, Windows Registry settings, and NS defaults are not used. */); inhibit_x_resources = 0; + DEFVAR_LISP ("emacs-copyright", &Vemacs_copyright, + doc: /* Short copyright string for this version of Emacs. */); + Vemacs_copyright = build_string (emacs_copyright); + + DEFVAR_LISP ("emacs-version", &Vemacs_version, + doc: /* Version numbers of this version of Emacs. */); + Vemacs_version = build_string (emacs_version); + + DEFVAR_LISP ("dynamic-library-alist", &Vdynamic_library_alist, + doc: /* Alist of dynamic libraries vs external files implementing them. +Each element is a list (LIBRARY FILE...), where the car is a symbol +representing a supported external library, and the rest are strings giving +alternate filenames for that library. + +Emacs tries to load the library from the files in the order they appear on +the list; if none is loaded, the running session of Emacs won't have access +to that library. + +Note that image types `pbm' and `xbm' do not need entries in this variable +because they do not depend on external libraries and are always available. + +Also note that this is not a generic facility for accessing external +libraries; only those already known by Emacs will be loaded. */); + Vdynamic_library_alist = Qnil; + Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt); + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; } diff --git a/src/eval.c b/src/eval.c index 6b74f5b884d..15112d8659b 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1,7 +1,7 @@ /* Evaluator for GNU Emacs Lisp interpreter. Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "commands.h" #include "keyboard.h" #include "dispextern.h" +#include "frame.h" /* For XFRAME. */ #if HAVE_X_WINDOWS #include "xterm.h" @@ -62,7 +63,6 @@ Lisp_Object Qand_rest, Qand_optional; Lisp_Object Qdebug_on_error; Lisp_Object Qdeclare; Lisp_Object Qdebug; -extern Lisp_Object Qinteractive_form; /* This holds either the symbol `run-hooks' or nil. It is nil at an early stage of startup, and when Emacs @@ -79,7 +79,7 @@ Lisp_Object Vautoload_queue; /* Current number of specbindings allocated in specpdl. */ -int specpdl_size; +EMACS_INT specpdl_size; /* Pointer to beginning of specpdl. */ @@ -95,7 +95,7 @@ EMACS_INT max_specpdl_size; /* Depth in Lisp evaluations and function calls. */ -int lisp_eval_depth; +EMACS_INT lisp_eval_depth; /* Maximum allowed depth in Lisp evaluations and function calls. */ @@ -165,23 +165,11 @@ int handling_signal; Lisp_Object Vmacro_declaration_function; -extern Lisp_Object Qrisky_local_variable; - -extern Lisp_Object Qfunction; - -static Lisp_Object funcall_lambda P_ ((Lisp_Object, int, Lisp_Object*)); -static void unwind_to_catch P_ ((struct catchtag *, Lisp_Object)) NO_RETURN; - -#if __GNUC__ -/* "gcc -O3" enables automatic function inlining, which optimizes out - the arguments for the invocations of these functions, whereas they - expect these values on the stack. */ -Lisp_Object apply1 () __attribute__((noinline)); -Lisp_Object call2 () __attribute__((noinline)); -#endif +static Lisp_Object funcall_lambda (Lisp_Object, int, Lisp_Object*); +static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN; void -init_eval_once () +init_eval_once (void) { specpdl_size = 50; specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); @@ -194,7 +182,7 @@ init_eval_once () } void -init_eval () +init_eval (void) { specpdl_ptr = specpdl; catchlist = 0; @@ -213,8 +201,7 @@ init_eval () /* unwind-protect function used by call_debugger. */ static Lisp_Object -restore_stack_limits (data) - Lisp_Object data; +restore_stack_limits (Lisp_Object data) { max_specpdl_size = XINT (XCAR (data)); max_lisp_eval_depth = XINT (XCDR (data)); @@ -224,13 +211,12 @@ restore_stack_limits (data) /* Call the Lisp debugger, giving it argument ARG. */ Lisp_Object -call_debugger (arg) - Lisp_Object arg; +call_debugger (Lisp_Object arg) { int debug_while_redisplaying; int count = SPECPDL_INDEX (); Lisp_Object val; - int old_max = max_specpdl_size; + EMACS_INT old_max = max_specpdl_size; /* Temporarily bump up the stack limits, so the debugger won't run out of stack. */ @@ -281,8 +267,7 @@ call_debugger (arg) } void -do_debug_on_call (code) - Lisp_Object code; +do_debug_on_call (Lisp_Object code) { debug_on_next_call = 0; backtrace_list->debug_on_exit = 1; @@ -298,8 +283,7 @@ DEFUN ("or", For, Sor, 0, UNEVALLED, 0, The remaining args are not evalled at all. If all args return nil, return nil. usage: (or CONDITIONS...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object val = Qnil; struct gcpro gcpro1; @@ -323,8 +307,7 @@ DEFUN ("and", Fand, Sand, 0, UNEVALLED, 0, The remaining args are not evalled at all. If no arg yields nil, return the last arg's value. usage: (and CONDITIONS...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object val = Qt; struct gcpro gcpro1; @@ -349,8 +332,7 @@ Returns the value of THEN or the value of the last of the ELSE's. THEN must be one expression, but ELSE... can be zero or more expressions. If COND yields nil, and there are no ELSE's, the value is nil. usage: (if COND THEN ELSE...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object cond; struct gcpro gcpro1; @@ -374,8 +356,7 @@ If no clause succeeds, cond returns nil. If a clause has one element, as in (CONDITION), CONDITION's value if non-nil is returned from the cond-form. usage: (cond CLAUSES...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object clause, val; struct gcpro gcpro1; @@ -402,8 +383,7 @@ usage: (cond CLAUSES...) */) DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, doc: /* Eval BODY forms sequentially and return value of last one. usage: (progn BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object val = Qnil; struct gcpro gcpro1; @@ -425,8 +405,7 @@ DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, The value of FIRST is saved during the evaluation of the remaining args, whose values are discarded. usage: (prog1 FIRST BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object val; register Lisp_Object args_left; @@ -443,7 +422,7 @@ usage: (prog1 FIRST BODY...) */) do { if (!(argnum++)) - val = Feval (Fcar (args_left)); + val = Feval (Fcar (args_left)); else Feval (Fcar (args_left)); args_left = Fcdr (args_left); @@ -459,8 +438,7 @@ DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, The value of FORM2 is saved during the evaluation of the remaining args, whose values are discarded. usage: (prog2 FORM1 FORM2 BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object val; register Lisp_Object args_left; @@ -479,7 +457,7 @@ usage: (prog2 FORM1 FORM2 BODY...) */) do { if (!(argnum++)) - val = Feval (Fcar (args_left)); + val = Feval (Fcar (args_left)); else Feval (Fcar (args_left)); args_left = Fcdr (args_left); @@ -499,8 +477,7 @@ The second VAL is not computed until after the first SYM is set, and so on; each VAL can use the new value of variables set earlier in the `setq'. The return value of the `setq' form is the value of the last VAL. usage: (setq [SYM VAL]...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object args_left; register Lisp_Object val, sym; @@ -528,8 +505,7 @@ usage: (setq [SYM VAL]...) */) DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0, doc: /* Return the argument, without evaluating it. `(quote x)' yields `x'. usage: (quote ARG) */) - (args) - Lisp_Object args; + (Lisp_Object args) { if (!NILP (Fcdr (args))) xsignal2 (Qwrong_number_of_arguments, Qquote, Flength (args)); @@ -541,8 +517,7 @@ DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0, In byte compilation, `function' causes its argument to be compiled. `quote' cannot do that. usage: (function ARG) */) - (args) - Lisp_Object args; + (Lisp_Object args) { if (!NILP (Fcdr (args))) xsignal2 (Qwrong_number_of_arguments, Qfunction, Flength (args)); @@ -567,7 +542,7 @@ To test whether your function was called with `call-interactively', either (i) add an extra optional argument and give it an `interactive' spec that specifies non-nil unconditionally (such as \"p\"); or (ii) use `called-interactively-p'. */) - () + (void) { return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil; } @@ -593,8 +568,7 @@ function-modifying features. Instead of using this, it is sometimes cleaner to give your function an extra optional argument whose `interactive' spec specifies non-nil unconditionally (\"p\" is a good way to do this), or via (not (or executing-kbd-macro noninteractive)). */) - (kind) - Lisp_Object kind; + (Lisp_Object kind) { return ((INTERACTIVE || !EQ (kind, intern ("interactive"))) && interactive_p (1)) ? Qt : Qnil; @@ -608,8 +582,7 @@ way to do this), or via (not (or executing-kbd-macro noninteractive)). */) called is a built-in. */ int -interactive_p (exclude_subrs_p) - int exclude_subrs_p; +interactive_p (int exclude_subrs_p) { struct backtrace *btp; Lisp_Object fun; @@ -656,8 +629,7 @@ DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, The definition is (lambda ARGLIST [DOCSTRING] BODY...). See also the function `interactive'. usage: (defun NAME ARGLIST [DOCSTRING] BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object fn_name; register Lisp_Object defn; @@ -700,8 +672,7 @@ The elements can look like this: Set NAME's `doc-string-elt' property to ELT. usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object fn_name; register Lisp_Object defn; @@ -719,8 +690,8 @@ usage: (defmacro NAME ARGLIST [DOCSTRING] [DECL] BODY...) */) tail = XCDR (tail); } - while (CONSP (Fcar (tail)) - && EQ (Fcar (Fcar (tail)), Qdeclare)) + if (CONSP (Fcar (tail)) + && EQ (Fcar (Fcar (tail)), Qdeclare)) { if (!NILP (Vmacro_declaration_function)) { @@ -759,32 +730,50 @@ or of the variable at the end of the chain of aliases, if BASE-VARIABLE is itself an alias. If NEW-ALIAS is bound, and BASE-VARIABLE is not, then the value of BASE-VARIABLE is set to that of NEW-ALIAS. The return value is BASE-VARIABLE. */) - (new_alias, base_variable, docstring) - Lisp_Object new_alias, base_variable, docstring; + (Lisp_Object new_alias, Lisp_Object base_variable, Lisp_Object docstring) { struct Lisp_Symbol *sym; CHECK_SYMBOL (new_alias); CHECK_SYMBOL (base_variable); - if (SYMBOL_CONSTANT_P (new_alias)) + sym = XSYMBOL (new_alias); + + if (sym->constant) + /* Not sure why, but why not? */ error ("Cannot make a constant an alias"); - sym = XSYMBOL (new_alias); + switch (sym->redirect) + { + case SYMBOL_FORWARDED: + error ("Cannot make an internal variable an alias"); + case SYMBOL_LOCALIZED: + error ("Don't know how to make a localized variable an alias"); + } + /* http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg00834.html - If n_a is bound, but b_v is not, set the value of b_v to n_a. - This is for the sake of define-obsolete-variable-alias and user - customizations. */ - if (NILP (Fboundp (base_variable)) && !NILP (Fboundp (new_alias))) - XSYMBOL(base_variable)->value = sym->value; - sym->indirect_variable = 1; - sym->value = base_variable; + If n_a is bound, but b_v is not, set the value of b_v to n_a, + so that old-code that affects n_a before the aliasing is setup + still works. */ + if (NILP (Fboundp (base_variable))) + set_internal (base_variable, find_symbol_value (new_alias), Qnil, 1); + + { + struct specbinding *p; + + for (p = specpdl_ptr - 1; p >= specpdl; p--) + if (p->func == NULL + && (EQ (new_alias, + CONSP (p->symbol) ? XCAR (p->symbol) : p->symbol))) + error ("Don't know how to make a let-bound variable an alias"); + } + + sym->redirect = SYMBOL_VARALIAS; + SET_SYMBOL_ALIAS (sym, XSYMBOL (base_variable)); sym->constant = SYMBOL_CONSTANT_P (base_variable); LOADHIST_ATTACH (new_alias); - if (!NILP (docstring)) - Fput (new_alias, Qvariable_documentation, docstring); - else - Fput (new_alias, Qvariable_documentation, Qnil); + /* Even if docstring is nil: remove old docstring. */ + Fput (new_alias, Qvariable_documentation, docstring); return base_variable; } @@ -812,8 +801,7 @@ load a file defining variables, with this form or with `defconst' or for these variables. \(`defconst' and `defcustom' behave similarly in this respect.) usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object sym, tem, tail; @@ -885,8 +873,7 @@ If SYMBOL has a local binding, then this form sets the local binding's value. However, you should normally not make local bindings for variables defined with this form. usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object sym, tem; @@ -912,8 +899,7 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) /* Error handler used in Fuser_variable_p. */ static Lisp_Object -user_variable_p_eh (ignore) - Lisp_Object ignore; +user_variable_p_eh (Lisp_Object ignore) { return Qnil; } @@ -935,8 +921,7 @@ A variable is a user variable if \(3) it is an alias for another user variable. Return nil if VARIABLE is an alias and there is a loop in the chain of symbols. */) - (variable) - Lisp_Object variable; + (Lisp_Object variable) { Lisp_Object documentation; @@ -944,35 +929,35 @@ chain of symbols. */) return Qnil; /* If indirect and there's an alias loop, don't check anything else. */ - if (XSYMBOL (variable)->indirect_variable + if (XSYMBOL (variable)->redirect == SYMBOL_VARALIAS && NILP (internal_condition_case_1 (lisp_indirect_variable, variable, - Qt, user_variable_p_eh))) + Qt, user_variable_p_eh))) return Qnil; while (1) { documentation = Fget (variable, Qvariable_documentation); if (INTEGERP (documentation) && XINT (documentation) < 0) - return Qt; + return Qt; if (STRINGP (documentation) - && ((unsigned char) SREF (documentation, 0) == '*')) - return Qt; + && ((unsigned char) SREF (documentation, 0) == '*')) + return Qt; /* If it is (STRING . INTEGER), a negative integer means a user variable. */ if (CONSP (documentation) - && STRINGP (XCAR (documentation)) - && INTEGERP (XCDR (documentation)) - && XINT (XCDR (documentation)) < 0) - return Qt; + && STRINGP (XCAR (documentation)) + && INTEGERP (XCDR (documentation)) + && XINT (XCDR (documentation)) < 0) + return Qt; /* Customizable? See `custom-variable-p'. */ if ((!NILP (Fget (variable, intern ("standard-value")))) - || (!NILP (Fget (variable, intern ("custom-autoload"))))) - return Qt; + || (!NILP (Fget (variable, intern ("custom-autoload"))))) + return Qt; - if (!XSYMBOL (variable)->indirect_variable) - return Qnil; + if (!(XSYMBOL (variable)->redirect == SYMBOL_VARALIAS)) + return Qnil; /* An indirect variable? Let's follow the chain. */ - variable = XSYMBOL (variable)->value; + XSETSYMBOL (variable, SYMBOL_ALIAS (XSYMBOL (variable))); } } @@ -983,8 +968,7 @@ Each element of VARLIST is a symbol (which is bound to nil) or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM). Each VALUEFORM can refer to the symbols already bound by this VARLIST. usage: (let* VARLIST BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object varlist, val, elt; int count = SPECPDL_INDEX (); @@ -1020,8 +1004,7 @@ Each element of VARLIST is a symbol (which is bound to nil) or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM). All the VALUEFORMs are evalled before any symbols are bound. usage: (let VARLIST BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object *temps, tem; register Lisp_Object elt, varlist; @@ -1076,8 +1059,7 @@ DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0, The order of execution is thus TEST, BODY, TEST, BODY and so on until TEST returns nil. usage: (while TEST BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object test, body; struct gcpro gcpro1, gcpro2; @@ -1104,9 +1086,7 @@ in place of FORM. When a non-macro-call results, it is returned. The second optional arg ENVIRONMENT specifies an environment of macro definitions to shadow the loaded ones for use in file byte-compilation. */) - (form, environment) - Lisp_Object form; - Lisp_Object environment; + (Lisp_Object form, Lisp_Object environment) { /* With cleanups from Hallvard Furuseth. */ register Lisp_Object expander, sym, def, tem; @@ -1184,8 +1164,7 @@ Within BODY, a call to `throw' with the same TAG exits BODY and this `catch'. If no throw happens, `catch' returns the value of the last BODY form. If a throw happens, it specifies the value to return from `catch'. usage: (catch TAG BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object tag; struct gcpro gcpro1; @@ -1201,10 +1180,7 @@ usage: (catch TAG BODY...) */) This is how catches are done from within C code. */ Lisp_Object -internal_catch (tag, func, arg) - Lisp_Object tag; - Lisp_Object (*func) (); - Lisp_Object arg; +internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object arg) { /* This structure is made part of the chain `catchlist'. */ struct catchtag c; @@ -1249,9 +1225,7 @@ internal_catch (tag, func, arg) This is used for correct unwinding in Fthrow and Fsignal. */ static void -unwind_to_catch (catch, value) - struct catchtag *catch; - Lisp_Object value; +unwind_to_catch (struct catchtag *catch, Lisp_Object value) { register int last_time; @@ -1269,7 +1243,7 @@ unwind_to_catch (catch, value) last_time = catchlist == catch; /* Unwind the specpdl stack, and then restore the proper set of - handlers. */ + handlers. */ unbind_to (catchlist->pdlcount, Qnil); handlerlist = catchlist->handlerlist; catchlist = catchlist->next; @@ -1280,8 +1254,8 @@ unwind_to_catch (catch, value) /* If x_catch_errors was done, turn it off now. (First we give unbind_to a chance to do that.) */ #if 0 /* This would disable x_catch_errors after x_connection_closed. - * The catch must remain in effect during that delicate - * state. --lorentey */ + The catch must remain in effect during that delicate + state. --lorentey */ x_fully_uncatch_errors (); #endif #endif @@ -1303,8 +1277,7 @@ unwind_to_catch (catch, value) DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, doc: /* Throw to the catch for TAG and return VALUE from it. Both TAG and VALUE are evalled. */) - (tag, value) - register Lisp_Object tag, value; + (register Lisp_Object tag, Lisp_Object value) { register struct catchtag *c; @@ -1324,8 +1297,7 @@ If BODYFORM completes normally, its value is returned after executing the UNWINDFORMS. If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway. usage: (unwind-protect BODYFORM UNWINDFORMS...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { Lisp_Object val; int count = SPECPDL_INDEX (); @@ -1359,14 +1331,13 @@ instead of a single condition name. Then it handles all of them. When a handler handles an error, control returns to the `condition-case' and it executes the handler's BODY... with VAR bound to (ERROR-SYMBOL . SIGNAL-DATA) from the error. -(If VAR is nil, the handler can't access that information.) +\(If VAR is nil, the handler can't access that information.) Then the value of the last BODY form is returned from the `condition-case' expression. See also the function `signal' for more info. usage: (condition-case VAR BODYFORM &rest HANDLERS) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object bodyform, handlers; volatile Lisp_Object var; @@ -1382,9 +1353,8 @@ usage: (condition-case VAR BODYFORM &rest HANDLERS) */) rather than passed in a list. Used by Fbyte_code. */ Lisp_Object -internal_lisp_condition_case (var, bodyform, handlers) - volatile Lisp_Object var; - Lisp_Object bodyform, handlers; +internal_lisp_condition_case (volatile Lisp_Object var, Lisp_Object bodyform, + Lisp_Object handlers) { Lisp_Object val; struct catchtag c; @@ -1416,7 +1386,7 @@ internal_lisp_condition_case (var, bodyform, handlers) if (_setjmp (c.jmp)) { if (!NILP (h.var)) - specbind (h.var, c.val); + specbind (h.var, c.val); val = Fprogn (Fcdr (h.chosen_clause)); /* Note that this just undoes the binding of h.var; whoever @@ -1451,10 +1421,8 @@ internal_lisp_condition_case (var, bodyform, handlers) but allow the debugger to run if that is enabled. */ Lisp_Object -internal_condition_case (bfun, handlers, hfun) - Lisp_Object (*bfun) (); - Lisp_Object handlers; - Lisp_Object (*hfun) (); +internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers, + Lisp_Object (*hfun) (Lisp_Object)) { Lisp_Object val; struct catchtag c; @@ -1498,11 +1466,8 @@ internal_condition_case (bfun, handlers, hfun) /* Like internal_condition_case but call BFUN with ARG as its argument. */ Lisp_Object -internal_condition_case_1 (bfun, arg, handlers, hfun) - Lisp_Object (*bfun) (); - Lisp_Object arg; - Lisp_Object handlers; - Lisp_Object (*hfun) (); +internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg, + Lisp_Object handlers, Lisp_Object (*hfun) (Lisp_Object)) { Lisp_Object val; struct catchtag c; @@ -1543,17 +1508,64 @@ internal_condition_case_1 (bfun, arg, handlers, hfun) return val; } +/* Like internal_condition_case_1 but call BFUN with ARG1 and ARG2 as + its arguments. */ + +Lisp_Object +internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object), + Lisp_Object arg1, + Lisp_Object arg2, + Lisp_Object handlers, + Lisp_Object (*hfun) (Lisp_Object)) +{ + Lisp_Object val; + struct catchtag c; + struct handler h; + + /* Since Fsignal will close off all calls to x_catch_errors, + we will get the wrong results if some are not closed now. */ +#if HAVE_X_WINDOWS + if (x_catching_errors ()) + abort (); +#endif + + c.tag = Qnil; + c.val = Qnil; + c.backlist = backtrace_list; + c.handlerlist = handlerlist; + c.lisp_eval_depth = lisp_eval_depth; + c.pdlcount = SPECPDL_INDEX (); + c.poll_suppress_count = poll_suppress_count; + c.interrupt_input_blocked = interrupt_input_blocked; + c.gcpro = gcprolist; + c.byte_stack = byte_stack_list; + if (_setjmp (c.jmp)) + { + return (*hfun) (c.val); + } + c.next = catchlist; + catchlist = &c; + h.handler = handlers; + h.var = Qnil; + h.next = handlerlist; + h.tag = &c; + handlerlist = &h; + + val = (*bfun) (arg1, arg2); + catchlist = c.next; + handlerlist = h.next; + return val; +} /* Like internal_condition_case but call BFUN with NARGS as first, and ARGS as second argument. */ Lisp_Object -internal_condition_case_2 (bfun, nargs, args, handlers, hfun) - Lisp_Object (*bfun) (); - int nargs; - Lisp_Object *args; - Lisp_Object handlers; - Lisp_Object (*hfun) (); +internal_condition_case_n (Lisp_Object (*bfun) (int, Lisp_Object*), + int nargs, + Lisp_Object *args, + Lisp_Object handlers, + Lisp_Object (*hfun) (Lisp_Object)) { Lisp_Object val; struct catchtag c; @@ -1595,8 +1607,8 @@ internal_condition_case_2 (bfun, nargs, args, handlers, hfun) } -static Lisp_Object find_handler_clause P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object)); +static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object); DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, doc: /* Signal an error. Args are ERROR-SYMBOL and associated DATA. @@ -1612,16 +1624,13 @@ See Info anchor `(elisp)Definition of signal' for some details on how this error message is constructed. If the signal is handled, DATA is made available to the handler. See also the function `condition-case'. */) - (error_symbol, data) - Lisp_Object error_symbol, data; + (Lisp_Object error_symbol, Lisp_Object data) { /* When memory is full, ERROR-SYMBOL is nil, and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). That is a special case--don't do this in other situations. */ register struct handler *allhandlers = handlerlist; Lisp_Object conditions; - extern int gc_in_progress; - extern int waiting_for_input; Lisp_Object string; Lisp_Object real_error_symbol; struct backtrace *bp; @@ -1725,8 +1734,7 @@ See also the function `condition-case'. */) Used for anything but Qquit (which can return from Fsignal). */ void -xsignal (error_symbol, data) - Lisp_Object error_symbol, data; +xsignal (Lisp_Object error_symbol, Lisp_Object data) { Fsignal (error_symbol, data); abort (); @@ -1735,29 +1743,25 @@ xsignal (error_symbol, data) /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ void -xsignal0 (error_symbol) - Lisp_Object error_symbol; +xsignal0 (Lisp_Object error_symbol) { xsignal (error_symbol, Qnil); } void -xsignal1 (error_symbol, arg) - Lisp_Object error_symbol, arg; +xsignal1 (Lisp_Object error_symbol, Lisp_Object arg) { xsignal (error_symbol, list1 (arg)); } void -xsignal2 (error_symbol, arg1, arg2) - Lisp_Object error_symbol, arg1, arg2; +xsignal2 (Lisp_Object error_symbol, Lisp_Object arg1, Lisp_Object arg2) { xsignal (error_symbol, list2 (arg1, arg2)); } void -xsignal3 (error_symbol, arg1, arg2, arg3) - Lisp_Object error_symbol, arg1, arg2, arg3; +xsignal3 (Lisp_Object error_symbol, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) { xsignal (error_symbol, list3 (arg1, arg2, arg3)); } @@ -1766,9 +1770,7 @@ xsignal3 (error_symbol, arg1, arg2, arg3) If ARG is not a genuine list, make it a one-element list. */ void -signal_error (s, arg) - char *s; - Lisp_Object arg; +signal_error (const char *s, Lisp_Object arg) { Lisp_Object tortoise, hare; @@ -1797,8 +1799,7 @@ signal_error (s, arg) a list containing one of CONDITIONS. */ static int -wants_debugger (list, conditions) - Lisp_Object list, conditions; +wants_debugger (Lisp_Object list, Lisp_Object conditions) { if (NILP (list)) return 0; @@ -1822,8 +1823,7 @@ wants_debugger (list, conditions) according to debugger-ignored-errors. */ static int -skip_debugger (conditions, data) - Lisp_Object conditions, data; +skip_debugger (Lisp_Object conditions, Lisp_Object data) { Lisp_Object tail; int first_string = 1; @@ -1860,8 +1860,7 @@ skip_debugger (conditions, data) SIG and DATA describe the signal, as in find_handler_clause. */ static int -maybe_call_debugger (conditions, sig, data) - Lisp_Object conditions, sig, data; +maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) { Lisp_Object combined_data; @@ -1897,8 +1896,8 @@ maybe_call_debugger (conditions, sig, data) a second error here in case we're handling specpdl overflow. */ static Lisp_Object -find_handler_clause (handlers, conditions, sig, data) - Lisp_Object handlers, conditions, sig, data; +find_handler_clause (Lisp_Object handlers, Lisp_Object conditions, + Lisp_Object sig, Lisp_Object data) { register Lisp_Object h; register Lisp_Object tem; @@ -1987,31 +1986,25 @@ find_handler_clause (handlers, conditions, sig, data) return Qnil; } -/* dump an error message; called like printf */ -/* VARARGS 1 */ +/* dump an error message; called like vprintf */ void -error (m, a1, a2, a3) - char *m; - char *a1, *a2, *a3; +verror (const char *m, va_list ap) { char buf[200]; - int size = 200; + EMACS_INT size = 200; int mlen; char *buffer = buf; char *args[3]; int allocated = 0; Lisp_Object string; - args[0] = a1; - args[1] = a2; - args[2] = a3; - mlen = strlen (m); while (1) { - int used = doprnt (buffer, size, m, m + mlen, 3, args); + EMACS_INT used; + used = doprnt (buffer, size, m, m + mlen, ap); if (used < size) break; size *= 2; @@ -2030,6 +2023,19 @@ error (m, a1, a2, a3) xsignal1 (Qerror, string); } + + +/* dump an error message; called like printf */ + +/* VARARGS 1 */ +void +error (const char *m, ...) +{ + va_list ap; + va_start (ap, m); + verror (m, ap); + va_end (ap); +} DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, doc: /* Non-nil if FUNCTION makes provisions for interactive calling. @@ -2046,8 +2052,7 @@ Also, a symbol satisfies `commandp' if its function definition does so. If the optional argument FOR-CALL-INTERACTIVELY is non-nil, then strings and vectors are not accepted. */) - (function, for_call_interactively) - Lisp_Object function, for_call_interactively; + (Lisp_Object function, Lisp_Object for_call_interactively) { register Lisp_Object fun; register Lisp_Object funcar; @@ -2111,11 +2116,8 @@ Third through fifth args give info about the real definition. They default to nil. If FUNCTION is already defined other than as an autoload, this does nothing and returns nil. */) - (function, file, docstring, interactive, type) - Lisp_Object function, file, docstring, interactive, type; + (Lisp_Object function, Lisp_Object file, Lisp_Object docstring, Lisp_Object interactive, Lisp_Object type) { - Lisp_Object args[4]; - CHECK_SYMBOL (function); CHECK_STRING (file); @@ -2131,16 +2133,18 @@ this does nothing and returns nil. */) LOADHIST_ATTACH (Fcons (Qautoload, function)); else /* We don't want the docstring in purespace (instead, - Snarf-documentation should (hopefully) overwrite it). */ - docstring = make_number (0); + Snarf-documentation should (hopefully) overwrite it). + We used to use 0 here, but that leads to accidental sharing in + purecopy's hash-consing, so we use a (hopefully) unique integer + instead. */ + docstring = make_number (XHASH (function)); return Ffset (function, Fpurecopy (list5 (Qautoload, file, docstring, interactive, type))); } Lisp_Object -un_autoload (oldqueue) - Lisp_Object oldqueue; +un_autoload (Lisp_Object oldqueue) { register Lisp_Object queue, first, second; @@ -2167,8 +2171,7 @@ un_autoload (oldqueue) FUNDEF is the autoload definition (a list). */ void -do_autoload (fundef, funname) - Lisp_Object fundef, funname; +do_autoload (Lisp_Object fundef, Lisp_Object funname) { int count = SPECPDL_INDEX (); Lisp_Object fun; @@ -2193,7 +2196,7 @@ do_autoload (fundef, funname) the function. We do this in the specific case of autoloading because autoloading is not an explicit request "load this file", but rather a request to "call this function". - + The value saved here is to be restored into Vautoload_queue. */ record_unwind_protect (un_autoload, Vautoload_queue); Vautoload_queue = Qt; @@ -2214,8 +2217,7 @@ do_autoload (fundef, funname) DEFUN ("eval", Feval, Seval, 1, 1, 0, doc: /* Evaluate FORM and return its value. */) - (form) - Lisp_Object form; + (Lisp_Object form) { Lisp_Object fun, val, original_fun, original_args; Lisp_Object funcar; @@ -2292,7 +2294,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, if (XSUBR (fun)->max_args == UNEVALLED) { backtrace.evalargs = 0; - val = (*XSUBR (fun)->function) (args_left); + val = (XSUBR (fun)->function.aUNEVALLED) (args_left); goto done; } @@ -2319,7 +2321,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, backtrace.args = vals; backtrace.nargs = XINT (numargs); - val = (*XSUBR (fun)->function) (XINT (numargs), vals); + val = (XSUBR (fun)->function.aMANY) (XINT (numargs), vals); UNGCPRO; SAFE_FREE (); goto done; @@ -2344,40 +2346,40 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, switch (i) { case 0: - val = (*XSUBR (fun)->function) (); + val = (XSUBR (fun)->function.a0) (); goto done; case 1: - val = (*XSUBR (fun)->function) (argvals[0]); + val = (XSUBR (fun)->function.a1) (argvals[0]); goto done; case 2: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1]); + val = (XSUBR (fun)->function.a2) (argvals[0], argvals[1]); goto done; case 3: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], - argvals[2]); + val = (XSUBR (fun)->function.a3) (argvals[0], argvals[1], + argvals[2]); goto done; case 4: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], - argvals[2], argvals[3]); + val = (XSUBR (fun)->function.a4) (argvals[0], argvals[1], + argvals[2], argvals[3]); goto done; case 5: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], - argvals[3], argvals[4]); + val = (XSUBR (fun)->function.a5) (argvals[0], argvals[1], argvals[2], + argvals[3], argvals[4]); goto done; case 6: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], - argvals[3], argvals[4], argvals[5]); + val = (XSUBR (fun)->function.a6) (argvals[0], argvals[1], argvals[2], + argvals[3], argvals[4], argvals[5]); goto done; case 7: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], - argvals[3], argvals[4], argvals[5], - argvals[6]); + val = (XSUBR (fun)->function.a7) (argvals[0], argvals[1], argvals[2], + argvals[3], argvals[4], argvals[5], + argvals[6]); goto done; case 8: - val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], - argvals[3], argvals[4], argvals[5], - argvals[6], argvals[7]); + val = (XSUBR (fun)->function.a8) (argvals[0], argvals[1], argvals[2], + argvals[3], argvals[4], argvals[5], + argvals[6], argvals[7]); goto done; default: @@ -2427,9 +2429,7 @@ DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, Then return the value FUNCTION returns. Thus, (apply '+ 1 2 '(3 4)) returns 10. usage: (apply FUNCTION &rest ARGUMENTS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { register int i, numargs; register Lisp_Object spread_arg; @@ -2492,7 +2492,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) gcpro1.nvars = 1 + numargs; } - bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); + memcpy (funcall_args, args, nargs * sizeof (Lisp_Object)); /* Spread the last arg we got. Its first element goes in the slot that it used to occupy, hence this value of I. */ i = nargs - 1; @@ -2513,8 +2513,8 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) /* Run hook variables in various ways. */ enum run_hooks_condition {to_completion, until_success, until_failure}; -static Lisp_Object run_hook_with_args P_ ((int, Lisp_Object *, - enum run_hooks_condition)); +static Lisp_Object run_hook_with_args (int, Lisp_Object *, + enum run_hooks_condition); DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 0, MANY, 0, doc: /* Run each hook in HOOKS. @@ -2531,9 +2531,7 @@ hook; they should use `run-mode-hooks' instead. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hooks &rest HOOKS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object hook[1]; register int i; @@ -2562,9 +2560,7 @@ as that may change. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args HOOK &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, to_completion); } @@ -2584,9 +2580,7 @@ However, if they all return nil, we return nil. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-success HOOK &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, until_success); } @@ -2605,9 +2599,7 @@ Then we return nil. However, if they all return non-nil, we return non-nil. Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, until_failure); } @@ -2621,10 +2613,7 @@ usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */) except that it isn't necessary to gcpro ARGS[0]. */ static Lisp_Object -run_hook_with_args (nargs, args, cond) - int nargs; - Lisp_Object *args; - enum run_hooks_condition cond; +run_hook_with_args (int nargs, Lisp_Object *args, enum run_hooks_condition cond) { Lisp_Object sym, val, ret; struct gcpro gcpro1, gcpro2, gcpro3; @@ -2704,10 +2693,7 @@ run_hook_with_args (nargs, args, cond) except that it isn't necessary to gcpro ARGS[0]. */ Lisp_Object -run_hook_list_with_args (funlist, nargs, args) - Lisp_Object funlist; - int nargs; - Lisp_Object *args; +run_hook_list_with_args (Lisp_Object funlist, int nargs, Lisp_Object *args) { Lisp_Object sym; Lisp_Object val; @@ -2749,8 +2735,7 @@ run_hook_list_with_args (funlist, nargs, args) /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */ void -run_hook_with_args_2 (hook, arg1, arg2) - Lisp_Object hook, arg1, arg2; +run_hook_with_args_2 (Lisp_Object hook, Lisp_Object arg1, Lisp_Object arg2) { Lisp_Object temp[3]; temp[0] = hook; @@ -2762,8 +2747,7 @@ run_hook_with_args_2 (hook, arg1, arg2) /* Apply fn to arg */ Lisp_Object -apply1 (fn, arg) - Lisp_Object fn, arg; +apply1 (Lisp_Object fn, Lisp_Object arg) { struct gcpro gcpro1; @@ -2771,7 +2755,6 @@ apply1 (fn, arg) if (NILP (arg)) RETURN_UNGCPRO (Ffuncall (1, &fn)); gcpro1.nvars = 2; -#ifdef NO_ARG_ARRAY { Lisp_Object args[2]; args[0] = fn; @@ -2779,15 +2762,11 @@ apply1 (fn, arg) gcpro1.var = args; RETURN_UNGCPRO (Fapply (2, args)); } -#else /* not NO_ARG_ARRAY */ - RETURN_UNGCPRO (Fapply (2, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn on no arguments */ Lisp_Object -call0 (fn) - Lisp_Object fn; +call0 (Lisp_Object fn) { struct gcpro gcpro1; @@ -2798,11 +2777,9 @@ call0 (fn) /* Call function fn with 1 argument arg1 */ /* ARGSUSED */ Lisp_Object -call1 (fn, arg1) - Lisp_Object fn, arg1; +call1 (Lisp_Object fn, Lisp_Object arg1) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[2]; args[0] = fn; @@ -2810,21 +2787,14 @@ call1 (fn, arg1) GCPRO1 (args[0]); gcpro1.nvars = 2; RETURN_UNGCPRO (Ffuncall (2, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 2; - RETURN_UNGCPRO (Ffuncall (2, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn with 2 arguments arg1, arg2 */ /* ARGSUSED */ Lisp_Object -call2 (fn, arg1, arg2) - Lisp_Object fn, arg1, arg2; +call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[3]; args[0] = fn; args[1] = arg1; @@ -2832,21 +2802,14 @@ call2 (fn, arg1, arg2) GCPRO1 (args[0]); gcpro1.nvars = 3; RETURN_UNGCPRO (Ffuncall (3, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 3; - RETURN_UNGCPRO (Ffuncall (3, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn with 3 arguments arg1, arg2, arg3 */ /* ARGSUSED */ Lisp_Object -call3 (fn, arg1, arg2, arg3) - Lisp_Object fn, arg1, arg2, arg3; +call3 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[4]; args[0] = fn; args[1] = arg1; @@ -2855,21 +2818,15 @@ call3 (fn, arg1, arg2, arg3) GCPRO1 (args[0]); gcpro1.nvars = 4; RETURN_UNGCPRO (Ffuncall (4, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 4; - RETURN_UNGCPRO (Ffuncall (4, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */ /* ARGSUSED */ Lisp_Object -call4 (fn, arg1, arg2, arg3, arg4) - Lisp_Object fn, arg1, arg2, arg3, arg4; +call4 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, + Lisp_Object arg4) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[5]; args[0] = fn; args[1] = arg1; @@ -2879,21 +2836,15 @@ call4 (fn, arg1, arg2, arg3, arg4) GCPRO1 (args[0]); gcpro1.nvars = 5; RETURN_UNGCPRO (Ffuncall (5, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 5; - RETURN_UNGCPRO (Ffuncall (5, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */ /* ARGSUSED */ Lisp_Object -call5 (fn, arg1, arg2, arg3, arg4, arg5) - Lisp_Object fn, arg1, arg2, arg3, arg4, arg5; +call5 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, + Lisp_Object arg4, Lisp_Object arg5) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[6]; args[0] = fn; args[1] = arg1; @@ -2904,21 +2855,15 @@ call5 (fn, arg1, arg2, arg3, arg4, arg5) GCPRO1 (args[0]); gcpro1.nvars = 6; RETURN_UNGCPRO (Ffuncall (6, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 6; - RETURN_UNGCPRO (Ffuncall (6, &fn)); -#endif /* not NO_ARG_ARRAY */ } /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */ /* ARGSUSED */ Lisp_Object -call6 (fn, arg1, arg2, arg3, arg4, arg5, arg6) - Lisp_Object fn, arg1, arg2, arg3, arg4, arg5, arg6; +call6 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, + Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6) { struct gcpro gcpro1; -#ifdef NO_ARG_ARRAY Lisp_Object args[7]; args[0] = fn; args[1] = arg1; @@ -2930,11 +2875,27 @@ call6 (fn, arg1, arg2, arg3, arg4, arg5, arg6) GCPRO1 (args[0]); gcpro1.nvars = 7; RETURN_UNGCPRO (Ffuncall (7, args)); -#else /* not NO_ARG_ARRAY */ - GCPRO1 (fn); - gcpro1.nvars = 7; - RETURN_UNGCPRO (Ffuncall (7, &fn)); -#endif /* not NO_ARG_ARRAY */ +} + +/* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7 */ +/* ARGSUSED */ +Lisp_Object +call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, + Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7) +{ + struct gcpro gcpro1; + Lisp_Object args[8]; + args[0] = fn; + args[1] = arg1; + args[2] = arg2; + args[3] = arg3; + args[4] = arg4; + args[5] = arg5; + args[6] = arg6; + args[7] = arg7; + GCPRO1 (args[0]); + gcpro1.nvars = 8; + RETURN_UNGCPRO (Ffuncall (8, args)); } /* The caller should GCPRO all the elements of ARGS. */ @@ -2944,9 +2905,7 @@ DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y). usage: (funcall FUNCTION &rest ARGUMENTS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object fun, original_fun; Lisp_Object funcar; @@ -3009,14 +2968,14 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) if (XSUBR (fun)->max_args == MANY) { - val = (*XSUBR (fun)->function) (numargs, args + 1); + val = (XSUBR (fun)->function.aMANY) (numargs, args + 1); goto done; } if (XSUBR (fun)->max_args > numargs) { internal_args = (Lisp_Object *) alloca (XSUBR (fun)->max_args * sizeof (Lisp_Object)); - bcopy (args + 1, internal_args, numargs * sizeof (Lisp_Object)); + memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object)); for (i = numargs; i < XSUBR (fun)->max_args; i++) internal_args[i] = Qnil; } @@ -3025,44 +2984,44 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) switch (XSUBR (fun)->max_args) { case 0: - val = (*XSUBR (fun)->function) (); + val = (XSUBR (fun)->function.a0) (); goto done; case 1: - val = (*XSUBR (fun)->function) (internal_args[0]); + val = (XSUBR (fun)->function.a1) (internal_args[0]); goto done; case 2: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1]); + val = (XSUBR (fun)->function.a2) (internal_args[0], internal_args[1]); goto done; case 3: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2]); + val = (XSUBR (fun)->function.a3) (internal_args[0], internal_args[1], + internal_args[2]); goto done; case 4: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2], internal_args[3]); + val = (XSUBR (fun)->function.a4) (internal_args[0], internal_args[1], + internal_args[2], internal_args[3]); goto done; case 5: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2], internal_args[3], - internal_args[4]); + val = (XSUBR (fun)->function.a5) (internal_args[0], internal_args[1], + internal_args[2], internal_args[3], + internal_args[4]); goto done; case 6: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2], internal_args[3], - internal_args[4], internal_args[5]); + val = (XSUBR (fun)->function.a6) (internal_args[0], internal_args[1], + internal_args[2], internal_args[3], + internal_args[4], internal_args[5]); goto done; case 7: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2], internal_args[3], - internal_args[4], internal_args[5], - internal_args[6]); + val = (XSUBR (fun)->function.a7) (internal_args[0], internal_args[1], + internal_args[2], internal_args[3], + internal_args[4], internal_args[5], + internal_args[6]); goto done; case 8: - val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], - internal_args[2], internal_args[3], - internal_args[4], internal_args[5], - internal_args[6], internal_args[7]); + val = (XSUBR (fun)->function.a8) (internal_args[0], internal_args[1], + internal_args[2], internal_args[3], + internal_args[4], internal_args[5], + internal_args[6], internal_args[7]); goto done; default: @@ -3105,9 +3064,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) } Lisp_Object -apply_lambda (fun, args, eval_flag) - Lisp_Object fun, args; - int eval_flag; +apply_lambda (Lisp_Object fun, Lisp_Object args, int eval_flag) { Lisp_Object args_left; Lisp_Object numargs; @@ -3156,10 +3113,7 @@ apply_lambda (fun, args, eval_flag) FUN must be either a lambda-expression or a compiled-code object. */ static Lisp_Object -funcall_lambda (fun, nargs, arg_vector) - Lisp_Object fun; - int nargs; - register Lisp_Object *arg_vector; +funcall_lambda (Lisp_Object fun, int nargs, register Lisp_Object *arg_vector) { Lisp_Object val, syms_left, next; int count = SPECPDL_INDEX (); @@ -3228,8 +3182,7 @@ funcall_lambda (fun, nargs, arg_vector) DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, 1, 1, 0, doc: /* If byte-compiled OBJECT is lazy-loaded, fetch it now. */) - (object) - Lisp_Object object; + (Lisp_Object object) { Lisp_Object tem; @@ -3251,7 +3204,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, } void -grow_specpdl () +grow_specpdl (void) { register int count = SPECPDL_INDEX (); if (specpdl_size >= max_specpdl_size) @@ -3268,89 +3221,120 @@ grow_specpdl () specpdl_ptr = specpdl + count; } +/* specpdl_ptr->symbol is a field which describes which variable is + let-bound, so it can be properly undone when we unbind_to. + It can have the following two shapes: + - SYMBOL : if it's a plain symbol, it means that we have let-bound + a symbol that is not buffer-local (at least at the time + the let binding started). Note also that it should not be + aliased (i.e. when let-binding V1 that's aliased to V2, we want + to record V2 here). + - (SYMBOL WHERE . BUFFER) : this means that it is a let-binding for + variable SYMBOL which can be buffer-local. WHERE tells us + which buffer is affected (or nil if the let-binding affects the + global value of the variable) and BUFFER tells us which buffer was + current (i.e. if WHERE is non-nil, then BUFFER==WHERE, otherwise + BUFFER did not yet have a buffer-local value). */ + void -specbind (symbol, value) - Lisp_Object symbol, value; +specbind (Lisp_Object symbol, Lisp_Object value) { - Lisp_Object valcontents; + struct Lisp_Symbol *sym; + + eassert (!handling_signal); CHECK_SYMBOL (symbol); + sym = XSYMBOL (symbol); if (specpdl_ptr == specpdl + specpdl_size) grow_specpdl (); - /* The most common case is that of a non-constant symbol with a - trivial value. Make that as fast as we can. */ - valcontents = SYMBOL_VALUE (symbol); - if (!MISCP (valcontents) && !SYMBOL_CONSTANT_P (symbol)) + start: + switch (sym->redirect) { + case SYMBOL_VARALIAS: + sym = indirect_variable (sym); XSETSYMBOL (symbol, sym); goto start; + case SYMBOL_PLAINVAL: + /* The most common case is that of a non-constant symbol with a + trivial value. Make that as fast as we can. */ specpdl_ptr->symbol = symbol; - specpdl_ptr->old_value = valcontents; + specpdl_ptr->old_value = SYMBOL_VAL (sym); specpdl_ptr->func = NULL; ++specpdl_ptr; - SET_SYMBOL_VALUE (symbol, value); - } - else - { - Lisp_Object ovalue = find_symbol_value (symbol); - specpdl_ptr->func = 0; - specpdl_ptr->old_value = ovalue; - - valcontents = XSYMBOL (symbol)->value; - - if (BUFFER_LOCAL_VALUEP (valcontents) - || BUFFER_OBJFWDP (valcontents)) - { - Lisp_Object where, current_buffer; - - current_buffer = Fcurrent_buffer (); - - /* For a local variable, record both the symbol and which - buffer's or frame's value we are saving. */ - if (!NILP (Flocal_variable_p (symbol, Qnil))) - where = current_buffer; - else if (BUFFER_LOCAL_VALUEP (valcontents) - && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) - where = XBUFFER_LOCAL_VALUE (valcontents)->frame; - else - where = Qnil; - - /* We're not using the `unused' slot in the specbinding - structure because this would mean we have to do more - work for simple variables. */ - specpdl_ptr->symbol = Fcons (symbol, Fcons (where, current_buffer)); - - /* If SYMBOL is a per-buffer variable which doesn't have a - buffer-local value here, make the `let' change the global - value by changing the value of SYMBOL in all buffers not - having their own value. This is consistent with what - happens with other buffer-local variables. */ - if (NILP (where) - && BUFFER_OBJFWDP (valcontents)) - { - ++specpdl_ptr; - Fset_default (symbol, value); - return; - } - } + if (!sym->constant) + SET_SYMBOL_VAL (sym, value); else - specpdl_ptr->symbol = symbol; - - specpdl_ptr++; - /* We used to do - if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) - store_symval_forwarding (symbol, ovalue, value, NULL); - else - but ovalue comes from find_symbol_value which should never return - such an internal value. */ - eassert (!(BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue))); - set_internal (symbol, value, 0, 1); + set_internal (symbol, value, Qnil, 1); + break; + case SYMBOL_LOCALIZED: + if (SYMBOL_BLV (sym)->frame_local) + error ("Frame-local vars cannot be let-bound"); + case SYMBOL_FORWARDED: + { + Lisp_Object ovalue = find_symbol_value (symbol); + specpdl_ptr->func = 0; + specpdl_ptr->old_value = ovalue; + + eassert (sym->redirect != SYMBOL_LOCALIZED + || (EQ (SYMBOL_BLV (sym)->where, + SYMBOL_BLV (sym)->frame_local ? + Fselected_frame () : Fcurrent_buffer ()))); + + if (sym->redirect == SYMBOL_LOCALIZED + || BUFFER_OBJFWDP (SYMBOL_FWD (sym))) + { + Lisp_Object where, cur_buf = Fcurrent_buffer (); + + /* For a local variable, record both the symbol and which + buffer's or frame's value we are saving. */ + if (!NILP (Flocal_variable_p (symbol, Qnil))) + { + eassert (sym->redirect != SYMBOL_LOCALIZED + || (BLV_FOUND (SYMBOL_BLV (sym)) + && EQ (cur_buf, SYMBOL_BLV (sym)->where))); + where = cur_buf; + } + else if (sym->redirect == SYMBOL_LOCALIZED + && BLV_FOUND (SYMBOL_BLV (sym))) + where = SYMBOL_BLV (sym)->where; + else + where = Qnil; + + /* We're not using the `unused' slot in the specbinding + structure because this would mean we have to do more + work for simple variables. */ + /* FIXME: The third value `current_buffer' is only used in + let_shadows_buffer_binding_p which is itself only used + in set_internal for local_if_set. */ + eassert (NILP (where) || EQ (where, cur_buf)); + specpdl_ptr->symbol = Fcons (symbol, Fcons (where, cur_buf)); + + /* If SYMBOL is a per-buffer variable which doesn't have a + buffer-local value here, make the `let' change the global + value by changing the value of SYMBOL in all buffers not + having their own value. This is consistent with what + happens with other buffer-local variables. */ + if (NILP (where) + && sym->redirect == SYMBOL_FORWARDED) + { + eassert (BUFFER_OBJFWDP (SYMBOL_FWD (sym))); + ++specpdl_ptr; + Fset_default (symbol, value); + return; + } + } + else + specpdl_ptr->symbol = symbol; + + specpdl_ptr++; + set_internal (symbol, value, Qnil, 1); + break; + } + default: abort (); } } void -record_unwind_protect (function, arg) - Lisp_Object (*function) P_ ((Lisp_Object)); - Lisp_Object arg; +record_unwind_protect (Lisp_Object (*function) (Lisp_Object), Lisp_Object arg) { eassert (!handling_signal); @@ -3363,9 +3347,7 @@ record_unwind_protect (function, arg) } Lisp_Object -unbind_to (count, value) - int count; - Lisp_Object value; +unbind_to (int count, Lisp_Object value) { Lisp_Object quitf = Vquit_flag; struct gcpro gcpro1, gcpro2; @@ -3392,7 +3374,7 @@ unbind_to (count, value) bound a variable that had a buffer-local or frame-local binding. WHERE nil means that the variable had the default value when it was bound. CURRENT-BUFFER is the buffer that - was current when the variable was bound. */ + was current when the variable was bound. */ else if (CONSP (this_binding.symbol)) { Lisp_Object symbol, where; @@ -3402,21 +3384,23 @@ unbind_to (count, value) if (NILP (where)) Fset_default (symbol, this_binding.old_value); - else if (BUFFERP (where)) - set_internal (symbol, this_binding.old_value, XBUFFER (where), 1); - else - set_internal (symbol, this_binding.old_value, NULL, 1); + /* If `where' is non-nil, reset the value in the appropriate + local binding, but only if that binding still exists. */ + else if (BUFFERP (where) + ? !NILP (Flocal_variable_p (symbol, where)) + : !NILP (Fassq (symbol, XFRAME (where)->param_alist))) + set_internal (symbol, this_binding.old_value, where, 1); } + /* If variable has a trivial value (no forwarding), we can + just set it. No need to check for constant symbols here, + since that was already done by specbind. */ + else if (XSYMBOL (this_binding.symbol)->redirect == SYMBOL_PLAINVAL) + SET_SYMBOL_VAL (XSYMBOL (this_binding.symbol), + this_binding.old_value); else - { - /* If variable has a trivial value (no forwarding), we can - just set it. No need to check for constant symbols here, - since that was already done by specbind. */ - if (!MISCP (SYMBOL_VALUE (this_binding.symbol))) - SET_SYMBOL_VALUE (this_binding.symbol, this_binding.old_value); - else - set_internal (this_binding.symbol, this_binding.old_value, 0, 1); - } + /* NOTE: we only ever come here if make_local_foo was used for + the first time on this var within this let. */ + Fset_default (this_binding.symbol, this_binding.old_value); } if (NILP (Vquit_flag) && !NILP (quitf)) @@ -3429,8 +3413,7 @@ unbind_to (count, value) DEFUN ("backtrace-debug", Fbacktrace_debug, Sbacktrace_debug, 2, 2, 0, doc: /* Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG. The debugger is entered when that frame exits, if the flag is non-nil. */) - (level, flag) - Lisp_Object level, flag; + (Lisp_Object level, Lisp_Object flag) { register struct backtrace *backlist = backtrace_list; register int i; @@ -3451,16 +3434,17 @@ The debugger is entered when that frame exits, if the flag is non-nil. */) DEFUN ("backtrace", Fbacktrace, Sbacktrace, 0, 0, "", doc: /* Print a trace of Lisp function calls currently active. Output stream used is value of `standard-output'. */) - () + (void) { register struct backtrace *backlist = backtrace_list; register int i; Lisp_Object tail; Lisp_Object tem; - extern Lisp_Object Vprint_level; struct gcpro gcpro1; + Lisp_Object old_print_level = Vprint_level; - XSETFASTINT (Vprint_level, 3); + if (NILP (Vprint_level)) + XSETFASTINT (Vprint_level, 8); tail = Qnil; GCPRO1 (tail); @@ -3501,7 +3485,7 @@ Output stream used is value of `standard-output'. */) backlist = backlist->next; } - Vprint_level = Qnil; + Vprint_level = old_print_level; UNGCPRO; return Qnil; } @@ -3516,8 +3500,7 @@ A &rest arg is represented as the tail of the list ARG-VALUES. FUNCTION is whatever was supplied as car of evaluated list, or a lambda expression for macro calls. If NFRAMES is more than the number of frames, the value is nil. */) - (nframes) - Lisp_Object nframes; + (Lisp_Object nframes) { register struct backtrace *backlist = backtrace_list; register int i; @@ -3546,7 +3529,7 @@ If NFRAMES is more than the number of frames, the value is nil. */) void -mark_backtrace () +mark_backtrace (void) { register struct backtrace *backlist; register int i; @@ -3565,7 +3548,7 @@ mark_backtrace () } void -syms_of_eval () +syms_of_eval (void) { DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, doc: /* *Limit on number of Lisp variable bindings and `unwind-protect's. diff --git a/src/fileio.c b/src/fileio.c index 440a726b26b..36b6cc3ca8b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1,7 +1,8 @@ /* File IO for GNU Emacs. - Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,11 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <limits.h> - -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif - #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> @@ -53,10 +50,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <ctype.h> #include <errno.h> -#ifndef vax11c -#ifndef USE_CRT_DLL -extern int errno; -#endif +#ifdef HAVE_LIBSELINUX +#include <selinux/selinux.h> +#include <selinux/context.h> #endif #include "lisp.h" @@ -72,24 +68,16 @@ extern int errno; #ifdef WINDOWSNT #define NOMINMAX 1 #include <windows.h> -#include <stdlib.h> #include <fcntl.h> #endif /* not WINDOWSNT */ #ifdef MSDOS #include "msdos.h" #include <sys/param.h> -#if __DJGPP__ >= 2 #include <fcntl.h> -#include <string.h> -#endif #endif #ifdef DOS_NT -#define CORRECT_DIR_SEPS(s) \ - do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ - else unixtodos_filename (s); \ - } while (0) /* On Windows, drive letters must be alphabetic - on DOS, the Netware redirector allows the six letters between 'Z' and 'a' as well. */ #ifdef MSDOS @@ -111,16 +99,6 @@ extern int errno; #endif #include "commands.h" -extern int use_dialog_box; -extern int use_file_dialog; - -#ifndef O_WRONLY -#define O_WRONLY 1 -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif #ifndef S_ISLNK # define lstat stat @@ -197,10 +175,6 @@ Lisp_Object Vauto_save_visited_file_name; /* Whether or not to continue auto-saving after a large deletion. */ Lisp_Object Vauto_save_include_big_deletions; -/* On NT, specifies the directory separator character, used (eg.) when - expanding file names. This can be bound to / or \. */ -Lisp_Object Vdirectory_sep_char; - #ifdef HAVE_FSYNC /* Nonzero means skip the call to fsync in Fwrite-region. */ int write_region_inhibit_fsync; @@ -221,16 +195,10 @@ Lisp_Object Qcopy_directory; /* Lisp function for recursively deleting directories. */ Lisp_Object Qdelete_directory; -extern Lisp_Object Vuser_login_name; - #ifdef WINDOWSNT extern Lisp_Object Vw32_get_true_file_attributes; #endif -extern int minibuf_level; - -extern int minibuffer_auto_raise; - /* These variables describe handlers that have "already" had a chance to handle the current operation. @@ -247,15 +215,13 @@ Lisp_Object Qfile_name_history; Lisp_Object Qcar_less_than_car; -static int a_write P_ ((int, Lisp_Object, int, int, - Lisp_Object *, struct coding_system *)); -static int e_write P_ ((int, Lisp_Object, int, int, struct coding_system *)); +static int a_write (int, Lisp_Object, int, int, + Lisp_Object *, struct coding_system *); +static int e_write (int, Lisp_Object, int, int, struct coding_system *); void -report_file_error (string, data) - const char *string; - Lisp_Object data; +report_file_error (const char *string, Lisp_Object data) { Lisp_Object errstring; int errorno = errno; @@ -293,8 +259,7 @@ report_file_error (string, data) } Lisp_Object -close_file_unwind (fd) - Lisp_Object fd; +close_file_unwind (Lisp_Object fd) { emacs_close (XFASTINT (fd)); return Qnil; @@ -303,8 +268,7 @@ close_file_unwind (fd) /* Restore point, having saved it as a marker. */ Lisp_Object -restore_point_unwind (location) - Lisp_Object location; +restore_point_unwind (Lisp_Object location) { Fgoto_char (location); Fset_marker (location, Qnil, Qnil); @@ -339,6 +303,8 @@ Lisp_Object Qfile_accessible_directory_p; Lisp_Object Qfile_modes; Lisp_Object Qset_file_modes; Lisp_Object Qset_file_times; +Lisp_Object Qfile_selinux_context; +Lisp_Object Qset_file_selinux_context; Lisp_Object Qfile_newer_than_file_p; Lisp_Object Qinsert_file_contents; Lisp_Object Qwrite_region; @@ -355,8 +321,7 @@ If OPERATION equals `inhibit-file-name-operation', then we ignore any handlers that are members of `inhibit-file-name-handlers', but we still do run any other handlers. This lets handlers use the standard functions without calling themselves recursively. */) - (filename, operation) - Lisp_Object filename, operation; + (Lisp_Object filename, Lisp_Object operation) { /* This function must not munge the match data. */ Lisp_Object chain, inhibited_handlers, result; @@ -412,8 +377,7 @@ DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, Return nil if FILENAME does not include a directory. Otherwise return a directory name. Given a Unix syntax file name, returns a string ending in slash. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { #ifndef DOS_NT register const unsigned char *beg; @@ -434,7 +398,7 @@ Given a Unix syntax file name, returns a string ending in slash. */) filename = FILE_SYSTEM_CASE (filename); #ifdef DOS_NT beg = (unsigned char *) alloca (SBYTES (filename) + 1); - bcopy (SDATA (filename), beg, SBYTES (filename) + 1); + memcpy (beg, SDATA (filename), SBYTES (filename) + 1); #else beg = SDATA (filename); #endif @@ -475,7 +439,7 @@ Given a Unix syntax file name, returns a string ending in slash. */) p = beg + strlen (beg); } } - CORRECT_DIR_SEPS (beg); + dostounix_filename (beg); #endif /* DOS_NT */ return make_specified_string (beg, -1, p - beg, STRING_MULTIBYTE (filename)); @@ -487,8 +451,7 @@ DEFUN ("file-name-nondirectory", Ffile_name_nondirectory, For example, in a Unix-syntax file name, this is everything after the last slash, or the entire name if it contains no slash. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { register const unsigned char *beg, *p, *end; Lisp_Object handler; @@ -528,8 +491,7 @@ If FILENAME refers to a file which is not accessible from a local process, then this should return nil. The `call-process' and `start-process' functions use this function to get a current directory to run processes in. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object handler; @@ -544,8 +506,7 @@ get a current directory to run processes in. */) char * -file_name_as_directory (out, in) - char *out, *in; +file_name_as_directory (char *out, char *in) { int size = strlen (in) - 1; @@ -562,12 +523,11 @@ file_name_as_directory (out, in) /* For Unix syntax, Append a slash if necessary */ if (!IS_DIRECTORY_SEP (out[size])) { - /* Cannot use DIRECTORY_SEP, which could have any value */ - out[size + 1] = '/'; + out[size + 1] = DIRECTORY_SEP; out[size + 2] = '\0'; } #ifdef DOS_NT - CORRECT_DIR_SEPS (out); + dostounix_filename (out); #endif return out; } @@ -580,8 +540,7 @@ a directory is different from its name as a file. The result can be used as the value of `default-directory' or passed as second argument to `expand-file-name'. For a Unix-syntax file name, just appends a slash. */) - (file) - Lisp_Object file; + (Lisp_Object file) { char *buf; Lisp_Object handler; @@ -610,8 +569,7 @@ For a Unix-syntax file name, just appends a slash. */) */ int -directory_file_name (src, dst) - char *src, *dst; +directory_file_name (char *src, char *dst) { long slen; @@ -628,7 +586,7 @@ directory_file_name (src, dst) ) dst[slen - 1] = 0; #ifdef DOS_NT - CORRECT_DIR_SEPS (dst); + dostounix_filename (dst); #endif return 1; } @@ -640,8 +598,7 @@ This is the name of the file that holds the data for the directory DIRECTORY. This operation exists because a directory is also a file, but its name as a directory is different from its name as a file. In Unix-syntax, this function just removes the final slash. */) - (directory) - Lisp_Object directory; + (Lisp_Object directory) { char *buf; Lisp_Object handler; @@ -694,9 +651,7 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p; generated. */ Lisp_Object -make_temp_name (prefix, base64_p) - Lisp_Object prefix; - int base64_p; +make_temp_name (Lisp_Object prefix, int base64_p) { Lisp_Object val; int len, clen; @@ -739,10 +694,10 @@ make_temp_name (prefix, base64_p) if (!STRING_MULTIBYTE (prefix)) STRING_SET_UNIBYTE (val); data = SDATA (val); - bcopy(SDATA (prefix), data, len); + memcpy (data, SDATA (prefix), len); p = data + len; - bcopy (pidbuf, p, pidlen); + memcpy (p, pidbuf, pidlen); p += pidlen; /* Here we try to minimize useless stat'ing when this function is @@ -815,8 +770,7 @@ probably use `make-temp-file' instead, except in three circumstances: * If you are creating the file in the user's home directory. * If you are creating a directory rather than an ordinary file. * If you are taking special precautions as `make-temp-file' does. */) - (prefix) - Lisp_Object prefix; + (Lisp_Object prefix) { return make_temp_name (prefix, 0); } @@ -841,8 +795,7 @@ non-intuitive results for the root directory; for instance, \(expand-file-name ".." "/") returns "/..". For this reason, use (directory-file-name (file-name-directory dirname)) to traverse a filesystem tree, not (expand-file-name ".." dirname). */) - (name, default_directory) - Lisp_Object name, default_directory; + (Lisp_Object name, Lisp_Object default_directory) { /* These point to SDATA and need to be careful with string-relocation during GC (via DECODE_FILE). */ @@ -884,8 +837,6 @@ filesystem tree, not (expand-file-name ".." dirname). */) To avoid this, we set default_directory to the root of the current drive. */ - extern char *emacs_root_dir (void); - default_directory = build_string (emacs_root_dir ()); #else default_directory = build_string ("/"); @@ -953,7 +904,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ nm = (unsigned char *) alloca (SBYTES (name) + 1); - bcopy (SDATA (name), nm, SBYTES (name) + 1); + memcpy (nm, SDATA (name), SBYTES (name) + 1); #ifdef DOS_NT /* Note if special escape prefix is present, but remove for now. */ @@ -1033,10 +984,9 @@ filesystem tree, not (expand-file-name ".." dirname). */) if (!lose) { #ifdef DOS_NT - /* Make sure directories are all separated with / or \ as - desired, but avoid allocation of a new string when not - required. */ - CORRECT_DIR_SEPS (nm); + /* Make sure directories are all separated with /, but + avoid allocation of a new string when not required. */ + dostounix_filename (nm); #ifdef WINDOWSNT if (IS_DIRECTORY_SEP (nm[1])) { @@ -1108,7 +1058,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) unsigned char *o, *p; for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++); o = alloca (p - nm + 1); - bcopy ((char *) nm, o, p - nm); + memcpy (o, nm, p - nm); o [p - nm] = 0; BLOCK_INPUT; @@ -1259,7 +1209,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) ) { unsigned char *temp = (unsigned char *) alloca (length); - bcopy (newdir, temp, length - 1); + memcpy (temp, newdir, length - 1); temp[length - 1] = 0; newdir = temp; } @@ -1382,7 +1332,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) target[0] = '/'; target[1] = ':'; } - CORRECT_DIR_SEPS (target); + dostounix_filename (target); #endif /* DOS_NT */ result = make_specified_string (target, -1, o - target, multibyte); @@ -1478,11 +1428,11 @@ See also the function `substitute-in-file-name'.") /* Get past ~ to user */ unsigned char *user = nm + 1; /* Find end of name. */ - unsigned char *ptr = (unsigned char *) index (user, '/'); + unsigned char *ptr = (unsigned char *) strchr (user, '/'); int len = ptr ? ptr - user : strlen (user); /* Copy the user name into temp storage. */ o = (unsigned char *) alloca (len + 1); - bcopy ((char *) user, o, len); + memcpy (o, user, len); o[len] = 0; /* Look up the user name. */ @@ -1565,8 +1515,7 @@ See also the function `substitute-in-file-name'.") /* If /~ or // appears, discard everything through first slash. */ static int -file_name_absolute_p (filename) - const unsigned char *filename; +file_name_absolute_p (const unsigned char *filename) { return (IS_DIRECTORY_SEP (*filename) || *filename == '~' @@ -1578,8 +1527,7 @@ file_name_absolute_p (filename) } static unsigned char * -search_embedded_absfilename (nm, endp) - unsigned char *nm, *endp; +search_embedded_absfilename (unsigned char *nm, unsigned char *endp) { unsigned char *p, *s; @@ -1600,7 +1548,7 @@ search_embedded_absfilename (nm, endp) { unsigned char *o = alloca (s - p + 1); struct passwd *pw; - bcopy (p, o, s - p); + memcpy (o, p, s - p); o [s - p] = 0; /* If we have ~user and `user' exists, discard @@ -1630,8 +1578,7 @@ the entire variable name in braces. If `/~' appears, all of FILENAME through that `/' is discarded. If `//' appears, everything up to and including the first of those `/' is discarded. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { unsigned char *nm; @@ -1657,10 +1604,10 @@ those `/' is discarded. */) decode of environment variables, causing the original Lisp_String data to be relocated. */ nm = (unsigned char *) alloca (SBYTES (filename) + 1); - bcopy (SDATA (filename), nm, SBYTES (filename) + 1); + memcpy (nm, SDATA (filename), SBYTES (filename) + 1); #ifdef DOS_NT - CORRECT_DIR_SEPS (nm); + dostounix_filename (nm); substituted = (strcmp (nm, SDATA (filename)) != 0); #endif endp = nm + SBYTES (filename); @@ -1830,8 +1777,7 @@ those `/' is discarded. */) (directory-file-name (expand-file-name FOO)). */ Lisp_Object -expand_and_dir_to_file (filename, defdir) - Lisp_Object filename, defdir; +expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) { register Lisp_Object absname; @@ -1860,12 +1806,7 @@ expand_and_dir_to_file (filename, defdir) If QUICK is nonzero, we ask for y or n, not yes or no. */ void -barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick) - Lisp_Object absname; - unsigned char *querystring; - int interactive; - struct stat *statptr; - int quick; +barf_or_query_if_file_exists (Lisp_Object absname, const unsigned char *querystring, int interactive, struct stat *statptr, int quick) { register Lisp_Object tem, encoded_filename; struct stat statbuf; @@ -1884,7 +1825,7 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick) tem = format2 ("File %s already exists; %s anyway? ", absname, build_string (querystring)); if (quick) - tem = Fy_or_n_p (tem); + tem = call1 (intern ("y-or-n-p"), tem); else tem = do_yes_or_no_p (tem); UNGCPRO; @@ -1902,7 +1843,7 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick) return; } -DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 5, +DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 6, "fCopy file: \nGCopy %s to file: \np\nP", doc: /* Copy FILE to NEWNAME. Both args must be strings. If NEWNAME names a directory, copy FILE there. @@ -1924,10 +1865,11 @@ last-modified time as the old one. (This works on only some systems.) A prefix arg makes KEEP-TIME non-nil. If PRESERVE-UID-GID is non-nil, we try to transfer the -uid and gid of FILE to NEWNAME. */) - (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid) - Lisp_Object file, newname, ok_if_already_exists, keep_time; - Lisp_Object preserve_uid_gid; +uid and gid of FILE to NEWNAME. + +If PRESERVE-SELINUX-CONTEXT is non-nil and SELinux is enabled +on the system, we copy the SELinux context of FILE to NEWNAME. */) + (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context) { int ifd, ofd, n; char buf[16 * 1024]; @@ -1937,6 +1879,10 @@ uid and gid of FILE to NEWNAME. */) int count = SPECPDL_INDEX (); int input_file_statable_p; Lisp_Object encoded_file, encoded_newname; +#if HAVE_LIBSELINUX + security_context_t con; + int fail, conlength = 0; +#endif encoded_file = encoded_newname = Qnil; GCPRO4 (file, newname, encoded_file, encoded_newname); @@ -1957,8 +1903,9 @@ uid and gid of FILE to NEWNAME. */) if (NILP (handler)) handler = Ffind_file_name_handler (newname, Qcopy_file); if (!NILP (handler)) - RETURN_UNGCPRO (call6 (handler, Qcopy_file, file, newname, - ok_if_already_exists, keep_time, preserve_uid_gid)); + RETURN_UNGCPRO (call7 (handler, Qcopy_file, file, newname, + ok_if_already_exists, keep_time, preserve_uid_gid, + preserve_selinux_context)); encoded_file = ENCODE_FILE (file); encoded_newname = ENCODE_FILE (newname); @@ -2012,7 +1959,15 @@ uid and gid of FILE to NEWNAME. */) copyable by us. */ input_file_statable_p = (fstat (ifd, &st) >= 0); -#if !defined (MSDOS) || __DJGPP__ > 1 +#if HAVE_LIBSELINUX + if (!NILP (preserve_selinux_context) && is_selinux_enabled ()) + { + conlength = fgetfilecon (ifd, &con); + if (conlength == -1) + report_file_error ("Doing fgetfilecon", Fcons (file, Qnil)); + } +#endif + if (out_st.st_mode != 0 && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino) { @@ -2020,7 +1975,6 @@ uid and gid of FILE to NEWNAME. */) report_file_error ("Input and output files are the same", Fcons (file, Fcons (newname, Qnil))); } -#endif #if defined (S_ISREG) && defined (S_ISLNK) if (input_file_statable_p) @@ -2071,6 +2025,18 @@ uid and gid of FILE to NEWNAME. */) } #endif /* not MSDOS */ +#if HAVE_LIBSELINUX + if (conlength > 0) + { + /* Set the modified context back to the file. */ + fail = fsetfilecon (ofd, con); + if (fail) + report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); + + freecon (con); + } +#endif + /* Closing the output clobbers the file times on some systems. */ if (emacs_close (ofd) < 0) report_file_error ("I/O error", Fcons (newname, Qnil)); @@ -2091,7 +2057,7 @@ uid and gid of FILE to NEWNAME. */) emacs_close (ifd); -#if defined (__DJGPP__) && __DJGPP__ > 1 +#ifdef MSDOS if (input_file_statable_p) { /* In DJGPP v2.0 and later, fstat usually returns true file mode bits, @@ -2101,7 +2067,7 @@ uid and gid of FILE to NEWNAME. */) if ((_djstat_flags & _STFAIL_WRITEBIT) == 0) chmod (SDATA (encoded_newname), st.st_mode & 07777); } -#endif /* DJGPP version 2 or newer */ +#endif /* MSDOS */ #endif /* not WINDOWSNT */ /* Discard the unwind protects. */ @@ -2114,8 +2080,7 @@ uid and gid of FILE to NEWNAME. */) DEFUN ("make-directory-internal", Fmake_directory_internal, Smake_directory_internal, 1, 1, 0, doc: /* Create a new directory named DIRECTORY. */) - (directory) - Lisp_Object directory; + (Lisp_Object directory) { const unsigned char *dir; Lisp_Object handler; @@ -2145,8 +2110,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal, DEFUN ("delete-directory-internal", Fdelete_directory_internal, Sdelete_directory_internal, 1, 1, 0, doc: /* Delete the directory named DIRECTORY. Does not follow symlinks. */) - (directory) - Lisp_Object directory; + (Lisp_Object directory) { const unsigned char *dir; Lisp_Object handler; @@ -2154,12 +2118,7 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, CHECK_STRING (directory); directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); - - if (delete_by_moving_to_trash) - return call1 (Qmove_file_to_trash, directory); - encoded_dir = ENCODE_FILE (directory); - dir = SDATA (encoded_dir); if (rmdir (dir) != 0) @@ -2168,11 +2127,20 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal, return Qnil; } -DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 1, "fDelete file: ", +DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, + "(list (read-file-name \ + (if (and delete-by-moving-to-trash (null current-prefix-arg)) \ + \"Move file to trash: \" \"Delete file: \") \ + nil default-directory (confirm-nonexistent-file-or-buffer)) \ + (null current-prefix-arg))", doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. -If file has multiple names, it continues to exist with the other names. */) - (filename) - Lisp_Object filename; +If file has multiple names, it continues to exist with the other names. +TRASH non-nil means to trash the file instead of deleting, provided +`delete-by-moving-to-trash' is non-nil. + +When called interactively, TRASH is t if no prefix argument is given. +With a prefix argument, TRASH is nil. */) + (Lisp_Object filename, Lisp_Object trash) { Lisp_Object handler; Lisp_Object encoded_file; @@ -2189,9 +2157,9 @@ If file has multiple names, it continues to exist with the other names. */) handler = Ffind_file_name_handler (filename, Qdelete_file); if (!NILP (handler)) - return call2 (handler, Qdelete_file, filename); + return call3 (handler, Qdelete_file, filename, trash); - if (delete_by_moving_to_trash) + if (delete_by_moving_to_trash && !NILP (trash)) return call1 (Qmove_file_to_trash, filename); encoded_file = ENCODE_FILE (filename); @@ -2202,20 +2170,20 @@ If file has multiple names, it continues to exist with the other names. */) } static Lisp_Object -internal_delete_file_1 (ignore) - Lisp_Object ignore; +internal_delete_file_1 (Lisp_Object ignore) { return Qt; } -/* Delete file FILENAME, returning 1 if successful and 0 if failed. */ +/* Delete file FILENAME, returning 1 if successful and 0 if failed. + This ignores `delete-by-moving-to-trash'. */ int -internal_delete_file (filename) - Lisp_Object filename; +internal_delete_file (Lisp_Object filename) { Lisp_Object tem; - tem = internal_condition_case_1 (Fdelete_file, filename, + + tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, Qt, internal_delete_file_1); return NILP (tem); } @@ -2228,8 +2196,7 @@ Signals a `file-already-exists' error if a file NEWNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. A number as third arg means request confirmation if NEWNAME already exists. This is what happens in interactive use with M-x. */) - (file, newname, ok_if_already_exists) - Lisp_Object file, newname, ok_if_already_exists; + (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists) { Lisp_Object handler; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; @@ -2297,7 +2264,7 @@ This is what happens in interactive use with M-x. */) have copy-file prompt again. */ Fcopy_file (file, newname, NILP (ok_if_already_exists) ? Qnil : Qt, - Qt, Qt); + Qt, Qt, Qt); count = SPECPDL_INDEX (); specbind (Qdelete_by_moving_to_trash, Qnil); @@ -2309,7 +2276,7 @@ This is what happens in interactive use with M-x. */) ) call2 (Qdelete_directory, file, Qt); else - Fdelete_file (file); + Fdelete_file (file, Qnil); unbind_to (count, Qnil); } else @@ -2326,8 +2293,7 @@ Signals a `file-already-exists' error if a file NEWNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. A number as third arg means request confirmation if NEWNAME already exists. This is what happens in interactive use with M-x. */) - (file, newname, ok_if_already_exists) - Lisp_Object file, newname, ok_if_already_exists; + (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists) { Lisp_Object handler; Lisp_Object encoded_file, encoded_newname; @@ -2382,8 +2348,7 @@ Signals a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. A number as third arg means request confirmation if LINKNAME already exists. This happens for interactive use with M-x. */) - (filename, linkname, ok_if_already_exists) - Lisp_Object filename, linkname, ok_if_already_exists; + (Lisp_Object filename, Lisp_Object linkname, Lisp_Object ok_if_already_exists) { Lisp_Object handler; Lisp_Object encoded_filename, encoded_linkname; @@ -2458,8 +2423,7 @@ DEFUN ("file-name-absolute-p", Ffile_name_absolute_p, Sfile_name_absolute_p, 1, 1, 0, doc: /* Return t if file FILENAME specifies an absolute file name. On Unix, this is a name starting with a `/' or a `~'. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { CHECK_STRING (filename); return file_name_absolute_p (SDATA (filename)) ? Qt : Qnil; @@ -2468,8 +2432,7 @@ On Unix, this is a name starting with a `/' or a `~'. */) /* Return nonzero if file FILENAME exists and can be executed. */ static int -check_executable (filename) - char *filename; +check_executable (char *filename) { #ifdef DOS_NT int len = strlen (filename); @@ -2477,16 +2440,7 @@ check_executable (filename) struct stat st; if (stat (filename, &st) < 0) return 0; -#if defined (WINDOWSNT) || (defined (MSDOS) && __DJGPP__ > 1) return ((st.st_mode & S_IEXEC) != 0); -#else - return (S_ISREG (st.st_mode) - && len >= 5 - && (xstrcasecmp ((suffix = filename + len-4), ".com") == 0 - || xstrcasecmp (suffix, ".exe") == 0 - || xstrcasecmp (suffix, ".bat") == 0) - || (st.st_mode & S_IFMT) == S_IFDIR); -#endif /* not WINDOWSNT */ #else /* not DOS_NT */ #ifdef HAVE_EUIDACCESS return (euidaccess (filename, 1) >= 0); @@ -2502,8 +2456,7 @@ check_executable (filename) /* Return nonzero if file FILENAME exists and can be written. */ static int -check_writable (filename) - char *filename; +check_writable (const char *filename) { #ifdef MSDOS struct stat st; @@ -2529,8 +2482,7 @@ DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0, See also `file-readable-p' and `file-attributes'. This returns nil for a symlink to a nonexistent file. Use `file-symlink-p' to test for such links. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object absname; Lisp_Object handler; @@ -2553,8 +2505,7 @@ Use `file-symlink-p' to test for such links. */) DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0, doc: /* Return t if FILENAME can be executed by you. For a directory, this means you can access files in that directory. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object absname; Lisp_Object handler; @@ -2576,8 +2527,7 @@ For a directory, this means you can access files in that directory. */) DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0, doc: /* Return t if file FILENAME exists and you can read it. See also `file-exists-p' and `file-attributes'. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object absname; Lisp_Object handler; @@ -2626,8 +2576,7 @@ See also `file-exists-p' and `file-attributes'. */) on the RT/PC. */ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, doc: /* Return t if file FILENAME can be written or created by you. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object absname, dir, encoded; Lisp_Object handler; @@ -2671,8 +2620,7 @@ DEFUN ("access-file", Faccess_file, Saccess_file, 2, 2, 0, doc: /* Access file FILENAME, and get an error if that does not work. The second argument STRING is used in the error message. If there is no error, returns nil. */) - (filename, string) - Lisp_Object filename, string; + (Lisp_Object filename, Lisp_Object string) { Lisp_Object handler, encoded_filename, absname; int fd; @@ -2705,8 +2653,7 @@ Otherwise it returns nil. This function returns t when given the name of a symlink that points to a nonexistent file. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object handler; @@ -2734,7 +2681,7 @@ points to a nonexistent file. */) { bufsize *= 2; buf = (char *) xrealloc (buf, bufsize); - bzero (buf, bufsize); + memset (buf, 0, bufsize); errno = 0; valsize = readlink (SDATA (filename), buf, bufsize); @@ -2755,7 +2702,7 @@ points to a nonexistent file. */) while (valsize >= bufsize); val = make_string (buf, valsize); - if (buf[0] == '/' && index (buf, ':')) + if (buf[0] == '/' && strchr (buf, ':')) val = concat2 (build_string ("/:"), val); xfree (buf); val = DECODE_FILE (val); @@ -2770,8 +2717,7 @@ DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, doc: /* Return t if FILENAME names an existing directory. Symbolic links to directories count as directories. See `file-symlink-p' to distinguish symlinks. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { register Lisp_Object absname; struct stat st; @@ -2800,8 +2746,7 @@ directory as a buffer's current directory, this predicate must return true. A directory name spec may be given instead; then the value is t if the directory so specified exists and really is a readable and searchable directory. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object handler; int tem; @@ -2825,8 +2770,7 @@ DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0, This is the sort of file that holds an ordinary stream of data bytes. Symbolic links to regular files count as regular files. See `file-symlink-p' to distinguish symlinks. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { register Lisp_Object absname; struct stat st; @@ -2863,11 +2807,142 @@ See `file-symlink-p' to distinguish symlinks. */) #endif } +DEFUN ("file-selinux-context", Ffile_selinux_context, + Sfile_selinux_context, 1, 1, 0, + doc: /* Return SELinux context of file named FILENAME, +as a list ("user", "role", "type", "range"). Return (nil, nil, nil, nil) +if file does not exist, is not accessible, or SELinux is disabled */) + (Lisp_Object filename) +{ + Lisp_Object absname; + Lisp_Object values[4]; + Lisp_Object handler; +#if HAVE_LIBSELINUX + security_context_t con; + int conlength; + context_t context; +#endif + + absname = expand_and_dir_to_file (filename, current_buffer->directory); + + /* If the file name has special constructs in it, + call the corresponding file handler. */ + handler = Ffind_file_name_handler (absname, Qfile_selinux_context); + if (!NILP (handler)) + return call2 (handler, Qfile_selinux_context, absname); + + absname = ENCODE_FILE (absname); + + values[0] = Qnil; + values[1] = Qnil; + values[2] = Qnil; + values[3] = Qnil; +#if HAVE_LIBSELINUX + if (is_selinux_enabled ()) + { + conlength = lgetfilecon (SDATA (absname), &con); + if (conlength > 0) + { + context = context_new (con); + if (context_user_get (context)) + values[0] = build_string (context_user_get (context)); + if (context_role_get (context)) + values[1] = build_string (context_role_get (context)); + if (context_type_get (context)) + values[2] = build_string (context_type_get (context)); + if (context_range_get (context)) + values[3] = build_string (context_range_get (context)); + context_free (context); + } + if (con) + freecon (con); + } +#endif + + return Flist (sizeof(values) / sizeof(values[0]), values); +} + +DEFUN ("set-file-selinux-context", Fset_file_selinux_context, + Sset_file_selinux_context, 2, 2, 0, + doc: /* Set SELinux context of file named FILENAME to CONTEXT +as a list ("user", "role", "type", "range"). Has no effect if SELinux +is disabled. */) + (Lisp_Object filename, Lisp_Object context) +{ + Lisp_Object absname, encoded_absname; + Lisp_Object handler; + Lisp_Object user = CAR_SAFE (context); + Lisp_Object role = CAR_SAFE (CDR_SAFE (context)); + Lisp_Object type = CAR_SAFE (CDR_SAFE (CDR_SAFE (context))); + Lisp_Object range = CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (context)))); +#if HAVE_LIBSELINUX + security_context_t con; + int fail, conlength; + context_t parsed_con; +#endif + + absname = Fexpand_file_name (filename, current_buffer->directory); + + /* If the file name has special constructs in it, + call the corresponding file handler. */ + handler = Ffind_file_name_handler (absname, Qset_file_selinux_context); + if (!NILP (handler)) + return call3 (handler, Qset_file_selinux_context, absname, context); + + encoded_absname = ENCODE_FILE (absname); + +#if HAVE_LIBSELINUX + if (is_selinux_enabled ()) + { + /* Get current file context. */ + conlength = lgetfilecon (SDATA (encoded_absname), &con); + if (conlength > 0) + { + parsed_con = context_new (con); + /* Change the parts defined in the parameter.*/ + if (STRINGP (user)) + { + if (context_user_set (parsed_con, SDATA (user))) + error ("Doing context_user_set"); + } + if (STRINGP (role)) + { + if (context_role_set (parsed_con, SDATA (role))) + error ("Doing context_role_set"); + } + if (STRINGP (type)) + { + if (context_type_set (parsed_con, SDATA (type))) + error ("Doing context_type_set"); + } + if (STRINGP (range)) + { + if (context_range_set (parsed_con, SDATA (range))) + error ("Doing context_range_set"); + } + + /* Set the modified context back to the file. */ + fail = lsetfilecon (SDATA (encoded_absname), context_str (parsed_con)); + if (fail) + report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); + + context_free (parsed_con); + } + else + report_file_error("Doing lgetfilecon", Fcons (absname, Qnil)); + + if (con) + freecon (con); + } +#endif + + return Qnil; +} + DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0, doc: /* Return mode bits of file named FILENAME, as an integer. Return nil, if file does not exist or is not accessible. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object absname; struct stat st; @@ -2885,10 +2960,6 @@ Return nil, if file does not exist or is not accessible. */) if (stat (SDATA (absname), &st) < 0) return Qnil; -#if defined (MSDOS) && __DJGPP__ < 2 - if (check_executable (SDATA (absname))) - st.st_mode |= S_IEXEC; -#endif /* MSDOS && __DJGPP__ < 2 */ return make_number (st.st_mode & 07777); } @@ -2901,8 +2972,7 @@ Only the 12 low bits of MODE are used. Interactively, mode bits are read by `read-file-modes', which accepts symbolic notation, like the `chmod' command from GNU Coreutils. */) - (filename, mode) - Lisp_Object filename, mode; + (Lisp_Object filename, Lisp_Object mode) { Lisp_Object absname, encoded_absname; Lisp_Object handler; @@ -2928,8 +2998,7 @@ DEFUN ("set-default-file-modes", Fset_default_file_modes, Sset_default_file_mode doc: /* Set the file permission bits for newly created files. The argument MODE should be an integer; only the low 9 bits are used. This setting is inherited by subprocesses. */) - (mode) - Lisp_Object mode; + (Lisp_Object mode) { CHECK_NUMBER (mode); @@ -2941,7 +3010,7 @@ This setting is inherited by subprocesses. */) DEFUN ("default-file-modes", Fdefault_file_modes, Sdefault_file_modes, 0, 0, 0, doc: /* Return the default file protection for created files. The value is an integer. */) - () + (void) { int realmask; Lisp_Object value; @@ -2953,7 +3022,6 @@ The value is an integer. */) return value; } -extern int lisp_time_argument P_ ((Lisp_Object, time_t *, int *)); DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0, doc: /* Set times of file FILENAME to TIME. @@ -2961,8 +3029,7 @@ Set both access and modification times. Return t on success, else nil. Use the current time if TIME is nil. TIME is in the format of `current-time'. */) - (filename, time) - Lisp_Object filename, time; + (Lisp_Object filename, Lisp_Object time) { Lisp_Object absname, encoded_absname; Lisp_Object handler; @@ -3009,7 +3076,7 @@ Use the current time if TIME is nil. TIME is in the format of #ifdef HAVE_SYNC DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "", doc: /* Tell Unix to finish all pending disk updates. */) - () + (void) { sync (); return Qnil; @@ -3021,8 +3088,7 @@ DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, Sfile_newer_than_file_ doc: /* Return t if file FILE1 is newer than file FILE2. If FILE1 does not exist, the answer is nil; otherwise, if FILE2 does not exist, the answer is t. */) - (file1, file2) - Lisp_Object file1, file2; + (Lisp_Object file1, Lisp_Object file2) { Lisp_Object absname1, absname2; struct stat st; @@ -3087,8 +3153,7 @@ Lisp_Object Qfind_buffer_file_type; o set back the buffer multibyteness. */ static Lisp_Object -decide_coding_unwind (unwind_data) - Lisp_Object unwind_data; +decide_coding_unwind (Lisp_Object unwind_data) { Lisp_Object multibyte, undo_list, buffer; @@ -3120,12 +3185,12 @@ static EMACS_INT non_regular_nbytes; /* Read from a non-regular file. - Read non_regular_trytry bytes max from non_regular_fd. + Read non_regular_nbytes bytes max from non_regular_fd. Non_regular_inserted specifies where to put the read bytes. Value is the number of bytes read. */ static Lisp_Object -read_non_regular () +read_non_regular (Lisp_Object ignore) { EMACS_INT nbytes; @@ -3143,7 +3208,7 @@ read_non_regular () in insert-file-contents. */ static Lisp_Object -read_non_regular_quit () +read_non_regular_quit (Lisp_Object ignore) { return Qnil; } @@ -3172,8 +3237,7 @@ the number of characters that replace previous buffer contents. This function does code conversion according to the value of `coding-system-for-read' or `file-coding-system-alist', and sets the variable `last-coding-system-used' to the coding system actually used. */) - (filename, visit, beg, end, replace) - Lisp_Object filename, visit, beg, end, replace; + (Lisp_Object filename, Lisp_Object visit, Lisp_Object beg, Lisp_Object end, Lisp_Object replace) { struct stat st; register int fd; @@ -3709,7 +3773,7 @@ variable `last-coding-system-used' to the coding system actually used. */) conversion_buffer); unprocessed = coding.carryover_bytes; if (coding.carryover_bytes > 0) - bcopy (coding.carryover, read_buf, unprocessed); + memcpy (read_buf, coding.carryover, unprocessed); } UNGCPRO; emacs_close (fd); @@ -4115,6 +4179,7 @@ variable `last-coding-system-used' to the coding system actually used. */) if (NILP (handler)) { current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; current_buffer->filename = orig_filename; } @@ -4296,11 +4361,10 @@ variable `last-coding-system-used' to the coding system actually used. */) RETURN_UNGCPRO (unbind_to (count, val)); } -static Lisp_Object build_annotations P_ ((Lisp_Object, Lisp_Object)); +static Lisp_Object build_annotations (Lisp_Object, Lisp_Object); static Lisp_Object -build_annotations_unwind (arg) - Lisp_Object arg; +build_annotations_unwind (Lisp_Object arg) { Vwrite_region_annotation_buffers = arg; return Qnil; @@ -4309,10 +4373,9 @@ build_annotations_unwind (arg) /* Decide the coding-system to encode the data with. */ static Lisp_Object -choose_write_coding_system (start, end, filename, - append, visit, lockname, coding) - Lisp_Object start, end, filename, append, visit, lockname; - struct coding_system *coding; +choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object filename, + Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, + struct coding_system *coding) { Lisp_Object val; Lisp_Object eol_parent = Qnil; @@ -4453,8 +4516,7 @@ This does code conversion according to the value of This calls `write-region-annotate-functions' at the start, and `write-region-post-annotation-function' at the end. */) - (start, end, filename, append, visit, lockname, mustbenew) - Lisp_Object start, end, filename, append, visit, lockname, mustbenew; + (Lisp_Object start, Lisp_Object end, Lisp_Object filename, Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, Lisp_Object mustbenew) { register int desc; int failure; @@ -4718,7 +4780,10 @@ This calls `write-region-annotate-functions' at the start, and to avoid a "file has changed on disk" warning on next attempt to save. */ if (visiting) - current_buffer->modtime = st.st_mtime; + { + current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; + } if (failure) error ("IO error writing %s: %s", SDATA (filename), @@ -4752,12 +4817,11 @@ This calls `write-region-annotate-functions' at the start, and return Qnil; } -Lisp_Object merge (); +Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0, doc: /* Return t if (car A) is numerically less than (car B). */) - (a, b) - Lisp_Object a, b; + (Lisp_Object a, Lisp_Object b) { return Flss (Fcar (a), Fcar (b)); } @@ -4771,8 +4835,7 @@ DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0, as save-excursion would do. */ static Lisp_Object -build_annotations (start, end) - Lisp_Object start, end; +build_annotations (Lisp_Object start, Lisp_Object end) { Lisp_Object annotations; Lisp_Object p, res; @@ -4861,13 +4924,7 @@ build_annotations (start, end) The return value is negative in case of system call failure. */ static int -a_write (desc, string, pos, nchars, annot, coding) - int desc; - Lisp_Object string; - register int nchars; - int pos; - Lisp_Object *annot; - struct coding_system *coding; +a_write (int desc, Lisp_Object string, int pos, register int nchars, Lisp_Object *annot, struct coding_system *coding) { Lisp_Object tem; int nextpos; @@ -4911,11 +4968,7 @@ a_write (desc, string, pos, nchars, annot, coding) are indexes to the string STRING. */ static int -e_write (desc, string, start, end, coding) - int desc; - Lisp_Object string; - int start, end; - struct coding_system *coding; +e_write (int desc, Lisp_Object string, int start, int end, struct coding_system *coding) { if (STRINGP (string)) { @@ -4995,8 +5048,7 @@ DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, doc: /* Return t if last mod time of BUF's visited file matches what BUF records. This means that the file has not been changed since it was visited or saved. See Info node `(elisp)Modification Time' for more details. */) - (buf) - Lisp_Object buf; + (Lisp_Object buf) { struct buffer *b; struct stat st; @@ -5027,11 +5079,13 @@ See Info node `(elisp)Modification Time' for more details. */) else st.st_mtime = 0; } - if (st.st_mtime == b->modtime - /* If both are positive, accept them if they are off by one second. */ - || (st.st_mtime > 0 && b->modtime > 0 - && (st.st_mtime == b->modtime + 1 - || st.st_mtime == b->modtime - 1))) + if ((st.st_mtime == b->modtime + /* If both are positive, accept them if they are off by one second. */ + || (st.st_mtime > 0 && b->modtime > 0 + && (st.st_mtime == b->modtime + 1 + || st.st_mtime == b->modtime - 1))) + && (st.st_size == b->modtime_size + || b->modtime_size < 0)) return Qt; return Qnil; } @@ -5040,9 +5094,10 @@ DEFUN ("clear-visited-file-modtime", Fclear_visited_file_modtime, Sclear_visited_file_modtime, 0, 0, 0, doc: /* Clear out records of last mod time of visited file. Next attempt to save will certainly not complain of a discrepancy. */) - () + (void) { current_buffer->modtime = 0; + current_buffer->modtime_size = -1; return Qnil; } @@ -5053,7 +5108,7 @@ The value is a list of the form (HIGH LOW), like the time values that `file-attributes' returns. If the current buffer has no recorded file modification time, this function returns 0. See Info node `(elisp)Modification Time' for more details. */) - () + (void) { if (! current_buffer->modtime) return make_number (0); @@ -5068,11 +5123,13 @@ or if the file itself has been changed for some known benign reason. An argument specifies the modification time value to use \(instead of that of the visited file), in the form of a list \(HIGH . LOW) or (HIGH LOW). */) - (time_list) - Lisp_Object time_list; + (Lisp_Object time_list) { if (!NILP (time_list)) - current_buffer->modtime = cons_to_long (time_list); + { + current_buffer->modtime = cons_to_long (time_list); + current_buffer->modtime_size = -1; + } else { register Lisp_Object filename; @@ -5091,15 +5148,17 @@ An argument specifies the modification time value to use filename = ENCODE_FILE (filename); if (stat (SDATA (filename), &st) >= 0) - current_buffer->modtime = st.st_mtime; + { + current_buffer->modtime = st.st_mtime; + current_buffer->modtime_size = st.st_size; + } } return Qnil; } Lisp_Object -auto_save_error (error) - Lisp_Object error; +auto_save_error (Lisp_Object error) { Lisp_Object args[3], msg; int i, nbytes; @@ -5118,7 +5177,7 @@ auto_save_error (error) GCPRO1 (msg); nbytes = SBYTES (msg); SAFE_ALLOCA (msgbuf, char *, nbytes); - bcopy (SDATA (msg), msgbuf, nbytes); + memcpy (msgbuf, SDATA (msg), nbytes); for (i = 0; i < 3; ++i) { @@ -5135,7 +5194,7 @@ auto_save_error (error) } Lisp_Object -auto_save_1 () +auto_save_1 (void) { struct stat st; Lisp_Object modes; @@ -5161,8 +5220,8 @@ auto_save_1 () } static Lisp_Object -do_auto_save_unwind (arg) /* used as unwind-protect function */ - Lisp_Object arg; +do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */ + { FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; auto_saving = 0; @@ -5176,16 +5235,15 @@ do_auto_save_unwind (arg) /* used as unwind-protect function */ } static Lisp_Object -do_auto_save_unwind_1 (value) /* used as unwind-protect function */ - Lisp_Object value; +do_auto_save_unwind_1 (Lisp_Object value) /* used as unwind-protect function */ + { minibuffer_auto_raise = XINT (value); return Qnil; } static Lisp_Object -do_auto_save_make_dir (dir) - Lisp_Object dir; +do_auto_save_make_dir (Lisp_Object dir) { Lisp_Object mode; @@ -5195,8 +5253,7 @@ do_auto_save_make_dir (dir) } static Lisp_Object -do_auto_save_eh (ignore) - Lisp_Object ignore; +do_auto_save_eh (Lisp_Object ignore) { return Qnil; } @@ -5212,8 +5269,7 @@ Normally we run the normal hook `auto-save-hook' before saving. A non-nil NO-MESSAGE argument means do not print any message if successful. A non-nil CURRENT-ONLY argument means save only current buffer. */) - (no_message, current_only) - Lisp_Object no_message, current_only; + (Lisp_Object no_message, Lisp_Object current_only) { struct buffer *old = current_buffer, *b; Lisp_Object tail, buf; @@ -5414,7 +5470,7 @@ DEFUN ("set-buffer-auto-saved", Fset_buffer_auto_saved, Sset_buffer_auto_saved, 0, 0, 0, doc: /* Mark current buffer as auto-saved with its current text. No auto-save file will be written until the buffer changes again. */) - () + (void) { /* FIXME: This should not be called in indirect buffers, since they're not autosaved. */ @@ -5427,7 +5483,7 @@ No auto-save file will be written until the buffer changes again. */) DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, Sclear_buffer_auto_save_failure, 0, 0, 0, doc: /* Clear any record of a recent auto-save failure in the current buffer. */) - () + (void) { current_buffer->auto_save_failure_time = -1; return Qnil; @@ -5439,7 +5495,7 @@ DEFUN ("recent-auto-save-p", Frecent_auto_save_p, Srecent_auto_save_p, More precisely, if it has been auto-saved since last read from or saved in the visited file. If the buffer has no visited file, then any auto-save counts as "recent". */) - () + (void) { /* FIXME: maybe we should return nil for indirect buffers since they're never autosaved. */ @@ -5453,7 +5509,7 @@ DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p, doc: /* Return t if a call to `read-file-name' will use a dialog. The return value is only relevant for a call to `read-file-name' that happens before any other event (mouse or keypress) is handled. */) - () + (void) { #if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) @@ -5466,8 +5522,7 @@ before any other event (mouse or keypress) is handled. */) } Lisp_Object -Fread_file_name (prompt, dir, default_filename, mustmatch, initial, predicate) - Lisp_Object prompt, dir, default_filename, mustmatch, initial, predicate; +Fread_file_name (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object initial, Lisp_Object predicate) { struct gcpro gcpro1, gcpro2; Lisp_Object args[7]; @@ -5485,7 +5540,7 @@ Fread_file_name (prompt, dir, default_filename, mustmatch, initial, predicate) void -syms_of_fileio () +syms_of_fileio (void) { Qoperations = intern_c_string ("operations"); Qexpand_file_name = intern_c_string ("expand-file-name"); @@ -5515,6 +5570,8 @@ syms_of_fileio () Qfile_modes = intern_c_string ("file-modes"); Qset_file_modes = intern_c_string ("set-file-modes"); Qset_file_times = intern_c_string ("set-file-times"); + Qfile_selinux_context = intern_c_string("file-selinux-context"); + Qset_file_selinux_context = intern_c_string("set-file-selinux-context"); Qfile_newer_than_file_p = intern_c_string ("file-newer-than-file-p"); Qinsert_file_contents = intern_c_string ("insert-file-contents"); Qwrite_region = intern_c_string ("write-region"); @@ -5550,6 +5607,8 @@ syms_of_fileio () staticpro (&Qfile_modes); staticpro (&Qset_file_modes); staticpro (&Qset_file_times); + staticpro (&Qfile_selinux_context); + staticpro (&Qset_file_selinux_context); staticpro (&Qfile_newer_than_file_p); staticpro (&Qinsert_file_contents); staticpro (&Qwrite_region); @@ -5616,11 +5675,6 @@ of file names regardless of the current language environment. */); Fput (Qfile_date_error, Qerror_message, make_pure_c_string ("Cannot set file date")); - DEFVAR_LISP ("directory-sep-char", &Vdirectory_sep_char, - doc: /* Directory separator character for built-in functions that return file names. -The value is always ?/. Don't use this variable, just use `/'. */); - XSETFASTINT (Vdirectory_sep_char, '/'); - DEFVAR_LISP ("file-name-handler-alist", &Vfile_name_handler_alist, doc: /* *Alist of elements (REGEXP . HANDLER) for file names handled specially. If a file name matches REGEXP, then all I/O on that file is done by calling @@ -5743,8 +5797,10 @@ A non-nil value may result in data loss! */); DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, doc: /* Specifies whether to use the system's trash can. -When non-nil, the function `move-file-to-trash' will be used by -`delete-file' and `delete-directory'. */); +When non-nil, certain file deletion commands use the function +`move-file-to-trash' instead of deleting files outright. +This includes interactive calls to `delete-file' and +`delete-directory' and the Dired deletion commands. */); delete_by_moving_to_trash = 0; Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); Qmove_file_to_trash = intern_c_string ("move-file-to-trash"); @@ -5783,6 +5839,8 @@ When non-nil, the function `move-file-to-trash' will be used by defsubr (&Sfile_modes); defsubr (&Sset_file_modes); defsubr (&Sset_file_times); + defsubr (&Sfile_selinux_context); + defsubr (&Sset_file_selinux_context); defsubr (&Sset_default_file_modes); defsubr (&Sdefault_file_modes); defsubr (&Sfile_newer_than_file_p); diff --git a/src/filelock.c b/src/filelock.c index 7c69ea954fc..acca7234419 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -31,12 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #include <sys/file.h> -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -47,9 +42,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* __FreeBSD__ */ #include <errno.h> -#ifndef errno -extern int errno; -#endif #include "lisp.h" #include "buffer.h" @@ -122,14 +114,12 @@ Lisp_Object Vtemporary_file_directory; static time_t boot_time; static int boot_time_initialized; -extern Lisp_Object Vshell_file_name; - #ifdef BOOT_TIME -static void get_boot_time_1 P_ ((char *, int)); +static void get_boot_time_1 (const char *, int); #endif static time_t -get_boot_time () +get_boot_time (void) { #if defined (BOOT_TIME) int counter; @@ -256,9 +246,7 @@ get_boot_time () Success is indicated by setting BOOT_TIME to a larger value. */ void -get_boot_time_1 (filename, newest) - char *filename; - int newest; +get_boot_time_1 (const char *filename, int newest) { struct utmp ut, *utp; int desc; @@ -329,9 +317,7 @@ typedef struct fill_in_lock_file_name (lock, (file))) static void -fill_in_lock_file_name (lockfile, fn) - register char *lockfile; - register Lisp_Object fn; +fill_in_lock_file_name (register char *lockfile, register Lisp_Object fn) { register char *p; struct stat st; @@ -367,14 +353,12 @@ fill_in_lock_file_name (lockfile, fn) Return 1 if successful, 0 if not. */ static int -lock_file_1 (lfname, force) - char *lfname; - int force; +lock_file_1 (char *lfname, int force) { register int err; time_t boot_time; - char *user_name; - char *host_name; + const char *user_name; + const char *host_name; char *lock_info_str; /* Call this first because it can GC. */ @@ -411,8 +395,7 @@ lock_file_1 (lfname, force) /* Return 1 if times A and B are no more than one second apart. */ int -within_one_second (a, b) - time_t a, b; +within_one_second (time_t a, time_t b) { return (a - b >= -1 && a - b <= 1); } @@ -423,13 +406,8 @@ within_one_second (a, b) or -1 if something is wrong with the locking mechanism. */ static int -current_lock_owner (owner, lfname) - lock_info_type *owner; - char *lfname; +current_lock_owner (lock_info_type *owner, char *lfname) { -#ifndef index - extern char *rindex (), *index (); -#endif int len, ret; int local_owner = 0; char *at, *dot, *colon; @@ -471,8 +449,8 @@ current_lock_owner (owner, lfname) /* Parse USER@HOST.PID:BOOT_TIME. If can't parse, return -1. */ /* The USER is everything before the last @. */ - at = rindex (lfinfo, '@'); - dot = rindex (lfinfo, '.'); + at = strrchr (lfinfo, '@'); + dot = strrchr (lfinfo, '.'); if (!at || !dot) { xfree (lfinfo); @@ -543,9 +521,7 @@ current_lock_owner (owner, lfname) Return -1 if cannot lock for any other reason. */ static int -lock_if_free (clasher, lfname) - lock_info_type *clasher; - register char *lfname; +lock_if_free (lock_info_type *clasher, register char *lfname) { while (lock_file_1 (lfname, 0) == 0) { @@ -588,8 +564,7 @@ lock_if_free (clasher, lfname) take away the lock, or return nil meaning ignore the lock. */ void -lock_file (fn) - Lisp_Object fn; +lock_file (Lisp_Object fn) { register Lisp_Object attack, orig_fn, encoded_fn; register char *lfname, *locker; @@ -648,8 +623,7 @@ lock_file (fn) } void -unlock_file (fn) - register Lisp_Object fn; +unlock_file (register Lisp_Object fn) { register char *lfname; @@ -663,7 +637,7 @@ unlock_file (fn) } void -unlock_all_files () +unlock_all_files (void) { register Lisp_Object tail; register struct buffer *b; @@ -683,8 +657,7 @@ DEFUN ("lock-buffer", Flock_buffer, Slock_buffer, doc: /* Lock FILE, if current buffer is modified. FILE defaults to current buffer's visited file, or else nothing is done if current buffer isn't visiting a file. */) - (file) - Lisp_Object file; + (Lisp_Object file) { if (NILP (file)) file = current_buffer->file_truename; @@ -701,7 +674,7 @@ DEFUN ("unlock-buffer", Funlock_buffer, Sunlock_buffer, doc: /* Unlock the file visited in the current buffer. If the buffer is not modified, this does nothing because the file should not be locked in that case. */) - () + (void) { if (SAVE_MODIFF < MODIFF && STRINGP (current_buffer->file_truename)) @@ -712,8 +685,7 @@ should not be locked in that case. */) /* Unlock the file visited in buffer BUFFER. */ void -unlock_buffer (buffer) - struct buffer *buffer; +unlock_buffer (struct buffer *buffer) { if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer) && STRINGP (buffer->file_truename)) @@ -724,8 +696,7 @@ DEFUN ("file-locked-p", Ffile_locked_p, Sfile_locked_p, 1, 1, 0, doc: /* Return a value indicating whether FILENAME is locked. The value is nil if the FILENAME is not locked, t if it is locked by you, else a string saying which user has locked it. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object ret; register char *lfname; @@ -753,14 +724,14 @@ t if it is locked by you, else a string saying which user has locked it. */) /* Initialization functions. */ void -init_filelock () +init_filelock (void) { boot_time = 0; boot_time_initialized = 0; } void -syms_of_filelock () +syms_of_filelock (void) { DEFVAR_LISP ("temporary-file-directory", &Vtemporary_file_directory, doc: /* The directory for writing temporary files. */); diff --git a/src/filemode.c b/src/filemode.c index 4a11d2a3115..3048077ff52 100644 --- a/src/filemode.c +++ b/src/filemode.c @@ -17,10 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - #include <sys/types.h> #include <sys/stat.h> @@ -90,10 +87,10 @@ #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) #endif -void mode_string (); -static char ftypelet (); -static void rwx (); -static void setst (); +void mode_string (short unsigned int mode, char *str); +static char ftypelet (long int bits); +static void rwx (short unsigned int bits, char *chars); +static void setst (short unsigned int bits, char *chars); /* filemodestring - fill in string STR with an ls-style ASCII representation of the st_mode field of file stats block STATP. @@ -132,9 +129,7 @@ static void setst (); 'T' if the file is sticky but not executable. */ void -filemodestring (statp, str) - struct stat *statp; - char *str; +filemodestring (struct stat *statp, char *str) { mode_string (statp->st_mode, str); } @@ -143,9 +138,7 @@ filemodestring (statp, str) is given as an argument. */ void -mode_string (mode, str) - unsigned short mode; - char *str; +mode_string (short unsigned int mode, char *str) { str[0] = ftypelet ((long) mode); rwx ((mode & 0700) << 0, &str[1]); @@ -167,8 +160,7 @@ mode_string (mode, str) '?' for any other file type. */ static char -ftypelet (bits) - long bits; +ftypelet (long int bits) { #ifdef S_ISBLK if (S_ISBLK (bits)) @@ -207,9 +199,7 @@ ftypelet (bits) flags in CHARS accordingly. */ static void -rwx (bits, chars) - unsigned short bits; - char *chars; +rwx (short unsigned int bits, char *chars) { chars[0] = (bits & S_IRUSR) ? 'r' : '-'; chars[1] = (bits & S_IWUSR) ? 'w' : '-'; @@ -220,9 +210,7 @@ rwx (bits, chars) according to the file mode BITS. */ static void -setst (bits, chars) - unsigned short bits; - char *chars; +setst (short unsigned int bits, char *chars) { #ifdef S_ISUID if (bits & S_ISUID) diff --git a/src/floatfns.c b/src/floatfns.c index 97d9ec00aae..29e5c119a1f 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -70,7 +70,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* This declaration is omitted on some systems, like Ultrix. */ #if !defined (HPUX) && defined (HAVE_LOGB) && !defined (logb) -extern double logb (); +extern double logb (double); #endif /* not HPUX and HAVE_LOGB and no logb macro */ #if defined(DOMAIN) && defined(SING) && defined(OVERFLOW) @@ -99,10 +99,6 @@ extern double logb (); #ifdef FLOAT_CHECK_ERRNO # include <errno.h> - -#ifndef USE_CRT_DLL -extern int errno; -#endif #endif #ifdef FLOAT_CATCH_SIGILL @@ -121,7 +117,7 @@ static int in_float; static Lisp_Object float_error_arg, float_error_arg2; -static char *float_error_fn_name; +static const char *float_error_fn_name; /* Evaluate the floating point expression D, recording NUM as the original argument for error messages. @@ -196,8 +192,7 @@ static char *float_error_fn_name; /* Extract a Lisp number as a `double', or signal an error. */ double -extract_float (num) - Lisp_Object num; +extract_float (Lisp_Object num) { CHECK_NUMBER_OR_FLOAT (num); @@ -210,8 +205,7 @@ extract_float (num) DEFUN ("acos", Facos, Sacos, 1, 1, 0, doc: /* Return the inverse cosine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -224,8 +218,7 @@ DEFUN ("acos", Facos, Sacos, 1, 1, 0, DEFUN ("asin", Fasin, Sasin, 1, 1, 0, doc: /* Return the inverse sine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -242,8 +235,7 @@ If only one argument Y is given, return the inverse tangent of Y. If two arguments Y and X are given, return the inverse tangent of Y divided by X, i.e. the angle in radians between the vector (X, Y) and the x-axis. */) - (y, x) - register Lisp_Object y, x; + (register Lisp_Object y, Lisp_Object x) { double d = extract_float (y); @@ -260,8 +252,7 @@ and the x-axis. */) DEFUN ("cos", Fcos, Scos, 1, 1, 0, doc: /* Return the cosine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = cos (d), "cos", arg); @@ -270,8 +261,7 @@ DEFUN ("cos", Fcos, Scos, 1, 1, 0, DEFUN ("sin", Fsin, Ssin, 1, 1, 0, doc: /* Return the sine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = sin (d), "sin", arg); @@ -280,8 +270,7 @@ DEFUN ("sin", Fsin, Ssin, 1, 1, 0, DEFUN ("tan", Ftan, Stan, 1, 1, 0, doc: /* Return the tangent of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); double c = cos (d); @@ -292,13 +281,72 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0, IN_FLOAT (d = sin (d) / c, "tan", arg); return make_float (d); } + +#if defined HAVE_ISNAN && defined HAVE_COPYSIGN +DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, + doc: /* Return non nil iff argument X is a NaN. */) + (Lisp_Object x) +{ + CHECK_FLOAT (x); + return isnan (XFLOAT_DATA (x)) ? Qt : Qnil; +} + +DEFUN ("copysign", Fcopysign, Scopysign, 1, 2, 0, + doc: /* Copy sign of X2 to value of X1, and return the result. +Cause an error if X1 or X2 is not a float. */) + (Lisp_Object x1, Lisp_Object x2) +{ + double f1, f2; + + CHECK_FLOAT (x1); + CHECK_FLOAT (x2); + + f1 = XFLOAT_DATA (x1); + f2 = XFLOAT_DATA (x2); + + return make_float (copysign (f1, f2)); +} + +DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, + doc: /* Get significand and exponent of a floating point number. +Breaks the floating point number X into its binary significand SGNFCAND +\(a floating point value between 0.5 (included) and 1.0 (excluded)) +and an integral exponent EXP for 2, such that: + + X = SGNFCAND * 2^EXP + +The function returns the cons cell (SGNFCAND . EXP). +If X is zero, both parts (SGNFCAND and EXP) are zero. */) + (Lisp_Object x) +{ + double f = XFLOATINT (x); + + if (f == 0.0) + return Fcons (make_float (0.0), make_number (0)); + else + { + int exp; + double sgnfcand = frexp (f, &exp); + return Fcons (make_float (sgnfcand), make_number (exp)); + } +} + +DEFUN ("ldexp", Fldexp, Sldexp, 1, 2, 0, + doc: /* Construct number X from significand SGNFCAND and exponent EXP. +Returns the floating point value resulting from multiplying SGNFCAND +(the significand) by 2 raised to the power of EXP (the exponent). */) + (Lisp_Object sgnfcand, Lisp_Object exp) +{ + CHECK_NUMBER (exp); + return make_float (ldexp (XFLOATINT (sgnfcand), XINT (exp))); +} +#endif #if 0 /* Leave these out unless we find there's a reason for them. */ DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, doc: /* Return the bessel function j0 of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = j0 (d), "bessel-j0", arg); @@ -307,8 +355,7 @@ DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0, doc: /* Return the bessel function j1 of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = j1 (d), "bessel-j1", arg); @@ -318,8 +365,7 @@ DEFUN ("bessel-j1", Fbessel_j1, Sbessel_j1, 1, 1, 0, DEFUN ("bessel-jn", Fbessel_jn, Sbessel_jn, 2, 2, 0, doc: /* Return the order N bessel function output jn of ARG. The first arg (the order) is truncated to an integer. */) - (n, arg) - register Lisp_Object n, arg; + (register Lisp_Object n, Lisp_Object arg) { int i1 = extract_float (n); double f2 = extract_float (arg); @@ -330,8 +376,7 @@ The first arg (the order) is truncated to an integer. */) DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0, doc: /* Return the bessel function y0 of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = y0 (d), "bessel-y0", arg); @@ -340,8 +385,7 @@ DEFUN ("bessel-y0", Fbessel_y0, Sbessel_y0, 1, 1, 0, DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0, doc: /* Return the bessel function y1 of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = y1 (d), "bessel-y0", arg); @@ -351,8 +395,7 @@ DEFUN ("bessel-y1", Fbessel_y1, Sbessel_y1, 1, 1, 0, DEFUN ("bessel-yn", Fbessel_yn, Sbessel_yn, 2, 2, 0, doc: /* Return the order N bessel function output yn of ARG. The first arg (the order) is truncated to an integer. */) - (n, arg) - register Lisp_Object n, arg; + (register Lisp_Object n, Lisp_Object arg) { int i1 = extract_float (n); double f2 = extract_float (arg); @@ -367,8 +410,7 @@ The first arg (the order) is truncated to an integer. */) DEFUN ("erf", Ferf, Serf, 1, 1, 0, doc: /* Return the mathematical error function of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = erf (d), "erf", arg); @@ -377,8 +419,7 @@ DEFUN ("erf", Ferf, Serf, 1, 1, 0, DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, doc: /* Return the complementary error function of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = erfc (d), "erfc", arg); @@ -387,8 +428,7 @@ DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, doc: /* Return the log gamma of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = lgamma (d), "log-gamma", arg); @@ -397,8 +437,7 @@ DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, doc: /* Return the cube root of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef HAVE_CBRT @@ -416,8 +455,7 @@ DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, DEFUN ("exp", Fexp, Sexp, 1, 1, 0, doc: /* Return the exponential base e of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -433,8 +471,7 @@ DEFUN ("exp", Fexp, Sexp, 1, 1, 0, DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, doc: /* Return the exponential ARG1 ** ARG2. */) - (arg1, arg2) - register Lisp_Object arg1, arg2; + (register Lisp_Object arg1, Lisp_Object arg2) { double f1, f2, f3; @@ -492,8 +529,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, DEFUN ("log", Flog, Slog, 1, 2, 0, doc: /* Return the natural logarithm of ARG. If the optional argument BASE is given, return log ARG using that base. */) - (arg, base) - register Lisp_Object arg, base; + (register Lisp_Object arg, Lisp_Object base) { double d = extract_float (arg); @@ -521,8 +557,7 @@ If the optional argument BASE is given, return log ARG using that base. */) DEFUN ("log10", Flog10, Slog10, 1, 1, 0, doc: /* Return the logarithm base 10 of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -535,8 +570,7 @@ DEFUN ("log10", Flog10, Slog10, 1, 1, 0, DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, doc: /* Return the square root of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -551,8 +585,7 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, doc: /* Return the inverse hyperbolic cosine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -569,8 +602,7 @@ DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, doc: /* Return the inverse hyperbolic sine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef HAVE_INVERSE_HYPERBOLIC @@ -583,8 +615,7 @@ DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, doc: /* Return the inverse hyperbolic tangent of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -601,8 +632,7 @@ DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, doc: /* Return the hyperbolic cosine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -615,8 +645,7 @@ DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, doc: /* Return the hyperbolic sine of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); #ifdef FLOAT_CHECK_DOMAIN @@ -629,8 +658,7 @@ DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, doc: /* Return the hyperbolic tangent of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = tanh (d), "tanh", arg); @@ -640,8 +668,7 @@ DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, DEFUN ("abs", Fabs, Sabs, 1, 1, 0, doc: /* Return the absolute value of ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { CHECK_NUMBER_OR_FLOAT (arg); @@ -655,8 +682,7 @@ DEFUN ("abs", Fabs, Sabs, 1, 1, 0, DEFUN ("float", Ffloat, Sfloat, 1, 1, 0, doc: /* Return the floating point number equal to ARG. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { CHECK_NUMBER_OR_FLOAT (arg); @@ -669,8 +695,7 @@ DEFUN ("float", Ffloat, Sfloat, 1, 1, 0, DEFUN ("logb", Flogb, Slogb, 1, 1, 0, doc: /* Returns largest integer <= the base 2 log of the magnitude of ARG. This is the same as the exponent of a float. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object val; EMACS_INT value; @@ -718,11 +743,10 @@ This is the same as the exponent of a float. */) /* the rounding functions */ static Lisp_Object -rounding_driver (arg, divisor, double_round, int_round2, name) - register Lisp_Object arg, divisor; - double (*double_round) (); - EMACS_INT (*int_round2) (); - char *name; +rounding_driver (Lisp_Object arg, Lisp_Object divisor, + double (*double_round) (double), + EMACS_INT (*int_round2) (EMACS_INT, EMACS_INT), + const char *name) { CHECK_NUMBER_OR_FLOAT (arg); @@ -772,8 +796,7 @@ rounding_driver (arg, divisor, double_round, int_round2, name) integer functions. */ static EMACS_INT -ceiling2 (i1, i2) - EMACS_INT i1, i2; +ceiling2 (EMACS_INT i1, EMACS_INT i2) { return (i2 < 0 ? (i1 < 0 ? ((-1 - i1) / -i2) + 1 : - (i1 / -i2)) @@ -781,8 +804,7 @@ ceiling2 (i1, i2) } static EMACS_INT -floor2 (i1, i2) - EMACS_INT i1, i2; +floor2 (EMACS_INT i1, EMACS_INT i2) { return (i2 < 0 ? (i1 <= 0 ? -i1 / -i2 : -1 - ((i1 - 1) / -i2)) @@ -790,8 +812,7 @@ floor2 (i1, i2) } static EMACS_INT -truncate2 (i1, i2) - EMACS_INT i1, i2; +truncate2 (EMACS_INT i1, EMACS_INT i2) { return (i2 < 0 ? (i1 < 0 ? -i1 / -i2 : - (i1 / -i2)) @@ -799,8 +820,7 @@ truncate2 (i1, i2) } static EMACS_INT -round2 (i1, i2) - EMACS_INT i1, i2; +round2 (EMACS_INT i1, EMACS_INT i2) { /* The C language's division operator gives us one remainder R, but we want the remainder R1 on the other side of 0 if R1 is closer @@ -820,16 +840,14 @@ round2 (i1, i2) #define emacs_rint rint #else static double -emacs_rint (d) - double d; +emacs_rint (double d) { return floor (d + 0.5); } #endif static double -double_identity (d) - double d; +double_identity (double d) { return d; } @@ -838,8 +856,7 @@ DEFUN ("ceiling", Fceiling, Sceiling, 1, 2, 0, doc: /* Return the smallest integer no less than ARG. This rounds the value towards +inf. With optional DIVISOR, return the smallest integer no less than ARG/DIVISOR. */) - (arg, divisor) - Lisp_Object arg, divisor; + (Lisp_Object arg, Lisp_Object divisor) { return rounding_driver (arg, divisor, ceil, ceiling2, "ceiling"); } @@ -848,8 +865,7 @@ DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0, doc: /* Return the largest integer no greater than ARG. This rounds the value towards -inf. With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR. */) - (arg, divisor) - Lisp_Object arg, divisor; + (Lisp_Object arg, Lisp_Object divisor) { return rounding_driver (arg, divisor, floor, floor2, "floor"); } @@ -862,8 +878,7 @@ Rounding a value equidistant between two integers may choose the integer closer to zero, or it may prefer an even integer, depending on your machine. For example, \(round 2.5\) can return 3 on some systems, but 2 on others. */) - (arg, divisor) - Lisp_Object arg, divisor; + (Lisp_Object arg, Lisp_Object divisor) { return rounding_driver (arg, divisor, emacs_rint, round2, "round"); } @@ -872,8 +887,7 @@ DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0, doc: /* Truncate a floating point number to an int. Rounds ARG toward zero. With optional DIVISOR, truncate ARG/DIVISOR. */) - (arg, divisor) - Lisp_Object arg, divisor; + (Lisp_Object arg, Lisp_Object divisor) { return rounding_driver (arg, divisor, double_identity, truncate2, "truncate"); @@ -881,8 +895,7 @@ With optional DIVISOR, truncate ARG/DIVISOR. */) Lisp_Object -fmod_float (x, y) - register Lisp_Object x, y; +fmod_float (Lisp_Object x, Lisp_Object y) { double f1, f2; @@ -904,8 +917,7 @@ fmod_float (x, y) DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0, doc: /* Return the smallest integer no less than ARG, as a float. \(Round toward +inf.\) */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = ceil (d), "fceiling", arg); @@ -915,8 +927,7 @@ DEFUN ("fceiling", Ffceiling, Sfceiling, 1, 1, 0, DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0, doc: /* Return the largest integer no greater than ARG, as a float. \(Round towards -inf.\) */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = floor (d), "ffloor", arg); @@ -925,8 +936,7 @@ DEFUN ("ffloor", Fffloor, Sffloor, 1, 1, 0, DEFUN ("fround", Ffround, Sfround, 1, 1, 0, doc: /* Return the nearest integer to ARG, as a float. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); IN_FLOAT (d = emacs_rint (d), "fround", arg); @@ -936,8 +946,7 @@ DEFUN ("fround", Ffround, Sfround, 1, 1, 0, DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, doc: /* Truncate a floating point number to an integral float value. Rounds the value toward zero. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { double d = extract_float (arg); if (d >= 0.0) @@ -975,20 +984,21 @@ float_error (signo) #ifdef HAVE_MATHERR int -matherr (x) - struct exception *x; +matherr (struct exception *x) { Lisp_Object args; + const char *name = x->name; + if (! in_float) /* Not called from emacs-lisp float routines; do the default thing. */ return 0; if (!strcmp (x->name, "pow")) - x->name = "expt"; + name = "expt"; args - = Fcons (build_string (x->name), + = Fcons (build_string (name), Fcons (make_float (x->arg1), - ((!strcmp (x->name, "log") || !strcmp (x->name, "pow")) + ((!strcmp (name, "log") || !strcmp (name, "pow")) ? Fcons (make_float (x->arg2), Qnil) : Qnil))); switch (x->type) @@ -1004,7 +1014,7 @@ matherr (x) #endif /* HAVE_MATHERR */ void -init_floatfns () +init_floatfns (void) { #ifdef FLOAT_CATCH_SIGILL signal (SIGILL, float_error); @@ -1013,7 +1023,7 @@ init_floatfns () } void -syms_of_floatfns () +syms_of_floatfns (void) { defsubr (&Sacos); defsubr (&Sasin); @@ -1021,6 +1031,12 @@ syms_of_floatfns () defsubr (&Scos); defsubr (&Ssin); defsubr (&Stan); +#if defined HAVE_ISNAN && defined HAVE_COPYSIGN + defsubr (&Sisnan); + defsubr (&Scopysign); + defsubr (&Sfrexp); + defsubr (&Sldexp); +#endif #if 0 defsubr (&Sacosh); defsubr (&Sasinh); diff --git a/src/fns.c b/src/fns.c index 4e8cd5db9a6..19d534e7fda 100644 --- a/src/fns.c +++ b/src/fns.c @@ -61,23 +61,16 @@ int use_dialog_box; questions asked by mouse commands. */ int use_file_dialog; -extern int minibuffer_auto_raise; -extern Lisp_Object minibuf_window; -extern Lisp_Object Vlocale_coding_system; -extern int load_in_progress; - Lisp_Object Qstring_lessp, Qprovide, Qrequire; Lisp_Object Qyes_or_no_p_history; Lisp_Object Qcursor_in_echo_area; Lisp_Object Qwidget_type; Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper; -extern Lisp_Object Qinput_method_function; - -static int internal_equal P_ ((Lisp_Object , Lisp_Object, int, int)); +static int internal_equal (Lisp_Object , Lisp_Object, int, int); -extern long get_random (); -extern void seed_random P_ ((long)); +extern long get_random (void); +extern void seed_random (long); #ifndef HAVE_UNISTD_H extern long time (); @@ -85,8 +78,7 @@ extern long time (); DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, doc: /* Return the argument unchanged. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { return arg; } @@ -98,8 +90,7 @@ All integers representable in Lisp are equally likely. With positive integer LIMIT, return random number in interval [0,LIMIT). With argument t, set the random number seed from the current time and pid. Other values of LIMIT are ignored. */) - (limit) - Lisp_Object limit; + (Lisp_Object limit) { EMACS_INT val; Lisp_Object lispy_val; @@ -135,8 +126,7 @@ A byte-code function object is also allowed. If the string contains multibyte characters, this is not necessarily the number of bytes in the string; it is the number of characters. To get the number of bytes, use `string-bytes'. */) - (sequence) - register Lisp_Object sequence; + (register Lisp_Object sequence) { register Lisp_Object val; register int i; @@ -186,8 +176,7 @@ DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0, This function never gets an error. If LIST is not really a list, it returns 0. If LIST is circular, it returns a finite value which is at least the number of distinct elements. */) - (list) - Lisp_Object list; + (Lisp_Object list) { Lisp_Object tail, halftail, length; int len = 0; @@ -210,8 +199,7 @@ which is at least the number of distinct elements. */) DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0, doc: /* Return the number of bytes in STRING. If STRING is multibyte, this may be greater than the length of STRING. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); return make_number (SBYTES (string)); @@ -221,8 +209,7 @@ DEFUN ("string-equal", Fstring_equal, Sstring_equal, 2, 2, 0, doc: /* Return t if two strings have identical contents. Case is significant, but text properties are ignored. Symbols are also allowed; their print names are used instead. */) - (s1, s2) - register Lisp_Object s1, s2; + (register Lisp_Object s1, Lisp_Object s2) { if (SYMBOLP (s1)) s1 = SYMBOL_NAME (s1); @@ -233,7 +220,7 @@ Symbols are also allowed; their print names are used instead. */) if (SCHARS (s1) != SCHARS (s2) || SBYTES (s1) != SBYTES (s2) - || bcmp (SDATA (s1), SDATA (s2), SBYTES (s1))) + || memcmp (SDATA (s1), SDATA (s2), SBYTES (s1))) return Qnil; return Qt; } @@ -252,11 +239,10 @@ If string STR1 is less, the value is a negative number N; - 1 - N is the number of characters that match at the beginning. If string STR1 is greater, the value is a positive number N; N - 1 is the number of characters that match at the beginning. */) - (str1, start1, end1, str2, start2, end2, ignore_case) - Lisp_Object str1, start1, end1, start2, str2, end2, ignore_case; + (Lisp_Object str1, Lisp_Object start1, Lisp_Object end1, Lisp_Object str2, Lisp_Object start2, Lisp_Object end2, Lisp_Object ignore_case) { - register int end1_char, end2_char; - register int i1, i1_byte, i2, i2_byte; + register EMACS_INT end1_char, end2_char; + register EMACS_INT i1, i1_byte, i2, i2_byte; CHECK_STRING (str1); CHECK_STRING (str2); @@ -344,11 +330,10 @@ DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, doc: /* Return t if first arg string is less than second in lexicographic order. Case is significant. Symbols are also allowed; their print names are used instead. */) - (s1, s2) - register Lisp_Object s1, s2; + (register Lisp_Object s1, Lisp_Object s2) { - register int end; - register int i1, i1_byte, i2, i2_byte; + register EMACS_INT end; + register EMACS_INT i1, i1_byte, i2, i2_byte; if (SYMBOLP (s1)) s1 = SYMBOL_NAME (s1); @@ -378,44 +363,28 @@ Symbols are also allowed; their print names are used instead. */) return i1 < SCHARS (s2) ? Qt : Qnil; } -#if __GNUC__ -/* "gcc -O3" enables automatic function inlining, which optimizes out - the arguments for the invocations of this function, whereas it - expects these values on the stack. */ -static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)) __attribute__((noinline)); -#else /* !__GNUC__ */ -static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)); -#endif +static Lisp_Object concat (int nargs, Lisp_Object *args, + enum Lisp_Type target_type, int last_special); /* ARGSUSED */ Lisp_Object -concat2 (s1, s2) - Lisp_Object s1, s2; +concat2 (Lisp_Object s1, Lisp_Object s2) { -#ifdef NO_ARG_ARRAY Lisp_Object args[2]; args[0] = s1; args[1] = s2; return concat (2, args, Lisp_String, 0); -#else - return concat (2, &s1, Lisp_String, 0); -#endif /* NO_ARG_ARRAY */ } /* ARGSUSED */ Lisp_Object -concat3 (s1, s2, s3) - Lisp_Object s1, s2, s3; +concat3 (Lisp_Object s1, Lisp_Object s2, Lisp_Object s3) { -#ifdef NO_ARG_ARRAY Lisp_Object args[3]; args[0] = s1; args[1] = s2; args[2] = s3; return concat (3, args, Lisp_String, 0); -#else - return concat (3, &s1, Lisp_String, 0); -#endif /* NO_ARG_ARRAY */ } DEFUN ("append", Fappend, Sappend, 0, MANY, 0, @@ -424,9 +393,7 @@ The result is a list whose elements are the elements of all the arguments. Each argument may be a list, vector or string. The last argument is not copied, just used as the tail of the new list. usage: (append &rest SEQUENCES) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_Cons, 1); } @@ -436,9 +403,7 @@ DEFUN ("concat", Fconcat, Sconcat, 0, MANY, 0, The result is a string whose elements are the elements of all the arguments. Each argument may be a string or a list or vector of characters (integers). usage: (concat &rest SEQUENCES) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_String, 0); } @@ -448,9 +413,7 @@ DEFUN ("vconcat", Fvconcat, Svconcat, 0, MANY, 0, The result is a vector whose elements are the elements of all the arguments. Each argument may be a list, vector or string. usage: (vconcat &rest SEQUENCES) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_Vectorlike, 0); } @@ -460,8 +423,7 @@ DEFUN ("copy-sequence", Fcopy_sequence, Scopy_sequence, 1, 1, 0, doc: /* Return a copy of a list, vector, string or char-table. The elements of a list or vector are not copied; they are shared with the original. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { if (NILP (arg)) return arg; @@ -478,8 +440,8 @@ with the original. */) / BOOL_VECTOR_BITS_PER_CHAR); val = Fmake_bool_vector (Flength (arg), Qnil); - bcopy (XBOOL_VECTOR (arg)->data, XBOOL_VECTOR (val)->data, - size_in_chars); + memcpy (XBOOL_VECTOR (val)->data, XBOOL_VECTOR (arg)->data, + size_in_chars); return val; } @@ -494,24 +456,20 @@ with the original. */) struct textprop_rec { int argnum; /* refer to ARGS (arguments of `concat') */ - int from; /* refer to ARGS[argnum] (argument string) */ - int to; /* refer to VAL (the target string) */ + EMACS_INT from; /* refer to ARGS[argnum] (argument string) */ + EMACS_INT to; /* refer to VAL (the target string) */ }; static Lisp_Object -concat (nargs, args, target_type, last_special) - int nargs; - Lisp_Object *args; - enum Lisp_Type target_type; - int last_special; +concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special) { Lisp_Object val; register Lisp_Object tail; register Lisp_Object this; - int toindex; - int toindex_byte = 0; - register int result_len; - register int result_len_byte; + EMACS_INT toindex; + EMACS_INT toindex_byte = 0; + register EMACS_INT result_len; + register EMACS_INT result_len_byte; register int argnum; Lisp_Object last_tail; Lisp_Object prev; @@ -555,16 +513,16 @@ concat (nargs, args, target_type, last_special) some_multibyte = 0; for (argnum = 0; argnum < nargs; argnum++) { - int len; + EMACS_INT len; this = args[argnum]; len = XFASTINT (Flength (this)); if (target_type == Lisp_String) { /* We must count the number of bytes needed in the string as well as the number of characters. */ - int i; + EMACS_INT i; Lisp_Object ch; - int this_len_byte; + EMACS_INT this_len_byte; if (VECTORP (this)) for (i = 0; i < len; i++) @@ -636,9 +594,9 @@ concat (nargs, args, target_type, last_special) for (argnum = 0; argnum < nargs; argnum++) { Lisp_Object thislen; - int thisleni = 0; - register unsigned int thisindex = 0; - register unsigned int thisindex_byte = 0; + EMACS_INT thisleni = 0; + register EMACS_INT thisindex = 0; + register EMACS_INT thisindex_byte = 0; this = args[argnum]; if (!CONSP (this)) @@ -648,10 +606,9 @@ concat (nargs, args, target_type, last_special) if (STRINGP (this) && STRINGP (val) && STRING_MULTIBYTE (this) == some_multibyte) { - int thislen_byte = SBYTES (this); + EMACS_INT thislen_byte = SBYTES (this); - bcopy (SDATA (this), SDATA (val) + toindex_byte, - SBYTES (this)); + memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); if (! NULL_INTERVAL_P (STRING_INTERVALS (this))) { textprops[num_textprops].argnum = argnum; @@ -756,7 +713,7 @@ concat (nargs, args, target_type, last_special) if (num_textprops > 0) { Lisp_Object props; - int last_to_end = -1; + EMACS_INT last_to_end = -1; for (argnum = 0; argnum < num_textprops; argnum++) { @@ -784,7 +741,7 @@ static EMACS_INT string_char_byte_cache_charpos; static EMACS_INT string_char_byte_cache_bytepos; void -clear_string_char_byte_cache () +clear_string_char_byte_cache (void) { string_char_byte_cache_string = Qnil; } @@ -792,9 +749,7 @@ clear_string_char_byte_cache () /* Return the byte index corresponding to CHAR_INDEX in STRING. */ EMACS_INT -string_char_to_byte (string, char_index) - Lisp_Object string; - EMACS_INT char_index; +string_char_to_byte (Lisp_Object string, EMACS_INT char_index) { EMACS_INT i_byte; EMACS_INT best_below, best_below_byte; @@ -854,9 +809,7 @@ string_char_to_byte (string, char_index) /* Return the character index corresponding to BYTE_INDEX in STRING. */ EMACS_INT -string_byte_to_char (string, byte_index) - Lisp_Object string; - EMACS_INT byte_index; +string_byte_to_char (Lisp_Object string, EMACS_INT byte_index) { EMACS_INT i, i_byte; EMACS_INT best_below, best_below_byte; @@ -920,8 +873,7 @@ string_byte_to_char (string, byte_index) /* Convert STRING to a multibyte string. */ Lisp_Object -string_make_multibyte (string) - Lisp_Object string; +string_make_multibyte (Lisp_Object string) { unsigned char *buf; EMACS_INT nbytes; @@ -954,8 +906,7 @@ string_make_multibyte (string) converted to eight-bit characters. */ Lisp_Object -string_to_multibyte (string) - Lisp_Object string; +string_to_multibyte (Lisp_Object string) { unsigned char *buf; EMACS_INT nbytes; @@ -972,7 +923,7 @@ string_to_multibyte (string) return make_multibyte_string (SDATA (string), nbytes, nbytes); SAFE_ALLOCA (buf, unsigned char *, nbytes); - bcopy (SDATA (string), buf, SBYTES (string)); + memcpy (buf, SDATA (string), SBYTES (string)); str_to_multibyte (buf, nbytes, SBYTES (string)); ret = make_multibyte_string (buf, SCHARS (string), nbytes); @@ -985,10 +936,9 @@ string_to_multibyte (string) /* Convert STRING to a single-byte string. */ Lisp_Object -string_make_unibyte (string) - Lisp_Object string; +string_make_unibyte (Lisp_Object string) { - int nchars; + EMACS_INT nchars; unsigned char *buf; Lisp_Object ret; USE_SAFE_ALLOCA; @@ -1019,8 +969,7 @@ or entirely ASCII, it is returned unchanged. In particular, when STRING is unibyte and entirely ASCII, the returned string is unibyte. \(When the characters are all ASCII, Emacs primitives will treat the string the same way whether it is unibyte or multibyte.) */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); @@ -1034,8 +983,7 @@ Multibyte character codes are converted to unibyte according to `nonascii-translation-table' or, if that is nil, `nonascii-insert-offset'. If the lookup in the translation table fails, this function takes just the low 8 bits of each character. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); @@ -1049,17 +997,16 @@ If STRING is unibyte, the result is STRING itself. Otherwise it is a newly created string, with no text properties. If STRING is multibyte and contains a character of charset `eight-bit', it is converted to the corresponding single byte. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); if (STRING_MULTIBYTE (string)) { - int bytes = SBYTES (string); + EMACS_INT bytes = SBYTES (string); unsigned char *str = (unsigned char *) xmalloc (bytes); - bcopy (SDATA (string), str, bytes); + memcpy (str, SDATA (string), bytes); bytes = str_as_unibyte (str, bytes); string = make_unibyte_string (str, bytes); xfree (str); @@ -1082,22 +1029,20 @@ Beware, this often doesn't really do what you think it does. It is similar to (decode-coding-string STRING 'utf-8-emacs). If you're not sure, whether to use `string-as-multibyte' or `string-to-multibyte', use `string-to-multibyte'. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); if (! STRING_MULTIBYTE (string)) { Lisp_Object new_string; - int nchars, nbytes; + EMACS_INT nchars, nbytes; parse_str_as_multibyte (SDATA (string), SBYTES (string), &nchars, &nbytes); new_string = make_uninit_multibyte_string (nchars, nbytes); - bcopy (SDATA (string), SDATA (new_string), - SBYTES (string)); + memcpy (SDATA (new_string), SDATA (string), SBYTES (string)); if (nbytes != SBYTES (string)) str_as_multibyte (SDATA (new_string), nbytes, SBYTES (string), NULL); @@ -1119,8 +1064,7 @@ the corresponding multibyte character of charset `eight-bit'. This differs from `string-as-multibyte' by converting each byte of a correct utf-8 sequence to an eight-bit character, not just bytes that don't form a correct sequence. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); @@ -1135,8 +1079,7 @@ Otherwise it is a newly created string, with no text properties, where each `eight-bit' character is converted to the corresponding byte. If STRING contains a non-ASCII, non-`eight-bit' character, an error is signaled. */) - (string) - Lisp_Object string; + (Lisp_Object string) { CHECK_STRING (string); @@ -1162,8 +1105,7 @@ but does not share the alist structure with ALIST. The objects mapped (cars and cdrs of elements of the alist) are shared, however. Elements of ALIST that are not conses are also shared. */) - (alist) - Lisp_Object alist; + (Lisp_Object alist) { register Lisp_Object tem; @@ -1193,15 +1135,13 @@ to the end of STRING. The STRING argument may also be a vector. In that case, the return value is a new vector that contains the elements between index FROM \(inclusive) and index TO (exclusive) of that vector argument. */) - (string, from, to) - Lisp_Object string; - register Lisp_Object from, to; + (Lisp_Object string, register Lisp_Object from, Lisp_Object to) { Lisp_Object res; - int size; - int size_byte = 0; - int from_char, to_char; - int from_byte = 0, to_byte = 0; + EMACS_INT size; + EMACS_INT size_byte = 0; + EMACS_INT from_char, to_char; + EMACS_INT from_byte = 0, to_byte = 0; CHECK_VECTOR_OR_STRING (string); CHECK_NUMBER (from); @@ -1264,13 +1204,11 @@ If FROM is nil or omitted, the substring starts at the beginning of STRING. If FROM or TO is negative, it counts from the end. With one argument, just copy STRING without its properties. */) - (string, from, to) - Lisp_Object string; - register Lisp_Object from, to; + (Lisp_Object string, register Lisp_Object from, Lisp_Object to) { - int size, size_byte; - int from_char, to_char; - int from_byte, to_byte; + EMACS_INT size, size_byte; + EMACS_INT from_char, to_char; + EMACS_INT from_byte, to_byte; CHECK_STRING (string); @@ -1318,13 +1256,12 @@ With one argument, just copy STRING without its properties. */) both in characters and in bytes. */ Lisp_Object -substring_both (string, from, from_byte, to, to_byte) - Lisp_Object string; - int from, from_byte, to, to_byte; +substring_both (Lisp_Object string, EMACS_INT from, EMACS_INT from_byte, + EMACS_INT to, EMACS_INT to_byte) { Lisp_Object res; - int size; - int size_byte; + EMACS_INT size; + EMACS_INT size_byte; CHECK_VECTOR_OR_STRING (string); @@ -1355,9 +1292,7 @@ substring_both (string, from, from_byte, to, to_byte) DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, doc: /* Take cdr N times on LIST, return the result. */) - (n, list) - Lisp_Object n; - register Lisp_Object list; + (Lisp_Object n, Lisp_Object list) { register int i, num; CHECK_NUMBER (n); @@ -1374,16 +1309,14 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0, DEFUN ("nth", Fnth, Snth, 2, 2, 0, doc: /* Return the Nth element of LIST. N counts from zero. If LIST is not that long, nil is returned. */) - (n, list) - Lisp_Object n, list; + (Lisp_Object n, Lisp_Object list) { return Fcar (Fnthcdr (n, list)); } DEFUN ("elt", Felt, Selt, 2, 2, 0, doc: /* Return element of SEQUENCE at index N. */) - (sequence, n) - register Lisp_Object sequence, n; + (register Lisp_Object sequence, Lisp_Object n) { CHECK_NUMBER (n); if (CONSP (sequence) || NILP (sequence)) @@ -1397,9 +1330,7 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0, DEFUN ("member", Fmember, Smember, 2, 2, 0, doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `equal'. The value is actually the tail of LIST whose car is ELT. */) - (elt, list) - register Lisp_Object elt; - Lisp_Object list; + (register Lisp_Object elt, Lisp_Object list) { register Lisp_Object tail; for (tail = list; CONSP (tail); tail = XCDR (tail)) @@ -1417,8 +1348,7 @@ The value is actually the tail of LIST whose car is ELT. */) DEFUN ("memq", Fmemq, Smemq, 2, 2, 0, doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `eq'. The value is actually the tail of LIST whose car is ELT. */) - (elt, list) - register Lisp_Object elt, list; + (register Lisp_Object elt, Lisp_Object list) { while (1) { @@ -1444,9 +1374,7 @@ The value is actually the tail of LIST whose car is ELT. */) DEFUN ("memql", Fmemql, Smemql, 2, 2, 0, doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `eql'. The value is actually the tail of LIST whose car is ELT. */) - (elt, list) - register Lisp_Object elt; - Lisp_Object list; + (register Lisp_Object elt, Lisp_Object list) { register Lisp_Object tail; @@ -1469,8 +1397,7 @@ DEFUN ("assq", Fassq, Sassq, 2, 2, 0, doc: /* Return non-nil if KEY is `eq' to the car of an element of LIST. The value is actually the first element of LIST whose car is KEY. Elements of LIST that are not conses are ignored. */) - (key, list) - Lisp_Object key, list; + (Lisp_Object key, Lisp_Object list) { while (1) { @@ -1502,8 +1429,7 @@ Elements of LIST that are not conses are ignored. */) Use only on lists known never to be circular. */ Lisp_Object -assq_no_quit (key, list) - Lisp_Object key, list; +assq_no_quit (Lisp_Object key, Lisp_Object list) { while (CONSP (list) && (!CONSP (XCAR (list)) @@ -1516,8 +1442,7 @@ assq_no_quit (key, list) DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0, doc: /* Return non-nil if KEY is `equal' to the car of an element of LIST. The value is actually the first element of LIST whose car equals KEY. */) - (key, list) - Lisp_Object key, list; + (Lisp_Object key, Lisp_Object list) { Lisp_Object car; @@ -1554,8 +1479,7 @@ The value is actually the first element of LIST whose car equals KEY. */) Use only on lists known never to be circular. */ Lisp_Object -assoc_no_quit (key, list) - Lisp_Object key, list; +assoc_no_quit (Lisp_Object key, Lisp_Object list) { while (CONSP (list) && (!CONSP (XCAR (list)) @@ -1569,9 +1493,7 @@ assoc_no_quit (key, list) DEFUN ("rassq", Frassq, Srassq, 2, 2, 0, doc: /* Return non-nil if KEY is `eq' to the cdr of an element of LIST. The value is actually the first element of LIST whose cdr is KEY. */) - (key, list) - register Lisp_Object key; - Lisp_Object list; + (register Lisp_Object key, Lisp_Object list) { while (1) { @@ -1602,8 +1524,7 @@ The value is actually the first element of LIST whose cdr is KEY. */) DEFUN ("rassoc", Frassoc, Srassoc, 2, 2, 0, doc: /* Return non-nil if KEY is `equal' to the cdr of an element of LIST. The value is actually the first element of LIST whose cdr equals KEY. */) - (key, list) - Lisp_Object key, list; + (Lisp_Object key, Lisp_Object list) { Lisp_Object cdr; @@ -1642,9 +1563,7 @@ The modified LIST is returned. Comparison is done with `eq'. If the first member of LIST is ELT, there is no way to remove it by side effect; therefore, write `(setq foo (delq element foo))' to be sure of changing the value of `foo'. */) - (elt, list) - register Lisp_Object elt; - Lisp_Object list; + (register Lisp_Object elt, Lisp_Object list) { register Lisp_Object tail, prev; register Lisp_Object tem; @@ -1678,8 +1597,7 @@ If SEQ is not a list, or the first member of SEQ is ELT, deleting it is not a side effect; it is simply using a different sequence. Therefore, write `(setq foo (delete element foo))' to be sure of changing the value of `foo'. */) - (elt, seq) - Lisp_Object elt, seq; + (Lisp_Object elt, Lisp_Object seq) { if (VECTORP (seq)) { @@ -1794,8 +1712,7 @@ to be sure of changing the value of `foo'. */) DEFUN ("nreverse", Fnreverse, Snreverse, 1, 1, 0, doc: /* Reverse LIST by modifying cdr pointers. Return the reversed list. */) - (list) - Lisp_Object list; + (Lisp_Object list) { register Lisp_Object prev, tail, next; @@ -1817,8 +1734,7 @@ Return the reversed list. */) DEFUN ("reverse", Freverse, Sreverse, 1, 1, 0, doc: /* Reverse LIST, copying. Return the reversed list. See also the function `nreverse', which is used more often. */) - (list) - Lisp_Object list; + (Lisp_Object list) { Lisp_Object new; @@ -1831,15 +1747,14 @@ See also the function `nreverse', which is used more often. */) return new; } -Lisp_Object merge (); +Lisp_Object merge (Lisp_Object org_l1, Lisp_Object org_l2, Lisp_Object pred); DEFUN ("sort", Fsort, Ssort, 2, 2, 0, doc: /* Sort LIST, stably, comparing elements using PREDICATE. Returns the sorted list. LIST is modified by side effects. PREDICATE is called with two elements of LIST, and should return non-nil if the first element should sort before the second. */) - (list, predicate) - Lisp_Object list, predicate; + (Lisp_Object list, Lisp_Object predicate) { Lisp_Object front, back; register Lisp_Object len, tem; @@ -1865,9 +1780,7 @@ if the first element should sort before the second. */) } Lisp_Object -merge (org_l1, org_l2, pred) - Lisp_Object org_l1, org_l2; - Lisp_Object pred; +merge (Lisp_Object org_l1, Lisp_Object org_l2, Lisp_Object pred) { Lisp_Object value; register Lisp_Object tail; @@ -1933,9 +1846,7 @@ PLIST is a property list, which is a list of the form \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value corresponding to the given PROP, or nil if PROP is not one of the properties on the list. This function never signals an error. */) - (plist, prop) - Lisp_Object plist; - Lisp_Object prop; + (Lisp_Object plist, Lisp_Object prop) { Lisp_Object tail, halftail; @@ -1965,8 +1876,7 @@ properties on the list. This function never signals an error. */) DEFUN ("get", Fget, Sget, 2, 2, 0, doc: /* Return the value of SYMBOL's PROPNAME property. This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */) - (symbol, propname) - Lisp_Object symbol, propname; + (Lisp_Object symbol, Lisp_Object propname) { CHECK_SYMBOL (symbol); return Fplist_get (XSYMBOL (symbol)->plist, propname); @@ -1980,10 +1890,7 @@ If PROP is already a property on the list, its value is set to VAL, otherwise the new PROP VAL pair is added. The new plist is returned; use `(setq x (plist-put x prop val))' to be sure to use the new value. The PLIST is modified by side effects. */) - (plist, prop, val) - Lisp_Object plist; - register Lisp_Object prop; - Lisp_Object val; + (Lisp_Object plist, register Lisp_Object prop, Lisp_Object val) { register Lisp_Object tail, prev; Lisp_Object newcell; @@ -2011,8 +1918,7 @@ The PLIST is modified by side effects. */) DEFUN ("put", Fput, Sput, 3, 3, 0, doc: /* Store SYMBOL's PROPNAME property with value VALUE. It can be retrieved with `(get SYMBOL PROPNAME)'. */) - (symbol, propname, value) - Lisp_Object symbol, propname, value; + (Lisp_Object symbol, Lisp_Object propname, Lisp_Object value) { CHECK_SYMBOL (symbol); XSYMBOL (symbol)->plist @@ -2026,9 +1932,7 @@ PLIST is a property list, which is a list of the form \(PROP1 VALUE1 PROP2 VALUE2...). This function returns the value corresponding to the given PROP, or nil if PROP is not one of the properties on the list. */) - (plist, prop) - Lisp_Object plist; - Lisp_Object prop; + (Lisp_Object plist, Lisp_Object prop) { Lisp_Object tail; @@ -2055,10 +1959,7 @@ If PROP is already a property on the list, its value is set to VAL, otherwise the new PROP VAL pair is added. The new plist is returned; use `(setq x (lax-plist-put x prop val))' to be sure to use the new value. The PLIST is modified by side effects. */) - (plist, prop, val) - Lisp_Object plist; - register Lisp_Object prop; - Lisp_Object val; + (Lisp_Object plist, register Lisp_Object prop, Lisp_Object val) { register Lisp_Object tail, prev; Lisp_Object newcell; @@ -2086,8 +1987,7 @@ The PLIST is modified by side effects. */) DEFUN ("eql", Feql, Seql, 2, 2, 0, doc: /* Return t if the two args are the same Lisp object. Floating-point numbers of equal value are `eql', but they may not be `eq'. */) - (obj1, obj2) - Lisp_Object obj1, obj2; + (Lisp_Object obj1, Lisp_Object obj2) { if (FLOATP (obj1)) return internal_equal (obj1, obj2, 0, 0) ? Qt : Qnil; @@ -2103,8 +2003,7 @@ Vectors and strings are compared element by element. Numbers are compared by value, but integers cannot equal floats. (Use `=' if you want integers and floats to be able to be equal.) Symbols must match exactly. */) - (o1, o2) - register Lisp_Object o1, o2; + (register Lisp_Object o1, Lisp_Object o2) { return internal_equal (o1, o2, 0, 0) ? Qt : Qnil; } @@ -2113,8 +2012,7 @@ DEFUN ("equal-including-properties", Fequal_including_properties, Sequal_includi doc: /* Return t if two Lisp objects have similar structure and contents. This is like `equal' except that it compares the text properties of strings. (`equal' ignores text properties.) */) - (o1, o2) - register Lisp_Object o1, o2; + (register Lisp_Object o1, Lisp_Object o2) { return internal_equal (o1, o2, 0, 1) ? Qt : Qnil; } @@ -2124,9 +2022,7 @@ of strings. (`equal' ignores text properties.) */) PROPS, if non-nil, means compare string text properties too. */ static int -internal_equal (o1, o2, depth, props) - register Lisp_Object o1, o2; - int depth, props; +internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int props) { if (depth > 200) error ("Stack overflow in equal"); @@ -2198,8 +2094,8 @@ internal_equal (o1, o2, depth, props) if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size) return 0; - if (bcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data, - size_in_chars)) + if (memcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data, + size_in_chars)) return 0; return 1; } @@ -2233,8 +2129,7 @@ internal_equal (o1, o2, depth, props) return 0; if (SBYTES (o1) != SBYTES (o2)) return 0; - if (bcmp (SDATA (o1), SDATA (o2), - SBYTES (o1))) + if (memcmp (SDATA (o1), SDATA (o2), SBYTES (o1))) return 0; if (props && !compare_string_intervals (o1, o2)) return 0; @@ -2247,15 +2142,15 @@ internal_equal (o1, o2, depth, props) return 0; } -extern Lisp_Object Fmake_char_internal (); DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0, doc: /* Store each element of ARRAY with ITEM. ARRAY is a vector, string, char-table, or bool-vector. */) - (array, item) - Lisp_Object array, item; + (Lisp_Object array, Lisp_Object item) { - register int size, index, charval; + register EMACS_INT size, index; + int charval; + if (VECTORP (array)) { register Lisp_Object *p = XVECTOR (array)->contents; @@ -2281,14 +2176,14 @@ ARRAY is a vector, string, char-table, or bool-vector. */) { unsigned char str[MAX_MULTIBYTE_LENGTH]; int len = CHAR_STRING (charval, str); - int size_byte = SBYTES (array); + EMACS_INT size_byte = SBYTES (array); unsigned char *p1 = p, *endp = p + size_byte; int i; if (size != size_byte) while (p1 < endp) { - int this_len = MULTIBYTE_FORM_LENGTH (p1, endp - p1); + int this_len = BYTES_BY_CHAR_HEAD (*p1); if (len != this_len) error ("Attempt to change byte length of a string"); p1 += this_len; @@ -2327,13 +2222,12 @@ DEFUN ("clear-string", Fclear_string, Sclear_string, 1, 1, 0, doc: /* Clear the contents of STRING. This makes STRING unibyte and may change its length. */) - (string) - Lisp_Object string; + (Lisp_Object string) { - int len; + EMACS_INT len; CHECK_STRING (string); len = SBYTES (string); - bzero (SDATA (string), len); + memset (SDATA (string), 0, len); STRING_SET_CHARS (string, len); STRING_SET_UNIBYTE (string); return Qnil; @@ -2341,26 +2235,19 @@ This makes STRING unibyte and may change its length. */) /* ARGSUSED */ Lisp_Object -nconc2 (s1, s2) - Lisp_Object s1, s2; +nconc2 (Lisp_Object s1, Lisp_Object s2) { -#ifdef NO_ARG_ARRAY Lisp_Object args[2]; args[0] = s1; args[1] = s2; return Fnconc (2, args); -#else - return Fnconc (2, &s1); -#endif /* NO_ARG_ARRAY */ } DEFUN ("nconc", Fnconc, Snconc, 0, MANY, 0, doc: /* Concatenate any number of lists by altering them. Only the last argument is not altered, and need not be a list. usage: (nconc &rest LISTS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { register int argnum; register Lisp_Object tail, tem, val; @@ -2401,14 +2288,11 @@ usage: (nconc &rest LISTS) */) LENI is the length of VALS, which should also be the length of SEQ. */ static void -mapcar1 (leni, vals, fn, seq) - int leni; - Lisp_Object *vals; - Lisp_Object fn, seq; +mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq) { register Lisp_Object tail; Lisp_Object dummy; - register int i; + register EMACS_INT i; struct gcpro gcpro1, gcpro2, gcpro3; if (vals) @@ -2450,12 +2334,12 @@ mapcar1 (leni, vals, fn, seq) } else if (STRINGP (seq)) { - int i_byte; + EMACS_INT i_byte; for (i = 0, i_byte = 0; i < leni;) { int c; - int i_before = i; + EMACS_INT i_before = i; FETCH_STRING_CHAR_ADVANCE (c, seq, i, i_byte); XSETFASTINT (dummy, c); @@ -2484,14 +2368,13 @@ DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0, In between each pair of results, stick in SEPARATOR. Thus, " " as SEPARATOR results in spaces between the values returned by FUNCTION. SEQUENCE may be a list, a vector, a bool-vector, or a string. */) - (function, sequence, separator) - Lisp_Object function, sequence, separator; + (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator) { Lisp_Object len; - register int leni; + register EMACS_INT leni; int nargs; register Lisp_Object *args; - register int i; + register EMACS_INT i; struct gcpro gcpro1; Lisp_Object ret; USE_SAFE_ALLOCA; @@ -2525,11 +2408,10 @@ DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, doc: /* Apply FUNCTION to each element of SEQUENCE, and make a list of the results. The result is a list just as long as SEQUENCE. SEQUENCE may be a list, a vector, a bool-vector, or a string. */) - (function, sequence) - Lisp_Object function, sequence; + (Lisp_Object function, Lisp_Object sequence) { register Lisp_Object len; - register int leni; + register EMACS_INT leni; register Lisp_Object *args; Lisp_Object ret; USE_SAFE_ALLOCA; @@ -2553,10 +2435,9 @@ DEFUN ("mapc", Fmapc, Smapc, 2, 2, 0, doc: /* Apply FUNCTION to each element of SEQUENCE for side effects only. Unlike `mapcar', don't accumulate the results. Return SEQUENCE. SEQUENCE may be a list, a vector, a bool-vector, or a string. */) - (function, sequence) - Lisp_Object function, sequence; + (Lisp_Object function, Lisp_Object sequence) { - register int leni; + register EMACS_INT leni; leni = XFASTINT (Flength (sequence)); if (CHAR_TABLE_P (sequence)) @@ -2566,155 +2447,13 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) return sequence; } -/* Anything that calls this function must protect from GC! */ - -DEFUN ("y-or-n-p", Fy_or_n_p, Sy_or_n_p, 1, 1, 0, - doc: /* Ask user a "y or n" question. Return t if answer is "y". -Takes one argument, which is the string to display to ask the question. -It should end in a space; `y-or-n-p' adds `(y or n) ' to it. -No confirmation of the answer is requested; a single character is enough. -Also accepts Space to mean yes, or Delete to mean no. \(Actually, it uses -the bindings in `query-replace-map'; see the documentation of that variable -for more information. In this case, the useful bindings are `act', `skip', -`recenter', and `quit'.\) - -Under a windowing system a dialog box will be used if `last-nonmenu-event' -is nil and `use-dialog-box' is non-nil. */) - (prompt) - Lisp_Object prompt; -{ - register Lisp_Object obj, key, def, map; - register int answer; - Lisp_Object xprompt; - Lisp_Object args[2]; - struct gcpro gcpro1, gcpro2; - int count = SPECPDL_INDEX (); - - specbind (Qcursor_in_echo_area, Qt); - - map = Fsymbol_value (intern ("query-replace-map")); - - CHECK_STRING (prompt); - xprompt = prompt; - GCPRO2 (prompt, xprompt); - -#ifdef HAVE_WINDOW_SYSTEM - if (display_hourglass_p) - cancel_hourglass (); -#endif - - while (1) - { - -#ifdef HAVE_MENUS - if (FRAME_WINDOW_P (SELECTED_FRAME ()) - && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) - && use_dialog_box - && have_menus_p ()) - { - Lisp_Object pane, menu; - redisplay_preserve_echo_area (3); - pane = Fcons (Fcons (build_string ("Yes"), Qt), - Fcons (Fcons (build_string ("No"), Qnil), - Qnil)); - menu = Fcons (prompt, pane); - obj = Fx_popup_dialog (Qt, menu, Qnil); - answer = !NILP (obj); - break; - } -#endif /* HAVE_MENUS */ - cursor_in_echo_area = 1; - choose_minibuf_frame (); - - { - Lisp_Object pargs[3]; - - /* Colorize prompt according to `minibuffer-prompt' face. */ - pargs[0] = build_string ("%s(y or n) "); - pargs[1] = intern ("face"); - pargs[2] = intern ("minibuffer-prompt"); - args[0] = Fpropertize (3, pargs); - args[1] = xprompt; - Fmessage (2, args); - } - - if (minibuffer_auto_raise) - { - Lisp_Object mini_frame; - - mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); - - Fraise_frame (mini_frame); - } - - temporarily_switch_to_single_kboard (SELECTED_FRAME ()); - obj = read_filtered_event (1, 0, 0, 0, Qnil); - cursor_in_echo_area = 0; - /* If we need to quit, quit with cursor_in_echo_area = 0. */ - QUIT; - - key = Fmake_vector (make_number (1), obj); - def = Flookup_key (map, key, Qt); - - if (EQ (def, intern ("skip"))) - { - answer = 0; - break; - } - else if (EQ (def, intern ("act"))) - { - answer = 1; - break; - } - else if (EQ (def, intern ("recenter"))) - { - Frecenter (Qnil); - xprompt = prompt; - continue; - } - else if (EQ (def, intern ("quit"))) - Vquit_flag = Qt; - /* We want to exit this command for exit-prefix, - and this is the only way to do it. */ - else if (EQ (def, intern ("exit-prefix"))) - Vquit_flag = Qt; - - QUIT; - - /* If we don't clear this, then the next call to read_char will - return quit_char again, and we'll enter an infinite loop. */ - Vquit_flag = Qnil; - - Fding (Qnil); - Fdiscard_input (); - if (EQ (xprompt, prompt)) - { - args[0] = build_string ("Please answer y or n. "); - args[1] = prompt; - xprompt = Fconcat (2, args); - } - } - UNGCPRO; - - if (! noninteractive) - { - cursor_in_echo_area = -1; - message_with_string (answer ? "%s(y or n) y" : "%s(y or n) n", - xprompt, 0); - } - - unbind_to (count, Qnil); - return answer ? Qt : Qnil; -} - /* This is how C code calls `yes-or-no-p' and allows the user to redefined it. Anything that calls this function must protect from GC! */ Lisp_Object -do_yes_or_no_p (prompt) - Lisp_Object prompt; +do_yes_or_no_p (Lisp_Object prompt) { return call1 (intern ("yes-or-no-p"), prompt); } @@ -2730,8 +2469,7 @@ and can edit it until it has been confirmed. Under a windowing system a dialog box will be used if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */) - (prompt) - Lisp_Object prompt; + (Lisp_Object prompt) { register Lisp_Object ans; Lisp_Object args[2]; @@ -2803,8 +2541,7 @@ An error is thrown if the load average can't be obtained. In some cases making it work would require Emacs being installed setuid or setgid so that it can read kernel information, and that usually isn't advisable. */) - (use_floats) - Lisp_Object use_floats; + (Lisp_Object use_floats) { double load_ave[3]; int loads = getloadavg (load_ave, 3); @@ -2825,7 +2562,6 @@ advisable. */) } Lisp_Object Vfeatures, Qsubfeatures; -extern Lisp_Object Vafter_load_alist; DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0, doc: /* Return t if FEATURE is present in this Emacs. @@ -2835,8 +2571,7 @@ presence or absence of Emacs or environment extensions. Use `provide' to declare that a feature is available. This function looks at the value of the variable `features'. The optional argument SUBFEATURE can be used to check a specific subfeature of FEATURE. */) - (feature, subfeature) - Lisp_Object feature, subfeature; + (Lisp_Object feature, Lisp_Object subfeature) { register Lisp_Object tem; CHECK_SYMBOL (feature); @@ -2850,8 +2585,7 @@ DEFUN ("provide", Fprovide, Sprovide, 1, 2, 0, doc: /* Announce that FEATURE is a feature of the current Emacs. The optional argument SUBFEATURES should be a list of symbols listing particular subfeatures supported in this version of FEATURE. */) - (feature, subfeatures) - Lisp_Object feature, subfeatures; + (Lisp_Object feature, Lisp_Object subfeatures) { register Lisp_Object tem; CHECK_SYMBOL (feature); @@ -2881,8 +2615,7 @@ particular subfeatures supported in this version of FEATURE. */) Lisp_Object require_nesting_list; Lisp_Object -require_unwind (old_value) - Lisp_Object old_value; +require_unwind (Lisp_Object old_value) { return require_nesting_list = old_value; } @@ -2898,8 +2631,7 @@ If the optional third argument NOERROR is non-nil, then return nil if the file is not found instead of signaling an error. Normally the return value is FEATURE. The normal messages at start and end of loading FILENAME are suppressed. */) - (feature, filename, noerror) - Lisp_Object feature, filename, noerror; + (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror) { register Lisp_Object tem; struct gcpro gcpro1, gcpro2; @@ -2994,8 +2726,7 @@ PLIST is a property list, which is a list of the form Unlike `plist-get', this allows you to distinguish between a missing property and a property with the value nil. The value is actually the tail of PLIST whose car is PROP. */) - (plist, prop) - Lisp_Object plist, prop; + (Lisp_Object plist, Lisp_Object prop) { while (CONSP (plist) && !EQ (XCAR (plist), prop)) { @@ -3009,8 +2740,7 @@ The value is actually the tail of PLIST whose car is PROP. */) DEFUN ("widget-put", Fwidget_put, Swidget_put, 3, 3, 0, doc: /* In WIDGET, set PROPERTY to VALUE. The value can later be retrieved with `widget-get'. */) - (widget, property, value) - Lisp_Object widget, property, value; + (Lisp_Object widget, Lisp_Object property, Lisp_Object value) { CHECK_CONS (widget); XSETCDR (widget, Fplist_put (XCDR (widget), property, value)); @@ -3021,8 +2751,7 @@ DEFUN ("widget-get", Fwidget_get, Swidget_get, 2, 2, 0, doc: /* In WIDGET, get the value of PROPERTY. The value could either be specified when the widget was created, or later with `widget-put'. */) - (widget, property) - Lisp_Object widget, property; + (Lisp_Object widget, Lisp_Object property) { Lisp_Object tmp; @@ -3048,9 +2777,7 @@ DEFUN ("widget-apply", Fwidget_apply, Swidget_apply, 2, MANY, 0, doc: /* Apply the value of WIDGET's PROPERTY to the widget itself. ARGS are passed as extra arguments to the function. usage: (widget-apply WIDGET PROPERTY &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { /* This function can GC. */ Lisp_Object newargs[3]; @@ -3089,8 +2816,7 @@ If the system can't provide such information through a call to See also Info node `(libc)Locales'. The data read from the system are decoded using `locale-coding-system'. */) - (item) - Lisp_Object item; + (Lisp_Object item) { char *str = NULL; #ifdef HAVE_LANGINFO_CODESET @@ -3235,8 +2961,9 @@ static const short base64_char_to_value[128] = base64 characters. */ -static int base64_encode_1 P_ ((const char *, char *, int, int, int)); -static int base64_decode_1 P_ ((const char *, char *, int, int, int *)); +static EMACS_INT base64_encode_1 (const char *, char *, EMACS_INT, int, int); +static EMACS_INT base64_decode_1 (const char *, char *, EMACS_INT, int, + EMACS_INT *); DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2, 3, "r", @@ -3244,13 +2971,12 @@ DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, Return the length of the encoded text. Optional third argument NO-LINE-BREAK means do not break long lines into shorter lines. */) - (beg, end, no_line_break) - Lisp_Object beg, end, no_line_break; + (Lisp_Object beg, Lisp_Object end, Lisp_Object no_line_break) { char *encoded; - int allength, length; - int ibeg, iend, encoded_length; - int old_pos = PT; + EMACS_INT allength, length; + EMACS_INT ibeg, iend, encoded_length; + EMACS_INT old_pos = PT; USE_SAFE_ALLOCA; validate_region (&beg, &end); @@ -3304,10 +3030,9 @@ DEFUN ("base64-encode-string", Fbase64_encode_string, Sbase64_encode_string, doc: /* Base64-encode STRING and return the result. Optional second argument NO-LINE-BREAK means do not break long lines into shorter lines. */) - (string, no_line_break) - Lisp_Object string, no_line_break; + (Lisp_Object string, Lisp_Object no_line_break) { - int allength, length, encoded_length; + EMACS_INT allength, length, encoded_length; char *encoded; Lisp_Object encoded_string; USE_SAFE_ALLOCA; @@ -3343,15 +3068,12 @@ into shorter lines. */) return encoded_string; } -static int -base64_encode_1 (from, to, length, line_break, multibyte) - const char *from; - char *to; - int length; - int line_break; - int multibyte; -{ - int counter = 0, i = 0; +static EMACS_INT +base64_encode_1 (const char *from, char *to, EMACS_INT length, + int line_break, int multibyte) +{ + int counter = 0; + EMACS_INT i = 0; char *e = to; int c; unsigned int value; @@ -3448,14 +3170,13 @@ DEFUN ("base64-decode-region", Fbase64_decode_region, Sbase64_decode_region, doc: /* Base64-decode the region between BEG and END. Return the length of the decoded text. If the region can't be decoded, signal an error and don't modify the buffer. */) - (beg, end) - Lisp_Object beg, end; + (Lisp_Object beg, Lisp_Object end) { - int ibeg, iend, length, allength; + EMACS_INT ibeg, iend, length, allength; char *decoded; - int old_pos = PT; - int decoded_length; - int inserted_chars; + EMACS_INT old_pos = PT; + EMACS_INT decoded_length; + EMACS_INT inserted_chars; int multibyte = !NILP (current_buffer->enable_multibyte_characters); USE_SAFE_ALLOCA; @@ -3509,11 +3230,10 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, 1, 1, 0, doc: /* Base64-decode STRING and return the result. */) - (string) - Lisp_Object string; + (Lisp_Object string) { char *decoded; - int length, decoded_length; + EMACS_INT length, decoded_length; Lisp_Object decoded_string; USE_SAFE_ALLOCA; @@ -3545,19 +3265,15 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, form. If NCHARS_RETRUN is not NULL, store the number of produced characters in *NCHARS_RETURN. */ -static int -base64_decode_1 (from, to, length, multibyte, nchars_return) - const char *from; - char *to; - int length; - int multibyte; - int *nchars_return; -{ - int i = 0; +static EMACS_INT +base64_decode_1 (const char *from, char *to, EMACS_INT length, + int multibyte, EMACS_INT *nchars_return) +{ + EMACS_INT i = 0; /* Used inside READ_QUADRUPLET_BYTE */ char *e = to; unsigned char c; unsigned long value; - int nchars = 0; + EMACS_INT nchars = 0; while (1) { @@ -3663,25 +3379,25 @@ Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value; /* Function prototypes. */ -static struct Lisp_Hash_Table *check_hash_table P_ ((Lisp_Object)); -static int get_key_arg P_ ((Lisp_Object, int, Lisp_Object *, char *)); -static void maybe_resize_hash_table P_ ((struct Lisp_Hash_Table *)); -static int cmpfn_eql P_ ((struct Lisp_Hash_Table *, Lisp_Object, unsigned, - Lisp_Object, unsigned)); -static int cmpfn_equal P_ ((struct Lisp_Hash_Table *, Lisp_Object, unsigned, - Lisp_Object, unsigned)); -static int cmpfn_user_defined P_ ((struct Lisp_Hash_Table *, Lisp_Object, - unsigned, Lisp_Object, unsigned)); -static unsigned hashfn_eq P_ ((struct Lisp_Hash_Table *, Lisp_Object)); -static unsigned hashfn_eql P_ ((struct Lisp_Hash_Table *, Lisp_Object)); -static unsigned hashfn_equal P_ ((struct Lisp_Hash_Table *, Lisp_Object)); -static unsigned hashfn_user_defined P_ ((struct Lisp_Hash_Table *, - Lisp_Object)); -static unsigned sxhash_string P_ ((unsigned char *, int)); -static unsigned sxhash_list P_ ((Lisp_Object, int)); -static unsigned sxhash_vector P_ ((Lisp_Object, int)); -static unsigned sxhash_bool_vector P_ ((Lisp_Object)); -static int sweep_weak_table P_ ((struct Lisp_Hash_Table *, int)); +static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); +static int get_key_arg (Lisp_Object, int, Lisp_Object *, char *); +static void maybe_resize_hash_table (struct Lisp_Hash_Table *); +static int cmpfn_eql (struct Lisp_Hash_Table *, Lisp_Object, unsigned, + Lisp_Object, unsigned); +static int cmpfn_equal (struct Lisp_Hash_Table *, Lisp_Object, unsigned, + Lisp_Object, unsigned); +static int cmpfn_user_defined (struct Lisp_Hash_Table *, Lisp_Object, + unsigned, Lisp_Object, unsigned); +static unsigned hashfn_eq (struct Lisp_Hash_Table *, Lisp_Object); +static unsigned hashfn_eql (struct Lisp_Hash_Table *, Lisp_Object); +static unsigned hashfn_equal (struct Lisp_Hash_Table *, Lisp_Object); +static unsigned hashfn_user_defined (struct Lisp_Hash_Table *, + Lisp_Object); +static unsigned sxhash_string (unsigned char *, int); +static unsigned sxhash_list (Lisp_Object, int); +static unsigned sxhash_vector (Lisp_Object, int); +static unsigned sxhash_bool_vector (Lisp_Object); +static int sweep_weak_table (struct Lisp_Hash_Table *, int); @@ -3693,8 +3409,7 @@ static int sweep_weak_table P_ ((struct Lisp_Hash_Table *, int)); Lisp_Hash_Table. Otherwise, signal an error. */ static struct Lisp_Hash_Table * -check_hash_table (obj) - Lisp_Object obj; +check_hash_table (Lisp_Object obj) { CHECK_HASH_TABLE (obj); return XHASH_TABLE (obj); @@ -3705,8 +3420,7 @@ check_hash_table (obj) number. */ int -next_almost_prime (n) - int n; +next_almost_prime (int n) { if (n % 2 == 0) n += 1; @@ -3725,11 +3439,7 @@ next_almost_prime (n) a DEFUN parameter list. */ static int -get_key_arg (key, nargs, args, used) - Lisp_Object key; - int nargs; - Lisp_Object *args; - char *used; +get_key_arg (Lisp_Object key, int nargs, Lisp_Object *args, char *used) { int i; @@ -3754,10 +3464,7 @@ get_key_arg (key, nargs, args, used) vector that are not copied from VEC are set to INIT. */ Lisp_Object -larger_vector (vec, new_size, init) - Lisp_Object vec; - int new_size; - Lisp_Object init; +larger_vector (Lisp_Object vec, int new_size, Lisp_Object init) { struct Lisp_Vector *v; int i, old_size; @@ -3767,8 +3474,7 @@ larger_vector (vec, new_size, init) xassert (new_size >= old_size); v = allocate_vector (new_size); - bcopy (XVECTOR (vec)->contents, v->contents, - old_size * sizeof *v->contents); + memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents); for (i = old_size; i < new_size; ++i) v->contents[i] = init; XSETVECTOR (vec, v); @@ -3785,10 +3491,7 @@ larger_vector (vec, new_size, init) KEY2 are the same. */ static int -cmpfn_eql (h, key1, hash1, key2, hash2) - struct Lisp_Hash_Table *h; - Lisp_Object key1, key2; - unsigned hash1, hash2; +cmpfn_eql (struct Lisp_Hash_Table *h, Lisp_Object key1, unsigned int hash1, Lisp_Object key2, unsigned int hash2) { return (FLOATP (key1) && FLOATP (key2) @@ -3801,10 +3504,7 @@ cmpfn_eql (h, key1, hash1, key2, hash2) KEY2 are the same. */ static int -cmpfn_equal (h, key1, hash1, key2, hash2) - struct Lisp_Hash_Table *h; - Lisp_Object key1, key2; - unsigned hash1, hash2; +cmpfn_equal (struct Lisp_Hash_Table *h, Lisp_Object key1, unsigned int hash1, Lisp_Object key2, unsigned int hash2) { return hash1 == hash2 && !NILP (Fequal (key1, key2)); } @@ -3815,10 +3515,7 @@ cmpfn_equal (h, key1, hash1, key2, hash2) if KEY1 and KEY2 are the same. */ static int -cmpfn_user_defined (h, key1, hash1, key2, hash2) - struct Lisp_Hash_Table *h; - Lisp_Object key1, key2; - unsigned hash1, hash2; +cmpfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key1, unsigned int hash1, Lisp_Object key2, unsigned int hash2) { if (hash1 == hash2) { @@ -3839,9 +3536,7 @@ cmpfn_user_defined (h, key1, hash1, key2, hash2) in a Lisp integer. */ static unsigned -hashfn_eq (h, key) - struct Lisp_Hash_Table *h; - Lisp_Object key; +hashfn_eq (struct Lisp_Hash_Table *h, Lisp_Object key) { unsigned hash = XUINT (key) ^ XTYPE (key); xassert ((hash & ~INTMASK) == 0); @@ -3854,9 +3549,7 @@ hashfn_eq (h, key) in a Lisp integer. */ static unsigned -hashfn_eql (h, key) - struct Lisp_Hash_Table *h; - Lisp_Object key; +hashfn_eql (struct Lisp_Hash_Table *h, Lisp_Object key) { unsigned hash; if (FLOATP (key)) @@ -3873,9 +3566,7 @@ hashfn_eql (h, key) in a Lisp integer. */ static unsigned -hashfn_equal (h, key) - struct Lisp_Hash_Table *h; - Lisp_Object key; +hashfn_equal (struct Lisp_Hash_Table *h, Lisp_Object key) { unsigned hash = sxhash (key, 0); xassert ((hash & ~INTMASK) == 0); @@ -3888,9 +3579,7 @@ hashfn_equal (h, key) guaranteed to fit in a Lisp integer. */ static unsigned -hashfn_user_defined (h, key) - struct Lisp_Hash_Table *h; - Lisp_Object key; +hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key) { Lisp_Object args[2], hash; @@ -3926,10 +3615,9 @@ hashfn_user_defined (h, key) one of the symbols `key', `value', `key-or-value', or `key-and-value'. */ Lisp_Object -make_hash_table (test, size, rehash_size, rehash_threshold, weak, - user_test, user_hash) - Lisp_Object test, size, rehash_size, rehash_threshold, weak; - Lisp_Object user_test, user_hash; +make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size, + Lisp_Object rehash_threshold, Lisp_Object weak, + Lisp_Object user_test, Lisp_Object user_hash) { struct Lisp_Hash_Table *h; Lisp_Object table; @@ -4014,8 +3702,7 @@ make_hash_table (test, size, rehash_size, rehash_threshold, weak, only the table itself is. */ Lisp_Object -copy_hash_table (h1) - struct Lisp_Hash_Table *h1; +copy_hash_table (struct Lisp_Hash_Table *h1) { Lisp_Object table; struct Lisp_Hash_Table *h2; @@ -4023,7 +3710,7 @@ copy_hash_table (h1) h2 = allocate_hash_table (); next = h2->vec_next; - bcopy (h1, h2, sizeof *h2); + memcpy (h2, h1, sizeof *h2); h2->vec_next = next; h2->key_and_value = Fcopy_sequence (h1->key_and_value); h2->hash = Fcopy_sequence (h1->hash); @@ -4046,8 +3733,7 @@ copy_hash_table (h1) because it's already too large, throw an error. */ static INLINE void -maybe_resize_hash_table (h) - struct Lisp_Hash_Table *h; +maybe_resize_hash_table (struct Lisp_Hash_Table *h) { if (NILP (h->next_free)) { @@ -4112,10 +3798,7 @@ maybe_resize_hash_table (h) matching KEY, or -1 if not found. */ int -hash_lookup (h, key, hash) - struct Lisp_Hash_Table *h; - Lisp_Object key; - unsigned *hash; +hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, unsigned int *hash) { unsigned hash_code; int start_of_bucket; @@ -4149,10 +3832,7 @@ hash_lookup (h, key, hash) Value is the index of the entry in H matching KEY. */ int -hash_put (h, key, value, hash) - struct Lisp_Hash_Table *h; - Lisp_Object key, value; - unsigned hash; +hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value, unsigned int hash) { int start_of_bucket, i; @@ -4182,9 +3862,7 @@ hash_put (h, key, value, hash) /* Remove the entry matching KEY from hash table H, if there is one. */ static void -hash_remove_from_table (h, key) - struct Lisp_Hash_Table *h; - Lisp_Object key; +hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key) { unsigned hash_code; int start_of_bucket; @@ -4232,8 +3910,7 @@ hash_remove_from_table (h, key) /* Clear hash table H. */ void -hash_clear (h) - struct Lisp_Hash_Table *h; +hash_clear (struct Lisp_Hash_Table *h) { if (h->count > 0) { @@ -4262,7 +3939,7 @@ hash_clear (h) ************************************************************************/ void -init_weak_hash_tables () +init_weak_hash_tables (void) { weak_hash_tables = NULL; } @@ -4273,9 +3950,7 @@ init_weak_hash_tables () non-zero if anything was marked. */ static int -sweep_weak_table (h, remove_entries_p) - struct Lisp_Hash_Table *h; - int remove_entries_p; +sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) { int bucket, n, marked; @@ -4363,7 +4038,7 @@ sweep_weak_table (h, remove_entries_p) from Vweak_hash_tables. Called from gc_sweep. */ void -sweep_weak_hash_tables () +sweep_weak_hash_tables (void) { struct Lisp_Hash_Table *h, *used, *next; int marked; @@ -4431,9 +4106,7 @@ sweep_weak_hash_tables () code returned is guaranteed to fit in a Lisp integer. */ static unsigned -sxhash_string (ptr, len) - unsigned char *ptr; - int len; +sxhash_string (unsigned char *ptr, int len) { unsigned char *p = ptr; unsigned char *end = p + len; @@ -4456,9 +4129,7 @@ sxhash_string (ptr, len) list. We don't recurse deeper than SXHASH_MAX_DEPTH in it. */ static unsigned -sxhash_list (list, depth) - Lisp_Object list; - int depth; +sxhash_list (Lisp_Object list, int depth) { unsigned hash = 0; int i; @@ -4486,9 +4157,7 @@ sxhash_list (list, depth) the Lisp structure. */ static unsigned -sxhash_vector (vec, depth) - Lisp_Object vec; - int depth; +sxhash_vector (Lisp_Object vec, int depth) { unsigned hash = ASIZE (vec); int i, n; @@ -4507,8 +4176,7 @@ sxhash_vector (vec, depth) /* Return a hash for bool-vector VECTOR. */ static unsigned -sxhash_bool_vector (vec) - Lisp_Object vec; +sxhash_bool_vector (Lisp_Object vec) { unsigned hash = XBOOL_VECTOR (vec)->size; int i, n; @@ -4525,9 +4193,7 @@ sxhash_bool_vector (vec) structure. Value is an unsigned integer clipped to INTMASK. */ unsigned -sxhash (obj, depth) - Lisp_Object obj; - int depth; +sxhash (Lisp_Object obj, int depth) { unsigned hash; @@ -4598,8 +4264,7 @@ sxhash (obj, depth) DEFUN ("sxhash", Fsxhash, Ssxhash, 1, 1, 0, doc: /* Compute a hash code for OBJ and return it as integer. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { unsigned hash = sxhash (obj, 0); return make_number (hash); @@ -4621,13 +4286,13 @@ keys. Default is `eql'. Predefined are the tests `eq', `eql', and Default is 65. :rehash-size REHASH-SIZE - Indicates how to expand the table when it -fills up. If REHASH-SIZE is an integer, add that many space. If it -is a float, it must be > 1.0, and the new size is computed by -multiplying the old size with that factor. Default is 1.5. +fills up. If REHASH-SIZE is an integer, increase the size by that +amount. If it is a float, it must be > 1.0, and the new size is the +old size multiplied by that factor. Default is 1.5. :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0. Resize the hash table when the ratio (number of entries / table size) -is greater or equal than THRESHOLD. Default is 0.8. +is greater than or equal to THRESHOLD. Default is 0.8. :weakness WEAK -- WEAK must be one of nil, t, `key', `value', `key-or-value', or `key-and-value'. If WEAK is not nil, the table @@ -4638,9 +4303,7 @@ WEAK. WEAK t is equivalent to `key-and-value'. Default value of WEAK is nil. usage: (make-hash-table &rest KEYWORD-ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object test, size, rehash_size, rehash_threshold, weak; Lisp_Object user_test, user_hash; @@ -4650,7 +4313,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */) /* The vector `used' is used to keep track of arguments that have been consumed. */ used = (char *) alloca (nargs * sizeof *used); - bzero (used, nargs * sizeof *used); + memset (used, 0, nargs * sizeof *used); /* See if there's a `:test TEST' among the arguments. */ i = get_key_arg (QCtest, nargs, args, used); @@ -4717,8 +4380,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */) DEFUN ("copy-hash-table", Fcopy_hash_table, Scopy_hash_table, 1, 1, 0, doc: /* Return a copy of hash table TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return copy_hash_table (check_hash_table (table)); } @@ -4726,8 +4388,7 @@ DEFUN ("copy-hash-table", Fcopy_hash_table, Scopy_hash_table, 1, 1, 0, DEFUN ("hash-table-count", Fhash_table_count, Shash_table_count, 1, 1, 0, doc: /* Return the number of elements in TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return make_number (check_hash_table (table)->count); } @@ -4736,8 +4397,7 @@ DEFUN ("hash-table-count", Fhash_table_count, Shash_table_count, 1, 1, 0, DEFUN ("hash-table-rehash-size", Fhash_table_rehash_size, Shash_table_rehash_size, 1, 1, 0, doc: /* Return the current rehash size of TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return check_hash_table (table)->rehash_size; } @@ -4746,8 +4406,7 @@ DEFUN ("hash-table-rehash-size", Fhash_table_rehash_size, DEFUN ("hash-table-rehash-threshold", Fhash_table_rehash_threshold, Shash_table_rehash_threshold, 1, 1, 0, doc: /* Return the current rehash threshold of TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return check_hash_table (table)->rehash_threshold; } @@ -4758,8 +4417,7 @@ DEFUN ("hash-table-size", Fhash_table_size, Shash_table_size, 1, 1, 0, The size can be used as an argument to `make-hash-table' to create a hash table than can hold as many elements as TABLE holds without need for resizing. */) - (table) - Lisp_Object table; + (Lisp_Object table) { struct Lisp_Hash_Table *h = check_hash_table (table); return make_number (HASH_TABLE_SIZE (h)); @@ -4768,8 +4426,7 @@ without need for resizing. */) DEFUN ("hash-table-test", Fhash_table_test, Shash_table_test, 1, 1, 0, doc: /* Return the test TABLE uses. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return check_hash_table (table)->test; } @@ -4778,8 +4435,7 @@ DEFUN ("hash-table-test", Fhash_table_test, Shash_table_test, 1, 1, 0, DEFUN ("hash-table-weakness", Fhash_table_weakness, Shash_table_weakness, 1, 1, 0, doc: /* Return the weakness of TABLE. */) - (table) - Lisp_Object table; + (Lisp_Object table) { return check_hash_table (table)->weak; } @@ -4787,8 +4443,7 @@ DEFUN ("hash-table-weakness", Fhash_table_weakness, Shash_table_weakness, DEFUN ("hash-table-p", Fhash_table_p, Shash_table_p, 1, 1, 0, doc: /* Return t if OBJ is a Lisp hash table object. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { return HASH_TABLE_P (obj) ? Qt : Qnil; } @@ -4796,8 +4451,7 @@ DEFUN ("hash-table-p", Fhash_table_p, Shash_table_p, 1, 1, 0, DEFUN ("clrhash", Fclrhash, Sclrhash, 1, 1, 0, doc: /* Clear hash table TABLE and return it. */) - (table) - Lisp_Object table; + (Lisp_Object table) { hash_clear (check_hash_table (table)); /* Be compatible with XEmacs. */ @@ -4808,8 +4462,7 @@ DEFUN ("clrhash", Fclrhash, Sclrhash, 1, 1, 0, DEFUN ("gethash", Fgethash, Sgethash, 2, 3, 0, doc: /* Look up KEY in TABLE and return its associated value. If KEY is not found, return DFLT which defaults to nil. */) - (key, table, dflt) - Lisp_Object key, table, dflt; + (Lisp_Object key, Lisp_Object table, Lisp_Object dflt) { struct Lisp_Hash_Table *h = check_hash_table (table); int i = hash_lookup (h, key, NULL); @@ -4821,8 +4474,7 @@ DEFUN ("puthash", Fputhash, Sputhash, 3, 3, 0, doc: /* Associate KEY with VALUE in hash table TABLE. If KEY is already present in table, replace its current value with VALUE. */) - (key, value, table) - Lisp_Object key, value, table; + (Lisp_Object key, Lisp_Object value, Lisp_Object table) { struct Lisp_Hash_Table *h = check_hash_table (table); int i; @@ -4840,8 +4492,7 @@ VALUE. */) DEFUN ("remhash", Fremhash, Sremhash, 2, 2, 0, doc: /* Remove KEY from TABLE. */) - (key, table) - Lisp_Object key, table; + (Lisp_Object key, Lisp_Object table) { struct Lisp_Hash_Table *h = check_hash_table (table); hash_remove_from_table (h, key); @@ -4852,8 +4503,7 @@ DEFUN ("remhash", Fremhash, Sremhash, 2, 2, 0, DEFUN ("maphash", Fmaphash, Smaphash, 2, 2, 0, doc: /* Call FUNCTION for all entries in hash table TABLE. FUNCTION is called with two arguments, KEY and VALUE. */) - (function, table) - Lisp_Object function, table; + (Lisp_Object function, Lisp_Object table) { struct Lisp_Hash_Table *h = check_hash_table (table); Lisp_Object args[3]; @@ -4884,8 +4534,7 @@ both arguments are the same. HASH must be a function taking one argument and return an integer that is the hash code of the argument. Hash code computation should use the whole value range of integers, including negative integers. */) - (name, test, hash) - Lisp_Object name, test, hash; + (Lisp_Object name, Lisp_Object test, Lisp_Object hash) { return Fput (name, Qhash_table_test, list2 (test, hash)); } @@ -4925,19 +4574,18 @@ command `prefer-coding-system') is used. If NOERROR is non-nil, silently assume the `raw-text' coding if the guesswork fails. Normally, an error is signaled in such case. */) - (object, start, end, coding_system, noerror) - Lisp_Object object, start, end, coding_system, noerror; + (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror) { unsigned char digest[16]; unsigned char value[33]; int i; - int size; - int size_byte = 0; - int start_char = 0, end_char = 0; - int start_byte = 0, end_byte = 0; - register int b, e; + EMACS_INT size; + EMACS_INT size_byte = 0; + EMACS_INT start_char = 0, end_char = 0; + EMACS_INT start_byte = 0, end_byte = 0; + register EMACS_INT b, e; register struct buffer *bp; - int temp; + EMACS_INT temp; if (STRINGP (object)) { @@ -5121,7 +4769,7 @@ guesswork fails. Normally, an error is signaled in such case. */) void -syms_of_fns () +syms_of_fns (void) { /* Hash table stuff. */ Qhash_table_p = intern_c_string ("hash-table-p"); @@ -5277,7 +4925,6 @@ this variable. */); defsubr (&Smapcar); defsubr (&Smapc); defsubr (&Smapconcat); - defsubr (&Sy_or_n_p); defsubr (&Syes_or_no_p); defsubr (&Sload_average); defsubr (&Sfeaturep); @@ -5297,7 +4944,7 @@ this variable. */); void -init_fns () +init_fns (void) { } diff --git a/src/font.c b/src/font.c index 77f43c81d71..aee6b483353 100644 --- a/src/font.c +++ b/src/font.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <stdlib.h> #include <ctype.h> #include <setjmp.h> @@ -48,10 +47,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "nsterm.h" #endif /* HAVE_NS */ -#ifdef HAVE_NS -extern Lisp_Object Qfontsize; -#endif - Lisp_Object Qopentype; /* Important character set strings. */ @@ -127,12 +122,6 @@ static const struct table_entry width_table[] = { 200, { "ultra-expanded", "ultraexpanded", "wide" }} }; -extern Lisp_Object Qnormal; - -/* Symbols representing keys of normal font properties. */ -extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth; -extern Lisp_Object QCheight, QCsize, QCname; - Lisp_Object QCfoundry, QCadstyle, QCregistry; /* Symbols representing keys of font extra info. */ Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript, QCavgwidth; @@ -175,7 +164,7 @@ static struct font_driver_list *font_driver_list; /* Creaters of font-related Lisp object. */ Lisp_Object -font_make_spec () +font_make_spec (void) { Lisp_Object font_spec; struct font_spec *spec @@ -187,7 +176,7 @@ font_make_spec () } Lisp_Object -font_make_entity () +font_make_entity (void) { Lisp_Object font_entity; struct font_entity *entity @@ -202,10 +191,7 @@ font_make_entity () not nil, copy properties from ENTITY to the font-object. If PIXELSIZE is positive, set the `size' property to PIXELSIZE. */ Lisp_Object -font_make_object (size, entity, pixelsize) - int size; - Lisp_Object entity; - int pixelsize; +font_make_object (int size, Lisp_Object entity, int pixelsize) { Lisp_Object font_object; struct font *font @@ -229,10 +215,10 @@ font_make_object (size, entity, pixelsize) -static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object)); -static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int)); -static Lisp_Object font_matching_entity P_ ((FRAME_PTR, Lisp_Object *, - Lisp_Object)); +static int font_pixel_size (FRAME_PTR f, Lisp_Object); +static Lisp_Object font_open_entity (FRAME_PTR, Lisp_Object, int); +static Lisp_Object font_matching_entity (FRAME_PTR, Lisp_Object *, + Lisp_Object); /* Number of registered font drivers. */ static int num_font_drivers; @@ -245,15 +231,12 @@ static int num_font_drivers; STR. */ Lisp_Object -font_intern_prop (str, len, force_symbol) - char *str; - int len; - int force_symbol; +font_intern_prop (const char *str, int len, int force_symbol) { int i; Lisp_Object tem; Lisp_Object obarray; - int nbytes, nchars; + EMACS_INT nbytes, nchars; if (len == 1 && *str == '*') return Qnil; @@ -290,9 +273,7 @@ font_intern_prop (str, len, force_symbol) /* Return a pixel size of font-spec SPEC on frame F. */ static int -font_pixel_size (f, spec) - FRAME_PTR f; - Lisp_Object spec; +font_pixel_size (FRAME_PTR f, Lisp_Object spec) { #ifdef HAVE_WINDOW_SYSTEM Lisp_Object size = AREF (spec, FONT_SIZE_INDEX); @@ -327,10 +308,7 @@ font_pixel_size (f, spec) VAL is an integer. */ int -font_style_to_value (prop, val, noerror) - enum font_property_index prop; - Lisp_Object val; - int noerror; +font_style_to_value (enum font_property_index prop, Lisp_Object val, int noerror) { Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); int len = ASIZE (table); @@ -395,10 +373,7 @@ font_style_to_value (prop, val, noerror) } Lisp_Object -font_style_symbolic (font, prop, for_face) - Lisp_Object font; - enum font_property_index prop; - int for_face; +font_style_symbolic (Lisp_Object font, enum font_property_index prop, int for_face) { Lisp_Object val = AREF (font, prop); Lisp_Object table, elt; @@ -414,18 +389,12 @@ font_style_symbolic (font, prop, for_face) return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); } -extern Lisp_Object Vface_alternative_font_family_alist; - -extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); - - /* Return ENCODING or a cons of ENCODING and REPERTORY of the font FONTNAME. ENCODING is a charset symbol that specifies the encoding of the font. REPERTORY is a charset symbol or nil. */ Lisp_Object -find_font_encoding (fontname) - Lisp_Object fontname; +find_font_encoding (Lisp_Object fontname) { Lisp_Object tail, elt; @@ -448,9 +417,7 @@ find_font_encoding (fontname) REGISTRY is available, return 0. Otherwise return -1. */ int -font_registry_charsets (registry, encoding, repertory) - Lisp_Object registry; - struct charset **encoding, **repertory; +font_registry_charsets (Lisp_Object registry, struct charset **encoding, struct charset **repertory) { Lisp_Object val; int encoding_id, repertory_id; @@ -508,16 +475,15 @@ font_registry_charsets (registry, encoding, repertory) /* Font property value validaters. See the comment of font_property_table for the meaning of the arguments. */ -static Lisp_Object font_prop_validate P_ ((int, Lisp_Object, Lisp_Object)); -static Lisp_Object font_prop_validate_symbol P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object font_prop_validate_style P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object font_prop_validate_non_neg P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object font_prop_validate_spacing P_ ((Lisp_Object, Lisp_Object)); -static int get_font_prop_index P_ ((Lisp_Object)); +static Lisp_Object font_prop_validate (int, Lisp_Object, Lisp_Object); +static Lisp_Object font_prop_validate_symbol (Lisp_Object, Lisp_Object); +static Lisp_Object font_prop_validate_style (Lisp_Object, Lisp_Object); +static Lisp_Object font_prop_validate_non_neg (Lisp_Object, Lisp_Object); +static Lisp_Object font_prop_validate_spacing (Lisp_Object, Lisp_Object); +static int get_font_prop_index (Lisp_Object); static Lisp_Object -font_prop_validate_symbol (prop, val) - Lisp_Object prop, val; +font_prop_validate_symbol (Lisp_Object prop, Lisp_Object val) { if (STRINGP (val)) val = Fintern (val, Qnil); @@ -530,8 +496,7 @@ font_prop_validate_symbol (prop, val) static Lisp_Object -font_prop_validate_style (style, val) - Lisp_Object style, val; +font_prop_validate_style (Lisp_Object style, Lisp_Object val) { enum font_property_index prop = (EQ (style, QCweight) ? FONT_WEIGHT_INDEX : EQ (style, QCslant) ? FONT_SLANT_INDEX @@ -565,16 +530,14 @@ font_prop_validate_style (style, val) } static Lisp_Object -font_prop_validate_non_neg (prop, val) - Lisp_Object prop, val; +font_prop_validate_non_neg (Lisp_Object prop, Lisp_Object val) { return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) ? val : Qerror); } static Lisp_Object -font_prop_validate_spacing (prop, val) - Lisp_Object prop, val; +font_prop_validate_spacing (Lisp_Object prop, Lisp_Object val) { if (NILP (val) || (NATNUMP (val) && XINT (val) <= FONT_SPACING_CHARCELL)) return val; @@ -595,8 +558,7 @@ font_prop_validate_spacing (prop, val) } static Lisp_Object -font_prop_validate_otf (prop, val) - Lisp_Object prop, val; +font_prop_validate_otf (Lisp_Object prop, Lisp_Object val) { Lisp_Object tail, tmp; int i; @@ -631,14 +593,14 @@ font_prop_validate_otf (prop, val) /* Structure of known font property keys and validater of the values. */ -struct +static const struct { /* Pointer to the key symbol. */ Lisp_Object *key; /* Function to validate PROP's value VAL, or NULL if any value is ok. The value is VAL or its regularized value if VAL is valid, and Qerror if not. */ - Lisp_Object (*validater) P_ ((Lisp_Object prop, Lisp_Object val)); + Lisp_Object (*validater) (Lisp_Object prop, Lisp_Object val); } font_property_table[] = { { &QCtype, font_prop_validate_symbol }, { &QCfoundry, font_prop_validate_symbol }, @@ -667,8 +629,7 @@ struct already known property. */ static int -get_font_prop_index (key) - Lisp_Object key; +get_font_prop_index (Lisp_Object key) { int i; @@ -683,9 +644,7 @@ get_font_prop_index (key) signal an error. The value is VAL or the regularized one. */ static Lisp_Object -font_prop_validate (idx, prop, val) - int idx; - Lisp_Object prop, val; +font_prop_validate (int idx, Lisp_Object prop, Lisp_Object val) { Lisp_Object validated; @@ -710,8 +669,7 @@ font_prop_validate (idx, prop, val) keeping the sorting order. Don't check the validity of VAL. */ Lisp_Object -font_put_extra (font, prop, val) - Lisp_Object font, prop, val; +font_put_extra (Lisp_Object font, Lisp_Object prop, Lisp_Object val) { Lisp_Object extra = AREF (font, FONT_EXTRA_INDEX); Lisp_Object slot = (NILP (extra) ? Qnil : assq_no_quit (prop, extra)); @@ -740,9 +698,9 @@ font_put_extra (font, prop, val) /* Font name parser and unparser */ -static int parse_matrix P_ ((char *)); -static int font_expand_wildcards P_ ((Lisp_Object *, int)); -static int font_parse_name P_ ((char *, Lisp_Object)); +static int parse_matrix (const char *); +static int font_expand_wildcards (Lisp_Object *, int); +static int font_parse_name (char *, Lisp_Object); /* An enumerator for each field of an XLFD font name. */ enum xlfd_field_index @@ -799,8 +757,7 @@ enum xlfd_field_mask -1. */ static int -parse_matrix (p) - char *p; +parse_matrix (const char *p) { double matrix[4]; char *end; @@ -822,9 +779,7 @@ parse_matrix (p) field position by its contents. */ static int -font_expand_wildcards (field, n) - Lisp_Object field[XLFD_LAST_INDEX]; - int n; +font_expand_wildcards (Lisp_Object *field, int n) { /* Copy of FIELD. */ Lisp_Object tmp[XLFD_LAST_INDEX]; @@ -1009,39 +964,6 @@ font_expand_wildcards (field, n) } -#ifdef ENABLE_CHECKING -/* Match a 14-field XLFD pattern against a full XLFD font name. */ -static int -font_match_xlfd (char *pattern, char *name) -{ - while (*pattern && *name) - { - if (*pattern == *name) - pattern++; - else if (*pattern == '*') - if (*name == pattern[1]) - pattern += 2; - else - ; - else - return 0; - name++; - } - return 1; -} - -/* Make sure the font object matches the XLFD font name. */ -static int -font_check_xlfd_parse (Lisp_Object font, char *name) -{ - char name_check[256]; - font_unparse_xlfd (font, 0, name_check, 255); - return font_match_xlfd (name_check, name); -} - -#endif - - /* Parse NAME (null terminated) as XLFD and store information in FONT (font-spec or font-entity). Size property of FONT is set as follows: @@ -1058,9 +980,7 @@ font_check_xlfd_parse (Lisp_Object font, char *name) a fully specified XLFD. */ int -font_parse_xlfd (name, font) - char *name; - Lisp_Object font; +font_parse_xlfd (char *name, Lisp_Object font) { int len = strlen (name); int i, j, n; @@ -1242,11 +1162,7 @@ font_parse_xlfd (name, font) 0, use PIXEL_SIZE instead. */ int -font_unparse_xlfd (font, pixel_size, name, nbytes) - Lisp_Object font; - int pixel_size; - char *name; - int nbytes; +font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes) { char *f[XLFD_REGISTRY_INDEX + 1]; Lisp_Object val; @@ -1389,9 +1305,7 @@ font_unparse_xlfd (font, pixel_size, name, nbytes) This function tries to guess which format it is. */ int -font_parse_fcname (name, font) - char *name; - Lisp_Object font; +font_parse_fcname (char *name, Lisp_Object font) { char *p, *q; char *size_beg = NULL, *size_end = NULL; @@ -1544,7 +1458,7 @@ font_parse_fcname (name, font) int size_found = 1; for (q = p + 1; *q && *q != ' '; q++) - if (! isdigit (*q)) + if (! isdigit (*q) && *q != '.') { size_found = 0; break; @@ -1648,11 +1562,7 @@ font_parse_fcname (name, font) FONT_SIZE_INDEX of FONT is 0, use PIXEL_SIZE instead. */ int -font_unparse_fcname (font, pixel_size, name, nbytes) - Lisp_Object font; - int pixel_size; - char *name; - int nbytes; +font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes) { Lisp_Object family, foundry; Lisp_Object tail, val; @@ -1660,7 +1570,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) int i, len = 1; char *p; Lisp_Object styles[3]; - char *style_names[3] = { "weight", "slant", "width" }; + const char *style_names[3] = { "weight", "slant", "width" }; char work[256]; family = AREF (font, FONT_FAMILY_INDEX); @@ -1771,11 +1681,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes) size. */ int -font_unparse_gtkname (font, f, name, nbytes) - Lisp_Object font; - struct frame *f; - char *name; - int nbytes; +font_unparse_gtkname (Lisp_Object font, struct frame *f, char *name, int nbytes) { char *p; int len = 1; @@ -1858,11 +1764,9 @@ font_unparse_gtkname (font, f, name, nbytes) 0. Otherwise return -1. */ static int -font_parse_name (name, font) - char *name; - Lisp_Object font; +font_parse_name (char *name, Lisp_Object font) { - if (name[0] == '-' || index (name, '*') || index (name, '?')) + if (name[0] == '-' || strchr (name, '*') || strchr (name, '?')) return font_parse_xlfd (name, font); return font_parse_fcname (name, font); } @@ -1873,8 +1777,7 @@ font_parse_name (name, font) part. */ void -font_parse_family_registry (family, registry, font_spec) - Lisp_Object family, registry, font_spec; +font_parse_family_registry (Lisp_Object family, Lisp_Object registry, Lisp_Object font_spec) { int len; char *p0, *p1; @@ -1885,7 +1788,7 @@ font_parse_family_registry (family, registry, font_spec) CHECK_STRING (family); len = SBYTES (family); p0 = (char *) SDATA (family); - p1 = index (p0, '-'); + p1 = strchr (p0, '-'); if (p1) { if ((*p0 != '*' && p1 - p0 > 0) @@ -1904,7 +1807,7 @@ font_parse_family_registry (family, registry, font_spec) CHECK_STRING (registry); len = SBYTES (registry); p0 = (char *) SDATA (registry); - p1 = index (p0, '-'); + p1 = strchr (p0, '-'); if (! p1) { if (SDATA (registry)[len - 1] == '*') @@ -2220,17 +2123,13 @@ font_otf_Anchor (anchor) /* Font sorting */ -static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); -static int font_compare P_ ((const void *, const void *)); -static Lisp_Object font_sort_entities P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, int)); - -/* Return a rescaling ratio of FONT_ENTITY. */ -extern Lisp_Object Vface_font_rescale_alist; +static unsigned font_score (Lisp_Object, Lisp_Object *); +static int font_compare (const void *, const void *); +static Lisp_Object font_sort_entities (Lisp_Object, Lisp_Object, + Lisp_Object, int); static double -font_rescale_ratio (font_entity) - Lisp_Object font_entity; +font_rescale_ratio (Lisp_Object font_entity) { Lisp_Object tail, elt; Lisp_Object name = Qnil; @@ -2277,8 +2176,7 @@ static int sort_shift_bits[FONT_SIZE_INDEX + 1]; SPEC_PROP. */ static unsigned -font_score (entity, spec_prop) - Lisp_Object entity, *spec_prop; +font_score (Lisp_Object entity, Lisp_Object *spec_prop) { unsigned score = 0; int i; @@ -2352,8 +2250,7 @@ struct font_sort_data /* The comparison function for qsort. */ static int -font_compare (d1, d2) - const void *d1, *d2; +font_compare (const void *d1, const void *d2) { const struct font_sort_data *data1 = d1; const struct font_sort_data *data2 = d2; @@ -2381,9 +2278,7 @@ font_compare (d1, d2) such a case. */ static Lisp_Object -font_sort_entities (list, prefer, frame, best_only) - Lisp_Object list, prefer, frame; - int best_only; +font_sort_entities (Lisp_Object list, Lisp_Object prefer, Lisp_Object frame, int best_only) { Lisp_Object prefer_prop[FONT_SPEC_MAX]; int len, maxlen, i; @@ -2488,8 +2383,7 @@ font_sort_entities (list, prefer, frame, best_only) function with font_sort_order after setting up it. */ void -font_update_sort_order (order) - int *order; +font_update_sort_order (int *order) { int i, shift_bits; @@ -2509,8 +2403,7 @@ font_update_sort_order (order) } static int -font_check_otf_features (script, langsys, features, table) - Lisp_Object script, langsys, features, table; +font_check_otf_features (Lisp_Object script, Lisp_Object langsys, Lisp_Object features, Lisp_Object table) { Lisp_Object val; int negative; @@ -2584,8 +2477,7 @@ font_check_otf (Lisp_Object spec, Lisp_Object otf_capability) specification SPEC. */ int -font_match_p (spec, font) - Lisp_Object spec, font; +font_match_p (Lisp_Object spec, Lisp_Object font) { Lisp_Object prop[FONT_SPEC_MAX], *props; Lisp_Object extra, font_extra; @@ -2701,16 +2593,14 @@ font_match_p (spec, font) is a number frames sharing this cache, and FONT-CACHE-DATA is a cons (FONT-SPEC FONT-ENTITY ...). */ -static void font_prepare_cache P_ ((FRAME_PTR, struct font_driver *)); -static void font_finish_cache P_ ((FRAME_PTR, struct font_driver *)); -static Lisp_Object font_get_cache P_ ((FRAME_PTR, struct font_driver *)); -static void font_clear_cache P_ ((FRAME_PTR, Lisp_Object, - struct font_driver *)); +static void font_prepare_cache (FRAME_PTR, struct font_driver *); +static void font_finish_cache (FRAME_PTR, struct font_driver *); +static Lisp_Object font_get_cache (FRAME_PTR, struct font_driver *); +static void font_clear_cache (FRAME_PTR, Lisp_Object, + struct font_driver *); static void -font_prepare_cache (f, driver) - FRAME_PTR f; - struct font_driver *driver; +font_prepare_cache (FRAME_PTR f, struct font_driver *driver) { Lisp_Object cache, val; @@ -2732,9 +2622,7 @@ font_prepare_cache (f, driver) static void -font_finish_cache (f, driver) - FRAME_PTR f; - struct font_driver *driver; +font_finish_cache (FRAME_PTR f, struct font_driver *driver) { Lisp_Object cache, val, tmp; @@ -2755,9 +2643,7 @@ font_finish_cache (f, driver) static Lisp_Object -font_get_cache (f, driver) - FRAME_PTR f; - struct font_driver *driver; +font_get_cache (FRAME_PTR f, struct font_driver *driver) { Lisp_Object val = driver->get_cache (f); Lisp_Object type = driver->type; @@ -2773,10 +2659,7 @@ font_get_cache (f, driver) static int num_fonts; static void -font_clear_cache (f, cache, driver) - FRAME_PTR f; - Lisp_Object cache; - struct font_driver *driver; +font_clear_cache (FRAME_PTR f, Lisp_Object cache, struct font_driver *driver) { Lisp_Object tail, elt; Lisp_Object tail2, entity; @@ -2821,10 +2704,14 @@ font_clear_cache (f, cache, driver) static Lisp_Object scratch_font_spec, scratch_font_prefer; +/* Check each font-entity in VEC, and return a list of font-entities + that satisfy this condition: + (1) matches with SPEC and SIZE if SPEC is not nil, and + (2) doesn't match with any regexps in Vface_ignored_fonts (if non-nil). +*/ + Lisp_Object -font_delete_unmatched (vec, spec, size) - Lisp_Object vec, spec; - int size; +font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size) { Lisp_Object entity, val; enum font_property_index prop; @@ -2833,6 +2720,29 @@ font_delete_unmatched (vec, spec, size) for (val = Qnil, i = ASIZE (vec) - 1; i >= 0; i--) { entity = AREF (vec, i); + if (! NILP (Vface_ignored_fonts)) + { + char name[256]; + Lisp_Object tail, regexp; + + if (font_unparse_xlfd (entity, 0, name, 256) >= 0) + { + for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) + { + regexp = XCAR (tail); + if (STRINGP (regexp) + && fast_c_string_match_ignore_case (regexp, name) >= 0) + break; + } + if (CONSP (tail)) + continue; + } + } + if (NILP (spec)) + { + val = Fcons (entity, val); + continue; + } for (prop = FONT_WEIGHT_INDEX; prop < FONT_SIZE_INDEX; prop++) if (INTEGERP (AREF (spec, prop)) && ((XINT (AREF (spec, prop)) >> 8) @@ -2874,8 +2784,7 @@ font_delete_unmatched (vec, spec, size) same font-driver. */ Lisp_Object -font_list_entities (frame, spec) - Lisp_Object frame, spec; +font_list_entities (Lisp_Object frame, Lisp_Object spec) { FRAME_PTR f = XFRAME (frame); struct font_driver_list *driver_list = f->font_driver_list; @@ -2932,8 +2841,10 @@ font_list_entities (frame, spec) ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); } - if (ASIZE (val) > 0 && need_filtering) - val = font_delete_unmatched (val, spec, size); + if (ASIZE (val) > 0 + && (need_filtering + || ! NILP (Vface_ignored_fonts))) + val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size); if (ASIZE (val) > 0) list = Fcons (val, list); } @@ -2949,9 +2860,7 @@ font_list_entities (frame, spec) font-related attributes. */ static Lisp_Object -font_matching_entity (f, attrs, spec) - FRAME_PTR f; - Lisp_Object *attrs, spec; +font_matching_entity (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec) { struct font_driver_list *driver_list = f->font_driver_list; Lisp_Object ftype, size, entity; @@ -2999,10 +2908,7 @@ font_matching_entity (f, attrs, spec) opened font object. */ static Lisp_Object -font_open_entity (f, entity, pixel_size) - FRAME_PTR f; - Lisp_Object entity; - int pixel_size; +font_open_entity (FRAME_PTR f, Lisp_Object entity, int pixel_size) { struct font_driver_list *driver_list; Lisp_Object objlist, size, val, font_object; @@ -3045,7 +2951,6 @@ font_open_entity (f, entity, pixel_size) return Qnil; ASET (entity, FONT_OBJLIST_INDEX, Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); - ASET (font_object, FONT_OBJLIST_INDEX, Qnil); num_fonts++; font = XFONT_OBJECT (font_object); @@ -3078,9 +2983,7 @@ font_open_entity (f, entity, pixel_size) /* Close FONT_OBJECT that is opened on frame F. */ void -font_close_object (f, font_object) - FRAME_PTR f; - Lisp_Object font_object; +font_close_object (FRAME_PTR f, Lisp_Object font_object) { struct font *font = XFONT_OBJECT (font_object); @@ -3101,10 +3004,7 @@ font_close_object (f, font_object) FONT is a font-entity and it must be opened to check. */ int -font_has_char (f, font, c) - FRAME_PTR f; - Lisp_Object font; - int c; +font_has_char (FRAME_PTR f, Lisp_Object font, int c) { struct font *fontp; @@ -3139,9 +3039,7 @@ font_has_char (f, font, c) /* Return the glyph ID of FONT_OBJECT for character C. */ unsigned -font_encode_char (font_object, c) - Lisp_Object font_object; - int c; +font_encode_char (Lisp_Object font_object, int c) { struct font *font; @@ -3154,8 +3052,7 @@ font_encode_char (font_object, c) /* Return the name of FONT_OBJECT. */ Lisp_Object -font_get_name (font_object) - Lisp_Object font_object; +font_get_name (Lisp_Object font_object) { font_assert (FONT_OBJECT_P (font_object)); return AREF (font_object, FONT_NAME_INDEX); @@ -3165,8 +3062,7 @@ font_get_name (font_object) /* Return the specification of FONT_OBJECT. */ Lisp_Object -font_get_spec (font_object) - Lisp_Object font_object; +font_get_spec (Lisp_Object font_object) { Lisp_Object spec = font_make_spec (); int i; @@ -3183,8 +3079,7 @@ font_get_spec (font_object) could not be parsed by font_parse_name, return Qnil. */ Lisp_Object -font_spec_from_name (font_name) - Lisp_Object font_name; +font_spec_from_name (Lisp_Object font_name) { Lisp_Object spec = Ffont_spec (0, NULL); @@ -3198,9 +3093,7 @@ font_spec_from_name (font_name) void -font_clear_prop (attrs, prop) - Lisp_Object *attrs; - enum font_property_index prop; +font_clear_prop (Lisp_Object *attrs, enum font_property_index prop) { Lisp_Object font = attrs[LFACE_FONT_INDEX]; @@ -3251,9 +3144,7 @@ font_clear_prop (attrs, prop) } void -font_update_lface (f, attrs) - FRAME_PTR f; - Lisp_Object *attrs; +font_update_lface (FRAME_PTR f, Lisp_Object *attrs) { Lisp_Object spec; @@ -3300,9 +3191,7 @@ font_update_lface (f, attrs) supports C and matches best with ATTRS and PIXEL_SIZE. */ static Lisp_Object -font_select_entity (frame, entities, attrs, pixel_size, c) - Lisp_Object frame, entities, *attrs; - int pixel_size, c; +font_select_entity (Lisp_Object frame, Lisp_Object entities, Lisp_Object *attrs, int pixel_size, int c) { Lisp_Object font_entity; Lisp_Object prefer; @@ -3347,11 +3236,7 @@ font_select_entity (frame, entities, attrs, pixel_size, c) character that the entity must support. */ Lisp_Object -font_find_for_lface (f, attrs, spec, c) - FRAME_PTR f; - Lisp_Object *attrs; - Lisp_Object spec; - int c; +font_find_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec, int c) { Lisp_Object work; Lisp_Object frame, entities, val; @@ -3501,11 +3386,7 @@ font_find_for_lface (f, attrs, spec, c) Lisp_Object -font_open_for_lface (f, entity, attrs, spec) - FRAME_PTR f; - Lisp_Object entity; - Lisp_Object *attrs; - Lisp_Object spec; +font_open_for_lface (FRAME_PTR f, Lisp_Object entity, Lisp_Object *attrs, Lisp_Object spec) { int size; @@ -3548,9 +3429,7 @@ font_open_for_lface (f, entity, attrs, spec) font-object. */ Lisp_Object -font_load_for_lface (f, attrs, spec) - FRAME_PTR f; - Lisp_Object *attrs, spec; +font_load_for_lface (FRAME_PTR f, Lisp_Object *attrs, Lisp_Object spec) { Lisp_Object entity, name; @@ -3580,9 +3459,7 @@ font_load_for_lface (f, attrs, spec) /* Make FACE on frame F ready to use the font opened for FACE. */ void -font_prepare_for_face (f, face) - FRAME_PTR f; - struct face *face; +font_prepare_for_face (FRAME_PTR f, struct face *face) { if (face->font->driver->prepare_face) face->font->driver->prepare_face (f, face); @@ -3592,9 +3469,7 @@ font_prepare_for_face (f, face) /* Make FACE on frame F stop using the font opened for FACE. */ void -font_done_for_face (f, face) - FRAME_PTR f; - struct face *face; +font_done_for_face (FRAME_PTR f, struct face *face) { if (face->font->driver->done_face) face->font->driver->done_face (f, face); @@ -3606,9 +3481,7 @@ font_done_for_face (f, face) font is found, return Qnil. */ Lisp_Object -font_open_by_spec (f, spec) - FRAME_PTR f; - Lisp_Object spec; +font_open_by_spec (FRAME_PTR f, Lisp_Object spec) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; @@ -3632,9 +3505,7 @@ font_open_by_spec (f, spec) found, return Qnil. */ Lisp_Object -font_open_by_name (f, name) - FRAME_PTR f; - char *name; +font_open_by_name (FRAME_PTR f, const char *name) { Lisp_Object args[2]; Lisp_Object spec, ret; @@ -3664,9 +3535,7 @@ font_open_by_name (f, name) (e.g. syms_of_xfont). */ void -register_font_driver (driver, f) - struct font_driver *driver; - FRAME_PTR f; +register_font_driver (struct font_driver *driver, FRAME_PTR f) { struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; struct font_driver_list *prev, *list; @@ -3694,8 +3563,7 @@ register_font_driver (driver, f) } void -free_font_driver_list (f) - FRAME_PTR f; +free_font_driver_list (FRAME_PTR f) { struct font_driver_list *list, *next; @@ -3717,9 +3585,7 @@ free_font_driver_list (f) F. */ Lisp_Object -font_update_drivers (f, new_drivers) - FRAME_PTR f; - Lisp_Object new_drivers; +font_update_drivers (FRAME_PTR f, Lisp_Object new_drivers) { Lisp_Object active_drivers = Qnil; struct font_driver *driver; @@ -3810,10 +3676,7 @@ font_update_drivers (f, new_drivers) } int -font_put_frame_data (f, driver, data) - FRAME_PTR f; - struct font_driver *driver; - void *data; +font_put_frame_data (FRAME_PTR f, struct font_driver *driver, void *data) { struct font_data_list *list, *prev; @@ -3847,9 +3710,7 @@ font_put_frame_data (f, driver, data) void * -font_get_frame_data (f, driver) - FRAME_PTR f; - struct font_driver *driver; +font_get_frame_data (FRAME_PTR f, struct font_driver *driver) { struct font_data_list *list; @@ -3868,11 +3729,10 @@ font_get_frame_data (f, driver) arrays of strings. This function is intended for use by the font drivers to implement their specific font_filter_properties. */ void -font_filter_properties (font, alist, boolean_properties, non_boolean_properties) - Lisp_Object font; - Lisp_Object alist; - const char *boolean_properties[]; - const char *non_boolean_properties[]; +font_filter_properties (Lisp_Object font, + Lisp_Object alist, + const char *boolean_properties[], + const char *non_boolean_properties[]) { Lisp_Object it; int i; @@ -3921,12 +3781,7 @@ font_filter_properties (font, alist, boolean_properties, non_boolean_properties) STRING. */ Lisp_Object -font_at (c, pos, face, w, string) - int c; - EMACS_INT pos; - struct face *face; - struct window *w; - Lisp_Object string; +font_at (int c, EMACS_INT pos, struct face *face, struct window *w, Lisp_Object string) { FRAME_PTR f; int multibyte; @@ -4008,13 +3863,9 @@ font_at (c, pos, face, w, string) It is assured that the current buffer (or STRING) is multibyte. */ Lisp_Object -font_range (pos, limit, w, face, string) - EMACS_INT pos, *limit; - struct window *w; - struct face *face; - Lisp_Object string; +font_range (EMACS_INT pos, EMACS_INT *limit, struct window *w, struct face *face, Lisp_Object string) { - EMACS_INT pos_byte, ignore, start, start_byte; + EMACS_INT pos_byte, ignore; int c; Lisp_Object font_object = Qnil; @@ -4036,7 +3887,6 @@ font_range (pos, limit, w, face, string) pos_byte = string_char_to_byte (string, pos); } - start = pos, start_byte = pos_byte; while (pos < *limit) { Lisp_Object category; @@ -4045,6 +3895,10 @@ font_range (pos, limit, w, face, string) FETCH_CHAR_ADVANCE_NO_CHECK (c, pos, pos_byte); else FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, pos, pos_byte); + category = CHAR_TABLE_REF (Vunicode_category_table, c); + if (EQ (category, QCf) + || CHAR_VARIATION_SELECTOR_P (c)) + continue; if (NILP (font_object)) { font_object = font_for_char (face, c, pos - 1, string); @@ -4052,40 +3906,8 @@ font_range (pos, limit, w, face, string) return Qnil; continue; } - - category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! EQ (category, QCf) - && ! CHAR_VARIATION_SELECTOR_P (c) - && font_encode_char (font_object, c) == FONT_INVALID_CODE) - { - Lisp_Object f = font_for_char (face, c, pos - 1, string); - EMACS_INT i, i_byte; - - - if (NILP (f)) - { - *limit = pos - 1; - return font_object; - } - i = start, i_byte = start_byte; - while (i < pos - 1) - { - - if (NILP (string)) - FETCH_CHAR_ADVANCE_NO_CHECK (c, i, i_byte); - else - FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, i, i_byte); - category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! EQ (category, QCf) - && ! CHAR_VARIATION_SELECTOR_P (c) - && font_encode_char (f, c) == FONT_INVALID_CODE) - { - *limit = pos - 1; - return font_object; - } - } - font_object = f; - } + if (font_encode_char (font_object, c) == FONT_INVALID_CODE) + *limit = pos - 1; } return font_object; } @@ -4100,8 +3922,7 @@ Return nil otherwise. Optional 2nd argument EXTRA-TYPE, if non-nil, specifies to check which kind of font it is. It must be one of `font-spec', `font-entity', `font-object'. */) - (object, extra_type) - Lisp_Object object, extra_type; + (Lisp_Object object, Lisp_Object extra_type) { if (NILP (extra_type)) return (FONTP (object) ? Qt : Qnil); @@ -4179,9 +4000,7 @@ be an OpenType font, and whose GPOS table of `thai' script's default language system must contain `mark' feature. usage: (font-spec ARGS...) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object spec = font_make_spec (); int i; @@ -4222,8 +4041,7 @@ usage: (font-spec ARGS...) */) DEFUN ("copy-font-spec", Fcopy_font_spec, Scopy_font_spec, 1, 1, 0, doc: /* Return a copy of FONT as a font-spec. */) - (font) - Lisp_Object font; + (Lisp_Object font) { Lisp_Object new_spec, tail, prev, extra; int i; @@ -4251,8 +4069,7 @@ DEFUN ("merge-font-spec", Fmerge_font_spec, Smerge_font_spec, 2, 2, 0, doc: /* Merge font-specs FROM and TO, and return a new font-spec. Every specified properties in FROM override the corresponding properties in TO. */) - (from, to) - Lisp_Object from, to; + (Lisp_Object from, Lisp_Object to) { Lisp_Object extra, tail; int i; @@ -4280,16 +4097,24 @@ properties in TO. */) DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, doc: /* Return the value of FONT's property KEY. FONT is a font-spec, a font-entity, or a font-object. -KEY must be one of these symbols: +KEY is any symbol, but these are reserved for specific meanings: :family, :weight, :slant, :width, :foundry, :adstyle, :registry, - :size, :name, :script + :size, :name, :script, :otf See the documentation of `font-spec' for their meanings. -If FONT is a font-entity or font-object, the value of :script may be -a list of scripts that are supported by the font. */) - (font, key) - Lisp_Object font, key; +In addition, if FONT is a font-entity or a font-object, values of +:script and :otf are different from those of a font-spec as below: + +The value of :script may be a list of scripts that are supported by the font. + +The value of :otf is a cons (GSUB . GPOS) where GSUB and GPOS are lists +representing the OpenType features supported by the font by this form: + ((SCRIPT (LANGSYS FEATURE ...) ...) ...) +SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType +Layout tags. */) + (Lisp_Object font, Lisp_Object key) { int idx; + Lisp_Object val; CHECK_FONT (font); CHECK_SYMBOL (key); @@ -4299,7 +4124,20 @@ a list of scripts that are supported by the font. */) return font_style_symbolic (font, idx, 0); if (idx >= 0 && idx < FONT_EXTRA_INDEX) return AREF (font, idx); - return Fcdr (Fassq (key, AREF (font, FONT_EXTRA_INDEX))); + val = Fassq (key, AREF (font, FONT_EXTRA_INDEX)); + if (NILP (val) && EQ (key, QCotf) && FONT_OBJECT_P (font)) + { + struct font *fontp = XFONT_OBJECT (font); + + if (fontp->driver->otf_capability) + val = fontp->driver->otf_capability (fontp); + else + val = Fcons (Qnil, Qnil); + font_put_extra (font, QCotf, val); + } + else + val = Fcdr (val); + return val; } #ifdef HAVE_WINDOW_SYSTEM @@ -4317,8 +4155,7 @@ may be omitted from the list if they are not specified by FONT. The optional argument FRAME specifies the frame that the face attributes are to be displayed on. If omitted, the selected frame is used. */) - (font, frame) - Lisp_Object font, frame; + (Lisp_Object font, Lisp_Object frame) { struct frame *f; Lisp_Object plist[10]; @@ -4391,18 +4228,36 @@ are to be displayed on. If omitted, the selected frame is used. */) #endif DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, - doc: /* Set one property of FONT-SPEC: give property PROP value VAL. */) - (font_spec, prop, val) - Lisp_Object font_spec, prop, val; + doc: /* Set one property of FONT: give property KEY value VAL. +FONT is a font-spec, a font-entity, or a font-object. + +If FONT is a font-spec, KEY can be any symbol. But if KEY is the one +accepted by the function `font-spec' (which see), VAL must be what +allowed in `font-spec'. + +If FONT is a font-entity or a font-object, KEY must not be the one +accepted by `font-spec'. */) + (Lisp_Object font, Lisp_Object prop, Lisp_Object val) { int idx; - CHECK_FONT_SPEC (font_spec); idx = get_font_prop_index (prop); if (idx >= 0 && idx < FONT_EXTRA_INDEX) - ASET (font_spec, idx, font_prop_validate (idx, Qnil, val)); + { + CHECK_FONT_SPEC (font); + ASET (font, idx, font_prop_validate (idx, Qnil, val)); + } else - font_put_extra (font_spec, prop, font_prop_validate (0, prop, val)); + { + if (EQ (prop, QCname) + || EQ (prop, QCscript) + || EQ (prop, QClang) + || EQ (prop, QCotf)) + CHECK_FONT_SPEC (font); + else + CHECK_FONT (font); + font_put_extra (font, prop, font_prop_validate (0, prop, val)); + } return val; } @@ -4413,8 +4268,7 @@ Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. Optional 4th argument PREFER, if non-nil, is a font-spec to control the order of the returned list. Fonts are sorted by how close they are to PREFER. */) - (font_spec, frame, num, prefer) - Lisp_Object font_spec, frame, num, prefer; + (Lisp_Object font_spec, Lisp_Object frame, Lisp_Object num, Lisp_Object prefer) { Lisp_Object vec, list; int n = 0; @@ -4463,8 +4317,7 @@ how close they are to PREFER. */) DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0, doc: /* List available font families on the current frame. Optional argument FRAME, if non-nil, specifies the target frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { FRAME_PTR f; struct font_driver_list *driver_list; @@ -4493,8 +4346,7 @@ Optional argument FRAME, if non-nil, specifies the target frame. */) DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, doc: /* Return a font-entity matching with FONT-SPEC on the current frame. Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) - (font_spec, frame) - Lisp_Object font_spec, frame; + (Lisp_Object font_spec, Lisp_Object frame) { Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); @@ -4509,8 +4361,7 @@ FONT is a font-spec, font-entity, or font-object. If the name is too long for XLFD (maximum 255 chars), return nil. If the 2nd optional arg FOLD-WILDCARDS is non-nil, the consecutive wildcards are folded to one. */) - (font, fold_wildcards) - Lisp_Object font, fold_wildcards; + (Lisp_Object font, Lisp_Object fold_wildcards) { char name[256]; int pixel_size = 0; @@ -4550,7 +4401,7 @@ the consecutive wildcards are folded to one. */) DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, doc: /* Clear font cache. */) - () + (void) { Lisp_Object list, frame; @@ -4584,8 +4435,7 @@ DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, void -font_fill_lglyph_metrics (glyph, font_object) - Lisp_Object glyph, font_object; +font_fill_lglyph_metrics (Lisp_Object glyph, Lisp_Object font_object) { struct font *font = XFONT_OBJECT (font_object); unsigned code; @@ -4612,8 +4462,7 @@ header of the glyph-string. If the shaping was successful, the value is GSTRING itself or a newly created glyph-string. Otherwise, the value is nil. */) - (gstring) - Lisp_Object gstring; + (Lisp_Object gstring) { struct font *font; Lisp_Object font_object, n, glyph; @@ -4641,6 +4490,8 @@ created glyph-string. Otherwise, the value is nil. */) } if (i == 3 || XINT (n) == 0) return Qnil; + if (XINT (n) < LGSTRING_GLYPH_LEN (gstring)) + LGSTRING_SET_GLYPH (gstring, XINT (n), Qnil); glyph = LGSTRING_GLYPH (gstring, 0); from = LGLYPH_FROM (glyph); @@ -4690,8 +4541,7 @@ where VARIATION-SELECTOR is a character code of variation selection (#xFE00..#xFE0F or #xE0100..#xE01EF) GLYPH-ID is a glyph code of the corresponding variation glyph. */) - (font_object, character) - Lisp_Object font_object, character; + (Lisp_Object font_object, Lisp_Object character) { unsigned variations[256]; struct font *font; @@ -4759,8 +4609,7 @@ produced in GSTRING-OUT, and the value is nil. See the documentation of `font-make-gstring' for the format of glyph-string. */) - (otf_features, gstring_in, from, to, gstring_out, index) - Lisp_Object otf_features, gstring_in, from, to, gstring_out, index; + (Lisp_Object otf_features, Lisp_Object gstring_in, Lisp_Object from, Lisp_Object to, Lisp_Object gstring_out, Lisp_Object index) { Lisp_Object font_object = LGSTRING_FONT (gstring_in); Lisp_Object val; @@ -4810,8 +4659,7 @@ The value is a list of cons cells of the format (GLYPH-ID . CHARACTER), where GLYPH-ID is a glyph index of the font, and CHARACTER is a character code corresponding to the glyph or nil if there's no corresponding character. */) - (font_object, character, otf_features) - Lisp_Object font_object, character, otf_features; + (Lisp_Object font_object, Lisp_Object character, Lisp_Object otf_features) { struct font *font; Lisp_Object gstring_in, gstring_out, g; @@ -4852,10 +4700,7 @@ corresponding character. */) DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, doc: /* Open FONT-ENTITY. */) - (font_entity, size, frame) - Lisp_Object font_entity; - Lisp_Object size; - Lisp_Object frame; + (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame) { int isize; @@ -4881,8 +4726,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, doc: /* Close FONT-OBJECT. */) - (font_object, frame) - Lisp_Object font_object, frame; + (Lisp_Object font_object, Lisp_Object frame) { CHECK_FONT_OBJECT (font_object); if (NILP (frame)) @@ -4933,8 +4777,7 @@ representing the default langsys. FEATURE is a symbol representing OpenType feature tag. If the font is not OpenType font, CAPABILITY is nil. */) - (font_object) - Lisp_Object font_object; + (Lisp_Object font_object) { struct font *font; Lisp_Object val; @@ -4955,25 +4798,99 @@ If the font is not OpenType font, CAPABILITY is nil. */) return val; } -DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, - doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. -Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) - (font_object, string) - Lisp_Object font_object, string; +DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0, + doc: + /* Return a vector of FONT-OBJECT's glyphs for the specified characters. +FROM and TO are positions (integers or markers) specifying a region +of the current buffer. +If the optional fourth arg OBJECT is not nil, it is a string or a +vector containing the target characters. + +Each element is a vector containing information of a glyph in this format: + [FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT ADJUSTMENT] +where + FROM is an index numbers of a character the glyph corresponds to. + TO is the same as FROM. + C is the character of the glyph. + CODE is the glyph-code of C in FONT-OBJECT. + WIDTH thru DESCENT are the metrics (in pixels) of the glyph. + ADJUSTMENT is always nil. +If FONT-OBJECT doesn't have a glyph for a character, +the corresponding element is nil. */) + (Lisp_Object font_object, Lisp_Object from, Lisp_Object to, + Lisp_Object object) { struct font *font; - int i, len; - Lisp_Object vec; + int i, len, c; + Lisp_Object *chars, vec; + USE_SAFE_ALLOCA; CHECK_FONT_GET_OBJECT (font_object, font); - CHECK_STRING (string); - len = SCHARS (string); + if (NILP (object)) + { + EMACS_INT charpos, bytepos; + + validate_region (&from, &to); + if (EQ (from, to)) + return Qnil; + len = XFASTINT (to) - XFASTINT (from); + SAFE_ALLOCA_LISP (chars, len); + charpos = XFASTINT (from); + bytepos = CHAR_TO_BYTE (charpos); + for (i = 0; charpos < XFASTINT (to); i++) + { + FETCH_CHAR_ADVANCE (c, charpos, bytepos); + chars[i] = make_number (c); + } + } + else if (STRINGP (object)) + { + const unsigned char *p; + + CHECK_NUMBER (from); + CHECK_NUMBER (to); + if (XINT (from) < 0 || XINT (from) > XINT (to) + || XINT (to) > SCHARS (object)) + args_out_of_range_3 (object, from, to); + if (EQ (from, to)) + return Qnil; + len = XFASTINT (to) - XFASTINT (from); + SAFE_ALLOCA_LISP (chars, len); + p = SDATA (object); + if (STRING_MULTIBYTE (object)) + for (i = 0; i < len; i++) + { + c = STRING_CHAR_ADVANCE (p); + chars[i] = make_number (c); + } + else + for (i = 0; i < len; i++) + chars[i] = make_number (p[i]); + } + else + { + CHECK_VECTOR (object); + CHECK_NUMBER (from); + CHECK_NUMBER (to); + if (XINT (from) < 0 || XINT (from) > XINT (to) + || XINT (to) > ASIZE (object)) + args_out_of_range_3 (object, from, to); + if (EQ (from, to)) + return Qnil; + len = XFASTINT (to) - XFASTINT (from); + for (i = 0; i < len; i++) + { + Lisp_Object elt = AREF (object, XFASTINT (from) + i); + CHECK_CHARACTER (elt); + } + chars = &(AREF (object, XFASTINT (from))); + } + vec = Fmake_vector (make_number (len), Qnil); for (i = 0; i < len; i++) { - Lisp_Object ch = Faref (string, make_number (i)); - Lisp_Object val; - int c = XINT (ch); + Lisp_Object g; + int c = XFASTINT (chars[i]); unsigned code; EMACS_INT cod; struct font_metrics metrics; @@ -4981,28 +4898,28 @@ Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. * cod = code = font->driver->encode_char (font, c); if (code == FONT_INVALID_CODE) continue; - val = Fmake_vector (make_number (6), Qnil); - if (cod <= MOST_POSITIVE_FIXNUM) - ASET (val, 0, make_number (code)); - else - ASET (val, 0, Fcons (make_number (code >> 16), - make_number (code & 0xFFFF))); + g = Fmake_vector (make_number (LGLYPH_SIZE), Qnil); + LGLYPH_SET_FROM (g, i); + LGLYPH_SET_TO (g, i); + LGLYPH_SET_CHAR (g, c); + LGLYPH_SET_CODE (g, code); font->driver->text_extents (font, &code, 1, &metrics); - ASET (val, 1, make_number (metrics.lbearing)); - ASET (val, 2, make_number (metrics.rbearing)); - ASET (val, 3, make_number (metrics.width)); - ASET (val, 4, make_number (metrics.ascent)); - ASET (val, 5, make_number (metrics.descent)); - ASET (vec, i, val); - } + LGLYPH_SET_WIDTH (g, metrics.width); + LGLYPH_SET_LBEARING (g, metrics.lbearing); + LGLYPH_SET_RBEARING (g, metrics.rbearing); + LGLYPH_SET_ASCENT (g, metrics.ascent); + LGLYPH_SET_DESCENT (g, metrics.descent); + ASET (vec, i, g); + } + if (! VECTORP (object)) + SAFE_FREE (); return vec; } DEFUN ("font-match-p", Ffont_match_p, Sfont_match_p, 2, 2, 0, doc: /* Return t if and only if font-spec SPEC matches with FONT. FONT is a font-spec, font-entity, or font-object. */) - (spec, font) - Lisp_Object spec, font; + (Lisp_Object spec, Lisp_Object font) { CHECK_FONT_SPEC (spec); CHECK_FONT (font); @@ -5014,8 +4931,7 @@ DEFUN ("font-at", Ffont_at, Sfont_at, 1, 3, 0, doc: /* Return a font-object for displaying a character at POSITION. Optional second arg WINDOW, if non-nil, is a window displaying the current buffer. It defaults to the currently selected window. */) - (position, window, string) - Lisp_Object position, window, string; + (Lisp_Object position, Lisp_Object window, Lisp_Object string) { struct window *w; EMACS_INT pos; @@ -5048,8 +4964,7 @@ DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. The value is a number of glyphs drawn. Type C-l to recover what previously shown. */) - (font_object, string) - Lisp_Object font_object, string; + (Lisp_Object font_object, Lisp_Object string) { Lisp_Object frame = selected_frame; FRAME_PTR f = XFRAME (frame); @@ -5103,8 +5018,7 @@ where RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling how to compose characters. If the named font is not yet loaded, return nil. */) - (name, frame) - Lisp_Object name, frame; + (Lisp_Object name, Lisp_Object frame) { FRAME_PTR f; struct font *font; @@ -5167,9 +5081,7 @@ If the named font is not yet loaded, return nil. */) build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry)) static Lisp_Object -build_style_table (entry, nelement) - struct table_entry *entry; - int nelement; +build_style_table (const struct table_entry *entry, int nelement) { int i, j; Lisp_Object table, elt; @@ -5199,9 +5111,7 @@ static Lisp_Object Vfont_log_deferred; opening), ARG is the argument for the action, and RESULT is the result of the action. */ void -font_add_log (action, arg, result) - char *action; - Lisp_Object arg, result; +font_add_log (const char *action, Lisp_Object arg, Lisp_Object result) { Lisp_Object tail, val; int i; @@ -5287,9 +5197,7 @@ font_add_log (action, arg, result) as font_add_log. */ void -font_deferred_log (action, arg, result) - char *action; - Lisp_Object arg, result; +font_deferred_log (const char *action, Lisp_Object arg, Lisp_Object result) { if (EQ (Vfont_log, Qt)) return; @@ -5298,17 +5206,8 @@ font_deferred_log (action, arg, result) ASET (Vfont_log_deferred, 2, result); } -extern void syms_of_ftfont P_ (()); -extern void syms_of_xfont P_ (()); -extern void syms_of_xftfont P_ (()); -extern void syms_of_ftxfont P_ (()); -extern void syms_of_bdffont P_ (()); -extern void syms_of_w32font P_ (()); -extern void syms_of_atmfont P_ (()); -extern void syms_of_nsfont P_ (()); - void -syms_of_font () +syms_of_font (void) { sort_shift_bits[FONT_TYPE_INDEX] = 0; sort_shift_bits[FONT_SLANT_INDEX] = 2; @@ -5396,7 +5295,7 @@ syms_of_font () defsubr (&Sopen_font); defsubr (&Sclose_font); defsubr (&Squery_font); - defsubr (&Sget_font_glyphs); + defsubr (&Sfont_get_glyphs); defsubr (&Sfont_match_p); defsubr (&Sfont_at); #if 0 @@ -5429,22 +5328,30 @@ non-nil value in the table are supported. If REPERTORY is nil, Emacs gets the repertory information by an opened font and ENCODING. */); Vfont_encoding_alist = Qnil; + /* FIXME: These 3 vars are not quite what they appear: setq on them + won't have any effect other than disconnect them from the style + table used by the font display code. So we make them read-only, + to avoid this confusing situation. */ + DEFVAR_LISP_NOPRO ("font-weight-table", &Vfont_weight_table, doc: /* Vector of valid font weight values. Each element has the form: [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. */); Vfont_weight_table = BUILD_STYLE_TABLE (weight_table); + XSYMBOL (intern_c_string ("font-weight-table"))->constant = 1; DEFVAR_LISP_NOPRO ("font-slant-table", &Vfont_slant_table, doc: /* Vector of font slant symbols vs the corresponding numeric values. See `font-weight-table' for the format of the vector. */); Vfont_slant_table = BUILD_STYLE_TABLE (slant_table); + XSYMBOL (intern_c_string ("font-slant-table"))->constant = 1; DEFVAR_LISP_NOPRO ("font-width-table", &Vfont_width_table, doc: /* Alist of font width symbols vs the corresponding numeric values. See `font-weight-table' for the format of the vector. */); Vfont_width_table = BUILD_STYLE_TABLE (width_table); + XSYMBOL (intern_c_string ("font-width-table"))->constant = 1; staticpro (&font_style_table); font_style_table = Fmake_vector (make_number (3), Qnil); @@ -5487,7 +5394,7 @@ EMACS_FONT_LOG is set. Otherwise, it is set to t. */); } void -init_font () +init_font (void) { Vfont_log = egetenv ("EMACS_FONT_LOG") ? Qnil : Qt; } diff --git a/src/font.h b/src/font.h index 14b1abc4de8..b2d7e49fa29 100644 --- a/src/font.h +++ b/src/font.h @@ -159,14 +159,19 @@ enum font_property_index /* This value is the length of font-spec vector. */ FONT_SPEC_MAX, - /* The followings are used only for a font-entity. */ + /* The followings are used only for a font-entity and a font-object. */ /* List of font-objects opened from the font-entity. */ FONT_OBJLIST_INDEX = FONT_SPEC_MAX, + /* Font-entity from which the font-object is opened. */ + FONT_ENTITY_INDEX = FONT_SPEC_MAX, + /* This value is the length of font-entity vector. */ FONT_ENTITY_MAX, + /* The followings are used only for a font-object. */ + /* XLFD name of the font (string). */ FONT_NAME_INDEX = FONT_ENTITY_MAX, @@ -234,7 +239,9 @@ enum font_property_index ASET ((font), prop, make_number (font_style_to_value (prop, val, 1))) extern Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript; -extern Lisp_Object QCavgwidth, QCfont_entity, QCfc_unknown_spec; +extern Lisp_Object QCavgwidth, QCantialias, QCfont_entity, QCfc_unknown_spec; +extern Lisp_Object Qp; + /* Important character set symbols. */ extern Lisp_Object Qascii_0; @@ -507,7 +514,7 @@ struct font_driver /* Return a cache of font-entities on frame F. The cache must be a cons whose cdr part is the actual cache area. */ - Lisp_Object (*get_cache) P_ ((FRAME_PTR F)); + Lisp_Object (*get_cache) (FRAME_PTR F); /* List fonts exactly matching with FONT_SPEC on FRAME. The value is a list of font-entities. The font properties to be considered @@ -530,7 +537,7 @@ struct font_driver This and the following `match' are the only APIs that allocate font-entities. */ - Lisp_Object (*list) P_ ((Lisp_Object frame, Lisp_Object font_spec)); + Lisp_Object (*list) (Lisp_Object frame, Lisp_Object font_spec); /* Return a font-entity most closely matching with FONT_SPEC on FRAME. Which font property to consider, and how to calculate the @@ -539,92 +546,92 @@ struct font_driver The properties that the font-entity has is the same as `list' method. */ - Lisp_Object (*match) P_ ((Lisp_Object frame, Lisp_Object font_spec)); + Lisp_Object (*match) (Lisp_Object frame, Lisp_Object font_spec); /* Optional. List available families. The value is a list of family names (symbols). */ - Lisp_Object (*list_family) P_ ((Lisp_Object frame)); + Lisp_Object (*list_family) (Lisp_Object frame); /* Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value). Free FONT_EXTRA_INDEX field of FONT_ENTITY. */ - void (*free_entity) P_ ((Lisp_Object font_entity)); + void (*free_entity) (Lisp_Object font_entity); /* Open a font specified by FONT_ENTITY on frame F. If the font is scalable, open it with PIXEL_SIZE. */ - Lisp_Object (*open) P_ ((FRAME_PTR f, Lisp_Object font_entity, - int pixel_size)); + Lisp_Object (*open) (FRAME_PTR f, Lisp_Object font_entity, + int pixel_size); /* Close FONT on frame F. */ - void (*close) P_ ((FRAME_PTR f, struct font *font)); + void (*close) (FRAME_PTR f, struct font *font); /* Optional (if FACE->extra is not used). Prepare FACE for displaying characters by FONT on frame F by storing some data in FACE->extra. If successful, return 0. Otherwise, return -1. */ - int (*prepare_face) P_ ((FRAME_PTR f, struct face *face)); + int (*prepare_face) (FRAME_PTR f, struct face *face); /* Optional. Done FACE for displaying characters by FACE->font on frame F. */ - void (*done_face) P_ ((FRAME_PTR f, struct face *face)); + void (*done_face) (FRAME_PTR f, struct face *face); /* Optional. If FONT (FONT-ENTITY or FONT-OBJECT) has a glyph for character C (Unicode code point), return 1. If not, return 0. If FONT is FONT-ENTITY and it must be opened to check it, return -1. */ - int (*has_char) P_ ((Lisp_Object font, int c)); + int (*has_char) (Lisp_Object font, int c); /* Return a glyph code of FONT for character C (Unicode code point). If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */ - unsigned (*encode_char) P_ ((struct font *font, int c)); + unsigned (*encode_char) (struct font *font, int c); /* Computate the total metrics of the NGLYPHS glyphs specified by the font FONT and the sequence of glyph codes CODE, and store the result in METRICS. */ - int (*text_extents) P_ ((struct font *font, - unsigned *code, int nglyphs, - struct font_metrics *metrics)); + int (*text_extents) (struct font *font, + unsigned *code, int nglyphs, + struct font_metrics *metrics); /* Optional. Draw glyphs between FROM and TO of S->char2b at (X Y) pixel position of frame F with S->FACE and S->GC. If WITH_BACKGROUND is nonzero, fill the background in advance. It is assured that WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars). */ - int (*draw) P_ ((struct glyph_string *s, int from, int to, - int x, int y, int with_background)); + int (*draw) (struct glyph_string *s, int from, int to, + int x, int y, int with_background); /* Optional. Store bitmap data for glyph-code CODE of FONT in BITMAP. It is intended that this method is callled from the other font-driver for actual drawing. */ - int (*get_bitmap) P_ ((struct font *font, unsigned code, - struct font_bitmap *bitmap, - int bits_per_pixel)); + int (*get_bitmap) (struct font *font, unsigned code, + struct font_bitmap *bitmap, + int bits_per_pixel); /* Optional. Free bitmap data in BITMAP. */ - void (*free_bitmap) P_ ((struct font *font, struct font_bitmap *bitmap)); + void (*free_bitmap) (struct font *font, struct font_bitmap *bitmap); /* Optional. Return an outline data for glyph-code CODE of FONT. The format of the outline data depends on the font-driver. */ - void *(*get_outline) P_ ((struct font *font, unsigned code)); + void *(*get_outline) (struct font *font, unsigned code); /* Optional. Free OUTLINE (that is obtained by the above method). */ - void (*free_outline) P_ ((struct font *font, void *outline)); + void (*free_outline) (struct font *font, void *outline); /* Optional. Get coordinates of the INDEXth anchor point of the glyph whose code is CODE. Store the coordinates in *X and *Y. Return 0 if the operations was successfull. Otherwise return -1. */ - int (*anchor_point) P_ ((struct font *font, unsigned code, int index, - int *x, int *y)); + int (*anchor_point) (struct font *font, unsigned code, int index, + int *x, int *y); /* Optional. Return a list describing which scripts/languages FONT supports by which GSUB/GPOS features of OpenType tables. */ - Lisp_Object (*otf_capability) P_ ((struct font *font)); + Lisp_Object (*otf_capability) (struct font *font); /* Optional. Apply FONT's OTF-FEATURES to the glyph string. @@ -641,20 +648,20 @@ struct font_driver Return the number of output codes. If none of the features are applicable to the input data, return 0. If GSTRING-OUT is too short, return -1. */ - int (*otf_drive) P_ ((struct font *font, Lisp_Object features, - Lisp_Object gstring_in, int from, int to, - Lisp_Object gstring_out, int idx, int alternate_subst)); + int (*otf_drive) (struct font *font, Lisp_Object features, + Lisp_Object gstring_in, int from, int to, + Lisp_Object gstring_out, int idx, int alternate_subst); /* Optional. Make the font driver ready for frame F. Usually this function makes some data specific to F and stores it in F by calling font_put_frame_data (). */ - int (*start_for_frame) P_ ((FRAME_PTR f)); + int (*start_for_frame) (FRAME_PTR f); /* Optional. End using the driver for frame F. Usually this function free some data stored for F. */ - int (*end_for_frame) P_ ((FRAME_PTR f)); + int (*end_for_frame) (FRAME_PTR f); /* Optional. @@ -670,14 +677,14 @@ struct font_driver a new glyph object and storing it in GSTRING. If (M) is greater than the length of GSTRING, nil should be return. In that case, this function is called again with the larger GSTRING. */ - Lisp_Object (*shape) P_ ((Lisp_Object lgstring)); + Lisp_Object (*shape) (Lisp_Object lgstring); /* Optional. If FONT is usable on frame F, return 0. Otherwise return -1. This method is used only for debugging. If this method is NULL, Emacs assumes that the font is usable on any frame. */ - int (*check) P_ ((FRAME_PTR F, struct font *font)); + int (*check) (FRAME_PTR F, struct font *font); /* Optional. @@ -685,18 +692,18 @@ struct font_driver FONT. VARIATIONS is an array of 256 elements. If the variation selector N (1..256) defines a glyph, that glyph code is stored in the (N-1)th element of VARIATIONS. */ - int (*get_variation_glyphs) P_ ((struct font *font, - int c, unsigned variations[256])); + int (*get_variation_glyphs) (struct font *font, + int c, unsigned variations[256]); - void (*filter_properties) P_ ((Lisp_Object font, Lisp_Object properties)); + void (*filter_properties) (Lisp_Object font, Lisp_Object properties); /* Optional. Return non-zero if FONT_OBJECT can be used as a (cached) font for ENTITY on frame F. */ - int (*cached_font_ok) P_ ((struct frame *f, - Lisp_Object font_object, - Lisp_Object entity)); + int (*cached_font_ok) (struct frame *f, + Lisp_Object font_object, + Lisp_Object entity); }; @@ -739,80 +746,80 @@ EXFUN (Ffont_family_list, 1); EXFUN (Fclear_font_cache, 0); EXFUN (Ffont_xlfd_name, 2); -extern Lisp_Object font_make_spec P_ ((void)); -extern Lisp_Object font_make_entity P_ ((void)); -extern Lisp_Object font_make_object P_ ((int, Lisp_Object, int)); - -extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); -extern int font_registry_charsets P_ ((Lisp_Object, struct charset **, - struct charset **)); -extern int font_style_to_value P_ ((enum font_property_index prop, - Lisp_Object name, int noerror)); -extern Lisp_Object font_style_symbolic P_ ((Lisp_Object font, - enum font_property_index prop, - int for_face)); - -extern int font_match_p P_ ((Lisp_Object spec, Lisp_Object font)); -extern Lisp_Object font_list_entities P_ ((Lisp_Object frame, - Lisp_Object spec)); - -extern Lisp_Object font_get_name P_ ((Lisp_Object font_object)); -extern Lisp_Object font_spec_from_name P_ ((Lisp_Object font_name)); -extern Lisp_Object font_get_frame P_ ((Lisp_Object font_object)); -extern int font_has_char P_ ((FRAME_PTR, Lisp_Object, int)); -extern unsigned font_encode_char P_ ((Lisp_Object, int)); - -extern void font_clear_prop P_ ((Lisp_Object *attrs, - enum font_property_index prop)); -extern void font_update_lface P_ ((FRAME_PTR f, Lisp_Object *attrs)); -extern Lisp_Object font_find_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface, - Lisp_Object spec, int c)); -extern Lisp_Object font_open_for_lface P_ ((FRAME_PTR f, Lisp_Object entity, - Lisp_Object *lface, - Lisp_Object spec)); -extern Lisp_Object font_load_for_lface P_ ((FRAME_PTR f, Lisp_Object *lface, - Lisp_Object spec)); -extern void font_prepare_for_face P_ ((FRAME_PTR f, struct face *face)); -extern void font_done_for_face P_ ((FRAME_PTR f, struct face *face)); - -extern Lisp_Object font_open_by_spec P_ ((FRAME_PTR f, Lisp_Object spec)); -extern Lisp_Object font_open_by_name P_ ((FRAME_PTR f, char *name)); +extern Lisp_Object font_make_spec (void); +extern Lisp_Object font_make_entity (void); +extern Lisp_Object font_make_object (int, Lisp_Object, int); + +extern Lisp_Object find_font_encoding (Lisp_Object); +extern int font_registry_charsets (Lisp_Object, struct charset **, + struct charset **); +extern int font_style_to_value (enum font_property_index prop, + Lisp_Object name, int noerror); +extern Lisp_Object font_style_symbolic (Lisp_Object font, + enum font_property_index prop, + int for_face); + +extern int font_match_p (Lisp_Object spec, Lisp_Object font); +extern Lisp_Object font_list_entities (Lisp_Object frame, + Lisp_Object spec); + +extern Lisp_Object font_get_name (Lisp_Object font_object); +extern Lisp_Object font_spec_from_name (Lisp_Object font_name); +extern Lisp_Object font_get_frame (Lisp_Object font_object); +extern int font_has_char (FRAME_PTR, Lisp_Object, int); +extern unsigned font_encode_char (Lisp_Object, int); + +extern void font_clear_prop (Lisp_Object *attrs, + enum font_property_index prop); +extern void font_update_lface (FRAME_PTR f, Lisp_Object *attrs); +extern Lisp_Object font_find_for_lface (FRAME_PTR f, Lisp_Object *lface, + Lisp_Object spec, int c); +extern Lisp_Object font_open_for_lface (FRAME_PTR f, Lisp_Object entity, + Lisp_Object *lface, + Lisp_Object spec); +extern Lisp_Object font_load_for_lface (FRAME_PTR f, Lisp_Object *lface, + Lisp_Object spec); +extern void font_prepare_for_face (FRAME_PTR f, struct face *face); +extern void font_done_for_face (FRAME_PTR f, struct face *face); + +extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec); +extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name); extern void font_close_object (FRAME_PTR f, Lisp_Object font_object); -extern Lisp_Object font_intern_prop P_ ((char *str, int len, int force_symbol)); -extern void font_update_sort_order P_ ((int *order)); - -extern void font_parse_family_registry P_ ((Lisp_Object family, - Lisp_Object registry, - Lisp_Object spec)); -extern Lisp_Object font_spec_from_family_registry P_ ((Lisp_Object family, - Lisp_Object registry)); - -extern int font_parse_xlfd P_ ((char *name, Lisp_Object font)); -extern int font_unparse_xlfd P_ ((Lisp_Object font, int pixel_size, - char *name, int bytes)); -extern int font_parse_fcname P_ ((char *name, Lisp_Object font)); -extern int font_unparse_fcname P_ ((Lisp_Object font, int pixel_size, - char *name, int bytes)); -extern int font_unparse_gtkname P_ ((Lisp_Object, struct frame *, char *, int)); -extern void register_font_driver P_ ((struct font_driver *driver, FRAME_PTR f)); -extern void free_font_driver_list P_ ((FRAME_PTR f)); -extern Lisp_Object font_update_drivers P_ ((FRAME_PTR f, Lisp_Object list)); -extern Lisp_Object font_at P_ ((int c, EMACS_INT pos, struct face *face, - struct window *w, Lisp_Object object)); +extern Lisp_Object font_intern_prop (const char *str, int len, int force_symbol); +extern void font_update_sort_order (int *order); + +extern void font_parse_family_registry (Lisp_Object family, + Lisp_Object registry, + Lisp_Object spec); +extern Lisp_Object font_spec_from_family_registry (Lisp_Object family, + Lisp_Object registry); + +extern int font_parse_xlfd (char *name, Lisp_Object font); +extern int font_unparse_xlfd (Lisp_Object font, int pixel_size, + char *name, int bytes); +extern int font_parse_fcname (char *name, Lisp_Object font); +extern int font_unparse_fcname (Lisp_Object font, int pixel_size, + char *name, int bytes); +extern int font_unparse_gtkname (Lisp_Object, struct frame *, char *, int); +extern void register_font_driver (struct font_driver *driver, FRAME_PTR f); +extern void free_font_driver_list (FRAME_PTR f); +extern Lisp_Object font_update_drivers (FRAME_PTR f, Lisp_Object list); +extern Lisp_Object font_at (int c, EMACS_INT pos, struct face *face, + struct window *w, Lisp_Object object); extern Lisp_Object font_range (EMACS_INT, EMACS_INT *, struct window *, struct face *, Lisp_Object); -extern void font_fill_lglyph_metrics P_ ((Lisp_Object, Lisp_Object)); +extern void font_fill_lglyph_metrics (Lisp_Object, Lisp_Object); -extern Lisp_Object font_put_extra P_ ((Lisp_Object font, Lisp_Object prop, - Lisp_Object val)); +extern Lisp_Object font_put_extra (Lisp_Object font, Lisp_Object prop, + Lisp_Object val); -extern int font_put_frame_data P_ ((FRAME_PTR f, - struct font_driver *driver, - void *data)); -extern void *font_get_frame_data P_ ((FRAME_PTR f, - struct font_driver *driver)); +extern int font_put_frame_data (FRAME_PTR f, + struct font_driver *driver, + void *data); +extern void *font_get_frame_data (FRAME_PTR f, + struct font_driver *driver); extern void font_filter_properties (Lisp_Object font, Lisp_Object alist, @@ -821,29 +828,41 @@ extern void font_filter_properties (Lisp_Object font, #ifdef HAVE_FREETYPE extern struct font_driver ftfont_driver; +extern void syms_of_ftfont (void); #endif /* HAVE_FREETYPE */ #ifdef HAVE_X_WINDOWS extern struct font_driver xfont_driver; extern struct font_driver ftxfont_driver; +extern void syms_of_xfont (void); +extern void syms_of_ftxfont (void); #ifdef HAVE_XFT extern struct font_driver xftfont_driver; +extern void syms_of_xftfont (void); #endif /* HAVE_XFT */ +#ifdef HAVE_BDFFONT +extern void syms_of_bdffont (void); +#endif /* HAVE_BDFFONT */ #endif /* HAVE_X_WINDOWS */ #ifdef WINDOWSNT extern struct font_driver w32font_driver; extern struct font_driver uniscribe_font_driver; +extern void syms_of_w32font (void); #endif /* WINDOWSNT */ #ifdef HAVE_NS +extern Lisp_Object Qfontsize; extern struct font_driver nsfont_driver; +extern void syms_of_nsfont (void); #endif /* HAVE_NS */ #ifndef FONT_DEBUG #define FONT_DEBUG #endif +extern Lisp_Object QCfoundry, QCadstyle, QCregistry; + extern Lisp_Object Vfont_log; -extern void font_add_log P_ ((char *, Lisp_Object, Lisp_Object)); -extern void font_deferred_log P_ ((char *, Lisp_Object, Lisp_Object)); +extern void font_add_log (const char *, Lisp_Object, Lisp_Object); +extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object); #define FONT_ADD_LOG(ACTION, ARG, RESULT) \ do { \ diff --git a/src/fontset.c b/src/fontset.c index e4fd9d72780..86b9ceb45db 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -177,7 +177,6 @@ EXFUN (Fclear_face_cache, 1); /********** VARIABLES and FUNCTION PROTOTYPES **********/ -extern Lisp_Object Qfont; static Lisp_Object Qfontset; static Lisp_Object Qfontset_info; static Lisp_Object Qprepend, Qappend; @@ -203,23 +202,23 @@ Lisp_Object Vvertical_centering_font_regexp; Lisp_Object Votf_script_alist; /* Check if any window system is used now. */ -void (*check_window_system_func) P_ ((void)); +void (*check_window_system_func) (void); /* Prototype declarations for static functions. */ -static Lisp_Object fontset_add P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object)); -static Lisp_Object fontset_find_font P_ ((Lisp_Object, int, struct face *, - int, int)); -static void reorder_font_vector P_ ((Lisp_Object, struct font *)); -static Lisp_Object fontset_font P_ ((Lisp_Object, int, struct face *, int)); -static Lisp_Object make_fontset P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -static Lisp_Object fontset_pattern_regexp P_ ((Lisp_Object)); -static void accumulate_script_ranges P_ ((Lisp_Object, Lisp_Object, - Lisp_Object)); -Lisp_Object find_font_encoding P_ ((Lisp_Object)); - -static void set_fontset_font P_ ((Lisp_Object, Lisp_Object)); +static Lisp_Object fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object); +static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *, + int, int); +static void reorder_font_vector (Lisp_Object, struct font *); +static Lisp_Object fontset_font (Lisp_Object, int, struct face *, int); +static Lisp_Object make_fontset (Lisp_Object, Lisp_Object, Lisp_Object); +static Lisp_Object fontset_pattern_regexp (Lisp_Object); +static void accumulate_script_ranges (Lisp_Object, Lisp_Object, + Lisp_Object); +Lisp_Object find_font_encoding (Lisp_Object); + +static void set_fontset_font (Lisp_Object, Lisp_Object); #ifdef FONTSET_DEBUG @@ -284,6 +283,10 @@ fontset_id_valid_p (id) #define RFONT_DEF_OBJECT(rfont_def) AREF (rfont_def, 2) #define RFONT_DEF_SET_OBJECT(rfont_def, object) \ ASET ((rfont_def), 2, (object)) +/* Score of RFONT_DEF is an integer value; the lowest 8 bits represent + the order of listing by font backends, the higher bits represents + the order given by charset priority list. The smaller value is + preferable. */ #define RFONT_DEF_SCORE(rfont_def) XINT (AREF (rfont_def, 3)) #define RFONT_DEF_SET_SCORE(rfont_def, score) \ ASET ((rfont_def), 3, make_number (score)) @@ -306,9 +309,7 @@ fontset_id_valid_p (id) : fontset_ref ((fontset), (c))) static Lisp_Object -fontset_ref (fontset, c) - Lisp_Object fontset; - int c; +fontset_ref (Lisp_Object fontset, int c) { Lisp_Object elt; @@ -343,8 +344,7 @@ fontset_ref (fontset, c) : fontset_add ((fontset), (range), (elt), (add))) static Lisp_Object -fontset_add (fontset, range, elt, add) - Lisp_Object fontset, range, elt, add; +fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add) { Lisp_Object args[2]; int idx = (EQ (add, Qappend) ? 0 : 1); @@ -376,8 +376,7 @@ fontset_add (fontset, range, elt, add) } static int -fontset_compare_rfontdef (val1, val2) - const void *val1, *val2; +fontset_compare_rfontdef (const void *val1, const void *val2) { return (RFONT_DEF_SCORE (*(Lisp_Object *) val1) - RFONT_DEF_SCORE (*(Lisp_Object *) val2)); @@ -392,12 +391,8 @@ fontset_compare_rfontdef (val1, val2) If PREFERRED_FAMILY is not nil, that family has the higher priority if the encoding charsets or languages in font-specs are the same. */ -extern Lisp_Object Fassoc_string (); - static void -reorder_font_vector (font_group, font) - Lisp_Object font_group; - struct font *font; +reorder_font_vector (Lisp_Object font_group, struct font *font) { Lisp_Object vec, font_object; int size; @@ -421,8 +416,13 @@ reorder_font_vector (font_group, font) Lisp_Object font_def = RFONT_DEF_FONT_DEF (rfont_def); Lisp_Object font_spec = FONT_DEF_SPEC (font_def); int score = RFONT_DEF_SCORE (rfont_def) & 0xFF; + Lisp_Object otf_spec = Ffont_get (font_spec, QCotf); - if (! font_match_p (font_spec, font_object)) + if (! NILP (otf_spec)) + /* A font-spec with :otf is preferable regardless of encoding + and language.. */ + ; + else if (! font_match_p (font_spec, font_object)) { Lisp_Object encoding = FONT_DEF_ENCODING (font_def); @@ -525,11 +525,7 @@ fontset_get_font_group (Lisp_Object fontset, int c) If FALLBACK is nonzero, search only fallback fonts. */ static Lisp_Object -fontset_find_font (fontset, c, face, id, fallback) - Lisp_Object fontset; - int c; - struct face *face; - int id, fallback; +fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fallback) { Lisp_Object vec, font_group; int i, charset_matched = 0, found_index; @@ -728,11 +724,7 @@ fontset_find_font (fontset, c, face, id, fallback) static Lisp_Object -fontset_font (fontset, c, face, id) - Lisp_Object fontset; - int c; - struct face *face; - int id; +fontset_font (Lisp_Object fontset, int c, struct face *face, int id) { Lisp_Object rfont_def, default_rfont_def; Lisp_Object base_fontset; @@ -793,8 +785,7 @@ fontset_font (fontset, c, face, id) BASE. */ static Lisp_Object -make_fontset (frame, name, base) - Lisp_Object frame, name, base; +make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base) { Lisp_Object fontset; int size = ASIZE (Vfontset_table); @@ -835,8 +826,7 @@ make_fontset (frame, name, base) /* Return the name of the fontset who has ID. */ Lisp_Object -fontset_name (id) - int id; +fontset_name (int id) { Lisp_Object fontset; @@ -848,8 +838,7 @@ fontset_name (id) /* Return the ASCII font name of the fontset who has ID. */ Lisp_Object -fontset_ascii (id) - int id; +fontset_ascii (int id) { Lisp_Object fontset, elt; @@ -861,9 +850,7 @@ fontset_ascii (id) } void -free_realized_fontset (f, fontset) - FRAME_PTR f; - Lisp_Object fontset; +free_realized_fontset (FRAME_PTR f, Lisp_Object fontset) { Lisp_Object tail; @@ -879,9 +866,7 @@ free_realized_fontset (f, fontset) free_realized_face. */ void -free_face_fontset (f, face) - FRAME_PTR f; - struct face *face; +free_face_fontset (FRAME_PTR f, struct face *face) { Lisp_Object fontset; @@ -915,9 +900,7 @@ free_face_fontset (f, face) when C is not an ASCII character. */ int -face_suitable_for_char_p (face, c) - struct face *face; - int c; +face_suitable_for_char_p (struct face *face, int c) { Lisp_Object fontset, rfont_def; @@ -934,11 +917,7 @@ face_suitable_for_char_p (face, c) the macro FACE_FOR_CHAR. */ int -face_for_char (f, face, c, pos, object) - FRAME_PTR f; - struct face *face; - int c, pos; - Lisp_Object object; +face_for_char (FRAME_PTR f, struct face *face, int c, int pos, Lisp_Object object) { Lisp_Object fontset, rfont_def, charset; int face_id; @@ -1006,10 +985,7 @@ face_for_char (f, face, c, pos, object) Lisp_Object -font_for_char (face, c, pos, object) - struct face *face; - int c, pos; - Lisp_Object object; +font_for_char (struct face *face, int c, int pos, Lisp_Object object) { Lisp_Object fontset, rfont_def, charset; int id; @@ -1059,10 +1035,7 @@ font_for_char (face, c, pos, object) Called from realize_x_face. */ int -make_fontset_for_ascii_face (f, base_fontset_id, face) - FRAME_PTR f; - int base_fontset_id; - struct face *face; +make_fontset_for_ascii_face (FRAME_PTR f, int base_fontset_id, struct face *face) { Lisp_Object base_fontset, fontset, frame; @@ -1096,11 +1069,10 @@ static Lisp_Object Vcached_fontset_data; expression corresponding to PATTERN. */ static Lisp_Object -fontset_pattern_regexp (pattern) - Lisp_Object pattern; +fontset_pattern_regexp (Lisp_Object pattern) { - if (!index ((char *) SDATA (pattern), '*') - && !index ((char *) SDATA (pattern), '?')) + if (!strchr ((char *) SDATA (pattern), '*') + && !strchr ((char *) SDATA (pattern), '?')) /* PATTERN does not contain any wild cards. */ return Qnil; @@ -1171,9 +1143,7 @@ fontset_pattern_regexp (pattern) */ int -fs_query_fontset (name, name_pattern) - Lisp_Object name; - int name_pattern; +fs_query_fontset (Lisp_Object name, int name_pattern) { Lisp_Object tem; int i; @@ -1222,8 +1192,7 @@ The value is nil if there is no matching fontset. PATTERN can contain `*' or `?' as a wildcard just as X font name matching algorithm allows. If REGEXPP is non-nil, PATTERN is a regular expression. */) - (pattern, regexpp) - Lisp_Object pattern, regexpp; + (Lisp_Object pattern, Lisp_Object regexpp) { Lisp_Object fontset; int id; @@ -1246,10 +1215,7 @@ If REGEXPP is non-nil, PATTERN is a regular expression. */) /* Return a list of base fontset names matching PATTERN on frame F. */ Lisp_Object -list_fontsets (f, pattern, size) - FRAME_PTR f; - Lisp_Object pattern; - int size; +list_fontsets (FRAME_PTR f, Lisp_Object pattern, int size) { Lisp_Object frame, regexp, val; int id; @@ -1285,8 +1251,7 @@ list_fontsets (f, pattern, size) /* Free all realized fontsets whose base fontset is BASE. */ static void -free_realized_fontsets (base) - Lisp_Object base; +free_realized_fontsets (Lisp_Object base) { int id; @@ -1343,8 +1308,7 @@ free_realized_fontsets (base) Set *FRAME to the actual frame. */ static Lisp_Object -check_fontset_name (name, frame) - Lisp_Object name, *frame; +check_fontset_name (Lisp_Object name, Lisp_Object *frame) { int id; @@ -1373,8 +1337,7 @@ check_fontset_name (name, frame) } static void -accumulate_script_ranges (arg, range, val) - Lisp_Object arg, range, val; +accumulate_script_ranges (Lisp_Object arg, Lisp_Object range, Lisp_Object val) { if (EQ (XCAR (arg), val)) { @@ -1399,8 +1362,7 @@ accumulate_script_ranges (arg, range, val) case. */ static void -set_fontset_font (arg, range) - Lisp_Object arg, range; +set_fontset_font (Lisp_Object arg, Lisp_Object range) { Lisp_Object fontset, font_def, add, ascii, script_range_list; int from = XINT (XCAR (range)), to = XINT (XCDR (range)); @@ -1439,8 +1401,7 @@ set_fontset_font (arg, range) ASET (arg, 4, script_range_list); } -extern Lisp_Object QCfamily, QCregistry; -static void update_auto_fontset_alist P_ ((Lisp_Object, Lisp_Object)); +static void update_auto_fontset_alist (Lisp_Object, Lisp_Object); DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0, @@ -1478,8 +1439,7 @@ Optional 5th argument ADD, if non-nil, specifies how to add FONT-SPEC to the font specifications for TARGET previously set. If it is `prepend', FONT-SPEC is prepended. If it is `append', FONT-SPEC is appended. By default, FONT-SPEC overrides the previous settings. */) - (name, target, font_spec, frame, add) - Lisp_Object name, target, font_spec, frame, add; + (Lisp_Object name, Lisp_Object target, Lisp_Object font_spec, Lisp_Object frame, Lisp_Object add) { Lisp_Object fontset; Lisp_Object font_def, registry, family; @@ -1502,7 +1462,6 @@ appended. By default, FONT-SPEC overrides the previous settings. */) else if (STRINGP (font_spec)) { Lisp_Object args[2]; - extern Lisp_Object QCname; fontname = font_spec; args[0] = QCname; @@ -1688,8 +1647,7 @@ char-table `char-script-table'. FONT-SPEC is a vector, a cons, or a string. See the documentation of `set-fontset-font' for the meaning. */) - (name, fontlist) - Lisp_Object name, fontlist; + (Lisp_Object name, Lisp_Object fontlist) { Lisp_Object fontset; int id; @@ -1762,8 +1720,7 @@ static int num_auto_fontsets; user intends to use FONT-OBJECT for Latin characters. */ int -fontset_from_font (font_object) - Lisp_Object font_object; +fontset_from_font (Lisp_Object font_object) { Lisp_Object font_name = font_get_name (font_object); Lisp_Object font_spec = Fcopy_font_spec (font_object); @@ -1819,8 +1776,7 @@ fontset_from_font (font_object) fontset_from_font. */ static void -update_auto_fontset_alist (font_object, fontset) - Lisp_Object font_object, fontset; +update_auto_fontset_alist (Lisp_Object font_object, Lisp_Object fontset) { Lisp_Object prev, tail; @@ -1866,8 +1822,7 @@ update_auto_fontset_alist (font_object, fontset) DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, doc: /* For internal use only. */) - (position, ch) - Lisp_Object position, ch; + (Lisp_Object position, Lisp_Object ch) { EMACS_INT pos, pos_byte, dummy; int face_id; @@ -1957,8 +1912,7 @@ The char-table has one extra slot. If FONTSET is not the default fontset, the value the extra slot is a char-table containing the information about the derived fonts from the default fontset. The format is the same as above. */) - (fontset, frame) - Lisp_Object fontset, frame; + (Lisp_Object fontset, Lisp_Object frame) { FRAME_PTR f; Lisp_Object *realized[2], fontsets[2], tables[2]; @@ -2093,8 +2047,7 @@ fontset. If the 2nd optional arg ALL is non-nil, return a list of all font name patterns. */) - (name, ch, all) - Lisp_Object name, ch, all; + (Lisp_Object name, Lisp_Object ch, Lisp_Object all) { int c; Lisp_Object fontset, elt, list, repertory, val; @@ -2154,7 +2107,7 @@ patterns. */) DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0, doc: /* Return a list of all defined fontset names. */) - () + (void) { Lisp_Object fontset, list; int i; @@ -2211,7 +2164,7 @@ dump_fontset (fontset) DEFUN ("fontset-list-all", Ffontset_list_all, Sfontset_list_all, 0, 0, 0, doc: /* Return a brief summary of all fontsets for debug use. */) - () + (void) { Lisp_Object val; int i; @@ -2224,7 +2177,7 @@ DEFUN ("fontset-list-all", Ffontset_list_all, Sfontset_list_all, 0, 0, 0, #endif /* FONTSET_DEBUG */ void -syms_of_fontset () +syms_of_fontset (void) { DEFSYM (Qfontset, "fontset"); Fput (Qfontset, Qchar_table_extra_slots, make_number (9)); diff --git a/src/fontset.h b/src/fontset.h index 78bdfaaaca0..661638feb39 100644 --- a/src/fontset.h +++ b/src/fontset.h @@ -28,23 +28,25 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define EMACS_FONTSET_H /* Check if any window system is used now. */ -extern void (*check_window_system_func) P_ ((void)); +extern void (*check_window_system_func) (void); struct face; -extern void free_face_fontset P_ ((FRAME_PTR, struct face *)); -extern Lisp_Object fontset_font_pattern P_ ((FRAME_PTR, struct face *, int)); -extern int face_suitable_for_char_p P_ ((struct face *, int)); -extern int face_for_char P_ ((FRAME_PTR, struct face *, int, - int, Lisp_Object)); -extern Lisp_Object font_for_char P_ ((struct face *, int, int, Lisp_Object)); +extern void free_face_fontset (FRAME_PTR, struct face *); +extern Lisp_Object fontset_font_pattern (FRAME_PTR, struct face *, int); +extern int face_suitable_for_char_p (struct face *, int); +extern int face_for_char (FRAME_PTR, struct face *, int, + int, Lisp_Object); +extern Lisp_Object font_for_char (struct face *, int, int, Lisp_Object); -extern int make_fontset_for_ascii_face P_ ((FRAME_PTR, int, struct face *)); -extern int fontset_from_font P_ ((Lisp_Object)); -extern int fs_query_fontset P_ ((Lisp_Object, int)); +extern int make_fontset_for_ascii_face (FRAME_PTR, int, struct face *); +extern int fontset_from_font (Lisp_Object); +extern int fs_query_fontset (Lisp_Object, int); EXFUN (Fquery_fontset, 2); -extern Lisp_Object list_fontsets P_ ((struct frame *, Lisp_Object, int)); +extern Lisp_Object list_fontsets (struct frame *, Lisp_Object, int); +extern Lisp_Object find_font_encoding (Lisp_Object); +extern Lisp_Object Qlatin; extern Lisp_Object Vuse_default_ascent; extern Lisp_Object Vignore_relative_composition; extern Lisp_Object Valternate_fontname_alist; @@ -52,12 +54,12 @@ extern Lisp_Object Vfontset_alias_alist; extern Lisp_Object Vvertical_centering_font_regexp; extern Lisp_Object Votf_script_alist; -extern Lisp_Object fontset_name P_ ((int)); -extern Lisp_Object fontset_ascii P_ ((int)); -extern int fontset_height P_ ((int)); +extern Lisp_Object fontset_name (int); +extern Lisp_Object fontset_ascii (int); +extern int fontset_height (int); struct font; -extern int face_for_font P_ ((struct frame *, Lisp_Object, struct face *)); +extern int face_for_font (struct frame *, Lisp_Object, struct face *); #endif /* EMACS_FONTSET_H */ diff --git a/src/frame.c b/src/frame.c index a30d1e18175..04cc1ca07da 100644 --- a/src/frame.c +++ b/src/frame.c @@ -119,7 +119,8 @@ Lisp_Object Qparent_id; Lisp_Object Qtitle, Qname; Lisp_Object Qexplicit_name; Lisp_Object Qunsplittable; -Lisp_Object Qmenu_bar_lines, Qtool_bar_lines; +Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position; +Lisp_Object Vmenu_bar_mode, Vtool_bar_mode; Lisp_Object Qleft_fringe, Qright_fringe; Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list; Lisp_Object Qtty_color_mode; @@ -142,9 +143,7 @@ static Lisp_Object Vdelete_frame_functions, Qdelete_frame_functions; int focus_follows_mouse; static void -set_menu_bar_lines_1 (window, n) - Lisp_Object window; - int n; +set_menu_bar_lines_1 (Lisp_Object window, int n) { struct window *w = XWINDOW (window); @@ -170,9 +169,7 @@ set_menu_bar_lines_1 (window, n) } void -set_menu_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int nlines; int olines = FRAME_MENU_BAR_LINES (f); @@ -201,13 +198,6 @@ set_menu_bar_lines (f, value, oldval) Lisp_Object Vframe_list; -extern Lisp_Object Vminibuffer_list; -extern Lisp_Object get_minibuffer (); -extern Lisp_Object Fhandle_switch_frame (); -extern Lisp_Object Fredirect_frame_focus (); -extern Lisp_Object x_get_focus_frame (); -extern Lisp_Object QCname, Qfont_param; - DEFUN ("framep", Fframep, Sframep, 1, 1, 0, doc: /* Return non-nil if OBJECT is a frame. @@ -217,8 +207,7 @@ Value is t for a termcap frame (a character-only terminal), `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display, `pc' for a direct-write MS-DOS frame. See also `frame-live-p'. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (!FRAMEP (object)) return Qnil; @@ -248,8 +237,7 @@ Value is nil if OBJECT is not a live frame. If object is a live frame, the return value indicates what sort of terminal device it is displayed on. See the documentation of `framep' for possible return values. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return ((FRAMEP (object) && FRAME_LIVE_P (XFRAME (object))) @@ -263,8 +251,7 @@ The value is a symbol---for instance, 'x' for X windows. The value is nil if Emacs is using a text-only terminal. FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object type; if (NILP (frame)) @@ -282,8 +269,7 @@ FRAME defaults to the currently selected frame. */) } struct frame * -make_frame (mini_p) - int mini_p; +make_frame (int mini_p) { Lisp_Object frame; register struct frame *f; @@ -330,10 +316,13 @@ make_frame (mini_p) f->menu_bar_window = Qnil; f->tool_bar_window = Qnil; f->tool_bar_items = Qnil; + f->tool_bar_position = Qtop; f->desired_tool_bar_string = f->current_tool_bar_string = Qnil; f->n_tool_bar_items = 0; f->left_fringe_width = f->right_fringe_width = 0; f->fringe_cols = 0; + f->menu_bar_lines = 0; + f->tool_bar_lines = 0; f->scroll_bar_actual_width = 0; f->border_width = 0; f->internal_border_width = 0; @@ -433,10 +422,7 @@ make_frame (mini_p) default (the global minibuffer). */ struct frame * -make_frame_without_minibuffer (mini_window, kb, display) - register Lisp_Object mini_window; - KBOARD *kb; - Lisp_Object display; +make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lisp_Object display) { register struct frame *f; struct gcpro gcpro1; @@ -485,7 +471,7 @@ make_frame_without_minibuffer (mini_window, kb, display) /* Make a frame containing only a minibuffer window. */ struct frame * -make_minibuffer_frame () +make_minibuffer_frame (void) { /* First make a frame containing just a root window, no minibuffer. */ @@ -562,6 +548,9 @@ make_initial_frame (void) FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; + /* The default value of menu-bar-mode is t. */ + set_menu_bar_lines (f, make_number (1), Qnil); + #ifdef CANNOT_DUMP if (!noninteractive) init_frame_faces (f); @@ -611,6 +600,7 @@ make_terminal_frame (struct terminal *terminal) FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; + FRAME_MENU_BAR_LINES(f) = NILP (Vmenu_bar_mode) ? 0 : 1; /* Set the top frame to the newly created frame. */ if (FRAMEP (FRAME_TTY (f)->top_frame) @@ -627,8 +617,7 @@ make_terminal_frame (struct terminal *terminal) /* Get a suitable value for frame parameter PARAMETER for a newly created frame, based on (1) the user-supplied frame parameter - alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else - fails, (3) Vdefault_frame_alist. */ + alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */ static Lisp_Object get_future_frame_param (Lisp_Object parameter, @@ -642,8 +631,6 @@ get_future_frame_param (Lisp_Object parameter, result = Fassq (parameter, XFRAME (selected_frame)->param_alist); if (NILP (result) && current_value != NULL) result = build_string (current_value); - if (NILP (result)) - result = Fassq (parameter, Vdefault_frame_alist); if (!NILP (result) && !STRINGP (result)) result = XCDR (result); if (NILP (result) || !STRINGP (result)) @@ -669,8 +656,7 @@ and the `tty-type' parameter specifies the terminal type. Example: Note that changing the size of one terminal frame automatically affects all frames on the same terminal device. */) - (parms) - Lisp_Object parms; + (Lisp_Object parms) { struct frame *f; struct terminal *t = NULL; @@ -748,7 +734,6 @@ affects all frames on the same terminal device. */) adjust_glyphs (f); calculate_costs (f); XSETFRAME (frame, f); - Fmodify_frame_parameters (frame, Vdefault_frame_alist); Fmodify_frame_parameters (frame, parms); Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type, build_string (t->display_info.tty->type)), @@ -788,9 +773,7 @@ affects all frames on the same terminal device. */) The value of NORECORD is passed as argument to Fselect_window. */ Lisp_Object -do_switch_frame (frame, track, for_deletion, norecord) - Lisp_Object frame, norecord; - int track, for_deletion; +do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord) { struct frame *sf = SELECTED_FRAME (); @@ -900,8 +883,7 @@ the window system's input focus. On a text-only terminal, the next redisplay will display FRAME. This function returns FRAME, or nil if FRAME has been deleted. */) - (frame, norecord) - Lisp_Object frame, norecord; + (Lisp_Object frame, Lisp_Object norecord) { return do_switch_frame (frame, 1, 0, norecord); } @@ -916,8 +898,7 @@ This function selects the selected window of the frame of EVENT. If EVENT is frame object, handle it as if it were a switch-frame event to that frame. */) - (event) - Lisp_Object event; + (Lisp_Object event) { /* Preserve prefix arg that the command loop just cleared. */ current_kboard->Vprefix_arg = Vcurrent_prefix_arg; @@ -927,15 +908,14 @@ to that frame. */) DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, doc: /* Return the frame that is now selected. */) - () + (void) { return selected_frame; } DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, doc: /* Return the frame object that window WINDOW is on. */) - (window) - Lisp_Object window; + (Lisp_Object window) { CHECK_LIVE_WINDOW (window); return XWINDOW (window)->frame; @@ -944,8 +924,7 @@ DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, doc: /* Returns the topmost, leftmost window of FRAME. If omitted, FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object w; @@ -971,7 +950,7 @@ If omitted, FRAME defaults to the currently selected frame. */) DEFUN ("active-minibuffer-window", Factive_minibuffer_window, Sactive_minibuffer_window, 0, 0, 0, doc: /* Return the currently active minibuffer window, or nil if none. */) - () + (void) { return minibuf_level ? minibuf_window : Qnil; } @@ -979,8 +958,7 @@ DEFUN ("active-minibuffer-window", Factive_minibuffer_window, DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, doc: /* Returns the root-window of FRAME. If omitted, FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object window; @@ -999,8 +977,7 @@ DEFUN ("frame-selected-window", Fframe_selected_window, Sframe_selected_window, 0, 1, 0, doc: /* Return the selected window of FRAME. FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object window; @@ -1023,8 +1000,7 @@ selected frame, this makes WINDOW the selected window. Optional argument NORECORD non-nil means to neither change the order of recently selected windows nor the buffer list. Return WINDOW. */) - (frame, window, norecord) - Lisp_Object frame, window, norecord; + (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord) { if (NILP (frame)) frame = selected_frame; @@ -1045,7 +1021,7 @@ Return WINDOW. */) DEFUN ("frame-list", Fframe_list, Sframe_list, 0, 0, 0, doc: /* Return a list of all live frames. */) - () + (void) { Lisp_Object frames; frames = Fcopy_sequence (Vframe_list); @@ -1065,9 +1041,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list, Otherwise, include all frames. */ static Lisp_Object -next_frame (frame, minibuf) - Lisp_Object frame; - Lisp_Object minibuf; +next_frame (Lisp_Object frame, Lisp_Object minibuf) { Lisp_Object tail; int passed = 0; @@ -1145,9 +1119,7 @@ next_frame (frame, minibuf) Otherwise, include all frames. */ static Lisp_Object -prev_frame (frame, minibuf) - Lisp_Object frame; - Lisp_Object minibuf; +prev_frame (Lisp_Object frame, Lisp_Object minibuf) { Lisp_Object tail; Lisp_Object prev; @@ -1230,8 +1202,7 @@ and any frame now using that window as the minibuffer. If MINIFRAME is `visible', include all visible frames. If MINIFRAME is 0, include all visible and iconified frames. Otherwise, include all frames. */) - (frame, miniframe) - Lisp_Object frame, miniframe; + (Lisp_Object frame, Lisp_Object miniframe) { if (NILP (frame)) frame = selected_frame; @@ -1251,8 +1222,7 @@ and any frame now using that window as the minibuffer. If MINIFRAME is `visible', include all visible frames. If MINIFRAME is 0, include all visible and iconified frames. Otherwise, include all frames. */) - (frame, miniframe) - Lisp_Object frame, miniframe; + (Lisp_Object frame, Lisp_Object miniframe) { if (NILP (frame)) frame = selected_frame; @@ -1265,8 +1235,7 @@ Otherwise, include all frames. */) (Exception: if F is the terminal frame, and we are using X, return 1.) */ int -other_visible_frames (f) - FRAME_PTR f; +other_visible_frames (FRAME_PTR f) { /* We know the selected frame is visible, so if F is some other frame, it can't be the sole visible one. */ @@ -1305,26 +1274,16 @@ other_visible_frames (f) return 1; } -/* Error handler for `delete-frame-functions'. */ -static Lisp_Object -delete_frame_handler (Lisp_Object arg) -{ - add_to_log ("Error during `delete-frame': %s", arg, Qnil); - return Qnil; -} - -extern Lisp_Object Qrun_hook_with_args; - /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME unconditionally. x_connection_closed and delete_terminal use this. Any other value of FORCE implements the semantics described for Fdelete_frame. */ Lisp_Object -delete_frame (frame, force) +delete_frame (Lisp_Object frame, Lisp_Object force) /* If we use `register' here, gcc-4.0.2 on amd64 using -DUSE_LISP_UNION_TYPE complains further down that we're getting the address of `force'. Go figure. */ - Lisp_Object frame, force; + { struct frame *f; struct frame *sf = SELECTED_FRAME (); @@ -1653,8 +1612,7 @@ but if the second optional argument FORCE is non-nil, you may do so. This function runs `delete-frame-functions' before actually deleting the frame, unless the frame is a tooltip. The functions are run with one argument, the frame to be deleted. */) - (frame, force) - Lisp_Object frame, force; + (Lisp_Object frame, Lisp_Object force) { return delete_frame (frame, !NILP (force) ? Qt : Qnil); } @@ -1673,7 +1631,7 @@ and nil for X and Y. If `mouse-position-function' is non-nil, `mouse-position' calls it, passing the normal return value to that function as an argument, and returns whatever that function returns. */) - () + (void) { FRAME_PTR f; Lisp_Object lispy_dummy; @@ -1719,7 +1677,7 @@ the vertical offset. If Emacs is running on a mouseless terminal or hasn't been programmed to read the mouse position, it returns the selected frame for FRAME and nil for X and Y. */) - () + (void) { FRAME_PTR f; Lisp_Object lispy_dummy; @@ -1756,8 +1714,7 @@ This function is a no-op for an X frame that is not visible. If you have just created a frame, you must wait for it to become visible before calling this function on it, like this. (while (not (frame-visible-p frame)) (sleep-for .5)) */) - (frame, x, y) - Lisp_Object frame, x, y; + (Lisp_Object frame, Lisp_Object x, Lisp_Object y) { CHECK_LIVE_FRAME (frame); CHECK_NUMBER (x); @@ -1798,8 +1755,7 @@ Note, this is a no-op for an X frame that is not visible. If you have just created a frame, you must wait for it to become visible before calling this function on it, like this. (while (not (frame-visible-p frame)) (sleep-for .5)) */) - (frame, x, y) - Lisp_Object frame, x, y; + (Lisp_Object frame, Lisp_Object x, Lisp_Object y) { CHECK_LIVE_FRAME (frame); CHECK_NUMBER (x); @@ -1830,14 +1786,13 @@ before calling this function on it, like this. return Qnil; } -static void make_frame_visible_1 P_ ((Lisp_Object)); +static void make_frame_visible_1 (Lisp_Object); DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible, 0, 1, "", doc: /* Make the frame FRAME visible (assuming it is an X window). If omitted, FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { if (NILP (frame)) frame = selected_frame; @@ -1865,8 +1820,7 @@ If omitted, FRAME defaults to the currently selected frame. */) and all its descendents. */ static void -make_frame_visible_1 (window) - Lisp_Object window; +make_frame_visible_1 (Lisp_Object window) { struct window *w; @@ -1897,8 +1851,7 @@ but if the second optional argument FORCE is non-nil, you may do so. This function has no effect on text-only terminal frames. Such frames are always considered visible, whether or not they are currently being displayed in the terminal. */) - (frame, force) - Lisp_Object frame, force; + (Lisp_Object frame, Lisp_Object force) { if (NILP (frame)) frame = selected_frame; @@ -1939,8 +1892,7 @@ DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame, 0, 1, "", doc: /* Make the frame FRAME into an icon. If omitted, FRAME defaults to the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { if (NILP (frame)) frame = selected_frame; @@ -1985,8 +1937,7 @@ usually not displayed at all, even in a window system's \"taskbar\". If FRAME is a text-only terminal frame, this always returns t. Such frames are always considered visible, whether or not they are currently being displayed on the terminal. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { CHECK_LIVE_FRAME (frame); @@ -2002,7 +1953,7 @@ currently being displayed on the terminal. */) DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, 0, 0, 0, doc: /* Return a list of all frames now \"visible\" (being updated). */) - () + (void) { Lisp_Object tail, frame; struct frame *f; @@ -2028,8 +1979,7 @@ If FRAME is invisible or iconified, make it visible. If you don't specify a frame, the selected frame is used. If Emacs is displaying on an ordinary terminal or some other device which doesn't support multiple overlapping frames, this function selects FRAME. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; if (NILP (frame)) @@ -2058,8 +2008,7 @@ DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "", If you don't specify a frame, the selected frame is used. If Emacs is displaying on an ordinary terminal or some other device which doesn't support multiple overlapping frames, this function does nothing. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2102,8 +2051,7 @@ differently from a frame whose focus is redirected to nil; the former is affected by `select-frame', while the latter is not. The redirection lasts until `redirect-frame-focus' is called to change it. */) - (frame, focus_frame) - Lisp_Object frame, focus_frame; + (Lisp_Object frame, Lisp_Object focus_frame) { struct frame *f; @@ -2130,8 +2078,7 @@ DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, doc: /* Return the frame to which FRAME's keystrokes are currently being sent. This returns nil if FRAME's focus is not redirected. See `redirect-frame-focus'. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { CHECK_LIVE_FRAME (frame); @@ -2143,9 +2090,7 @@ See `redirect-frame-focus'. */) /* Return the value of frame parameter PROP in frame FRAME. */ Lisp_Object -get_frame_param (frame, prop) - register struct frame *frame; - Lisp_Object prop; +get_frame_param (register struct frame *frame, Lisp_Object prop) { register Lisp_Object tem; @@ -2158,8 +2103,7 @@ get_frame_param (frame, prop) /* Return the buffer-predicate of the selected frame. */ Lisp_Object -frame_buffer_predicate (frame) - Lisp_Object frame; +frame_buffer_predicate (Lisp_Object frame) { return XFRAME (frame)->buffer_predicate; } @@ -2167,8 +2111,7 @@ frame_buffer_predicate (frame) /* Return the buffer-list of the selected frame. */ Lisp_Object -frame_buffer_list (frame) - Lisp_Object frame; +frame_buffer_list (Lisp_Object frame) { return XFRAME (frame)->buffer_list; } @@ -2176,8 +2119,7 @@ frame_buffer_list (frame) /* Set the buffer-list of the selected frame. */ void -set_frame_buffer_list (frame, list) - Lisp_Object frame, list; +set_frame_buffer_list (Lisp_Object frame, Lisp_Object list) { XFRAME (frame)->buffer_list = list; } @@ -2185,8 +2127,7 @@ set_frame_buffer_list (frame, list) /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ void -frames_discard_buffer (buffer) - Lisp_Object buffer; +frames_discard_buffer (Lisp_Object buffer) { Lisp_Object frame, tail; @@ -2203,9 +2144,7 @@ frames_discard_buffer (buffer) If the alist already has an element for PROP, we change it. */ void -store_in_alist (alistptr, prop, val) - Lisp_Object *alistptr, val; - Lisp_Object prop; +store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val) { register Lisp_Object tem; @@ -2217,9 +2156,7 @@ store_in_alist (alistptr, prop, val) } static int -frame_name_fnn_p (str, len) - char *str; - EMACS_INT len; +frame_name_fnn_p (char *str, EMACS_INT len) { if (len > 1 && str[0] == 'F') { @@ -2237,9 +2174,7 @@ frame_name_fnn_p (str, len) Modeled after x_set_name which is used for WINDOW frames. */ static void -set_term_frame_name (f, name) - struct frame *f; - Lisp_Object name; +set_term_frame_name (struct frame *f, Lisp_Object name) { f->explicit_name = ! NILP (name); @@ -2277,9 +2212,7 @@ set_term_frame_name (f, name) } void -store_frame_param (f, prop, val) - struct frame *f; - Lisp_Object prop, val; +store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) { register Lisp_Object old_alist_elt; @@ -2302,13 +2235,20 @@ store_frame_param (f, prop, val) without messing up the symbol's status. */ if (SYMBOLP (prop)) { - Lisp_Object valcontents; - valcontents = SYMBOL_VALUE (prop); - if ((BUFFER_LOCAL_VALUEP (valcontents)) - && XBUFFER_LOCAL_VALUE (valcontents)->check_frame - && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame - && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f) - swap_in_global_binding (prop); + struct Lisp_Symbol *sym = XSYMBOL (prop); + start: + switch (sym->redirect) + { + case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; + case SYMBOL_PLAINVAL: case SYMBOL_FORWARDED: break; + case SYMBOL_LOCALIZED: + { struct Lisp_Buffer_Local_Value *blv = sym->val.blv; + if (blv->frame_local && BLV_FOUND (blv) && XFRAME (blv->where) == f) + swap_in_global_binding (sym); + break; + } + default: abort (); + } } /* The tty color needed to be set before the frame's parameter @@ -2359,8 +2299,7 @@ DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. The meaningful PARMs depend on the kind of frame. If FRAME is omitted, return information on the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object alist; FRAME_PTR f; @@ -2457,8 +2396,7 @@ If FRAME is omitted, return information on the currently selected frame. */) DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0, doc: /* Return FRAME's value for parameter PARAMETER. If FRAME is nil, describe the currently selected frame. */) - (frame, parameter) - Lisp_Object frame, parameter; + (Lisp_Object frame, Lisp_Object parameter) { struct frame *f; Lisp_Object value; @@ -2524,6 +2462,8 @@ If FRAME is nil, describe the currently selected frame. */) || EQ (parameter, Qbackground_mode)) value = Fcdr (Fassq (parameter, f->param_alist)); else + /* FIXME: Avoid this code path at all (as well as code duplication) + by sharing more code with Fframe_parameters. */ value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); } @@ -2546,8 +2486,7 @@ as a frame-local binding for the variable FOO, if you have enabled such bindings for that variable with `make-variable-frame-local'. Note that this functionality is obsolete as of Emacs 22.2, and its use is not recommended. Explicitly check for a frame-parameter instead. */) - (frame, alist) - Lisp_Object frame, alist; + (Lisp_Object frame, Lisp_Object alist) { FRAME_PTR f; register Lisp_Object tail, prop, val; @@ -2612,8 +2551,7 @@ DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, doc: /* Height in pixels of a line in the font in frame FRAME. If FRAME is omitted, the selected frame is used. For a terminal frame, the value is always 1. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2637,8 +2575,7 @@ DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, If FRAME is omitted, the selected frame is used. On a graphical screen, the width is the standard width of the default font. For a terminal screen, the value is always 1. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2674,8 +2611,7 @@ and menu bar. For a text-only terminal, it includes the menu bar. In this case, the result is really in characters rather than pixels (i.e., is identical to `frame-height'). */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2697,8 +2633,7 @@ DEFUN ("frame-pixel-width", Fframe_pixel_width, doc: /* Return FRAME's width in pixels. For a terminal frame, the result really gives the width in characters. If FRAME is omitted, the selected frame is used. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2714,13 +2649,34 @@ If FRAME is omitted, the selected frame is used. */) #endif return make_number (FRAME_COLS (f)); } + +DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width, + Stool_bar_pixel_width, 0, 1, 0, + doc: /* Return width in pixels of FRAME's tool bar. +The result is greater than zero only when the tool bar is on the left +or right side of FRAME. If FRAME is omitted, the selected frame is +used. */) + (Lisp_Object frame) +{ + struct frame *f; + + if (NILP (frame)) + frame = selected_frame; + CHECK_FRAME (frame); + f = XFRAME (frame); + +#ifdef FRAME_TOOLBAR_WIDTH + if (FRAME_WINDOW_P (f)) + return make_number (FRAME_TOOLBAR_WIDTH (f)); +#endif + return make_number (0); +} DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0, doc: /* Specify that the frame FRAME has LINES lines. Optional third arg non-nil means that redisplay should use LINES lines but that the idea of the actual height of the frame should not be changed. */) - (frame, lines, pretend) - Lisp_Object frame, lines, pretend; + (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend) { register struct frame *f; @@ -2748,8 +2704,7 @@ DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0, doc: /* Specify that the frame FRAME has COLS columns. Optional third arg non-nil means that redisplay should use COLS columns but that the idea of the actual width of the frame should not be changed. */) - (frame, cols, pretend) - Lisp_Object frame, cols, pretend; + (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend) { register struct frame *f; CHECK_NUMBER (cols); @@ -2774,8 +2729,7 @@ but that the idea of the actual width of the frame should not be changed. */) DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0, doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. */) - (frame, cols, rows) - Lisp_Object frame, cols, rows; + (Lisp_Object frame, Lisp_Object cols, Lisp_Object rows) { register struct frame *f; @@ -2807,8 +2761,7 @@ DEFUN ("set-frame-position", Fset_frame_position, This is actually the position of the upper left corner of the frame. Negative values for XOFFSET or YOFFSET are interpreted relative to the rightmost or bottommost possible position (that stays within the screen). */) - (frame, xoffset, yoffset) - Lisp_Object frame, xoffset, yoffset; + (Lisp_Object frame, Lisp_Object xoffset, Lisp_Object yoffset) { register struct frame *f; @@ -2839,11 +2792,11 @@ the rightmost or bottommost possible position (that stays within the screen). * that is an index in this table. */ struct frame_parm_table { - char *name; + const char *name; Lisp_Object *variable; }; -static struct frame_parm_table frame_parms[] = +static const struct frame_parm_table frame_parms[] = { {"auto-raise", &Qauto_raise}, {"auto-lower", &Qauto_lower}, @@ -2877,13 +2830,11 @@ static struct frame_parm_table frame_parms[] = {"font-backend", &Qfont_backend}, {"alpha", &Qalpha}, {"sticky", &Qsticky}, + {"tool-bar-position", &Qtool_bar_position}, }; #ifdef HAVE_WINDOW_SYSTEM -extern Lisp_Object Qbox; -extern Lisp_Object Qtop; - /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the wanted positions of the WM window (not Emacs window). Return in *WIDTH and *HEIGHT the wanted width and height of Emacs @@ -2891,12 +2842,7 @@ extern Lisp_Object Qtop; */ void -x_fullscreen_adjust (f, width, height, top_pos, left_pos) - struct frame *f; - int *width; - int *height; - int *top_pos; - int *left_pos; +x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos) { int newwidth = FRAME_COLS (f); int newheight = FRAME_LINES (f); @@ -2939,9 +2885,7 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos) to store the new value in the parameter alist. */ void -x_set_frame_parameters (f, alist) - FRAME_PTR f; - Lisp_Object alist; +x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist) { Lisp_Object tail; @@ -3215,9 +3159,7 @@ x_set_frame_parameters (f, alist) param_alist need to be considered here. */ void -x_report_frame_params (f, alistptr) - struct frame *f; - Lisp_Object *alistptr; +x_report_frame_params (struct frame *f, Lisp_Object *alistptr) { char buf[16]; Lisp_Object tem; @@ -3279,6 +3221,7 @@ x_report_frame_params (f, alistptr) XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc); store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil)); store_in_alist (alistptr, Qparent_id, tem); + store_in_alist (alistptr, Qtool_bar_position, f->tool_bar_position); } @@ -3286,9 +3229,7 @@ x_report_frame_params (f, alistptr) the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_fullscreen (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (NILP (new_value)) f->want_fullscreen = FULLSCREEN_NONE; @@ -3310,9 +3251,7 @@ x_set_fullscreen (f, new_value, old_value) the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_line_spacing (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (NILP (new_value)) f->extra_line_spacing = 0; @@ -3329,9 +3268,7 @@ x_set_line_spacing (f, new_value, old_value) the previous value of that parameter, NEW_VALUE is the new value. */ void -x_set_screen_gamma (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { Lisp_Object bgcolor; @@ -3361,9 +3298,7 @@ x_set_screen_gamma (f, new_value, old_value) void -x_set_font (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { Lisp_Object frame, font_object, font_param = Qnil; int fontset = -1; @@ -3460,9 +3395,7 @@ x_set_font (f, arg, oldval) void -x_set_font_backend (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { if (! NILP (new_value) && !CONSP (new_value)) @@ -3518,17 +3451,18 @@ x_set_font_backend (f, new_value, old_value) void -x_set_fringe_width (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_fringe_width (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { compute_fringe_widths (f, 1); +#ifdef HAVE_X_WINDOWS + /* Must adjust this so window managers report correct number of columns. */ + if (FRAME_X_WINDOW (f) != 0) + x_wm_set_size_hint (f, 0, 0); +#endif } void -x_set_border_width (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { CHECK_NUMBER (arg); @@ -3542,9 +3476,7 @@ x_set_border_width (f, arg, oldval) } void -x_set_internal_border_width (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int old = FRAME_INTERNAL_BORDER_WIDTH (f); @@ -3572,9 +3504,7 @@ x_set_internal_border_width (f, arg, oldval) } void -x_set_visibility (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) { Lisp_Object frame; XSETFRAME (frame, f); @@ -3588,33 +3518,25 @@ x_set_visibility (f, value, oldval) } void -x_set_autoraise (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->auto_raise = !EQ (Qnil, arg); } void -x_set_autolower (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->auto_lower = !EQ (Qnil, arg); } void -x_set_unsplittable (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { f->no_split = !NILP (arg); } void -x_set_vertical_scroll_bars (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)) || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) @@ -3645,9 +3567,7 @@ x_set_vertical_scroll_bars (f, arg, oldval) } void -x_set_scroll_bar_width (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int wid = FRAME_COLUMN_WIDTH (f); @@ -3682,8 +3602,7 @@ x_set_scroll_bar_width (f, arg, oldval) /* Return non-nil if frame F wants a bitmap icon. */ Lisp_Object -x_icon_type (f) - FRAME_PTR f; +x_icon_type (FRAME_PTR f) { Lisp_Object tem; @@ -3695,9 +3614,7 @@ x_icon_type (f) } void -x_set_alpha (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { double alpha = 1.0; double newval[2]; @@ -3755,7 +3672,7 @@ x_set_alpha (f, arg, oldval) Fix it up, or set it to `emacs' if it is too hopeless. */ void -validate_x_resource_name () +validate_x_resource_name (void) { int len = 0; /* Number of valid characters in the resource name. */ @@ -3771,7 +3688,6 @@ validate_x_resource_name () if (STRINGP (Vx_resource_name)) { unsigned char *p = SDATA (Vx_resource_name); - int i; len = SBYTES (Vx_resource_name); @@ -3822,17 +3738,15 @@ validate_x_resource_name () } -extern char *x_get_string_resource P_ ((XrmDatabase, char *, char *)); -extern Display_Info *check_x_display_info P_ ((Lisp_Object)); +extern char *x_get_string_resource (XrmDatabase, const char *, const char *); +extern Display_Info *check_x_display_info (Lisp_Object); /* Get specified attribute from resource database RDB. See Fx_get_resource below for other parameters. */ static Lisp_Object -xrdb_get_resource (rdb, attribute, class, component, subclass) - XrmDatabase rdb; - Lisp_Object attribute, class, component, subclass; +xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) { register char *value; char *name_key; @@ -3903,8 +3817,7 @@ The optional arguments COMPONENT and SUBCLASS add to the key and the class, respectively. You must specify both of them or neither. If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE' and the class is `Emacs.CLASS.SUBCLASS'. */) - (attribute, class, component, subclass) - Lisp_Object attribute, class, component, subclass; + (Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) { #ifdef HAVE_X_WINDOWS check_x (); @@ -3917,9 +3830,7 @@ and the class is `Emacs.CLASS.SUBCLASS'. */) /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */ Lisp_Object -display_x_get_resource (dpyinfo, attribute, class, component, subclass) - Display_Info *dpyinfo; - Lisp_Object attribute, class, component, subclass; +display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) { return xrdb_get_resource (dpyinfo->xrdb, attribute, class, component, subclass); @@ -3929,8 +3840,7 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass) /* Used when C code wants a resource value. */ /* Called from oldXMenu/Create.c. */ char * -x_get_resource_string (attribute, class) - char *attribute, *class; +x_get_resource_string (const char *attribute, const char *class) { char *name_key; char *class_key; @@ -3963,12 +3873,8 @@ x_get_resource_string (attribute, class) and don't let it get stored in any Lisp-visible variables! */ Lisp_Object -x_get_arg (dpyinfo, alist, param, attribute, class, type) - Display_Info *dpyinfo; - Lisp_Object alist, param; - char *attribute; - char *class; - enum resource_types type; +x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, + const char *attribute, const char *class, enum resource_types type) { register Lisp_Object tem; @@ -4066,12 +3972,9 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) } Lisp_Object -x_frame_get_arg (f, alist, param, attribute, class, type) - struct frame *f; - Lisp_Object alist, param; - char *attribute; - char *class; - enum resource_types type; +x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, + const char *attribute, const char *class, + enum resource_types type) { return x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param, attribute, class, type); @@ -4080,12 +3983,10 @@ x_frame_get_arg (f, alist, param, attribute, class, type) /* Like x_frame_get_arg, but also record the value in f->param_alist. */ Lisp_Object -x_frame_get_and_record_arg (f, alist, param, attribute, class, type) - struct frame *f; - Lisp_Object alist, param; - char *attribute; - char *class; - enum resource_types type; +x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, + Lisp_Object param, + const char *attribute, const char *class, + enum resource_types type) { Lisp_Object value; @@ -4105,14 +4006,9 @@ x_frame_get_and_record_arg (f, alist, param, attribute, class, type) If that is not found either, use the value DEFLT. */ Lisp_Object -x_default_parameter (f, alist, prop, deflt, xprop, xclass, type) - struct frame *f; - Lisp_Object alist; - Lisp_Object prop; - Lisp_Object deflt; - char *xprop; - char *xclass; - enum resource_types type; +x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, + Lisp_Object deflt, const char *xprop, const char *xclass, + enum resource_types type) { Lisp_Object tem; @@ -4142,8 +4038,7 @@ For X, the value of `left' or `top' may be an integer, or a list (+ N) meaning N pixels relative to top/left corner, or a list (- N) meaning -N pixels relative to bottom/right corner. On Nextstep, this just calls `ns-parse-geometry'. */) - (string) - Lisp_Object string; + (Lisp_Object string) { #ifdef HAVE_NS call1 (Qns_parse_geometry, string); @@ -4206,10 +4101,7 @@ On Nextstep, this just calls `ns-parse-geometry'. */) #define DEFAULT_COLS 80 int -x_figure_window_size (f, parms, toolbar_p) - struct frame *f; - Lisp_Object parms; - int toolbar_p; +x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p) { register Lisp_Object tem0, tem1, tem2; long window_prompting = 0; @@ -4384,7 +4276,7 @@ x_figure_window_size (f, parms, toolbar_p) #endif /* HAVE_WINDOW_SYSTEM */ void -frame_make_pointer_invisible () +frame_make_pointer_invisible (void) { if (! NILP (Vmake_pointer_invisible)) { @@ -4404,7 +4296,7 @@ frame_make_pointer_invisible () } void -frame_make_pointer_visible () +frame_make_pointer_visible (void) { /* We don't check Vmake_pointer_invisible here in case the pointer was invisible when Vmake_pointer_invisible was set to nil. */ @@ -4429,7 +4321,7 @@ frame_make_pointer_visible () ***********************************************************************/ void -syms_of_frame () +syms_of_frame (void) { Qframep = intern_c_string ("framep"); staticpro (&Qframep); @@ -4597,8 +4489,9 @@ Setting this variable does not affect existing frames, only new ones. */); DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars, doc: /* Default position of scroll bars on this window-system. */); #ifdef HAVE_WINDOW_SYSTEM -#if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) - /* MS-Windows and Mac OS X have scroll bars on the right by default. */ +#if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS)) + /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by + default. */ Vdefault_frame_scroll_bars = Qright; #else Vdefault_frame_scroll_bars = Qleft; @@ -4644,6 +4537,14 @@ recursively). */); Qdelete_frame_functions = intern_c_string ("delete-frame-functions"); staticpro (&Qdelete_frame_functions); + DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode, + doc: /* Non-nil if Menu-Bar mode is enabled. */); + Vmenu_bar_mode = Qt; + + DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode, + doc: /* Non-nil if Tool-Bar mode is enabled. */); + Vtool_bar_mode = Qt; + DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame, doc: /* Minibufferless frames use this frame's minibuffer. @@ -4717,6 +4618,7 @@ automatically. See also `mouse-autoselect-window'. */); defsubr (&Sframe_char_width); defsubr (&Sframe_pixel_height); defsubr (&Sframe_pixel_width); + defsubr (&Stool_bar_pixel_width); defsubr (&Sset_frame_height); defsubr (&Sset_frame_width); defsubr (&Sset_frame_size); diff --git a/src/frame.h b/src/frame.h index 8f5e47c40a5..e66fd9341c7 100644 --- a/src/frame.h +++ b/src/frame.h @@ -191,6 +191,10 @@ struct frame /* Desired and current tool-bar items. */ Lisp_Object tool_bar_items; + /* Where tool bar is, can be left, right, top or bottom. The native + tool bar only supports top. */ + Lisp_Object tool_bar_position; + /* Desired and current contents displayed in tool_bar_window. */ Lisp_Object desired_tool_bar_string, current_tool_bar_string; @@ -823,24 +827,25 @@ typedef struct frame *FRAME_PTR; extern Lisp_Object Qframep, Qframe_live_p; extern Lisp_Object Qtty, Qtty_type; +extern Lisp_Object Qtty_color_mode; extern Lisp_Object Qterminal, Qterminal_live_p; extern Lisp_Object Qnoelisp; extern struct frame *last_nonminibuf_frame; -extern struct frame *make_initial_frame P_ ((void)); -extern struct frame *make_terminal_frame P_ ((struct terminal *)); -extern struct frame *make_frame P_ ((int)); +extern struct frame *make_initial_frame (void); +extern struct frame *make_terminal_frame (struct terminal *); +extern struct frame *make_frame (int); #ifdef HAVE_WINDOW_SYSTEM -extern struct frame *make_minibuffer_frame P_ ((void)); -extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object, - struct kboard *, - Lisp_Object)); +extern struct frame *make_minibuffer_frame (void); +extern struct frame *make_frame_without_minibuffer (Lisp_Object, + struct kboard *, + Lisp_Object); #endif /* HAVE_WINDOW_SYSTEM */ -extern int other_visible_frames P_ ((struct frame *)); -extern void frame_make_pointer_invisible P_ ((void)); -extern void frame_make_pointer_visible P_ ((void)); -extern Lisp_Object delete_frame P_ ((Lisp_Object, Lisp_Object)); +extern int other_visible_frames (struct frame *); +extern void frame_make_pointer_invisible (void); +extern void frame_make_pointer_visible (void); +extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object); extern Lisp_Object Vframe_list; extern Lisp_Object Vdefault_frame_alist; @@ -1044,7 +1049,8 @@ extern Lisp_Object Qfont; extern Lisp_Object Qbackground_color, Qforeground_color; extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top; extern Lisp_Object Qinternal_border_width; -extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines; +extern Lisp_Object Qtooltip; +extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position; extern Lisp_Object Qmouse_color; extern Lisp_Object Qname, Qtitle; extern Lisp_Object Qparent_id; @@ -1063,7 +1069,6 @@ extern Lisp_Object Qalpha; extern Lisp_Object Qleft_fringe, Qright_fringe; extern Lisp_Object Qheight, Qwidth; extern Lisp_Object Qminibuffer, Qmodeline; -extern Lisp_Object Qonly; extern Lisp_Object Qx, Qw32, Qmac, Qpc, Qns; extern Lisp_Object Qvisible; extern Lisp_Object Qdisplay_type; @@ -1071,9 +1076,11 @@ extern Lisp_Object Qbackground_mode; extern Lisp_Object Qx_resource_name; -extern Lisp_Object Qleft, Qright, Qtop, Qbox; +extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom; extern Lisp_Object Qdisplay; +extern Lisp_Object Qrun_hook_with_args; + #ifdef HAVE_WINDOW_SYSTEM /* The class of this X application. */ @@ -1081,52 +1088,53 @@ extern Lisp_Object Qdisplay; /* These are in xterm.c, w32term.c, etc. */ -extern void x_set_scroll_bar_default_width P_ ((struct frame *)); -extern void x_set_offset P_ ((struct frame *, int, int, int)); -extern void x_wm_set_icon_position P_ ((struct frame *, int, int)); +extern void x_set_scroll_bar_default_width (struct frame *); +extern void x_set_offset (struct frame *, int, int, int); +extern void x_wm_set_icon_position (struct frame *, int, int); -extern Lisp_Object x_new_font P_ ((struct frame *, Lisp_Object, int)); +extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int); /* These are in frame.c */ extern Lisp_Object Vx_resource_name; extern Lisp_Object Vx_resource_class; +extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode; extern Lisp_Object Qface_set_after_frame_default; -extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *, - int *, int *)); - -extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object)); -extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *)); - -extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_font_backend P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object, - Lisp_Object)); -extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object, - Lisp_Object)); -extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, - Lisp_Object)); - -extern Lisp_Object x_icon_type P_ ((struct frame *)); - -extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int)); +extern void x_fullscreen_adjust (struct frame *f, int *, int *, + int *, int *); + +extern void x_set_frame_parameters (struct frame *, Lisp_Object); +extern void x_report_frame_params (struct frame *, Lisp_Object *); + +extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_internal_border_width (struct frame *, Lisp_Object, + Lisp_Object); +extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, + Lisp_Object); +extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, + Lisp_Object); + +extern Lisp_Object x_icon_type (struct frame *); + +extern int x_figure_window_size (struct frame *, Lisp_Object, int); extern Lisp_Object Vframe_alpha_lower_limit; -extern void x_set_alpha P_ ((struct frame *, Lisp_Object, Lisp_Object)); +extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object); -extern void validate_x_resource_name P_ ((void)); +extern void validate_x_resource_name (void); extern Lisp_Object display_x_get_resource (Display_Info *, Lisp_Object attribute, @@ -1134,6 +1142,9 @@ extern Lisp_Object display_x_get_resource (Display_Info *, Lisp_Object component, Lisp_Object subclass); +/* In xmenu.c */ +extern void set_frame_menubar (FRAME_PTR, int, int); + #endif /* HAVE_WINDOW_SYSTEM */ #endif /* not EMACS_FRAME_H */ diff --git a/src/fringe.c b/src/fringe.c index 2425e236b98..fce100b1463 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -32,10 +32,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_WINDOW_SYSTEM -extern Lisp_Object Qfringe; -extern Lisp_Object Qtop, Qbottom, Qcenter; -extern Lisp_Object Qup, Qdown, Qleft, Qright; - /* Non-nil means that newline may flow into the right fringe. */ Lisp_Object Voverflow_newline_into_fringe; @@ -83,10 +79,8 @@ Lisp_Object Vfringe_bitmaps; must specify physical bitmap symbols. */ -extern Lisp_Object Qunknown; Lisp_Object Qtruncation, Qcontinuation, Qoverlay_arrow; Lisp_Object Qempty_line, Qtop_bottom; -extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow; Lisp_Object Qhollow_small; enum fringe_bitmap_align @@ -490,8 +484,7 @@ int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS; Return 0 if not a bitmap. */ int -lookup_fringe_bitmap (bitmap) - Lisp_Object bitmap; +lookup_fringe_bitmap (Lisp_Object bitmap) { int bn; @@ -517,8 +510,7 @@ lookup_fringe_bitmap (bitmap) Return BN if not found in Vfringe_bitmaps. */ static Lisp_Object -get_fringe_bitmap_name (bn) - int bn; +get_fringe_bitmap_name (int bn) { Lisp_Object bitmaps; Lisp_Object num; @@ -550,11 +542,7 @@ get_fringe_bitmap_name (bn) */ static void -draw_fringe_bitmap_1 (w, row, left_p, overlay, which) - struct window *w; - struct glyph_row *row; - int left_p, overlay; - int which; +draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int overlay, int which) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct draw_fringe_bitmap_params p; @@ -585,11 +573,10 @@ draw_fringe_bitmap_1 (w, row, left_p, overlay, which) if (face_id == DEFAULT_FACE_ID) { - Lisp_Object face; - - if ((face = fringe_faces[which], NILP (face)) - || (face_id = lookup_derived_face (f, face, FRINGE_FACE_ID, 0), - face_id < 0)) + Lisp_Object face = fringe_faces[which]; + face_id = NILP (face) ? lookup_named_face (f, Qfringe, 0) + : lookup_derived_face (f, face, FRINGE_FACE_ID, 0); + if (face_id < 0) face_id = FRINGE_FACE_ID; } @@ -684,9 +671,7 @@ draw_fringe_bitmap_1 (w, row, left_p, overlay, which) } static int -get_logical_cursor_bitmap (w, cursor) - struct window *w; - Lisp_Object cursor; +get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor) { Lisp_Object cmap, bm = Qnil; @@ -709,10 +694,7 @@ get_logical_cursor_bitmap (w, cursor) } static int -get_logical_fringe_bitmap (w, bitmap, right_p, partial_p) - struct window *w; - Lisp_Object bitmap; - int right_p, partial_p; +get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, int partial_p) { Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm; int ln1 = 0, ln2 = 0; @@ -812,14 +794,11 @@ get_logical_fringe_bitmap (w, bitmap, right_p, partial_p) void -draw_fringe_bitmap (w, row, left_p) - struct window *w; - struct glyph_row *row; - int left_p; +draw_fringe_bitmap (struct window *w, struct glyph_row *row, int left_p) { int overlay = 0; - if (!left_p && row->cursor_in_fringe_p) + if (left_p == row->reversed_p && row->cursor_in_fringe_p) { Lisp_Object cursor = Qnil; @@ -851,7 +830,7 @@ draw_fringe_bitmap (w, row, left_p) int bm = get_logical_cursor_bitmap (w, cursor); if (bm != NO_FRINGE_BITMAP) { - draw_fringe_bitmap_1 (w, row, 0, 2, bm); + draw_fringe_bitmap_1 (w, row, left_p, 2, bm); overlay = EQ (cursor, Qbox) ? 3 : 1; } } @@ -868,9 +847,7 @@ draw_fringe_bitmap (w, row, left_p) function with input blocked. */ void -draw_row_fringe_bitmaps (w, row) - struct window *w; - struct glyph_row *row; +draw_row_fringe_bitmaps (struct window *w, struct glyph_row *row) { xassert (interrupt_input_blocked); @@ -898,9 +875,7 @@ draw_row_fringe_bitmaps (w, row) */ int -draw_window_fringes (w, no_fringe) - struct window *w; - int no_fringe; +draw_window_fringes (struct window *w, int no_fringe) { struct glyph_row *row; int yb = window_text_bottom_y (w); @@ -938,9 +913,7 @@ draw_window_fringes (w, no_fringe) If KEEP_CURRENT_P is 0, update current_matrix too. */ int -update_window_fringes (w, keep_current_p) - struct window *w; - int keep_current_p; +update_window_fringes (struct window *w, int keep_current_p) { struct glyph_row *row, *cur = 0; int yb = window_text_bottom_y (w); @@ -1200,7 +1173,8 @@ update_window_fringes (w, keep_current_p) left = row->left_user_fringe_bitmap; left_face_id = row->left_user_fringe_face_id; } - else if (row->truncated_on_left_p) + else if ((!row->reversed_p && row->truncated_on_left_p) + || (row->reversed_p && row->truncated_on_right_p)) left = LEFT_FRINGE(0, Qtruncation, 0); else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) { @@ -1216,7 +1190,8 @@ update_window_fringes (w, keep_current_p) if (bot_ind_max_y >= 0) left_offset = bot_ind_max_y - (row->y + row->visible_height); } - else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) + else if ((!row->reversed_p && MATRIX_ROW_CONTINUATION_LINE_P (row)) + || (row->reversed_p && row->continued_p)) left = LEFT_FRINGE (4, Qcontinuation, 0); else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) left = LEFT_FRINGE (5, Qempty_line, 0); @@ -1243,7 +1218,8 @@ update_window_fringes (w, keep_current_p) right = row->right_user_fringe_bitmap; right_face_id = row->right_user_fringe_face_id; } - else if (row->truncated_on_right_p) + else if ((!row->reversed_p && row->truncated_on_right_p) + || (row->reversed_p && row->truncated_on_left_p)) right = RIGHT_FRINGE (0, Qtruncation, 0); else if (row->indicate_bob_p && EQ (boundary_top, Qright)) { @@ -1259,7 +1235,8 @@ update_window_fringes (w, keep_current_p) if (bot_ind_max_y >= 0) right_offset = bot_ind_max_y - (row->y + row->visible_height); } - else if (row->continued_p) + else if ((!row->reversed_p && row->continued_p) + || (row->reversed_p && MATRIX_ROW_CONTINUATION_LINE_P (row))) right = RIGHT_FRINGE (4, Qcontinuation, 0); else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) { @@ -1337,9 +1314,7 @@ update_window_fringes (w, keep_current_p) */ void -compute_fringe_widths (f, redraw) - struct frame *f; - int redraw; +compute_fringe_widths (struct frame *f, int redraw) { int o_left = FRAME_LEFT_FRINGE_WIDTH (f); int o_right = FRAME_RIGHT_FRINGE_WIDTH (f); @@ -1421,8 +1396,7 @@ compute_fringe_widths (f, redraw) /* Free resources used by a user-defined bitmap. */ void -destroy_fringe_bitmap (n) - int n; +destroy_fringe_bitmap (int n) { struct fringe_bitmap **fbp; @@ -1449,8 +1423,7 @@ DEFUN ("destroy-fringe-bitmap", Fdestroy_fringe_bitmap, Sdestroy_fringe_bitmap, 1, 1, 0, doc: /* Destroy fringe bitmap BITMAP. If BITMAP overrides a standard fringe bitmap, the original bitmap is restored. */) - (bitmap) - Lisp_Object bitmap; + (Lisp_Object bitmap) { int n; @@ -1491,10 +1464,7 @@ static const unsigned char swap_nibble[16] = { #endif /* HAVE_X_WINDOWS */ void -init_fringe_bitmap (which, fb, once_p) - int which; - struct fringe_bitmap *fb; - int once_p; +init_fringe_bitmap (int which, struct fringe_bitmap *fb, int once_p) { if (once_p || fb->dynamic) { @@ -1524,7 +1494,7 @@ init_fringe_bitmap (which, fb, once_p) | (swap_nibble[(b>>8) & 0xf] << 4) | (swap_nibble[(b>>12) & 0xf])); b >>= (16 - fb->width); -#ifdef WORDS_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN b = ((b >> 8) | (b << 8)); #endif *bits++ = b; @@ -1564,8 +1534,7 @@ is used; the default is to center the bitmap. Fifth arg may also be a list (ALIGN PERIODIC) where PERIODIC non-nil specifies that the bitmap should be repeated. If BITMAP already exists, the existing definition is replaced. */) - (bitmap, bits, height, width, align) - Lisp_Object bitmap, bits, height, width, align; + (Lisp_Object bitmap, Lisp_Object bits, Lisp_Object height, Lisp_Object width, Lisp_Object align) { int n, h, i, j; unsigned short *b; @@ -1669,7 +1638,7 @@ If BITMAP already exists, the existing definition is replaced. */) xfb = (struct fringe_bitmap *) xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW); fb.bits = b = (unsigned short *) (xfb + 1); - bzero (b, fb.height); + memset (b, 0, fb.height); j = 0; while (j < fb.height) @@ -1696,8 +1665,7 @@ DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_fac 1, 2, 0, doc: /* Set face for fringe bitmap BITMAP to FACE. If FACE is nil, reset face to default fringe face. */) - (bitmap, face) - Lisp_Object bitmap, face; + (Lisp_Object bitmap, Lisp_Object face) { int n; int face_id; @@ -1729,8 +1697,7 @@ is the symbol for the bitmap in the left fringe (or nil if no bitmap), RIGHT is similar for the right fringe, and OV is non-nil if there is an overlay arrow in the left fringe. Return nil if POS is not visible in WINDOW. */) - (pos, window) - Lisp_Object pos, window; + (Lisp_Object pos, Lisp_Object window) { struct window *w; struct glyph_row *row; @@ -1769,7 +1736,7 @@ Return nil if POS is not visible in WINDOW. */) ***********************************************************************/ void -syms_of_fringe () +syms_of_fringe (void) { Qtruncation = intern_c_string ("truncation"); staticpro (&Qtruncation); @@ -1806,7 +1773,7 @@ If nil, also continue lines which are exactly as wide as the window. */); /* Garbage collection hook */ void -mark_fringe_data () +mark_fringe_data (void) { int i; @@ -1818,7 +1785,7 @@ mark_fringe_data () /* Initialize this module when Emacs starts. */ void -init_fringe_once () +init_fringe_once (void) { int bt; @@ -1827,7 +1794,7 @@ init_fringe_once () } void -init_fringe () +init_fringe (void) { int i; @@ -1863,7 +1830,7 @@ w32_init_fringe (struct redisplay_interface *rif) } void -w32_reset_fringes () +w32_reset_fringes (void) { /* Destroy row bitmaps. */ int bt; diff --git a/src/ftfont.c b/src/ftfont.c index 4699c74470f..b0d10791379 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -80,27 +80,27 @@ enum ftfont_cache_for FTFONT_CACHE_FOR_ENTITY }; -static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object)); +static Lisp_Object ftfont_pattern_entity (FcPattern *, Lisp_Object); -static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object, - FcPattern *)); -static Lisp_Object ftfont_lookup_cache P_ ((Lisp_Object, - enum ftfont_cache_for)); +static Lisp_Object ftfont_resolve_generic_family (Lisp_Object, + FcPattern *); +static Lisp_Object ftfont_lookup_cache (Lisp_Object, + enum ftfont_cache_for); -static void ftfont_filter_properties P_ ((Lisp_Object font, Lisp_Object alist)); +static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist); -Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object)); +Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object); #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) static struct { /* registry name */ - char *name; + const char *name; /* characters to distinguish the charset from the others */ int uniquifier[6]; /* additional constraint by language */ - char *lang; + const char *lang; /* set on demand */ FcCharSet *fc_charset; } fc_charset_table[] = @@ -144,8 +144,6 @@ static struct { NULL } }; -extern Lisp_Object Qc, Qm, Qp, Qd; - /* Dirty hack for handing ADSTYLE property. Fontconfig (actually the underlying FreeType) gives such ADSTYLE @@ -188,9 +186,7 @@ get_adstyle_property (FcPattern *p) } static Lisp_Object -ftfont_pattern_entity (p, extra) - FcPattern *p; - Lisp_Object extra; +ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) { Lisp_Object key, cache, entity; char *file, *str; @@ -289,9 +285,7 @@ ftfont_pattern_entity (p, extra) static Lisp_Object ftfont_generic_family_list; static Lisp_Object -ftfont_resolve_generic_family (family, pattern) - Lisp_Object family; - FcPattern *pattern; +ftfont_resolve_generic_family (Lisp_Object family, FcPattern *pattern) { Lisp_Object slot; FcPattern *match; @@ -348,9 +342,7 @@ struct ftfont_cache_data }; static Lisp_Object -ftfont_lookup_cache (key, cache_for) - Lisp_Object key; - enum ftfont_cache_for cache_for; +ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) { Lisp_Object cache, val, entity; struct ftfont_cache_data *cache_data; @@ -450,8 +442,7 @@ ftfont_lookup_cache (key, cache_for) } FcCharSet * -ftfont_get_fc_charset (entity) - Lisp_Object entity; +ftfont_get_fc_charset (Lisp_Object entity) { Lisp_Object val, cache; struct ftfont_cache_data *cache_data; @@ -464,8 +455,7 @@ ftfont_get_fc_charset (entity) #ifdef HAVE_LIBOTF static OTF * -ftfont_get_otf (ftfont_info) - struct ftfont_info *ftfont_info; +ftfont_get_otf (struct ftfont_info *ftfont_info) { OTF *otf; @@ -486,26 +476,26 @@ ftfont_get_otf (ftfont_info) } #endif /* HAVE_LIBOTF */ -static Lisp_Object ftfont_get_cache P_ ((FRAME_PTR)); -static Lisp_Object ftfont_list P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object ftfont_match P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object ftfont_list_family P_ ((Lisp_Object)); -static Lisp_Object ftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); -static void ftfont_close P_ ((FRAME_PTR, struct font *)); -static int ftfont_has_char P_ ((Lisp_Object, int)); -static unsigned ftfont_encode_char P_ ((struct font *, int)); -static int ftfont_text_extents P_ ((struct font *, unsigned *, int, - struct font_metrics *)); -static int ftfont_get_bitmap P_ ((struct font *, unsigned, - struct font_bitmap *, int)); -static int ftfont_anchor_point P_ ((struct font *, unsigned, int, - int *, int *)); -static Lisp_Object ftfont_otf_capability P_ ((struct font *)); -static Lisp_Object ftfont_shape P_ ((Lisp_Object)); +static Lisp_Object ftfont_get_cache (FRAME_PTR); +static Lisp_Object ftfont_list (Lisp_Object, Lisp_Object); +static Lisp_Object ftfont_match (Lisp_Object, Lisp_Object); +static Lisp_Object ftfont_list_family (Lisp_Object); +static Lisp_Object ftfont_open (FRAME_PTR, Lisp_Object, int); +static void ftfont_close (FRAME_PTR, struct font *); +static int ftfont_has_char (Lisp_Object, int); +static unsigned ftfont_encode_char (struct font *, int); +static int ftfont_text_extents (struct font *, unsigned *, int, + struct font_metrics *); +static int ftfont_get_bitmap (struct font *, unsigned, + struct font_bitmap *, int); +static int ftfont_anchor_point (struct font *, unsigned, int, + int *, int *); +static Lisp_Object ftfont_otf_capability (struct font *); +static Lisp_Object ftfont_shape (Lisp_Object); #ifdef HAVE_OTF_GET_VARIATION_GLYPHS -static int ftfont_variation_glyphs P_ ((struct font *, int c, - unsigned variations[256])); +static int ftfont_variation_glyphs (struct font *, int c, + unsigned variations[256]); #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ struct font_driver ftfont_driver = @@ -556,18 +546,14 @@ struct font_driver ftfont_driver = ftfont_filter_properties, /* filter_properties */ }; -extern Lisp_Object QCname; - static Lisp_Object -ftfont_get_cache (f) - FRAME_PTR f; +ftfont_get_cache (FRAME_PTR f) { return freetype_font_cache; } static int -ftfont_get_charset (registry) - Lisp_Object registry; +ftfont_get_charset (Lisp_Object registry) { char *str = (char *) SDATA (SYMBOL_NAME (registry)); char *re = alloca (SBYTES (SYMBOL_NAME (registry)) * 2 + 1); @@ -705,16 +691,8 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec) return spec; } -static FcPattern *ftfont_spec_pattern P_ ((Lisp_Object, char *, - struct OpenTypeSpec **, - char **langname)); - static FcPattern * -ftfont_spec_pattern (spec, otlayout, otspec, langname) - Lisp_Object spec; - char *otlayout; - struct OpenTypeSpec **otspec; - char **langname; +ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **otspec, const char **langname) { Lisp_Object tmp, extra; FcPattern *pattern = NULL; @@ -871,8 +849,7 @@ ftfont_spec_pattern (spec, otlayout, otspec, langname) } static Lisp_Object -ftfont_list (frame, spec) - Lisp_Object frame, spec; +ftfont_list (Lisp_Object frame, Lisp_Object spec) { Lisp_Object val = Qnil, family, adstyle; int i; @@ -885,7 +862,7 @@ ftfont_list (frame, spec) char otlayout[15]; /* For "otlayout:XXXX" */ struct OpenTypeSpec *otspec = NULL; int spacing = -1; - char *langname = NULL; + const char *langname = NULL; if (! fc_initialized) { @@ -1069,15 +1046,14 @@ ftfont_list (frame, spec) } static Lisp_Object -ftfont_match (frame, spec) - Lisp_Object frame, spec; +ftfont_match (Lisp_Object frame, Lisp_Object spec) { Lisp_Object entity = Qnil; FcPattern *pattern, *match = NULL; FcResult result; char otlayout[15]; /* For "otlayout:XXXX" */ struct OpenTypeSpec *otspec = NULL; - char *langname = NULL; + const char *langname = NULL; if (! fc_initialized) { @@ -1120,8 +1096,7 @@ ftfont_match (frame, spec) } static Lisp_Object -ftfont_list_family (frame) - Lisp_Object frame; +ftfont_list_family (Lisp_Object frame) { Lisp_Object list = Qnil; FcPattern *pattern = NULL; @@ -1164,10 +1139,7 @@ ftfont_list_family (frame) static Lisp_Object -ftfont_open (f, entity, pixel_size) - FRAME_PTR f; - Lisp_Object entity; - int pixel_size; +ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) { struct ftfont_info *ftfont_info; struct font *font; @@ -1307,9 +1279,7 @@ ftfont_open (f, entity, pixel_size) } static void -ftfont_close (f, font) - FRAME_PTR f; - struct font *font; +ftfont_close (FRAME_PTR f, struct font *font) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; Lisp_Object val, cache; @@ -1335,9 +1305,7 @@ ftfont_close (f, font) } static int -ftfont_has_char (font, c) - Lisp_Object font; - int c; +ftfont_has_char (Lisp_Object font, int c) { struct charset *cs = NULL; @@ -1367,9 +1335,7 @@ ftfont_has_char (font, c) } static unsigned -ftfont_encode_char (font, c) - struct font *font; - int c; +ftfont_encode_char (struct font *font, int c) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; @@ -1380,11 +1346,7 @@ ftfont_encode_char (font, c) } static int -ftfont_text_extents (font, code, nglyphs, metrics) - struct font *font; - unsigned *code; - int nglyphs; - struct font_metrics *metrics; +ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; @@ -1394,7 +1356,7 @@ ftfont_text_extents (font, code, nglyphs, metrics) if (ftfont_info->ft_size != ft_face->size) FT_Activate_Size (ftfont_info->ft_size); if (metrics) - bzero (metrics, sizeof (struct font_metrics)); + memset (metrics, 0, sizeof (struct font_metrics)); for (i = 0, first = 1; i < nglyphs; i++) { if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) @@ -1439,11 +1401,7 @@ ftfont_text_extents (font, code, nglyphs, metrics) } static int -ftfont_get_bitmap (font, code, bitmap, bits_per_pixel) - struct font *font; - unsigned code; - struct font_bitmap *bitmap; - int bits_per_pixel; +ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bitmap, int bits_per_pixel) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; @@ -1487,11 +1445,7 @@ ftfont_get_bitmap (font, code, bitmap, bits_per_pixel) } static int -ftfont_anchor_point (font, code, index, x, y) - struct font *font; - unsigned code; - int index; - int *x, *y; +ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, int *y) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; @@ -1512,8 +1466,7 @@ ftfont_anchor_point (font, code, index, x, y) #ifdef HAVE_LIBOTF static Lisp_Object -ftfont_otf_features (gsub_gpos) - OTF_GSUB_GPOS *gsub_gpos; +ftfont_otf_features (OTF_GSUB_GPOS *gsub_gpos) { Lisp_Object scripts, langsyses, features, sym; int i, j, k, l; @@ -1557,8 +1510,7 @@ ftfont_otf_features (gsub_gpos) static Lisp_Object -ftfont_otf_capability (font) - struct font *font; +ftfont_otf_capability (struct font *font) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; OTF *otf = ftfont_get_otf (ftfont_info); @@ -1596,10 +1548,8 @@ struct MFLTFontFT }; static int -ftfont_get_glyph_id (font, gstring, from, to) - MFLTFont *font; - MFLTGlyphString *gstring; - int from, to; +ftfont_get_glyph_id (MFLTFont *font, MFLTGlyphString *gstring, + int from, int to) { struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; FT_Face ft_face = flt_font_ft->ft_face; @@ -1623,10 +1573,8 @@ ftfont_get_glyph_id (font, gstring, from, to) #define ROUND(x) (((x)+32) & -64) static int -ftfont_get_metrics (font, gstring, from, to) - MFLTFont *font; - MFLTGlyphString *gstring; - int from, to; +ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring, + int from, int to) { struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; FT_Face ft_face = flt_font_ft->ft_face; @@ -1684,38 +1632,70 @@ ftfont_get_metrics (font, gstring, from, to) static int ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec) { +#define FEATURE_NONE(IDX) (! spec->features[IDX]) + +#define FEATURE_ANY(IDX) \ + (spec->features[IDX] \ + && spec->features[IDX][0] == 0xFFFFFFFF && spec->features[IDX][1] == 0) + struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; OTF *otf = flt_font_ft->otf; OTF_Tag *tags; int i, n, negative; + if (FEATURE_ANY (0) && FEATURE_ANY (1)) + /* Return 1 iff any of GSUB or GPOS support the script (and language). */ + return (otf + && (OTF_check_features (otf, 0, spec->script, spec->langsys, + NULL, 0) > 0 + || OTF_check_features (otf, 1, spec->script, spec->langsys, + NULL, 0) > 0)); + for (i = 0; i < 2; i++) - { - if (! spec->features[i]) - continue; - for (n = 0; spec->features[i][n]; n++); - tags = alloca (sizeof (OTF_Tag) * n); - for (n = 0, negative = 0; spec->features[i][n]; n++) - { - if (spec->features[i][n] == 0xFFFFFFFF) - negative = 1; - else if (negative) - tags[n - 1] = spec->features[i][n] | 0x80000000; - else - tags[n] = spec->features[i][n]; - } + if (! FEATURE_ANY (i)) + { + if (FEATURE_NONE (i)) + { + if (otf + && OTF_check_features (otf, i == 0, spec->script, spec->langsys, + NULL, 0) > 0) + return 0; + continue; + } + if (spec->features[i][0] == 0xFFFFFFFF) + { + if (! otf + || OTF_check_features (otf, i == 0, spec->script, spec->langsys, + NULL, 0) <= 0) + continue; + } + else if (! otf) + return 0; + for (n = 1; spec->features[i][n]; n++); + tags = alloca (sizeof (OTF_Tag) * n); + for (n = 0, negative = 0; spec->features[i][n]; n++) + { + if (spec->features[i][n] == 0xFFFFFFFF) + negative = 1; + else if (negative) + tags[n - 1] = spec->features[i][n] | 0x80000000; + else + tags[n] = spec->features[i][n]; + } #ifdef M17N_FLT_USE_NEW_FEATURE - if (OTF_check_features (otf, i == 0, spec->script, spec->langsys, - tags, n - negative) != 1) - return 0; + if (OTF_check_features (otf, i == 0, spec->script, spec->langsys, + tags, n - negative) != 1) + return 0; #else /* not M17N_FLT_USE_NEW_FEATURE */ - if (n - negative > 0 - && OTF_check_features (otf, i == 0, spec->script, spec->langsys, - tags, n - negative) != 1) - return 0; + if (n - negative > 0 + && OTF_check_features (otf, i == 0, spec->script, spec->langsys, + tags, n - negative) != 1) + return 0; #endif /* not M17N_FLT_USE_NEW_FEATURE */ - } + } return 1; +#undef FEATURE_NONE +#undef FEATURE_ANY } #define DEVICE_DELTA(table, size) \ @@ -2123,13 +2103,9 @@ ftfont_try_otf (MFLTFont *font, MFLTOtfSpec *spec, #else /* not M17N_FLT_USE_NEW_FEATURE */ static int -ftfont_drive_otf (font, spec, in, from, to, out, adjustment) - MFLTFont *font; - MFLTOtfSpec *spec; - MFLTGlyphString *in; - int from, to; - MFLTGlyphString *out; - MFLTGlyphAdjustment *adjustment; +ftfont_drive_otf (MFLTFont *font, MFLTOtfSpec *spec, MFLTGlyphString *in, + int from, int to, + MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment) { struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; FT_Face ft_face = flt_font_ft->ft_face; @@ -2381,15 +2357,9 @@ static MFLTGlyphString gstring; static int m17n_flt_initialized; -extern Lisp_Object QCfamily; - static Lisp_Object -ftfont_shape_by_flt (lgstring, font, ft_face, otf, matrix) - Lisp_Object lgstring; - struct font *font; - FT_Face ft_face; - OTF *otf; - FT_Matrix *matrix; +ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font, + FT_Face ft_face, OTF *otf, FT_Matrix *matrix) { EMACS_UINT len = LGSTRING_GLYPH_LEN (lgstring); EMACS_UINT i; @@ -2555,8 +2525,7 @@ ftfont_shape_by_flt (lgstring, font, ft_face, otf, matrix) } Lisp_Object -ftfont_shape (lgstring) - Lisp_Object lgstring; +ftfont_shape (Lisp_Object lgstring) { struct font *font; struct ftfont_info *ftfont_info; @@ -2576,10 +2545,7 @@ ftfont_shape (lgstring) #ifdef HAVE_OTF_GET_VARIATION_GLYPHS static int -ftfont_variation_glyphs (font, c, variations) - struct font *font; - int c; - unsigned variations[256]; +ftfont_variation_glyphs (struct font *font, int c, unsigned variations[256]) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; OTF *otf = ftfont_get_otf (ftfont_info); @@ -2677,16 +2643,14 @@ static const char *ftfont_non_booleans [] = { }; static void -ftfont_filter_properties (font, alist) - Lisp_Object font; - Lisp_Object alist; +ftfont_filter_properties (Lisp_Object font, Lisp_Object alist) { font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans); } void -syms_of_ftfont () +syms_of_ftfont (void) { DEFSYM (Qfreetype, "freetype"); DEFSYM (Qmonospace, "monospace"); diff --git a/src/ftfont.h b/src/ftfont.h index 7ad9b8a008c..9053c9ce81d 100644 --- a/src/ftfont.h +++ b/src/ftfont.h @@ -36,6 +36,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* HAVE_M17N_FLT */ #endif /* HAVE_LIBOTF */ +extern Lisp_Object ftfont_font_format (FcPattern *, Lisp_Object); +extern FcCharSet *ftfont_get_fc_charset (Lisp_Object); + #endif /* EMACS_FTFONT_H */ /* arch-tag: cec13d1c-7156-4997-9ebd-e989040c3d78 diff --git a/src/ftxfont.c b/src/ftxfont.c index 847522a2f9c..0a9137617b8 100644 --- a/src/ftxfont.c +++ b/src/ftxfont.c @@ -39,12 +39,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ static Lisp_Object Qftx; /* Prototypes for helper function. */ -static GC *ftxfont_get_gcs P_ ((FRAME_PTR, unsigned long, unsigned long)); -static int ftxfont_draw_bitmap P_ ((FRAME_PTR, GC, GC *, struct font *, - unsigned, int, int, XPoint *, int, int *, - int)); -static void ftxfont_draw_backgrond P_ ((FRAME_PTR, struct font *, GC, - int, int, int)); +static GC *ftxfont_get_gcs (FRAME_PTR, unsigned long, unsigned long); +static int ftxfont_draw_bitmap (FRAME_PTR, GC, GC *, struct font *, + unsigned, int, int, XPoint *, int, int *, + int); +static void ftxfont_draw_backgrond (FRAME_PTR, struct font *, GC, + int, int, int); struct ftxfont_frame_data { @@ -61,9 +61,7 @@ struct ftxfont_frame_data /* Return an array of 6 GCs for antialiasing. */ static GC * -ftxfont_get_gcs (f, foreground, background) - FRAME_PTR f; - unsigned long foreground, background; +ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int background) { XColor color; XGCValues xgcv; @@ -140,15 +138,7 @@ ftxfont_get_gcs (f, foreground, background) } static int -ftxfont_draw_bitmap (f, gc_fore, gcs, font, code, x, y, p, size, n, flush) - FRAME_PTR f; - GC gc_fore, *gcs; - struct font *font; - unsigned code; - int x, y; - XPoint *p; - int size, *n; - int flush; +ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font, unsigned int code, int x, int y, XPoint *p, int size, int *n, int flush) { struct font_bitmap bitmap; unsigned char *b; @@ -224,11 +214,7 @@ ftxfont_draw_bitmap (f, gc_fore, gcs, font, code, x, y, p, size, n, flush) } static void -ftxfont_draw_backgrond (f, font, gc, x, y, width) - FRAME_PTR f; - struct font *font; - GC gc; - int x, y, width; +ftxfont_draw_backgrond (FRAME_PTR f, struct font *font, GC gc, int x, int y, int width) { XGCValues xgcv; @@ -241,18 +227,16 @@ ftxfont_draw_backgrond (f, font, gc, x, y, width) } /* Prototypes for font-driver methods. */ -static Lisp_Object ftxfont_list P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object ftxfont_match P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object ftxfont_open P_ ((FRAME_PTR, Lisp_Object, int)); -static void ftxfont_close P_ ((FRAME_PTR, struct font *)); -static int ftxfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); +static Lisp_Object ftxfont_list (Lisp_Object, Lisp_Object); +static Lisp_Object ftxfont_match (Lisp_Object, Lisp_Object); +static Lisp_Object ftxfont_open (FRAME_PTR, Lisp_Object, int); +static void ftxfont_close (FRAME_PTR, struct font *); +static int ftxfont_draw (struct glyph_string *, int, int, int, int, int); struct font_driver ftxfont_driver; static Lisp_Object -ftxfont_list (frame, spec) - Lisp_Object frame; - Lisp_Object spec; +ftxfont_list (Lisp_Object frame, Lisp_Object spec) { Lisp_Object list = ftfont_driver.list (frame, spec), tail; @@ -262,9 +246,7 @@ ftxfont_list (frame, spec) } static Lisp_Object -ftxfont_match (frame, spec) - Lisp_Object frame; - Lisp_Object spec; +ftxfont_match (Lisp_Object frame, Lisp_Object spec) { Lisp_Object entity = ftfont_driver.match (frame, spec); @@ -274,10 +256,7 @@ ftxfont_match (frame, spec) } static Lisp_Object -ftxfont_open (f, entity, pixel_size) - FRAME_PTR f; - Lisp_Object entity; - int pixel_size; +ftxfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) { Lisp_Object font_object; struct font *font; @@ -291,17 +270,13 @@ ftxfont_open (f, entity, pixel_size) } static void -ftxfont_close (f, font) - FRAME_PTR f; - struct font *font; +ftxfont_close (FRAME_PTR f, struct font *font) { ftfont_driver.close (f, font); } static int -ftxfont_draw (s, from, to, x, y, with_background) - struct glyph_string *s; - int from, to, x, y, with_background; +ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) { FRAME_PTR f = s->f; struct face *face = s->face; @@ -372,8 +347,7 @@ ftxfont_draw (s, from, to, x, y, with_background) } static int -ftxfont_end_for_frame (f) - FRAME_PTR f; +ftxfont_end_for_frame (FRAME_PTR f) { struct ftxfont_frame_data *data = font_get_frame_data (f, &ftxfont_driver); @@ -396,7 +370,7 @@ ftxfont_end_for_frame (f) void -syms_of_ftxfont () +syms_of_ftxfont (void) { DEFSYM (Qftx, "ftx"); diff --git a/src/getloadavg.c b/src/getloadavg.c index a174fc07a01..779a0ef804c 100644 --- a/src/getloadavg.c +++ b/src/getloadavg.c @@ -713,7 +713,7 @@ getloadavg (loadavg, nelem) for (i = 0; i < conf.config_maxclass; ++i) { struct class_stats stats; - bzero ((char *) &stats, sizeof stats); + memset (&stats, 0, sizeof stats); desc.sd_type = CPUTYPE_CLASS; desc.sd_objid = i; diff --git a/src/gmalloc.c b/src/gmalloc.c index f1be37ba348..8314798b171 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -42,8 +42,7 @@ Fifth Floor, Boston, MA 02110-1301, USA. #endif #if ((defined __cplusplus || (defined (__STDC__) && __STDC__) \ - || defined STDC_HEADERS || defined PROTOTYPES) \ - && ! defined (BROKEN_PROTOTYPES)) + || defined STDC_HEADERS || defined PROTOTYPES)) #undef PP #define PP(args) args #undef __ptr_t @@ -122,7 +121,7 @@ extern __ptr_t calloc PP ((__malloc_size_t __nmemb, __malloc_size_t __size)); extern void free PP ((__ptr_t __ptr)); /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ -#if ! (defined (_MALLOC_INTERNAL) && __DJGPP__ - 0 == 1) /* Avoid conflict. */ +#if !defined (_MALLOC_INTERNAL) || defined (MSDOS) /* Avoid conflict. */ extern __ptr_t memalign PP ((__malloc_size_t __alignment, __malloc_size_t __size)); extern int posix_memalign PP ((__ptr_t *, __malloc_size_t, @@ -1763,13 +1762,6 @@ Fifth Floor, Boston, MA 02110-1301, USA. */ #include <malloc.h> #endif -#if __DJGPP__ - 0 == 1 - -/* There is some problem with memalign in DJGPP v1 and we are supposed - to omit it. Noone told me why, they just told me to do it. */ - -#else - __ptr_t (*__memalign_hook) PP ((__malloc_size_t __size, __malloc_size_t __alignment)); @@ -1878,7 +1870,6 @@ posix_memalign (memptr, alignment, size) return 0; } -#endif /* Not DJGPP v1 */ /* Allocate memory on a page boundary. Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc. @@ -1978,12 +1969,12 @@ Fifth Floor, Boston, MA 02110-1301, USA. #endif /* Old hook values. */ -static void (*old_free_hook) __P ((__ptr_t ptr)); -static __ptr_t (*old_malloc_hook) __P ((__malloc_size_t size)); -static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, __malloc_size_t size)); +static void (*old_free_hook) (__ptr_t ptr); +static __ptr_t (*old_malloc_hook) (__malloc_size_t size); +static __ptr_t (*old_realloc_hook) (__ptr_t ptr, __malloc_size_t size); /* Function to call when something awful happens. */ -static void (*abortfunc) __P ((enum mcheck_status)); +static void (*abortfunc) (enum mcheck_status); /* Arbitrary magical numbers. */ #define MAGICWORD 0xfedabeeb @@ -2001,7 +1992,7 @@ struct hdr #if defined(_LIBC) || defined(STDC_HEADERS) || defined(USG) #define flood memset #else -static void flood __P ((__ptr_t, int, __malloc_size_t)); +static void flood (__ptr_t, int, __malloc_size_t); static void flood (ptr, val, size) __ptr_t ptr; @@ -2014,7 +2005,7 @@ flood (ptr, val, size) } #endif -static enum mcheck_status checkhdr __P ((const struct hdr *)); +static enum mcheck_status checkhdr (const struct hdr *); static enum mcheck_status checkhdr (hdr) const struct hdr *hdr; @@ -2040,7 +2031,7 @@ checkhdr (hdr) return status; } -static void freehook __P ((__ptr_t)); +static void freehook (__ptr_t); static void freehook (ptr) __ptr_t ptr; @@ -2062,7 +2053,7 @@ freehook (ptr) __free_hook = freehook; } -static __ptr_t mallochook __P ((__malloc_size_t)); +static __ptr_t mallochook (__malloc_size_t); static __ptr_t mallochook (size) __malloc_size_t size; @@ -2082,7 +2073,7 @@ mallochook (size) return (__ptr_t) (hdr + 1); } -static __ptr_t reallochook __P ((__ptr_t, __malloc_size_t)); +static __ptr_t reallochook (__ptr_t, __malloc_size_t); static __ptr_t reallochook (ptr, size) __ptr_t ptr; @@ -2155,7 +2146,7 @@ static int mcheck_used = 0; int mcheck (func) - void (*func) __P ((enum mcheck_status)); + void (*func) (enum mcheck_status); { abortfunc = (func != NULL) ? func : &mabort; diff --git a/src/gnutls.c b/src/gnutls.c new file mode 100644 index 00000000000..577cca247ee --- /dev/null +++ b/src/gnutls.c @@ -0,0 +1,631 @@ +/* GnuTLS glue for GNU Emacs. + Copyright (C) 2010 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> +#include <errno.h> +#include <setjmp.h> + +#include "lisp.h" +#include "process.h" + +#ifdef HAVE_GNUTLS +#include <gnutls/gnutls.h> + +Lisp_Object Qgnutls_code; +Lisp_Object Qgnutls_anon, Qgnutls_x509pki; +Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again, + Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake; +int global_initialized; + +/* The following are for the property list of `gnutls-boot'. */ +Lisp_Object Qgnutls_bootprop_priority; +Lisp_Object Qgnutls_bootprop_trustfiles; +Lisp_Object Qgnutls_bootprop_keyfiles; +Lisp_Object Qgnutls_bootprop_callbacks; +Lisp_Object Qgnutls_bootprop_loglevel; + +static void +emacs_gnutls_handshake (struct Lisp_Process *proc) +{ + gnutls_session_t state = proc->gnutls_state; + int ret; + + if (proc->gnutls_initstage < GNUTLS_STAGE_HANDSHAKE_CANDO) + return; + + if (proc->gnutls_initstage < GNUTLS_STAGE_TRANSPORT_POINTERS_SET) + { + /* This is how GnuTLS takes sockets: as file descriptors passed + in. For an Emacs process socket, infd and outfd are the + same but we use this two-argument version for clarity. */ + gnutls_transport_set_ptr2 (state, + (gnutls_transport_ptr_t) (long) proc->infd, + (gnutls_transport_ptr_t) (long) proc->outfd); + + proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; + } + + ret = gnutls_handshake (state); + proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; + + if (ret == GNUTLS_E_SUCCESS) + { + /* here we're finally done. */ + proc->gnutls_initstage = GNUTLS_STAGE_READY; + } +} + +int +emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, + unsigned int nbyte) +{ + register int rtnval, bytes_written; + gnutls_session_t state = proc->gnutls_state; + + if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { +#ifdef EWOULDBLOCK + errno = EWOULDBLOCK; +#endif +#ifdef EAGAIN + errno = EAGAIN; +#endif + return -1; + } + + bytes_written = 0; + + while (nbyte > 0) + { + rtnval = gnutls_write (state, buf, nbyte); + + if (rtnval < 0) + { + if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED) + continue; + else + return (bytes_written ? bytes_written : -1); + } + + buf += rtnval; + nbyte -= rtnval; + bytes_written += rtnval; + } + + return (bytes_written); +} + +int +emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, + unsigned int nbyte) +{ + register int rtnval; + gnutls_session_t state = proc->gnutls_state; + + if (proc->gnutls_initstage != GNUTLS_STAGE_READY) + { + emacs_gnutls_handshake (proc); + return -1; + } + + rtnval = gnutls_read (state, buf, nbyte); + if (rtnval >= 0) + return rtnval; + else + return -1; +} + +/* convert an integer error to a Lisp_Object; it will be either a + known symbol like `gnutls_e_interrupted' and `gnutls_e_again' or + simply the integer value of the error. GNUTLS_E_SUCCESS is mapped + to Qt. */ +static Lisp_Object +gnutls_make_error (int error) +{ + switch (error) + { + case GNUTLS_E_SUCCESS: + return Qt; + case GNUTLS_E_AGAIN: + return Qgnutls_e_again; + case GNUTLS_E_INTERRUPTED: + return Qgnutls_e_interrupted; + case GNUTLS_E_INVALID_SESSION: + return Qgnutls_e_invalid_session; + } + + return make_number (error); +} + +DEFUN ("gnutls-get-initstage", Fgnutls_get_initstage, Sgnutls_get_initstage, 1, 1, 0, + doc: /* Return the GnuTLS init stage of process PROC. +See also `gnutls-boot'. */) + (Lisp_Object proc) +{ + CHECK_PROCESS (proc); + + return make_number (GNUTLS_INITSTAGE (proc)); +} + +DEFUN ("gnutls-errorp", Fgnutls_errorp, Sgnutls_errorp, 1, 1, 0, + doc: /* Return t if ERROR indicates a GnuTLS problem. +ERROR is an integer or a symbol with an integer `gnutls-code' property. +usage: (gnutls-errorp ERROR) */) + (Lisp_Object err) +{ + if (EQ (err, Qt)) return Qnil; + + return Qt; +} + +DEFUN ("gnutls-error-fatalp", Fgnutls_error_fatalp, Sgnutls_error_fatalp, 1, 1, 0, + doc: /* Check if ERROR is fatal. +ERROR is an integer or a symbol with an integer `gnutls-code' property. +usage: (gnutls-error-fatalp ERROR) */) + (Lisp_Object err) +{ + Lisp_Object code; + + if (EQ (err, Qt)) return Qnil; + + if (SYMBOLP (err)) + { + code = Fget (err, Qgnutls_code); + if (NUMBERP (code)) + { + err = code; + } + else + { + error ("Symbol has no numeric gnutls-code property"); + } + } + + if (!NUMBERP (err)) + error ("Not an error symbol or code"); + + if (0 == gnutls_error_is_fatal (XINT (err))) + return Qnil; + + return Qt; +} + +DEFUN ("gnutls-error-string", Fgnutls_error_string, Sgnutls_error_string, 1, 1, 0, + doc: /* Return a description of ERROR. +ERROR is an integer or a symbol with an integer `gnutls-code' property. +usage: (gnutls-error-string ERROR) */) + (Lisp_Object err) +{ + Lisp_Object code; + + if (EQ (err, Qt)) return build_string ("Not an error"); + + if (SYMBOLP (err)) + { + code = Fget (err, Qgnutls_code); + if (NUMBERP (code)) + { + err = code; + } + else + { + return build_string ("Symbol has no numeric gnutls-code property"); + } + } + + if (!NUMBERP (err)) + return build_string ("Not an error symbol or code"); + + return build_string (gnutls_strerror (XINT (err))); +} + +DEFUN ("gnutls-deinit", Fgnutls_deinit, Sgnutls_deinit, 1, 1, 0, + doc: /* Deallocate GnuTLS resources associated with process PROC. +See also `gnutls-init'. */) + (Lisp_Object proc) +{ + gnutls_session_t state; + + CHECK_PROCESS (proc); + state = XPROCESS (proc)->gnutls_state; + + if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) + { + gnutls_deinit (state); + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1; + } + + return Qt; +} + +/* Initializes global GnuTLS state to defaults. +Call `gnutls-global-deinit' when GnuTLS usage is no longer needed. +Returns zero on success. */ +static Lisp_Object +gnutls_emacs_global_init (void) +{ + int ret = GNUTLS_E_SUCCESS; + + if (!global_initialized) + ret = gnutls_global_init (); + + global_initialized = 1; + + return gnutls_make_error (ret); +} + +/* Deinitializes global GnuTLS state. +See also `gnutls-global-init'. */ +static Lisp_Object +gnutls_emacs_global_deinit (void) +{ + if (global_initialized) + gnutls_global_deinit (); + + global_initialized = 0; + + return gnutls_make_error (GNUTLS_E_SUCCESS); +} + +static void +gnutls_log_function (int level, const char* string) +{ + message ("gnutls.c: [%d] %s", level, string); +} + +static void +gnutls_log_function2 (int level, const char* string, const char* extra) +{ + message ("gnutls.c: [%d] %s %s", level, string, extra); +} + +DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, + doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST. +Currently only client mode is supported. Returns a success/failure +value you can check with `gnutls-errorp'. + +TYPE is a symbol, either `gnutls-anon' or `gnutls-x509pki'. +PROPLIST is a property list with the following keys: + +:priority is a GnuTLS priority string, defaults to "NORMAL". +:trustfiles is a list of PEM-encoded trust files for `gnutls-x509pki'. +:keyfiles is a list of PEM-encoded key files for `gnutls-x509pki'. +:callbacks is an alist of callback functions (TODO). +:loglevel is the debug level requested from GnuTLS, try 4. + +The debug level will be set for this process AND globally for GnuTLS. +So if you set it higher or lower at any point, it affects global +debugging. + +Note that the priority is set on the client. The server does not use +the protocols's priority except for disabling protocols that were not +specified. + +Processes must be initialized with this function before other GnuTLS +functions are used. This function allocates resources which can only +be deallocated by calling `gnutls-deinit' or by calling it again. + +Each authentication type may need additional information in order to +work. For X.509 PKI (`gnutls-x509pki'), you probably need at least +one trustfile (usually a CA bundle). */) + (Lisp_Object proc, Lisp_Object type, Lisp_Object proplist) +{ + int ret = GNUTLS_E_SUCCESS; + + int max_log_level = 0; + + /* TODO: GNUTLS_X509_FMT_DER is also an option. */ + int file_format = GNUTLS_X509_FMT_PEM; + + gnutls_session_t state; + gnutls_certificate_credentials_t x509_cred; + gnutls_anon_client_credentials_t anon_cred; + Lisp_Object global_init; + char* priority_string_ptr = "NORMAL"; /* default priority string. */ + Lisp_Object tail; + + /* Placeholders for the property list elements. */ + Lisp_Object priority_string; + Lisp_Object trustfiles; + Lisp_Object keyfiles; + Lisp_Object callbacks; + Lisp_Object loglevel; + + CHECK_PROCESS (proc); + CHECK_SYMBOL (type); + CHECK_LIST (proplist); + + priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); + trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); + keyfiles = Fplist_get (proplist, Qgnutls_bootprop_keyfiles); + callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); + loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); + + state = XPROCESS (proc)->gnutls_state; + XPROCESS (proc)->gnutls_p = 1; + + if (NUMBERP (loglevel)) + { + gnutls_global_set_log_function (gnutls_log_function); + gnutls_global_set_log_level (XINT (loglevel)); + max_log_level = XINT (loglevel); + XPROCESS (proc)->gnutls_log_level = max_log_level; + } + + /* always initialize globals. */ + global_init = gnutls_emacs_global_init (); + if (! NILP (Fgnutls_errorp (global_init))) + return global_init; + + /* deinit and free resources. */ + if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC) + { + GNUTLS_LOG (1, max_log_level, "deallocating credentials"); + + if (EQ (type, Qgnutls_x509pki)) + { + GNUTLS_LOG (2, max_log_level, "deallocating x509 credentials"); + x509_cred = XPROCESS (proc)->gnutls_x509_cred; + gnutls_certificate_free_credentials (x509_cred); + } + else if (EQ (type, Qgnutls_anon)) + { + GNUTLS_LOG (2, max_log_level, "deallocating anon credentials"); + anon_cred = XPROCESS (proc)->gnutls_anon_cred; + gnutls_anon_free_client_credentials (anon_cred); + } + else + { + error ("unknown credential type"); + ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; + } + + if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) + { + GNUTLS_LOG (1, max_log_level, "deallocating x509 credentials"); + Fgnutls_deinit (proc); + } + } + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; + + GNUTLS_LOG (1, max_log_level, "allocating credentials"); + + if (EQ (type, Qgnutls_x509pki)) + { + GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); + x509_cred = XPROCESS (proc)->gnutls_x509_cred; + if (gnutls_certificate_allocate_credentials (&x509_cred) < 0) + memory_full (); + } + else if (EQ (type, Qgnutls_anon)) + { + GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); + anon_cred = XPROCESS (proc)->gnutls_anon_cred; + if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0) + memory_full (); + } + else + { + error ("unknown credential type"); + ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; + } + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC; + + if (EQ (type, Qgnutls_x509pki)) + { + for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail)) + { + Lisp_Object trustfile = Fcar (tail); + if (STRINGP (trustfile)) + { + GNUTLS_LOG2 (1, max_log_level, "setting the trustfile: ", + SDATA (trustfile)); + ret = gnutls_certificate_set_x509_trust_file + (x509_cred, + SDATA (trustfile), + file_format); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + } + else + { + error ("Sorry, GnuTLS can't use non-string trustfile %s", + trustfile); + } + } + + for (tail = keyfiles; !NILP (tail); tail = Fcdr (tail)) + { + Lisp_Object keyfile = Fcar (tail); + if (STRINGP (keyfile)) + { + GNUTLS_LOG2 (1, max_log_level, "setting the keyfile: ", + SDATA (keyfile)); + ret = gnutls_certificate_set_x509_crl_file + (x509_cred, + SDATA (keyfile), + file_format); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + } + else + { + error ("Sorry, GnuTLS can't use non-string keyfile %s", + keyfile); + } + } + } + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; + + GNUTLS_LOG (1, max_log_level, "gnutls_init"); + + ret = gnutls_init (&state, GNUTLS_CLIENT); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + XPROCESS (proc)->gnutls_state = state; + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT; + + if (STRINGP (priority_string)) + { + priority_string_ptr = (char*) SDATA (priority_string); + GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:", + priority_string_ptr); + } + else + { + GNUTLS_LOG2 (1, max_log_level, "using default priority string:", + priority_string_ptr); + } + + GNUTLS_LOG (1, max_log_level, "setting the priority string"); + + ret = gnutls_priority_set_direct (state, + priority_string_ptr, + NULL); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_PRIORITY; + + if (EQ (type, Qgnutls_x509pki)) + { + ret = gnutls_cred_set (state, GNUTLS_CRD_CERTIFICATE, x509_cred); + } + else if (EQ (type, Qgnutls_anon)) + { + ret = gnutls_cred_set (state, GNUTLS_CRD_ANON, anon_cred); + } + else + { + error ("unknown credential type"); + ret = GNUTLS_EMACS_ERROR_INVALID_TYPE; + } + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + XPROCESS (proc)->gnutls_anon_cred = anon_cred; + XPROCESS (proc)->gnutls_x509_cred = x509_cred; + XPROCESS (proc)->gnutls_cred_type = type; + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; + + emacs_gnutls_handshake (XPROCESS (proc)); + + return gnutls_make_error (GNUTLS_E_SUCCESS); +} + +DEFUN ("gnutls-bye", Fgnutls_bye, + Sgnutls_bye, 2, 2, 0, + doc: /* Terminate current GnuTLS connection for process PROC. +The connection should have been initiated using `gnutls-handshake'. + +If CONT is not nil the TLS connection gets terminated and further +receives and sends will be disallowed. If the return value is zero you +may continue using the connection. If CONT is nil, GnuTLS actually +sends an alert containing a close request and waits for the peer to +reply with the same message. In order to reuse the connection you +should wait for an EOF from the peer. + +This function may also return `gnutls-e-again', or +`gnutls-e-interrupted'. */) + (Lisp_Object proc, Lisp_Object cont) +{ + gnutls_session_t state; + int ret; + + CHECK_PROCESS (proc); + + state = XPROCESS (proc)->gnutls_state; + + ret = gnutls_bye (state, + NILP (cont) ? GNUTLS_SHUT_RDWR : GNUTLS_SHUT_WR); + + return gnutls_make_error (ret); +} + +void +syms_of_gnutls (void) +{ + global_initialized = 0; + + Qgnutls_code = intern_c_string ("gnutls-code"); + staticpro (&Qgnutls_code); + + Qgnutls_anon = intern_c_string ("gnutls-anon"); + staticpro (&Qgnutls_anon); + + Qgnutls_x509pki = intern_c_string ("gnutls-x509pki"); + staticpro (&Qgnutls_x509pki); + + Qgnutls_bootprop_priority = intern_c_string (":priority"); + staticpro (&Qgnutls_bootprop_priority); + + Qgnutls_bootprop_trustfiles = intern_c_string (":trustfiles"); + staticpro (&Qgnutls_bootprop_trustfiles); + + Qgnutls_bootprop_keyfiles = intern_c_string (":keyfiles"); + staticpro (&Qgnutls_bootprop_keyfiles); + + Qgnutls_bootprop_callbacks = intern_c_string (":callbacks"); + staticpro (&Qgnutls_bootprop_callbacks); + + Qgnutls_bootprop_loglevel = intern_c_string (":loglevel"); + staticpro (&Qgnutls_bootprop_loglevel); + + Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted"); + staticpro (&Qgnutls_e_interrupted); + Fput (Qgnutls_e_interrupted, Qgnutls_code, + make_number (GNUTLS_E_INTERRUPTED)); + + Qgnutls_e_again = intern_c_string ("gnutls-e-again"); + staticpro (&Qgnutls_e_again); + Fput (Qgnutls_e_again, Qgnutls_code, + make_number (GNUTLS_E_AGAIN)); + + Qgnutls_e_invalid_session = intern_c_string ("gnutls-e-invalid-session"); + staticpro (&Qgnutls_e_invalid_session); + Fput (Qgnutls_e_invalid_session, Qgnutls_code, + make_number (GNUTLS_E_INVALID_SESSION)); + + Qgnutls_e_not_ready_for_handshake = + intern_c_string ("gnutls-e-not-ready-for-handshake"); + staticpro (&Qgnutls_e_not_ready_for_handshake); + Fput (Qgnutls_e_not_ready_for_handshake, Qgnutls_code, + make_number (GNUTLS_E_APPLICATION_ERROR_MIN)); + + defsubr (&Sgnutls_get_initstage); + defsubr (&Sgnutls_errorp); + defsubr (&Sgnutls_error_fatalp); + defsubr (&Sgnutls_error_string); + defsubr (&Sgnutls_boot); + defsubr (&Sgnutls_deinit); + defsubr (&Sgnutls_bye); +} +#endif diff --git a/src/gnutls.h b/src/gnutls.h new file mode 100644 index 00000000000..2669317e97a --- /dev/null +++ b/src/gnutls.h @@ -0,0 +1,64 @@ +/* GnuTLS glue for GNU Emacs. + Copyright (C) 2010 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef EMACS_GNUTLS_DEFINED +#define EMACS_GNUTLS_DEFINED + +#ifdef HAVE_GNUTLS +#include <gnutls/gnutls.h> + +typedef enum +{ + /* Initialization stages. */ + GNUTLS_STAGE_EMPTY = 0, + GNUTLS_STAGE_CRED_ALLOC, + GNUTLS_STAGE_FILES, + GNUTLS_STAGE_INIT, + GNUTLS_STAGE_PRIORITY, + GNUTLS_STAGE_CRED_SET, + + /* Handshake stages. */ + GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET, + GNUTLS_STAGE_TRANSPORT_POINTERS_SET, + GNUTLS_STAGE_HANDSHAKE_TRIED, + + GNUTLS_STAGE_READY, +} gnutls_initstage_t; + +#define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN + +#define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage) + +#define GNUTLS_PROCESS_USABLE(proc) (GNUTLS_INITSTAGE(proc) >= GNUTLS_STAGE_READY) + +#define GNUTLS_LOG(level, max, string) if (level <= max) { gnutls_log_function (level, "(Emacs) " string); } + +#define GNUTLS_LOG2(level, max, string, extra) if (level <= max) { gnutls_log_function2 (level, "(Emacs) " string, extra); } + +int +emacs_gnutls_write (int fildes, struct Lisp_Process *proc, char *buf, + unsigned int nbyte); +int +emacs_gnutls_read (int fildes, struct Lisp_Process *proc, char *buf, + unsigned int nbyte); + +extern void syms_of_gnutls (void); + +#endif + +#endif diff --git a/src/gtkutil.c b/src/gtkutil.c index 7a25bbb1e3f..3b7e6888753 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #ifdef USE_GTK -#include <string.h> #include <signal.h> #include <stdio.h> #include <setjmp.h> @@ -35,6 +34,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "charset.h" #include "coding.h" #include <gdk/gdkkeysyms.h> +#include "xsettings.h" #ifdef HAVE_XFT #include <X11/Xft/Xft.h> @@ -43,16 +43,40 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) +#define FRAME_TOTAL_PIXEL_WIDTH(f) \ + (FRAME_PIXEL_WIDTH (f) + FRAME_TOOLBAR_WIDTH (f)) + /* Avoid "differ in sign" warnings */ #define SSDATA(x) ((char *) SDATA (x)) +#ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW +#define gtk_widget_set_has_window(w, b) \ + (gtk_fixed_set_has_window (GTK_FIXED (w), b)) +#endif +#ifndef HAVE_GTK_DIALOG_GET_ACTION_AREA +#define gtk_dialog_get_action_area(w) ((w)->action_area) +#define gtk_dialog_get_content_area(w) ((w)->vbox) +#endif +#ifndef HAVE_GTK_WIDGET_GET_SENSITIVE +#define gtk_widget_get_sensitive(w) (GTK_WIDGET_SENSITIVE (w)) +#endif +#ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE +#define gtk_adjustment_set_page_size(w, s) ((w)->page_size = (s)) +#define gtk_adjustment_set_page_increment(w, s) ((w)->page_increment = (s)) +#define gtk_adjustment_get_step_increment(w) ((w)->step_increment) +#define gtk_adjustment_set_step_increment(w, s) ((w)->step_increment = (s)) +#endif +#if GTK_MAJOR_VERSION > 2 || GTK_MINOR_VERSION > 11 +#define remove_submenu(w) gtk_menu_item_set_submenu ((w), NULL) +#else +#define remove_submenu(w) gtk_menu_item_remove_submenu ((w)) +#endif + /*********************************************************************** Display handling functions ***********************************************************************/ -#ifdef HAVE_GTK_MULTIDISPLAY - /* Keep track of the default display, or NULL if there is none. Emacs may close all its displays. */ @@ -63,9 +87,7 @@ static GdkDisplay *gdpy_def; W can be a GtkMenu or a GtkWindow widget. */ static void -xg_set_screen (w, f) - GtkWidget *w; - FRAME_PTR f; +xg_set_screen (GtkWidget *w, FRAME_PTR f) { if (FRAME_X_DISPLAY (f) != GDK_DISPLAY ()) { @@ -80,20 +102,6 @@ xg_set_screen (w, f) } -#else /* not HAVE_GTK_MULTIDISPLAY */ - -/* Make some defines so we can use the GTK 2.2 functions when - compiling with GTK 2.0. */ - -#define xg_set_screen(w, f) -#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) -#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) -#define gdk_cursor_new_for_display(dpy, c) gdk_cursor_new (c) -#define gdk_x11_lookup_xdisplay(dpy) 0 -#define GdkDisplay void - -#endif /* not HAVE_GTK_MULTIDISPLAY */ - /* Open a display named by DISPLAY_NAME. The display is returned in *DPY. *DPY is set to NULL if the display can't be opened. @@ -101,12 +109,9 @@ xg_set_screen (w, f) be opened, and less than zero if the GTK version doesn't support multipe displays. */ -int -xg_display_open (display_name, dpy) - char *display_name; - Display **dpy; +void +xg_display_open (char *display_name, Display **dpy) { -#ifdef HAVE_GTK_MULTIDISPLAY GdkDisplay *gdpy; gdpy = gdk_display_open (display_name); @@ -118,12 +123,6 @@ xg_display_open (display_name, dpy) } *dpy = gdpy ? GDK_DISPLAY_XDISPLAY (gdpy) : NULL; - return gdpy != NULL; - -#else /* not HAVE_GTK_MULTIDISPLAY */ - - return -1; -#endif /* not HAVE_GTK_MULTIDISPLAY */ } @@ -132,7 +131,6 @@ xg_display_open (display_name, dpy) void xg_display_close (Display *dpy) { -#ifdef HAVE_GTK_MULTIDISPLAY GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); /* If this is the default display, try to change it before closing. @@ -164,7 +162,6 @@ xg_display_close (Display *dpy) /* This seems to be fixed in GTK 2.10. */ gdk_display_close (gdpy); #endif -#endif /* HAVE_GTK_MULTIDISPLAY */ } @@ -181,7 +178,7 @@ static int malloc_cpt; Return a pointer to the allocated structure. */ widget_value * -malloc_widget_value () +malloc_widget_value (void) { widget_value *wv; if (widget_value_free_list) @@ -203,8 +200,7 @@ malloc_widget_value () by malloc_widget_value, and no substructures. */ void -free_widget_value (wv) - widget_value *wv; +free_widget_value (widget_value *wv) { if (wv->free_list) abort (); @@ -228,8 +224,7 @@ free_widget_value (wv) scroll bars on display DPY. */ GdkCursor * -xg_create_default_cursor (dpy) - Display *dpy; +xg_create_default_cursor (Display *dpy) { GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR); @@ -238,10 +233,9 @@ xg_create_default_cursor (dpy) /* Apply GMASK to GPIX and return a GdkPixbuf with an alpha channel. */ static GdkPixbuf * -xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap) - GdkPixmap *gpix; - GdkPixmap *gmask; - GdkColormap *cmap; +xg_get_pixbuf_from_pix_and_mask (GdkPixmap *gpix, + GdkPixmap *gmask, + GdkColormap *cmap) { int width, height; GdkPixbuf *icon_buf, *tmp_buf; @@ -292,12 +286,10 @@ xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap) } static Lisp_Object -file_for_image (image) - Lisp_Object image; +file_for_image (Lisp_Object image) { Lisp_Object specified_file = Qnil; Lisp_Object tail; - extern Lisp_Object QCfile; for (tail = XCDR (image); NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail)); @@ -320,11 +312,10 @@ file_for_image (image) If OLD_WIDGET is not NULL, that widget is modified. */ static GtkWidget * -xg_get_image_for_pixmap (f, img, widget, old_widget) - FRAME_PTR f; - struct image *img; - GtkWidget *widget; - GtkImage *old_widget; +xg_get_image_for_pixmap (FRAME_PTR f, + struct image *img, + GtkWidget *widget, + GtkImage *old_widget) { GdkPixmap *gpix; GdkPixmap *gmask; @@ -392,13 +383,12 @@ xg_get_image_for_pixmap (f, img, widget, old_widget) and it is those widgets that are visible. */ static void -xg_set_cursor (w, cursor) - GtkWidget *w; - GdkCursor *cursor; +xg_set_cursor (GtkWidget *w, GdkCursor *cursor) { - GList *children = gdk_window_peek_children (w->window); + GdkWindow *window = gtk_widget_get_window(w); + GList *children = gdk_window_peek_children (window); - gdk_window_set_cursor (w->window, cursor); + gdk_window_set_cursor (window, cursor); /* The scroll bar widget has more than one GDK window (had to look at the source to figure this out), and there is no way to set cursor @@ -441,21 +431,22 @@ xg_list_remove (xg_list_node *list, xg_list_node *node) } /* Allocate and return a utf8 version of STR. If STR is already - utf8 or NULL, just return STR. - If not, a new string is allocated and the caller must free the result + utf8 or NULL, just return a copy of STR. + A new string is allocated and the caller must free the result with g_free. */ static char * -get_utf8_string (str) - char *str; +get_utf8_string (const char *str) { - char *utf8_str = str; + char *utf8_str; if (!str) return NULL; /* If not UTF-8, try current locale. */ if (!g_utf8_validate (str, -1, NULL)) utf8_str = g_locale_to_utf8 (str, -1, 0, 0, 0); + else + return g_strdup (str); if (!utf8_str) { @@ -514,6 +505,207 @@ get_utf8_string (str) return utf8_str; } +/* Check for special colors used in face spec for region face. + The colors are fetched from the Gtk+ theme. + Return 1 if color was found, 0 if not. */ + +int +xg_check_special_colors (struct frame *f, + const char *color_name, + XColor *color) +{ + int success_p = 0; + if (FRAME_GTK_WIDGET (f)) + { + if (strcmp ("gtk_selection_bg_color", color_name) == 0) + { + GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); + color->red = gsty->bg[GTK_STATE_SELECTED].red; + color->green = gsty->bg[GTK_STATE_SELECTED].green; + color->blue = gsty->bg[GTK_STATE_SELECTED].blue; + color->pixel = gsty->bg[GTK_STATE_SELECTED].pixel; + success_p = 1; + } + else if (strcmp ("gtk_selection_fg_color", color_name) == 0) + { + GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); + color->red = gsty->fg[GTK_STATE_SELECTED].red; + color->green = gsty->fg[GTK_STATE_SELECTED].green; + color->blue = gsty->fg[GTK_STATE_SELECTED].blue; + color->pixel = gsty->fg[GTK_STATE_SELECTED].pixel; + success_p = 1; + } + } + + return success_p; +} + + + +/*********************************************************************** + Tooltips + ***********************************************************************/ +/* Gtk+ calls this callback when the parent of our tooltip dummy changes. + We use that to pop down the tooltip. This happens if Gtk+ for some + reason wants to change or hide the tooltip. */ + +#ifdef USE_GTK_TOOLTIP + +static void +hierarchy_ch_cb (GtkWidget *widget, + GtkWidget *previous_toplevel, + gpointer user_data) +{ + FRAME_PTR f = (FRAME_PTR) user_data; + struct x_output *x = f->output_data.x; + GtkWidget *top = gtk_widget_get_toplevel (x->ttip_lbl); + + if (! top || ! GTK_IS_WINDOW (top)) + gtk_widget_hide (previous_toplevel); +} + +/* Callback called when Gtk+ thinks a tooltip should be displayed. + We use it to get the tooltip window and the tooltip widget so + we can manipulate the ourselves. + + Return FALSE ensures that the tooltip is not shown. */ + +static gboolean +qttip_cb (GtkWidget *widget, + gint xpos, + gint ypos, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) +{ + FRAME_PTR f = (FRAME_PTR) user_data; + struct x_output *x = f->output_data.x; + if (x->ttip_widget == NULL) + { + g_object_set (G_OBJECT (widget), "has-tooltip", FALSE, NULL); + x->ttip_widget = tooltip; + g_object_ref (G_OBJECT (tooltip)); + x->ttip_lbl = gtk_label_new (""); + g_object_ref (G_OBJECT (x->ttip_lbl)); + gtk_tooltip_set_custom (tooltip, x->ttip_lbl); + x->ttip_window = GTK_WINDOW (gtk_widget_get_toplevel (x->ttip_lbl)); + /* Realize so we can safely get screen later on. */ + gtk_widget_realize (GTK_WIDGET (x->ttip_window)); + gtk_widget_realize (x->ttip_lbl); + + g_signal_connect (x->ttip_lbl, "hierarchy-changed", + G_CALLBACK (hierarchy_ch_cb), f); + } + return FALSE; +} + +#endif /* USE_GTK_TOOLTIP */ + +/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT. + Return zero if no system tooltip available, non-zero otherwise. */ + +int +xg_prepare_tooltip (FRAME_PTR f, + Lisp_Object string, + int *width, + int *height) +{ +#ifndef USE_GTK_TOOLTIP + return 0; +#else + struct x_output *x = f->output_data.x; + GtkWidget *widget; + GdkWindow *gwin; + GdkScreen *screen; + GtkSettings *settings; + gboolean tt_enabled = TRUE; + GtkRequisition req; + Lisp_Object encoded_string; + + if (!x->ttip_lbl) return 0; + + BLOCK_INPUT; + encoded_string = ENCODE_UTF_8 (string); + widget = GTK_WIDGET (x->ttip_lbl); + gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window)); + screen = gdk_drawable_get_screen (gwin); + settings = gtk_settings_get_for_screen (screen); + g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL); + if (tt_enabled) + { + g_object_set (settings, "gtk-enable-tooltips", FALSE, NULL); + /* Record that we disabled it so it can be enabled again. */ + g_object_set_data (G_OBJECT (x->ttip_window), "restore-tt", + (gpointer)f); + } + + /* Prevent Gtk+ from hiding tooltip on mouse move and such. */ + g_object_set_data (G_OBJECT + (gtk_widget_get_display (GTK_WIDGET (x->ttip_window))), + "gdk-display-current-tooltip", NULL); + + /* Put out dummy widget in so we can get callbacks for unrealize and + hierarchy-changed. */ + gtk_tooltip_set_custom (x->ttip_widget, widget); + + gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string)); + gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req); + if (width) *width = req.width; + if (height) *height = req.height; + + UNBLOCK_INPUT; + + return 1; +#endif /* USE_GTK_TOOLTIP */ +} + +/* Show the tooltip at ROOT_X and ROOT_Y. + xg_prepare_tooltip must have been called before this function. */ + +void +xg_show_tooltip (FRAME_PTR f, int root_x, int root_y) +{ +#ifdef USE_GTK_TOOLTIP + struct x_output *x = f->output_data.x; + if (x->ttip_window) + { + BLOCK_INPUT; + gtk_window_move (x->ttip_window, root_x, root_y); + gtk_widget_show_all (GTK_WIDGET (x->ttip_window)); + UNBLOCK_INPUT; + } +#endif +} + +/* Hide tooltip if shown. Do nothing if not shown. + Return non-zero if tip was hidden, non-ero if not (i.e. not using + system tooltips). */ + +int +xg_hide_tooltip (FRAME_PTR f) +{ + int ret = 0; +#ifdef USE_GTK_TOOLTIP + if (f->output_data.x->ttip_window) + { + GtkWindow *win = f->output_data.x->ttip_window; + BLOCK_INPUT; + gtk_widget_hide (GTK_WIDGET (win)); + + if (g_object_get_data (G_OBJECT (win), "restore-tt")) + { + GdkWindow *gwin = gtk_widget_get_window (GTK_WIDGET (win)); + GdkScreen *screen = gdk_drawable_get_screen (gwin); + GtkSettings *settings = gtk_settings_get_for_screen (screen); + g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL); + } + UNBLOCK_INPUT; + + ret = 1; + } +#endif + return ret; +} /*********************************************************************** @@ -526,10 +718,9 @@ get_utf8_string (str) F is the frame we shall set geometry for. */ static void -xg_set_geometry (f) - FRAME_PTR f; +xg_set_geometry (FRAME_PTR f) { - if (f->size_hint_flags & USPosition) + if (f->size_hint_flags & (USPosition | PPosition)) { int left = f->left_pos; int xneg = f->size_hint_flags & XNegative; @@ -544,7 +735,7 @@ xg_set_geometry (f) sprintf (geom_str, "=%dx%d%c%d%c%d", FRAME_PIXEL_WIDTH (f), - FRAME_TOTAL_PIXEL_HEIGHT (f), + FRAME_PIXEL_HEIGHT (f), (xneg ? '-' : '+'), left, (yneg ? '-' : '+'), top); @@ -552,17 +743,13 @@ xg_set_geometry (f) geom_str)) fprintf (stderr, "Failed to parse: '%s'\n", geom_str); } - else if (f->size_hint_flags & PPosition) - gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - f->left_pos, f->top_pos); } /* Clear under internal border if any. As we use a mix of Gtk+ and X calls and use a GtkFixed widget, this doesn't happen automatically. */ static void -xg_clear_under_internal_border (f) - FRAME_PTR f; +xg_clear_under_internal_border (FRAME_PTR f) { if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) { @@ -600,16 +787,15 @@ xg_clear_under_internal_border (f) PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ void -xg_frame_resized (f, pixelwidth, pixelheight) - FRAME_PTR f; - int pixelwidth, pixelheight; +xg_frame_resized (FRAME_PTR f, int pixelwidth, int pixelheight) { int rows, columns; if (pixelwidth == -1 && pixelheight == -1) { - if (FRAME_GTK_WIDGET (f) && GTK_WIDGET_MAPPED (FRAME_GTK_WIDGET (f))) - gdk_window_get_geometry (FRAME_GTK_WIDGET (f)->window, 0, 0, + if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f))) + gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)), + 0, 0, &pixelwidth, &pixelheight, 0); else return; } @@ -637,10 +823,7 @@ xg_frame_resized (f, pixelwidth, pixelheight) COLUMNS/ROWS is the size the edit area shall have after the resize. */ void -xg_frame_set_char_size (f, cols, rows) - FRAME_PTR f; - int cols; - int rows; +xg_frame_set_char_size (FRAME_PTR f, int cols, int rows) { int pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); @@ -661,7 +844,8 @@ xg_frame_set_char_size (f, cols, rows) /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it after calculating that value. */ - pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); + pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols) + + FRAME_TOOLBAR_WIDTH (f); /* Do this before resize, as we don't know yet if we will be resized. */ @@ -698,15 +882,15 @@ xg_frame_set_char_size (f, cols, rows) } } -/* Handle height changes (i.e. add/remove menu/toolbar). +/* Handle height/width changes (i.e. add/remove/move menu/toolbar). The policy is to keep the number of editable lines. */ static void -xg_height_changed (f) - FRAME_PTR f; +xg_height_or_width_changed (FRAME_PTR f) { gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - FRAME_PIXEL_WIDTH (f), FRAME_TOTAL_PIXEL_HEIGHT (f)); + FRAME_TOTAL_PIXEL_WIDTH (f), + FRAME_TOTAL_PIXEL_HEIGHT (f)); f->output_data.x->hint_flags = 0; x_wm_set_size_hint (f, 0, 0); } @@ -718,9 +902,7 @@ xg_height_changed (f) Return 0 if no widget match WDESC. */ GtkWidget * -xg_win_to_widget (dpy, wdesc) - Display *dpy; - Window wdesc; +xg_win_to_widget (Display *dpy, Window wdesc) { gpointer gdkwin; GtkWidget *gwdesc = 0; @@ -744,24 +926,40 @@ xg_win_to_widget (dpy, wdesc) W is the widget that color will be used for. Used to find colormap. */ static void -xg_pix_to_gcolor (w, pixel, c) - GtkWidget *w; - unsigned long pixel; - GdkColor *c; +xg_pix_to_gcolor (GtkWidget *w, long unsigned int pixel, GdkColor *c) { GdkColormap *map = gtk_widget_get_colormap (w); gdk_colormap_query_color (map, pixel, c); } +/* Callback called when the gtk theme changes. + We notify lisp code so it can fix faces used for region for example. */ + +static void +style_changed_cb (GObject *go, + GParamSpec *spec, + gpointer user_data) +{ + struct input_event event; + GdkDisplay *gdpy = (GdkDisplay *) user_data; + const char *display_name = gdk_display_get_name (gdpy); + + EVENT_INIT (event); + event.kind = CONFIG_CHANGED_EVENT; + event.frame_or_window = make_string (display_name, strlen (display_name)); + /* Theme doesn't change often, so intern is called seldom. */ + event.arg = intern ("theme-name"); + kbd_buffer_store_event (&event); +} + /* Create and set up the GTK widgets for frame F. Return 0 if creation failed, non-zero otherwise. */ int -xg_create_frame_widgets (f) - FRAME_PTR f; +xg_create_frame_widgets (FRAME_PTR f) { GtkWidget *wtop; - GtkWidget *wvbox; + GtkWidget *wvbox, *whbox; GtkWidget *wfixed; GdkColor bg; GtkRcStyle *style; @@ -777,12 +975,14 @@ xg_create_frame_widgets (f) xg_set_screen (wtop, f); wvbox = gtk_vbox_new (FALSE, 0); + whbox = gtk_hbox_new (FALSE, 0); wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ - if (! wtop || ! wvbox || ! wfixed) + if (! wtop || ! wvbox || ! whbox || ! wfixed) { if (wtop) gtk_widget_destroy (wtop); if (wvbox) gtk_widget_destroy (wvbox); + if (whbox) gtk_widget_destroy (whbox); if (wfixed) gtk_widget_destroy (wfixed); UNBLOCK_INPUT; @@ -803,11 +1003,13 @@ xg_create_frame_widgets (f) FRAME_GTK_OUTER_WIDGET (f) = wtop; FRAME_GTK_WIDGET (f) = wfixed; f->output_data.x->vbox_widget = wvbox; + f->output_data.x->hbox_widget = whbox; - gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE); + gtk_widget_set_has_window (wfixed, TRUE); gtk_container_add (GTK_CONTAINER (wtop), wvbox); - gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (wvbox), whbox, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (whbox), wfixed, TRUE, TRUE, 0); if (FRAME_EXTERNAL_TOOL_BAR (f)) update_frame_tool_bar (f); @@ -866,17 +1068,54 @@ xg_create_frame_widgets (f) style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>"); gtk_widget_modify_style (wfixed, style); - /* GTK does not set any border, and they look bad with GTK. */ - /* That they look bad is no excuse for imposing this here. --Stef - It should be done by providing the proper default in Fx_create_Frame. - f->border_width = 0; - f->internal_border_width = 0; */ +#ifdef USE_GTK_TOOLTIP + /* Steal a tool tip window we can move ourselves. */ + f->output_data.x->ttip_widget = 0; + f->output_data.x->ttip_lbl = 0; + f->output_data.x->ttip_window = 0; + gtk_widget_set_tooltip_text (wtop, "Dummy text"); + g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f); +#endif + + { + GdkScreen *screen = gtk_widget_get_screen (wtop); + GtkSettings *gs = gtk_settings_get_for_screen (screen); + /* Only connect this signal once per screen. */ + if (! g_signal_handler_find (G_OBJECT (gs), + G_SIGNAL_MATCH_FUNC, + 0, 0, 0, + G_CALLBACK (style_changed_cb), + 0)) + { + g_signal_connect (G_OBJECT (gs), "notify::gtk-theme-name", + G_CALLBACK (style_changed_cb), + gdk_screen_get_display (screen)); + } + } UNBLOCK_INPUT; return 1; } +void +xg_free_frame_widgets (FRAME_PTR f) +{ + if (FRAME_GTK_OUTER_WIDGET (f)) + { + struct x_output *x = f->output_data.x; + gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); + FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */ + FRAME_GTK_OUTER_WIDGET (f) = 0; +#ifdef USE_GTK_TOOLTIP + if (x->ttip_lbl) + gtk_widget_destroy (x->ttip_lbl); + if (x->ttip_widget) + g_object_unref (G_OBJECT (x->ttip_widget)); +#endif + } +} + /* Set the normal size hints for the window manager, for frame F. FLAGS is the flags word to use--or 0 meaning preserve the flags that the window now has. @@ -884,10 +1123,7 @@ xg_create_frame_widgets (f) flag (this is useful when FLAGS is 0). */ void -x_wm_set_size_hint (f, flags, user_position) - FRAME_PTR f; - long flags; - int user_position; +x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position) { /* Must use GTK routines here, otherwise GTK resets the size hints to its own defaults. */ @@ -920,7 +1156,7 @@ x_wm_set_size_hint (f, flags, user_position) size_hints.height_inc = FRAME_LINE_HEIGHT (f); hint_flags |= GDK_HINT_BASE_SIZE; - base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); + base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0) + FRAME_TOOLBAR_WIDTH (f); base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); @@ -956,10 +1192,6 @@ x_wm_set_size_hint (f, flags, user_position) else if (win_gravity == StaticGravity) size_hints.win_gravity = GDK_GRAVITY_STATIC; - if (flags & PPosition) hint_flags |= GDK_HINT_POS; - if (flags & USPosition) hint_flags |= GDK_HINT_USER_POS; - if (flags & USSize) hint_flags |= GDK_HINT_USER_SIZE; - if (user_position) { hint_flags &= ~GDK_HINT_POS; @@ -987,9 +1219,7 @@ x_wm_set_size_hint (f, flags, user_position) BG is the pixel value to change to. */ void -xg_set_background_color (f, bg) - FRAME_PTR f; - unsigned long bg; +xg_set_background_color (FRAME_PTR f, long unsigned int bg) { if (FRAME_GTK_WIDGET (f)) { @@ -1007,10 +1237,7 @@ xg_set_background_color (f, bg) functions so GTK does not overwrite the icon. */ void -xg_set_frame_icon (f, icon_pixmap, icon_mask) - FRAME_PTR f; - Pixmap icon_pixmap; - Pixmap icon_mask; +xg_set_frame_icon (FRAME_PTR f, Pixmap icon_pixmap, Pixmap icon_mask) { GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); GdkPixmap *gpix = gdk_pixmap_foreign_new_for_display (gdpy, icon_pixmap); @@ -1028,10 +1255,10 @@ xg_set_frame_icon (f, icon_pixmap, icon_mask) /* Return the dialog title to use for a dialog of type KEY. This is the encoding used by lwlib. We use the same for GTK. */ -static char * +static const char * get_dialog_title (char key) { - char *title = ""; + const char *title = ""; switch (key) { case 'E': case 'e': @@ -1070,10 +1297,7 @@ get_dialog_title (char key) Returns TRUE to end propagation of event. */ static gboolean -dialog_delete_callback (w, event, user_data) - GtkWidget *w; - GdkEvent *event; - gpointer user_data; +dialog_delete_callback (GtkWidget *w, GdkEvent *event, gpointer user_data) { gtk_widget_unmap (w); return TRUE; @@ -1087,20 +1311,20 @@ dialog_delete_callback (w, event, user_data) Returns the GTK dialog widget. */ static GtkWidget * -create_dialog (wv, select_cb, deactivate_cb) - widget_value *wv; - GCallback select_cb; - GCallback deactivate_cb; +create_dialog (widget_value *wv, + GCallback select_cb, + GCallback deactivate_cb) { - char *title = get_dialog_title (wv->name[0]); + const char *title = get_dialog_title (wv->name[0]); int total_buttons = wv->name[1] - '0'; int right_buttons = wv->name[4] - '0'; int left_buttons; int button_nr = 0; int button_spacing = 10; GtkWidget *wdialog = gtk_dialog_new (); + GtkDialog *wd = GTK_DIALOG (wdialog); + GtkBox *cur_box = GTK_BOX (gtk_dialog_get_action_area (wd)); widget_value *item; - GtkBox *cur_box; GtkWidget *wvbox; GtkWidget *whbox_up; GtkWidget *whbox_down; @@ -1115,7 +1339,6 @@ create_dialog (wv, select_cb, deactivate_cb) gtk_window_set_title (GTK_WINDOW (wdialog), title); gtk_widget_set_name (wdialog, "emacs-dialog"); - cur_box = GTK_BOX (GTK_DIALOG (wdialog)->action_area); if (make_two_rows) { @@ -1147,21 +1370,18 @@ create_dialog (wv, select_cb, deactivate_cb) if (item->name && strcmp (item->name, "message") == 0) { + GtkBox *wvbox = GTK_BOX (gtk_dialog_get_content_area (wd)); /* This is the text part of the dialog. */ w = gtk_label_new (utf8_label); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (wdialog)->vbox), - gtk_label_new (""), - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (wdialog)->vbox), w, - TRUE, TRUE, 0); + gtk_box_pack_start (wvbox, gtk_label_new (""), FALSE, FALSE, 0); + gtk_box_pack_start (wvbox, w, TRUE, TRUE, 0); gtk_misc_set_alignment (GTK_MISC (w), 0.1, 0.5); /* Try to make dialog look better. Must realize first so the widget can calculate the size it needs. */ gtk_widget_realize (w); gtk_widget_size_request (w, &req); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (wdialog)->vbox), - req.height); + gtk_box_set_spacing (wvbox, req.height); if (item->value && strlen (item->value) > 0) button_spacing = 2*req.width/strlen (item->value); } @@ -1188,7 +1408,7 @@ create_dialog (wv, select_cb, deactivate_cb) } } - if (utf8_label && utf8_label != item->value) + if (utf8_label) g_free (utf8_label); } @@ -1208,12 +1428,9 @@ struct xg_dialog_data USER_DATA is what we passed in to g_signal_connect. */ static void -xg_dialog_response_cb (w, - response, - user_data) - GtkDialog *w; - gint response; - gpointer user_data; +xg_dialog_response_cb (GtkDialog *w, + gint response, + gpointer user_data) { struct xg_dialog_data *dd = (struct xg_dialog_data *)user_data; dd->response = response; @@ -1224,8 +1441,7 @@ xg_dialog_response_cb (w, /* Destroy the dialog. This makes it pop down. */ static Lisp_Object -pop_down_dialog (arg) - Lisp_Object arg; +pop_down_dialog (Lisp_Object arg) { struct Lisp_Save_Value *p = XSAVE_VALUE (arg); struct xg_dialog_data *dd = (struct xg_dialog_data *) p->pointer; @@ -1246,8 +1462,7 @@ pop_down_dialog (arg) We pass in DATA as gpointer* so we can use this as a callback. */ static gboolean -xg_maybe_add_timer (data) - gpointer data; +xg_maybe_add_timer (gpointer data) { struct xg_dialog_data *dd = (struct xg_dialog_data *) data; EMACS_TIME next_time = timer_check (1); @@ -1271,10 +1486,7 @@ xg_maybe_add_timer (data) The dialog W is not destroyed when this function returns. */ static int -xg_dialog_run (f, w) - FRAME_PTR f; - GtkWidget *w; - +xg_dialog_run (FRAME_PTR f, GtkWidget *w) { int count = SPECPDL_INDEX (); struct xg_dialog_data dd; @@ -1317,33 +1529,24 @@ xg_dialog_run (f, w) Return zero if not. */ int -xg_uses_old_file_dialog () +xg_uses_old_file_dialog (void) { -#ifdef HAVE_GTK_FILE_BOTH +#ifdef HAVE_GTK_FILE_SELECTION_NEW extern int x_gtk_use_old_file_dialog; return x_gtk_use_old_file_dialog; -#else /* ! HAVE_GTK_FILE_BOTH */ - -#ifdef HAVE_GTK_FILE_SELECTION_NEW - return 1; #else return 0; #endif - -#endif /* ! HAVE_GTK_FILE_BOTH */ } -typedef char * (*xg_get_file_func) P_ ((GtkWidget *)); - -#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW +typedef char * (*xg_get_file_func) (GtkWidget *); /* Return the selected file for file chooser dialog W. The returned string must be free:d. */ static char * -xg_get_file_name_from_chooser (w) - GtkWidget *w; +xg_get_file_name_from_chooser (GtkWidget *w) { return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w)); } @@ -1352,9 +1555,7 @@ xg_get_file_name_from_chooser (w) WIDGET is the toggle widget, DATA is the file chooser dialog. */ static void -xg_toggle_visibility_cb (widget, data) - GtkWidget *widget; - gpointer data; +xg_toggle_visibility_cb (GtkWidget *widget, gpointer data) { GtkFileChooser *dialog = GTK_FILE_CHOOSER (data); gboolean visible; @@ -1370,10 +1571,7 @@ xg_toggle_visibility_cb (widget, data) changes that property by right clicking in the file list. */ static void -xg_toggle_notify_cb (gobject, arg1, user_data) - GObject *gobject; - GParamSpec *arg1; - gpointer user_data; +xg_toggle_notify_cb (GObject *gobject, GParamSpec *arg1, gpointer user_data) { extern int x_gtk_show_hidden_files; @@ -1411,13 +1609,11 @@ xg_toggle_notify_cb (gobject, arg1, user_data) Returns the created widget. */ static GtkWidget * -xg_get_file_with_chooser (f, prompt, default_filename, - mustmatch_p, only_dir_p, func) - FRAME_PTR f; - char *prompt; - char *default_filename; - int mustmatch_p, only_dir_p; - xg_get_file_func *func; +xg_get_file_with_chooser (FRAME_PTR f, + char *prompt, + char *default_filename, + int mustmatch_p, int only_dir_p, + xg_get_file_func *func) { char message[1024]; @@ -1513,7 +1709,6 @@ xg_get_file_with_chooser (f, prompt, default_filename, *func = xg_get_file_name_from_chooser; return filewin; } -#endif /* HAVE_GTK_FILE_CHOOSER_DIALOG_NEW */ #ifdef HAVE_GTK_FILE_SELECTION_NEW @@ -1521,8 +1716,7 @@ xg_get_file_with_chooser (f, prompt, default_filename, The returned string must be free:d. */ static char * -xg_get_file_name_from_selector (w) - GtkWidget *w; +xg_get_file_name_from_selector (GtkWidget *w) { GtkFileSelection *filesel = GTK_FILE_SELECTION (w); return xstrdup ((char*) gtk_file_selection_get_filename (filesel)); @@ -1539,13 +1733,11 @@ xg_get_file_name_from_selector (w) Returns the created widget. */ static GtkWidget * -xg_get_file_with_selection (f, prompt, default_filename, - mustmatch_p, only_dir_p, func) - FRAME_PTR f; - char *prompt; - char *default_filename; - int mustmatch_p, only_dir_p; - xg_get_file_func *func; +xg_get_file_with_selection (FRAME_PTR f, + char *prompt, + char *default_filename, + int mustmatch_p, int only_dir_p, + xg_get_file_func *func) { GtkWidget *filewin; GtkFileSelection *filesel; @@ -1583,11 +1775,11 @@ xg_get_file_with_selection (f, prompt, default_filename, The returned string must be freed by the caller. */ char * -xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) - FRAME_PTR f; - char *prompt; - char *default_filename; - int mustmatch_p, only_dir_p; +xg_get_file_name (FRAME_PTR f, + char *prompt, + char *default_filename, + int mustmatch_p, + int only_dir_p) { GtkWidget *w = 0; char *fn = 0; @@ -1601,7 +1793,7 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) sigblock (sigmask (__SIGRTMIN)); #endif /* HAVE_GTK_AND_PTHREAD */ -#ifdef HAVE_GTK_FILE_BOTH +#ifdef HAVE_GTK_FILE_SELECTION_NEW if (xg_uses_old_file_dialog ()) w = xg_get_file_with_selection (f, prompt, default_filename, @@ -1610,18 +1802,10 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) w = xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p, &func); -#else /* not HAVE_GTK_FILE_BOTH */ - -#ifdef HAVE_GTK_FILE_SELECTION_NEW - w = xg_get_file_with_selection (f, prompt, default_filename, - mustmatch_p, only_dir_p, &func); -#endif -#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW +#else /* not HAVE_GTK_FILE_SELECTION_NEW */ w = xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p, &func); -#endif - -#endif /* HAVE_GTK_FILE_BOTH */ +#endif /* not HAVE_GTK_FILE_SELECTION_NEW */ gtk_widget_set_name (w, "emacs-filedialog"); @@ -1649,9 +1833,7 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) DEFAULT_NAME, if non-zero, is the default font name. */ char * -xg_get_font_name (f, default_name) - FRAME_PTR f; - char *default_name; +xg_get_font_name (FRAME_PTR f, const char *default_name) { GtkWidget *w; char *fontname = NULL; @@ -1716,10 +1898,7 @@ static xg_list_node xg_menu_item_cb_list; allocated xg_menu_cb_data if CL_DATA is NULL. */ static xg_menu_cb_data * -make_cl_data (cl_data, f, highlight_cb) - xg_menu_cb_data *cl_data; - FRAME_PTR f; - GCallback highlight_cb; +make_cl_data (xg_menu_cb_data *cl_data, FRAME_PTR f, GCallback highlight_cb) { if (! cl_data) { @@ -1750,10 +1929,9 @@ make_cl_data (cl_data, f, highlight_cb) creating the menu bar. */ static void -update_cl_data (cl_data, f, highlight_cb) - xg_menu_cb_data *cl_data; - FRAME_PTR f; - GCallback highlight_cb; +update_cl_data (xg_menu_cb_data *cl_data, + FRAME_PTR f, + GCallback highlight_cb) { if (cl_data) { @@ -1768,8 +1946,7 @@ update_cl_data (cl_data, f, highlight_cb) If reference count is zero, free CL_DATA. */ static void -unref_cl_data (cl_data) - xg_menu_cb_data *cl_data; +unref_cl_data (xg_menu_cb_data *cl_data) { if (cl_data && cl_data->ref_count > 0) { @@ -1785,7 +1962,7 @@ unref_cl_data (cl_data) /* Function that marks all lisp data during GC. */ void -xg_mark_data () +xg_mark_data (void) { xg_list_node *iter; @@ -1807,9 +1984,7 @@ xg_mark_data () CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ static void -menuitem_destroy_callback (w, client_data) - GtkWidget *w; - gpointer client_data; +menuitem_destroy_callback (GtkWidget *w, gpointer client_data) { if (client_data) { @@ -1827,10 +2002,9 @@ menuitem_destroy_callback (w, client_data) Returns FALSE to tell GTK to keep processing this event. */ static gboolean -menuitem_highlight_callback (w, event, client_data) - GtkWidget *w; - GdkEventCrossing *event; - gpointer client_data; +menuitem_highlight_callback (GtkWidget *w, + GdkEventCrossing *event, + gpointer client_data) { GdkEvent ev; GtkWidget *subwidget; @@ -1858,9 +2032,7 @@ menuitem_highlight_callback (w, event, client_data) CLIENT_DATA points to the xg_menu_cb_data associated with W. */ static void -menu_destroy_callback (w, client_data) - GtkWidget *w; - gpointer client_data; +menu_destroy_callback (GtkWidget *w, gpointer client_data) { unref_cl_data ((xg_menu_cb_data*) client_data); } @@ -1871,9 +2043,7 @@ menu_destroy_callback (w, client_data) Returns the GtkHBox. */ static GtkWidget * -make_widget_for_menu_item (utf8_label, utf8_key) - char *utf8_label; - char *utf8_key; +make_widget_for_menu_item (const char *utf8_label, const char *utf8_key) { GtkWidget *wlbl; GtkWidget *wkey; @@ -1911,11 +2081,10 @@ make_widget_for_menu_item (utf8_label, utf8_key) but the MacOS X version doesn't either, so I guess that is OK. */ static GtkWidget * -make_menu_item (utf8_label, utf8_key, item, group) - char *utf8_label; - char *utf8_key; - widget_value *item; - GSList **group; +make_menu_item (const char *utf8_label, + const char *utf8_key, + widget_value *item, + GSList **group) { GtkWidget *w; GtkWidget *wtoadd = 0; @@ -1979,7 +2148,7 @@ static const char* separator_names[] = { }; static int -xg_separator_p (char *label) +xg_separator_p (const char *label) { if (! label) return 0; else if (strlen (label) > 3 @@ -2010,7 +2179,7 @@ static int xg_detached_menus; /* Returns non-zero if there are detached menus. */ int -xg_have_tear_offs () +xg_have_tear_offs (void) { return xg_detached_menus > 0; } @@ -2021,9 +2190,7 @@ xg_have_tear_offs () CLIENT_DATA is not used. */ static void -tearoff_remove (widget, client_data) - GtkWidget *widget; - gpointer client_data; +tearoff_remove (GtkWidget *widget, gpointer client_data) { if (xg_detached_menus > 0) --xg_detached_menus; } @@ -2034,9 +2201,7 @@ tearoff_remove (widget, client_data) CLIENT_DATA is not used. */ static void -tearoff_activate (widget, client_data) - GtkWidget *widget; - gpointer client_data; +tearoff_activate (GtkWidget *widget, gpointer client_data) { GtkWidget *menu = gtk_widget_get_parent (widget); if (gtk_menu_get_tearoff_state (GTK_MENU (menu))) @@ -2064,13 +2229,12 @@ tearoff_activate (widget, client_data) Returns the created GtkWidget. */ static GtkWidget * -xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) - widget_value *item; - FRAME_PTR f; - GCallback select_cb; - GCallback highlight_cb; - xg_menu_cb_data *cl_data; - GSList **group; +xg_create_one_menuitem (widget_value *item, + FRAME_PTR f, + GCallback select_cb, + GCallback highlight_cb, + xg_menu_cb_data *cl_data, + GSList **group) { char *utf8_label; char *utf8_key; @@ -2082,8 +2246,8 @@ xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) w = make_menu_item (utf8_label, utf8_key, item, group); - if (utf8_label && utf8_label != item->name) g_free (utf8_label); - if (utf8_key && utf8_key != item->key) g_free (utf8_key); + if (utf8_label) g_free (utf8_label); + if (utf8_key) g_free (utf8_key); cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); @@ -2113,10 +2277,6 @@ xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) return w; } -static GtkWidget *create_menus P_ ((widget_value *, FRAME_PTR, GCallback, - GCallback, GCallback, int, int, int, - GtkWidget *, xg_menu_cb_data *, char *)); - /* Create a full menu tree specified by DATA. F is the frame the created menu belongs to. SELECT_CB is the callback to use when a menu item is selected. @@ -2140,19 +2300,17 @@ static GtkWidget *create_menus P_ ((widget_value *, FRAME_PTR, GCallback, This function calls itself to create submenus. */ static GtkWidget * -create_menus (data, f, select_cb, deactivate_cb, highlight_cb, - pop_up_p, menu_bar_p, add_tearoff_p, topmenu, cl_data, name) - widget_value *data; - FRAME_PTR f; - GCallback select_cb; - GCallback deactivate_cb; - GCallback highlight_cb; - int pop_up_p; - int menu_bar_p; - int add_tearoff_p; - GtkWidget *topmenu; - xg_menu_cb_data *cl_data; - char *name; +create_menus (widget_value *data, + FRAME_PTR f, + GCallback select_cb, + GCallback deactivate_cb, + GCallback highlight_cb, + int pop_up_p, + int menu_bar_p, + int add_tearoff_p, + GtkWidget *topmenu, + xg_menu_cb_data *cl_data, + const char *name) { widget_value *item; GtkWidget *wmenu = topmenu; @@ -2225,7 +2383,7 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb, gtk_menu_set_title (GTK_MENU (wmenu), utf8_label); w = gtk_menu_item_new_with_label (utf8_label); gtk_widget_set_sensitive (w, FALSE); - if (utf8_label && utf8_label != item->name) g_free (utf8_label); + if (utf8_label) g_free (utf8_label); } else if (xg_separator_p (item->name)) { @@ -2284,15 +2442,9 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb, Returns the widget created. */ GtkWidget * -xg_create_widget (type, name, f, val, - select_cb, deactivate_cb, highlight_cb) - char *type; - char *name; - FRAME_PTR f; - widget_value *val; - GCallback select_cb; - GCallback deactivate_cb; - GCallback highlight_cb; +xg_create_widget (const char *type, const char *name, FRAME_PTR f, widget_value *val, + GCallback select_cb, GCallback deactivate_cb, + GCallback highlight_cb) { GtkWidget *w = 0; int menu_bar_p = strcmp (type, "menubar") == 0; @@ -2343,8 +2495,7 @@ xg_create_widget (type, name, f, val, /* Return the label for menu item WITEM. */ static const char * -xg_get_menu_item_label (witem) - GtkMenuItem *witem; +xg_get_menu_item_label (GtkMenuItem *witem) { GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); return gtk_label_get_label (wlabel); @@ -2353,9 +2504,7 @@ xg_get_menu_item_label (witem) /* Return non-zero if the menu item WITEM has the text LABEL. */ static int -xg_item_label_same_p (witem, label) - GtkMenuItem *witem; - char *label; +xg_item_label_same_p (GtkMenuItem *witem, const char *label) { int is_same = 0; char *utf8_label = get_utf8_string (label); @@ -2366,7 +2515,7 @@ xg_item_label_same_p (witem, label) else if (old_label && utf8_label) is_same = strcmp (utf8_label, old_label) == 0; - if (utf8_label && utf8_label != label) g_free (utf8_label); + if (utf8_label) g_free (utf8_label); return is_same; } @@ -2374,8 +2523,7 @@ xg_item_label_same_p (witem, label) /* Destroy widgets in LIST. */ static void -xg_destroy_widgets (list) - GList *list; +xg_destroy_widgets (GList *list) { GList *iter; @@ -2401,18 +2549,16 @@ xg_destroy_widgets (list) This function calls itself to walk through the menu bar names. */ static void -xg_update_menubar (menubar, f, list, iter, pos, val, - select_cb, deactivate_cb, highlight_cb, cl_data) - GtkWidget *menubar; - FRAME_PTR f; - GList **list; - GList *iter; - int pos; - widget_value *val; - GCallback select_cb; - GCallback deactivate_cb; - GCallback highlight_cb; - xg_menu_cb_data *cl_data; +xg_update_menubar (GtkWidget *menubar, + FRAME_PTR f, + GList **list, + GList *iter, + int pos, + widget_value *val, + GCallback select_cb, + GCallback deactivate_cb, + GCallback highlight_cb, + xg_menu_cb_data *cl_data) { if (! iter && ! val) return; @@ -2479,7 +2625,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val, New: A C Remove B. */ - gtk_widget_ref (GTK_WIDGET (witem)); + g_object_ref (G_OBJECT (witem)); gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem)); gtk_widget_destroy (GTK_WIDGET (witem)); @@ -2516,6 +2662,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val, /* Set the title of the detached window. */ gtk_menu_set_title (GTK_MENU (submenu), utf8_label); + if (utf8_label) g_free (utf8_label); iter = g_list_next (iter); val = val->next; ++pos; @@ -2528,7 +2675,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val, Insert X. */ int nr = pos; - GList *group = 0; + GSList *group = 0; GtkWidget *w = xg_create_one_menuitem (val, f, select_cb, @@ -2561,11 +2708,11 @@ xg_update_menubar (menubar, f, list, iter, pos, val, New: A C B Move C before B */ - gtk_widget_ref (GTK_WIDGET (witem2)); + g_object_ref (G_OBJECT (witem2)); gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem2)); gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), GTK_WIDGET (witem2), pos); - gtk_widget_unref (GTK_WIDGET (witem2)); + g_object_unref (G_OBJECT (witem2)); g_list_free (*list); *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); @@ -2587,12 +2734,11 @@ xg_update_menubar (menubar, f, list, iter, pos, val, CL_DATA is the data to set in the widget for menu invocation. */ static void -xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) - widget_value *val; - GtkWidget *w; - GCallback select_cb; - GCallback highlight_cb; - xg_menu_cb_data *cl_data; +xg_update_menu_item (widget_value *val, + GtkWidget *w, + GCallback select_cb, + GCallback highlight_cb, + xg_menu_cb_data *cl_data) { GtkWidget *wchild; GtkLabel *wlbl = 0; @@ -2619,9 +2765,10 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) if (! utf8_key) { /* Remove the key and keep just the label. */ - gtk_widget_ref (GTK_WIDGET (wlbl)); + g_object_ref (G_OBJECT (wlbl)); gtk_container_remove (GTK_CONTAINER (w), wchild); gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); + g_object_unref (G_OBJECT (wlbl)); wkey = 0; } @@ -2655,12 +2802,12 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) if (! old_label || strcmp (utf8_label, old_label) != 0) gtk_label_set_text (wlbl, utf8_label); - if (utf8_key && utf8_key != val->key) g_free (utf8_key); - if (utf8_label && utf8_label != val->name) g_free (utf8_label); + if (utf8_key) g_free (utf8_key); + if (utf8_label) g_free (utf8_label); - if (! val->enabled && GTK_WIDGET_SENSITIVE (w)) + if (! val->enabled && gtk_widget_get_sensitive (w)) gtk_widget_set_sensitive (w, FALSE); - else if (val->enabled && ! GTK_WIDGET_SENSITIVE (w)) + else if (val->enabled && ! gtk_widget_get_sensitive (w)) gtk_widget_set_sensitive (w, TRUE); cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (w), @@ -2691,9 +2838,7 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) /* Update the toggle menu item W so it corresponds to VAL. */ static void -xg_update_toggle_item (val, w) - widget_value *val; - GtkWidget *w; +xg_update_toggle_item (widget_value *val, GtkWidget *w) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); } @@ -2701,9 +2846,7 @@ xg_update_toggle_item (val, w) /* Update the radio menu item W so it corresponds to VAL. */ static void -xg_update_radio_item (val, w) - widget_value *val; - GtkWidget *w; +xg_update_radio_item (widget_value *val, GtkWidget *w) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); } @@ -2721,15 +2864,13 @@ xg_update_radio_item (val, w) was NULL. */ static GtkWidget * -xg_update_submenu (submenu, f, val, - select_cb, deactivate_cb, highlight_cb, cl_data) - GtkWidget *submenu; - FRAME_PTR f; - widget_value *val; - GCallback select_cb; - GCallback deactivate_cb; - GCallback highlight_cb; - xg_menu_cb_data *cl_data; +xg_update_submenu (GtkWidget *submenu, + FRAME_PTR f, + widget_value *val, + GCallback select_cb, + GCallback deactivate_cb, + GCallback highlight_cb, + xg_menu_cb_data *cl_data) { GtkWidget *newsub = submenu; GList *list = 0; @@ -2799,8 +2940,8 @@ xg_update_submenu (submenu, f, val, if (sub && ! cur->contents) { /* Not a submenu anymore. */ - gtk_widget_ref (sub); - gtk_menu_item_remove_submenu (witem); + g_object_ref (G_OBJECT (sub)); + remove_submenu (witem); gtk_widget_destroy (sub); } else if (cur->contents) @@ -2864,15 +3005,10 @@ xg_update_submenu (submenu, f, val, HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ void -xg_modify_menubar_widgets (menubar, f, val, deep_p, - select_cb, deactivate_cb, highlight_cb) - GtkWidget *menubar; - FRAME_PTR f; - widget_value *val; - int deep_p; - GCallback select_cb; - GCallback deactivate_cb; - GCallback highlight_cb; +xg_modify_menubar_widgets (GtkWidget *menubar, FRAME_PTR f, widget_value *val, + int deep_p, + GCallback select_cb, GCallback deactivate_cb, + GCallback highlight_cb) { xg_menu_cb_data *cl_data; GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); @@ -2901,7 +3037,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, GList *iter; GtkWidget *sub = 0; GtkWidget *newsub; - GtkMenuItem *witem; + GtkMenuItem *witem = 0; /* Find sub menu that corresponds to val and update it. */ for (iter = list ; iter; iter = g_list_next (iter)) @@ -2924,7 +3060,7 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, /* sub may still be NULL. If we just updated non deep and added a new menu bar item, it has no sub menu yet. So we set the newly created sub menu under witem. */ - if (newsub != sub) + if (newsub != sub && witem != 0) { xg_set_screen (newsub, f); gtk_menu_item_set_submenu (witem, newsub); @@ -2940,13 +3076,12 @@ xg_modify_menubar_widgets (menubar, f, val, deep_p, changed. Value is non-zero if widgets were updated. */ int -xg_update_frame_menubar (f) - FRAME_PTR f; +xg_update_frame_menubar (FRAME_PTR f) { struct x_output *x = f->output_data.x; GtkRequisition req; - if (!x->menubar_widget || GTK_WIDGET_MAPPED (x->menubar_widget)) + if (!x->menubar_widget || gtk_widget_get_mapped (x->menubar_widget)) return 0; if (x->menubar_widget && gtk_widget_get_parent (x->menubar_widget)) @@ -2961,7 +3096,7 @@ xg_update_frame_menubar (f) gtk_widget_show_all (x->menubar_widget); gtk_widget_size_request (x->menubar_widget, &req); FRAME_MENUBAR_HEIGHT (f) = req.height; - xg_height_changed (f); + xg_height_or_width_changed (f); UNBLOCK_INPUT; return 1; @@ -2971,8 +3106,7 @@ xg_update_frame_menubar (f) This is used when deleting a frame, and when turning off the menu bar. */ void -free_frame_menubar (f) - FRAME_PTR f; +free_frame_menubar (FRAME_PTR f) { struct x_output *x = f->output_data.x; @@ -2985,7 +3119,7 @@ free_frame_menubar (f) the container. */ x->menubar_widget = 0; FRAME_MENUBAR_HEIGHT (f) = 0; - xg_height_changed (f); + xg_height_or_width_changed (f); UNBLOCK_INPUT; } } @@ -3032,7 +3166,7 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event) for (iter = list ; iter; iter = g_list_next (iter)) { GtkWidget *w = GTK_WIDGET (iter->data); - if (GTK_WIDGET_MAPPED (w) && gtk_widget_intersect (w, &rec, NULL)) + if (gtk_widget_get_mapped (w) && gtk_widget_intersect (w, &rec, NULL)) break; } g_list_free (list); @@ -3069,8 +3203,7 @@ static struct /* Store the widget pointer W in id_to_widget and return the integer index. */ static int -xg_store_widget_in_map (w) - GtkWidget *w; +xg_store_widget_in_map (GtkWidget *w) { int i; @@ -3108,8 +3241,7 @@ xg_store_widget_in_map (w) Called when scroll bar is destroyed. */ static void -xg_remove_widget_from_map (idx) - int idx; +xg_remove_widget_from_map (int idx) { if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) { @@ -3121,8 +3253,7 @@ xg_remove_widget_from_map (idx) /* Get the widget pointer at IDX from id_to_widget. */ static GtkWidget * -xg_get_widget_from_map (idx) - int idx; +xg_get_widget_from_map (int idx) { if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) return id_to_widget.widgets[idx]; @@ -3134,9 +3265,7 @@ xg_get_widget_from_map (idx) Return -1 if WID not in id_to_widget. */ int -xg_get_scroll_id_for_window (dpy, wid) - Display *dpy; - Window wid; +xg_get_scroll_id_for_window (Display *dpy, Window wid) { int idx; GtkWidget *w; @@ -3158,9 +3287,7 @@ xg_get_scroll_id_for_window (dpy, wid) We free pointer to last scroll bar values here and remove the index. */ static void -xg_gtk_scroll_destroy (widget, data) - GtkWidget *widget; - gpointer data; +xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data) { int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */ xg_remove_widget_from_map (id); @@ -3175,11 +3302,11 @@ xg_gtk_scroll_destroy (widget, data) to set resources for the widget. */ void -xg_create_scroll_bar (f, bar, scroll_callback, end_callback, scroll_bar_name) - FRAME_PTR f; - struct scroll_bar *bar; - GCallback scroll_callback, end_callback; - char *scroll_bar_name; +xg_create_scroll_bar (FRAME_PTR f, + struct scroll_bar *bar, + GCallback scroll_callback, + GCallback end_callback, + const char *scroll_bar_name) { GtkWidget *wscroll; GtkWidget *webox; @@ -3229,23 +3356,10 @@ xg_create_scroll_bar (f, bar, scroll_callback, end_callback, scroll_bar_name) bar->x_window = scroll_id; } -/* Make the scroll bar represented by SCROLLBAR_ID visible. */ - -void -xg_show_scroll_bar (scrollbar_id) - int scrollbar_id; -{ - GtkWidget *w = xg_get_widget_from_map (scrollbar_id); - if (w) - gtk_widget_show_all (gtk_widget_get_parent (w)); -} - /* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ void -xg_remove_scroll_bar (f, scrollbar_id) - FRAME_PTR f; - int scrollbar_id; +xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id) { GtkWidget *w = xg_get_widget_from_map (scrollbar_id); if (w) @@ -3263,13 +3377,12 @@ xg_remove_scroll_bar (f, scrollbar_id) WIDTH, HEIGHT is the size in pixels the bar shall have. */ void -xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) - FRAME_PTR f; - int scrollbar_id; - int top; - int left; - int width; - int height; +xg_update_scrollbar_pos (FRAME_PTR f, + int scrollbar_id, + int top, + int left, + int width, + int height) { GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); @@ -3278,30 +3391,35 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) { GtkWidget *wfixed = f->output_data.x->edit_widget; GtkWidget *wparent = gtk_widget_get_parent (wscroll); - GtkFixed *wf = GTK_FIXED (wfixed); + gint msl; /* Clear out old position. */ - GList *iter; int oldx = -1, oldy = -1, oldw, oldh; - for (iter = wf->children; iter; iter = iter->next) - if (((GtkFixedChild *)iter->data)->widget == wparent) - { - GtkFixedChild *ch = (GtkFixedChild *)iter->data; - if (ch->x != left || ch->y != top) - { - oldx = ch->x; - oldy = ch->y; - gtk_widget_get_size_request (wscroll, &oldw, &oldh); - } - break; - } + if (gtk_widget_get_parent (wparent) == wfixed) + { + gtk_container_child_get (GTK_CONTAINER (wfixed), wparent, + "x", &oldx, "y", &oldy, NULL); + gtk_widget_get_size_request (wscroll, &oldw, &oldh); + } /* Move and resize to new values. */ gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top); - gtk_widget_set_size_request (wscroll, width, height); + gtk_widget_style_get (wscroll, "min-slider-length", &msl, NULL); + if (msl > height) + { + /* No room. Hide scroll bar as some themes output a warning if + the height is less than the min size. */ + gtk_widget_hide (wparent); + gtk_widget_hide (wscroll); + } + else + { + gtk_widget_show_all (wparent); + gtk_widget_set_size_request (wscroll, width, height); + } gtk_widget_queue_draw (wfixed); gdk_window_process_all_updates (); - if (oldx != -1) + if (oldx != -1 && oldw > 0 && oldh > 0) { /* Clear under old scroll bar position. This must be done after the gtk_widget_queue_draw and gdk_window_process_all_updates @@ -3325,9 +3443,10 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) displaying PORTION out of a whole WHOLE, and our position POSITION. */ void -xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) - struct scroll_bar *bar; - int portion, position, whole; +xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, + int portion, + int position, + int whole) { GtkWidget *wscroll = xg_get_widget_from_map (bar->x_window); @@ -3371,13 +3490,13 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) /* Assume all lines are of equal size. */ new_step = size / max (1, FRAME_LINES (f)); - if ((int) adj->page_size != size - || (int) adj->step_increment != new_step) + if ((int) gtk_adjustment_get_page_size (adj) != size + || (int) gtk_adjustment_get_step_increment (adj) != new_step) { - adj->page_size = size; - adj->step_increment = new_step; + gtk_adjustment_set_page_size (adj, size); + gtk_adjustment_set_step_increment (adj, new_step); /* Assume a page increment is about 95% of the page size */ - adj->page_increment = (int) (0.95*adj->page_size); + gtk_adjustment_set_page_increment (adj,(int) (0.95*size)); changed = 1; } @@ -3409,9 +3528,7 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) Return non-zero if the event is for a scroll bar, zero otherwise. */ int -xg_event_is_for_scrollbar (f, event) - FRAME_PTR f; - XEvent *event; +xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event) { int retval = 0; @@ -3420,15 +3537,15 @@ xg_event_is_for_scrollbar (f, event) /* Check if press occurred outside the edit widget. */ GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL) - != f->output_data.x->edit_widget->window; + != gtk_widget_get_window (f->output_data.x->edit_widget); } else if (f && ((event->type == ButtonRelease && event->xbutton.button < 4) || event->type == MotionNotify)) { /* If we are releasing or moving the scroll bar, it has the grab. */ - retval = gtk_grab_get_current () != 0 - && gtk_grab_get_current () != f->output_data.x->edit_widget; + GtkWidget *w = gtk_grab_get_current (); + retval = w != 0 && GTK_IS_SCROLLBAR (w); } return retval; @@ -3466,10 +3583,9 @@ xg_event_is_for_scrollbar (f, event) tool bar. 0 is the first button. */ static gboolean -xg_tool_bar_button_cb (widget, event, user_data) - GtkWidget *widget; - GdkEventButton *event; - gpointer user_data; +xg_tool_bar_button_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) { /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */ gpointer ptr = (gpointer) (EMACS_INT) event->state; @@ -3484,9 +3600,7 @@ xg_tool_bar_button_cb (widget, event, user_data) tool bar. 0 is the first button. */ static void -xg_tool_bar_callback (w, client_data) - GtkWidget *w; - gpointer client_data; +xg_tool_bar_callback (GtkWidget *w, gpointer client_data) { /* The EMACS_INT cast avoids a warning. */ int idx = (int) (EMACS_INT) client_data; @@ -3535,9 +3649,7 @@ xg_tool_bar_callback (w, client_data) tool bar. 0 is the first button. */ static void -xg_tool_bar_proxy_callback (w, client_data) - GtkWidget *w; - gpointer client_data; +xg_tool_bar_proxy_callback (GtkWidget *w, gpointer client_data) { GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_PROXY_BUTTON)); @@ -3546,18 +3658,17 @@ xg_tool_bar_proxy_callback (w, client_data) static gboolean -xg_tool_bar_help_callback P_ ((GtkWidget *w, - GdkEventCrossing *event, - gpointer client_data)); +xg_tool_bar_help_callback (GtkWidget *w, + GdkEventCrossing *event, + gpointer client_data); /* This callback is called when a help is to be shown for an item in the detached tool bar when the detached tool bar it is not expanded. */ static gboolean -xg_tool_bar_proxy_help_callback (w, event, client_data) - GtkWidget *w; - GdkEventCrossing *event; - gpointer client_data; +xg_tool_bar_proxy_help_callback (GtkWidget *w, + GdkEventCrossing *event, + gpointer client_data) { GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_PROXY_BUTTON)); @@ -3565,6 +3676,17 @@ xg_tool_bar_proxy_help_callback (w, event, client_data) return xg_tool_bar_help_callback (wbutton, event, client_data); } +static GtkWidget * +xg_get_tool_bar_widgets (GtkWidget *vb, GtkWidget **wimage) +{ + GList *clist = gtk_container_get_children (GTK_CONTAINER (vb)); + GtkWidget *c1 = (GtkWidget *) clist->data; + GtkWidget *c2 = (GtkWidget *) clist->next->data; + *wimage = GTK_IS_IMAGE (c1) ? c1 : c2; + g_list_free (clist); + return GTK_IS_LABEL (c1) ? c1 : c2; +} + /* This callback is called when a tool item should create a proxy item, such as for the overflow menu. Also called when the tool bar is detached. @@ -3572,21 +3694,24 @@ xg_tool_bar_proxy_help_callback (w, event, client_data) blank. */ static gboolean -xg_tool_bar_menu_proxy (toolitem, user_data) - GtkToolItem *toolitem; - gpointer user_data; +xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data) { GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem)); GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox))); - GtkWidget *wmenuitem = gtk_image_menu_item_new_with_label (""); + GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); + GtkWidget *c1; + GtkLabel *wlbl = GTK_LABEL (xg_get_tool_bar_widgets (vb, &c1)); + GtkImage *wimage = GTK_IMAGE (c1); + GtkWidget *wmenuitem = gtk_image_menu_item_new_with_label + (gtk_label_get_text (wlbl)); GtkWidget *wmenuimage; + if (gtk_button_get_use_stock (wbutton)) wmenuimage = gtk_image_new_from_stock (gtk_button_get_label (wbutton), GTK_ICON_SIZE_MENU); else { - GtkImage *wimage = GTK_IMAGE (gtk_bin_get_child (GTK_BIN (wbutton))); GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton)); GtkImageType store_type = gtk_image_get_storage_type (wimage); @@ -3654,7 +3779,8 @@ xg_tool_bar_menu_proxy (toolitem, user_data) g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON, (gpointer) wbutton); gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem); - gtk_widget_set_sensitive (wmenuitem, GTK_WIDGET_SENSITIVE (wbutton)); + gtk_widget_set_sensitive (wmenuitem, + gtk_widget_get_sensitive (GTK_WIDGET (wbutton))); /* Use enter/leave notify to show help. We use the events rather than the GtkButton specific signals "enter" and @@ -3680,10 +3806,9 @@ xg_tool_bar_menu_proxy (toolitem, user_data) CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ static void -xg_tool_bar_detach_callback (wbox, w, client_data) - GtkHandleBox *wbox; - GtkWidget *w; - gpointer client_data; +xg_tool_bar_detach_callback (GtkHandleBox *wbox, + GtkWidget *w, + gpointer client_data) { FRAME_PTR f = (FRAME_PTR) client_data; extern int x_gtk_whole_detached_tool_bar; @@ -3693,13 +3818,21 @@ xg_tool_bar_detach_callback (wbox, w, client_data) if (f) { + GtkRequisition req, req2; FRAME_X_OUTPUT (f)->toolbar_detached = 1; - - /* When detaching a tool bar, not everything dissapear. There are - a few pixels left that are used to drop the tool bar back into - place. */ - FRAME_TOOLBAR_HEIGHT (f) = 4; - xg_height_changed (f); + gtk_widget_size_request (GTK_WIDGET (wbox), &req); + gtk_widget_size_request (w, &req2); + req.width -= req2.width; + req.height -= req2.height; + if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0) + FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height; + else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height; + else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0) + FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width; + else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0) + FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width; + xg_height_or_width_changed (f); } } @@ -3711,23 +3844,30 @@ xg_tool_bar_detach_callback (wbox, w, client_data) CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ static void -xg_tool_bar_attach_callback (wbox, w, client_data) - GtkHandleBox *wbox; - GtkWidget *w; - gpointer client_data; +xg_tool_bar_attach_callback (GtkHandleBox *wbox, + GtkWidget *w, + gpointer client_data) { FRAME_PTR f = (FRAME_PTR) client_data; g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL); if (f) { - GtkRequisition req; - + GtkRequisition req, req2; FRAME_X_OUTPUT (f)->toolbar_detached = 0; - - gtk_widget_size_request (w, &req); - FRAME_TOOLBAR_HEIGHT (f) = req.height; - xg_height_changed (f); + gtk_widget_size_request (GTK_WIDGET (wbox), &req); + gtk_widget_size_request (w, &req2); + req.width += req2.width; + req.height += req2.height; + if (FRAME_TOOLBAR_TOP_HEIGHT (f) != 0) + FRAME_TOOLBAR_TOP_HEIGHT (f) = req.height; + else if (FRAME_TOOLBAR_BOTTOM_HEIGHT (f) != 0) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = req.height; + else if (FRAME_TOOLBAR_RIGHT_WIDTH (f) != 0) + FRAME_TOOLBAR_RIGHT_WIDTH (f) = req.width; + else if (FRAME_TOOLBAR_LEFT_WIDTH (f) != 0) + FRAME_TOOLBAR_LEFT_WIDTH (f) = req.width; + xg_height_or_width_changed (f); } } @@ -3741,10 +3881,9 @@ xg_tool_bar_attach_callback (wbox, w, client_data) Returns FALSE to tell GTK to keep processing this event. */ static gboolean -xg_tool_bar_help_callback (w, event, client_data) - GtkWidget *w; - GdkEventCrossing *event; - gpointer client_data; +xg_tool_bar_help_callback (GtkWidget *w, + GdkEventCrossing *event, + gpointer client_data) { /* The EMACS_INT cast avoids a warning. */ int idx = (int) (EMACS_INT) client_data; @@ -3783,10 +3922,9 @@ xg_tool_bar_help_callback (w, event, client_data) Returns FALSE to tell GTK to keep processing this event. */ static gboolean -xg_tool_bar_item_expose_callback (w, event, client_data) - GtkWidget *w; - GdkEventExpose *event; - gpointer client_data; +xg_tool_bar_item_expose_callback (GtkWidget *w, + GdkEventExpose *event, + gpointer client_data) { gint width, height; @@ -3804,37 +3942,70 @@ xg_tool_bar_item_expose_callback (w, event, client_data) return FALSE; } +#ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION +#define toolbar_set_orientation(w, o) \ + gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o) +#else +#define toolbar_set_orientation(w, o) \ + gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o) +#endif + /* Attach a tool bar to frame F. */ static void -xg_pack_tool_bar (f) - FRAME_PTR f; +xg_pack_tool_bar (FRAME_PTR f, Lisp_Object pos) { struct x_output *x = f->output_data.x; - int vbox_pos = x->menubar_widget ? 1 : 0; - - x->handlebox_widget = gtk_handle_box_new (); - g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", - G_CALLBACK (xg_tool_bar_detach_callback), f); - g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", - G_CALLBACK (xg_tool_bar_attach_callback), f); + int into_hbox = EQ (pos, Qleft) || EQ (pos, Qright); - gtk_container_add (GTK_CONTAINER (x->handlebox_widget), - x->toolbar_widget); - - gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, - FALSE, FALSE, 0); + toolbar_set_orientation (x->toolbar_widget, + into_hbox + ? GTK_ORIENTATION_VERTICAL + : GTK_ORIENTATION_HORIZONTAL); + if (!x->handlebox_widget) + { + x->handlebox_widget = gtk_handle_box_new (); + g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", + G_CALLBACK (xg_tool_bar_detach_callback), f); + g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", + G_CALLBACK (xg_tool_bar_attach_callback), f); + gtk_container_add (GTK_CONTAINER (x->handlebox_widget), + x->toolbar_widget); + } - gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget, - vbox_pos); - gtk_widget_show_all (x->handlebox_widget); + if (into_hbox) + { + gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), + GTK_POS_TOP); + gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget, + FALSE, FALSE, 0); + + if (EQ (pos, Qleft)) + gtk_box_reorder_child (GTK_BOX (x->hbox_widget), + x->handlebox_widget, + 0); + x->toolbar_in_hbox = 1; + } + else + { + int vbox_pos = x->menubar_widget ? 1 : 0; + gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), + GTK_POS_LEFT); + gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, + FALSE, FALSE, 0); + + if (EQ (pos, Qtop)) + gtk_box_reorder_child (GTK_BOX (x->vbox_widget), + x->handlebox_widget, + vbox_pos); + x->toolbar_in_hbox = 0; + } } /* Create a tool bar for frame F. */ static void -xg_create_tool_bar (f) - FRAME_PTR f; +xg_create_tool_bar (FRAME_PTR f) { struct x_output *x = f->output_data.x; @@ -3843,16 +4014,8 @@ xg_create_tool_bar (f) gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar"); - /* We only have icons, so override any user setting. We could - use the caption property of the toolbar item (see update_frame_tool_bar - below), but some of those strings are long, making the toolbar so - long it does not fit on the screen. The GtkToolbar widget makes every - item equal size, so the longest caption determine the size of every - tool bar item. I think the creators of the GtkToolbar widget - counted on 4 or 5 character long strings. */ gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS); - gtk_toolbar_set_orientation (GTK_TOOLBAR (x->toolbar_widget), - GTK_ORIENTATION_HORIZONTAL); + toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL); } @@ -3862,10 +4025,7 @@ xg_create_tool_bar (f) Returns IMAGE if RTL is not found. */ static Lisp_Object -find_rtl_image (f, image, rtl) - FRAME_PTR f; - Lisp_Object image; - Lisp_Object rtl; +find_rtl_image (FRAME_PTR f, Lisp_Object image, Lisp_Object rtl) { int i; Lisp_Object file, rtl_name; @@ -3892,16 +4052,192 @@ find_rtl_image (f, image, rtl) return image; } -/* Update the tool bar for frame F. Add new buttons and remove old. */ +static GtkToolItem * +xg_make_tool_item (FRAME_PTR f, + GtkWidget *wimage, + GtkWidget **wbutton, + const char *label, + int i) +{ + GtkToolItem *ti = gtk_tool_item_new (); + Lisp_Object style = Ftool_bar_get_system_style (); + int both_horiz = EQ (style, Qboth_horiz); + int text_image = EQ (style, Qtext_image_horiz); + + GtkWidget *vb = both_horiz || text_image + ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0); + GtkWidget *wb = gtk_button_new (); + GtkWidget *weventbox = gtk_event_box_new (); + + if (wimage && ! text_image) + gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX (vb), gtk_label_new (label), TRUE, TRUE, 0); + + if (wimage && text_image) + gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0); + + gtk_button_set_focus_on_click (GTK_BUTTON (wb), FALSE); + gtk_button_set_relief (GTK_BUTTON (wb), GTK_RELIEF_NONE); + gtk_container_add (GTK_CONTAINER (wb), vb); + gtk_container_add (GTK_CONTAINER (weventbox), wb); + gtk_container_add (GTK_CONTAINER (ti), weventbox); + + if (wimage) + { + /* The EMACS_INT cast avoids a warning. */ + g_signal_connect (G_OBJECT (ti), "create-menu-proxy", + G_CALLBACK (xg_tool_bar_menu_proxy), + (gpointer) (EMACS_INT) i); + + g_signal_connect (G_OBJECT (wb), "clicked", + G_CALLBACK (xg_tool_bar_callback), + (gpointer) (EMACS_INT) i); + + g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f); + + /* Catch expose events to overcome an annoying redraw bug, see + comment for xg_tool_bar_item_expose_callback. */ + g_signal_connect (G_OBJECT (ti), + "expose-event", + G_CALLBACK (xg_tool_bar_item_expose_callback), + 0); + + gtk_tool_item_set_homogeneous (ti, FALSE); + + /* Callback to save modifyer mask (Shift/Control, etc). GTK makes + no distinction based on modifiers in the activate callback, + so we have to do it ourselves. */ + g_signal_connect (wb, "button-release-event", + G_CALLBACK (xg_tool_bar_button_cb), + NULL); + + g_object_set_data (G_OBJECT (wb), XG_FRAME_DATA, (gpointer)f); + + /* Use enter/leave notify to show help. We use the events + rather than the GtkButton specific signals "enter" and + "leave", so we can have only one callback. The event + will tell us what kind of event it is. */ + /* The EMACS_INT cast avoids a warning. */ + g_signal_connect (G_OBJECT (weventbox), + "enter-notify-event", + G_CALLBACK (xg_tool_bar_help_callback), + (gpointer) (EMACS_INT) i); + g_signal_connect (G_OBJECT (weventbox), + "leave-notify-event", + G_CALLBACK (xg_tool_bar_help_callback), + (gpointer) (EMACS_INT) i); + } + + if (wbutton) *wbutton = wb; -extern Lisp_Object Qx_gtk_map_stock; + return ti; +} + +static void +xg_show_toolbar_item (GtkToolItem *ti) +{ + Lisp_Object style = Ftool_bar_get_system_style (); + int both_horiz = EQ (style, Qboth_horiz); + int text_image = EQ (style, Qtext_image_horiz); + + int horiz = both_horiz || text_image; + int show_label = ! EQ (style, Qimage); + int show_image = ! EQ (style, Qtext); + + GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti)); + GtkWidget *wbutton = gtk_bin_get_child (GTK_BIN (weventbox)); + GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); + GtkWidget *wimage; + GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); + GtkWidget *new_box = NULL; + + if (GTK_IS_VBOX (vb) && horiz) + new_box = gtk_hbox_new (FALSE, 0); + else if (GTK_IS_HBOX (vb) && !horiz && show_label && show_image) + new_box = gtk_vbox_new (FALSE, 0); + + if (!new_box && horiz) + gtk_box_reorder_child (GTK_BOX (vb), wlbl, text_image ? 0 : 1); + else if (new_box) + { + g_object_ref (G_OBJECT (wimage)); + g_object_ref (G_OBJECT (wlbl)); + gtk_container_remove (GTK_CONTAINER (vb), wimage); + gtk_container_remove (GTK_CONTAINER (vb), wlbl); + gtk_widget_destroy (GTK_WIDGET (vb)); + if (! text_image) + gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (new_box), wlbl, TRUE, TRUE, 0); + if (text_image) + gtk_box_pack_start (GTK_BOX (new_box), wimage, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (wbutton), new_box); + g_object_unref (G_OBJECT (wimage)); + g_object_unref (G_OBJECT (wlbl)); + vb = new_box; + } + + if (show_label) gtk_widget_show (wlbl); + else gtk_widget_hide (wlbl); + if (show_image) gtk_widget_show (wimage); + else gtk_widget_hide (wimage); + gtk_widget_show (GTK_WIDGET (weventbox)); + gtk_widget_show (GTK_WIDGET (vb)); + gtk_widget_show (GTK_WIDGET (wbutton)); + gtk_widget_show (GTK_WIDGET (ti)); +} + +static int +xg_update_tool_bar_sizes (FRAME_PTR f) +{ + struct x_output *x = f->output_data.x; + GtkRequisition req; + int nl = 0, nr = 0, nt = 0, nb = 0; + + gtk_widget_size_request (GTK_WIDGET (x->handlebox_widget), &req); + if (x->toolbar_in_hbox) + { + int pos; + gtk_container_child_get (GTK_CONTAINER (x->hbox_widget), + x->handlebox_widget, + "position", &pos, NULL); + if (pos == 0) nl = req.width; + else nr = req.width; + } + else + { + int pos; + gtk_container_child_get (GTK_CONTAINER (x->vbox_widget), + x->handlebox_widget, + "position", &pos, NULL); + if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height; + else nb = req.height; + } + + if (nl != FRAME_TOOLBAR_LEFT_WIDTH (f) + || nr != FRAME_TOOLBAR_RIGHT_WIDTH (f) + || nt != FRAME_TOOLBAR_TOP_HEIGHT (f) + || nb != FRAME_TOOLBAR_BOTTOM_HEIGHT (f)) + { + FRAME_TOOLBAR_RIGHT_WIDTH (f) = FRAME_TOOLBAR_LEFT_WIDTH (f) + = FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; + FRAME_TOOLBAR_LEFT_WIDTH (f) = nl; + FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr; + FRAME_TOOLBAR_TOP_HEIGHT (f) = nt; + FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb; + return 1; + } + + return 0; +} + + +/* Update the tool bar for frame F. Add new buttons and remove old. */ void -update_frame_tool_bar (f) - FRAME_PTR f; +update_frame_tool_bar (FRAME_PTR f) { int i; - GtkRequisition old_req, new_req; struct x_output *x = f->output_data.x; int hmargin = 0, vmargin = 0; GtkToolbar *wtoolbar; @@ -3942,9 +4278,8 @@ update_frame_tool_bar (f) xg_create_tool_bar (f); wtoolbar = GTK_TOOLBAR (x->toolbar_widget); - gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req); - dir = gtk_widget_get_direction (x->toolbar_widget); - + dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar)); + for (i = 0; i < f->n_tool_bar_items; ++i) { int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); @@ -3962,8 +4297,10 @@ update_frame_tool_bar (f) GtkWidget *wbutton = NULL; GtkWidget *weventbox; Lisp_Object specified_file; - - ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); + const char *label = (STRINGP (PROP (TOOL_BAR_ITEM_LABEL)) + ? SSDATA (PROP (TOOL_BAR_ITEM_LABEL)) : ""); + + ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i); if (ti) { @@ -3971,6 +4308,7 @@ update_frame_tool_bar (f) wbutton = gtk_bin_get_child (GTK_BIN (weventbox)); } + image = PROP (TOOL_BAR_ITEM_IMAGES); /* Ignore invalid image specifications. */ @@ -4002,7 +4340,7 @@ update_frame_tool_bar (f) icon_size = gtk_toolbar_get_icon_size (wtoolbar); } else if (gtk_stock_lookup (SSDATA (stock), &stock_item)) - icon_size = gtk_toolbar_get_icon_size (wtoolbar); + icon_size = gtk_toolbar_get_icon_size (wtoolbar); else { stock = Qnil; @@ -4046,22 +4384,15 @@ update_frame_tool_bar (f) if (img->load_failed_p || img->pixmap == None) { - if (ti) - gtk_widget_hide_all (GTK_WIDGET (ti)); - else + if (ti) + gtk_widget_hide_all (GTK_WIDGET (ti)); + else { - /* Insert an empty (non-image) button */ - weventbox = gtk_event_box_new (); - wbutton = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE); - gtk_button_set_relief (GTK_BUTTON (wbutton), - GTK_RELIEF_NONE); - gtk_container_add (GTK_CONTAINER (weventbox), wbutton); - ti = gtk_tool_item_new (); - gtk_container_add (GTK_CONTAINER (ti), weventbox); - gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1); + /* Insert an empty (non-image) button */ + ti = xg_make_tool_item (f, NULL, NULL, "", i); + gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); } - continue; + continue; } } @@ -4092,73 +4423,23 @@ update_frame_tool_bar (f) } gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); - wbutton = gtk_button_new (); - gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE); - gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE); - gtk_container_add (GTK_CONTAINER (wbutton), w); - weventbox = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (weventbox), wbutton); - ti = gtk_tool_item_new (); - gtk_container_add (GTK_CONTAINER (ti), weventbox); - gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1); - - - /* The EMACS_INT cast avoids a warning. */ - g_signal_connect (G_OBJECT (ti), "create-menu-proxy", - G_CALLBACK (xg_tool_bar_menu_proxy), - (gpointer) (EMACS_INT) i); - - g_signal_connect (G_OBJECT (wbutton), "clicked", - G_CALLBACK (xg_tool_bar_callback), - (gpointer) (EMACS_INT) i); - - gtk_widget_show_all (GTK_WIDGET (ti)); - - - g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f); - - /* Catch expose events to overcome an annoying redraw bug, see - comment for xg_tool_bar_item_expose_callback. */ - g_signal_connect (G_OBJECT (ti), - "expose-event", - G_CALLBACK (xg_tool_bar_item_expose_callback), - 0); - + ti = xg_make_tool_item (f, w, &wbutton, label, i); + gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); gtk_widget_set_sensitive (wbutton, enabled_p); - gtk_tool_item_set_homogeneous (ti, FALSE); - - /* Callback to save modifyer mask (Shift/Control, etc). GTK makes - no distinction based on modifiers in the activate callback, - so we have to do it ourselves. */ - g_signal_connect (wbutton, "button-release-event", - G_CALLBACK (xg_tool_bar_button_cb), - NULL); - - g_object_set_data (G_OBJECT (wbutton), XG_FRAME_DATA, (gpointer)f); - - /* Use enter/leave notify to show help. We use the events - rather than the GtkButton specific signals "enter" and - "leave", so we can have only one callback. The event - will tell us what kind of event it is. */ - /* The EMACS_INT cast avoids a warning. */ - g_signal_connect (G_OBJECT (weventbox), - "enter-notify-event", - G_CALLBACK (xg_tool_bar_help_callback), - (gpointer) (EMACS_INT) i); - g_signal_connect (G_OBJECT (weventbox), - "leave-notify-event", - G_CALLBACK (xg_tool_bar_help_callback), - (gpointer) (EMACS_INT) i); } else { - GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton)); + GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); + GtkWidget *wimage; + GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); + Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA); gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME); gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME); + gtk_label_set_text (GTK_LABEL (wlbl), label); if (stock_name && (! old_stock_name || strcmp (old_stock_name, stock_name) != 0)) { @@ -4169,7 +4450,8 @@ update_frame_tool_bar (f) (GDestroyNotify) xfree); g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, NULL); - g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, NULL); + g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, + NULL); } else if (icon_name && (! old_icon_name || strcmp (old_icon_name, icon_name) != 0)) @@ -4186,20 +4468,22 @@ update_frame_tool_bar (f) } else if (img && old_img != img->pixmap) { - (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); + (void) xg_get_image_for_pixmap (f, img, x->widget, + GTK_IMAGE (wimage)); g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, (gpointer)img->pixmap); g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, NULL); - g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, NULL); + g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, + NULL); } gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin); gtk_widget_set_sensitive (wbutton, enabled_p); - gtk_widget_show_all (GTK_WIDGET (ti)); - } + } + xg_show_toolbar_item (ti); #undef PROP } @@ -4208,22 +4492,20 @@ update_frame_tool_bar (f) can be reused later on. */ do { - ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i++); + ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i++); if (ti) gtk_widget_hide_all (GTK_WIDGET (ti)); } while (ti != NULL); - new_req.height = 0; - if (pack_tool_bar && f->n_tool_bar_items != 0) - xg_pack_tool_bar (f); - - - gtk_widget_size_request (GTK_WIDGET (x->toolbar_widget), &new_req); - if (old_req.height != new_req.height - && ! FRAME_X_OUTPUT (f)->toolbar_detached) + if (f->n_tool_bar_items != 0) { - FRAME_TOOLBAR_HEIGHT (f) = new_req.height; - xg_height_changed (f); + if (pack_tool_bar) + xg_pack_tool_bar (f, f->tool_bar_position); + gtk_widget_show (x->toolbar_widget); + gtk_widget_show (x->handlebox_widget); + if (xg_update_tool_bar_sizes (f)) + xg_height_or_width_changed (f); } + UNBLOCK_INPUT; } @@ -4231,8 +4513,7 @@ update_frame_tool_bar (f) Remove the tool bar. */ void -free_frame_tool_bar (f) - FRAME_PTR f; +free_frame_tool_bar (FRAME_PTR f) { struct x_output *x = f->output_data.x; @@ -4242,28 +4523,61 @@ free_frame_tool_bar (f) BLOCK_INPUT; /* We may have created the toolbar_widget in xg_create_tool_bar, but not the x->handlebox_widget which is created in xg_pack_tool_bar. */ - if (is_packed) - gtk_container_remove (GTK_CONTAINER (x->vbox_widget), - x->handlebox_widget); + if (is_packed) + { + if (x->toolbar_in_hbox) + gtk_container_remove (GTK_CONTAINER (x->hbox_widget), + x->handlebox_widget); + else + gtk_container_remove (GTK_CONTAINER (x->vbox_widget), + x->handlebox_widget); + } else gtk_widget_destroy (x->toolbar_widget); x->toolbar_widget = 0; x->handlebox_widget = 0; - FRAME_TOOLBAR_HEIGHT (f) = 0; - xg_height_changed (f); + FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; + FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0; + + xg_height_or_width_changed (f); UNBLOCK_INPUT; } } +int +xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos) +{ + struct x_output *x = f->output_data.x; + + if (! x->toolbar_widget || ! x->handlebox_widget) + return 1; + + BLOCK_INPUT; + g_object_ref (x->handlebox_widget); + if (x->toolbar_in_hbox) + gtk_container_remove (GTK_CONTAINER (x->hbox_widget), + x->handlebox_widget); + else + gtk_container_remove (GTK_CONTAINER (x->vbox_widget), + x->handlebox_widget); + xg_pack_tool_bar (f, pos); + g_object_unref (x->handlebox_widget); + if (xg_update_tool_bar_sizes (f)) + xg_height_or_width_changed (f); + + UNBLOCK_INPUT; + return 1; +} + /*********************************************************************** Initializing - ***********************************************************************/ +***********************************************************************/ void -xg_initialize () +xg_initialize (void) { GtkBindingSet *binding_set; diff --git a/src/gtkutil.h b/src/gtkutil.h index 7c1e09a1a5e..9b796e1138c 100644 --- a/src/gtkutil.h +++ b/src/gtkutil.h @@ -38,15 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Key for data that menu items hold. */ #define XG_ITEM_DATA "emacs_menuitem" - -/* Button types in menus. */ -enum button_type -{ - BUTTON_TYPE_NONE, - BUTTON_TYPE_TOGGLE, - BUTTON_TYPE_RADIO -}; - /* This is a list node in a generic list implementation. */ typedef struct xg_list_node_ { @@ -83,132 +74,109 @@ typedef struct xg_menu_item_cb_data_ } xg_menu_item_cb_data; -/* Used to specify menus and dialogs. - This is an adaption from lwlib for Gtk so we can use more of the same - code as lwlib in xmenu.c. */ -typedef struct _widget_value -{ - /* name of widget */ - Lisp_Object lname; - char *name; - /* value (meaning depend on widget type) */ - char *value; - /* keyboard equivalent. no implications for XtTranslations */ - Lisp_Object lkey; - char *key; - /* Help string or nil if none. - GC finds this string through the frame's menu_bar_vector - or through menu_items. */ - Lisp_Object help; - /* true if enabled */ - gint enabled; - /* true if selected */ - gint selected; - /* The type of a button. */ - enum button_type button_type; - /* Contents of the sub-widgets, also selected slot for checkbox */ - struct _widget_value *contents; - /* data passed to callback */ - gpointer call_data; - /* next one in the list */ - struct _widget_value *next; - - /* we resource the widget_value structures; this points to the next - one on the free list if this one has been deallocated. - */ - struct _widget_value *free_list; -} widget_value; - -#ifdef HAVE_GTK_FILE_BOTH +#ifdef HAVE_GTK_FILE_SELECTION_NEW extern int use_old_gtk_file_dialog; #endif +struct _widget_value; + +extern struct _widget_value *malloc_widget_value (void); +extern void free_widget_value (struct _widget_value *); + +extern int xg_uses_old_file_dialog (void); + +extern char *xg_get_file_name (FRAME_PTR f, + char *prompt, + char *default_filename, + int mustmatch_p, + int only_dir_p); + +extern char *xg_get_font_name (FRAME_PTR f, const char *); + +extern GtkWidget *xg_create_widget (const char *type, + const char *name, + FRAME_PTR f, + struct _widget_value *val, + GCallback select_cb, + GCallback deactivate_cb, + GCallback hightlight_cb); + +extern void xg_modify_menubar_widgets (GtkWidget *menubar, + FRAME_PTR f, + struct _widget_value *val, + int deep_p, + GCallback select_cb, + GCallback deactivate_cb, + GCallback hightlight_cb); + +extern int xg_update_frame_menubar (FRAME_PTR f); + +extern int xg_event_is_for_menubar (FRAME_PTR f, XEvent *event); + +extern int xg_have_tear_offs (void); + +extern int xg_get_scroll_id_for_window (Display *dpy, Window wid); + +extern void xg_create_scroll_bar (FRAME_PTR f, + struct scroll_bar *bar, + GCallback scroll_callback, + GCallback end_callback, + const char *scroll_bar_name); +extern void xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id); + +extern void xg_update_scrollbar_pos (FRAME_PTR f, + int scrollbar_id, + int top, + int left, + int width, + int height); + +extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, + int portion, + int position, + int whole); +extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); + +extern void update_frame_tool_bar (FRAME_PTR f); +extern void free_frame_tool_bar (FRAME_PTR f); +extern int xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos); + +extern void xg_frame_resized (FRAME_PTR f, + int pixelwidth, + int pixelheight); +extern void xg_frame_set_char_size (FRAME_PTR f, int cols, int rows); +extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc); + +extern void xg_display_open (char *display_name, Display **dpy); +extern void xg_display_close (Display *dpy); +extern GdkCursor * xg_create_default_cursor (Display *dpy); + +extern int xg_create_frame_widgets (FRAME_PTR f); +extern void xg_free_frame_widgets (FRAME_PTR f); +extern void x_wm_set_size_hint (FRAME_PTR f, + long flags, + int user_position); +extern void xg_set_background_color (FRAME_PTR f, unsigned long bg); +extern int xg_check_special_colors (struct frame *f, + const char *color_name, + XColor *color); + +extern void xg_set_frame_icon (FRAME_PTR f, + Pixmap icon_pixmap, + Pixmap icon_mask); + +extern int xg_prepare_tooltip (FRAME_PTR f, + Lisp_Object string, + int *width, + int *height); +extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y); +extern int xg_hide_tooltip (FRAME_PTR f); -extern widget_value *malloc_widget_value P_ ((void)); -extern void free_widget_value P_ ((widget_value *)); - -extern int xg_uses_old_file_dialog P_ ((void)); - -extern char *xg_get_file_name P_ ((FRAME_PTR f, - char *prompt, - char *default_filename, - int mustmatch_p, - int only_dir_p)); - -extern char *xg_get_font_name P_ ((FRAME_PTR f, char *)); - -extern GtkWidget *xg_create_widget P_ ((char *type, - char *name, - FRAME_PTR f, - widget_value *val, - GCallback select_cb, - GCallback deactivate_cb, - GCallback hightlight_cb)); - -extern void xg_modify_menubar_widgets P_ ((GtkWidget *menubar, - FRAME_PTR f, - widget_value *val, - int deep_p, - GCallback select_cb, - GCallback deactivate_cb, - GCallback hightlight_cb)); - -extern int xg_update_frame_menubar P_ ((FRAME_PTR f)); - -extern int xg_event_is_for_menubar P_ ((FRAME_PTR f, XEvent *event)); - -extern int xg_have_tear_offs P_ ((void)); - -extern int xg_get_scroll_id_for_window P_ ((Display *dpy, Window wid)); - -extern void xg_create_scroll_bar P_ ((FRAME_PTR f, - struct scroll_bar *bar, - GCallback scroll_callback, - GCallback end_callback, - char *scroll_bar_name)); -extern void xg_show_scroll_bar P_ ((int scrollbar_id)); -extern void xg_remove_scroll_bar P_ ((FRAME_PTR f, int scrollbar_id)); - -extern void xg_update_scrollbar_pos P_ ((FRAME_PTR f, - int scrollbar_id, - int top, - int left, - int width, - int height)); - -extern void xg_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *bar, - int portion, - int position, - int whole)); -extern int xg_event_is_for_scrollbar P_ ((FRAME_PTR f, XEvent *event)); - -extern void update_frame_tool_bar P_ ((FRAME_PTR f)); -extern void free_frame_tool_bar P_ ((FRAME_PTR f)); - -extern void xg_frame_resized P_ ((FRAME_PTR f, - int pixelwidth, - int pixelheight)); -extern void xg_frame_set_char_size P_ ((FRAME_PTR f, int cols, int rows)); -extern GtkWidget * xg_win_to_widget P_ ((Display *dpy, Window wdesc)); - -extern int xg_display_open P_ ((char *display_name, Display **dpy)); -extern void xg_display_close P_ ((Display *dpy)); -extern GdkCursor * xg_create_default_cursor P_ ((Display *dpy)); - -extern int xg_create_frame_widgets P_ ((FRAME_PTR f)); -extern void x_wm_set_size_hint P_ ((FRAME_PTR f, - long flags, - int user_position)); -extern void xg_set_background_color P_ ((FRAME_PTR f, unsigned long bg)); - -extern void xg_set_frame_icon P_ ((FRAME_PTR f, - Pixmap icon_pixmap, - Pixmap icon_mask)); /* Mark all callback data that are Lisp_object:s during GC. */ -extern void xg_mark_data P_ ((void)); +extern void xg_mark_data (void); /* Initialize GTK specific parts. */ -extern void xg_initialize P_ ((void)); +extern void xg_initialize (void); /* Setting scrollbar values invokes the callback. Use this variable to indicate that the callback should do nothing. */ diff --git a/src/image.c b/src/image.c index e7db3a7df1b..bd742138195 100644 --- a/src/image.c +++ b/src/image.c @@ -126,17 +126,20 @@ typedef struct ns_bitmap_record Bitmap_Record; Lisp_Object Vx_bitmap_file_path; +/* The symbol `postscript' identifying images of this type. */ + +Lisp_Object Qpostscript; -static void x_disable_image P_ ((struct frame *, struct image *)); -static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object, - Lisp_Object)); +static void x_disable_image (struct frame *, struct image *); +static void x_edge_detection (struct frame *, struct image *, Lisp_Object, + Lisp_Object); -static void init_color_table P_ ((void)); -static unsigned long lookup_rgb_color P_ ((struct frame *f, int r, int g, int b)); +static void init_color_table (void); +static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b); #ifdef COLOR_TABLE_SUPPORT -static void free_color_table P_ ((void)); -static unsigned long *colors_in_color_table P_ ((int *n)); -static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p)); +static void free_color_table (void); +static unsigned long *colors_in_color_table (int *n); +static unsigned long lookup_pixel_color (struct frame *f, unsigned long p); #endif /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap @@ -157,7 +160,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y, unsigned long plane_mask, int format) { /* TODO: not sure what this function is supposed to do.. */ - ns_retain_object(pixmap); + ns_retain_object (pixmap); return pixmap; } @@ -165,7 +168,7 @@ XGetImage (Display *display, Pixmap pixmap, int x, int y, unsigned long XGetPixel (XImagePtr ximage, int x, int y) { - return ns_get_pixel(ximage, x, y); + return ns_get_pixel (ximage, x, y); } /* use with imgs created by ns_image_for_XPM; alpha set to 1; @@ -173,7 +176,7 @@ XGetPixel (XImagePtr ximage, int x, int y) void XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) { - ns_put_pixel(ximage, x, y, pixel); + ns_put_pixel (ximage, x, y, pixel); } #endif /* HAVE_NS */ @@ -181,26 +184,20 @@ XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) /* Functions to access the contents of a bitmap, given an id. */ int -x_bitmap_height (f, id) - FRAME_PTR f; - int id; +x_bitmap_height (FRAME_PTR f, int id) { return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; } int -x_bitmap_width (f, id) - FRAME_PTR f; - int id; +x_bitmap_width (FRAME_PTR f, int id) { return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; } #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) int -x_bitmap_pixmap (f, id) - FRAME_PTR f; - int id; +x_bitmap_pixmap (FRAME_PTR f, int id) { return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; } @@ -208,9 +205,7 @@ x_bitmap_pixmap (f, id) #ifdef HAVE_X_WINDOWS int -x_bitmap_mask (f, id) - FRAME_PTR f; - int id; +x_bitmap_mask (FRAME_PTR f, int id) { return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; } @@ -219,8 +214,7 @@ x_bitmap_mask (f, id) /* Allocate a new bitmap record. Returns index of new record. */ static int -x_allocate_bitmap_record (f) - FRAME_PTR f; +x_allocate_bitmap_record (FRAME_PTR f) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); int i; @@ -251,9 +245,7 @@ x_allocate_bitmap_record (f) /* Add one reference to the reference count of the bitmap with id ID. */ void -x_reference_bitmap (f, id) - FRAME_PTR f; - int id; +x_reference_bitmap (FRAME_PTR f, int id) { ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount; } @@ -261,10 +253,7 @@ x_reference_bitmap (f, id) /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ int -x_create_bitmap_from_data (f, bits, width, height) - struct frame *f; - char *bits; - unsigned int width, height; +x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); int id; @@ -288,7 +277,7 @@ x_create_bitmap_from_data (f, bits, width, height) #endif /* HAVE_NTGUI */ #ifdef HAVE_NS - void *bitmap = ns_image_from_XBM(bits, width, height); + void *bitmap = ns_image_from_XBM (bits, width, height); if (!bitmap) return -1; #endif @@ -323,9 +312,7 @@ x_create_bitmap_from_data (f, bits, width, height) /* Create bitmap from file FILE for frame F. */ int -x_create_bitmap_from_file (f, file) - struct frame *f; - Lisp_Object file; +x_create_bitmap_from_file (struct frame *f, Lisp_Object file) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -335,7 +322,7 @@ x_create_bitmap_from_file (f, file) #ifdef HAVE_NS int id; - void *bitmap = ns_image_from_file(file); + void *bitmap = ns_image_from_file (file); if (!bitmap) return -1; @@ -346,8 +333,8 @@ x_create_bitmap_from_file (f, file) dpyinfo->bitmaps[id - 1].refcount = 1; dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1); dpyinfo->bitmaps[id - 1].depth = 1; - dpyinfo->bitmaps[id - 1].height = ns_image_width(bitmap); - dpyinfo->bitmaps[id - 1].width = ns_image_height(bitmap); + dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap); + dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap); strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); return id; #endif @@ -402,9 +389,7 @@ x_create_bitmap_from_file (f, file) /* Free bitmap B. */ static void -free_bitmap_record (dpyinfo, bm) - Display_Info *dpyinfo; - Bitmap_Record *bm; +free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) { #ifdef HAVE_X_WINDOWS XFreePixmap (dpyinfo->display, bm->pixmap); @@ -417,7 +402,7 @@ free_bitmap_record (dpyinfo, bm) #endif /* HAVE_NTGUI */ #ifdef HAVE_NS - ns_release_object(bm->img); + ns_release_object (bm->img); #endif if (bm->file) @@ -430,9 +415,7 @@ free_bitmap_record (dpyinfo, bm) /* Remove reference to bitmap with id number ID. */ void -x_destroy_bitmap (f, id) - FRAME_PTR f; - int id; +x_destroy_bitmap (FRAME_PTR f, int id) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -452,8 +435,7 @@ x_destroy_bitmap (f, id) /* Free all the bitmaps for the display specified by DPYINFO. */ void -x_destroy_all_bitmaps (dpyinfo) - Display_Info *dpyinfo; +x_destroy_all_bitmaps (Display_Info *dpyinfo) { int i; Bitmap_Record *bm = dpyinfo->bitmaps; @@ -471,25 +453,23 @@ x_destroy_all_bitmaps (dpyinfo) /* Useful functions defined in the section `Image type independent image structures' below. */ -static unsigned long four_corners_best P_ ((XImagePtr ximg, - int *corners, - unsigned long width, - unsigned long height)); +static unsigned long four_corners_best (XImagePtr ximg, + int *corners, + unsigned long width, + unsigned long height); -static int x_create_x_image_and_pixmap P_ ((struct frame *f, int width, int height, - int depth, XImagePtr *ximg, - Pixmap *pixmap)); +static int x_create_x_image_and_pixmap (struct frame *f, int width, int height, + int depth, XImagePtr *ximg, + Pixmap *pixmap); -static void x_destroy_x_image P_ ((XImagePtr ximg)); +static void x_destroy_x_image (XImagePtr ximg); /* Create a mask of a bitmap. Note is this not a perfect mask. It's nicer with some borders in this context */ int -x_create_bitmap_mask (f, id) - struct frame *f; - int id; +x_create_bitmap_mask (struct frame *f, int id) { Pixmap pixmap, mask; XImagePtr ximg, mask_img; @@ -587,10 +567,6 @@ static struct image_type *image_types; Lisp_Object Vimage_types; -/* An alist of image types and libraries that implement the type. */ - -Lisp_Object Vimage_library_alist; - /* Cache for delayed-loading image types. */ static Lisp_Object Vimage_type_cache; @@ -601,12 +577,9 @@ Lisp_Object Qxbm; /* Keywords. */ -extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; -extern Lisp_Object QCdata, QCtype; -extern Lisp_Object Qcenter; -Lisp_Object QCascent, QCmargin, QCrelief, Qcount; +Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; -Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask; +Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry, QCcrop, QCrotation; /* Other symbols. */ @@ -619,13 +592,13 @@ Lisp_Object Vimage_cache_eviction_delay; /* Function prototypes. */ -static Lisp_Object define_image_type P_ ((struct image_type *type, int loaded)); -static struct image_type *lookup_image_type P_ ((Lisp_Object symbol)); -static void image_error P_ ((char *format, Lisp_Object, Lisp_Object)); -static void x_laplace P_ ((struct frame *, struct image *)); -static void x_emboss P_ ((struct frame *, struct image *)); -static int x_build_heuristic_mask P_ ((struct frame *, struct image *, - Lisp_Object)); +static Lisp_Object define_image_type (struct image_type *type, int loaded); +static struct image_type *lookup_image_type (Lisp_Object symbol); +static void image_error (const char *format, Lisp_Object, Lisp_Object); +static void x_laplace (struct frame *, struct image *); +static void x_emboss (struct frame *, struct image *); +static int x_build_heuristic_mask (struct frame *, struct image *, + Lisp_Object); #define CACHE_IMAGE_TYPE(type, status) \ do { Vimage_type_cache = Fcons (Fcons (type, status), Vimage_type_cache); } while (0) @@ -637,9 +610,7 @@ static int x_build_heuristic_mask P_ ((struct frame *, struct image *, image_types and caches the loading status of TYPE. */ static Lisp_Object -define_image_type (type, loaded) - struct image_type *type; - int loaded; +define_image_type (struct image_type *type, int loaded) { Lisp_Object success; @@ -650,7 +621,7 @@ define_image_type (type, loaded) /* Make a copy of TYPE to avoid a bus error in a dumped Emacs. The initialized data segment is read-only. */ struct image_type *p = (struct image_type *) xmalloc (sizeof *p); - bcopy (type, p, sizeof *p); + memcpy (p, type, sizeof *p); p->next = image_types; image_types = p; success = Qt; @@ -665,13 +636,12 @@ define_image_type (type, loaded) structure. Value is null if SYMBOL is not a known image type. */ static INLINE struct image_type * -lookup_image_type (symbol) - Lisp_Object symbol; +lookup_image_type (Lisp_Object symbol) { struct image_type *type; /* We must initialize the image-type if it hasn't been already. */ - if (NILP (Finit_image_library (symbol, Vimage_library_alist))) + if (NILP (Finit_image_library (symbol, Vdynamic_library_alist))) return 0; /* unimplemented */ for (type = image_types; type; type = type->next) @@ -690,8 +660,7 @@ lookup_image_type (symbol) image type. */ int -valid_image_p (object) - Lisp_Object object; +valid_image_p (Lisp_Object object) { int valid_p = 0; @@ -726,9 +695,7 @@ valid_image_p (object) therefore simply displays a message. */ static void -image_error (format, arg1, arg2) - char *format; - Lisp_Object arg1, arg2; +image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2) { add_to_log (format, arg1, arg2); } @@ -760,7 +727,7 @@ enum image_value_type struct image_keyword { /* Name of keyword. */ - char *name; + const char *name; /* The type of value allowed. */ enum image_value_type type; @@ -776,9 +743,9 @@ struct image_keyword }; -static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *, - int, Lisp_Object)); -static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); +static int parse_image_spec (Lisp_Object, struct image_keyword *, + int, Lisp_Object); +static Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, int *); /* Parse image spec SPEC according to KEYWORDS. A valid image spec @@ -788,11 +755,8 @@ static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ static int -parse_image_spec (spec, keywords, nkeywords, type) - Lisp_Object spec; - struct image_keyword *keywords; - int nkeywords; - Lisp_Object type; +parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, + int nkeywords, Lisp_Object type) { int i; Lisp_Object plist; @@ -928,9 +892,7 @@ parse_image_spec (spec, keywords, nkeywords, type) to 1 if KEY was found in SPEC, set it to 0 otherwise. */ static Lisp_Object -image_spec_value (spec, key, found) - Lisp_Object spec, key; - int *found; +image_spec_value (Lisp_Object spec, Lisp_Object key, int *found) { Lisp_Object tail; @@ -960,8 +922,7 @@ PIXELS non-nil means return the size in pixels, otherwise return the size in canonical character units. FRAME is the frame on which the image will be displayed. FRAME nil or omitted means use the selected frame. */) - (spec, pixels, frame) - Lisp_Object spec, pixels, frame; + (Lisp_Object spec, Lisp_Object pixels, Lisp_Object frame) { Lisp_Object size; @@ -991,8 +952,7 @@ DEFUN ("image-mask-p", Fimage_mask_p, Simage_mask_p, 1, 2, 0, doc: /* Return t if image SPEC has a mask bitmap. FRAME is the frame on which the image will be displayed. FRAME nil or omitted means use the selected frame. */) - (spec, frame) - Lisp_Object spec, frame; + (Lisp_Object spec, Lisp_Object frame) { Lisp_Object mask; @@ -1011,12 +971,11 @@ or omitted means use the selected frame. */) return mask; } -DEFUN ("image-extension-data", Fimage_extension_data, Simage_extension_data, 1, 2, 0, - doc: /* Return extension data for image SPEC. +DEFUN ("image-metadata", Fimage_metadata, Simage_metadata, 1, 2, 0, + doc: /* Return metadata for image SPEC. FRAME is the frame on which the image will be displayed. FRAME nil or omitted means use the selected frame. */) - (spec, frame) - Lisp_Object spec, frame; + (Lisp_Object spec, Lisp_Object frame) { Lisp_Object ext; @@ -1037,9 +996,9 @@ or omitted means use the selected frame. */) Image type independent image structures ***********************************************************************/ -static struct image *make_image P_ ((Lisp_Object spec, unsigned hash)); -static void free_image P_ ((struct frame *f, struct image *img)); -static int check_image_size P_ ((struct frame *f, int width, int height)); +static struct image *make_image (Lisp_Object spec, unsigned hash); +static void free_image (struct frame *f, struct image *img); +static int check_image_size (struct frame *f, int width, int height); #define MAX_IMAGE_SIZE 6.0 Lisp_Object Vmax_image_size; @@ -1048,15 +1007,13 @@ Lisp_Object Vmax_image_size; SPEC. SPEC has a hash value of HASH. */ static struct image * -make_image (spec, hash) - Lisp_Object spec; - unsigned hash; +make_image (Lisp_Object spec, unsigned int hash) { struct image *img = (struct image *) xmalloc (sizeof *img); Lisp_Object file = image_spec_value (spec, QCfile, NULL); xassert (valid_image_p (spec)); - bzero (img, sizeof *img); + memset (img, 0, sizeof *img); img->dependencies = NILP (file) ? Qnil : list1 (file); img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); xassert (img->type != NULL); @@ -1072,9 +1029,7 @@ make_image (spec, hash) /* Free image IMG which was used on frame F, including its resources. */ static void -free_image (f, img) - struct frame *f; - struct image *img; +free_image (struct frame *f, struct image *img) { if (img) { @@ -1105,10 +1060,7 @@ free_image (f, img) otherwise, return 0. */ int -check_image_size (f, width, height) - struct frame *f; - int width; - int height; +check_image_size (struct frame *f, int width, int height) { int w, h; @@ -1139,9 +1091,7 @@ check_image_size (f, width, height) drawing an image. */ void -prepare_image_for_display (f, img) - struct frame *f; - struct image *img; +prepare_image_for_display (struct frame *f, struct image *img) { EMACS_TIME t; @@ -1161,10 +1111,7 @@ prepare_image_for_display (f, img) drawn in face FACE. */ int -image_ascent (img, face, slice) - struct image *img; - struct face *face; - struct glyph_slice *slice; +image_ascent (struct image *img, struct face *face, struct glyph_slice *slice) { int height; int ascent; @@ -1210,10 +1157,8 @@ image_ascent (img, face, slice) On W32, XIMG is assumed to a device context with the bitmap selected. */ static RGB_PIXEL_COLOR -four_corners_best (ximg, corners, width, height) - XImagePtr_or_DC ximg; - int *corners; - unsigned long width, height; +four_corners_best (XImagePtr_or_DC ximg, int *corners, + unsigned long width, unsigned long height) { RGB_PIXEL_COLOR corner_pixels[4], best; int i, best_count; @@ -1263,10 +1208,10 @@ four_corners_best (ximg, corners, width, height) #elif defined (HAVE_NS) #define Destroy_Image(ximg, dummy) \ - ns_release_object(ximg) + ns_release_object (ximg) #define Free_Pixmap(display, pixmap) \ - ns_release_object(pixmap) + ns_release_object (pixmap) #else @@ -1285,10 +1230,7 @@ four_corners_best (ximg, corners, width, height) use for the heuristic. */ RGB_PIXEL_COLOR -image_background (img, f, ximg) - struct image *img; - struct frame *f; - XImagePtr_or_DC ximg; +image_background (struct image *img, struct frame *f, XImagePtr_or_DC ximg) { if (! img->background_valid) /* IMG doesn't have a background yet, try to guess a reasonable value. */ @@ -1327,10 +1269,7 @@ image_background (img, f, ximg) existing XImage object to use for the heuristic. */ int -image_background_transparent (img, f, mask) - struct image *img; - struct frame *f; - XImagePtr_or_DC mask; +image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_DC mask) { if (! img->background_transparent_valid) /* IMG doesn't have a background yet, try to guess a reasonable value. */ @@ -1375,13 +1314,13 @@ image_background_transparent (img, f, mask) Helper functions for X image types ***********************************************************************/ -static void x_clear_image_1 P_ ((struct frame *, struct image *, int, - int, int)); -static void x_clear_image P_ ((struct frame *f, struct image *img)); -static unsigned long x_alloc_image_color P_ ((struct frame *f, - struct image *img, - Lisp_Object color_name, - unsigned long dflt)); +static void x_clear_image_1 (struct frame *, struct image *, int, + int, int); +static void x_clear_image (struct frame *f, struct image *img); +static unsigned long x_alloc_image_color (struct frame *f, + struct image *img, + Lisp_Object color_name, + unsigned long dflt); /* Clear X resources of image IMG on frame F. PIXMAP_P non-zero means @@ -1390,10 +1329,8 @@ static unsigned long x_alloc_image_color P_ ((struct frame *f, the image, if any. */ static void -x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) - struct frame *f; - struct image *img; - int pixmap_p, mask_p, colors_p; +x_clear_image_1 (struct frame *f, struct image *img, int pixmap_p, int mask_p, + int colors_p) { if (pixmap_p && img->pixmap) { @@ -1426,9 +1363,7 @@ x_clear_image_1 (f, img, pixmap_p, mask_p, colors_p) /* Free X resources of image IMG which is used on frame F. */ static void -x_clear_image (f, img) - struct frame *f; - struct image *img; +x_clear_image (struct frame *f, struct image *img) { BLOCK_INPUT; x_clear_image_1 (f, img, 1, 1, 1); @@ -1442,11 +1377,8 @@ x_clear_image (f, img) color. */ static unsigned long -x_alloc_image_color (f, img, color_name, dflt) - struct frame *f; - struct image *img; - Lisp_Object color_name; - unsigned long dflt; +x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object color_name, + unsigned long dflt) { XColor color; unsigned long result; @@ -1476,25 +1408,25 @@ x_alloc_image_color (f, img, color_name, dflt) Image Cache ***********************************************************************/ -static struct image *search_image_cache P_ ((struct frame *, Lisp_Object, unsigned)); -static void cache_image P_ ((struct frame *f, struct image *img)); -static void postprocess_image P_ ((struct frame *, struct image *)); +static struct image *search_image_cache (struct frame *, Lisp_Object, unsigned); +static void cache_image (struct frame *f, struct image *img); +static void postprocess_image (struct frame *, struct image *); /* Return a new, initialized image cache that is allocated from the heap. Call free_image_cache to free an image cache. */ struct image_cache * -make_image_cache () +make_image_cache (void) { struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); int size; - bzero (c, sizeof *c); + memset (c, 0, sizeof *c); c->size = 50; c->images = (struct image **) xmalloc (c->size * sizeof *c->images); size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; c->buckets = (struct image **) xmalloc (size); - bzero (c->buckets, size); + memset (c->buckets, 0, size); return c; } @@ -1502,10 +1434,7 @@ make_image_cache () /* Find an image matching SPEC in the cache, and return it. If no image is found, return NULL. */ static struct image * -search_image_cache (f, spec, hash) - struct frame *f; - Lisp_Object spec; - unsigned hash; +search_image_cache (struct frame *f, Lisp_Object spec, unsigned int hash) { struct image *img; struct image_cache *c = FRAME_IMAGE_CACHE (f); @@ -1538,9 +1467,7 @@ search_image_cache (f, spec, hash) /* Search frame F for an image with spec SPEC, and free it. */ static void -uncache_image (f, spec) - struct frame *f; - Lisp_Object spec; +uncache_image (struct frame *f, Lisp_Object spec) { struct image *img = search_image_cache (f, spec, sxhash (spec, 0)); if (img) @@ -1552,8 +1479,7 @@ uncache_image (f, spec) caches. */ void -free_image_cache (f) - struct frame *f; +free_image_cache (struct frame *f) { struct image_cache *c = FRAME_IMAGE_CACHE (f); if (c) @@ -1586,29 +1512,56 @@ clear_image_cache (struct frame *f, Lisp_Object filter) { struct image_cache *c = FRAME_IMAGE_CACHE (f); - if (c && (!NILP (filter) || INTEGERP (Vimage_cache_eviction_delay))) + if (c) { - EMACS_TIME t; - unsigned long old; - int i, nfreed; - - EMACS_GET_TIME (t); - old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); + int i, nfreed = 0; /* Block input so that we won't be interrupted by a SIGIO while being in an inconsistent state. */ BLOCK_INPUT; - for (i = nfreed = 0; i < c->used; ++i) + if (!NILP (filter)) { - struct image *img = c->images[i]; - if (img != NULL - && (NILP (filter) ? img->timestamp < old - : (EQ (Qt, filter) - || !NILP (Fmember (filter, img->dependencies))))) + /* Filter image cache. */ + for (i = 0; i < c->used; ++i) { - free_image (f, img); - ++nfreed; + struct image *img = c->images[i]; + if (img && (EQ (Qt, filter) + || !NILP (Fmember (filter, img->dependencies)))) + { + free_image (f, img); + ++nfreed; + } + } + } + else if (INTEGERP (Vimage_cache_eviction_delay)) + { + /* Free cache based on timestamp. */ + EMACS_TIME t; + unsigned long old; + int delay, nimages = 0; + + for (i = 0; i < c->used; ++i) + if (c->images[i]) + nimages++; + + /* If the number of cached images has grown unusually large, + decrease the cache eviction delay (Bug#6230). */ + delay = XFASTINT (Vimage_cache_eviction_delay); + if (nimages > 40) + delay = max (1, 1600 * delay / (nimages*nimages)); + + EMACS_GET_TIME (t); + old = EMACS_SECS (t) - delay; + + for (i = 0; i < c->used; ++i) + { + struct image *img = c->images[i]; + if (img && img->timestamp < old) + { + free_image (f, img); + ++nfreed; + } } } @@ -1654,8 +1607,7 @@ FILTER nil or a frame means clear all images in the selected frame. FILTER t means clear the image caches of all frames. Anything else, means only clear those images which refer to FILTER, which is then usually a filename. */) - (filter) - Lisp_Object filter; + (Lisp_Object filter) { if (!(EQ (filter, Qnil) || FRAMEP (filter))) clear_image_caches (filter); @@ -1666,15 +1618,16 @@ which is then usually a filename. */) } -DEFUN ("image-refresh", Fimage_refresh, Simage_refresh, +DEFUN ("image-flush", Fimage_flush, Simage_flush, 1, 2, 0, - doc: /* Refresh the image with specification SPEC on frame FRAME. -If SPEC specifies an image file, the displayed image is updated with -the current contents of that file. + doc: /* Fush the image with specification SPEC on frame FRAME. +This removes the image from the Emacs image cache. If SPEC specifies +an image file, the next redisplay of this image will read from the +current contents of that file. + FRAME nil or omitted means use the selected frame. FRAME t means refresh the image on all frames. */) - (spec, frame) - Lisp_Object spec, frame; + (Lisp_Object spec, Lisp_Object frame) { if (!valid_image_p (spec)) error ("Invalid image specification"); @@ -1700,9 +1653,7 @@ FRAME t means refresh the image on all frames. */) by the image's specification, */ static void -postprocess_image (f, img) - struct frame *f; - struct image *img; +postprocess_image (struct frame *f, struct image *img) { /* Manipulation of the image's mask. */ if (img->pixmap) @@ -1775,14 +1726,11 @@ postprocess_image (f, img) SPEC must be a valid Lisp image specification (see valid_image_p). */ int -lookup_image (f, spec) - struct frame *f; - Lisp_Object spec; +lookup_image (struct frame *f, Lisp_Object spec) { struct image_cache *c; struct image *img; unsigned hash; - struct gcpro gcpro1; EMACS_TIME now; /* F must be a window-system frame, and SPEC must be a valid image @@ -1792,8 +1740,6 @@ lookup_image (f, spec) c = FRAME_IMAGE_CACHE (f); - GCPRO1 (spec); - /* Look up SPEC in the hash table of the image cache. */ hash = sxhash (spec, 0); img = search_image_cache (f, spec, hash); @@ -1806,8 +1752,6 @@ lookup_image (f, spec) /* If not found, create a new image and cache it. */ if (img == NULL) { - extern Lisp_Object Qpostscript; - BLOCK_INPUT; img = make_image (spec, hash); cache_image (f, img); @@ -1887,8 +1831,6 @@ lookup_image (f, spec) EMACS_GET_TIME (now); img->timestamp = EMACS_SECS (now); - UNGCPRO; - /* Value is the image id. */ return img->id; } @@ -1897,9 +1839,7 @@ lookup_image (f, spec) /* Cache image IMG in the image cache of frame F. */ static void -cache_image (f, img) - struct frame *f; - struct image *img; +cache_image (struct frame *f, struct image *img) { struct image_cache *c = FRAME_IMAGE_CACHE (f); int i; @@ -1939,8 +1879,7 @@ cache_image (f, img) /* Mark Lisp objects in image IMG. */ static void -mark_image (img) - struct image *img; +mark_image (struct image *img) { mark_object (img->spec); mark_object (img->dependencies); @@ -1971,7 +1910,7 @@ mark_image_cache (struct image_cache *c) #ifdef HAVE_NTGUI /* Macro for defining functions that will be loaded from image DLLs. */ -#define DEF_IMGLIB_FN(func) int (FAR CDECL *fn_##func)() +#define DEF_IMGLIB_FN(func,args) int (FAR CDECL *fn_##func)args /* Macro for loading those image functions from the library. */ #define LOAD_IMGLIB_FN(lib,func) { \ @@ -1980,10 +1919,11 @@ mark_image_cache (struct image_cache *c) } /* Load a DLL implementing an image type. - The `image-library-alist' variable associates a symbol, - identifying an image type, to a list of possible filenames. + The argument LIBRARIES is usually the variable + `dynamic-library-alist', which associates a symbol, identifying + an external DLL library, to a list of possible filenames. The function returns NULL if no library could be loaded for - the given image type, or if the library was previously loaded; + the given symbol, or if the library was previously loaded; else the handle of the DLL. */ static HMODULE w32_delayed_load (Lisp_Object libraries, Lisp_Object type) @@ -2008,10 +1948,10 @@ w32_delayed_load (Lisp_Object libraries, Lisp_Object type) #endif /* HAVE_NTGUI */ -static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, - XImagePtr *, Pixmap *)); -static void x_destroy_x_image P_ ((XImagePtr)); -static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int)); +static int x_create_x_image_and_pixmap (struct frame *, int, int, int, + XImagePtr *, Pixmap *); +static void x_destroy_x_image (XImagePtr); +static void x_put_x_image (struct frame *, XImagePtr, Pixmap, int, int); /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on @@ -2024,11 +1964,8 @@ static void x_put_x_image P_ ((struct frame *, XImagePtr, Pixmap, int, int)); should indicate the bit depth of the image. */ static int -x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) - struct frame *f; - int width, height, depth; - XImagePtr *ximg; - Pixmap *pixmap; +x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, + XImagePtr *ximg, Pixmap *pixmap) { #ifdef HAVE_X_WINDOWS Display *display = FRAME_X_DISPLAY (f); @@ -2100,8 +2037,8 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) return 0; } - header = &((*ximg)->info.bmiHeader); - bzero (&((*ximg)->info), sizeof (BITMAPINFO)); + header = &(*ximg)->info.bmiHeader; + memset (&(*ximg)->info, 0, sizeof (BITMAPINFO)); header->biSize = sizeof (*header); header->biWidth = width; header->biHeight = -height; /* negative indicates a top-down bitmap. */ @@ -2151,7 +2088,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) #endif /* HAVE_NTGUI */ #ifdef HAVE_NS - *pixmap = ns_image_for_XPM(width, height, depth); + *pixmap = ns_image_for_XPM (width, height, depth); if (*pixmap == 0) { *ximg = NULL; @@ -2167,8 +2104,7 @@ x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap) /* Destroy XImage XIMG. Free XIMG->data. */ static void -x_destroy_x_image (ximg) - XImagePtr ximg; +x_destroy_x_image (XImagePtr ximg) { xassert (interrupt_input_blocked); if (ximg) @@ -2184,7 +2120,7 @@ x_destroy_x_image (ximg) xfree (ximg); #endif /* HAVE_NTGUI */ #ifdef HAVE_NS - ns_release_object(ximg); + ns_release_object (ximg); #endif /* HAVE_NS */ } } @@ -2194,11 +2130,7 @@ x_destroy_x_image (ximg) are width and height of both the image and pixmap. */ static void -x_put_x_image (f, ximg, pixmap, width, height) - struct frame *f; - XImagePtr ximg; - Pixmap pixmap; - int width, height; +x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int height) { #ifdef HAVE_X_WINDOWS GC gc; @@ -2219,7 +2151,7 @@ x_put_x_image (f, ximg, pixmap, width, height) #ifdef HAVE_NS xassert (ximg == pixmap); - ns_retain_object(ximg); + ns_retain_object (ximg); #endif } @@ -2228,7 +2160,7 @@ x_put_x_image (f, ximg, pixmap, width, height) File Handling ***********************************************************************/ -static unsigned char *slurp_file P_ ((char *, int *)); +static unsigned char *slurp_file (char *, int *); /* Find image file FILE. Look in data-directory/images, then @@ -2236,20 +2168,16 @@ static unsigned char *slurp_file P_ ((char *, int *)); found, or nil if not found. */ Lisp_Object -x_find_image_file (file) - Lisp_Object file; +x_find_image_file (Lisp_Object file) { Lisp_Object file_found, search_path; - struct gcpro gcpro1, gcpro2; int fd; - file_found = Qnil; /* TODO I think this should use something like image-load-path instead. Unfortunately, that can contain non-string elements. */ search_path = Fcons (Fexpand_file_name (build_string ("images"), Vdata_directory), Vx_bitmap_file_path); - GCPRO2 (file_found, search_path); /* Try to find FILE in data-directory/images, then x-bitmap-file-path. */ fd = openp (search_path, file, Qnil, &file_found, Qnil); @@ -2262,7 +2190,6 @@ x_find_image_file (file) close (fd); } - UNGCPRO; return file_found; } @@ -2272,9 +2199,7 @@ x_find_image_file (file) occurred. *SIZE is set to the size of the file. */ static unsigned char * -slurp_file (file, size) - char *file; - int *size; +slurp_file (char *file, int *size) { FILE *fp = NULL; unsigned char *buf = NULL; @@ -2308,15 +2233,15 @@ slurp_file (file, size) XBM images ***********************************************************************/ -static int xbm_scan P_ ((unsigned char **, unsigned char *, char *, int *)); -static int xbm_load P_ ((struct frame *f, struct image *img)); -static int xbm_load_image P_ ((struct frame *f, struct image *img, - unsigned char *, unsigned char *)); -static int xbm_image_p P_ ((Lisp_Object object)); -static int xbm_read_bitmap_data P_ ((struct frame *f, - unsigned char *, unsigned char *, - int *, int *, unsigned char **, int)); -static int xbm_file_p P_ ((Lisp_Object)); +static int xbm_scan (unsigned char **, unsigned char *, char *, int *); +static int xbm_load (struct frame *f, struct image *img); +static int xbm_load_image (struct frame *f, struct image *img, + unsigned char *, unsigned char *); +static int xbm_image_p (Lisp_Object object); +static int xbm_read_bitmap_data (struct frame *f, + unsigned char *, unsigned char *, + int *, int *, unsigned char **, int); +static int xbm_file_p (Lisp_Object); /* Indices of image specification fields in xbm_format, below. */ @@ -2409,12 +2334,11 @@ enum xbm_token displayed is used. */ static int -xbm_image_p (object) - Lisp_Object object; +xbm_image_p (Lisp_Object object) { struct image_keyword kw[XBM_LAST]; - bcopy (xbm_format, kw, sizeof kw); + memcpy (kw, xbm_format, sizeof kw); if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) return 0; @@ -2503,10 +2427,7 @@ xbm_image_p (object) scanning a number, store its value in *IVAL. */ static int -xbm_scan (s, end, sval, ival) - unsigned char **s, *end; - char *sval; - int *ival; +xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) { unsigned int c; @@ -2607,7 +2528,7 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data) w1 = (width + 7) / 8; /* nb of 8bits elt in X bitmap */ w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */ bits = (unsigned char *) alloca (height * w2); - bzero (bits, height * w2); + memset (bits, 0, height * w2); for (i = 0; i < height; i++) { p = bits + i*w2; @@ -2625,10 +2546,8 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data) } static void -convert_mono_to_color_image (f, img, foreground, background) - struct frame *f; - struct image *img; - COLORREF foreground, background; +convert_mono_to_color_image (struct frame *f, struct image *img, + COLORREF foreground, COLORREF background) { HDC hdc, old_img_dc, new_img_dc; HGDIOBJ old_prev, new_prev; @@ -2670,12 +2589,9 @@ convert_mono_to_color_image (f, img, foreground, background) static void -Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) - struct frame *f; - struct image *img; - char *data; - RGB_PIXEL_COLOR fg, bg; - int non_default_colors; +Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, + RGB_PIXEL_COLOR fg, RGB_PIXEL_COLOR bg, + int non_default_colors) { #ifdef HAVE_NTGUI img->pixmap @@ -2686,7 +2602,7 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) convert_mono_to_color_image (f, img, fg, bg); #elif defined (HAVE_NS) - img->pixmap = ns_image_from_XBM(data, img->width, img->height); + img->pixmap = ns_image_from_XBM (data, img->width, img->height); #else img->pixmap @@ -2711,12 +2627,9 @@ Create_Pixmap_From_Bitmap_Data (f, img, data, fg, bg, non_default_colors) invalid (the bitmap remains unread). */ static int -xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error) - struct frame *f; - unsigned char *contents, *end; - int *width, *height; - unsigned char **data; - int inhibit_image_error; +xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end, + int *width, int *height, unsigned char **data, + int inhibit_image_error) { unsigned char *s = contents; char buffer[BUFSIZ]; @@ -2865,10 +2778,8 @@ xbm_read_bitmap_data (f, contents, end, width, height, data, inhibit_image_error successful. */ static int -xbm_load_image (f, img, contents, end) - struct frame *f; - struct image *img; - unsigned char *contents, *end; +xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, + unsigned char *end) { int rc; unsigned char *data; @@ -2924,8 +2835,7 @@ xbm_load_image (f, img, contents, end) /* Value is non-zero if DATA looks like an in-memory XBM file. */ static int -xbm_file_p (data) - Lisp_Object data; +xbm_file_p (Lisp_Object data) { int w, h; return (STRINGP (data) @@ -2939,9 +2849,7 @@ xbm_file_p (data) non-zero if successful. */ static int -xbm_load (f, img) - struct frame *f; - struct image *img; +xbm_load (struct frame *f, struct image *img) { int success_p = 0; Lisp_Object file_name; @@ -2955,14 +2863,11 @@ xbm_load (f, img) Lisp_Object file; unsigned char *contents; int size; - struct gcpro gcpro1; file = x_find_image_file (file_name); - GCPRO1 (file); if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", file_name, Qnil); - UNGCPRO; return 0; } @@ -2970,12 +2875,10 @@ xbm_load (f, img) if (contents == NULL) { image_error ("Error loading XBM image `%s'", img->spec, Qnil); - UNGCPRO; return 0; } success_p = xbm_load_image (f, img, contents, contents + size); - UNGCPRO; } else { @@ -2993,7 +2896,7 @@ xbm_load (f, img) in_memory_file_p = xbm_file_p (data); /* Parse the image specification. */ - bcopy (xbm_format, fmt, sizeof fmt); + memcpy (fmt, xbm_format, sizeof fmt); parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); xassert (parsed_p); @@ -3039,9 +2942,9 @@ xbm_load (f, img) { Lisp_Object line = XVECTOR (data)->contents[i]; if (STRINGP (line)) - bcopy (SDATA (line), p, nbytes); + memcpy (p, SDATA (line), nbytes); else - bcopy (XBOOL_VECTOR (line)->data, p, nbytes); + memcpy (p, XBOOL_VECTOR (line)->data, nbytes); } } else if (STRINGP (data)) @@ -3057,7 +2960,7 @@ xbm_load (f, img) invertedBits = bits; nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * img->height; - bits = (char *) alloca(nbytes); + bits = (char *) alloca (nbytes); for (i = 0; i < nbytes; i++) bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); } @@ -3089,9 +2992,9 @@ xbm_load (f, img) #if defined (HAVE_XPM) || defined (HAVE_NS) -static int xpm_image_p P_ ((Lisp_Object object)); -static int xpm_load P_ ((struct frame *f, struct image *img)); -static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); +static int xpm_image_p (Lisp_Object object); +static int xpm_load (struct frame *f, struct image *img); +static int xpm_valid_color_symbols_p (Lisp_Object); #endif /* HAVE_XPM || HAVE_NS */ @@ -3182,12 +3085,12 @@ static struct image_type xpm_type = #ifdef ALLOC_XPM_COLORS -static void xpm_init_color_cache P_ ((struct frame *, XpmAttributes *)); -static void xpm_free_color_cache P_ ((void)); -static int xpm_lookup_color P_ ((struct frame *, char *, XColor *)); -static int xpm_color_bucket P_ ((char *)); -static struct xpm_cached_color *xpm_cache_color P_ ((struct frame *, char *, - XColor *, int)); +static void xpm_init_color_cache (struct frame *, XpmAttributes *); +static void xpm_free_color_cache (void); +static int xpm_lookup_color (struct frame *, char *, XColor *); +static int xpm_color_bucket (char *); +static struct xpm_cached_color *xpm_cache_color (struct frame *, char *, + XColor *, int); /* An entry in a hash table used to cache color definitions of named colors. This cache is necessary to speed up XPM image loading in @@ -3215,9 +3118,7 @@ struct xpm_cached_color **xpm_color_cache; /* Initialize the color cache. */ static void -xpm_init_color_cache (f, attrs) - struct frame *f; - XpmAttributes *attrs; +xpm_init_color_cache (struct frame *f, XpmAttributes *attrs) { size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache; xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes); @@ -3243,7 +3144,7 @@ xpm_init_color_cache (f, attrs) /* Free the color cache. */ static void -xpm_free_color_cache () +xpm_free_color_cache (void) { struct xpm_cached_color *p, *next; int i; @@ -3264,8 +3165,7 @@ xpm_free_color_cache () cache. */ static int -xpm_color_bucket (color_name) - char *color_name; +xpm_color_bucket (char *color_name) { unsigned h = 0; char *s; @@ -3281,11 +3181,7 @@ xpm_color_bucket (color_name) entry added. */ static struct xpm_cached_color * -xpm_cache_color (f, color_name, color, bucket) - struct frame *f; - char *color_name; - XColor *color; - int bucket; +xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket) { size_t nbytes; struct xpm_cached_color *p; @@ -3308,10 +3204,7 @@ xpm_cache_color (f, color_name, color, bucket) allocation failed. */ static int -xpm_lookup_color (f, color_name, color) - struct frame *f; - char *color_name; - XColor *color; +xpm_lookup_color (struct frame *f, char *color_name, XColor *color) { struct xpm_cached_color *p; int h = xpm_color_bucket (color_name); @@ -3333,7 +3226,7 @@ xpm_lookup_color (f, color_name, color) with transparency, and it's useful. */ else if (strcmp ("opaque", color_name) == 0) { - bzero (color, sizeof (XColor)); /* Is this necessary/correct? */ + memset (color, 0, sizeof (XColor)); /* Is this necessary/correct? */ color->pixel = FRAME_FOREGROUND_PIXEL (f); p = xpm_cache_color (f, color_name, color, h); } @@ -3348,12 +3241,8 @@ xpm_lookup_color (f, color_name, color) if successful. */ static int -xpm_alloc_color (dpy, cmap, color_name, color, closure) - Display *dpy; - Colormap cmap; - char *color_name; - XColor *color; - void *closure; +xpm_alloc_color (Display *dpy, Colormap cmap, char *color_name, XColor *color, + void *closure) { return xpm_lookup_color ((struct frame *) closure, color_name, color); } @@ -3364,12 +3253,7 @@ xpm_alloc_color (dpy, cmap, color_name, color, closure) non-zero if successful. */ static int -xpm_free_colors (dpy, cmap, pixels, npixels, closure) - Display *dpy; - Colormap cmap; - Pixel *pixels; - int npixels; - void *closure; +xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *closure) { return 1; } @@ -3381,10 +3265,12 @@ xpm_free_colors (dpy, cmap, pixels, npixels, closure) /* XPM library details. */ -DEF_IMGLIB_FN (XpmFreeAttributes); -DEF_IMGLIB_FN (XpmCreateImageFromBuffer); -DEF_IMGLIB_FN (XpmReadFileToImage); -DEF_IMGLIB_FN (XImageFree); +DEF_IMGLIB_FN (XpmFreeAttributes, (XpmAttributes *)); +DEF_IMGLIB_FN (XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, + xpm_XImage **, XpmAttributes *)); +DEF_IMGLIB_FN (XpmReadFileToImage, (Display *, char *, xpm_XImage **, + xpm_XImage **, XpmAttributes *)); +DEF_IMGLIB_FN (XImageFree, (xpm_XImage *)); static int init_xpm_functions (Lisp_Object libraries) @@ -3409,8 +3295,7 @@ init_xpm_functions (Lisp_Object libraries) cdr are strings. */ static int -xpm_valid_color_symbols_p (color_symbols) - Lisp_Object color_symbols; +xpm_valid_color_symbols_p (Lisp_Object color_symbols) { while (CONSP (color_symbols)) { @@ -3429,11 +3314,10 @@ xpm_valid_color_symbols_p (color_symbols) /* Value is non-zero if OBJECT is a valid XPM image specification. */ static int -xpm_image_p (object) - Lisp_Object object; +xpm_image_p (Lisp_Object object) { struct image_keyword fmt[XPM_LAST]; - bcopy (xpm_format, fmt, sizeof fmt); + memcpy (fmt, xpm_format, sizeof fmt); return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) /* Either `:file' or `:data' must be present. */ && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 @@ -3447,16 +3331,14 @@ xpm_image_p (object) #if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) int -x_create_bitmap_from_xpm_data (f, bits) - struct frame *f; - char **bits; +x_create_bitmap_from_xpm_data (struct frame *f, char **bits) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); int id, rc; XpmAttributes attrs; Pixmap bitmap, mask; - bzero (&attrs, sizeof attrs); + memset (&attrs, 0, sizeof attrs); attrs.visual = FRAME_X_VISUAL (f); attrs.colormap = FRAME_X_COLORMAP (f); @@ -3492,9 +3374,7 @@ x_create_bitmap_from_xpm_data (f, bits) #ifdef HAVE_XPM static int -xpm_load (f, img) - struct frame *f; - struct image *img; +xpm_load (struct frame *f, struct image *img) { int rc; XpmAttributes attrs; @@ -3506,7 +3386,7 @@ xpm_load (f, img) /* Configure the XPM lib. Use the visual of frame F. Allocate close colors. Return colors allocated. */ - bzero (&attrs, sizeof attrs); + memset (&attrs, 0, sizeof attrs); #ifndef HAVE_NTGUI attrs.visual = FRAME_X_VISUAL (f); @@ -3553,7 +3433,7 @@ xpm_load (f, img) /* Allocate an XpmColorSymbol array. */ size = attrs.numsymbols * sizeof *xpm_syms; xpm_syms = (XpmColorSymbol *) alloca (size); - bzero (xpm_syms, size); + memset (xpm_syms, 0, size); attrs.colorsymbols = xpm_syms; /* Fill the color symbol array. */ @@ -3561,12 +3441,31 @@ xpm_load (f, img) CONSP (tail); ++i, tail = XCDR (tail)) { - Lisp_Object name = XCAR (XCAR (tail)); - Lisp_Object color = XCDR (XCAR (tail)); - xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1); - strcpy (xpm_syms[i].name, SDATA (name)); - xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); - strcpy (xpm_syms[i].value, SDATA (color)); + Lisp_Object name; + Lisp_Object color; + + if (!CONSP (XCAR (tail))) + { + xpm_syms[i].name = ""; + xpm_syms[i].value = ""; + continue; + } + name = XCAR (XCAR (tail)); + color = XCDR (XCAR (tail)); + if (STRINGP (name)) + { + xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1); + strcpy (xpm_syms[i].name, SDATA (name)); + } + else + xpm_syms[i].name = ""; + if (STRINGP (color)) + { + xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); + strcpy (xpm_syms[i].value, SDATA (color)); + } + else + xpm_syms[i].value = ""; } } @@ -3592,6 +3491,9 @@ xpm_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); +#ifdef ALLOC_XPM_COLORS + xpm_free_color_cache (); +#endif return 0; } @@ -3610,6 +3512,14 @@ xpm_load (f, img) else { Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); + if (!STRINGP (buffer)) + { + image_error ("Invalid image data `%s'", buffer, Qnil); +#ifdef ALLOC_XPM_COLORS + xpm_free_color_cache (); +#endif + return 0; + } #ifdef HAVE_NTGUI /* XpmCreatePixmapFromBuffer is not available in the Windows port of libxpm. But XpmCreateImageFromBuffer almost does what we want. */ @@ -3727,25 +3637,25 @@ xpm_load (f, img) /* XPM support functions for NS where libxpm is not available. Only XPM version 3 (without any extensions) is supported. */ -static int xpm_scan P_ ((const unsigned char **, const unsigned char *, - const unsigned char **, int *)); +static int xpm_scan (const unsigned char **, const unsigned char *, + const unsigned char **, int *); static Lisp_Object xpm_make_color_table_v - P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), - Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); -static void xpm_put_color_table_v P_ ((Lisp_Object, const unsigned char *, - int, Lisp_Object)); -static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object, - const unsigned char *, int)); + (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), + Lisp_Object (**) (Lisp_Object, const unsigned char *, int)); +static void xpm_put_color_table_v (Lisp_Object, const unsigned char *, + int, Lisp_Object); +static Lisp_Object xpm_get_color_table_v (Lisp_Object, + const unsigned char *, int); static Lisp_Object xpm_make_color_table_h - P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), - Lisp_Object (**) (Lisp_Object, const unsigned char *, int))); -static void xpm_put_color_table_h P_ ((Lisp_Object, const unsigned char *, - int, Lisp_Object)); -static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object, - const unsigned char *, int)); -static int xpm_str_to_color_key P_ ((const char *)); -static int xpm_load_image P_ ((struct frame *, struct image *, - const unsigned char *, const unsigned char *)); + (void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object), + Lisp_Object (**) (Lisp_Object, const unsigned char *, int)); +static void xpm_put_color_table_h (Lisp_Object, const unsigned char *, + int, Lisp_Object); +static Lisp_Object xpm_get_color_table_h (Lisp_Object, + const unsigned char *, int); +static int xpm_str_to_color_key (const char *); +static int xpm_load_image (struct frame *, struct image *, + const unsigned char *, const unsigned char *); /* Tokens returned from xpm_scan. */ @@ -3764,9 +3674,10 @@ enum xpm_token length of the corresponding token, respectively. */ static int -xpm_scan (s, end, beg, len) - const unsigned char **s, *end, **beg; - int *len; +xpm_scan (const unsigned char **s, + const unsigned char *end, + const unsigned char **beg, + int *len) { int c; @@ -3830,9 +3741,13 @@ xpm_scan (s, end, beg, len) hash table is used. */ static Lisp_Object -xpm_make_color_table_v (put_func, get_func) - void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); - Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); +xpm_make_color_table_v (void (**put_func) (Lisp_Object, + const unsigned char *, + int, + Lisp_Object), + Lisp_Object (**get_func) (Lisp_Object, + const unsigned char *, + int)) { *put_func = xpm_put_color_table_v; *get_func = xpm_get_color_table_v; @@ -3840,28 +3755,30 @@ xpm_make_color_table_v (put_func, get_func) } static void -xpm_put_color_table_v (color_table, chars_start, chars_len, color) - Lisp_Object color_table; - const unsigned char *chars_start; - int chars_len; - Lisp_Object color; +xpm_put_color_table_v (Lisp_Object color_table, + const unsigned char *chars_start, + int chars_len, + Lisp_Object color) { XVECTOR (color_table)->contents[*chars_start] = color; } static Lisp_Object -xpm_get_color_table_v (color_table, chars_start, chars_len) - Lisp_Object color_table; - const unsigned char *chars_start; - int chars_len; +xpm_get_color_table_v (Lisp_Object color_table, + const unsigned char *chars_start, + int chars_len) { return XVECTOR (color_table)->contents[*chars_start]; } static Lisp_Object -xpm_make_color_table_h (put_func, get_func) - void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object); - Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int); +xpm_make_color_table_h (void (**put_func) (Lisp_Object, + const unsigned char *, + int, + Lisp_Object), + Lisp_Object (**get_func) (Lisp_Object, + const unsigned char *, + int)) { *put_func = xpm_put_color_table_h; *get_func = xpm_get_color_table_h; @@ -3872,11 +3789,10 @@ xpm_make_color_table_h (put_func, get_func) } static void -xpm_put_color_table_h (color_table, chars_start, chars_len, color) - Lisp_Object color_table; - const unsigned char *chars_start; - int chars_len; - Lisp_Object color; +xpm_put_color_table_h (Lisp_Object color_table, + const unsigned char *chars_start, + int chars_len, + Lisp_Object color) { struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); unsigned hash_code; @@ -3887,10 +3803,9 @@ xpm_put_color_table_h (color_table, chars_start, chars_len, color) } static Lisp_Object -xpm_get_color_table_h (color_table, chars_start, chars_len) - Lisp_Object color_table; - const unsigned char *chars_start; - int chars_len; +xpm_get_color_table_h (Lisp_Object color_table, + const unsigned char *chars_start, + int chars_len) { struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len), @@ -3910,8 +3825,7 @@ enum xpm_color_key { static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"}; static int -xpm_str_to_color_key (s) - const char *s; +xpm_str_to_color_key (const char *s) { int i; @@ -3924,10 +3838,10 @@ xpm_str_to_color_key (s) } static int -xpm_load_image (f, img, contents, end) - struct frame *f; - struct image *img; - const unsigned char *contents, *end; +xpm_load_image (struct frame *f, + struct image *img, + const unsigned char *contents, + const unsigned char *end) { const unsigned char *s = contents, *beg, *str; unsigned char buffer[BUFSIZ]; @@ -3959,7 +3873,7 @@ xpm_load_image (f, img, contents, end) if (!(end - s >= 9 && memcmp (s, "/* XPM */", 9) == 0)) goto failure; s += 9; - match(); + match (); expect_ident ("static"); expect_ident ("char"); expect ('*'); @@ -4109,8 +4023,8 @@ xpm_load_image (f, img, contents, end) (!EQ (color_val, Qt) ? PIX_MASK_DRAW : (have_mask = 1, PIX_MASK_RETAIN))); #else - if (EQ(color_val, Qt)) - ns_set_alpha(ximg, x, y, 0); + if (EQ (color_val, Qt)) + ns_set_alpha (ximg, x, y, 0); #endif } if (y + 1 < height) @@ -4159,9 +4073,8 @@ xpm_load_image (f, img, contents, end) } static int -xpm_load (f, img) - struct frame *f; - struct image *img; +xpm_load (struct frame *f, + struct image *img) { int success_p = 0; Lisp_Object file_name; @@ -4173,14 +4086,11 @@ xpm_load (f, img) Lisp_Object file; unsigned char *contents; int size; - struct gcpro gcpro1; file = x_find_image_file (file_name); - GCPRO1 (file); if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", file_name, Qnil); - UNGCPRO; return 0; } @@ -4188,19 +4098,22 @@ xpm_load (f, img) if (contents == NULL) { image_error ("Error loading XPM image `%s'", img->spec, Qnil); - UNGCPRO; return 0; } success_p = xpm_load_image (f, img, contents, contents + size); xfree (contents); - UNGCPRO; } else { Lisp_Object data; data = image_spec_value (img->spec, QCdata, NULL); + if (!STRINGP (data)) + { + image_error ("Invalid image data `%s'", data, Qnil); + return 0; + } success_p = xpm_load_image (f, img, SDATA (data), SDATA (data) + SBYTES (data)); } @@ -4248,11 +4161,11 @@ int ct_colors_allocated; /* Initialize the color table. */ static void -init_color_table () +init_color_table (void) { int size = CT_SIZE * sizeof (*ct_table); ct_table = (struct ct_color **) xmalloc (size); - bzero (ct_table, size); + memset (ct_table, 0, size); ct_colors_allocated = 0; } @@ -4260,7 +4173,7 @@ init_color_table () /* Free memory associated with the color table. */ static void -free_color_table () +free_color_table (void) { int i; struct ct_color *p, *next; @@ -4283,9 +4196,7 @@ free_color_table () G, B, and make an entry in the color table. */ static unsigned long -lookup_rgb_color (f, r, g, b) - struct frame *f; - int r, g, b; +lookup_rgb_color (struct frame *f, int r, int g, int b) { unsigned hash = CT_HASH_RGB (r, g, b); int i = hash % CT_SIZE; @@ -4380,9 +4291,7 @@ lookup_rgb_color (f, r, g, b) table. If not already present, allocate it. Value is PIXEL. */ static unsigned long -lookup_pixel_color (f, pixel) - struct frame *f; - unsigned long pixel; +lookup_pixel_color (struct frame *f, unsigned long pixel) { int i = pixel % CT_SIZE; struct ct_color *p; @@ -4434,8 +4343,7 @@ lookup_pixel_color (f, pixel) allocated via xmalloc. Set *N to the number of colors. */ static unsigned long * -colors_in_color_table (n) - int *n; +colors_in_color_table (int *n) { int i, j; struct ct_color *p; @@ -4463,9 +4371,7 @@ colors_in_color_table (n) #else /* COLOR_TABLE_SUPPORT */ static unsigned long -lookup_rgb_color (f, r, g, b) - struct frame *f; - int r, g, b; +lookup_rgb_color (struct frame *f, int r, int g, int b) { unsigned long pixel; @@ -4480,7 +4386,7 @@ lookup_rgb_color (f, r, g, b) } static void -init_color_table () +init_color_table (void) { } #endif /* COLOR_TABLE_SUPPORT */ @@ -4490,9 +4396,9 @@ init_color_table () Algorithms ***********************************************************************/ -static XColor *x_to_xcolors P_ ((struct frame *, struct image *, int)); -static void x_from_xcolors P_ ((struct frame *, struct image *, XColor *)); -static void x_detect_edges P_ ((struct frame *, struct image *, int[9], int)); +static XColor *x_to_xcolors (struct frame *, struct image *, int); +static void x_from_xcolors (struct frame *, struct image *, XColor *); +static void x_detect_edges (struct frame *, struct image *, int[9], int); #ifdef HAVE_NTGUI static void XPutPixel (XImagePtr , int, int, COLORREF); @@ -4533,10 +4439,7 @@ static int laplace_matrix[9] = { allocated with xmalloc; it must be freed by the caller. */ static XColor * -x_to_xcolors (f, img, rgb_p) - struct frame *f; - struct image *img; - int rgb_p; +x_to_xcolors (struct frame *f, struct image *img, int rgb_p) { int x, y; XColor *colors, *p; @@ -4601,10 +4504,7 @@ x_to_xcolors (f, img, rgb_p) stored in ximg->data. */ static void -XPutPixel (ximg, x, y, color) - XImagePtr ximg; - int x, y; - COLORREF color; +XPutPixel (XImagePtr ximg, int x, int y, COLORREF color) { int width = ximg->info.bmiHeader.biWidth; int height = ximg->info.bmiHeader.biHeight; @@ -4649,10 +4549,7 @@ XPutPixel (ximg, x, y, color) COLORS will be freed; an existing IMG->pixmap will be freed, too. */ static void -x_from_xcolors (f, img, colors) - struct frame *f; - struct image *img; - XColor *colors; +x_from_xcolors (struct frame *f, struct image *img, XColor *colors) { int x, y; XImagePtr oimg = NULL; @@ -4694,10 +4591,7 @@ x_from_xcolors (f, img, colors) outgoing image. */ static void -x_detect_edges (f, img, matrix, color_adjust) - struct frame *f; - struct image *img; - int matrix[9], color_adjust; +x_detect_edges (struct frame *f, struct image *img, int *matrix, int color_adjust) { XColor *colors = x_to_xcolors (f, img, 1); XColor *new, *p; @@ -4763,9 +4657,7 @@ x_detect_edges (f, img, matrix, color_adjust) on frame F. */ static void -x_emboss (f, img) - struct frame *f; - struct image *img; +x_emboss (struct frame *f, struct image *img) { x_detect_edges (f, img, emboss_matrix, 0xffff / 2); } @@ -4776,9 +4668,7 @@ x_emboss (f, img) to draw disabled buttons, for example. */ static void -x_laplace (f, img) - struct frame *f; - struct image *img; +x_laplace (struct frame *f, struct image *img) { x_detect_edges (f, img, laplace_matrix, 45000); } @@ -4796,10 +4686,8 @@ x_laplace (f, img) number. */ static void -x_edge_detection (f, img, matrix, color_adjust) - struct frame *f; - struct image *img; - Lisp_Object matrix, color_adjust; +x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix, + Lisp_Object color_adjust) { int i = 0; int trans[9]; @@ -4828,9 +4716,7 @@ x_edge_detection (f, img, matrix, color_adjust) /* Transform image IMG on frame F so that it looks disabled. */ static void -x_disable_image (f, img) - struct frame *f; - struct image *img; +x_disable_image (struct frame *f, struct image *img) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); #ifdef HAVE_NTGUI @@ -4932,10 +4818,7 @@ x_disable_image (f, img) heuristically. Value is non-zero if successful. */ static int -x_build_heuristic_mask (f, img, how) - struct frame *f; - struct image *img; - Lisp_Object how; +x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) { XImagePtr_or_DC ximg; #ifndef HAVE_NTGUI @@ -4973,7 +4856,7 @@ x_build_heuristic_mask (f, img, how) /* Create the bit array serving as mask. */ row_width = (img->width + 7) / 8; mask_img = xmalloc (row_width * img->height); - bzero (mask_img, row_width * img->height); + memset (mask_img, 0, row_width * img->height); /* Create a memory device context for IMG->pixmap. */ frame_dc = get_frame_dc (f); @@ -5022,7 +4905,7 @@ x_build_heuristic_mask (f, img, how) ? PIX_MASK_DRAW : PIX_MASK_RETAIN)); #else if (XGetPixel (ximg, x, y) == bg) - ns_set_alpha(ximg, x, y, 0); + ns_set_alpha (ximg, x, y, 0); #endif /* HAVE_NS */ #ifndef HAVE_NS /* Fill in the background_transparent field while we have the mask handy. */ @@ -5062,9 +4945,9 @@ x_build_heuristic_mask (f, img, how) PBM (mono, gray, color) ***********************************************************************/ -static int pbm_image_p P_ ((Lisp_Object object)); -static int pbm_load P_ ((struct frame *f, struct image *img)); -static int pbm_scan_number P_ ((unsigned char **, unsigned char *)); +static int pbm_image_p (Lisp_Object object); +static int pbm_load (struct frame *f, struct image *img); +static int pbm_scan_number (unsigned char **, unsigned char *); /* The symbol `pbm' identifying images of this type. */ @@ -5121,12 +5004,11 @@ static struct image_type pbm_type = /* Return non-zero if OBJECT is a valid PBM image specification. */ static int -pbm_image_p (object) - Lisp_Object object; +pbm_image_p (Lisp_Object object) { struct image_keyword fmt[PBM_LAST]; - bcopy (pbm_format, fmt, sizeof fmt); + memcpy (fmt, pbm_format, sizeof fmt); if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) return 0; @@ -5141,8 +5023,7 @@ pbm_image_p (object) end of input. */ static int -pbm_scan_number (s, end) - unsigned char **s, *end; +pbm_scan_number (unsigned char **s, unsigned char *end) { int c = 0, val = -1; @@ -5217,23 +5098,18 @@ pbm_read_file (file, size) /* Load PBM image IMG for use on frame F. */ static int -pbm_load (f, img) - struct frame *f; - struct image *img; +pbm_load (struct frame *f, struct image *img) { int raw_p, x, y; int width, height, max_color_idx = 0; XImagePtr ximg; Lisp_Object file, specified_file; enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type; - struct gcpro gcpro1; unsigned char *contents = NULL; unsigned char *end, *p; int size; specified_file = image_spec_value (img->spec, QCfile, NULL); - file = Qnil; - GCPRO1 (file); if (STRINGP (specified_file)) { @@ -5241,7 +5117,6 @@ pbm_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); - UNGCPRO; return 0; } @@ -5249,7 +5124,6 @@ pbm_load (f, img) if (contents == NULL) { image_error ("Error reading `%s'", file, Qnil); - UNGCPRO; return 0; } @@ -5260,6 +5134,11 @@ pbm_load (f, img) { Lisp_Object data; data = image_spec_value (img->spec, QCdata, NULL); + if (!STRINGP (data)) + { + image_error ("Invalid image data `%s'", data, Qnil); + return 0; + } p = SDATA (data); end = p + SBYTES (data); } @@ -5270,7 +5149,6 @@ pbm_load (f, img) image_error ("Not a PBM image: `%s'", img->spec, Qnil); error: xfree (contents); - UNGCPRO; return 0; } @@ -5341,7 +5219,7 @@ pbm_load (f, img) unsigned long bg = FRAME_BACKGROUND_PIXEL (f); /* Parse the image specification. */ - bcopy (pbm_format, fmt, sizeof fmt); + memcpy (fmt, pbm_format, sizeof fmt); parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); /* Get foreground and background colors, maybe allocate colors. */ @@ -5472,7 +5350,6 @@ pbm_load (f, img) img->width = width; img->height = height; */ - UNGCPRO; xfree (contents); return 1; } @@ -5486,8 +5363,8 @@ pbm_load (f, img) /* Function prototypes. */ -static int png_image_p P_ ((Lisp_Object object)); -static int png_load P_ ((struct frame *f, struct image *img)); +static int png_image_p (Lisp_Object object); +static int png_load (struct frame *f, struct image *img); /* The symbol `png' identifying images of this type. */ @@ -5541,11 +5418,10 @@ static struct image_type png_type = /* Return non-zero if OBJECT is a valid PNG image specification. */ static int -png_image_p (object) - Lisp_Object object; +png_image_p (Lisp_Object object) { struct image_keyword fmt[PNG_LAST]; - bcopy (png_format, fmt, sizeof fmt); + memcpy (fmt, png_format, sizeof fmt); if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) return 0; @@ -5562,27 +5438,31 @@ png_image_p (object) #ifdef HAVE_NTGUI /* PNG library details. */ -DEF_IMGLIB_FN (png_get_io_ptr); -DEF_IMGLIB_FN (png_sig_cmp); -DEF_IMGLIB_FN (png_create_read_struct); -DEF_IMGLIB_FN (png_create_info_struct); -DEF_IMGLIB_FN (png_destroy_read_struct); -DEF_IMGLIB_FN (png_set_read_fn); -DEF_IMGLIB_FN (png_set_sig_bytes); -DEF_IMGLIB_FN (png_read_info); -DEF_IMGLIB_FN (png_get_IHDR); -DEF_IMGLIB_FN (png_get_valid); -DEF_IMGLIB_FN (png_set_strip_16); -DEF_IMGLIB_FN (png_set_expand); -DEF_IMGLIB_FN (png_set_gray_to_rgb); -DEF_IMGLIB_FN (png_set_background); -DEF_IMGLIB_FN (png_get_bKGD); -DEF_IMGLIB_FN (png_read_update_info); -DEF_IMGLIB_FN (png_get_channels); -DEF_IMGLIB_FN (png_get_rowbytes); -DEF_IMGLIB_FN (png_read_image); -DEF_IMGLIB_FN (png_read_end); -DEF_IMGLIB_FN (png_error); +DEF_IMGLIB_FN (png_get_io_ptr, (png_structp)); +DEF_IMGLIB_FN (png_sig_cmp, (png_bytep, png_size_t, png_size_t)); +DEF_IMGLIB_FN (png_create_read_struct, (png_const_charp, png_voidp, + png_error_ptr, png_error_ptr)); +DEF_IMGLIB_FN (png_create_info_struct, (png_structp)); +DEF_IMGLIB_FN (png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); +DEF_IMGLIB_FN (png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); +DEF_IMGLIB_FN (png_set_sig_bytes, (png_structp, int)); +DEF_IMGLIB_FN (png_read_info, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_get_IHDR, (png_structp, png_infop, + png_uint_32 *, png_uint_32 *, + int *, int *, int *, int *, int *)); +DEF_IMGLIB_FN (png_get_valid, (png_structp, png_infop, png_uint_32)); +DEF_IMGLIB_FN (png_set_strip_16, (png_structp)); +DEF_IMGLIB_FN (png_set_expand, (png_structp)); +DEF_IMGLIB_FN (png_set_gray_to_rgb, (png_structp)); +DEF_IMGLIB_FN (png_set_background, (png_structp, png_color_16p, + int, int, double)); +DEF_IMGLIB_FN (png_get_bKGD, (png_structp, png_infop, png_color_16p *)); +DEF_IMGLIB_FN (png_read_update_info, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_get_channels, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_get_rowbytes, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_read_image, (png_structp, png_bytepp)); +DEF_IMGLIB_FN (png_read_end, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_error, (png_structp, png_const_charp)); static int init_png_functions (Lisp_Object libraries) @@ -5646,9 +5526,7 @@ init_png_functions (Lisp_Object libraries) is initialized. */ static void -my_png_error (png_ptr, msg) - png_struct *png_ptr; - char *msg; +my_png_error (png_struct *png_ptr, const char *msg) { xassert (png_ptr != NULL); image_error ("PNG error: %s", build_string (msg), Qnil); @@ -5657,9 +5535,7 @@ my_png_error (png_ptr, msg) static void -my_png_warning (png_ptr, msg) - png_struct *png_ptr; - char *msg; +my_png_warning (png_struct *png_ptr, const char *msg) { xassert (png_ptr != NULL); image_error ("PNG warning: %s", build_string (msg), Qnil); @@ -5680,10 +5556,7 @@ struct png_memory_storage bytes from the input to DATA. */ static void -png_read_from_memory (png_ptr, data, length) - png_structp png_ptr; - png_bytep data; - png_size_t length; +png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) { struct png_memory_storage *tbr = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr); @@ -5691,7 +5564,7 @@ png_read_from_memory (png_ptr, data, length) if (length > tbr->len - tbr->index) fn_png_error (png_ptr, "Read error"); - bcopy (tbr->bytes + tbr->index, data, length); + memcpy (data, tbr->bytes + tbr->index, length); tbr->index = tbr->index + length; } @@ -5701,10 +5574,7 @@ png_read_from_memory (png_ptr, data, length) bytes from the input to DATA. */ static void -png_read_from_file (png_ptr, data, length) - png_structp png_ptr; - png_bytep data; - png_size_t length; +png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) { FILE *fp = (FILE *) fn_png_get_io_ptr (png_ptr); @@ -5717,15 +5587,12 @@ png_read_from_file (png_ptr, data, length) successful. */ static int -png_load (f, img) - struct frame *f; - struct image *img; +png_load (struct frame *f, struct image *img) { Lisp_Object file, specified_file; Lisp_Object specified_data; int x, y, i; XImagePtr ximg, mask_img = NULL; - struct gcpro gcpro1; png_struct *png_ptr = NULL; png_info *info_ptr = NULL, *end_info = NULL; FILE *volatile fp = NULL; @@ -5742,8 +5609,6 @@ png_load (f, img) /* Find out what file to load. */ specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); - file = Qnil; - GCPRO1 (file); if (NILP (specified_data)) { @@ -5751,7 +5616,6 @@ png_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); - UNGCPRO; return 0; } @@ -5760,7 +5624,6 @@ png_load (f, img) if (!fp) { image_error ("Cannot open image file `%s'", file, Qnil); - UNGCPRO; return 0; } @@ -5769,13 +5632,18 @@ png_load (f, img) || fn_png_sig_cmp (sig, 0, sizeof sig)) { image_error ("Not a PNG file: `%s'", file, Qnil); - UNGCPRO; fclose (fp); return 0; } } else { + if (!STRINGP (specified_data)) + { + image_error ("Invalid image data `%s'", specified_data, Qnil); + return 0; + } + /* Read from memory. */ tbr.bytes = SDATA (specified_data); tbr.len = SBYTES (specified_data); @@ -5786,7 +5654,6 @@ png_load (f, img) || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig)) { image_error ("Not a PNG image: `%s'", img->spec, Qnil); - UNGCPRO; return 0; } @@ -5802,7 +5669,6 @@ png_load (f, img) if (!png_ptr) { if (fp) fclose (fp); - UNGCPRO; return 0; } @@ -5812,7 +5678,6 @@ png_load (f, img) { fn_png_destroy_read_struct (&png_ptr, NULL, NULL); if (fp) fclose (fp); - UNGCPRO; return 0; } @@ -5822,7 +5687,6 @@ png_load (f, img) { fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); if (fp) fclose (fp); - UNGCPRO; return 0; } @@ -5836,7 +5700,6 @@ png_load (f, img) xfree (pixels); xfree (rows); if (fp) fclose (fp); - UNGCPRO; return 0; } @@ -5898,7 +5761,7 @@ png_load (f, img) { png_color_16 user_bg; - bzero (&user_bg, sizeof user_bg); + memset (&user_bg, 0, sizeof user_bg); user_bg.red = color.red >> shift; user_bg.green = color.green >> shift; user_bg.blue = color.blue >> shift; @@ -5918,7 +5781,7 @@ png_load (f, img) color.pixel = FRAME_BACKGROUND_PIXEL (f); x_query_color (f, &color); - bzero (&frame_background, sizeof frame_background); + memset (&frame_background, 0, sizeof frame_background); frame_background.red = color.red >> shift; frame_background.green = color.green >> shift; frame_background.blue = color.blue >> shift; @@ -6061,7 +5924,6 @@ png_load (f, img) x_destroy_x_image (mask_img); } - UNGCPRO; return 1; } @@ -6088,8 +5950,8 @@ png_load (struct frame *f, struct image *img) #if defined (HAVE_JPEG) || defined (HAVE_NS) -static int jpeg_image_p P_ ((Lisp_Object object)); -static int jpeg_load P_ ((struct frame *f, struct image *img)); +static int jpeg_image_p (Lisp_Object object); +static int jpeg_load (struct frame *f, struct image *img); /* The symbol `jpeg' identifying images of this type. */ @@ -6143,12 +6005,11 @@ static struct image_type jpeg_type = /* Return non-zero if OBJECT is a valid JPEG image specification. */ static int -jpeg_image_p (object) - Lisp_Object object; +jpeg_image_p (Lisp_Object object) { struct image_keyword fmt[JPEG_LAST]; - bcopy (jpeg_format, fmt, sizeof fmt); + memcpy (fmt, jpeg_format, sizeof fmt); if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) return 0; @@ -6184,14 +6045,14 @@ jpeg_image_p (object) #ifdef HAVE_NTGUI /* JPEG library details. */ -DEF_IMGLIB_FN (jpeg_CreateDecompress); -DEF_IMGLIB_FN (jpeg_start_decompress); -DEF_IMGLIB_FN (jpeg_finish_decompress); -DEF_IMGLIB_FN (jpeg_destroy_decompress); -DEF_IMGLIB_FN (jpeg_read_header); -DEF_IMGLIB_FN (jpeg_read_scanlines); -DEF_IMGLIB_FN (jpeg_std_error); -DEF_IMGLIB_FN (jpeg_resync_to_restart); +DEF_IMGLIB_FN (jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); +DEF_IMGLIB_FN (jpeg_start_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (jpeg_finish_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (jpeg_destroy_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (jpeg_read_header, (j_decompress_ptr, boolean)); +DEF_IMGLIB_FN (jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); +DEF_IMGLIB_FN (jpeg_std_error, (struct jpeg_error_mgr *)); +DEF_IMGLIB_FN (jpeg_resync_to_restart, (j_decompress_ptr, int)); static int init_jpeg_functions (Lisp_Object libraries) @@ -6215,9 +6076,7 @@ init_jpeg_functions (Lisp_Object libraries) /* Wrapper since we can't directly assign the function pointer to another function pointer that was declared more completely easily. */ static boolean -jpeg_resync_to_restart_wrapper (cinfo, desired) - j_decompress_ptr cinfo; - int desired; +jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) { return fn_jpeg_resync_to_restart (cinfo, desired); } @@ -6243,8 +6102,7 @@ struct my_jpeg_error_mgr static void -my_error_exit (cinfo) - j_common_ptr cinfo; +my_error_exit (j_common_ptr cinfo) { struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; longjmp (mgr->setjmp_buffer, 1); @@ -6256,8 +6114,7 @@ my_error_exit (cinfo) libjpeg.doc from the JPEG lib distribution. */ static void -our_common_init_source (cinfo) - j_decompress_ptr cinfo; +our_common_init_source (j_decompress_ptr cinfo) { } @@ -6266,8 +6123,7 @@ our_common_init_source (cinfo) jpeg_finish_decompress() after all data has been processed. */ static void -our_common_term_source (cinfo) - j_decompress_ptr cinfo; +our_common_term_source (j_decompress_ptr cinfo) { } @@ -6279,8 +6135,7 @@ our_common_term_source (cinfo) static JOCTET our_memory_buffer[2]; static boolean -our_memory_fill_input_buffer (cinfo) - j_decompress_ptr cinfo; +our_memory_fill_input_buffer (j_decompress_ptr cinfo) { /* Insert a fake EOI marker. */ struct jpeg_source_mgr *src = cinfo->src; @@ -6298,9 +6153,7 @@ our_memory_fill_input_buffer (cinfo) is the JPEG data source manager. */ static void -our_memory_skip_input_data (cinfo, num_bytes) - j_decompress_ptr cinfo; - long num_bytes; +our_memory_skip_input_data (j_decompress_ptr cinfo, long int num_bytes) { struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; @@ -6320,10 +6173,7 @@ our_memory_skip_input_data (cinfo, num_bytes) reading the image. */ static void -jpeg_memory_src (cinfo, data, len) - j_decompress_ptr cinfo; - JOCTET *data; - unsigned int len; +jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) { struct jpeg_source_mgr *src; @@ -6366,8 +6216,7 @@ struct jpeg_stdio_mgr whenever more data is needed. The data is read from a FILE *. */ static boolean -our_stdio_fill_input_buffer (cinfo) - j_decompress_ptr cinfo; +our_stdio_fill_input_buffer (j_decompress_ptr cinfo) { struct jpeg_stdio_mgr *src; @@ -6398,9 +6247,7 @@ our_stdio_fill_input_buffer (cinfo) is the JPEG data source manager. */ static void -our_stdio_skip_input_data (cinfo, num_bytes) - j_decompress_ptr cinfo; - long num_bytes; +our_stdio_skip_input_data (j_decompress_ptr cinfo, long int num_bytes) { struct jpeg_stdio_mgr *src; src = (struct jpeg_stdio_mgr *) cinfo->src; @@ -6430,9 +6277,7 @@ our_stdio_skip_input_data (cinfo, num_bytes) reading the image. */ static void -jpeg_file_src (cinfo, fp) - j_decompress_ptr cinfo; - FILE *fp; +jpeg_file_src (j_decompress_ptr cinfo, FILE *fp) { struct jpeg_stdio_mgr *src; @@ -6466,9 +6311,7 @@ jpeg_file_src (cinfo, fp) from the JPEG lib. */ static int -jpeg_load (f, img) - struct frame *f; - struct image *img; +jpeg_load (struct frame *f, struct image *img) { struct jpeg_decompress_struct cinfo; struct my_jpeg_error_mgr mgr; @@ -6481,13 +6324,10 @@ jpeg_load (f, img) int rc; unsigned long *colors; int width, height; - struct gcpro gcpro1; /* Open the JPEG file. */ specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); - file = Qnil; - GCPRO1 (file); if (NILP (specified_data)) { @@ -6495,7 +6335,6 @@ jpeg_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); - UNGCPRO; return 0; } @@ -6503,10 +6342,14 @@ jpeg_load (f, img) if (fp == NULL) { image_error ("Cannot open `%s'", file, Qnil); - UNGCPRO; return 0; } } + else if (!STRINGP (specified_data)) + { + image_error ("Invalid image data `%s'", specified_data, Qnil); + return 0; + } /* Customize libjpeg's error handling to call my_error_exit when an error is detected. This function will perform a longjmp. @@ -6535,8 +6378,6 @@ jpeg_load (f, img) /* Free pixmap and colors. */ x_clear_image (f, img); - - UNGCPRO; return 0; } @@ -6634,7 +6475,6 @@ jpeg_load (f, img) /* Put the image into the pixmap. */ x_put_x_image (f, ximg, img->pixmap, width, height); x_destroy_x_image (ximg); - UNGCPRO; return 1; } @@ -6644,9 +6484,9 @@ jpeg_load (f, img) static int jpeg_load (struct frame *f, struct image *img) { - return ns_load_image(f, img, - image_spec_value (img->spec, QCfile, NULL), - image_spec_value (img->spec, QCdata, NULL)); + return ns_load_image (f, img, + image_spec_value (img->spec, QCfile, NULL), + image_spec_value (img->spec, QCdata, NULL)); } #endif /* HAVE_NS */ @@ -6660,8 +6500,8 @@ jpeg_load (struct frame *f, struct image *img) #if defined (HAVE_TIFF) || defined (HAVE_NS) -static int tiff_image_p P_ ((Lisp_Object object)); -static int tiff_load P_ ((struct frame *f, struct image *img)); +static int tiff_image_p (Lisp_Object object); +static int tiff_load (struct frame *f, struct image *img); /* The symbol `tiff' identifying images of this type. */ @@ -6717,11 +6557,10 @@ static struct image_type tiff_type = /* Return non-zero if OBJECT is a valid TIFF image specification. */ static int -tiff_image_p (object) - Lisp_Object object; +tiff_image_p (Lisp_Object object) { struct image_keyword fmt[TIFF_LAST]; - bcopy (tiff_format, fmt, sizeof fmt); + memcpy (fmt, tiff_format, sizeof fmt); if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) return 0; @@ -6739,14 +6578,17 @@ tiff_image_p (object) #ifdef HAVE_NTGUI /* TIFF library details. */ -DEF_IMGLIB_FN (TIFFSetErrorHandler); -DEF_IMGLIB_FN (TIFFSetWarningHandler); -DEF_IMGLIB_FN (TIFFOpen); -DEF_IMGLIB_FN (TIFFClientOpen); -DEF_IMGLIB_FN (TIFFGetField); -DEF_IMGLIB_FN (TIFFReadRGBAImage); -DEF_IMGLIB_FN (TIFFClose); -DEF_IMGLIB_FN (TIFFSetDirectory); +DEF_IMGLIB_FN (TIFFSetErrorHandler, (TIFFErrorHandler)); +DEF_IMGLIB_FN (TIFFSetWarningHandler, (TIFFErrorHandler)); +DEF_IMGLIB_FN (TIFFOpen, (const char *, const char *)); +DEF_IMGLIB_FN (TIFFClientOpen, (const char *, const char *, thandle_t, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc)); +DEF_IMGLIB_FN (TIFFGetField, (TIFF *, ttag_t, ...)); +DEF_IMGLIB_FN (TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); +DEF_IMGLIB_FN (TIFFClose, (TIFF *)); +DEF_IMGLIB_FN (TIFFSetDirectory, (TIFF *, tdir_t)); static int init_tiff_functions (Lisp_Object libraries) @@ -6798,34 +6640,25 @@ typedef struct tiff_memory_source; static size_t -tiff_read_from_memory (data, buf, size) - thandle_t data; - tdata_t buf; - tsize_t size; +tiff_read_from_memory (thandle_t data, tdata_t buf, tsize_t size) { tiff_memory_source *src = (tiff_memory_source *) data; if (size > src->len - src->index) return (size_t) -1; - bcopy (src->bytes + src->index, buf, size); + memcpy (buf, src->bytes + src->index, size); src->index += size; return size; } static size_t -tiff_write_from_memory (data, buf, size) - thandle_t data; - tdata_t buf; - tsize_t size; +tiff_write_from_memory (thandle_t data, tdata_t buf, tsize_t size) { return (size_t) -1; } static toff_t -tiff_seek_in_memory (data, off, whence) - thandle_t data; - toff_t off; - int whence; +tiff_seek_in_memory (thandle_t data, toff_t off, int whence) { tiff_memory_source *src = (tiff_memory_source *) data; int idx; @@ -6856,44 +6689,34 @@ tiff_seek_in_memory (data, off, whence) } static int -tiff_close_memory (data) - thandle_t data; +tiff_close_memory (thandle_t data) { /* NOOP */ return 0; } static int -tiff_mmap_memory (data, pbase, psize) - thandle_t data; - tdata_t *pbase; - toff_t *psize; +tiff_mmap_memory (thandle_t data, tdata_t *pbase, toff_t *psize) { /* It is already _IN_ memory. */ return 0; } static void -tiff_unmap_memory (data, base, size) - thandle_t data; - tdata_t base; - toff_t size; +tiff_unmap_memory (thandle_t data, tdata_t base, toff_t size) { /* We don't need to do this. */ } static toff_t -tiff_size_of_memory (data) - thandle_t data; +tiff_size_of_memory (thandle_t data) { return ((tiff_memory_source *) data)->len; } static void -tiff_error_handler (title, format, ap) - const char *title, *format; - va_list ap; +tiff_error_handler (const char *title, const char *format, va_list ap) { char buf[512]; int len; @@ -6905,9 +6728,7 @@ tiff_error_handler (title, format, ap) static void -tiff_warning_handler (title, format, ap) - const char *title, *format; - va_list ap; +tiff_warning_handler (const char *title, const char *format, va_list ap) { char buf[512]; int len; @@ -6922,9 +6743,7 @@ tiff_warning_handler (title, format, ap) successful. */ static int -tiff_load (f, img) - struct frame *f; - struct image *img; +tiff_load (struct frame *f, struct image *img) { Lisp_Object file, specified_file; Lisp_Object specified_data; @@ -6933,14 +6752,11 @@ tiff_load (f, img) uint32 *buf; int rc, rc2; XImagePtr ximg; - struct gcpro gcpro1; tiff_memory_source memsrc; Lisp_Object image; specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); - file = Qnil; - GCPRO1 (file); fn_TIFFSetErrorHandler (tiff_error_handler); fn_TIFFSetWarningHandler (tiff_warning_handler); @@ -6952,7 +6768,6 @@ tiff_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); - UNGCPRO; return 0; } @@ -6962,12 +6777,17 @@ tiff_load (f, img) if (tiff == NULL) { image_error ("Cannot open `%s'", file, Qnil); - UNGCPRO; return 0; } } else { + if (!STRINGP (specified_data)) + { + image_error ("Invalid image data `%s'", specified_data, Qnil); + return 0; + } + /* Memory source! */ memsrc.bytes = SDATA (specified_data); memsrc.len = SBYTES (specified_data); @@ -6986,7 +6806,6 @@ tiff_load (f, img) if (!tiff) { image_error ("Cannot open memory source for `%s'", img->spec, Qnil); - UNGCPRO; return 0; } } @@ -7000,7 +6819,6 @@ tiff_load (f, img) image_error ("Invalid image number `%s' in image `%s'", image, img->spec); fn_TIFFClose (tiff); - UNGCPRO; return 0; } } @@ -7014,7 +6832,6 @@ tiff_load (f, img) { image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); fn_TIFFClose (tiff); - UNGCPRO; return 0; } @@ -7036,7 +6853,6 @@ tiff_load (f, img) { image_error ("Error reading TIFF image `%s'", img->spec, Qnil); xfree (buf); - UNGCPRO; return 0; } @@ -7044,7 +6860,6 @@ tiff_load (f, img) if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) { xfree (buf); - UNGCPRO; return 0; } @@ -7085,7 +6900,6 @@ tiff_load (f, img) x_destroy_x_image (ximg); xfree (buf); - UNGCPRO; return 1; } @@ -7095,9 +6909,9 @@ tiff_load (f, img) static int tiff_load (struct frame *f, struct image *img) { - return ns_load_image(f, img, - image_spec_value (img->spec, QCfile, NULL), - image_spec_value (img->spec, QCdata, NULL)); + return ns_load_image (f, img, + image_spec_value (img->spec, QCfile, NULL), + image_spec_value (img->spec, QCdata, NULL)); } #endif /* HAVE_NS */ @@ -7111,9 +6925,9 @@ tiff_load (struct frame *f, struct image *img) #if defined (HAVE_GIF) || defined (HAVE_NS) -static int gif_image_p P_ ((Lisp_Object object)); -static int gif_load P_ ((struct frame *f, struct image *img)); -static void gif_clear_image P_ ((struct frame *f, struct image *img)); +static int gif_image_p (Lisp_Object object); +static int gif_load (struct frame *f, struct image *img); +static void gif_clear_image (struct frame *f, struct image *img); /* The symbol `gif' identifying images of this type. */ @@ -7169,11 +6983,9 @@ static struct image_type gif_type = /* Free X resources of GIF image IMG which is used on frame F. */ static void -gif_clear_image (f, img) - struct frame *f; - struct image *img; +gif_clear_image (struct frame *f, struct image *img) { - /* IMG->data.ptr_val may contain extension data. */ + /* IMG->data.ptr_val may contain metadata with extension data. */ img->data.lisp_val = Qnil; x_clear_image (f, img); } @@ -7181,11 +6993,10 @@ gif_clear_image (f, img) /* Return non-zero if OBJECT is a valid GIF image specification. */ static int -gif_image_p (object) - Lisp_Object object; +gif_image_p (Lisp_Object object) { struct image_keyword fmt[GIF_LAST]; - bcopy (gif_format, fmt, sizeof fmt); + memcpy (fmt, gif_format, sizeof fmt); if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) return 0; @@ -7219,10 +7030,10 @@ gif_image_p (object) #ifdef HAVE_NTGUI /* GIF library details. */ -DEF_IMGLIB_FN (DGifCloseFile); -DEF_IMGLIB_FN (DGifSlurp); -DEF_IMGLIB_FN (DGifOpen); -DEF_IMGLIB_FN (DGifOpenFileName); +DEF_IMGLIB_FN (DGifCloseFile, (GifFileType *)); +DEF_IMGLIB_FN (DGifSlurp, (GifFileType *)); +DEF_IMGLIB_FN (DGifOpen, (void *, InputFunc)); +DEF_IMGLIB_FN (DGifOpenFileName, (const char *)); static int init_gif_functions (Lisp_Object libraries) @@ -7265,17 +7076,14 @@ gif_memory_source; static gif_memory_source *current_gif_memory_src; static int -gif_read_from_memory (file, buf, len) - GifFileType *file; - GifByteType *buf; - int len; +gif_read_from_memory (GifFileType *file, GifByteType *buf, int len) { gif_memory_source *src = current_gif_memory_src; if (len > src->len - src->index) return -1; - bcopy (src->bytes + src->index, buf, len); + memcpy (buf, src->bytes + src->index, len); src->index += len; return len; } @@ -7288,9 +7096,7 @@ static const int interlace_start[] = {0, 4, 2, 1}; static const int interlace_increment[] = {8, 8, 4, 2}; static int -gif_load (f, img) - struct frame *f; - struct image *img; +gif_load (struct frame *f, struct image *img) { Lisp_Object file, specified_file; Lisp_Object specified_data; @@ -7299,7 +7105,6 @@ gif_load (f, img) ColorMapObject *gif_color_map; unsigned long pixel_colors[256]; GifFileType *gif; - struct gcpro gcpro1; Lisp_Object image; int ino, image_height, image_width; gif_memory_source memsrc; @@ -7307,8 +7112,6 @@ gif_load (f, img) specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); - file = Qnil; - GCPRO1 (file); if (NILP (specified_data)) { @@ -7316,7 +7119,6 @@ gif_load (f, img) if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", specified_file, Qnil); - UNGCPRO; return 0; } @@ -7326,12 +7128,17 @@ gif_load (f, img) if (gif == NULL) { image_error ("Cannot open `%s'", file, Qnil); - UNGCPRO; return 0; } } else { + if (!STRINGP (specified_data)) + { + image_error ("Invalid image data `%s'", specified_data, Qnil); + return 0; + } + /* Read from memory! */ current_gif_memory_src = &memsrc; memsrc.bytes = SDATA (specified_data); @@ -7343,7 +7150,6 @@ gif_load (f, img) if (!gif) { image_error ("Cannot open memory source `%s'", img->spec, Qnil); - UNGCPRO; return 0; } } @@ -7353,7 +7159,6 @@ gif_load (f, img) { image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); fn_DGifCloseFile (gif); - UNGCPRO; return 0; } @@ -7363,7 +7168,6 @@ gif_load (f, img) { image_error ("Error reading `%s'", img->spec, Qnil); fn_DGifCloseFile (gif); - UNGCPRO; return 0; } @@ -7374,7 +7178,6 @@ gif_load (f, img) image_error ("Invalid image number `%s' in image `%s'", image, img->spec); fn_DGifCloseFile (gif); - UNGCPRO; return 0; } @@ -7396,7 +7199,6 @@ gif_load (f, img) { image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); fn_DGifCloseFile (gif); - UNGCPRO; return 0; } @@ -7404,7 +7206,6 @@ gif_load (f, img) if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) { fn_DGifCloseFile (gif); - UNGCPRO; return 0; } @@ -7413,7 +7214,7 @@ gif_load (f, img) if (!gif_color_map) gif_color_map = gif->SColorMap; init_color_table (); - bzero (pixel_colors, sizeof pixel_colors); + memset (pixel_colors, 0, sizeof pixel_colors); if (gif_color_map) for (i = 0; i < gif_color_map->ColorCount; ++i) @@ -7492,8 +7293,8 @@ gif_load (f, img) } } - /* Save GIF image extension data for `image-extension-data'. - Format is (count IMAGES FUNCTION "BYTES" ...). */ + /* Save GIF image extension data for `image-metadata'. + Format is (count IMAGES extension-data (FUNCTION "BYTES" ...)). */ img->data.lisp_val = Qnil; if (gif->SavedImages[ino].ExtensionBlockCount > 0) { @@ -7503,7 +7304,9 @@ gif_load (f, img) img->data.lisp_val = Fcons (make_unibyte_string (ext->Bytes, ext->ByteCount), Fcons (make_number (ext->Function), img->data.lisp_val)); - img->data.lisp_val = Fnreverse (img->data.lisp_val); + img->data.lisp_val = Fcons (Qextension_data, + Fcons (Fnreverse (img->data.lisp_val), + Qnil)); } if (gif->ImageCount > 1) img->data.lisp_val = Fcons (Qcount, @@ -7521,7 +7324,6 @@ gif_load (f, img) x_put_x_image (f, ximg, img->pixmap, width, height); x_destroy_x_image (ximg); - UNGCPRO; return 1; } @@ -7531,15 +7333,531 @@ gif_load (f, img) static int gif_load (struct frame *f, struct image *img) { - return ns_load_image(f, img, - image_spec_value (img->spec, QCfile, NULL), - image_spec_value (img->spec, QCdata, NULL)); + return ns_load_image (f, img, + image_spec_value (img->spec, QCfile, NULL), + image_spec_value (img->spec, QCdata, NULL)); } #endif /* HAVE_NS */ #endif /* HAVE_GIF */ +/*********************************************************************** + imagemagick +***********************************************************************/ +#if defined (HAVE_IMAGEMAGICK) +Lisp_Object Vimagemagick_render_type; + +/* The symbol `imagemagick' identifying images of this type. */ + +Lisp_Object Qimagemagick; +Lisp_Object Vimagemagick_render_type; + +/* Indices of image specification fields in imagemagick_format, below. */ + +enum imagemagick_keyword_index + { + IMAGEMAGICK_TYPE, + IMAGEMAGICK_DATA, + IMAGEMAGICK_FILE, + IMAGEMAGICK_ASCENT, + IMAGEMAGICK_MARGIN, + IMAGEMAGICK_RELIEF, + IMAGEMAGICK_ALGORITHM, + IMAGEMAGICK_HEURISTIC_MASK, + IMAGEMAGICK_MASK, + IMAGEMAGICK_BACKGROUND, + IMAGEMAGICK_HEIGHT, + IMAGEMAGICK_WIDTH, + IMAGEMAGICK_ROTATION, + IMAGEMAGICK_CROP, + IMAGEMAGICK_LAST + }; + +/* Vector of image_keyword structures describing the format + of valid user-defined image specifications. */ + +static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = + { + {":type", IMAGE_SYMBOL_VALUE, 1}, + {":data", IMAGE_STRING_VALUE, 0}, + {":file", IMAGE_STRING_VALUE, 0}, + {":ascent", IMAGE_ASCENT_VALUE, 0}, + {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, + {":relief", IMAGE_INTEGER_VALUE, 0}, + {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, + {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, + {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, + {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, + {":height", IMAGE_INTEGER_VALUE, 0}, + {":width", IMAGE_INTEGER_VALUE, 0}, + {":rotation", IMAGE_NUMBER_VALUE, 0}, + {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} + }; +/* Free X resources of imagemagick image IMG which is used on frame F. */ + +static void +imagemagick_clear_image (struct frame *f, + struct image *img) +{ + x_clear_image (f, img); +} + + + +/* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do + this by calling parse_image_spec and supplying the keywords that + identify the IMAGEMAGICK format. */ + +static int +imagemagick_image_p (Lisp_Object object) +{ + struct image_keyword fmt[IMAGEMAGICK_LAST]; + memcpy (fmt, imagemagick_format, sizeof fmt); + + if (!parse_image_spec (object, fmt, IMAGEMAGICK_LAST, Qimagemagick)) + return 0; + + /* Must specify either the :data or :file keyword. */ + return fmt[IMAGEMAGICK_FILE].count + fmt[IMAGEMAGICK_DATA].count == 1; +} + +/* The GIF library also defines DrawRectangle, but its never used in Emacs. + Therefore rename the function so it doesnt collide with ImageMagick. */ +#define DrawRectangle DrawRectangleGif +#include <wand/MagickWand.h> + +/* imagemagick_load_image is a helper function for imagemagick_load, + which does the actual loading given contents and size, apart from + frame and image structures, passed from imagemagick_load. + + Uses librimagemagick to do most of the image processing. + + non-zero when successful. +*/ + +static int +imagemagick_load_image (/* Pointer to emacs frame structure. */ + struct frame *f, + /* Pointer to emacs image structure. */ + struct image *img, + /* String containing the IMAGEMAGICK data to + be parsed. */ + unsigned char *contents, + /* Size of data in bytes. */ + unsigned int size, + /* Filename, either pass filename or + contents/size. */ + unsigned char *filename) +{ + unsigned long width; + unsigned long height; + + MagickBooleanType + status; + + XImagePtr ximg; + Lisp_Object specified_bg; + XColor background; + int x; + int y; + + MagickWand *image_wand; + MagickWand *ping_wand; + PixelIterator *iterator; + PixelWand **pixels; + MagickPixelPacket pixel; + Lisp_Object image; + Lisp_Object value; + Lisp_Object crop, geometry; + long ino; + int desired_width, desired_height; + double rotation; + int imagemagick_rendermethod; + int pixelwidth; + ImageInfo *image_info; + ExceptionInfo *exception; + Image * im_image; + + + /* Handle image index for image types who can contain more than one + image. Interface :index is same as for GIF. First we "ping" the + image to see how many sub-images it contains. Pinging is faster + than loading the image to find out things about it. */ + image = image_spec_value (img->spec, QCindex, NULL); + ino = INTEGERP (image) ? XFASTINT (image) : 0; + ping_wand = NewMagickWand (); + MagickSetResolution (ping_wand, 2, 2); + if (filename != NULL) + { + status = MagickPingImage (ping_wand, filename); + } + else + { + status = MagickPingImageBlob (ping_wand, contents, size); + } + + if (ino >= MagickGetNumberImages (ping_wand)) + { + image_error ("Invalid image number `%s' in image `%s'", + image, img->spec); + DestroyMagickWand (ping_wand); + return 0; + } + + if (MagickGetNumberImages(ping_wand) > 1) + img->data.lisp_val = + Fcons (Qcount, + Fcons (make_number (MagickGetNumberImages (ping_wand)), + img->data.lisp_val)); + + DestroyMagickWand (ping_wand); + /* Now, after pinging, we know how many images are inside the + file. If its not a bundle, just one. */ + + if (filename != NULL) + { + image_info = CloneImageInfo ((ImageInfo *) NULL); + (void) strcpy (image_info->filename, filename); + image_info->number_scenes = 1; + image_info->scene = ino; + exception = AcquireExceptionInfo (); + + im_image = ReadImage (image_info, exception); + CatchException (exception); + + image_wand = NewMagickWandFromImage (im_image); + } + else + { + image_wand = NewMagickWand (); + status = MagickReadImageBlob (image_wand, contents, size); + } + image_error ("im read failed", Qnil, Qnil); + if (status == MagickFalse) goto imagemagick_error; + + /* If width and/or height is set in the display spec assume we want + to scale to those values. if either h or w is unspecified, the + unspecified should be calculated from the specified to preserve + aspect ratio. */ + + value = image_spec_value (img->spec, QCwidth, NULL); + desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); + value = image_spec_value (img->spec, QCheight, NULL); + desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); + + height = MagickGetImageHeight (image_wand); + width = MagickGetImageWidth (image_wand); + + if(desired_width != -1 && desired_height == -1) + { + /* w known, calculate h. */ + desired_height = (double) desired_width / width * height; + } + if(desired_width == -1 && desired_height != -1) + { + /* h known, calculate w. */ + desired_width = (double) desired_height / height * width; + } + if(desired_width != -1 && desired_height != -1) + { + status = MagickScaleImage (image_wand, desired_width, desired_height); + if (status == MagickFalse) + { + image_error ("Imagemagick scale failed", Qnil, Qnil); + goto imagemagick_error; + } + } + + + /* crop behaves similar to image slicing in Emacs but is more memory + efficient. */ + crop = image_spec_value (img->spec, QCcrop, NULL); + + if (CONSP (crop) && INTEGERP (XCAR (crop))) + { + /* After some testing, it seems MagickCropImage is the fastest + crop function in ImageMagick. This crop function seems to do + less copying than the alternatives, but it still reads the + entire image into memory before croping, which is aparently + difficult to avoid when using imagemagick. */ + + int w, h, x, y; + w = XFASTINT (XCAR (crop)); + crop = XCDR (crop); + if (CONSP (crop) && INTEGERP (XCAR (crop))) + { + h = XFASTINT (XCAR (crop)); + crop = XCDR (crop); + if (CONSP (crop) && INTEGERP (XCAR (crop))) + { + x = XFASTINT (XCAR (crop)); + crop = XCDR (crop); + if (CONSP (crop) && INTEGERP (XCAR (crop))) + { + y = XFASTINT (XCAR (crop)); + MagickCropImage (image_wand, w, h, x, y); + } + } + } + } + + /* Furthermore :rotation. we need background color and angle for + rotation. */ + /* + TODO background handling for rotation specified_bg = + image_spec_value (img->spec, QCbackground, NULL); if (!STRINGP + (specified_bg). */ + value = image_spec_value (img->spec, QCrotation, NULL); + if (FLOATP (value)) + { + PixelWand* background = NewPixelWand (); + PixelSetColor (background, "#ffffff");/*TODO remove hardcode*/ + + rotation = extract_float (value); + + status = MagickRotateImage (image_wand, background, rotation); + DestroyPixelWand (background); + if (status == MagickFalse) + { + image_error ("Imagemagick image rotate failed", Qnil, Qnil); + goto imagemagick_error; + } + } + + /* Finaly we are done manipulating the image, figure out resulting + width, height, and then transfer ownerwship to Emacs. */ + height = MagickGetImageHeight (image_wand); + width = MagickGetImageWidth (image_wand); + if (status == MagickFalse) + { + image_error ("Imagemagick image get size failed", Qnil, Qnil); + goto imagemagick_error; + } + + if (! check_image_size (f, width, height)) + { + image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); + goto imagemagick_error; + } + + /* We can now get a valid pixel buffer from the imagemagick file, if all + went ok. */ + + init_color_table (); + imagemagick_rendermethod = (INTEGERP (Vimagemagick_render_type) + ? XFASTINT (Vimagemagick_render_type) : 0); + if (imagemagick_rendermethod == 0) + { + /* Try to create a x pixmap to hold the imagemagick pixmap. */ + if (!x_create_x_image_and_pixmap (f, width, height, 0, + &ximg, &img->pixmap)) + { + image_error("Imagemagick X bitmap allocation failure", Qnil, Qnil); + goto imagemagick_error; + } + + /* Copy imagegmagick image to x with primitive yet robust pixel + pusher loop. This has been tested a lot with many different + images. */ + + /* Copy pixels from the imagemagick image structure to the x image map. */ + iterator = NewPixelIterator (image_wand); + if (iterator == (PixelIterator *) NULL) + { + image_error ("Imagemagick pixel iterator creation failed", + Qnil, Qnil); + goto imagemagick_error; + } + + for (y = 0; y < (long) MagickGetImageHeight (image_wand); y++) + { + pixels = PixelGetNextIteratorRow (iterator, &width); + if (pixels == (PixelWand **) NULL) + break; + for (x = 0; x < (long) width; x++) + { + PixelGetMagickColor (pixels[x], &pixel); + XPutPixel (ximg, x, y, + lookup_rgb_color (f, + pixel.red, + pixel.green, + pixel.blue)); + } + } + DestroyPixelIterator (iterator); + } + + if (imagemagick_rendermethod == 1) + { + /* Magicexportimage is normaly faster than pixelpushing. This + method is also well tested. Some aspects of this method are + ad-hoc and needs to be more researched. */ + int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ + char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ + /* Try to create a x pixmap to hold the imagemagick pixmap. */ + if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, + &ximg, &img->pixmap)) + { + image_error("Imagemagick X bitmap allocation failure", Qnil, Qnil); + goto imagemagick_error; + } + + + /* Oddly, the below code doesnt seem to work:*/ + /* switch(ximg->bitmap_unit){ */ + /* case 8: */ + /* pixelwidth=CharPixel; */ + /* break; */ + /* case 16: */ + /* pixelwidth=ShortPixel; */ + /* break; */ + /* case 32: */ + /* pixelwidth=LongPixel; */ + /* break; */ + /* } */ + /* + Here im just guessing the format of the bitmap. + happens to work fine for: + - bw djvu images + on rgb display. + seems about 3 times as fast as pixel pushing(not carefully measured) + */ + pixelwidth = CharPixel;/*??? TODO figure out*/ +#ifdef HAVE_MAGICKEXPORTIMAGEPIXELS + MagickExportImagePixels (image_wand, + 0, 0, + width, height, + exportdepth, + pixelwidth, + /*&(img->pixmap));*/ + ximg->data); +#else + image_error ("You dont have MagickExportImagePixels, upgrade ImageMagick!", + Qnil, Qnil); +#endif + } + + +#ifdef COLOR_TABLE_SUPPORT + /* Remember colors allocated for this image. */ + img->colors = colors_in_color_table (&img->ncolors); + free_color_table (); +#endif /* COLOR_TABLE_SUPPORT */ + + + img->width = width; + img->height = height; + + /* Put the image into the pixmap, then free the X image and its + buffer. */ + x_put_x_image (f, ximg, img->pixmap, width, height); + x_destroy_x_image (ximg); + + + /* Final cleanup. image_wand should be the only resource left. */ + DestroyMagickWand (image_wand); + + return 1; + + imagemagick_error: + /* TODO more cleanup. */ + image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); + return 0; +} + + +/* Load IMAGEMAGICK image IMG for use on frame F. Value is non-zero if + successful. this function will go into the imagemagick_type structure, and + the prototype thus needs to be compatible with that structure. */ + +static int +imagemagick_load (struct frame *f, + struct image *img) +{ + int success_p = 0; + Lisp_Object file_name; + + /* If IMG->spec specifies a file name, create a non-file spec from it. */ + file_name = image_spec_value (img->spec, QCfile, NULL); + if (STRINGP (file_name)) + { + Lisp_Object file; + + file = x_find_image_file (file_name); + if (!STRINGP (file)) + { + image_error ("Cannot find image file `%s'", file_name, Qnil); + return 0; + } + success_p = imagemagick_load_image (f, img, 0, 0, SDATA (file)); + } + /* Else its not a file, its a lisp object. Load the image from a + lisp object rather than a file. */ + else + { + Lisp_Object data; + + data = image_spec_value (img->spec, QCdata, NULL); + if (!STRINGP (data)) + { + image_error ("Invalid image data `%s'", data, Qnil); + return 0; + } + success_p = imagemagick_load_image (f, img, SDATA (data), + SBYTES (data), NULL); + } + + return success_p; +} + +/* Structure describing the image type `imagemagick'. Its the same + type of structure defined for all image formats, handled by Emacs + image functions. See struct image_type in dispextern.h. */ + +static struct image_type imagemagick_type = + { + /* An identifier showing that this is an image structure for the + IMAGEMAGICK format. */ + &Qimagemagick, + /* Handle to a function that can be used to identify a IMAGEMAGICK + file. */ + imagemagick_image_p, + /* Handle to function used to load a IMAGEMAGICK file. */ + imagemagick_load, + /* Handle to function to free resources for IMAGEMAGICK. */ + imagemagick_clear_image, + /* An internal field to link to the next image type in a list of + image types, will be filled in when registering the format. */ + NULL + }; + + + + +DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, + doc: /* Return image file types supported by ImageMagick. +Since ImageMagick recognizes a lot of file-types that clash with Emacs, +such as .c, we want to be able to alter the list at the lisp level. */) + (void) +{ + Lisp_Object typelist = Qnil; + unsigned long numf; + ExceptionInfo ex; + char **imtypes = GetMagickList ("*", &numf, &ex); + int i; + Lisp_Object Qimagemagicktype; + for (i = 0; i < numf; i++) + { + Qimagemagicktype = intern (imtypes[i]); + typelist = Fcons (Qimagemagicktype, typelist); + } + return typelist; +} + +#endif /* defined (HAVE_IMAGEMAGICK) */ + + /*********************************************************************** SVG @@ -7549,11 +7867,11 @@ gif_load (struct frame *f, struct image *img) /* Function prototypes. */ -static int svg_image_p P_ ((Lisp_Object object)); -static int svg_load P_ ((struct frame *f, struct image *img)); +static int svg_image_p (Lisp_Object object); +static int svg_load (struct frame *f, struct image *img); -static int svg_load_image P_ ((struct frame *, struct image *, - unsigned char *, unsigned int)); +static int svg_load_image (struct frame *, struct image *, + unsigned char *, unsigned int); /* The symbol `svg' identifying images of this type. */ @@ -7618,11 +7936,10 @@ static struct image_type svg_type = identify the SVG format. */ static int -svg_image_p (object) - Lisp_Object object; +svg_image_p (Lisp_Object object) { struct image_keyword fmt[SVG_LAST]; - bcopy (svg_format, fmt, sizeof fmt); + memcpy (fmt, svg_format, sizeof fmt); if (!parse_image_spec (object, fmt, SVG_LAST, Qsvg)) return 0; @@ -7721,9 +8038,7 @@ init_svg_functions (Lisp_Object libraries) the prototype thus needs to be compatible with that structure. */ static int -svg_load (f, img) - struct frame *f; - struct image *img; +svg_load (struct frame *f, struct image *img) { int success_p = 0; Lisp_Object file_name; @@ -7735,14 +8050,11 @@ svg_load (f, img) Lisp_Object file; unsigned char *contents; int size; - struct gcpro gcpro1; file = x_find_image_file (file_name); - GCPRO1 (file); if (!STRINGP (file)) { image_error ("Cannot find image file `%s'", file_name, Qnil); - UNGCPRO; return 0; } @@ -7751,13 +8063,11 @@ svg_load (f, img) if (contents == NULL) { image_error ("Error loading SVG image `%s'", img->spec, Qnil); - UNGCPRO; return 0; } /* If the file was slurped into memory properly, parse it. */ success_p = svg_load_image (f, img, contents, size); xfree (contents); - UNGCPRO; } /* Else its not a file, its a lisp object. Load the image from a lisp object rather than a file. */ @@ -7766,6 +8076,11 @@ svg_load (f, img) Lisp_Object data; data = image_spec_value (img->spec, QCdata, NULL); + if (!STRINGP (data)) + { + image_error ("Invalid image data `%s'", data, Qnil); + return 0; + } success_p = svg_load_image (f, img, SDATA (data), SBYTES (data)); } @@ -7780,15 +8095,10 @@ svg_load (f, img) Returns non-zero when successful. */ static int -svg_load_image (f, img, contents, size) - /* Pointer to emacs frame structure. */ - struct frame *f; - /* Pointer to emacs image structure. */ - struct image *img; - /* String containing the SVG XML data to be parsed. */ - unsigned char *contents; - /* Size of data in bytes. */ - unsigned int size; +svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ + struct image *img, /* Pointer to emacs image structure. */ + unsigned char *contents, /* String containing the SVG XML data to be parsed. */ + unsigned int size) /* Size of data in bytes. */ { RsvgHandle *rsvg_handle; RsvgDimensionData dimension_data; @@ -7863,7 +8173,7 @@ svg_load_image (f, img, contents, size) background.pixel = FRAME_BACKGROUND_PIXEL (f); x_query_color (f, &background); #else - ns_query_color(FRAME_BACKGROUND_COLOR (f), &background, 1); + ns_query_color (FRAME_BACKGROUND_COLOR (f), &background, 1); #endif } @@ -7949,15 +8259,11 @@ svg_load_image (f, img, contents, size) #define HAVE_GHOSTSCRIPT 1 #endif /* HAVE_X_WINDOWS */ -/* The symbol `postscript' identifying images of this type. */ - -Lisp_Object Qpostscript; - #ifdef HAVE_GHOSTSCRIPT -static int gs_image_p P_ ((Lisp_Object object)); -static int gs_load P_ ((struct frame *f, struct image *img)); -static void gs_clear_image P_ ((struct frame *f, struct image *img)); +static int gs_image_p (Lisp_Object object); +static int gs_load (struct frame *f, struct image *img); +static void gs_clear_image (struct frame *f, struct image *img); /* Keyword symbols. */ @@ -8018,9 +8324,7 @@ static struct image_type gs_type = /* Free X resources of Ghostscript image IMG which is used on frame F. */ static void -gs_clear_image (f, img) - struct frame *f; - struct image *img; +gs_clear_image (struct frame *f, struct image *img) { /* IMG->data.ptr_val may contain a recorded colormap. */ xfree (img->data.ptr_val); @@ -8032,14 +8336,13 @@ gs_clear_image (f, img) specification. */ static int -gs_image_p (object) - Lisp_Object object; +gs_image_p (Lisp_Object object) { struct image_keyword fmt[GS_LAST]; Lisp_Object tem; int i; - bcopy (gs_format, fmt, sizeof fmt); + memcpy (fmt, gs_format, sizeof fmt); if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) return 0; @@ -8073,13 +8376,10 @@ gs_image_p (object) if successful. */ static int -gs_load (f, img) - struct frame *f; - struct image *img; +gs_load (struct frame *f, struct image *img) { char buffer[100]; Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width; - struct gcpro gcpro1, gcpro2; Lisp_Object frame; double in_width, in_height; Lisp_Object pixel_colors = Qnil; @@ -8089,10 +8389,10 @@ gs_load (f, img) = 1/72 in, xdpi and ydpi are stored in the frame's X display info. */ pt_width = image_spec_value (img->spec, QCpt_width, NULL); - in_width = XFASTINT (pt_width) / 72.0; + in_width = INTEGERP (pt_width) ? XFASTINT (pt_width) / 72.0 : 0; img->width = in_width * FRAME_X_DISPLAY_INFO (f)->resx; pt_height = image_spec_value (img->spec, QCpt_height, NULL); - in_height = XFASTINT (pt_height) / 72.0; + in_height = INTEGERP (pt_height) ? XFASTINT (pt_height) / 72.0 : 0; img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy; if (!check_image_size (f, img->width, img->height)) @@ -8121,8 +8421,6 @@ gs_load (f, img) if successful. We do not record_unwind_protect here because other places in redisplay like calling window scroll functions don't either. Let the Lisp loader use `unwind-protect' instead. */ - GCPRO2 (window_and_pixmap_id, pixel_colors); - sprintf (buffer, "%lu %lu", (unsigned long) FRAME_X_WINDOW (f), (unsigned long) img->pixmap); @@ -8143,7 +8441,6 @@ gs_load (f, img) make_number (img->height), window_and_pixmap_id, pixel_colors); - UNGCPRO; return PROCESSP (img->data.lisp_val); } @@ -8153,9 +8450,7 @@ gs_load (f, img) telling Emacs that Ghostscript has finished drawing. */ void -x_kill_gs_process (pixmap, f) - Pixmap pixmap; - struct frame *f; +x_kill_gs_process (Pixmap pixmap, struct frame *f) { struct image_cache *c = FRAME_IMAGE_CACHE (f); int class, i; @@ -8253,16 +8548,14 @@ x_kill_gs_process (pixmap, f) DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0, doc: /* Value is non-nil if SPEC is a valid image specification. */) - (spec) - Lisp_Object spec; + (Lisp_Object spec) { return valid_image_p (spec) ? Qt : Qnil; } DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "") - (spec) - Lisp_Object spec; + (Lisp_Object spec) { int id = -1; @@ -8296,9 +8589,8 @@ Return non-nil if TYPE is a supported image type. Image types pbm and xbm are prebuilt; other types are loaded here. Libraries to load are specified in alist LIBRARIES (usually, the value -of `image-library-alist', which see). */) - (type, libraries) - Lisp_Object type, libraries; +of `dynamic-library-alist', which see). */) + (Lisp_Object type, Lisp_Object libraries) { Lisp_Object tested; @@ -8337,6 +8629,16 @@ of `image-library-alist', which see). */) return CHECK_LIB_AVAILABLE (&svg_type, init_svg_functions, libraries); #endif +#if defined (HAVE_IMAGEMAGICK) + if (EQ (type, Qimagemagick)) + { + /* MagickWandGenesis() initializes the imagemagick library. */ + MagickWandGenesis (); + return CHECK_LIB_AVAILABLE (&imagemagick_type, init_imagemagick_functions, + libraries); + } +#endif + #ifdef HAVE_GHOSTSCRIPT if (EQ (type, Qpostscript)) return CHECK_LIB_AVAILABLE (&gs_type, init_gs_functions, libraries); @@ -8348,10 +8650,8 @@ of `image-library-alist', which see). */) } void -syms_of_image () +syms_of_image (void) { - extern Lisp_Object Qrisky_local_variable; /* Syms_of_xdisp has already run. */ - /* Initialize this only once, since that's what we do with Vimage_types and they are supposed to be in sync. Initializing here gives correct operation on GNU/Linux of calling dump-emacs after loading some images. */ @@ -8365,20 +8665,6 @@ Each element of the list is a symbol for an image type, like 'jpeg or 'png. To check whether it is really supported, use `image-type-available-p'. */); Vimage_types = Qnil; - DEFVAR_LISP ("image-library-alist", &Vimage_library_alist, - doc: /* Alist of image types vs external libraries needed to display them. - -Each element is a list (IMAGE-TYPE LIBRARY...), where the car is a symbol -representing a supported image type, and the rest are strings giving -alternate filenames for the corresponding external libraries. - -Emacs tries to load the libraries in the order they appear on the -list; if none is loaded, the running session of Emacs won't -support the image type. Types 'pbm and 'xbm don't need to be -listed; they are always supported. */); - Vimage_library_alist = Qnil; - Fput (intern_c_string ("image-library-alist"), Qrisky_local_variable, Qt); - DEFVAR_LISP ("max-image-size", &Vmax_image_size, doc: /* Maximum size of images. Emacs will not load an image into memory if its pixel width or @@ -8407,6 +8693,8 @@ non-numeric, there is no explicit limit on the size of images. */); Qcount = intern_c_string ("count"); staticpro (&Qcount); + Qextension_data = intern_c_string ("extension-data"); + staticpro (&Qextension_data); QCascent = intern_c_string (":ascent"); staticpro (&QCascent); @@ -8422,6 +8710,12 @@ non-numeric, there is no explicit limit on the size of images. */); staticpro (&QCheuristic_mask); QCindex = intern_c_string (":index"); staticpro (&QCindex); + QCgeometry = intern_c_string (":geometry"); + staticpro (&QCgeometry); + QCcrop = intern_c_string (":crop"); + staticpro (&QCcrop); + QCrotation = intern_c_string (":rotation"); + staticpro (&QCrotation); QCmatrix = intern_c_string (":matrix"); staticpro (&QCmatrix); QCcolor_adjustment = intern_c_string (":color-adjustment"); @@ -8482,6 +8776,12 @@ non-numeric, there is no explicit limit on the size of images. */); ADD_IMAGE_TYPE (Qpng); #endif +#if defined (HAVE_IMAGEMAGICK) + Qimagemagick = intern_c_string ("imagemagick"); + staticpro (&Qimagemagick); + ADD_IMAGE_TYPE (Qimagemagick); +#endif + #if defined (HAVE_RSVG) Qsvg = intern_c_string ("svg"); staticpro (&Qsvg); @@ -8498,11 +8798,14 @@ non-numeric, there is no explicit limit on the size of images. */); #endif /* HAVE_RSVG */ defsubr (&Sinit_image_library); +#ifdef HAVE_IMAGEMAGICK + defsubr (&Simagemagick_types); +#endif defsubr (&Sclear_image_cache); - defsubr (&Simage_refresh); + defsubr (&Simage_flush); defsubr (&Simage_size); defsubr (&Simage_mask_p); - defsubr (&Simage_extension_data); + defsubr (&Simage_metadata); #if GLYPH_DEBUG defsubr (&Simagep); @@ -8520,15 +8823,23 @@ A cross is always drawn on black & white displays. */); Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS); DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay, - doc: /* Time after which cached images are removed from the cache. -When an image has not been displayed this many seconds, remove it -from the image cache. Value must be an integer or nil with nil -meaning don't clear the cache. */); - Vimage_cache_eviction_delay = make_number (30 * 60); + doc: /* Maximum time after which images are removed from the cache. +When an image has not been displayed this many seconds, Emacs +automatically removes it from the image cache. If the cache contains +a large number of images, the actual eviction time may be shorter. +The value can also be nil, meaning the cache is never cleared. + +The function `clear-image-cache' disregards this variable. */); + Vimage_cache_eviction_delay = make_number (300); +#ifdef HAVE_IMAGEMAGICK + DEFVAR_LISP ("imagemagick-render-type", &Vimagemagick_render_type, + doc: /* Choose between ImageMagick render methods. */); +#endif + } void -init_image () +init_image (void) { } diff --git a/src/indent.c b/src/indent.c index a7f41f7e8e4..affcc222f0b 100644 --- a/src/indent.c +++ b/src/indent.c @@ -61,8 +61,8 @@ EMACS_INT last_known_column_point; static int last_known_column_modified; -static double current_column_1 P_ ((void)); -static double position_indentation P_ ((int)); +static double current_column_1 (void); +static double position_indentation (int); /* Cache of beginning of line found by the last call of current_column. */ @@ -72,7 +72,7 @@ static EMACS_INT current_column_bol_cache; /* Get the display table to use for the current buffer. */ struct Lisp_Char_Table * -buffer_display_table () +buffer_display_table (void) { Lisp_Object thisbuf; @@ -89,9 +89,7 @@ buffer_display_table () /* Return the width of character C under display table DP. */ static int -character_width (c, dp) - int c; - struct Lisp_Char_Table *dp; +character_width (int c, struct Lisp_Char_Table *dp) { Lisp_Object elt; @@ -125,9 +123,7 @@ character_width (c, dp) invalidate the buffer's width_run_cache. */ int -disptab_matches_widthtab (disptab, widthtab) - struct Lisp_Char_Table *disptab; - struct Lisp_Vector *widthtab; +disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *widthtab) { int i; @@ -145,9 +141,7 @@ disptab_matches_widthtab (disptab, widthtab) /* Recompute BUF's width table, using the display table DISPTAB. */ void -recompute_width_table (buf, disptab) - struct buffer *buf; - struct Lisp_Char_Table *disptab; +recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab) { int i; struct Lisp_Vector *widthtab; @@ -166,7 +160,7 @@ recompute_width_table (buf, disptab) state of current_buffer's cache_long_line_scans variable. */ static void -width_run_cache_on_off () +width_run_cache_on_off (void) { if (NILP (current_buffer->cache_long_line_scans) /* And, for the moment, this feature doesn't work on multibyte @@ -217,11 +211,7 @@ width_run_cache_on_off () will equal the return value. */ EMACS_INT -skip_invisible (pos, next_boundary_p, to, window) - EMACS_INT pos; - EMACS_INT *next_boundary_p; - EMACS_INT to; - Lisp_Object window; +skip_invisible (EMACS_INT pos, EMACS_INT *next_boundary_p, EMACS_INT to, Lisp_Object window) { Lisp_Object prop, position, overlay_limit, proplimit; Lisp_Object buffer, tmp; @@ -322,7 +312,7 @@ Whether the line is visible (if `selective-display' is t) has no effect; however, ^M is treated as end of line when `selective-display' is t. Text that has an invisible property is considered as having width 0, unless `buffer-invisibility-spec' specifies that it is replaced by an ellipsis. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, (int) current_column ()); /* iftc */ @@ -332,13 +322,13 @@ Text that has an invisible property is considered as having width 0, unless /* Cancel any recorded value of the horizontal position. */ void -invalidate_current_column () +invalidate_current_column (void) { last_known_column_point = 0; } double -current_column () +current_column (void) { register int col; register unsigned char *ptr, *stop; @@ -479,7 +469,6 @@ current_column () return col; } -extern Lisp_Object Qspace, QCwidth, QCalign_to; /* Check the presence of a display property and compute its width. If a property was found and its width was found as well, return @@ -506,7 +495,7 @@ check_display_width (EMACS_INT pos, EMACS_INT col, EMACS_INT *endpos) width = XINT (prop) - col; else if (FLOATP (prop)) width = (int)(XFLOAT_DATA (prop) + 0.5) - col; - + if (width >= 0) { EMACS_INT start; @@ -556,7 +545,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) w = ! NILP (window) ? XWINDOW (window) : NULL; if (tab_width <= 0 || tab_width > 1000) tab_width = 8; - bzero (&cmp_it, sizeof cmp_it); + memset (&cmp_it, 0, sizeof cmp_it); cmp_it.id = -1; composition_compute_stop_pos (&cmp_it, scan, scan_byte, end, Qnil); @@ -628,7 +617,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) to this character. */ if (dp != 0 - && ! (multibyte && BASE_LEADING_CODE_P (c)) + && ! (multibyte && LEADING_CODE_P (c)) && VECTORP (DISP_CHAR_VECTOR (dp, c))) { Lisp_Object charvec; @@ -679,7 +668,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) col += tab_width; col = col / tab_width * tab_width; } - else if (multibyte && BASE_LEADING_CODE_P (c)) + else if (multibyte && LEADING_CODE_P (c)) { /* Start of multi-byte form. */ unsigned char *ptr; @@ -723,7 +712,7 @@ scan_for_column (EMACS_INT *endpos, EMACS_INT *goalcol, EMACS_INT *prevcol) due to text properties or overlays. */ static double -current_column_1 () +current_column_1 (void) { EMACS_INT col = MOST_POSITIVE_FIXNUM; EMACS_INT opoint = PT; @@ -822,8 +811,7 @@ Optional second argument MINIMUM says always do at least MINIMUM spaces even if that goes past COLUMN; by default, MINIMUM is zero. The return value is COLUMN. */) - (column, minimum) - Lisp_Object column, minimum; + (Lisp_Object column, Lisp_Object minimum) { int mincol; register int fromcol; @@ -867,17 +855,17 @@ The return value is COLUMN. */) } -static double position_indentation P_ ((int)); +static double position_indentation (int); DEFUN ("current-indentation", Fcurrent_indentation, Scurrent_indentation, 0, 0, 0, doc: /* Return the indentation of the current line. This is the horizontal position of the character following any initial whitespace. */) - () + (void) { Lisp_Object val; - int opoint = PT, opoint_byte = PT_BYTE; + EMACS_INT opoint = PT, opoint_byte = PT_BYTE; scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); @@ -887,8 +875,7 @@ following any initial whitespace. */) } static double -position_indentation (pos_byte) - register int pos_byte; +position_indentation (register int pos_byte) { register EMACS_INT column = 0; register EMACS_INT tab_width = XINT (current_buffer->tab_width); @@ -977,12 +964,10 @@ position_indentation (pos_byte) preceding line. */ int -indented_beyond_p (pos, pos_byte, column) - int pos, pos_byte; - double column; +indented_beyond_p (EMACS_INT pos, EMACS_INT pos_byte, double column) { double val; - int opoint = PT, opoint_byte = PT_BYTE; + EMACS_INT opoint = PT, opoint_byte = PT_BYTE; SET_PT_BOTH (pos, pos_byte); while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') @@ -1011,8 +996,7 @@ In addition, if FORCE is t, and the line is too short to reach COLUMN, add spaces/tabs to get there. The return value is the current column. */) - (column, force) - Lisp_Object column, force; + (Lisp_Object column, Lisp_Object force) { EMACS_INT pos; EMACS_INT col, prev_col; @@ -1137,12 +1121,7 @@ struct position val_compute_motion; the scroll bars if they are turned on. */ struct position * -compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win) - EMACS_INT from, fromvpos, fromhpos, to, tovpos, tohpos; - int did_motion; - EMACS_INT width; - EMACS_INT hscroll, tab_offset; - struct window *win; +compute_motion (EMACS_INT from, EMACS_INT fromvpos, EMACS_INT fromhpos, int did_motion, EMACS_INT to, EMACS_INT tovpos, EMACS_INT tohpos, EMACS_INT width, EMACS_INT hscroll, EMACS_INT tab_offset, struct window *win) { register EMACS_INT hpos = fromhpos; register EMACS_INT vpos = fromvpos; @@ -1232,7 +1211,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, pos_byte = prev_pos_byte = CHAR_TO_BYTE (from); contin_hpos = 0; prev_tab_offset = tab_offset; - bzero (&cmp_it, sizeof cmp_it); + memset (&cmp_it, 0, sizeof cmp_it); cmp_it.id = -1; composition_compute_stop_pos (&cmp_it, pos, pos_byte, to, Qnil); @@ -1275,7 +1254,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, to be changed here. */ { unsigned char *ovstr; - int ovlen = overlay_strings (pos, win, &ovstr); + EMACS_INT ovlen = overlay_strings (pos, win, &ovstr); hpos += ((multibyte && ovlen > 0) ? strwidth (ovstr, ovlen) : ovlen); } @@ -1469,7 +1448,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, the text character-by-character. */ if (current_buffer->width_run_cache && pos >= next_width_run) { - int run_end; + EMACS_INT run_end; int common_width = region_cache_forward (current_buffer, current_buffer->width_run_cache, @@ -1480,7 +1459,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, want to skip over it for some other reason. */ if (common_width != 0) { - int run_end_hpos; + EMACS_INT run_end_hpos; /* Don't go past the final buffer posn the user requested. */ @@ -1577,7 +1556,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, } if (dp != 0 - && ! (multibyte && BASE_LEADING_CODE_P (c)) + && ! (multibyte && LEADING_CODE_P (c)) && VECTORP (DISP_CHAR_VECTOR (dp, c))) { charvec = DISP_CHAR_VECTOR (dp, c); @@ -1683,7 +1662,7 @@ compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hpos = width; } } - else if (multibyte && BASE_LEADING_CODE_P (c)) + else if (multibyte && LEADING_CODE_P (c)) { /* Start of multi-byte form. */ unsigned char *ptr; @@ -1775,9 +1754,7 @@ of a certain window, pass the window's starting location as FROM and the window's upper-left coordinates as FROMPOS. Pass the buffer's (point-max) as TO, to limit the scan to the end of the visible section of the buffer, and pass LINE and COL as TOPOS. */) - (from, frompos, to, topos, width, offsets, window) - Lisp_Object from, frompos, to, topos; - Lisp_Object width, offsets, window; + (Lisp_Object from, Lisp_Object frompos, Lisp_Object to, Lisp_Object topos, Lisp_Object width, Lisp_Object offsets, Lisp_Object window) { struct window *w; Lisp_Object bufpos, hpos, vpos, prevhpos; @@ -1856,9 +1833,7 @@ visible section of the buffer, and pass LINE and COL as TOPOS. */) struct position val_vmotion; struct position * -vmotion (from, vtarget, w) - register EMACS_INT from, vtarget; - struct window *w; +vmotion (register EMACS_INT from, register EMACS_INT vtarget, struct window *w) { EMACS_INT hscroll = XINT (w->hscroll); struct position pos; @@ -2021,8 +1996,7 @@ regardless of which buffer is displayed in WINDOW. This is consistent with other cursor motion functions and makes it possible to use `vertical-motion' in any buffer, whether or not it is currently displayed in some window. */) - (lines, window) - Lisp_Object lines, window; + (Lisp_Object lines, Lisp_Object window) { struct it it; struct text_pos pt; @@ -2183,7 +2157,7 @@ whether or not it is currently displayed in some window. */) /* File's initialization. */ void -syms_of_indent () +syms_of_indent (void) { DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode, doc: /* *Indentation can insert tabs if this is non-nil. */); diff --git a/src/indent.h b/src/indent.h index 4d9dbf2d7ff..394d7216b4f 100644 --- a/src/indent.h +++ b/src/indent.h @@ -49,16 +49,16 @@ struct position EMACS_INT tab_offset; }; -struct position *compute_motion P_ ((EMACS_INT from, EMACS_INT fromvpos, - EMACS_INT fromhpos, int did_motion, - EMACS_INT to, EMACS_INT tovpos, - EMACS_INT tohpos, - EMACS_INT width, EMACS_INT hscroll, - EMACS_INT tab_offset, struct window *)); -struct position *vmotion P_ ((EMACS_INT from, EMACS_INT vtarget, - struct window *)); -EMACS_INT skip_invisible P_ ((EMACS_INT pos, EMACS_INT *next_boundary_p, - EMACS_INT to, Lisp_Object window)); +struct position *compute_motion (EMACS_INT from, EMACS_INT fromvpos, + EMACS_INT fromhpos, int did_motion, + EMACS_INT to, EMACS_INT tovpos, + EMACS_INT tohpos, + EMACS_INT width, EMACS_INT hscroll, + EMACS_INT tab_offset, struct window *); +struct position *vmotion (EMACS_INT from, EMACS_INT vtarget, + struct window *); +EMACS_INT skip_invisible (EMACS_INT pos, EMACS_INT *next_boundary_p, + EMACS_INT to, Lisp_Object window); /* Value of point when current_column was called */ extern EMACS_INT last_known_column_point; @@ -68,12 +68,12 @@ extern EMACS_INT last_known_column_point; /* Return true if the display table DISPTAB specifies the same widths for characters as WIDTHTAB. We use this to decide when to invalidate the buffer's column_cache. */ -int disptab_matches_widthtab P_ ((struct Lisp_Char_Table *disptab, - struct Lisp_Vector *widthtab)); +int disptab_matches_widthtab (struct Lisp_Char_Table *disptab, + struct Lisp_Vector *widthtab); /* Recompute BUF's width table, using the display table DISPTAB. */ -void recompute_width_table P_ ((struct buffer *buf, - struct Lisp_Char_Table *disptab)); +void recompute_width_table (struct buffer *buf, + struct Lisp_Char_Table *disptab); /* arch-tag: f9feb373-5bff-4f4f-9198-94805d00cfd7 diff --git a/src/insdel.c b/src/insdel.c index ededd597b0d..abe6f350585 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -51,10 +51,10 @@ static void adjust_markers_for_replace (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT); static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes); -Lisp_Object Fcombine_after_change_execute (); +Lisp_Object Fcombine_after_change_execute (void); /* Non-nil means don't call the after-change-functions right away, - just record an element in Vcombine_after_change_calls_list. */ + just record an element in combine_after_change_list. */ Lisp_Object Vcombine_after_change_calls; /* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT) @@ -74,6 +74,8 @@ Lisp_Object combine_after_change_buffer; Lisp_Object Qinhibit_modification_hooks; +extern Lisp_Object Vselect_active_regions, Vsaved_region_selection, Qonly; + /* Check all markers in the current buffer, looking for something invalid. */ @@ -85,7 +87,7 @@ static int check_markers_debug_flag; else void -check_markers () +check_markers (void) { register struct Lisp_Marker *tail; int multibyte = ! NILP (current_buffer->enable_multibyte_characters); @@ -164,28 +166,9 @@ gap_left (EMACS_INT charpos, EMACS_INT bytepos, int newgap) /* Move at most 32000 chars before checking again for a quit. */ if (i > 32000) i = 32000; -#ifdef GAP_USE_BCOPY - if (i >= 128 - /* bcopy is safe if the two areas of memory do not overlap - or on systems where bcopy is always safe for moving upward. */ - && (BCOPY_UPWARD_SAFE - || to - from >= 128)) - { - /* If overlap is not safe, avoid it by not moving too many - characters at once. */ - if (!BCOPY_UPWARD_SAFE && i > to - from) - i = to - from; - new_s1 -= i; - from -= i, to -= i; - bcopy (from, to, i); - } - else -#endif - { - new_s1 -= i; - while (--i >= 0) - *--to = *--from; - } + new_s1 -= i; + from -= i, to -= i; + memmove (to, from, i); } /* Adjust markers, and buffer data structure, to put the gap at BYTEPOS. @@ -238,28 +221,9 @@ gap_right (EMACS_INT charpos, EMACS_INT bytepos) /* Move at most 32000 chars before checking again for a quit. */ if (i > 32000) i = 32000; -#ifdef GAP_USE_BCOPY - if (i >= 128 - /* bcopy is safe if the two areas of memory do not overlap - or on systems where bcopy is always safe for moving downward. */ - && (BCOPY_DOWNWARD_SAFE - || from - to >= 128)) - { - /* If overlap is not safe, avoid it by not moving too many - characters at once. */ - if (!BCOPY_DOWNWARD_SAFE && i > from - to) - i = from - to; - new_s1 += i; - bcopy (from, to, i); - from += i, to += i; - } - else -#endif - { - new_s1 += i; - while (--i >= 0) - *to++ = *from++; - } + new_s1 += i; + memmove (to, from, i); + from += i, to += i; } adjust_markers_gap_motion (GPT_BYTE + GAP_SIZE, bytepos + GAP_SIZE, @@ -437,7 +401,7 @@ adjust_markers_for_insert (EMACS_INT from, EMACS_INT from_byte, } /* Adjusting only markers whose insertion-type is t may result in - - disordered start and end in overlays, and + - disordered start and end in overlays, and - disordered overlays in the slot `overlays_before' of current_buffer. */ if (adjusted) { @@ -585,7 +549,7 @@ make_gap_smaller (EMACS_INT nbytes_removed) /* Pretend that the last unwanted part of the gap is the entire gap, and that the first desired part of the gap is part of the buffer text. */ - bzero (GPT_ADDR, new_gap_size); + memset (GPT_ADDR, 0, new_gap_size); GPT += new_gap_size; GPT_BYTE += new_gap_size; Z += new_gap_size; @@ -636,7 +600,7 @@ copy_text (const unsigned char *from_addr, unsigned char *to_addr, { if (from_multibyte == to_multibyte) { - bcopy (from_addr, to_addr, nbytes); + memcpy (to_addr, from_addr, nbytes); return nbytes; } else if (from_multibyte) @@ -843,7 +807,7 @@ count_combining_before (const unsigned char *string, EMACS_INT length, len = 1; p = BYTE_POS_ADDR (pos_byte - 1); while (! CHAR_HEAD_P (*p)) p--, len++; - if (! BASE_LEADING_CODE_P (*p)) /* case (3) */ + if (! LEADING_CODE_P (*p)) /* case (3) */ return 0; combining_bytes = BYTES_BY_CHAR_HEAD (*p) - len; @@ -906,7 +870,7 @@ count_combining_after (const unsigned char *string, i = pos_byte - 2; while (i >= 0 && ! CHAR_HEAD_P (p[i])) i--; - if (i < 0 || !BASE_LEADING_CODE_P (p[i])) + if (i < 0 || !LEADING_CODE_P (p[i])) return 0; bytes = BYTES_BY_CHAR_HEAD (p[i]); @@ -914,7 +878,7 @@ count_combining_after (const unsigned char *string, ? 0 : bytes - (pos_byte - 1 - i + length)); } - if (!BASE_LEADING_CODE_P (string[i])) + if (!LEADING_CODE_P (string[i])) return 0; bytes = BYTES_BY_CHAR_HEAD (string[i]) - (length - i); @@ -966,7 +930,7 @@ insert_1_both (const unsigned char *string, MODIFF++; CHARS_MODIFF = MODIFF; - bcopy (string, GPT_ADDR, nbytes); + memcpy (GPT_ADDR, string, nbytes); GAP_SIZE -= nbytes; GPT += nchars; @@ -1007,7 +971,7 @@ insert_1_both (const unsigned char *string, copy them into the buffer. It does not work to use `insert' for this, because a GC could happen - before we bcopy the stuff into the buffer, and relocate the string + before we copy the stuff into the buffer, and relocate the string without insert noticing. */ void @@ -1182,7 +1146,7 @@ insert_from_gap (EMACS_INT nchars, EMACS_INT nbytes) into the current buffer. It does not work to use `insert' for this, because a malloc could happen - and relocate BUF's text before the bcopy happens. */ + and relocate BUF's text before the copy happens. */ void insert_from_buffer (struct buffer *buf, @@ -1666,7 +1630,7 @@ replace_range (EMACS_INT from, EMACS_INT to, Lisp_Object new, void replace_range_2 (EMACS_INT from, EMACS_INT from_byte, EMACS_INT to, EMACS_INT to_byte, - char *ins, EMACS_INT inschars, EMACS_INT insbytes, + const char *ins, EMACS_INT inschars, EMACS_INT insbytes, int markers) { EMACS_INT nbytes_del, nchars_del; @@ -1712,7 +1676,7 @@ replace_range_2 (EMACS_INT from, EMACS_INT from_byte, make_gap (insbytes - GAP_SIZE); /* Copy the replacement text into the buffer. */ - bcopy (ins, GPT_ADDR, insbytes); + memcpy (GPT_ADDR, ins, insbytes); #ifdef BYTE_COMBINING_DEBUG /* We have copied text into the gap, but we have not marked @@ -2085,6 +2049,23 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end, base_buffer->filename); #endif /* not CLASH_DETECTION */ + /* If `select-active-regions' is non-nil, save the region text. */ + if (!NILP (current_buffer->mark_active) + && XMARKER (current_buffer->mark)->buffer + && NILP (Vsaved_region_selection) + && (EQ (Vselect_active_regions, Qonly) + ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) + : (!NILP (Vselect_active_regions) + && !NILP (Vtransient_mark_mode)))) + { + EMACS_INT b = XMARKER (current_buffer->mark)->charpos; + EMACS_INT e = PT; + if (b < e) + Vsaved_region_selection = make_buffer_string (b, e, 0); + else if (b > e) + Vsaved_region_selection = make_buffer_string (e, b, 0); + } + signal_before_change (start, end, preserve_ptr); if (current_buffer->newline_cache) @@ -2132,8 +2113,7 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end, NO-ERROR-FLAG is nil if there was an error, anything else meaning no error (so this function does nothing). */ Lisp_Object -reset_var_on_error (val) - Lisp_Object val; +reset_var_on_error (Lisp_Object val) { if (NILP (XCDR (val))) Fset (XCAR (val), Qnil); @@ -2297,8 +2277,7 @@ signal_after_change (EMACS_INT charpos, EMACS_INT lendel, EMACS_INT lenins) } Lisp_Object -Fcombine_after_change_execute_1 (val) - Lisp_Object val; +Fcombine_after_change_execute_1 (Lisp_Object val) { Vcombine_after_change_calls = val; return val; @@ -2307,7 +2286,7 @@ Fcombine_after_change_execute_1 (val) DEFUN ("combine-after-change-execute", Fcombine_after_change_execute, Scombine_after_change_execute, 0, 0, 0, doc: /* This function is for use internally in `combine-after-change-calls'. */) - () + (void) { int count = SPECPDL_INDEX (); EMACS_INT beg, end, change; @@ -2390,7 +2369,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute, } void -syms_of_insdel () +syms_of_insdel (void) { staticpro (&combine_after_change_list); staticpro (&combine_after_change_buffer); diff --git a/src/intervals.c b/src/intervals.c index 9836f763489..5e08e13d23b 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -52,9 +52,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set)) -Lisp_Object merge_properties_sticky (); -static INTERVAL reproduce_tree P_ ((INTERVAL, INTERVAL)); -static INTERVAL reproduce_tree_obj P_ ((INTERVAL, Lisp_Object)); +Lisp_Object merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright); +static INTERVAL reproduce_tree (INTERVAL, INTERVAL); +static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object); /* Utility functions for intervals. */ @@ -62,8 +62,7 @@ static INTERVAL reproduce_tree_obj P_ ((INTERVAL, Lisp_Object)); /* Create the root interval of some object, a buffer or string. */ INTERVAL -create_root_interval (parent) - Lisp_Object parent; +create_root_interval (Lisp_Object parent) { INTERVAL new; @@ -95,8 +94,7 @@ create_root_interval (parent) /* Make the interval TARGET have exactly the properties of SOURCE */ void -copy_properties (source, target) - register INTERVAL source, target; +copy_properties (register INTERVAL source, register INTERVAL target) { if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target)) return; @@ -110,8 +108,7 @@ copy_properties (source, target) is added to TARGET if TARGET has no such property as yet. */ static void -merge_properties (source, target) - register INTERVAL source, target; +merge_properties (register INTERVAL source, register INTERVAL target) { register Lisp_Object o, sym, val; @@ -149,8 +146,7 @@ merge_properties (source, target) 0 otherwise. */ int -intervals_equal (i0, i1) - INTERVAL i0, i1; +intervals_equal (INTERVAL i0, INTERVAL i1) { register Lisp_Object i0_cdr, i0_sym; register Lisp_Object i1_cdr, i1_val; @@ -206,10 +202,7 @@ intervals_equal (i0, i1) Pass FUNCTION two args: an interval, and ARG. */ void -traverse_intervals_noorder (tree, function, arg) - INTERVAL tree; - void (* function) P_ ((INTERVAL, Lisp_Object)); - Lisp_Object arg; +traverse_intervals_noorder (INTERVAL tree, void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg) { /* Minimize stack usage. */ while (!NULL_INTERVAL_P (tree)) @@ -229,11 +222,8 @@ traverse_intervals_noorder (tree, function, arg) Pass FUNCTION two args: an interval, and ARG. */ void -traverse_intervals (tree, position, function, arg) - INTERVAL tree; - int position; - void (* function) P_ ((INTERVAL, Lisp_Object)); - Lisp_Object arg; +traverse_intervals (INTERVAL tree, EMACS_INT position, + void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg) { while (!NULL_INTERVAL_P (tree)) { @@ -323,12 +313,11 @@ root_interval (interval) */ static INLINE INTERVAL -rotate_right (interval) - INTERVAL interval; +rotate_right (INTERVAL interval) { INTERVAL i; INTERVAL B = interval->left; - int old_total = interval->total_length; + EMACS_INT old_total = interval->total_length; /* Deal with any Parent of A; make it point to B. */ if (! ROOT_INTERVAL_P (interval)) @@ -371,12 +360,11 @@ rotate_right (interval) */ static INLINE INTERVAL -rotate_left (interval) - INTERVAL interval; +rotate_left (INTERVAL interval) { INTERVAL i; INTERVAL B = interval->right; - int old_total = interval->total_length; + EMACS_INT old_total = interval->total_length; /* Deal with any parent of A; make it point to B. */ if (! ROOT_INTERVAL_P (interval)) @@ -413,10 +401,9 @@ rotate_left (interval) themselves are already balanced. */ static INTERVAL -balance_an_interval (i) - INTERVAL i; +balance_an_interval (INTERVAL i) { - register int old_diff, new_diff; + register EMACS_INT old_diff, new_diff; while (1) { @@ -451,8 +438,7 @@ balance_an_interval (i) Lisp Object. */ static INLINE INTERVAL -balance_possible_root_interval (interval) - register INTERVAL interval; +balance_possible_root_interval (register INTERVAL interval) { Lisp_Object parent; int have_parent = 0; @@ -482,8 +468,7 @@ balance_possible_root_interval (interval) (the amount of text). */ static INTERVAL -balance_intervals_internal (tree) - register INTERVAL tree; +balance_intervals_internal (register INTERVAL tree) { /* Balance within each side. */ if (tree->left) @@ -496,8 +481,7 @@ balance_intervals_internal (tree) /* Advertised interface to balance intervals. */ INTERVAL -balance_intervals (tree) - INTERVAL tree; +balance_intervals (INTERVAL tree) { if (tree == NULL_INTERVAL) return NULL_INTERVAL; @@ -519,13 +503,11 @@ balance_intervals (tree) it is still a root after this operation. */ INTERVAL -split_interval_right (interval, offset) - INTERVAL interval; - int offset; +split_interval_right (INTERVAL interval, EMACS_INT offset) { INTERVAL new = make_interval (); - int position = interval->position; - int new_length = LENGTH (interval) - offset; + EMACS_INT position = interval->position; + EMACS_INT new_length = LENGTH (interval) - offset; new->position = position + offset; SET_INTERVAL_PARENT (new, interval); @@ -566,12 +548,10 @@ split_interval_right (interval, offset) it is still a root after this operation. */ INTERVAL -split_interval_left (interval, offset) - INTERVAL interval; - int offset; +split_interval_left (INTERVAL interval, EMACS_INT offset) { INTERVAL new = make_interval (); - int new_length = offset; + EMACS_INT new_length = offset; new->position = interval->position; interval->position = interval->position + offset; @@ -608,8 +588,7 @@ split_interval_left (interval, offset) of another interval! */ int -interval_start_pos (source) - INTERVAL source; +interval_start_pos (INTERVAL source) { Lisp_Object parent; @@ -635,13 +614,11 @@ interval_start_pos (source) will update this cache based on the result of find_interval. */ INTERVAL -find_interval (tree, position) - register INTERVAL tree; - register int position; +find_interval (register INTERVAL tree, register EMACS_INT position) { /* The distance from the left edge of the subtree at TREE to POSITION. */ - register int relative_position; + register EMACS_INT relative_position; if (NULL_INTERVAL_P (tree)) return NULL_INTERVAL; @@ -691,11 +668,10 @@ find_interval (tree, position) find_interval). */ INTERVAL -next_interval (interval) - register INTERVAL interval; +next_interval (register INTERVAL interval) { register INTERVAL i = interval; - register int next_position; + register EMACS_INT next_position; if (NULL_INTERVAL_P (i)) return NULL_INTERVAL; @@ -731,8 +707,7 @@ next_interval (interval) find_interval). */ INTERVAL -previous_interval (interval) - register INTERVAL interval; +previous_interval (register INTERVAL interval) { register INTERVAL i; @@ -771,9 +746,7 @@ previous_interval (interval) To speed up the process, we assume that the ->position of I and all its parents is already uptodate. */ INTERVAL -update_interval (i, pos) - register INTERVAL i; - int pos; +update_interval (register INTERVAL i, EMACS_INT pos) { if (NULL_INTERVAL_P (i)) return NULL_INTERVAL; @@ -892,15 +865,14 @@ adjust_intervals_for_insertion (tree, position, length) this text, and make it have the merged properties of both ends. */ static INTERVAL -adjust_intervals_for_insertion (tree, position, length) - INTERVAL tree; - int position, length; +adjust_intervals_for_insertion (INTERVAL tree, + EMACS_INT position, EMACS_INT length) { register INTERVAL i; register INTERVAL temp; int eobp = 0; Lisp_Object parent; - int offset; + EMACS_INT offset; if (TOTAL_LENGTH (tree) == 0) /* Paranoia */ abort (); @@ -1119,8 +1091,7 @@ FR 8 9 A B */ Lisp_Object -merge_properties_sticky (pleft, pright) - Lisp_Object pleft, pright; +merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright) { register Lisp_Object props, front, rear; Lisp_Object lfront, lrear, rfront, rrear; @@ -1256,11 +1227,10 @@ merge_properties_sticky (pleft, pright) storing the resulting subtree into its parent. */ static INTERVAL -delete_node (i) - register INTERVAL i; +delete_node (register INTERVAL i) { register INTERVAL migrate, this; - register int migrate_amt; + register EMACS_INT migrate_amt; if (NULL_INTERVAL_P (i->left)) return i->right; @@ -1290,11 +1260,10 @@ delete_node (i) for the length of I. */ void -delete_interval (i) - register INTERVAL i; +delete_interval (register INTERVAL i) { register INTERVAL parent; - int amt = LENGTH (i); + EMACS_INT amt = LENGTH (i); if (amt > 0) /* Only used on zero-length intervals now. */ abort (); @@ -1344,12 +1313,11 @@ delete_interval (i) Do this by recursing down TREE to the interval in question, and deleting the appropriate amount of text. */ -static int -interval_deletion_adjustment (tree, from, amount) - register INTERVAL tree; - register int from, amount; +static EMACS_INT +interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from, + register EMACS_INT amount) { - register int relative_position = from; + register EMACS_INT relative_position = from; if (NULL_INTERVAL_P (tree)) return 0; @@ -1357,9 +1325,9 @@ interval_deletion_adjustment (tree, from, amount) /* Left branch */ if (relative_position < LEFT_TOTAL_LENGTH (tree)) { - int subtract = interval_deletion_adjustment (tree->left, - relative_position, - amount); + EMACS_INT subtract = interval_deletion_adjustment (tree->left, + relative_position, + amount); tree->total_length -= subtract; CHECK_TOTAL_LENGTH (tree); return subtract; @@ -1368,7 +1336,7 @@ interval_deletion_adjustment (tree, from, amount) else if (relative_position >= (TOTAL_LENGTH (tree) - RIGHT_TOTAL_LENGTH (tree))) { - int subtract; + EMACS_INT subtract; relative_position -= (tree->total_length - RIGHT_TOTAL_LENGTH (tree)); @@ -1383,9 +1351,9 @@ interval_deletion_adjustment (tree, from, amount) else { /* How much can we delete from this interval? */ - int my_amount = ((tree->total_length - - RIGHT_TOTAL_LENGTH (tree)) - - relative_position); + EMACS_INT my_amount = ((tree->total_length + - RIGHT_TOTAL_LENGTH (tree)) + - relative_position); if (amount > my_amount) amount = my_amount; @@ -1407,14 +1375,13 @@ interval_deletion_adjustment (tree, from, amount) buffer position, i.e. origin 1). */ static void -adjust_intervals_for_deletion (buffer, start, length) - struct buffer *buffer; - int start, length; +adjust_intervals_for_deletion (struct buffer *buffer, + EMACS_INT start, EMACS_INT length) { - register int left_to_delete = length; + register EMACS_INT left_to_delete = length; register INTERVAL tree = BUF_INTERVALS (buffer); Lisp_Object parent; - int offset; + EMACS_INT offset; GET_INTERVAL_OBJECT (parent, tree); offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0); @@ -1460,9 +1427,7 @@ adjust_intervals_for_deletion (buffer, start, length) of LENGTH. */ INLINE void -offset_intervals (buffer, start, length) - struct buffer *buffer; - int start, length; +offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) { if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) return; @@ -1483,10 +1448,9 @@ offset_intervals (buffer, start, length) interval. */ INTERVAL -merge_interval_right (i) - register INTERVAL i; +merge_interval_right (register INTERVAL i) { - register int absorb = LENGTH (i); + register EMACS_INT absorb = LENGTH (i); register INTERVAL successor; /* Zero out this interval. */ @@ -1540,10 +1504,9 @@ merge_interval_right (i) The caller must verify that this is not the first (leftmost) interval. */ INTERVAL -merge_interval_left (i) - register INTERVAL i; +merge_interval_left (register INTERVAL i) { - register int absorb = LENGTH (i); + register EMACS_INT absorb = LENGTH (i); register INTERVAL predecessor; /* Zero out this interval. */ @@ -1595,12 +1558,11 @@ merge_interval_left (i) the pointers of the copy. */ static INTERVAL -reproduce_tree (source, parent) - INTERVAL source, parent; +reproduce_tree (INTERVAL source, INTERVAL parent) { register INTERVAL t = make_interval (); - bcopy (source, t, INTERVAL_SIZE); + memcpy (t, source, INTERVAL_SIZE); copy_properties (source, t); SET_INTERVAL_PARENT (t, parent); if (! NULL_LEFT_CHILD (source)) @@ -1612,13 +1574,11 @@ reproduce_tree (source, parent) } static INTERVAL -reproduce_tree_obj (source, parent) - INTERVAL source; - Lisp_Object parent; +reproduce_tree_obj (INTERVAL source, Lisp_Object parent) { register INTERVAL t = make_interval (); - bcopy (source, t, INTERVAL_SIZE); + memcpy (t, source, INTERVAL_SIZE); copy_properties (source, t); SET_INTERVAL_OBJECT (t, parent); if (! NULL_LEFT_CHILD (source)) @@ -1642,7 +1602,7 @@ reproduce_tree_obj (source, parent) static INTERVAL make_new_interval (intervals, start, length) INTERVAL intervals; - int start, length; + EMACS_INT start, length; { INTERVAL slot; @@ -1714,15 +1674,13 @@ make_new_interval (intervals, start, length) text... */ void -graft_intervals_into_buffer (source, position, length, buffer, inherit) - INTERVAL source; - int position, length; - struct buffer *buffer; - int inherit; +graft_intervals_into_buffer (INTERVAL source, EMACS_INT position, + EMACS_INT length, struct buffer *buffer, + int inherit) { register INTERVAL under, over, this, prev; register INTERVAL tree; - int over_used; + EMACS_INT over_used; tree = BUF_INTERVALS (buffer); @@ -1876,18 +1834,13 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) and for PROP appearing on the default-text-properties list. */ Lisp_Object -textget (plist, prop) - Lisp_Object plist; - register Lisp_Object prop; +textget (Lisp_Object plist, register Lisp_Object prop) { return lookup_char_property (plist, prop, 1); } Lisp_Object -lookup_char_property (plist, prop, textprop) - Lisp_Object plist; - register Lisp_Object prop; - int textprop; +lookup_char_property (Lisp_Object plist, register Lisp_Object prop, int textprop) { register Lisp_Object tail, fallback = Qnil; @@ -1973,9 +1926,9 @@ set_point (EMACS_INT charpos) Note that `stickiness' is determined by overlay marker insertion types, if the invisible property comes from an overlay. */ -static int -adjust_for_invis_intang (pos, test_offs, adj, test_intang) - int pos, test_offs, adj, test_intang; +static EMACS_INT +adjust_for_invis_intang (EMACS_INT pos, EMACS_INT test_offs, EMACS_INT adj, + int test_intang) { Lisp_Object invis_propval, invis_overlay; Lisp_Object test_pos; @@ -2237,8 +2190,7 @@ set_point_both (EMACS_INT charpos, EMACS_INT bytepos) segment that reaches all the way to point. */ void -move_if_not_intangible (position) - int position; +move_if_not_intangible (EMACS_INT position) { Lisp_Object pos; Lisp_Object intangible_propval; @@ -2301,11 +2253,8 @@ move_if_not_intangible (position) nil means the current buffer. */ int -get_property_and_range (pos, prop, val, start, end, object) - int pos; - Lisp_Object prop, *val; - EMACS_INT *start, *end; - Lisp_Object object; +get_property_and_range (EMACS_INT pos, Lisp_Object prop, Lisp_Object *val, + EMACS_INT *start, EMACS_INT *end, Lisp_Object object) { INTERVAL i, prev, next; @@ -2348,13 +2297,11 @@ get_property_and_range (pos, prop, val, start, end, object) POSITION must be in the accessible part of BUFFER. */ Lisp_Object -get_local_map (position, buffer, type) - register int position; - register struct buffer *buffer; - Lisp_Object type; +get_local_map (register EMACS_INT position, register struct buffer *buffer, + Lisp_Object type) { Lisp_Object prop, lispy_position, lispy_buffer; - int old_begv, old_zv, old_begv_byte, old_zv_byte; + EMACS_INT old_begv, old_zv, old_begv_byte, old_zv_byte; /* Perhaps we should just change `position' to the limit. */ if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer)) @@ -2404,12 +2351,10 @@ get_local_map (position, buffer, type) The new interval tree has no parent and has a starting-position of 0. */ INTERVAL -copy_intervals (tree, start, length) - INTERVAL tree; - int start, length; +copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length) { register INTERVAL i, new, t; - register int got, prevlen; + register EMACS_INT got, prevlen; if (NULL_INTERVAL_P (tree) || length <= 0) return NULL_INTERVAL; @@ -2447,10 +2392,8 @@ copy_intervals (tree, start, length) /* Give STRING the properties of BUFFER from POSITION to LENGTH. */ INLINE void -copy_intervals_to_string (string, buffer, position, length) - Lisp_Object string; - struct buffer *buffer; - int position, length; +copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, + EMACS_INT position, EMACS_INT length) { INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer), position, length); @@ -2465,12 +2408,11 @@ copy_intervals_to_string (string, buffer, position, length) Assume they have identical characters. */ int -compare_string_intervals (s1, s2) - Lisp_Object s1, s2; +compare_string_intervals (Lisp_Object s1, Lisp_Object s2) { INTERVAL i1, i2; - int pos = 0; - int end = SCHARS (s1); + EMACS_INT pos = 0; + EMACS_INT end = SCHARS (s1); i1 = find_interval (STRING_INTERVALS (s1), 0); i2 = find_interval (STRING_INTERVALS (s2), 0); @@ -2478,9 +2420,9 @@ compare_string_intervals (s1, s2) while (pos < end) { /* Determine how far we can go before we reach the end of I1 or I2. */ - int len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos; - int len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos; - int distance = min (len1, len2); + EMACS_INT len1 = (i1 != 0 ? INTERVAL_LAST_POS (i1) : end) - pos; + EMACS_INT len2 = (i2 != 0 ? INTERVAL_LAST_POS (i2) : end) - pos; + EMACS_INT distance = min (len1, len2); /* If we ever find a mismatch between the strings, they differ. */ @@ -2504,10 +2446,9 @@ compare_string_intervals (s1, s2) START_BYTE ... END_BYTE in bytes. */ static void -set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte) - INTERVAL i; - int multi_flag; - int start, start_byte, end, end_byte; +set_intervals_multibyte_1 (INTERVAL i, int multi_flag, + EMACS_INT start, EMACS_INT start_byte, + EMACS_INT end, EMACS_INT end_byte) { /* Fix the length of this interval. */ if (multi_flag) @@ -2525,11 +2466,11 @@ set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte) /* Recursively fix the length of the subintervals. */ if (i->left) { - int left_end, left_end_byte; + EMACS_INT left_end, left_end_byte; if (multi_flag) { - int temp; + EMACS_INT temp; left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); left_end = BYTE_TO_CHAR (left_end_byte); @@ -2558,11 +2499,11 @@ set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte) } if (i->right) { - int right_start_byte, right_start; + EMACS_INT right_start_byte, right_start; if (multi_flag) { - int temp; + EMACS_INT temp; right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); right_start = BYTE_TO_CHAR (right_start_byte); @@ -2617,8 +2558,7 @@ set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte) or to fit them as non-multibyte (if MULTI_FLAG is 0). */ void -set_intervals_multibyte (multi_flag) - int multi_flag; +set_intervals_multibyte (int multi_flag) { if (BUF_INTERVALS (current_buffer)) set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, diff --git a/src/intervals.h b/src/intervals.h index 5d1132e11ba..b39fbd6899d 100644 --- a/src/intervals.h +++ b/src/intervals.h @@ -28,8 +28,8 @@ struct interval { /* The first group of entries deal with the tree structure. */ - unsigned EMACS_INT total_length; /* Length of myself and both children. */ - unsigned EMACS_INT position; /* Cache of interval's character position. */ + EMACS_UINT total_length; /* Length of myself and both children. */ + EMACS_UINT position; /* Cache of interval's character position. */ /* This field is usually updated simultaneously with an interval traversal, there is no guarantee @@ -243,49 +243,49 @@ struct interval /* Declared in alloc.c */ -extern INTERVAL make_interval P_ ((void)); +extern INTERVAL make_interval (void); /* Declared in intervals.c */ -extern INTERVAL create_root_interval P_ ((Lisp_Object)); -extern void copy_properties P_ ((INTERVAL, INTERVAL)); -extern int intervals_equal P_ ((INTERVAL, INTERVAL)); -extern void traverse_intervals P_ ((INTERVAL, int, - void (*) (INTERVAL, Lisp_Object), - Lisp_Object)); -extern void traverse_intervals_noorder P_ ((INTERVAL, - void (*) (INTERVAL, Lisp_Object), - Lisp_Object)); -extern INTERVAL split_interval_right P_ ((INTERVAL, int)); -extern INTERVAL split_interval_left P_ ((INTERVAL, int)); -extern INTERVAL find_interval P_ ((INTERVAL, int)); -extern INTERVAL next_interval P_ ((INTERVAL)); -extern INTERVAL previous_interval P_ ((INTERVAL)); -extern INTERVAL merge_interval_left P_ ((INTERVAL)); -extern INTERVAL merge_interval_right P_ ((INTERVAL)); -extern void delete_interval P_ ((INTERVAL)); -extern INLINE void offset_intervals P_ ((struct buffer *, int, int)); -extern void graft_intervals_into_buffer P_ ((INTERVAL, int, int, - struct buffer *, int)); -extern void verify_interval_modification P_ ((struct buffer *, int, int)); -extern INTERVAL balance_intervals P_ ((INTERVAL)); -extern INLINE void copy_intervals_to_string P_ ((Lisp_Object, struct buffer *, - int, int)); -extern INTERVAL copy_intervals P_ ((INTERVAL, int, int)); -extern int compare_string_intervals P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object textget P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object lookup_char_property P_ ((Lisp_Object, Lisp_Object, int)); -extern void move_if_not_intangible P_ ((int)); -extern int get_property_and_range P_ ((int, Lisp_Object, Lisp_Object *, - EMACS_INT *, EMACS_INT *, Lisp_Object)); -extern Lisp_Object get_local_map P_ ((int, struct buffer *, Lisp_Object)); -extern INTERVAL update_interval P_ ((INTERVAL, int)); -extern void set_intervals_multibyte P_ ((int)); -extern INTERVAL validate_interval_range P_ ((Lisp_Object, Lisp_Object *, - Lisp_Object *, int)); +extern INTERVAL create_root_interval (Lisp_Object); +extern void copy_properties (INTERVAL, INTERVAL); +extern int intervals_equal (INTERVAL, INTERVAL); +extern void traverse_intervals (INTERVAL, EMACS_INT, + void (*) (INTERVAL, Lisp_Object), + Lisp_Object); +extern void traverse_intervals_noorder (INTERVAL, + void (*) (INTERVAL, Lisp_Object), + Lisp_Object); +extern INTERVAL split_interval_right (INTERVAL, EMACS_INT); +extern INTERVAL split_interval_left (INTERVAL, EMACS_INT); +extern INTERVAL find_interval (INTERVAL, EMACS_INT); +extern INTERVAL next_interval (INTERVAL); +extern INTERVAL previous_interval (INTERVAL); +extern INTERVAL merge_interval_left (INTERVAL); +extern INTERVAL merge_interval_right (INTERVAL); +extern void delete_interval (INTERVAL); +extern INLINE void offset_intervals (struct buffer *, EMACS_INT, EMACS_INT); +extern void graft_intervals_into_buffer (INTERVAL, EMACS_INT, EMACS_INT, + struct buffer *, int); +extern void verify_interval_modification (struct buffer *, int, int); +extern INTERVAL balance_intervals (INTERVAL); +extern INLINE void copy_intervals_to_string (Lisp_Object, struct buffer *, + EMACS_INT, EMACS_INT); +extern INTERVAL copy_intervals (INTERVAL, EMACS_INT, EMACS_INT); +extern int compare_string_intervals (Lisp_Object, Lisp_Object); +extern Lisp_Object textget (Lisp_Object, Lisp_Object); +extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, int); +extern void move_if_not_intangible (EMACS_INT); +extern int get_property_and_range (EMACS_INT, Lisp_Object, Lisp_Object *, + EMACS_INT *, EMACS_INT *, Lisp_Object); +extern Lisp_Object get_local_map (EMACS_INT, struct buffer *, Lisp_Object); +extern INTERVAL update_interval (INTERVAL, EMACS_INT); +extern void set_intervals_multibyte (int); +extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *, + Lisp_Object *, int); /* Defined in xdisp.c */ -extern int invisible_p P_ ((Lisp_Object, Lisp_Object)); +extern int invisible_p (Lisp_Object, Lisp_Object); /* Declared in textprop.c */ @@ -323,27 +323,27 @@ EXFUN (Fremove_text_properties, 4); EXFUN (Ftext_property_any, 5); EXFUN (Ftext_property_not_all, 5); EXFUN (Fprevious_single_char_property_change, 4); -extern Lisp_Object copy_text_properties P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object)); -extern Lisp_Object set_text_properties P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - Lisp_Object)); -extern void set_text_properties_1 P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, INTERVAL)); - -Lisp_Object text_property_list P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object)); -int add_text_properties_from_list P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -Lisp_Object extend_property_ranges P_ ((Lisp_Object, Lisp_Object)); -Lisp_Object get_char_property_and_overlay P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object*)); -extern int text_property_stickiness P_ ((Lisp_Object prop, Lisp_Object pos, - Lisp_Object buffer)); -extern Lisp_Object get_pos_property P_ ((Lisp_Object pos, Lisp_Object prop, - Lisp_Object object)); - -extern void syms_of_textprop P_ ((void)); +extern Lisp_Object copy_text_properties (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object); +extern Lisp_Object set_text_properties (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + Lisp_Object); +extern void set_text_properties_1 (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, INTERVAL); + +Lisp_Object text_property_list (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object); +int add_text_properties_from_list (Lisp_Object, Lisp_Object, Lisp_Object); +Lisp_Object extend_property_ranges (Lisp_Object, Lisp_Object); +Lisp_Object get_char_property_and_overlay (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object*); +extern int text_property_stickiness (Lisp_Object prop, Lisp_Object pos, + Lisp_Object buffer); +extern Lisp_Object get_pos_property (Lisp_Object pos, Lisp_Object prop, + Lisp_Object object); + +extern void syms_of_textprop (void); #include "composite.h" diff --git a/src/keyboard.c b/src/keyboard.c index 22c58985a56..9af26cd427d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "puresize.h" #include "systime.h" #include "atimer.h" +#include "process.h" #include <errno.h> #ifdef HAVE_GTK_AND_PTHREAD @@ -61,9 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif /* This is to get the definitions of the XK_ symbols. */ #ifdef HAVE_X_WINDOWS @@ -78,10 +77,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "nsterm.h" #endif -#ifndef USE_CRT_DLL -extern int errno; -#endif - /* Variables for blockinput.h: */ /* Non-zero if interrupt input is blocked right now. */ @@ -249,9 +244,6 @@ Lisp_Object Vminibuffer_message_timeout; ASCII character. */ int quit_char; -extern Lisp_Object current_global_map; -extern int minibuf_level; - /* If non-nil, this is a map that overrides all other local maps. */ Lisp_Object Voverriding_local_map; @@ -310,7 +302,7 @@ EMACS_INT extra_keyboard_modifiers; Lisp_Object meta_prefix_char; /* Last size recorded for a current buffer which is not a minibuffer. */ -static int last_non_minibuf_size; +static EMACS_INT last_non_minibuf_size; /* Number of idle seconds before an auto-save and garbage collection. */ static Lisp_Object Vauto_save_timeout; @@ -343,7 +335,7 @@ Lisp_Object real_this_command; Lisp_Object Vthis_original_command; /* The value of point when the last command was started. */ -int last_point_position; +EMACS_INT last_point_position; /* The buffer that was current when the last command was started. */ Lisp_Object last_point_position_buffer; @@ -367,6 +359,15 @@ Lisp_Object Vlast_event_frame; X Windows wants this for selection ownership. */ unsigned long last_event_timestamp; +/* If non-nil, active regions automatically become the window selection. */ +Lisp_Object Vselect_active_regions; + +/* The text in the active region prior to modifying the buffer. + Used by the `select-active-regions' feature. */ +Lisp_Object Vsaved_region_selection; + +Lisp_Object Qx_set_selection, QPRIMARY, Qhandle_switch_frame; + Lisp_Object Qself_insert_command; Lisp_Object Qforward_char; Lisp_Object Qbackward_char; @@ -471,8 +472,6 @@ Lisp_Object Qmake_frame_visible; Lisp_Object Qselect_window; Lisp_Object Qhelp_echo; -extern Lisp_Object Qremap; - #if defined (HAVE_MOUSE) || defined (HAVE_GPM) Lisp_Object Qmouse_fixup_help_message; #endif @@ -499,8 +498,7 @@ Lisp_Object Qevent_symbol_elements; /* menu item parts */ Lisp_Object Qmenu_enable; Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence; -Lisp_Object QCbutton, QCtoggle, QCradio; -extern Lisp_Object Qmenu_item; +Lisp_Object QCbutton, QCtoggle, QCradio, QClabel; /* An event header symbol HEAD may have a property named Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS); @@ -520,21 +518,14 @@ Lisp_Object Qmode_line; Lisp_Object Qvertical_line; Lisp_Object Qvertical_scroll_bar; Lisp_Object Qmenu_bar; -extern Lisp_Object Qleft_margin, Qright_margin; -extern Lisp_Object Qleft_fringe, Qright_fringe; -extern Lisp_Object QCmap; -Lisp_Object recursive_edit_unwind (), command_loop (); -Lisp_Object Fthis_command_keys (); +Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void); +Lisp_Object Fthis_command_keys (void); Lisp_Object Qextended_command_history; -EMACS_TIME timer_check (); - -extern Lisp_Object Vhistory_length, Vtranslation_table_for_input; +EMACS_TIME timer_check (int do_it_now); -extern char *x_get_keysym_name (); - -static void record_menu_key (); -static int echo_length (); +static void record_menu_key (Lisp_Object c); +static int echo_length (void); Lisp_Object Qpolling_period; @@ -547,8 +538,6 @@ Lisp_Object Vtimer_idle_list; /* Incremented whenever a timer is run. */ int timers_run; -extern Lisp_Object Vprint_level, Vprint_length; - /* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt happens. */ EMACS_TIME *input_available_clear_time; @@ -614,68 +603,54 @@ Lisp_Object Venable_disabled_menus_and_buttons; #define READABLE_EVENTS_IGNORE_SQUEEZABLES (1 << 2) /* Function for init_keyboard to call with no args (if nonzero). */ -void (*keyboard_init_hook) (); - -static int read_avail_input P_ ((int)); -static void get_input_pending P_ ((int *, int)); -static int readable_events P_ ((int)); -static Lisp_Object read_char_x_menu_prompt P_ ((int, Lisp_Object *, - Lisp_Object, int *)); -static Lisp_Object read_char_x_menu_prompt (); -static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int, - Lisp_Object *)); -static Lisp_Object make_lispy_event P_ ((struct input_event *)); +void (*keyboard_init_hook) (void); + +static int read_avail_input (int); +static void get_input_pending (int *, int); +static int readable_events (int); +static Lisp_Object read_char_x_menu_prompt (int, Lisp_Object *, + Lisp_Object, int *); +static Lisp_Object read_char_minibuf_menu_prompt (int, int, + Lisp_Object *); +static Lisp_Object make_lispy_event (struct input_event *); #if defined (HAVE_MOUSE) || defined (HAVE_GPM) -static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object, - enum scroll_bar_part, - Lisp_Object, Lisp_Object, - unsigned long)); -#endif -static Lisp_Object modify_event_symbol P_ ((int, unsigned, Lisp_Object, - Lisp_Object, char **, - Lisp_Object *, unsigned)); -static Lisp_Object make_lispy_switch_frame P_ ((Lisp_Object)); -static void save_getcjmp P_ ((jmp_buf)); -static void save_getcjmp (); -static void restore_getcjmp P_ ((jmp_buf)); -static Lisp_Object apply_modifiers P_ ((int, Lisp_Object)); -static void clear_event P_ ((struct input_event *)); -static Lisp_Object restore_kboard_configuration P_ ((Lisp_Object)); -static SIGTYPE interrupt_signal P_ ((int signalnum)); -static void handle_interrupt P_ ((void)); -static void timer_start_idle P_ ((void)); -static void timer_stop_idle P_ ((void)); -static void timer_resume_idle P_ ((void)); -static SIGTYPE handle_user_signal P_ ((int)); -static char *find_user_signal_name P_ ((int)); -static int store_user_signal_events P_ ((void)); +static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, + enum scroll_bar_part, + Lisp_Object, Lisp_Object, + unsigned long); +#endif +static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object, + Lisp_Object, const char **, + Lisp_Object *, unsigned); +static Lisp_Object make_lispy_switch_frame (Lisp_Object); +static void save_getcjmp (jmp_buf); +static void restore_getcjmp (jmp_buf); +static Lisp_Object apply_modifiers (int, Lisp_Object); +static void clear_event (struct input_event *); +static Lisp_Object restore_kboard_configuration (Lisp_Object); +static SIGTYPE interrupt_signal (int signalnum); +#ifdef SIGIO +static SIGTYPE input_available_signal (int signo); +#endif +static void handle_interrupt (void); +static void timer_start_idle (void); +static void timer_stop_idle (void); +static void timer_resume_idle (void); +static SIGTYPE handle_user_signal (int); +static char *find_user_signal_name (int); +static int store_user_signal_events (void); /* Nonzero means don't try to suspend even if the operating system seems to support it. */ static int cannot_suspend; -extern Lisp_Object Qidentity, Qonly; -/* Install the string STR as the beginning of the string of echoing, - so that it serves as a prompt for the next character. - Also start echoing. */ - -void -echo_prompt (str) - Lisp_Object str; -{ - current_kboard->echo_string = str; - current_kboard->echo_after_prompt = SCHARS (str); - echo_now (); -} - /* Add C to the echo string, if echoing is going on. C can be a character, which is printed prettily ("M-C-x" and all that jazz), or a symbol, whose name is printed. */ void -echo_char (c) - Lisp_Object c; +echo_char (Lisp_Object c) { if (current_kboard->immediate_echo) { @@ -724,7 +699,7 @@ echo_char (c) ptr = buffer + offset; } - bcopy (text, ptr, len); + memcpy (ptr, text, len); ptr += len; } @@ -762,12 +737,15 @@ echo_char (c) empty, so that it serves as a mini-prompt for the very next character. */ void -echo_dash () +echo_dash (void) { /* Do nothing if not echoing at all. */ if (NILP (current_kboard->echo_string)) return; + if (this_command_key_count == 0) + return; + if (!current_kboard->immediate_echo && SCHARS (current_kboard->echo_string) == 0) return; @@ -803,7 +781,7 @@ echo_dash () doing so. */ void -echo_now () +echo_now (void) { if (!current_kboard->immediate_echo) { @@ -853,7 +831,7 @@ echo_now () /* Turn off echoing, for the start of a new command. */ void -cancel_echoing () +cancel_echoing (void) { current_kboard->immediate_echo = 0; current_kboard->echo_after_prompt = -1; @@ -866,7 +844,7 @@ cancel_echoing () /* Return the length of the current echo string. */ static int -echo_length () +echo_length (void) { return (STRINGP (current_kboard->echo_string) ? SCHARS (current_kboard->echo_string) @@ -878,8 +856,7 @@ echo_length () switches frames while entering a key sequence. */ static void -echo_truncate (nchars) - int nchars; +echo_truncate (EMACS_INT nchars) { if (STRINGP (current_kboard->echo_string)) current_kboard->echo_string @@ -891,8 +868,7 @@ echo_truncate (nchars) /* Functions for manipulating this_command_keys. */ static void -add_command_key (key) - Lisp_Object key; +add_command_key (Lisp_Object key) { #if 0 /* Not needed after we made Freset_this_command_lengths do the job immediately. */ @@ -919,7 +895,7 @@ add_command_key (key) Lisp_Object -recursive_edit_1 () +recursive_edit_1 (void) { int count = SPECPDL_INDEX (); Lisp_Object val; @@ -964,7 +940,7 @@ recursive_edit_1 () /* When an auto-save happens, record the "time", and don't do again soon. */ void -record_auto_save () +record_auto_save (void) { last_auto_save = num_nonmacro_input_events; } @@ -972,7 +948,7 @@ record_auto_save () /* Make an auto save happen as soon as possible at command level. */ void -force_auto_save_soon () +force_auto_save_soon (void) { last_auto_save = - auto_save_interval - 1; @@ -985,7 +961,7 @@ To get out of the recursive edit, a command can do `(throw 'exit nil)'; that tells this function to return. Alternatively, `(throw 'exit t)' makes this function signal an error. This function is called by the editor initialization to begin editing. */) - () + (void) { int count = SPECPDL_INDEX (); Lisp_Object buffer; @@ -1017,8 +993,7 @@ This function is called by the editor initialization to begin editing. */) } Lisp_Object -recursive_edit_unwind (buffer) - Lisp_Object buffer; +recursive_edit_unwind (Lisp_Object buffer) { if (BUFFERP (buffer)) Fset_buffer (buffer); @@ -1063,8 +1038,7 @@ single_kboard_state () get out of it. */ void -not_single_kboard_state (kboard) - KBOARD *kboard; +not_single_kboard_state (KBOARD *kboard) { if (kboard == current_kboard) single_kboard = 0; @@ -1083,8 +1057,7 @@ struct kboard_stack static struct kboard_stack *kboard_stack; void -push_kboard (k) - struct kboard *k; +push_kboard (struct kboard *k) { struct kboard_stack *p = (struct kboard_stack *) xmalloc (sizeof (struct kboard_stack)); @@ -1097,7 +1070,7 @@ push_kboard (k) } void -pop_kboard () +pop_kboard (void) { struct terminal *t; struct kboard_stack *p = kboard_stack; @@ -1132,8 +1105,7 @@ pop_kboard () locked, then this function will throw an errow. */ void -temporarily_switch_to_single_kboard (f) - struct frame *f; +temporarily_switch_to_single_kboard (struct frame *f) { int was_locked = single_kboard; if (was_locked) @@ -1173,8 +1145,7 @@ record_single_kboard_state () #endif static Lisp_Object -restore_kboard_configuration (was_locked) - Lisp_Object was_locked; +restore_kboard_configuration (Lisp_Object was_locked) { if (NILP (was_locked)) single_kboard = 0; @@ -1195,8 +1166,7 @@ restore_kboard_configuration (was_locked) by printing an error message and returning to the editor command loop. */ Lisp_Object -cmd_error (data) - Lisp_Object data; +cmd_error (Lisp_Object data) { Lisp_Object old_level, old_length; char macroerror[50]; @@ -1254,9 +1224,7 @@ cmd_error (data) string. */ void -cmd_error_internal (data, context) - Lisp_Object data; - char *context; +cmd_error_internal (Lisp_Object data, const char *context) { struct frame *sf = SELECTED_FRAME (); @@ -1307,16 +1275,16 @@ cmd_error_internal (data, context) Vsignaling_function = Qnil; } -Lisp_Object command_loop_1 (); -Lisp_Object command_loop_2 (); -Lisp_Object top_level_1 (); +Lisp_Object command_loop_1 (void); +Lisp_Object command_loop_2 (Lisp_Object); +Lisp_Object top_level_1 (Lisp_Object); /* Entry to editor-command-loop. This level has the catches for exiting/returning to editor command loop. It returns nil to exit recursive edit, t to abort it. */ Lisp_Object -command_loop () +command_loop (void) { if (command_loop_level > 0 || minibuf_level > 0) { @@ -1351,7 +1319,7 @@ command_loop () returned due to end of file (or end of kbd macro). */ Lisp_Object -command_loop_2 () +command_loop_2 (Lisp_Object ignore) { register Lisp_Object val; @@ -1363,13 +1331,13 @@ command_loop_2 () } Lisp_Object -top_level_2 () +top_level_2 (void) { return Feval (Vtop_level); } Lisp_Object -top_level_1 () +top_level_1 (Lisp_Object ignore) { /* On entry to the outer level, run the startup file */ if (!NILP (Vtop_level)) @@ -1384,7 +1352,7 @@ top_level_1 () DEFUN ("top-level", Ftop_level, Stop_level, 0, 0, "", doc: /* Exit all recursive editing levels. This also exits all active minibuffers. */) - () + (void) { #ifdef HAVE_WINDOW_SYSTEM if (display_hourglass_p) @@ -1396,29 +1364,27 @@ This also exits all active minibuffers. */) while (INPUT_BLOCKED_P) UNBLOCK_INPUT; - return Fthrow (Qtop_level, Qnil); + Fthrow (Qtop_level, Qnil); } DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "", doc: /* Exit from the innermost recursive edit or minibuffer. */) - () + (void) { if (command_loop_level > 0 || minibuf_level > 0) Fthrow (Qexit, Qnil); error ("No recursive edit is in progress"); - return Qnil; } DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, 0, "", doc: /* Abort the command that requested this recursive edit or minibuffer input. */) - () + (void) { if (command_loop_level > 0 || minibuf_level > 0) Fthrow (Qexit, Qt); error ("No recursive edit is in progress"); - return Qnil; } #if defined (HAVE_MOUSE) || defined (HAVE_GPM) @@ -1427,8 +1393,7 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, of this function. */ static Lisp_Object -tracking_off (old_value) - Lisp_Object old_value; +tracking_off (Lisp_Object old_value) { do_mouse_tracking = old_value; if (NILP (old_value)) @@ -1454,8 +1419,7 @@ Within a `track-mouse' form, mouse motion generates input events that you can read with `read-event'. Normally, mouse motion is ignored. usage: (track-mouse BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { int count = SPECPDL_INDEX (); Lisp_Object val; @@ -1478,7 +1442,7 @@ usage: (track-mouse BODY...) */) int ignore_mouse_drag_p; static FRAME_PTR -some_mouse_moved () +some_mouse_moved (void) { Lisp_Object tail, frame; @@ -1502,30 +1466,31 @@ some_mouse_moved () /* This is the actual command reading loop, sans error-handling encapsulation. */ -static int read_key_sequence P_ ((Lisp_Object *, int, Lisp_Object, - int, int, int)); -void safe_run_hooks P_ ((Lisp_Object)); -static void adjust_point_for_property P_ ((int, int)); +static int read_key_sequence (Lisp_Object *, int, Lisp_Object, + int, int, int); +void safe_run_hooks (Lisp_Object); +static void adjust_point_for_property (EMACS_INT, int); /* Cancel hourglass from protect_unwind. ARG is not used. */ #ifdef HAVE_WINDOW_SYSTEM static Lisp_Object -cancel_hourglass_unwind (arg) - Lisp_Object arg; +cancel_hourglass_unwind (Lisp_Object arg) { cancel_hourglass (); return Qnil; } #endif -extern int nonundocount; /* Declared in cmds.c. */ +/* FIXME: This is wrong rather than test window-system, we should call + a new set-selection, which will then dispatch to x-set-selection, or + tty-set-selection, or w32-set-selection, ... */ +EXFUN (Fwindow_system, 1); Lisp_Object -command_loop_1 () +command_loop_1 (void) { Lisp_Object cmd; - int lose; Lisp_Object keybuf[30]; int i; int prev_modiff = 0; @@ -1743,149 +1708,8 @@ command_loop_1 () } else { - if (NILP (current_kboard->Vprefix_arg)) - { - /* In case we jump to directly_done. */ - Vcurrent_prefix_arg = current_kboard->Vprefix_arg; - - /* Recognize some common commands in common situations and - do them directly. */ - if (EQ (Vthis_command, Qforward_char) && PT < ZV - && NILP (Vthis_command_keys_shift_translated) - && !CONSP (Vtransient_mark_mode)) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - lose = FETCH_CHAR (PT_BYTE); - SET_PT (PT + 1); - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position + 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - /* To extract the case of continuation on - wide-column characters. */ - && ASCII_BYTE_P (lose) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT - 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (1); - goto directly_done; - } - else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV - && NILP (Vthis_command_keys_shift_translated) - && !CONSP (Vtransient_mark_mode)) - { - struct Lisp_Char_Table *dp - = window_display_table (XWINDOW (selected_window)); - SET_PT (PT - 1); - lose = FETCH_CHAR (PT_BYTE); - if (! NILP (Vpost_command_hook)) - goto directly_done; - if (current_buffer == prev_buffer - && last_point_position != PT - && NILP (Vdisable_point_adjustment) - && NILP (Vglobal_disable_point_adjustment)) - adjust_point_for_property (last_point_position, 0); - already_adjusted = 1; - if (PT == last_point_position - 1 - && (dp - ? (VECTORP (DISP_CHAR_VECTOR (dp, lose)) - ? XVECTOR (DISP_CHAR_VECTOR (dp, lose))->size == 1 - : (NILP (DISP_CHAR_VECTOR (dp, lose)) - && (lose >= 0x20 && lose < 0x7f))) - : (lose >= 0x20 && lose < 0x7f)) - && (XFASTINT (XWINDOW (selected_window)->last_modified) - >= MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - >= OVERLAY_MODIFF) - && (XFASTINT (XWINDOW (selected_window)->last_point) - == PT + 1) - && !windows_or_buffers_changed - && EQ (current_buffer->selective_display, Qnil) - && !detect_input_pending () - && NILP (XWINDOW (selected_window)->column_number_displayed) - && NILP (Vexecuting_kbd_macro)) - direct_output_forward_char (-1); - goto directly_done; - } - else if (EQ (Vthis_command, Qself_insert_command) - /* Try this optimization only on char keystrokes. */ - && NATNUMP (last_command_event) - && CHAR_VALID_P (XFASTINT (last_command_event), 0)) - { - unsigned int c - = translate_char (Vtranslation_table_for_input, - XFASTINT (last_command_event)); - int value; - if (NILP (Vexecuting_kbd_macro) - && !EQ (minibuf_window, selected_window)) - { - if (!nonundocount || nonundocount >= 20) - { - Fundo_boundary (); - nonundocount = 0; - } - nonundocount++; - } - - lose = ((XFASTINT (XWINDOW (selected_window)->last_modified) - < MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_overlay_modified) - < OVERLAY_MODIFF) - || (XFASTINT (XWINDOW (selected_window)->last_point) - != PT) - || MODIFF <= SAVE_MODIFF - || windows_or_buffers_changed - || !EQ (current_buffer->selective_display, Qnil) - || detect_input_pending () - || !NILP (XWINDOW (selected_window)->column_number_displayed) - || !NILP (Vexecuting_kbd_macro)); - - value = internal_self_insert (c, 0); - - if (value == 2) - nonundocount = 0; - - frame_make_pointer_invisible (); - - if (! NILP (Vpost_command_hook)) - /* Put this before calling adjust_point_for_property - so it will only get called once in any case. */ - goto directly_done; - - /* VALUE == 1 when AFTER-CHANGE functions are - installed which is the case most of the time - because FONT-LOCK installs one. */ - if (!lose && !value) - direct_output_for_insert (c); - goto directly_done; - } - } - /* Here for a command that isn't executed directly */ - { #ifdef HAVE_WINDOW_SYSTEM int scount = SPECPDL_INDEX (); @@ -1897,7 +1721,6 @@ command_loop_1 () } #endif - nonundocount = 0; if (NILP (current_kboard->Vprefix_arg)) /* FIXME: Why? --Stef */ Fundo_boundary (); Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil); @@ -1912,8 +1735,6 @@ command_loop_1 () unbind_to (scount, Qnil); #endif } - } - directly_done: ; current_kboard->Vlast_prefix_arg = Vcurrent_prefix_arg; /* Note that the value cell will never directly contain nil @@ -1954,7 +1775,8 @@ command_loop_1 () this_single_command_key_start = 0; } - if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks)) + if (!NILP (current_buffer->mark_active) + && !NILP (Vrun_hooks)) { /* In Emacs 22, setting transient-mark-mode to `only' was a way of turning it on for just one command. This usage is @@ -1965,9 +1787,40 @@ command_loop_1 () Vtransient_mark_mode = Qidentity; if (!NILP (Vdeactivate_mark)) + /* If `select-active-regions' is non-nil, this call to + `deactivate-mark' also sets the PRIMARY selection. */ call0 (Qdeactivate_mark); - else if (current_buffer != prev_buffer || MODIFF != prev_modiff) - call1 (Vrun_hooks, intern ("activate-mark-hook")); + else + { + /* Even if not deactivating the mark, set PRIMARY if + `select-active-regions' is non-nil. */ + if (!NILP (Fwindow_system (Qnil)) + /* Even if mark_active is non-nil, the actual buffer + marker may not have been set yet (Bug#7044). */ + && XMARKER (current_buffer->mark)->buffer + && (EQ (Vselect_active_regions, Qonly) + ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) + : (!NILP (Vselect_active_regions) + && !NILP (Vtransient_mark_mode))) + && !EQ (Vthis_command, Qhandle_switch_frame)) + { + EMACS_INT beg = + XINT (Fmarker_position (current_buffer->mark)); + EMACS_INT end = PT; + if (beg < end) + call2 (Qx_set_selection, QPRIMARY, + make_buffer_string (beg, end, 0)); + else if (beg > end) + call2 (Qx_set_selection, QPRIMARY, + make_buffer_string (end, beg, 0)); + /* Don't set empty selections. */ + } + + if (current_buffer != prev_buffer || MODIFF != prev_modiff) + call1 (Vrun_hooks, intern ("activate-mark-hook")); + } + + Vsaved_region_selection = Qnil; } finalize: @@ -2004,20 +1857,13 @@ command_loop_1 () } } -extern Lisp_Object Qcomposition, Qdisplay; - /* Adjust point to a boundary of a region that has such a property that should be treated intangible. For the moment, we check `composition', `display' and `invisible' properties. LAST_PT is the last position of point. */ -extern Lisp_Object Qafter_string, Qbefore_string; -extern Lisp_Object get_pos_property P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); - static void -adjust_point_for_property (last_pt, modified) - int last_pt; - int modified; +adjust_point_for_property (EMACS_INT last_pt, int modified) { EMACS_INT beg, end; Lisp_Object val, overlay, tmp; @@ -2026,7 +1872,7 @@ adjust_point_for_property (last_pt, modified) user can keep inserting another character at point or keep deleting characters around point. */ int check_composition = ! modified, check_display = 1, check_invisible = 1; - int orig_pt = PT; + EMACS_INT orig_pt = PT; /* FIXME: cycling is probably not necessary because these properties can't be usefully combined anyway. */ @@ -2167,8 +2013,7 @@ adjust_point_for_property (last_pt, modified) /* Subroutine for safe_run_hooks: run the hook HOOK. */ static Lisp_Object -safe_run_hooks_1 (hook) - Lisp_Object hook; +safe_run_hooks_1 (void) { if (NILP (Vrun_hooks)) return Qnil; @@ -2178,8 +2023,7 @@ safe_run_hooks_1 (hook) /* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */ static Lisp_Object -safe_run_hooks_error (data) - Lisp_Object data; +safe_run_hooks_error (Lisp_Object data) { Lisp_Object args[3]; args[0] = build_string ("Error in %s: %s"); @@ -2194,8 +2038,7 @@ safe_run_hooks_error (data) to mysteriously evaporate. */ void -safe_run_hooks (hook) - Lisp_Object hook; +safe_run_hooks (Lisp_Object hook) { int count = SPECPDL_INDEX (); specbind (Qinhibit_quit, hook); @@ -2227,7 +2070,7 @@ struct atimer *poll_timer; there. */ void -poll_for_input_1 () +poll_for_input_1 (void) { /* Tell ns_read_socket() it is being called asynchronously so it can avoid doing anything dangerous. */ @@ -2246,8 +2089,7 @@ poll_for_input_1 () poll_timer. */ void -poll_for_input (timer) - struct atimer *timer; +poll_for_input (struct atimer *timer) { if (poll_suppress_count == 0) { @@ -2266,7 +2108,7 @@ poll_for_input (timer) This function is called unconditionally from various places. */ void -start_polling () +start_polling (void) { #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), @@ -2303,7 +2145,7 @@ start_polling () /* Nonzero if we are using polling to handle input asynchronously. */ int -input_polling_used () +input_polling_used (void) { #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), @@ -2318,7 +2160,7 @@ input_polling_used () /* Turn off polling. */ void -stop_polling () +stop_polling (void) { #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), @@ -2333,8 +2175,7 @@ stop_polling () and start or stop polling accordingly. */ void -set_poll_suppress_count (count) - int count; +set_poll_suppress_count (int count) { #ifdef POLL_FOR_INPUT if (count == 0 && poll_suppress_count != 0) @@ -2354,8 +2195,7 @@ set_poll_suppress_count (count) But don't decrease it. */ void -bind_polling_period (n) - int n; +bind_polling_period (int n) { #ifdef POLL_FOR_INPUT int new = polling_period; @@ -2374,8 +2214,7 @@ bind_polling_period (n) /* Apply the control modifier to CHARACTER. */ int -make_ctrl_char (c) - int c; +make_ctrl_char (int c) { /* Save the upper bits here. */ int upper = c & ~0177; @@ -2444,9 +2283,8 @@ make_ctrl_char (c) from X code running asynchronously. */ void -show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo) - Lisp_Object help, window, object, pos; - int ok_to_overwrite_keystroke_echo; +show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object, + Lisp_Object pos, int ok_to_overwrite_keystroke_echo) { if (!NILP (help) && !STRINGP (help)) { @@ -2493,9 +2331,10 @@ show_help_echo (help, window, object, pos, ok_to_overwrite_keystroke_echo) /* Input of single characters from keyboard */ -Lisp_Object print_help (); -static Lisp_Object kbd_buffer_get_event (); -static void record_char (); +Lisp_Object print_help (Lisp_Object object); +static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, int *used_mouse_menu, + struct timeval *end_time); +static void record_char (Lisp_Object c); static Lisp_Object help_form_saved_window_configs; static Lisp_Object @@ -2544,13 +2383,8 @@ do { if (polling_stopped_here) start_polling (); \ Value is t if we showed a menu and the user rejected it. */ Lisp_Object -read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) - int commandflag; - int nmaps; - Lisp_Object *maps; - Lisp_Object prev_event; - int *used_mouse_menu; - EMACS_TIME *end_time; +read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event, + int *used_mouse_menu, struct timeval *end_time) { volatile Lisp_Object c; int count, jmpcount; @@ -2941,7 +2775,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) if (INTERACTIVE && NILP (c)) { - int delay_level, buffer_size; + int delay_level; + EMACS_INT buffer_size; /* Slow down auto saves logarithmically in size of current buffer, and garbage collect while we're at it. */ @@ -3461,8 +3296,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) Record it for echoing, for this-command-keys, and so on. */ static void -record_menu_key (c) - Lisp_Object c; +record_menu_key (Lisp_Object c) { /* Wipe the echo area. */ clear_message (1, 0); @@ -3496,8 +3330,7 @@ record_menu_key (c) /* Return 1 if should recognize C as "the help character". */ int -help_char_p (c) - Lisp_Object c; +help_char_p (Lisp_Object c) { Lisp_Object tail; @@ -3512,8 +3345,7 @@ help_char_p (c) /* Record the input event C in various ways. */ static void -record_char (c) - Lisp_Object c; +record_char (Lisp_Object c) { int recorded = 0; @@ -3647,8 +3479,7 @@ record_char (c) } Lisp_Object -print_help (object) - Lisp_Object object; +print_help (Lisp_Object object) { struct buffer *old = current_buffer; Fprinc (object, Qnil); @@ -3664,17 +3495,15 @@ print_help (object) See read_process_output. */ static void -save_getcjmp (temp) - jmp_buf temp; +save_getcjmp (jmp_buf temp) { - bcopy (getcjmp, temp, sizeof getcjmp); + memcpy (temp, getcjmp, sizeof getcjmp); } static void -restore_getcjmp (temp) - jmp_buf temp; +restore_getcjmp (jmp_buf temp) { - bcopy (temp, getcjmp, sizeof getcjmp); + memcpy (getcjmp, temp, sizeof getcjmp); } /* Low level keyboard/mouse input. @@ -3684,15 +3513,8 @@ restore_getcjmp (temp) /* Return true if there are any events in the queue that read-char would return. If this returns false, a read-char would block. */ static int -readable_events (flags) - int flags; +readable_events (int flags) { -#ifdef HAVE_DBUS - /* Check whether a D-Bus message has arrived. */ - if (xd_pending_messages () > 0) - return 1; -#endif /* HAVE_DBUS */ - if (flags & READABLE_EVENTS_DO_TIMERS_NOW) timer_check (1); @@ -3761,8 +3583,7 @@ readable_events (flags) int stop_character; static KBOARD * -event_to_kboard (event) - struct input_event *event; +event_to_kboard (struct input_event *event) { Lisp_Object frame; frame = event->frame_or_window; @@ -3780,14 +3601,25 @@ event_to_kboard (event) return FRAME_KBOARD (XFRAME (frame)); } +/* Return the number of slots occupied in kbd_buffer. */ + +static int +kbd_buffer_nr_stored (void) +{ + return kbd_fetch_ptr == kbd_store_ptr + ? 0 + : (kbd_fetch_ptr < kbd_store_ptr + ? kbd_store_ptr - kbd_fetch_ptr + : ((kbd_buffer + KBD_BUFFER_SIZE) - kbd_fetch_ptr + + (kbd_store_ptr - kbd_buffer))); +} Lisp_Object Vthrow_on_input; /* Store an event obtained at interrupt level into kbd_buffer, fifo */ void -kbd_buffer_store_event (event) - register struct input_event *event; +kbd_buffer_store_event (register struct input_event *event) { kbd_buffer_store_event_hold (event, 0); } @@ -3805,9 +3637,8 @@ kbd_buffer_store_event (event) */ void -kbd_buffer_store_event_hold (event, hold_quit) - register struct input_event *event; - struct input_event *hold_quit; +kbd_buffer_store_event_hold (register struct input_event *event, + struct input_event *hold_quit) { if (event->kind == NO_EVENT) abort (); @@ -3854,7 +3685,7 @@ kbd_buffer_store_event_hold (event, hold_quit) if (hold_quit) { - bcopy (event, (char *) hold_quit, sizeof (*event)); + memcpy (hold_quit, event, sizeof (*event)); return; } @@ -3903,6 +3734,17 @@ kbd_buffer_store_event_hold (event, hold_quit) { *kbd_store_ptr = *event; ++kbd_store_ptr; + if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE/2 && ! kbd_on_hold_p ()) + { + /* Don't read keyboard input until we have processed kbd_buffer. + This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ + hold_keyboard_input (); +#ifdef SIGIO + if (!noninteractive) + signal (SIGIO, SIG_IGN); +#endif + stop_polling (); + } } /* If we're inside while-no-input, and this event qualifies @@ -3928,8 +3770,7 @@ kbd_buffer_store_event_hold (event, hold_quit) /* Put an input event back in the head of the event queue. */ void -kbd_buffer_unget_event (event) - register struct input_event *event; +kbd_buffer_unget_event (register struct input_event *event) { if (kbd_fetch_ptr == kbd_buffer) kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE; @@ -3943,23 +3784,20 @@ kbd_buffer_unget_event (event) } -/* Generate HELP_EVENT input_events in BUFP which has room for - SIZE events. If there's not enough room in BUFP, ignore this - event. +/* Generate a HELP_EVENT input_event and store it in the keyboard + buffer. HELP is the help form. - FRAME is the frame on which the help is generated. OBJECT is the - Lisp object where the help was found (a buffer, a string, an - overlay, or nil if neither from a string nor from a buffer. POS is - the position within OBJECT where the help was found. - - Value is the number of input_events generated. */ + FRAME and WINDOW are the frame and window where the help is + generated. OBJECT is the Lisp object where the help was found (a + buffer, a string, an overlay, or nil if neither from a string nor + from a buffer). POS is the position within OBJECT where the help + was found. */ void -gen_help_event (help, frame, window, object, pos) - Lisp_Object help, frame, object, window; - int pos; +gen_help_event (Lisp_Object help, Lisp_Object frame, Lisp_Object window, + Lisp_Object object, EMACS_INT pos) { struct input_event event; @@ -3978,8 +3816,7 @@ gen_help_event (help, frame, window, object, pos) /* Store HELP_EVENTs for HELP on FRAME in the input queue. */ void -kbd_buffer_store_help_event (frame, help) - Lisp_Object frame, help; +kbd_buffer_store_help_event (Lisp_Object frame, Lisp_Object help) { struct input_event event; @@ -3996,7 +3833,7 @@ kbd_buffer_store_help_event (frame, help) /* Discard any mouse events in the event buffer by setting them to NO_EVENT. */ void -discard_mouse_events () +discard_mouse_events (void) { struct input_event *sp; for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) @@ -4026,8 +3863,7 @@ discard_mouse_events () are no real input events. */ int -kbd_buffer_events_waiting (discard) - int discard; +kbd_buffer_events_waiting (int discard) { struct input_event *sp; @@ -4049,8 +3885,7 @@ kbd_buffer_events_waiting (discard) /* Clear input event EVENT. */ static INLINE void -clear_event (event) - struct input_event *event; +clear_event (struct input_event *event) { event->kind = NO_EVENT; } @@ -4063,14 +3898,25 @@ clear_event (event) We always read and discard one event. */ static Lisp_Object -kbd_buffer_get_event (kbp, used_mouse_menu, end_time) - KBOARD **kbp; - int *used_mouse_menu; - EMACS_TIME *end_time; +kbd_buffer_get_event (KBOARD **kbp, + int *used_mouse_menu, + struct timeval *end_time) { register int c; Lisp_Object obj; + if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4) + { + /* Start reading input again, we have processed enough so we can + accept new events again. */ + unhold_keyboard_input (); +#ifdef SIGIO + if (!noninteractive) + signal (SIGIO, input_available_signal); +#endif /* SIGIO */ + start_polling (); + } + if (noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ @@ -4106,11 +3952,6 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) /* One way or another, wait until input is available; then, if interrupt handlers have not read it, read it now. */ -#ifdef HAVE_DBUS - /* Read D-Bus messages. */ - xd_read_queued_messages (); -#endif /* HAVE_DBUS */ - /* Note SIGIO has been undef'd if FIONREAD is missing. */ #ifdef SIGIO gobble_input (0); @@ -4438,8 +4279,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu, end_time) then return, without reading any user-visible events. */ void -swallow_events (do_display) - int do_display; +swallow_events (int do_display) { int old_timers_run; @@ -4489,7 +4329,7 @@ swallow_events (do_display) for the sake of running idle-time timers. */ static void -timer_start_idle () +timer_start_idle (void) { Lisp_Object timers; @@ -4517,7 +4357,7 @@ timer_start_idle () /* Record that Emacs is no longer idle, so stop running idle-time timers. */ static void -timer_stop_idle () +timer_stop_idle (void) { EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1); } @@ -4525,7 +4365,7 @@ timer_stop_idle () /* Resume idle timer from last idle start time. */ static void -timer_resume_idle () +timer_resume_idle (void) { if (! EMACS_TIME_NEG_P (timer_idleness_start_time)) return; @@ -4541,8 +4381,6 @@ struct input_event last_timer_event; ...). Each element has the form (FUN . ARGS). */ Lisp_Object pending_funcalls; -extern Lisp_Object Qapply; - /* Check whether a timer has fired. To prevent larger problems we simply disregard elements that are not proper timers. Do not make a circular timer list for the time being. @@ -4556,7 +4394,7 @@ extern Lisp_Object Qapply; should be done. */ static EMACS_TIME -timer_check_2 () +timer_check_2 (void) { EMACS_TIME nexttime; EMACS_TIME now, idleness_now; @@ -4757,8 +4595,7 @@ timer_check_2 () Now we always run timers directly. */ EMACS_TIME -timer_check (do_it_now) - int do_it_now; +timer_check (int do_it_now) { EMACS_TIME nexttime; @@ -4781,7 +4618,7 @@ The value when Emacs is not idle is nil. The microsecond count is zero on systems that do not provide resolution finer than a second. */) - () + (void) { if (! EMACS_TIME_NEG_P (timer_idleness_start_time)) { @@ -4915,7 +4752,7 @@ static const int lispy_accent_codes[] = /* This is a list of Lisp names for special "accent" characters. It parallels lispy_accent_codes. */ -static char *lispy_accent_keys[] = +static const char *lispy_accent_keys[] = { "dead-circumflex", "dead-grave", @@ -4942,7 +4779,7 @@ static char *lispy_accent_keys[] = #ifdef HAVE_NTGUI #define FUNCTION_KEY_OFFSET 0x0 -char *lispy_function_keys[] = +char const *lispy_function_keys[] = { 0, /* 0 */ @@ -5105,9 +4942,9 @@ char *lispy_function_keys[] = 0, /* VK_OEM_102 0xE2 */ "ico-help", /* VK_ICO_HELP 0xE3 */ "ico-00", /* VK_ICO_00 0xE4 */ - 0, /* VK_PROCESSKEY 0xE5 */ + 0, /* VK_PROCESSKEY 0xE5 - used by IME */ "ico-clear", /* VK_ICO_CLEAR 0xE6 */ - "packet", /* VK_PACKET 0xE7 */ + 0, /* VK_PACKET 0xE7 - used to pass unicode chars */ 0, /* 0xE8 */ "reset", /* VK_OEM_RESET 0xE9 */ "jump", /* VK_OEM_JUMP 0xEA */ @@ -5136,7 +4973,7 @@ char *lispy_function_keys[] = /* Some of these duplicate the "Media keys" on newer keyboards, but they are delivered to the application in a different way. */ -static char *lispy_multimedia_keys[] = +static const char *lispy_multimedia_keys[] = { 0, "browser-back", @@ -5200,7 +5037,7 @@ static char *lispy_multimedia_keys[] = the XK_kana_A case below. */ #if 0 #ifdef XK_kana_A -static char *lispy_kana_keys[] = +static const char *lispy_kana_keys[] = { /* X Keysym value */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x400 .. 0x40f */ @@ -5239,7 +5076,7 @@ static char *lispy_kana_keys[] = /* You'll notice that this table is arranged to be conveniently indexed by X Windows keysym values. */ -static char *lispy_function_keys[] = +static const char *lispy_function_keys[] = { /* X Keysym value */ @@ -5325,7 +5162,7 @@ static char *lispy_function_keys[] = /* ISO 9995 Function and Modifier Keys; the first byte is 0xFE. */ #define ISO_FUNCTION_KEY_OFFSET 0xfe00 -static char *iso_lispy_function_keys[] = +static const char *iso_lispy_function_keys[] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0xfe00 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xfe08 */ @@ -5348,14 +5185,14 @@ static char *iso_lispy_function_keys[] = Lisp_Object Vlispy_mouse_stem; -static char *lispy_wheel_names[] = +static const char *lispy_wheel_names[] = { "wheel-up", "wheel-down", "wheel-left", "wheel-right" }; /* drag-n-drop events are generated when a set of selected files are dragged from another application and dropped onto an Emacs window. */ -static char *lispy_drag_n_drop_names[] = +static const char *lispy_drag_n_drop_names[] = { "drag-n-drop" }; @@ -5366,7 +5203,7 @@ Lisp_Object Qup, Qdown, Qbottom, Qend_scroll; Lisp_Object Qtop, Qratio; /* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */ -Lisp_Object *scroll_bar_parts[] = { +const Lisp_Object *scroll_bar_parts[] = { &Qabove_handle, &Qhandle, &Qbelow_handle, &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio }; @@ -5409,10 +5246,8 @@ int double_click_count; /* Return position of a mouse click or wheel event */ static Lisp_Object -make_lispy_position (f, x, y, time) - struct frame *f; - Lisp_Object *x, *y; - unsigned long time; +make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y, + unsigned long time) { Lisp_Object window; enum window_part part; @@ -5432,7 +5267,8 @@ make_lispy_position (f, x, y, time) /* It's a click in window window at frame coordinates (x,y) */ struct window *w = XWINDOW (window); Lisp_Object string_info = Qnil; - int textpos = -1, rx = -1, ry = -1; + EMACS_INT textpos = -1; + int rx = -1, ry = -1; int dx = -1, dy = -1; int width = -1, height = -1; Lisp_Object object = Qnil; @@ -5451,7 +5287,7 @@ make_lispy_position (f, x, y, time) /* Mode line or header line. Look for a string under the mouse that may have a `local-map' property. */ Lisp_Object string; - int charpos; + EMACS_INT charpos; posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line; rx = wx, ry = wy; @@ -5475,7 +5311,7 @@ make_lispy_position (f, x, y, time) else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN) { Lisp_Object string; - int charpos; + EMACS_INT charpos; posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin; rx = wx, ry = wy; @@ -5599,8 +5435,7 @@ make_lispy_position (f, x, y, time) in order to build drag events when the button is released. */ static Lisp_Object -make_lispy_event (event) - struct input_event *event; +make_lispy_event (struct input_event *event) { int i; @@ -5611,7 +5446,7 @@ make_lispy_event (event) case MULTIBYTE_CHAR_KEYSTROKE_EVENT: { Lisp_Object lispy_c; - int c = event->code; + EMACS_INT c = event->code; if (event->kind == ASCII_KEYSTROKE_EVENT) { c &= 0377; @@ -6307,12 +6142,8 @@ make_lispy_event (event) #if defined(HAVE_MOUSE) || defined(HAVE_GPM) static Lisp_Object -make_lispy_movement (frame, bar_window, part, x, y, time) - FRAME_PTR frame; - Lisp_Object bar_window; - enum scroll_bar_part part; - Lisp_Object x, y; - unsigned long time; +make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part, + Lisp_Object x, Lisp_Object y, unsigned long time) { /* Is it a scroll bar movement? */ if (frame && ! NILP (bar_window)) @@ -6347,8 +6178,7 @@ make_lispy_movement (frame, bar_window, part, x, y, time) /* Construct a switch frame event. */ static Lisp_Object -make_lispy_switch_frame (frame) - Lisp_Object frame; +make_lispy_switch_frame (Lisp_Object frame) { return Fcons (Qswitch_frame, Fcons (frame, Qnil)); } @@ -6364,9 +6194,7 @@ make_lispy_switch_frame (frame) This doesn't use any caches. */ static int -parse_modifiers_uncached (symbol, modifier_end) - Lisp_Object symbol; - int *modifier_end; +parse_modifiers_uncached (Lisp_Object symbol, int *modifier_end) { Lisp_Object name; int i; @@ -6476,10 +6304,7 @@ parse_modifiers_uncached (symbol, modifier_end) prepended to the string BASE[0..BASE_LEN-1]. This doesn't use any caches. */ static Lisp_Object -apply_modifiers_uncached (modifiers, base, base_len, base_len_byte) - int modifiers; - char *base; - int base_len, base_len_byte; +apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_byte) { /* Since BASE could contain nulls, we can't use intern here; we have to use Fintern, which expects a genuine Lisp_String, and keeps a @@ -6518,8 +6343,8 @@ apply_modifiers_uncached (modifiers, base, base_len, base_len_byte) new_name = make_uninit_multibyte_string (mod_len + base_len, mod_len + base_len_byte); - bcopy (new_mods, SDATA (new_name), mod_len); - bcopy (base, SDATA (new_name) + mod_len, base_len_byte); + memcpy (SDATA (new_name), new_mods, mod_len); + memcpy (SDATA (new_name) + mod_len, base, base_len_byte); return Fintern (new_name, Qnil); } @@ -6538,8 +6363,7 @@ static Lisp_Object modifier_symbols; /* Return the list of modifier symbols corresponding to the mask MODIFIERS. */ static Lisp_Object -lispy_modifier_list (modifiers) - int modifiers; +lispy_modifier_list (int modifiers) { Lisp_Object modifier_list; int i; @@ -6564,8 +6388,7 @@ lispy_modifier_list (modifiers) #define KEY_TO_CHAR(k) (XINT (k) & ((1 << CHARACTERBITS) - 1)) Lisp_Object -parse_modifiers (symbol) - Lisp_Object symbol; +parse_modifiers (Lisp_Object symbol) { Lisp_Object elements; @@ -6613,8 +6436,7 @@ parse_modifiers (symbol) DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers, Sevent_symbol_parse_modifiers, 1, 1, 0, doc: /* Parse the event symbol. For internal use. */) - (symbol) - Lisp_Object symbol; + (Lisp_Object symbol) { /* Fill the cache if needed. */ parse_modifiers (symbol); @@ -6634,9 +6456,7 @@ DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers, apply_modifiers copies the value of BASE's Qevent_kind property to the modified symbol. */ static Lisp_Object -apply_modifiers (modifiers, base) - int modifiers; - Lisp_Object base; +apply_modifiers (int modifiers, Lisp_Object base) { Lisp_Object cache, index, entry, new_symbol; @@ -6705,8 +6525,7 @@ apply_modifiers (modifiers, base) and M-C-foo end up being equivalent in the keymap. */ Lisp_Object -reorder_modifiers (symbol) - Lisp_Object symbol; +reorder_modifiers (Lisp_Object symbol) { /* It's hopefully okay to write the code this way, since everything will soon be in caches, and no consing will be done at all. */ @@ -6751,15 +6570,9 @@ reorder_modifiers (symbol) in the symbol's name. */ static Lisp_Object -modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist_or_stem, - name_table, symbol_table, table_size) - int symbol_num; - unsigned modifiers; - Lisp_Object symbol_kind; - Lisp_Object name_alist_or_stem; - char **name_table; - Lisp_Object *symbol_table; - unsigned int table_size; +modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object symbol_kind, + Lisp_Object name_alist_or_stem, const char **name_table, + Lisp_Object *symbol_table, unsigned int table_size) { Lisp_Object value; Lisp_Object symbol_int; @@ -6821,7 +6634,7 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist_or_stem, if (NILP (value)) { char buf[20]; - sprintf (buf, "key-%d", symbol_num); + sprintf (buf, "key-%ld", (long)symbol_num); value = intern (buf); } @@ -6852,8 +6665,7 @@ and zero or more modifier names (control, meta, hyper, super, shift, alt, drag, down, double or triple). The base must be last. The return value is an event type (a character or symbol) which has the same base event type and all the specified modifiers. */) - (event_desc) - Lisp_Object event_desc; + (Lisp_Object event_desc) { Lisp_Object base; int modifiers = 0; @@ -6996,8 +6808,7 @@ parse_solitary_modifier (Lisp_Object symbol) but it can be a Lucid-style event type list. */ int -lucid_event_type_list_p (object) - Lisp_Object object; +lucid_event_type_list_p (Lisp_Object object) { Lisp_Object tail; @@ -7034,9 +6845,7 @@ lucid_event_type_list_p (object) movements and toolkit scroll bar thumb drags. */ static void -get_input_pending (addr, flags) - int *addr; - int flags; +get_input_pending (int *addr, int flags) { /* First of all, have we already counted some input? */ *addr = (!NILP (Vquit_flag) || readable_events (flags)); @@ -7053,8 +6862,7 @@ get_input_pending (addr, flags) /* Interface to read_avail_input, blocking SIGIO or SIGALRM if necessary. */ void -gobble_input (expected) - int expected; +gobble_input (int expected) { #ifdef SIGIO if (interrupt_input) @@ -7086,7 +6894,7 @@ gobble_input (expected) so that read_key_sequence will notice the new current buffer. */ void -record_asynch_buffer_change () +record_asynch_buffer_change (void) { struct input_event event; Lisp_Object tem; @@ -7096,18 +6904,15 @@ record_asynch_buffer_change () event.frame_or_window = Qnil; event.arg = Qnil; -#ifdef subprocesses /* We don't need a buffer-switch event unless Emacs is waiting for input. The purpose of the event is to make read_key_sequence look up the keymaps again. If we aren't in read_key_sequence, we don't need one, - and the event could cause trouble by messing up (input-pending-p). */ + and the event could cause trouble by messing up (input-pending-p). + Note: Fwaiting_for_user_input_p always returns nil when async + subprocesses aren't supported. */ tem = Fwaiting_for_user_input_p (); if (NILP (tem)) return; -#else - /* We never need these events if we have no asynchronous subprocesses. */ - return; -#endif /* Make sure no interrupt happens while storing the event. */ #ifdef SIGIO @@ -7136,8 +6941,7 @@ record_asynch_buffer_change () this is a bad time to try to read input. */ static int -read_avail_input (expected) - int expected; +read_avail_input (int expected) { int nread = 0; int err = 0; @@ -7270,6 +7074,10 @@ tty_read_avail_input (struct terminal *terminal, int n_to_read, i; struct tty_display_info *tty = terminal->display_info.tty; int nread = 0; + int buffer_free = KBD_BUFFER_SIZE - kbd_buffer_nr_stored () - 1; + + if (kbd_on_hold_p () || buffer_free <= 0) + return 0; if (!terminal->name) /* Don't read from a dead terminal. */ return 0; @@ -7351,6 +7159,10 @@ tty_read_avail_input (struct terminal *terminal, #endif #endif + /* Don't read more than we can store. */ + if (n_to_read > buffer_free) + n_to_read = buffer_free; + /* Now read; for one reason or another, this will not block. NREAD is set to the number of chars read. */ do @@ -7463,7 +7275,7 @@ tty_read_avail_input (struct terminal *terminal, } void -handle_async_input () +handle_async_input (void) { interrupt_input_pending = 0; #ifdef SYNC_INPUT @@ -7490,7 +7302,7 @@ handle_async_input () } void -process_pending_signals () +process_pending_signals (void) { if (interrupt_input_pending) handle_async_input (); @@ -7501,17 +7313,10 @@ process_pending_signals () /* Note SIGIO has been undef'd if FIONREAD is missing. */ static SIGTYPE -input_available_signal (signo) - int signo; +input_available_signal (int signo) { /* Must preserve main program's value of errno. */ int old_errno = errno; -#if defined (USG) && !defined (POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time */ - signal (signo, input_available_signal); -#endif /* USG */ - SIGNAL_THREAD_CHECK (signo); #ifdef SYNC_INPUT @@ -7537,7 +7342,7 @@ input_available_signal (signo) dealing with, without assuming that every file which uses UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ void -reinvoke_input_signal () +reinvoke_input_signal (void) { #ifdef SIGIO handle_async_input (); @@ -7566,9 +7371,7 @@ struct user_signal_info static struct user_signal_info *user_signals = NULL; void -add_user_signal (sig, name) - int sig; - const char *name; +add_user_signal (int sig, const char *name) { struct user_signal_info *p; @@ -7588,18 +7391,11 @@ add_user_signal (sig, name) } static SIGTYPE -handle_user_signal (sig) - int sig; +handle_user_signal (int sig) { int old_errno = errno; struct user_signal_info *p; -#if defined (USG) && !defined (POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time */ - signal (sig, handle_user_signal); -#endif - SIGNAL_THREAD_CHECK (sig); for (p = user_signals; p; p = p->next) @@ -7624,8 +7420,7 @@ handle_user_signal (sig) } static char * -find_user_signal_name (sig) - int sig; +find_user_signal_name (int sig) { struct user_signal_info *p; @@ -7637,7 +7432,7 @@ find_user_signal_name (sig) } static int -store_user_signal_events () +store_user_signal_events (void) { struct user_signal_info *p; struct input_event buf; @@ -7650,7 +7445,7 @@ store_user_signal_events () if (nstored == 0) { - bzero (&buf, sizeof buf); + memset (&buf, 0, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.frame_or_window = selected_frame; } @@ -7671,7 +7466,7 @@ store_user_signal_events () } -static void menu_bar_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, void*)); +static void menu_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); static Lisp_Object menu_bar_one_keymap_changed_items; /* These variables hold the vector under construction within @@ -7687,8 +7482,7 @@ static int menu_bar_items_index; OLD is an old vector we can optionally reuse, or nil. */ Lisp_Object -menu_bar_items (old) - Lisp_Object old; +menu_bar_items (Lisp_Object old) { /* The number of keymaps we're scanning right now, and the number of keymaps we have allocated space for. */ @@ -7755,7 +7549,7 @@ menu_bar_items (old) nmaps = 0; if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) maps[nmaps++] = tem; - bcopy (tmaps, (void *) (maps + nmaps), nminor * sizeof (maps[0])); + memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0])); nmaps += nminor; maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map); } @@ -7796,9 +7590,9 @@ menu_bar_items (old) tem2 = XVECTOR (menu_bar_items_vector)->contents[i + 2]; tem3 = XVECTOR (menu_bar_items_vector)->contents[i + 3]; if (end > i + 4) - bcopy (&XVECTOR (menu_bar_items_vector)->contents[i + 4], - &XVECTOR (menu_bar_items_vector)->contents[i], - (end - i - 4) * sizeof (Lisp_Object)); + memmove (&XVECTOR (menu_bar_items_vector)->contents[i], + &XVECTOR (menu_bar_items_vector)->contents[i + 4], + (end - i - 4) * sizeof (Lisp_Object)); XVECTOR (menu_bar_items_vector)->contents[end - 4] = tem0; XVECTOR (menu_bar_items_vector)->contents[end - 3] = tem1; XVECTOR (menu_bar_items_vector)->contents[end - 2] = tem2; @@ -7828,9 +7622,7 @@ menu_bar_items (old) Lisp_Object item_properties; static void -menu_bar_item (key, item, dummy1, dummy2) - Lisp_Object key, item, dummy1; - void *dummy2; +menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dummy2) { struct gcpro gcpro1; int i; @@ -7845,9 +7637,9 @@ menu_bar_item (key, item, dummy1, dummy2) if (EQ (key, XVECTOR (menu_bar_items_vector)->contents[i])) { if (menu_bar_items_index > i + 4) - bcopy (&XVECTOR (menu_bar_items_vector)->contents[i + 4], - &XVECTOR (menu_bar_items_vector)->contents[i], - (menu_bar_items_index - i - 4) * sizeof (Lisp_Object)); + memmove (&XVECTOR (menu_bar_items_vector)->contents[i], + &XVECTOR (menu_bar_items_vector)->contents[i + 4], + (menu_bar_items_index - i - 4) * sizeof (Lisp_Object)); menu_bar_items_index -= 4; } } @@ -7905,8 +7697,7 @@ menu_bar_item (key, item, dummy1, dummy2) /* This is used as the handler when calling menu_item_eval_property. */ static Lisp_Object -menu_item_eval_property_1 (arg) - Lisp_Object arg; +menu_item_eval_property_1 (Lisp_Object arg) { /* If we got a quit from within the menu computation, quit all the way out of it. This takes care of C-] in the debugger. */ @@ -7919,8 +7710,7 @@ menu_item_eval_property_1 (arg) /* Evaluate an expression and return the result (or nil if something went wrong). Used to evaluate dynamic parts of menu items. */ Lisp_Object -menu_item_eval_property (sexpr) - Lisp_Object sexpr; +menu_item_eval_property (Lisp_Object sexpr) { int count = SPECPDL_INDEX (); Lisp_Object val; @@ -7940,9 +7730,7 @@ menu_item_eval_property (sexpr) otherwise. */ int -parse_menu_item (item, inmenubar) - Lisp_Object item; - int inmenubar; +parse_menu_item (Lisp_Object item, int inmenubar) { Lisp_Object def, tem, item_string, start; Lisp_Object filter; @@ -8231,18 +8019,17 @@ static Lisp_Object tool_bar_item_properties; static int ntool_bar_items; -/* The symbols `tool-bar', `:image' and `:rtl'. */ +/* The symbols `:image' and `:rtl'. */ -extern Lisp_Object Qtool_bar; Lisp_Object QCimage; Lisp_Object Qrtl; /* Function prototypes. */ -static void init_tool_bar_items P_ ((Lisp_Object)); -static void process_tool_bar_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, void*)); -static int parse_tool_bar_item P_ ((Lisp_Object, Lisp_Object)); -static void append_tool_bar_item P_ ((void)); +static void init_tool_bar_items (Lisp_Object); +static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); +static int parse_tool_bar_item (Lisp_Object, Lisp_Object); +static void append_tool_bar_item (void); /* Return a vector of tool bar items for keymaps currently in effect. @@ -8250,9 +8037,7 @@ static void append_tool_bar_item P_ ((void)); tool bar items found. */ Lisp_Object -tool_bar_items (reuse, nitems) - Lisp_Object reuse; - int *nitems; +tool_bar_items (Lisp_Object reuse, int *nitems) { Lisp_Object *maps; int nmaps, i; @@ -8301,7 +8086,7 @@ tool_bar_items (reuse, nitems) nmaps = 0; if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) maps[nmaps++] = tem; - bcopy (tmaps, (void *) (maps + nmaps), nminor * sizeof (maps[0])); + memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0])); nmaps += nminor; maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map); } @@ -8330,12 +8115,9 @@ tool_bar_items (reuse, nitems) /* Process the definition of KEY which is DEF. */ static void -process_tool_bar_item (key, def, data, args) - Lisp_Object key, def, data; - void *args; +process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void *args) { int i; - extern Lisp_Object Qundefined; struct gcpro gcpro1, gcpro2; /* Protect KEY and DEF from GC because parse_tool_bar_item may call @@ -8353,9 +8135,9 @@ process_tool_bar_item (key, def, data, args) if (EQ (key, v[TOOL_BAR_ITEM_KEY])) { if (ntool_bar_items > i + TOOL_BAR_ITEM_NSLOTS) - bcopy (v + TOOL_BAR_ITEM_NSLOTS, v, - ((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS) - * sizeof (Lisp_Object))); + memmove (v, v + TOOL_BAR_ITEM_NSLOTS, + ((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS) + * sizeof (Lisp_Object))); ntool_bar_items -= TOOL_BAR_ITEM_NSLOTS; break; } @@ -8410,18 +8192,21 @@ process_tool_bar_item (key, def, data, args) - `:help HELP-STRING'. - Gives a help string to display for the tool bar item. */ + Gives a help string to display for the tool bar item. + + - `:label LABEL-STRING'. + + A text label to show with the tool bar button if labels are enabled. */ static int -parse_tool_bar_item (key, item) - Lisp_Object key, item; +parse_tool_bar_item (Lisp_Object key, Lisp_Object item) { /* Access slot with index IDX of vector tool_bar_item_properties. */ #define PROP(IDX) XVECTOR (tool_bar_item_properties)->contents[IDX] Lisp_Object filter = Qnil; Lisp_Object caption; - int i; + int i, have_label = 0; /* Defininition looks like `(menu-item CAPTION BINDING PROPS...)'. Rule out items that aren't lists, don't start with @@ -8497,8 +8282,17 @@ parse_tool_bar_item (key, item) return 0; } else if (EQ (key, QChelp)) - /* `:help HELP-STRING'. */ - PROP (TOOL_BAR_ITEM_HELP) = value; + /* `:help HELP-STRING'. */ + PROP (TOOL_BAR_ITEM_HELP) = value; + else if (EQ (key, QClabel)) + { + const char *bad_label = "!!?GARBLED ITEM?!!"; + /* `:label LABEL-STRING'. */ + PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value) + ? value + : make_string (bad_label, strlen (bad_label)); + have_label = 1; + } else if (EQ (key, QCfilter)) /* ':filter FORM'. */ filter = value; @@ -8526,6 +8320,51 @@ parse_tool_bar_item (key, item) PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value; } + + if (!have_label) + { + /* Try to make one from caption and key. */ + Lisp_Object key = PROP (TOOL_BAR_ITEM_KEY); + Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION); + const char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : ""; + const char *caption = STRINGP (capt) ? (char *) SDATA (capt) : ""; + EMACS_INT max_lbl = 2 * tool_bar_max_label_size; + char *buf = (char *) xmalloc (max_lbl + 1); + Lisp_Object new_lbl; + size_t caption_len = strlen (caption); + + if (caption_len <= max_lbl && caption[0] != '\0') + { + strcpy (buf, caption); + while (caption_len > 0 && buf[caption_len - 1] == '.') + caption_len--; + buf[caption_len] = '\0'; + label = caption = buf; + } + + if (strlen (label) <= max_lbl && label[0] != '\0') + { + int i; + if (label != buf) + strcpy (buf, label); + + for (i = 0; buf[i] != '\0'; ++i) + if (buf[i] == '-') + buf[i] = ' '; + label = buf; + + } + else + label = ""; + + new_lbl = Fupcase_initials (make_string (label, strlen (label))); + if (SCHARS (new_lbl) <= tool_bar_max_label_size) + PROP (TOOL_BAR_ITEM_LABEL) = new_lbl; + else + PROP (TOOL_BAR_ITEM_LABEL) = make_string ("", 0); + free (buf); + } + /* If got a filter apply it on binding. */ if (!NILP (filter)) PROP (TOOL_BAR_ITEM_BINDING) @@ -8557,8 +8396,7 @@ parse_tool_bar_item (key, item) that can be reused. */ static void -init_tool_bar_items (reuse) - Lisp_Object reuse; +init_tool_bar_items (Lisp_Object reuse) { if (VECTORP (reuse)) tool_bar_items_vector = reuse; @@ -8572,7 +8410,7 @@ init_tool_bar_items (reuse) tool_bar_item_properties */ static void -append_tool_bar_item () +append_tool_bar_item (void) { Lisp_Object *to, *from; @@ -8587,7 +8425,7 @@ append_tool_bar_item () tool_bar_items_vector. */ to = XVECTOR (tool_bar_items_vector)->contents + ntool_bar_items; from = XVECTOR (tool_bar_item_properties)->contents; - bcopy (from, to, TOOL_BAR_ITEM_NSLOTS * sizeof *to); + memcpy (to, from, TOOL_BAR_ITEM_NSLOTS * sizeof *to); ntool_bar_items += TOOL_BAR_ITEM_NSLOTS; } @@ -8616,11 +8454,8 @@ append_tool_bar_item () and do auto-saving in the inner call of read_char. */ static Lisp_Object -read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) - int nmaps; - Lisp_Object *maps; - Lisp_Object prev_event; - int *used_mouse_menu; +read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event, + int *used_mouse_menu) { int mapno; @@ -8704,10 +8539,7 @@ static char *read_char_minibuf_menu_text; static int read_char_minibuf_menu_width; static Lisp_Object -read_char_minibuf_menu_prompt (commandflag, nmaps, maps) - int commandflag ; - int nmaps; - Lisp_Object *maps; +read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) { int mapno; register Lisp_Object name; @@ -8886,7 +8718,7 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) thiswidth = SCHARS (desc); if (thiswidth + i > width) thiswidth = width - i; - bcopy (SDATA (desc), menu + i, thiswidth); + memcpy (menu + i, SDATA (desc), thiswidth); i += thiswidth; strcpy (menu + i, " = "); i += 3; @@ -8896,7 +8728,7 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) thiswidth = SCHARS (s); if (thiswidth + i > width) thiswidth = width - i; - bcopy (SDATA (s), menu + i, thiswidth); + memcpy (menu + i, SDATA (s), thiswidth); i += thiswidth; menu[i] = 0; } @@ -8972,10 +8804,8 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) NEXT may be the same array as CURRENT. */ static int -follow_key (key, nmaps, current, defs, next) - Lisp_Object key; - Lisp_Object *current, *defs, *next; - int nmaps; +follow_key (Lisp_Object key, int nmaps, Lisp_Object *current, Lisp_Object *defs, + Lisp_Object *next) { int i, first_binding; @@ -9024,9 +8854,8 @@ typedef struct keyremap that it is indeed a vector). */ static Lisp_Object -access_keymap_keyremap (map, key, prompt, do_funcall) - Lisp_Object map, key, prompt; - int do_funcall; +access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, + int do_funcall) { Lisp_Object next; @@ -9077,10 +8906,8 @@ access_keymap_keyremap (map, key, prompt, do_funcall) The return value is non-zero if the remapping actually took place. */ static int -keyremap_step (keybuf, bufsize, fkey, input, doit, diff, prompt) - Lisp_Object *keybuf, prompt; - keyremap *fkey; - int input, doit, *diff, bufsize; +keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, + int input, int doit, int *diff, Lisp_Object prompt) { Lisp_Object next, key; @@ -9172,14 +8999,9 @@ keyremap_step (keybuf, bufsize, fkey, input, doit, diff, prompt) from the selected window's buffer. */ static int -read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, - can_return_switch_frame, fix_current_buffer) - Lisp_Object *keybuf; - int bufsize; - Lisp_Object prompt; - int dont_downcase_last; - int can_return_switch_frame; - int fix_current_buffer; +read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, + int dont_downcase_last, int can_return_switch_frame, + int fix_current_buffer) { Lisp_Object from_string; int count = SPECPDL_INDEX (); @@ -9294,7 +9116,14 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, if (INTERACTIVE) { if (!NILP (prompt)) - echo_prompt (prompt); + { + /* Install the string STR as the beginning of the string of + echoing, so that it serves as a prompt for the next + character. */ + current_kboard->echo_string = prompt; + current_kboard->echo_after_prompt = SCHARS (prompt); + echo_now (); + } else if (cursor_in_echo_area && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) && NILP (Fzerop (Vecho_keystrokes))) @@ -9390,8 +9219,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, if (!NILP (orig_keymap)) submaps[nmaps++] = orig_keymap; - bcopy (maps, (void *) (submaps + nmaps), - nminor * sizeof (submaps[0])); + memcpy (submaps + nmaps, maps, nminor * sizeof (submaps[0])); nmaps += nminor; @@ -10306,10 +10134,7 @@ The optional fifth argument COMMAND-LOOP, if non-nil, means that this key sequence is being read by something that will read commands one after another. It should be nil if the caller will read just one key sequence. */) - (prompt, continue_echo, dont_downcase_last, can_return_switch_frame, - command_loop) - Lisp_Object prompt, continue_echo, dont_downcase_last; - Lisp_Object can_return_switch_frame, command_loop; + (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object command_loop) { Lisp_Object keybuf[30]; register int i; @@ -10325,7 +10150,7 @@ will read just one key sequence. */) specbind (Qinput_method_use_echo_area, (NILP (command_loop) ? Qt : Qnil)); - bzero (keybuf, sizeof keybuf); + memset (keybuf, 0, sizeof keybuf); GCPRO1 (keybuf[0]); gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); @@ -10366,10 +10191,7 @@ will read just one key sequence. */) DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, Sread_key_sequence_vector, 1, 5, 0, doc: /* Like `read-key-sequence' but always return a vector. */) - (prompt, continue_echo, dont_downcase_last, can_return_switch_frame, - command_loop) - Lisp_Object prompt, continue_echo, dont_downcase_last; - Lisp_Object can_return_switch_frame, command_loop; + (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object command_loop) { Lisp_Object keybuf[30]; register int i; @@ -10385,7 +10207,7 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, specbind (Qinput_method_use_echo_area, (NILP (command_loop) ? Qt : Qnil)); - bzero (keybuf, sizeof keybuf); + memset (keybuf, 0, sizeof keybuf); GCPRO1 (keybuf[0]); gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); @@ -10429,13 +10251,11 @@ The argument KEYS specifies the value to use instead of (this-command-keys) when reading the arguments; if it is nil, (this-command-keys) is used. The argument SPECIAL, if non-nil, means that this command is executing a special event, so ignore the prefix argument and don't clear it. */) - (cmd, record_flag, keys, special) - Lisp_Object cmd, record_flag, keys, special; + (Lisp_Object cmd, Lisp_Object record_flag, Lisp_Object keys, Lisp_Object special) { register Lisp_Object final; register Lisp_Object tem; Lisp_Object prefixarg; - extern int debug_on_next_call; debug_on_next_call = 0; @@ -10519,17 +10339,15 @@ the numeric argument to this command. Noninteractively, the argument PREFIXARG is the prefix argument to give to the command you invoke, if it asks for an argument. */) - (prefixarg) - Lisp_Object prefixarg; + (Lisp_Object prefixarg) { Lisp_Object function; - char buf[40]; - int saved_last_point_position; + EMACS_INT saved_last_point_position; Lisp_Object saved_keys, saved_last_point_position_buffer; Lisp_Object bindings, value; struct gcpro gcpro1, gcpro2, gcpro3; #ifdef HAVE_WINDOW_SYSTEM - /* The call to Fcompleting_read wil start and cancel the hourglass, + /* The call to Fcompleting_read will start and cancel the hourglass, but if the hourglass was already scheduled, this means that no hourglass will be shown for the actual M-x command itself. So we restart it if it is already scheduled. Note that checking @@ -10542,31 +10360,9 @@ give to the command you invoke, if it asks for an argument. */) XVECTOR (this_command_keys)->contents); saved_last_point_position_buffer = last_point_position_buffer; saved_last_point_position = last_point_position; - buf[0] = 0; GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); - if (EQ (prefixarg, Qminus)) - strcpy (buf, "- "); - else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4) - strcpy (buf, "C-u "); - else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg))) - sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg))); - else if (INTEGERP (prefixarg)) - sprintf (buf, "%ld ", (long) XINT (prefixarg)); - - /* This isn't strictly correct if execute-extended-command - is bound to anything else. Perhaps it should use - this_command_keys? */ - strcat (buf, "M-x "); - - /* Prompt with buf, and then read a string, completing from and - restricting to the set of all defined commands. Don't provide - any initial input. Save the command read on the extended-command - history list. */ - function = Fcompleting_read (build_string (buf), - Vobarray, Qcommandp, - Qt, Qnil, Qextended_command_history, Qnil, - Qnil); + function = call0 (intern ("read-extended-command")); #ifdef HAVE_WINDOW_SYSTEM if (hstarted) start_hourglass (); @@ -10674,7 +10470,7 @@ give to the command you invoke, if it asks for an argument. */) /* Return nonzero if input events are pending. */ int -detect_input_pending () +detect_input_pending (void) { if (!input_pending) get_input_pending (&input_pending, 0); @@ -10686,7 +10482,7 @@ detect_input_pending () pending. */ int -detect_input_pending_ignore_squeezables () +detect_input_pending_ignore_squeezables (void) { if (!input_pending) get_input_pending (&input_pending, READABLE_EVENTS_IGNORE_SQUEEZABLES); @@ -10697,8 +10493,7 @@ detect_input_pending_ignore_squeezables () /* Return nonzero if input events are pending, and run any pending timers. */ int -detect_input_pending_run_timers (do_display) - int do_display; +detect_input_pending_run_timers (int do_display) { int old_timers_run = timers_run; @@ -10729,7 +10524,7 @@ detect_input_pending_run_timers (do_display) So calling this function unnecessarily can't do any harm. */ void -clear_input_pending () +clear_input_pending (void) { input_pending = 0; } @@ -10741,7 +10536,7 @@ clear_input_pending () to do in that case. It isn't trivial. */ int -requeued_events_pending_p () +requeued_events_pending_p (void) { return (!NILP (Vunread_command_events) || unread_command_char != -1); } @@ -10751,7 +10546,7 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, doc: /* Return t if command input is currently available with no wait. Actually, the value is nil only if we can be sure that no input is available; if there is a doubt, the value is t. */) - () + (void) { if (!NILP (Vunread_command_events) || unread_command_char != -1 || !NILP (Vunread_post_input_method_events) @@ -10766,7 +10561,7 @@ if there is a doubt, the value is t. */) DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, doc: /* Return vector of last 300 events, not counting those from keyboard macros. */) - () + (void) { Lisp_Object *keys = XVECTOR (recent_keys)->contents; Lisp_Object val; @@ -10776,12 +10571,10 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, else { val = Fvector (NUM_RECENT_KEYS, keys); - bcopy (keys + recent_keys_index, - XVECTOR (val)->contents, - (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); - bcopy (keys, - XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, - recent_keys_index * sizeof (Lisp_Object)); + memcpy (XVECTOR (val)->contents, keys + recent_keys_index, + (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); + memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, + keys, recent_keys_index * sizeof (Lisp_Object)); return val; } } @@ -10793,7 +10586,7 @@ the last key sequence that has been read. The value is a string or a vector. See also `this-command-keys-vector'. */) - () + (void) { return make_event_array (this_command_key_count, XVECTOR (this_command_keys)->contents); @@ -10805,7 +10598,7 @@ However, if the command has called `read-key-sequence', it returns the last key sequence that has been read. See also `this-command-keys'. */) - () + (void) { return Fvector (this_command_key_count, XVECTOR (this_command_keys)->contents); @@ -10819,7 +10612,7 @@ the command loop or by `read-key-sequence'. Unlike `this-command-keys', this function's value does not include prefix arguments. The value is always a vector. */) - () + (void) { return Fvector (this_command_key_count - this_single_command_key_start, @@ -10835,7 +10628,7 @@ the command loop or by `read-key-sequence'. Unlike `this-single-command-keys', this function's value shows the events before all translations (except for input methods). The value is always a vector. */) - () + (void) { return Fvector (raw_keybuf_count, (XVECTOR (raw_keybuf)->contents)); @@ -10853,7 +10646,7 @@ both in the value of (this-command-keys) and in echoing. To achieve this, `universal-argument-other-key' calls `reset-this-command-lengths', which discards the record of reading these events the first time. */) - () + (void) { this_command_key_count = before_command_key_count; if (this_command_key_count < this_single_command_key_start) @@ -10873,8 +10666,7 @@ DEFUN ("clear-this-command-keys", Fclear_this_command_keys, doc: /* Clear out the vector that `this-command-keys' returns. Also clear the record of the last 100 events, unless optional arg KEEP-RECORD is non-nil. */) - (keep_record) - Lisp_Object keep_record; + (Lisp_Object keep_record) { int i; @@ -10893,7 +10685,7 @@ KEEP-RECORD is non-nil. */) DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, doc: /* Return the current depth in recursive edits. */) - () + (void) { Lisp_Object temp; XSETFASTINT (temp, command_loop_level + minibuf_level); @@ -10904,8 +10696,7 @@ DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, "FOpen dribble file: ", doc: /* Start writing all keyboard characters to a dribble file called FILE. If FILE is nil, close any open dribble file. */) - (file) - Lisp_Object file; + (Lisp_Object file) { if (dribble) { @@ -10927,7 +10718,7 @@ If FILE is nil, close any open dribble file. */) DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0, doc: /* Discard the contents of the terminal input buffer. Also end any kbd macro being defined. */) - () + (void) { if (!NILP (current_kboard->defining_kbd_macro)) { @@ -10962,8 +10753,7 @@ After resumption run the normal hook `suspend-resume-hook'. Some operating systems cannot stop the Emacs process and resume it later. On such systems, Emacs starts a subshell instead of suspending. */) - (stuffstring) - Lisp_Object stuffstring; + (Lisp_Object stuffstring) { int count = SPECPDL_INDEX (); int old_height, old_width; @@ -10985,7 +10775,7 @@ On such systems, Emacs starts a subshell instead of suspending. */) reset_all_sys_modes (); /* sys_suspend can get an error if it tries to fork a subshell and the system resources aren't available for that. */ - record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_all_sys_modes, + record_unwind_protect ((Lisp_Object (*) (Lisp_Object)) init_all_sys_modes, Qnil); stuff_buffered_input (stuffstring); if (cannot_suspend) @@ -11013,15 +10803,14 @@ On such systems, Emacs starts a subshell instead of suspending. */) Then in any case stuff anything Emacs has read ahead and not used. */ void -stuff_buffered_input (stuffstring) - Lisp_Object stuffstring; +stuff_buffered_input (Lisp_Object stuffstring) { #ifdef SIGTSTP /* stuff_char is defined if SIGTSTP. */ register unsigned char *p; if (STRINGP (stuffstring)) { - register int count; + register EMACS_INT count; p = SDATA (stuffstring); count = SBYTES (stuffstring); @@ -11052,8 +10841,7 @@ stuff_buffered_input (stuffstring) } void -set_waiting_for_input (time_to_clear) - EMACS_TIME *time_to_clear; +set_waiting_for_input (struct timeval *time_to_clear) { input_available_clear_time = time_to_clear; @@ -11067,7 +10855,7 @@ set_waiting_for_input (time_to_clear) } void -clear_waiting_for_input () +clear_waiting_for_input (void) { /* Tell handle_interrupt not to throw back to read_char, */ waiting_for_input = 0; @@ -11081,20 +10869,13 @@ clear_waiting_for_input () Otherwise, the handler kills Emacs. */ static SIGTYPE -interrupt_signal (signalnum) /* If we don't have an argument, */ - int signalnum; /* some compilers complain in signal calls. */ +interrupt_signal (int signalnum) /* If we don't have an argument, some */ + /* compilers complain in signal calls. */ { /* Must preserve main program's value of errno. */ int old_errno = errno; struct terminal *terminal; -#if defined (USG) && !defined (POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time */ - signal (SIGINT, interrupt_signal); - signal (SIGQUIT, interrupt_signal); -#endif /* USG */ - SIGNAL_THREAD_CHECK (signalnum); /* See if we have an active terminal on our controlling tty. */ @@ -11133,7 +10914,7 @@ interrupt_signal (signalnum) /* If we don't have an argument, */ non-nil, it stops the job right away. */ static void -handle_interrupt () +handle_interrupt (void) { char c; @@ -11234,6 +11015,7 @@ handle_interrupt () GCPRO4 (saved.object, saved.global_code, saved.current_syntax_table, saved.old_prop); Fsignal (Qquit, Qnil); + /* FIXME: AFAIK, `quit' can never return, so this code is dead! */ gl_state = saved; UNGCPRO; } @@ -11258,7 +11040,7 @@ handle_interrupt () /* Handle a C-g by making read_char return C-g. */ void -quit_throw_to_read_char () +quit_throw_to_read_char (void) { sigfree (); /* Prevent another signal from doing this before we finish. */ @@ -11291,8 +11073,7 @@ If INTERRUPT is non-nil, Emacs will use input interrupts; otherwise Emacs uses CBREAK mode. See also `current-input-mode'. */) - (interrupt) - Lisp_Object interrupt; + (Lisp_Object interrupt) { int new_interrupt_input; #ifdef SIGIO @@ -11302,11 +11083,7 @@ See also `current-input-mode'. */) { /* When using X, don't give the user a real choice, because we haven't implemented the mechanisms to support it. */ -#ifdef NO_SOCK_SIGIO - new_interrupt_input = 0; -#else /* not NO_SOCK_SIGIO */ new_interrupt_input = 1; -#endif /* NO_SOCK_SIGIO */ } else #endif /* HAVE_X_WINDOWS */ @@ -11346,8 +11123,7 @@ This setting only has an effect on tty terminals and only when Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'. See also `current-input-mode'. */) - (flow, terminal) - Lisp_Object flow, terminal; + (Lisp_Object flow, Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); struct tty_display_info *tty; @@ -11389,8 +11165,7 @@ It may be a terminal object, a frame, or nil for the terminal used by the currently selected frame. See also `current-input-mode'. */) - (meta, terminal) - Lisp_Object meta, terminal; + (Lisp_Object meta, Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); struct tty_display_info *tty; @@ -11431,8 +11206,7 @@ This function only has an effect on the controlling tty of the Emacs process. See also `current-input-mode'. */) - (quit) - Lisp_Object quit; + (Lisp_Object quit) { struct terminal *t = get_named_tty ("/dev/tty"); struct tty_display_info *tty; @@ -11469,8 +11243,7 @@ Third arg META t means accept 8-bit input (for a Meta key). Otherwise, accept 8-bit input and don't use the top bit for Meta. Optional fourth arg QUIT if non-nil specifies character to use for quitting. See also `current-input-mode'. */) - (interrupt, flow, meta, quit) - Lisp_Object interrupt, flow, meta, quit; + (Lisp_Object interrupt, Lisp_Object flow, Lisp_Object meta, Lisp_Object quit) { Fset_input_interrupt_mode (interrupt); Fset_output_flow_control (flow, Qnil); @@ -11494,7 +11267,7 @@ The value is a list of the form (INTERRUPT FLOW META QUIT), where QUIT is the character Emacs currently uses to quit. The elements of this list correspond to the arguments of `set-input-mode'. */) - () + (void) { Lisp_Object val[4]; struct frame *sf = XFRAME (selected_frame); @@ -11528,8 +11301,7 @@ The return value is similar to a mouse click position: (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) IMAGE (DX . DY) (WIDTH . HEIGHT)) The `posn-' functions access elements of such lists. */) - (x, y, frame_or_window, whole) - Lisp_Object x, y, frame_or_window, whole; + (Lisp_Object x, Lisp_Object y, Lisp_Object frame_or_window, Lisp_Object whole) { CHECK_NATNUM (x); CHECK_NATNUM (y); @@ -11569,8 +11341,7 @@ to the given buffer position: (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW) IMAGE (DX . DY) (WIDTH . HEIGHT)) The `posn-' functions access elements of such lists. */) - (pos, window) - Lisp_Object pos, window; + (Lisp_Object pos, Lisp_Object window) { Lisp_Object tem; @@ -11597,8 +11368,7 @@ The `posn-' functions access elements of such lists. */) * Set up a new kboard object with reasonable initial values. */ void -init_kboard (kb) - KBOARD *kb; +init_kboard (KBOARD *kb) { kb->Voverriding_terminal_local_map = Qnil; kb->Vlast_command = Qnil; @@ -11632,8 +11402,7 @@ init_kboard (kb) * it a second time. */ static void -wipe_kboard (kb) - KBOARD *kb; +wipe_kboard (KBOARD *kb) { xfree (kb->kbd_macro_buffer); } @@ -11641,8 +11410,7 @@ wipe_kboard (kb) /* Free KB and memory referenced from it. */ void -delete_kboard (kb) - KBOARD *kb; +delete_kboard (KBOARD *kb) { KBOARD **kbp; @@ -11667,7 +11435,7 @@ delete_kboard (kb) } void -init_keyboard () +init_keyboard (void) { /* This is correct before outermost invocation of the editor loop */ command_loop_level = -1; @@ -11712,11 +11480,11 @@ init_keyboard () Emacs on SIGINT when there are no termcap frames on the controlling terminal. */ signal (SIGINT, interrupt_signal); -#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) +#ifndef DOS_NT /* For systems with SysV TERMIO, C-g is set up for both SIGINT and SIGQUIT and we can't tell which one it will give us. */ signal (SIGQUIT, interrupt_signal); -#endif /* HAVE_TERMIO */ +#endif /* not DOS_NT */ } /* Note SIGIO has been undef'd if FIONREAD is missing. */ #ifdef SIGIO @@ -11750,11 +11518,11 @@ init_keyboard () event header symbols and put properties on them. */ struct event_head { Lisp_Object *var; - char *name; + const char *name; Lisp_Object *kind; }; -struct event_head head_table[] = { +static const struct event_head head_table[] = { {&Qmouse_movement, "mouse-movement", &Qmouse_movement}, {&Qscroll_bar_movement, "scroll-bar-movement", &Qmouse_movement}, {&Qswitch_frame, "switch-frame", &Qswitch_frame}, @@ -11767,7 +11535,7 @@ struct event_head head_table[] = { }; void -syms_of_keyboard () +syms_of_keyboard (void) { pending_funcalls = Qnil; staticpro (&pending_funcalls); @@ -11871,6 +11639,8 @@ syms_of_keyboard () staticpro (&QCtoggle); QCradio = intern_c_string (":radio"); staticpro (&QCradio); + QClabel = intern_c_string (":label"); + staticpro (&QClabel); Qmode_line = intern_c_string ("mode-line"); staticpro (&Qmode_line); @@ -11925,6 +11695,13 @@ syms_of_keyboard () Qinput_method_function = intern_c_string ("input-method-function"); staticpro (&Qinput_method_function); + Qx_set_selection = intern_c_string ("x-set-selection"); + staticpro (&Qx_set_selection); + QPRIMARY = intern_c_string ("PRIMARY"); + staticpro (&QPRIMARY); + Qhandle_switch_frame = intern_c_string ("handle-switch-frame"); + staticpro (&Qhandle_switch_frame); + Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char"); staticpro (&Qinput_method_exit_on_first_char); Qinput_method_use_echo_area = intern_c_string ("input-method-use-echo-area"); @@ -11937,7 +11714,7 @@ syms_of_keyboard () last_point_position_window = Qnil; { - struct event_head *p; + const struct event_head *p; for (p = head_table; p < head_table + (sizeof (head_table) / sizeof (head_table[0])); @@ -12532,6 +12309,23 @@ Help functions bind this to allow help on disabled menu items and tool-bar buttons. */); Venable_disabled_menus_and_buttons = Qnil; + DEFVAR_LISP ("select-active-regions", + &Vselect_active_regions, + doc: /* If non-nil, an active region automatically becomes the window selection. +If the value is `only', only temporarily active regions (usually made +by mouse-dragging or shift-selection) set the window selection. + +This takes effect only when Transient Mark mode is enabled. */); + Vselect_active_regions = Qt; + + DEFVAR_LISP ("saved-region-selection", + &Vsaved_region_selection, + doc: /* Contents of active region prior to buffer modification. +If `select-active-regions' is non-nil, Emacs sets this to the +text in the region before modifying the buffer. The next +`deactivate-mark' call uses this to set the window selection. */); + Vsaved_region_selection = Qnil; + /* Create the initial keyboard. */ initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (initial_kboard); @@ -12541,7 +12335,7 @@ and tool-bar buttons. */); } void -keys_of_keyboard () +keys_of_keyboard (void) { initial_define_key (global_map, Ctl ('Z'), "suspend-emacs"); initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs"); @@ -12601,7 +12395,7 @@ keys_of_keyboard () /* Mark the pointers in the kboard objects. Called by the Fgarbage_collector. */ void -mark_kboards () +mark_kboards (void) { KBOARD *kb; Lisp_Object *p; diff --git a/src/keyboard.h b/src/keyboard.h index 27fc0e5eb6a..9fd3b48eba9 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -300,7 +300,7 @@ enum menu_item_idx MENU_ITEMS_ITEM_LENGTH }; -extern Lisp_Object unuse_menu_items P_ ((Lisp_Object dummy)); +extern Lisp_Object unuse_menu_items (Lisp_Object dummy); /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU isn't defined. The use of HAVE_MULTILINGUAL_MENU could probably be @@ -318,10 +318,7 @@ extern Lisp_Object unuse_menu_items P_ ((Lisp_Object dummy)); #define ENCODE_MENU_STRING(str) (str) #endif -#if defined (HAVE_NS) || defined (HAVE_NTGUI) - -typedef void * XtPointer; -typedef unsigned char Boolean; +#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK) /* Definitions copied from lwlib.h */ @@ -338,36 +335,37 @@ typedef struct _widget_value { /* name of widget */ Lisp_Object lname; - char* name; + const char* name; /* value (meaning depend on widget type) */ - char* value; + const char* value; /* keyboard equivalent. no implications for XtTranslations */ Lisp_Object lkey; - char* key; + const char* key; /* Help string or nil if none. GC finds this string through the frame's menu_bar_vector or through menu_items. */ Lisp_Object help; /* true if enabled */ - Boolean enabled; + unsigned char enabled; /* true if selected */ - Boolean selected; + unsigned char selected; /* The type of a button. */ enum button_type button_type; #if defined (HAVE_NTGUI) /* true if menu title */ - Boolean title; + unsigned char title; #endif /* Contents of the sub-widgets, also selected slot for checkbox */ struct _widget_value* contents; /* data passed to callback */ - XtPointer call_data; + void *call_data; /* next one in the list */ struct _widget_value* next; +#ifdef USE_GTK + struct _widget_value *free_list; +#endif } widget_value; -extern widget_value *xmalloc_widget_value P_ ((void)); -extern widget_value *digest_single_submenu P_ ((int, int, int)); #endif /* HAVE_NS || HAVE_NTGUI */ @@ -406,6 +404,8 @@ extern widget_value *digest_single_submenu P_ ((int, int, int)); #define POSN_INBUFFER_P(posn) (NILP (POSN_STRING (posn))) #define POSN_BUFFER_POSN(posn) (Fnth (make_number (5), (posn))) +extern Lisp_Object do_mouse_tracking; + /* Some of the event heads. */ extern Lisp_Object Qswitch_frame; @@ -420,6 +420,8 @@ extern Lisp_Object Qevent_kind, Qevent_symbol_elements; extern Lisp_Object Qfunction_key, Qmouse_click, Qmouse_movement; extern Lisp_Object Qscroll_bar_movement; +extern Lisp_Object Qhelp_echo; + /* Getting the kind of an event head. */ #define EVENT_HEAD_KIND(event_head) \ (Fget ((event_head), Qevent_kind)) @@ -427,13 +429,27 @@ extern Lisp_Object Qscroll_bar_movement; /* Symbols to use for non-text mouse positions. */ extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line; +/* True while doing kbd input. */ +extern int waiting_for_input; + +/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt + happens. */ +extern EMACS_TIME *input_available_clear_time; + +extern int ignore_mouse_drag_p; + +extern Lisp_Object Vdouble_click_time; + +/* The primary selection. */ +extern Lisp_Object QPRIMARY; + /* Forward declaration for prototypes. */ struct input_event; -extern Lisp_Object parse_modifiers P_ ((Lisp_Object)); -extern Lisp_Object reorder_modifiers P_ ((Lisp_Object)); -extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, - int *, EMACS_TIME *)); +extern Lisp_Object parse_modifiers (Lisp_Object); +extern Lisp_Object reorder_modifiers (Lisp_Object); +extern Lisp_Object read_char (int, int, Lisp_Object *, Lisp_Object, + int *, EMACS_TIME *); extern int parse_solitary_modifier (Lisp_Object symbol); @@ -443,52 +459,80 @@ extern Lisp_Object Vfunction_key_map; /* Keymap of key translations that can override keymaps. */ extern Lisp_Object Vkey_translation_map; +/* This is like Vthis_command, except that commands never set it. */ +extern Lisp_Object real_this_command; + +/* If the lookup of the command returns a binding, the original + command is stored in this-original-command. It is nil otherwise. */ +extern Lisp_Object Vthis_original_command; + +/* Non-nil disable property on a command means + do not execute it; call disabled-command-function's value instead. */ +extern Lisp_Object QCbutton, QCtoggle, QCradio, QClabel; + +/* A mask of extra modifier bits to put into every keyboard char. */ +extern EMACS_INT extra_keyboard_modifiers; + +/* If non-nil, this implements the current input method. */ +extern Lisp_Object Vinput_method_function; +extern Lisp_Object Qinput_method_function; + +/* An event header symbol HEAD may have a property named + Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS); + BASE is the base, unmodified version of HEAD, and MODIFIERS is the + mask of modifiers applied to it. If present, this is used to help + speed up parse_modifiers. */ +extern Lisp_Object Qevent_symbol_element_mask; + +/* The timestamp of the last input event we received from the X server. + X Windows wants this for selection ownership. */ +extern unsigned long last_event_timestamp; + +extern int quit_char; + extern int parse_menu_item (Lisp_Object, int); -extern void echo_now P_ ((void)); -extern void init_kboard P_ ((KBOARD *)); -extern void delete_kboard P_ ((KBOARD *)); -extern void not_single_kboard_state P_ ((KBOARD *)); -extern void push_kboard P_ ((struct kboard *)); -extern void push_frame_kboard P_ ((struct frame *)); -extern void pop_kboard P_ ((void)); -extern void temporarily_switch_to_single_kboard P_ ((struct frame *)); -extern void record_asynch_buffer_change P_ ((void)); -extern SIGTYPE input_poll_signal P_ ((int)); -extern void start_polling P_ ((void)); -extern void stop_polling P_ ((void)); -extern void set_poll_suppress_count P_ ((int)); -extern void gobble_input P_ ((int)); -extern int input_polling_used P_ ((void)); -extern void clear_input_pending P_ ((void)); -extern int requeued_events_pending_p P_ ((void)); -extern void bind_polling_period P_ ((int)); -extern void stuff_buffered_input P_ ((Lisp_Object)); -extern void clear_waiting_for_input P_ ((void)); -extern void swallow_events P_ ((int)); -extern int help_char_p P_ ((Lisp_Object)); -extern void quit_throw_to_read_char P_ ((void)) NO_RETURN; -extern void cmd_error_internal P_ ((Lisp_Object, char *)); -extern int lucid_event_type_list_p P_ ((Lisp_Object)); -extern void kbd_buffer_store_event P_ ((struct input_event *)); -extern void kbd_buffer_store_event_hold P_ ((struct input_event *, - struct input_event *)); -extern void kbd_buffer_unget_event P_ ((struct input_event *)); -#ifdef POLL_FOR_INPUT -extern void poll_for_input_1 P_ ((void)); -#endif -extern void show_help_echo P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, int)); -extern void gen_help_event P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, int)); -extern void kbd_buffer_store_help_event P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object menu_item_eval_property P_ ((Lisp_Object)); -extern int kbd_buffer_events_waiting P_ ((int)); -extern void add_user_signal P_ ((int, const char *)); - -extern int tty_read_avail_input P_ ((struct terminal *, int, - struct input_event *)); -extern EMACS_TIME timer_check P_ ((int)); +extern void echo_now (void); +extern void init_kboard (KBOARD *); +extern void delete_kboard (KBOARD *); +extern void not_single_kboard_state (KBOARD *); +extern void push_kboard (struct kboard *); +extern void push_frame_kboard (struct frame *); +extern void pop_kboard (void); +extern void temporarily_switch_to_single_kboard (struct frame *); +extern void record_asynch_buffer_change (void); +extern SIGTYPE input_poll_signal (int); +extern void start_polling (void); +extern void stop_polling (void); +extern void set_poll_suppress_count (int); +extern void gobble_input (int); +extern int input_polling_used (void); +extern void clear_input_pending (void); +extern int requeued_events_pending_p (void); +extern void bind_polling_period (int); +extern void stuff_buffered_input (Lisp_Object); +extern void clear_waiting_for_input (void); +extern void swallow_events (int); +extern int help_char_p (Lisp_Object); +extern void quit_throw_to_read_char (void) NO_RETURN; +extern int lucid_event_type_list_p (Lisp_Object); +extern void kbd_buffer_store_event (struct input_event *); +extern void kbd_buffer_store_event_hold (struct input_event *, + struct input_event *); +extern void kbd_buffer_unget_event (struct input_event *); +extern void poll_for_input_1 (void); +extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object, int); +extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object, EMACS_INT); +extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object); +extern Lisp_Object menu_item_eval_property (Lisp_Object); +extern int kbd_buffer_events_waiting (int); +extern void add_user_signal (int, const char *); + +extern int tty_read_avail_input (struct terminal *, int, + struct input_event *); +extern EMACS_TIME timer_check (int); /* arch-tag: 769cbade-1ba9-4950-b886-db265b061aa3 (do not change this comment) */ diff --git a/src/keymap.c b/src/keymap.c index b5efd12cd6e..cc25d350d44 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -22,9 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <setjmp.h> -#if HAVE_ALLOCA_H -# include <alloca.h> -#endif #include "lisp.h" #include "commands.h" #include "buffer.h" @@ -106,32 +103,25 @@ static Lisp_Object exclude_keys; /* Pre-allocated 2-element vector for Fcommand_remapping to use. */ static Lisp_Object command_remapping_vector; -/* A char with the CHAR_META bit set in a vector or the 0200 bit set - in a string key sequence is equivalent to prefixing with this - character. */ -extern Lisp_Object meta_prefix_char; - -extern Lisp_Object Voverriding_local_map; - /* Hash table used to cache a reverse-map to speed up calls to where-is. */ static Lisp_Object where_is_cache; /* Which keymaps are reverse-stored in the cache. */ static Lisp_Object where_is_cache_keymaps; -static Lisp_Object store_in_keymap P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -static void fix_submap_inheritance P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); - -static Lisp_Object define_as_prefix P_ ((Lisp_Object, Lisp_Object)); -static void describe_command P_ ((Lisp_Object, Lisp_Object)); -static void describe_translation P_ ((Lisp_Object, Lisp_Object)); -static void describe_map P_ ((Lisp_Object, Lisp_Object, - void (*) P_ ((Lisp_Object, Lisp_Object)), - int, Lisp_Object, Lisp_Object*, int, int)); -static void describe_vector P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - void (*) (Lisp_Object, Lisp_Object), int, - Lisp_Object, Lisp_Object, int *, - int, int, int)); -static void silly_event_symbol_error P_ ((Lisp_Object)); +static Lisp_Object store_in_keymap (Lisp_Object, Lisp_Object, Lisp_Object); +static void fix_submap_inheritance (Lisp_Object, Lisp_Object, Lisp_Object); + +static Lisp_Object define_as_prefix (Lisp_Object, Lisp_Object); +static void describe_command (Lisp_Object, Lisp_Object); +static void describe_translation (Lisp_Object, Lisp_Object); +static void describe_map (Lisp_Object, Lisp_Object, + void (*) (Lisp_Object, Lisp_Object), + int, Lisp_Object, Lisp_Object*, int, int); +static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, + void (*) (Lisp_Object, Lisp_Object), int, + Lisp_Object, Lisp_Object, int *, + int, int, int); +static void silly_event_symbol_error (Lisp_Object); /* Keymap object support - constructors and predicates. */ @@ -145,8 +135,7 @@ input stream. Initially, ALIST is nil. The optional arg STRING supplies a menu name for the keymap in case you use it as a menu with `x-popup-menu'. */) - (string) - Lisp_Object string; + (Lisp_Object string) { Lisp_Object tail; if (!NILP (string)) @@ -166,8 +155,7 @@ Initially the alist is nil. The optional arg STRING supplies a menu name for the keymap in case you use it as a menu with `x-popup-menu'. */) - (string) - Lisp_Object string; + (Lisp_Object string) { if (!NILP (string)) { @@ -186,19 +174,13 @@ in case you use it as a menu with `x-popup-menu'. */) initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */ void -initial_define_key (keymap, key, defname) - Lisp_Object keymap; - int key; - char *defname; +initial_define_key (Lisp_Object keymap, int key, const char *defname) { store_in_keymap (keymap, make_number (key), intern_c_string (defname)); } void -initial_define_lispy_key (keymap, keyname, defname) - Lisp_Object keymap; - char *keyname; - char *defname; +initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname) { store_in_keymap (keymap, intern_c_string (keyname), intern_c_string (defname)); } @@ -211,8 +193,7 @@ or a symbol whose function definition is itself a keymap. ALIST elements look like (CHAR . DEFN) or (SYMBOL . DEFN); a vector of densely packed bindings for small character codes is also allowed as an element. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return (KEYMAPP (object) ? Qt : Qnil); } @@ -221,8 +202,7 @@ DEFUN ("keymap-prompt", Fkeymap_prompt, Skeymap_prompt, 1, 1, 0, doc: /* Return the prompt-string of a keymap MAP. If non-nil, the prompt is shown in the echo-area when reading a key-sequence to be looked-up in this keymap. */) - (map) - Lisp_Object map; + (Lisp_Object map) { map = get_keymap (map, 0, 0); while (CONSP (map)) @@ -258,9 +238,7 @@ when reading a key-sequence to be looked-up in this keymap. */) do_autoload which can GC. */ Lisp_Object -get_keymap (object, error, autoload) - Lisp_Object object; - int error, autoload; +get_keymap (Lisp_Object object, int error, int autoload) { Lisp_Object tem; @@ -312,9 +290,7 @@ get_keymap (object, error, autoload) We assume that KEYMAP is a valid keymap. */ Lisp_Object -keymap_parent (keymap, autoload) - Lisp_Object keymap; - int autoload; +keymap_parent (Lisp_Object keymap, int autoload) { Lisp_Object list; @@ -335,16 +311,14 @@ keymap_parent (keymap, autoload) DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0, doc: /* Return the parent keymap of KEYMAP. If KEYMAP has no parent, return nil. */) - (keymap) - Lisp_Object keymap; + (Lisp_Object keymap) { return keymap_parent (keymap, 1); } /* Check whether MAP is one of MAPS parents. */ int -keymap_memberp (map, maps) - Lisp_Object map, maps; +keymap_memberp (Lisp_Object map, Lisp_Object maps) { if (NILP (map)) return 0; while (KEYMAPP (maps) && !EQ (map, maps)) @@ -357,8 +331,7 @@ keymap_memberp (map, maps) DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0, doc: /* Modify KEYMAP to set its parent map to PARENT. Return PARENT. PARENT should be nil or another keymap. */) - (keymap, parent) - Lisp_Object keymap, parent; + (Lisp_Object keymap, Lisp_Object parent) { Lisp_Object list, prev; struct gcpro gcpro1, gcpro2; @@ -440,8 +413,7 @@ Return PARENT. PARENT should be nil or another keymap. */) make sure that SUBMAP inherits that definition as its own parent. */ static void -fix_submap_inheritance (map, event, submap) - Lisp_Object map, event, submap; +fix_submap_inheritance (Lisp_Object map, Lisp_Object event, Lisp_Object submap) { Lisp_Object map_parent, parent_entry; @@ -503,12 +475,7 @@ fix_submap_inheritance (map, event, submap) If NOINHERIT, don't accept a subkeymap found in an inherited keymap. */ Lisp_Object -access_keymap (map, idx, t_ok, noinherit, autoload) - Lisp_Object map; - Lisp_Object idx; - int t_ok; - int noinherit; - int autoload; +access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int autoload) { Lisp_Object val; @@ -637,10 +604,7 @@ access_keymap (map, idx, t_ok, noinherit, autoload) } static void -map_keymap_item (fun, args, key, val, data) - map_keymap_function_t fun; - Lisp_Object args, key, val; - void *data; +map_keymap_item (map_keymap_function_t fun, Lisp_Object args, Lisp_Object key, Lisp_Object val, void *data) { /* We should maybe try to detect bindings shadowed by previous ones and things like that. */ @@ -650,8 +614,7 @@ map_keymap_item (fun, args, key, val, data) } static void -map_keymap_char_table_item (args, key, val) - Lisp_Object args, key, val; +map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) { if (!NILP (val)) { @@ -710,9 +673,7 @@ map_keymap_internal (Lisp_Object map, } static void -map_keymap_call (key, val, fun, dummy) - Lisp_Object key, val, fun; - void *dummy; +map_keymap_call (Lisp_Object key, Lisp_Object val, Lisp_Object fun, void *dummy) { call2 (fun, key, val); } @@ -720,11 +681,7 @@ map_keymap_call (key, val, fun, dummy) /* Same as map_keymap_internal, but doesn't traverses parent keymaps as well. A non-zero AUTOLOAD indicates that autoloaded keymaps should be loaded. */ void -map_keymap (map, fun, args, data, autoload) - map_keymap_function_t fun; - Lisp_Object map, args; - void *data; - int autoload; +map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data, int autoload) { struct gcpro gcpro1; GCPRO1 (args); @@ -742,10 +699,7 @@ Lisp_Object Qkeymap_canonicalize; /* Same as map_keymap, but does it right, properly eliminating duplicate bindings due to inheritance. */ void -map_keymap_canonical (map, fun, args, data) - map_keymap_function_t fun; - Lisp_Object map, args; - void *data; +map_keymap_canonical (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data) { struct gcpro gcpro1; GCPRO1 (args); @@ -762,8 +716,7 @@ DEFUN ("map-keymap-internal", Fmap_keymap_internal, Smap_keymap_internal, 2, 2, FUNCTION is called with two arguments: the event that is bound, and the definition it is bound to. The event may be a character range. If KEYMAP has a parent, this function returns it without processing it. */) - (function, keymap) - Lisp_Object function, keymap; + (Lisp_Object function, Lisp_Object keymap) { struct gcpro gcpro1; GCPRO1 (function); @@ -782,8 +735,7 @@ If KEYMAP has a parent, the parent's bindings are included as well. This works recursively: if the parent has itself a parent, then the grandparent's bindings are also included and so on. usage: (map-keymap FUNCTION KEYMAP) */) - (function, keymap, sort_first) - Lisp_Object function, keymap, sort_first; + (Lisp_Object function, Lisp_Object keymap, Lisp_Object sort_first) { if (! NILP (sort_first)) return call2 (intern ("map-keymap-sorted"), function, keymap); @@ -807,9 +759,7 @@ usage: (map-keymap FUNCTION KEYMAP) */) This can GC because menu_item_eval_property calls Feval. */ Lisp_Object -get_keyelt (object, autoload) - Lisp_Object object; - int autoload; +get_keyelt (Lisp_Object object, int autoload) { while (1) { @@ -889,10 +839,7 @@ get_keyelt (object, autoload) } static Lisp_Object -store_in_keymap (keymap, idx, def) - Lisp_Object keymap; - register Lisp_Object idx; - Lisp_Object def; +store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def) { /* Flush any reverse-map cache. */ where_is_cache = Qnil; @@ -1047,8 +994,7 @@ store_in_keymap (keymap, idx, def) EXFUN (Fcopy_keymap, 1); Lisp_Object -copy_keymap_item (elt) - Lisp_Object elt; +copy_keymap_item (Lisp_Object elt) { Lisp_Object res, tem; @@ -1121,8 +1067,7 @@ copy_keymap_item (elt) } static void -copy_keymap_1 (chartable, idx, elt) - Lisp_Object chartable, idx, elt; +copy_keymap_1 (Lisp_Object chartable, Lisp_Object idx, Lisp_Object elt) { Fset_char_table_range (chartable, idx, copy_keymap_item (elt)); } @@ -1134,8 +1079,7 @@ but changing either the copy or KEYMAP does not affect the other. Any key definitions that are subkeymaps are recursively copied. However, a key definition which is a symbol whose definition is a keymap is not copied. */) - (keymap) - Lisp_Object keymap; + (Lisp_Object keymap) { register Lisp_Object copy, tail; keymap = get_keymap (keymap, 1, 0); @@ -1179,7 +1123,7 @@ KEY is a string or a vector of symbols and characters, representing a sequence of keystrokes and events. Non-ASCII characters with codes above 127 (such as ISO Latin-1) can be represented by vectors. Two types of vector have special meanings: - [remap COMMAND] remaps any key binding for COMMAND in KEYMAP. + [remap COMMAND] remaps any key binding for COMMAND. [t] creates a default definition, which applies to any event with no other definition in KEYMAP. @@ -1200,10 +1144,7 @@ DEF is anything that can be a key's definition: If KEYMAP is a sparse keymap with a binding for KEY, the existing binding is altered. If there is no binding for KEY, the new pair binding KEY to DEF is added at the front of KEYMAP. */) - (keymap, key, def) - Lisp_Object keymap; - Lisp_Object key; - Lisp_Object def; + (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) { register int idx; register Lisp_Object c; @@ -1280,7 +1221,7 @@ binding KEY to DEF is added at the front of KEYMAP. */) && (!CONSP (c) /* If C is a range, it must be a leaf. */ || (INTEGERP (XCAR (c)) && idx != length))) - error ("Key sequence contains invalid event"); + message_with_string ("Key sequence contains invalid event %s", c, 1); if (idx == length) RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); @@ -1319,8 +1260,7 @@ ignored if POSITION is non-nil. If the optional argument KEYMAPS is non-nil, it should be a list of keymaps to search for command remapping. Otherwise, search for the remapping in all currently active keymaps. */) - (command, position, keymaps) - Lisp_Object command, position, keymaps; + (Lisp_Object command, Lisp_Object position, Lisp_Object keymaps) { if (!SYMBOLP (command)) return Qnil; @@ -1362,10 +1302,7 @@ bindings, used when nothing else in the keymap applies; this makes it usable as a general function for probing keymaps. However, if the third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will recognize the default bindings, just as `read-key-sequence' does. */) - (keymap, key, accept_default) - Lisp_Object keymap; - Lisp_Object key; - Lisp_Object accept_default; + (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) { register int idx; register Lisp_Object cmd; @@ -1398,7 +1335,7 @@ recognize the default bindings, just as `read-key-sequence' does. */) /* Allow string since binding for `menu-bar-select-buffer' includes the buffer name in the key sequence. */ if (!INTEGERP (c) && !SYMBOLP (c) && !CONSP (c) && !STRINGP (c)) - error ("Key sequence contains invalid event"); + message_with_string ("Key sequence contains invalid event %s", c, 1); cmd = access_keymap (keymap, c, t_ok, 0, 1); if (idx == length) @@ -1417,8 +1354,7 @@ recognize the default bindings, just as `read-key-sequence' does. */) Return the keymap. */ static Lisp_Object -define_as_prefix (keymap, c) - Lisp_Object keymap, c; +define_as_prefix (Lisp_Object keymap, Lisp_Object c) { Lisp_Object cmd; @@ -1435,8 +1371,7 @@ define_as_prefix (keymap, c) /* Append a key to the end of a key sequence. We always make a vector. */ Lisp_Object -append_key (key_sequence, key) - Lisp_Object key_sequence, key; +append_key (Lisp_Object key_sequence, Lisp_Object key) { Lisp_Object args[2]; @@ -1450,8 +1385,7 @@ append_key (key_sequence, key) signal an error if is a mistake such as RET or M-RET or C-DEL, etc. */ static void -silly_event_symbol_error (c) - Lisp_Object c; +silly_event_symbol_error (Lisp_Object c) { Lisp_Object parsed, base, name, assoc; int modifiers; @@ -1520,8 +1454,7 @@ static int cmm_size = 0; list, let the key sequence be read, and hope some other piece of code signals the error. */ int -current_minor_maps (modeptr, mapptr) - Lisp_Object **modeptr, **mapptr; +current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) { int i = 0; int list_number = 0; @@ -1580,7 +1513,8 @@ current_minor_maps (modeptr, mapptr) { if (cmm_modes) { - bcopy (cmm_modes, newmodes, cmm_size * sizeof cmm_modes[0]); + memcpy (newmodes, cmm_modes, + cmm_size * sizeof cmm_modes[0]); free (cmm_modes); } cmm_modes = newmodes; @@ -1591,7 +1525,8 @@ current_minor_maps (modeptr, mapptr) { if (cmm_maps) { - bcopy (cmm_maps, newmaps, cmm_size * sizeof cmm_maps[0]); + memcpy (newmaps, cmm_maps, + cmm_size * sizeof cmm_maps[0]); free (cmm_maps); } cmm_maps = newmaps; @@ -1625,8 +1560,7 @@ DEFUN ("current-active-maps", Fcurrent_active_maps, Scurrent_active_maps, OLP if non-nil indicates that we should obey `overriding-local-map' and `overriding-terminal-local-map'. POSITION can specify a click position like in the respective argument of `key-binding'. */) - (olp, position) - Lisp_Object olp, position; + (Lisp_Object olp, Lisp_Object position) { int count = SPECPDL_INDEX (); @@ -1789,8 +1723,7 @@ occurs in the keymaps associated with it instead of KEY. It can also be a number or marker, in which case the keymap properties at the specified buffer position instead of point are used. */) - (key, accept_default, no_remap, position) - Lisp_Object key, accept_default, no_remap, position; + (Lisp_Object key, Lisp_Object accept_default, Lisp_Object no_remap, Lisp_Object position) { Lisp_Object *maps, value; int nmaps, i; @@ -1980,8 +1913,7 @@ The binding is probably a symbol with a function definition. If optional argument ACCEPT-DEFAULT is non-nil, recognize default bindings; see the description of `lookup-key' for more details about this. */) - (keys, accept_default) - Lisp_Object keys, accept_default; + (Lisp_Object keys, Lisp_Object accept_default) { register Lisp_Object map; map = current_buffer->keymap; @@ -2001,8 +1933,7 @@ This function's return values are the same as those of `lookup-key' If optional argument ACCEPT-DEFAULT is non-nil, recognize default bindings; see the description of `lookup-key' for more details about this. */) - (keys, accept_default) - Lisp_Object keys, accept_default; + (Lisp_Object keys, Lisp_Object accept_default) { return Flookup_key (current_global_map, keys, accept_default); } @@ -2021,8 +1952,7 @@ that come after prefix bindings. If optional argument ACCEPT-DEFAULT is non-nil, recognize default bindings; see the description of `lookup-key' for more details about this. */) - (key, accept_default) - Lisp_Object key, accept_default; + (Lisp_Object key, Lisp_Object accept_default) { Lisp_Object *modes, *maps; int nmaps; @@ -2061,8 +1991,7 @@ as a function. The third optional argument NAME, if given, supplies a menu name string for the map. This is required to use the keymap as a menu. This function returns COMMAND. */) - (command, mapvar, name) - Lisp_Object command, mapvar, name; + (Lisp_Object command, Lisp_Object mapvar, Lisp_Object name) { Lisp_Object map; map = Fmake_sparse_keymap (name); @@ -2076,8 +2005,7 @@ This function returns COMMAND. */) DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, doc: /* Select KEYMAP as the global keymap. */) - (keymap) - Lisp_Object keymap; + (Lisp_Object keymap) { keymap = get_keymap (keymap, 1, 1); current_global_map = keymap; @@ -2088,8 +2016,7 @@ DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, DEFUN ("use-local-map", Fuse_local_map, Suse_local_map, 1, 1, 0, doc: /* Select KEYMAP as the local keymap. If KEYMAP is nil, that means no local keymap. */) - (keymap) - Lisp_Object keymap; + (Lisp_Object keymap) { if (!NILP (keymap)) keymap = get_keymap (keymap, 1, 1); @@ -2102,21 +2029,21 @@ If KEYMAP is nil, that means no local keymap. */) DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0, doc: /* Return current buffer's local keymap, or nil if it has none. Normally the local keymap is set by the major mode with `use-local-map'. */) - () + (void) { return current_buffer->keymap; } DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0, doc: /* Return the current global keymap. */) - () + (void) { return current_global_map; } DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_maps, 0, 0, 0, doc: /* Return a list of keymaps for the minor modes of the current buffer. */) - () + (void) { Lisp_Object *maps; int nmaps = current_minor_maps (0, &maps); @@ -2133,10 +2060,8 @@ struct accessible_keymaps_data { }; static void -accessible_keymaps_1 (key, cmd, args, data) - Lisp_Object key, cmd, args; - /* Use void* to be compatible with map_keymap_function_t. */ - void *data; +accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *data) +/* Use void* data to be compatible with map_keymap_function_t. */ { struct accessible_keymaps_data *d = data; /* Cast! */ Lisp_Object maps = d->maps; @@ -2206,8 +2131,7 @@ KEYS starting from KEYMAP gets you to MAP. These elements are ordered so that the KEYS increase in length. The first element is ([] . KEYMAP). An optional argument PREFIX, if non-nil, should be a key sequence; then the value includes only maps for prefixes that start with PREFIX. */) - (keymap, prefix) - Lisp_Object keymap, prefix; + (Lisp_Object keymap, Lisp_Object prefix) { Lisp_Object maps, tail; int prefixlen = XINT (Flength (prefix)); @@ -2295,8 +2219,7 @@ DEFUN ("key-description", Fkey_description, Skey_description, 1, 2, 0, Optional arg PREFIX is the sequence of keys leading up to KEYS. Control characters turn into "C-foo" sequences, meta into "M-foo", spaces are put between sequence elements, etc. */) - (keys, prefix) - Lisp_Object keys, prefix; + (Lisp_Object keys, Lisp_Object prefix) { int len = 0; int i, i_byte; @@ -2394,10 +2317,7 @@ spaces are put between sequence elements, etc. */) char * -push_key_description (c, p, force_multibyte) - register unsigned int c; - register char *p; - int force_multibyte; +push_key_description (register unsigned int c, register char *p, int force_multibyte) { unsigned c2; @@ -2519,8 +2439,7 @@ DEFUN ("single-key-description", Fsingle_key_description, Control characters turn into C-whatever, etc. Optional argument NO-ANGLES non-nil means don't put angle brackets around function keys and event symbols. */) - (key, no_angles) - Lisp_Object key, no_angles; + (Lisp_Object key, Lisp_Object no_angles) { if (CONSP (key) && lucid_event_type_list_p (key)) key = Fevent_convert_list (key); @@ -2554,9 +2473,7 @@ around function keys and event symbols. */) } char * -push_text_char_description (c, p) - register unsigned int c; - register char *p; +push_text_char_description (register unsigned int c, register char *p) { if (c >= 0200) { @@ -2588,8 +2505,7 @@ Control characters turn into "^char", etc. This differs from Also, this function recognizes the 2**7 bit as the Meta character, whereas `single-key-description' uses the 2**27 bit for Meta. See Info node `(elisp)Describing Characters' for examples. */) - (character) - Lisp_Object character; + (Lisp_Object character) { /* Currently MAX_MULTIBYTE_LENGTH is 4 (< 6). */ unsigned char str[6]; @@ -2616,8 +2532,7 @@ static int where_is_preferred_modifier; Else, return 2 if SEQ uses the where_is_preferred_modifier, and 1 otherwise. */ static int -preferred_sequence_p (seq) - Lisp_Object seq; +preferred_sequence_p (Lisp_Object seq) { int i; int len = XINT (Flength (seq)); @@ -2648,8 +2563,8 @@ preferred_sequence_p (seq) /* where-is - finding a command in a set of keymaps. */ -static void where_is_internal_1 P_ ((Lisp_Object key, Lisp_Object binding, - Lisp_Object args, void *data)); +static void where_is_internal_1 (Lisp_Object key, Lisp_Object binding, + Lisp_Object args, void *data); /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map. Returns the first non-nil binding found in any of those maps. @@ -2819,9 +2734,7 @@ indirect definition itself. If optional 5th arg NO-REMAP is non-nil, don't search for key sequences that invoke a command which is remapped to DEFINITION, but include the remapped command in the returned list. */) - (definition, keymap, firstonly, noindirect, no_remap) - Lisp_Object definition, keymap; - Lisp_Object firstonly, noindirect, no_remap; + (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) { /* The keymaps in which to search. */ Lisp_Object keymaps; @@ -2987,9 +2900,7 @@ remapped command in the returned list. */) /* This function can GC because get_keyelt can. */ static void -where_is_internal_1 (key, binding, args, data) - Lisp_Object key, binding, args; - void *data; +where_is_internal_1 (Lisp_Object key, Lisp_Object binding, Lisp_Object args, void *data) { struct where_is_internal_data *d = data; /* Cast! */ Lisp_Object definition = d->definition; @@ -3044,15 +2955,14 @@ The optional argument PREFIX, if non-nil, should be a key sequence; then we display only bindings that start with that prefix. The optional argument MENUS, if non-nil, says to mention menu bindings. \(Ordinarily these are omitted from the output.) */) - (buffer, prefix, menus) - Lisp_Object buffer, prefix, menus; + (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) { Lisp_Object outbuf, shadow; int nomenu = NILP (menus); register Lisp_Object start1; struct gcpro gcpro1; - char *alternate_heading + const char *alternate_heading = "\ Keyboard translations:\n\n\ You type Translation\n\ @@ -3156,12 +3066,12 @@ You type Translation\n\ *p++ = '\f'; *p++ = '\n'; *p++ = '`'; - bcopy (SDATA (SYMBOL_NAME (modes[i])), p, - SCHARS (SYMBOL_NAME (modes[i]))); + memcpy (p, SDATA (SYMBOL_NAME (modes[i])), + SCHARS (SYMBOL_NAME (modes[i]))); p += SCHARS (SYMBOL_NAME (modes[i])); *p++ = '\''; - bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings") - 1); - p += sizeof (" Minor Mode Bindings") - 1; + memcpy (p, " Minor Mode Bindings", strlen (" Minor Mode Bindings")); + p += strlen (" Minor Mode Bindings"); *p = 0; describe_map_tree (maps[i], 1, shadow, prefix, @@ -3223,20 +3133,14 @@ You type Translation\n\ don't omit it; instead, mention it but say it is shadowed. */ void -describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl, - always_title, mention_shadow) - Lisp_Object startmap, shadow, prefix; - int partial; - char *title; - int nomenu; - int transl; - int always_title; - int mention_shadow; +describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, + Lisp_Object prefix, const char *title, int nomenu, int transl, + int always_title, int mention_shadow) { Lisp_Object maps, orig_maps, seen, sub_shadows; struct gcpro gcpro1, gcpro2, gcpro3; int something = 0; - char *key_heading + const char *key_heading = "\ key binding\n\ --- -------\n"; @@ -3347,8 +3251,7 @@ key binding\n\ static int previous_description_column; static void -describe_command (definition, args) - Lisp_Object definition, args; +describe_command (Lisp_Object definition, Lisp_Object args) { register Lisp_Object tem1; int column = (int) current_column (); /* iftc */ @@ -3384,8 +3287,7 @@ describe_command (definition, args) } static void -describe_translation (definition, args) - Lisp_Object definition, args; +describe_translation (Lisp_Object definition, Lisp_Object args) { register Lisp_Object tem1; @@ -3418,8 +3320,7 @@ struct describe_map_elt { Lisp_Object event; Lisp_Object definition; int shadowe the event field. */ static int -describe_map_compare (aa, bb) - const void *aa, *bb; +describe_map_compare (const void *aa, const void *bb) { const struct describe_map_elt *a = aa, *b = bb; if (INTEGERP (a->event) && INTEGERP (b->event)) @@ -3441,16 +3342,10 @@ describe_map_compare (aa, bb) PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ static void -describe_map (map, prefix, elt_describer, partial, shadow, - seen, nomenu, mention_shadow) - register Lisp_Object map; - Lisp_Object prefix; - void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); - int partial; - Lisp_Object shadow; - Lisp_Object *seen; - int nomenu; - int mention_shadow; +describe_map (Lisp_Object map, Lisp_Object prefix, + void (*elt_describer) (Lisp_Object, Lisp_Object), + int partial, Lisp_Object shadow, + Lisp_Object *seen, int nomenu, int mention_shadow) { Lisp_Object tail, definition, event; Lisp_Object tem; @@ -3629,8 +3524,7 @@ describe_map (map, prefix, elt_describer, partial, shadow, } static void -describe_vector_princ (elt, fun) - Lisp_Object elt, fun; +describe_vector_princ (Lisp_Object elt, Lisp_Object fun) { Findent_to (make_number (16), make_number (1)); call1 (fun, elt); @@ -3641,8 +3535,7 @@ DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 2, 0, doc: /* Insert a description of contents of VECTOR. This is text showing the elements of vector matched against indices. DESCRIBER is the output function used; nil means use `princ'. */) - (vector, describer) - Lisp_Object vector, describer; + (Lisp_Object vector, Lisp_Object describer) { int count = SPECPDL_INDEX (); if (NILP (describer)) @@ -3691,20 +3584,11 @@ DESCRIBER is the output function used; nil means use `princ'. */) ARGS is simply passed as the second argument to ELT_DESCRIBER. */ static void -describe_vector (vector, prefix, args, elt_describer, - partial, shadow, entire_map, - indices, char_table_depth, keymap_p, - mention_shadow) - register Lisp_Object vector; - Lisp_Object prefix, args; - void (*elt_describer) P_ ((Lisp_Object, Lisp_Object)); - int partial; - Lisp_Object shadow; - Lisp_Object entire_map; - int *indices; - int char_table_depth; - int keymap_p; - int mention_shadow; +describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, + void (*elt_describer) (Lisp_Object, Lisp_Object), + int partial, Lisp_Object shadow, Lisp_Object entire_map, + int *indices, int char_table_depth, int keymap_p, + int mention_shadow) { Lisp_Object definition; Lisp_Object tem2; @@ -3898,8 +3782,7 @@ static Lisp_Object apropos_predicate; static Lisp_Object apropos_accumulate; static void -apropos_accum (symbol, string) - Lisp_Object symbol, string; +apropos_accum (Lisp_Object symbol, Lisp_Object string) { register Lisp_Object tem; @@ -3915,8 +3798,7 @@ DEFUN ("apropos-internal", Fapropos_internal, Sapropos_internal, 1, 2, 0, If optional 2nd arg PREDICATE is non-nil, (funcall PREDICATE SYMBOL) is done for each symbol and a symbol is mentioned only if that returns non-nil. Return list of symbols found. */) - (regexp, predicate) - Lisp_Object regexp, predicate; + (Lisp_Object regexp, Lisp_Object predicate) { Lisp_Object tem; CHECK_STRING (regexp); @@ -3930,7 +3812,7 @@ Return list of symbols found. */) } void -syms_of_keymap () +syms_of_keymap (void) { Qkeymap = intern_c_string ("keymap"); staticpro (&Qkeymap); @@ -4124,7 +4006,7 @@ preferred. */); } void -keys_of_keymap () +keys_of_keymap (void) { initial_define_key (global_map, 033, "ESC-prefix"); initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); diff --git a/src/keymap.h b/src/keymap.h index ed9bf7f192c..c68d763204d 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -22,6 +22,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define KEYMAPP(m) (!NILP (get_keymap (m, 0, 0))) extern Lisp_Object Qkeymap, Qmenu_bar; +extern Lisp_Object Qremap; +extern Lisp_Object Qmenu_item; +extern Lisp_Object meta_prefix_char; +extern Lisp_Object Voverriding_local_map; +extern Lisp_Object Voverriding_local_map_menu_flag; extern Lisp_Object current_global_map; EXFUN (Fmake_sparse_keymap, 1); EXFUN (Fkeymap_prompt, 1); @@ -33,21 +38,21 @@ EXFUN (Fkey_description, 2); EXFUN (Fsingle_key_description, 2); EXFUN (Fwhere_is_internal, 5); EXFUN (Fcurrent_active_maps, 2); -extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int)); -extern Lisp_Object get_keyelt P_ ((Lisp_Object, int)); -extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int)); +extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, int, int, int); +extern Lisp_Object get_keyelt (Lisp_Object, int); +extern Lisp_Object get_keymap (Lisp_Object, int, int); EXFUN (Fset_keymap_parent, 2); -extern void describe_map_tree P_ ((Lisp_Object, int, Lisp_Object, Lisp_Object, - char *, int, int, int, int)); -extern int current_minor_maps P_ ((Lisp_Object **, Lisp_Object **)); -extern void initial_define_key P_ ((Lisp_Object, int, char *)); -extern void initial_define_lispy_key P_ ((Lisp_Object, char *, char *)); -extern void syms_of_keymap P_ ((void)); -extern void keys_of_keymap P_ ((void)); +extern void describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object, + const char *, int, int, int, int); +extern int current_minor_maps (Lisp_Object **, Lisp_Object **); +extern void initial_define_key (Lisp_Object, int, const char *); +extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); +extern void syms_of_keymap (void); +extern void keys_of_keymap (void); typedef void (*map_keymap_function_t) - P_ ((Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data)); -extern void map_keymap P_ ((Lisp_Object map, map_keymap_function_t fun, Lisp_Object largs, void* cargs, int autoload)); + (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data); +extern void map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object largs, void* cargs, int autoload); extern void map_keymap_canonical (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data); diff --git a/src/lisp.h b/src/lisp.h index 5f0b3a700f7..c9104f88954 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -21,8 +21,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef EMACS_LISP_H #define EMACS_LISP_H -/* Declare the prototype for a general external function. */ -#define P_(proto) proto +#include <stdarg.h> +#include <stddef.h> /* Use the configure flag --enable-checking[=LIST] to enable various types of run time checks for Lisp objects. */ @@ -54,7 +54,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Extra internal type checking? */ extern int suppress_checking; -extern void die P_((const char *, const char *, int)) NO_RETURN; +extern void die (const char *, const char *, int) NO_RETURN; #ifdef ENABLE_CHECKING @@ -95,10 +95,9 @@ extern void die P_((const char *, const char *, int)) NO_RETURN; #endif #endif /* ENABLE_CHECKING */ -/* Define this to make Lisp_Object use a union type instead of the - default int. FIXME: It might be better to add a flag to configure - to do this. */ -/* #define USE_LISP_UNION_TYPE */ +/* Use the configure flag --enable-use-lisp-union-type to make + Lisp_Object use a union type instead of the default int. The flag + causes USE_LISP_UNION_TYPE to be defined. */ /***** Select the tagging scheme. *****/ /* There are basically two options that control the tagging scheme: @@ -223,13 +222,7 @@ enum Lisp_Misc_Type { Lisp_Misc_Free = 0x5eab, Lisp_Misc_Marker, - Lisp_Misc_Intfwd, - Lisp_Misc_Boolfwd, - Lisp_Misc_Objfwd, - Lisp_Misc_Buffer_Objfwd, - Lisp_Misc_Buffer_Local_Value, Lisp_Misc_Overlay, - Lisp_Misc_Kboard_Objfwd, Lisp_Misc_Save_Value, /* Currently floats are not a misc type, but let's define this in case we want to change that. */ @@ -238,6 +231,18 @@ enum Lisp_Misc_Type Lisp_Misc_Limit }; +/* These are the types of forwarding objects used in the value slot + of symbols for special built-in variables whose value is stored in + C variables. */ +enum Lisp_Fwd_Type + { + Lisp_Fwd_Int, /* Fwd to a C `int' variable. */ + Lisp_Fwd_Bool, /* Fwd to a C boolean var. */ + Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */ + Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */ + Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ + }; + #ifndef GCTYPEBITS #define GCTYPEBITS 3 #endif @@ -249,7 +254,7 @@ enum Lisp_Misc_Type #ifdef USE_LISP_UNION_TYPE -#ifndef WORDS_BIG_ENDIAN +#ifndef WORDS_BIGENDIAN /* Definition of Lisp_Object for little-endian machines. */ @@ -273,7 +278,7 @@ union Lisp_Object } Lisp_Object; -#else /* If WORDS_BIG_ENDIAN */ +#else /* If WORDS_BIGENDIAN */ typedef union Lisp_Object @@ -295,7 +300,7 @@ union Lisp_Object } Lisp_Object; -#endif /* WORDS_BIG_ENDIAN */ +#endif /* WORDS_BIGENDIAN */ #ifdef __GNUC__ static __inline__ Lisp_Object @@ -304,11 +309,10 @@ LISP_MAKE_RVALUE (Lisp_Object o) return o; } #else -/* This isn't quite right - it keeps the argument as an lvalue. - Making it const via casting would help avoid code actually - modifying the location in question, but the casting could cover - other type-related bugs. */ -#define LISP_MAKE_RVALUE(o) (o) +/* This is more portable to pre-C99 non-GCC compilers, but for + backwards compatibility GCC still accepts an old GNU extension + which caused this to only generate a warning. */ +#define LISP_MAKE_RVALUE(o) (0 ? (o) : (o)) #endif #else /* USE_LISP_UNION_TYPE */ @@ -488,7 +492,7 @@ enum pvec_type #define make_number(N) \ (__extension__ ({ Lisp_Object _l; _l.s.val = (N); _l.s.type = Lisp_Int; _l; })) #else -extern Lisp_Object make_number P_ ((EMACS_INT)); +extern Lisp_Object make_number (EMACS_INT); #endif #endif /* USE_LISP_UNION_TYPE */ @@ -504,12 +508,6 @@ extern Lisp_Object make_number P_ ((EMACS_INT)); #define EQ(x, y) (XHASH (x) == XHASH (y)) #ifndef XPNTR -#ifdef HAVE_SHM -/* In this representation, data is found in two widely separated segments. */ -extern size_t pure_size; -#define XPNTR(a) \ - (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)) -#else /* not HAVE_SHM */ #ifdef DATA_SEG_BITS /* This case is used for the rt-pc. In the diffs I was given, it checked for ptr = 0 @@ -524,7 +522,6 @@ extern size_t pure_size; size. */ #define XPNTR(a) ((EMACS_INT) XUINT (a)) #endif -#endif /* not HAVE_SHM */ #endif /* no XPNTR */ /* Largest and smallest representable fixnum values. These are the C @@ -566,17 +563,19 @@ extern size_t pure_size; #define XMISCANY(a) (eassert (MISCP (a)), &(XMISC(a)->u_any)) #define XMISCTYPE(a) (XMISCANY (a)->type) #define XMARKER(a) (eassert (MARKERP (a)), &(XMISC(a)->u_marker)) -#define XINTFWD(a) (eassert (INTFWDP (a)), &(XMISC(a)->u_intfwd)) -#define XBOOLFWD(a) (eassert (BOOLFWDP (a)), &(XMISC(a)->u_boolfwd)) -#define XOBJFWD(a) (eassert (OBJFWDP (a)), &(XMISC(a)->u_objfwd)) #define XOVERLAY(a) (eassert (OVERLAYP (a)), &(XMISC(a)->u_overlay)) #define XSAVE_VALUE(a) (eassert (SAVE_VALUEP (a)), &(XMISC(a)->u_save_value)) + +/* Forwarding object types. */ + +#define XFWDTYPE(a) (a->u_intfwd.type) +#define XINTFWD(a) (eassert (INTFWDP (a)), &((a)->u_intfwd)) +#define XBOOLFWD(a) (eassert (BOOLFWDP (a)), &((a)->u_boolfwd)) +#define XOBJFWD(a) (eassert (OBJFWDP (a)), &((a)->u_objfwd)) #define XBUFFER_OBJFWD(a) \ - (eassert (BUFFER_OBJFWDP (a)), &(XMISC(a)->u_buffer_objfwd)) -#define XBUFFER_LOCAL_VALUE(a) \ - (eassert (BUFFER_LOCAL_VALUEP (a)), &(XMISC(a)->u_buffer_local_value)) + (eassert (BUFFER_OBJFWDP (a)), &((a)->u_buffer_objfwd)) #define XKBOARD_OBJFWD(a) \ - (eassert (KBOARD_OBJFWDP (a)), &(XMISC(a)->u_kboard_objfwd)) + (eassert (KBOARD_OBJFWDP (a)), &((a)->u_kboard_objfwd)) /* Pseudovector types. */ @@ -644,7 +643,7 @@ extern size_t pure_size; (XSTRING (string)->size = (newsize)) #define STRING_COPYIN(string, index, new, count) \ - bcopy (new, SDATA (string) + index, count) + memcpy (SDATA (string) + index, new, count) /* Type checking. */ @@ -713,11 +712,6 @@ struct Lisp_Cons #define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n)) #define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n)) -/* For performance: Fast storage of positive integers into the - fields of a cons cell. See above caveats. */ -#define XSETCARFASTINT(c,n) XSETFASTINT(XCAR_AS_LVALUE(c),(n)) -#define XSETCDRFASTINT(c,n) XSETFASTINT(XCDR_AS_LVALUE(c),(n)) - /* Take the car or cdr of something whose type is not known. */ #define CAR(c) \ (CONSP ((c)) ? XCAR ((c)) \ @@ -745,7 +739,7 @@ struct Lisp_Cons #ifdef GC_CHECK_STRING_BYTES struct Lisp_String; -extern int string_bytes P_ ((struct Lisp_String *)); +extern EMACS_INT string_bytes (struct Lisp_String *); #define STRING_BYTES(S) string_bytes ((S)) #else /* not GC_CHECK_STRING_BYTES */ @@ -784,13 +778,6 @@ struct Lisp_String unsigned char *data; }; -#ifdef offsetof -#define OFFSETOF(type,field) offsetof(type,field) -#else -#define OFFSETOF(type,field) \ - ((int)((char*)&((type*)0)->field - (char*)0)) -#endif - struct Lisp_Vector { EMACS_UINT size; @@ -801,7 +788,7 @@ struct Lisp_Vector /* If a struct is made to look like a vector, this macro returns the length of the shortest vector that would hold that struct. */ #define VECSIZE(type) ((sizeof (type) \ - - OFFSETOF (struct Lisp_Vector, contents[0]) \ + - offsetof (struct Lisp_Vector, contents[0]) \ + sizeof(Lisp_Object) - 1) /* round up */ \ / sizeof (Lisp_Object)) @@ -809,7 +796,7 @@ struct Lisp_Vector at the end and we need to compute the number of Lisp_Object fields (the ones that the GC needs to trace). */ #define PSEUDOVECSIZE(type, nonlispfield) \ - ((OFFSETOF(type, nonlispfield) - OFFSETOF(struct Lisp_Vector, contents[0])) \ + ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \ / sizeof (Lisp_Object)) /* A char-table is a kind of vectorlike, with contents are like a @@ -967,11 +954,23 @@ struct Lisp_Bool_Vector struct Lisp_Subr { EMACS_UINT size; - Lisp_Object (*function) (); + union { + Lisp_Object (*a0) (void); + Lisp_Object (*a1) (Lisp_Object); + Lisp_Object (*a2) (Lisp_Object, Lisp_Object); + Lisp_Object (*a3) (Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*a4) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*a5) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*a6) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*a7) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); + Lisp_Object (*aUNEVALLED) (Lisp_Object args); + Lisp_Object (*aMANY) (int, Lisp_Object *); + } function; short min_args, max_args; const char *symbol_name; - char *intspec; - char *doc; + const char *intspec; + const char *doc; }; @@ -988,19 +987,32 @@ enum symbol_interned SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2 }; +enum symbol_redirect +{ + SYMBOL_PLAINVAL = 4, + SYMBOL_VARALIAS = 1, + SYMBOL_LOCALIZED = 2, + SYMBOL_FORWARDED = 3 +}; + /* In a symbol, the markbit of the plist is used as the gc mark bit */ struct Lisp_Symbol { unsigned gcmarkbit : 1; - /* Non-zero means symbol serves as a variable alias. The symbol - holding the real value is found in the value slot. */ - unsigned indirect_variable : 1; + /* Indicates where the value can be found: + 0 : it's a plain var, the value is in the `value' field. + 1 : it's a varalias, the value is really in the `alias' symbol. + 2 : it's a localized var, the value is in the `blv' object. + 3 : it's a forwarding variable, the value is in `forward'. + */ + enum symbol_redirect redirect : 3; /* Non-zero means symbol is constant, i.e. changing its value - should signal an error. */ - unsigned constant : 1; + should signal an error. If the value is 3, then the var + can be changed, but only by `defconst'. */ + unsigned constant : 2; /* Interned state of the symbol. This is an enumerator from enum symbol_interned. */ @@ -1013,10 +1025,15 @@ struct Lisp_Symbol Lisp_Object xname; /* Value of the symbol or Qunbound if unbound. If this symbol is a - defvaralias, `value' contains the symbol for which it is an + defvaralias, `alias' contains the symbol for which it is an alias. Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get and set a symbol's value, to take defvaralias into account. */ - Lisp_Object value; + union { + Lisp_Object value; + struct Lisp_Symbol *alias; + struct Lisp_Buffer_Local_Value *blv; + union Lisp_Fwd *fwd; + } val; /* Function value of the symbol or Qunbound if not fboundp. */ Lisp_Object function; @@ -1030,6 +1047,23 @@ struct Lisp_Symbol /* Value is name of symbol. */ +#define SYMBOL_VAL(sym) \ + (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value) +#define SYMBOL_ALIAS(sym) \ + (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias) +#define SYMBOL_BLV(sym) \ + (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv) +#define SYMBOL_FWD(sym) \ + (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd) +#define SET_SYMBOL_VAL(sym, v) \ + (eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value = (v)) +#define SET_SYMBOL_ALIAS(sym, v) \ + (eassert ((sym)->redirect == SYMBOL_VARALIAS), (sym)->val.alias = (v)) +#define SET_SYMBOL_BLV(sym, v) \ + (eassert ((sym)->redirect == SYMBOL_LOCALIZED), (sym)->val.blv = (v)) +#define SET_SYMBOL_FWD(sym, v) \ + (eassert ((sym)->redirect == SYMBOL_FORWARDED), (sym)->val.fwd = (v)) + #define SYMBOL_NAME(sym) \ LISP_MAKE_RVALUE (XSYMBOL (sym)->xname) @@ -1049,24 +1083,6 @@ struct Lisp_Symbol #define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant -/* Value is the value of SYM, with defvaralias taken into - account. */ - -#define SYMBOL_VALUE(sym) \ - (XSYMBOL (sym)->indirect_variable \ - ? indirect_variable (XSYMBOL (sym))->value \ - : XSYMBOL (sym)->value) - -/* Set SYM's value to VAL, taking defvaralias into account. */ - -#define SET_SYMBOL_VALUE(sym, val) \ - do { \ - if (XSYMBOL (sym)->indirect_variable) \ - indirect_variable (XSYMBOL (sym))->value = (val); \ - else \ - XSYMBOL (sym)->value = (val); \ - } while (0) - /*********************************************************************** Hash Tables @@ -1136,11 +1152,11 @@ struct Lisp_Hash_Table struct Lisp_Hash_Table *next_weak; /* C function to compare two keys. */ - int (* cmpfn) P_ ((struct Lisp_Hash_Table *, Lisp_Object, - unsigned, Lisp_Object, unsigned)); + int (* cmpfn) (struct Lisp_Hash_Table *, Lisp_Object, + unsigned, Lisp_Object, unsigned); /* C function to compute hash code. */ - unsigned (* hashfn) P_ ((struct Lisp_Hash_Table *, Lisp_Object)); + unsigned (* hashfn) (struct Lisp_Hash_Table *, Lisp_Object); }; @@ -1200,9 +1216,11 @@ struct Lisp_Hash_Table struct Lisp_Misc_Any /* Supertype of all Misc types. */ { - enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Marker */ + enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ unsigned gcmarkbit : 1; int spacer : 15; + /* Make it as long as "Lisp_Free without padding". */ + void *fill; }; struct Lisp_Marker @@ -1225,7 +1243,7 @@ struct Lisp_Marker - Fmarker_buffer - Fset_marker: check eq(oldbuf, newbuf) to avoid unchain+rechain. - unchain_marker: to find the list from which to unchain. - - Fkill_buffer: to unchain the markers of current indirect buffer. + - Fkill_buffer: to only unchain the markers of current indirect buffer. */ struct buffer *buffer; @@ -1239,7 +1257,10 @@ struct Lisp_Marker struct Lisp_Marker *next; /* This is the char position where the marker points. */ EMACS_INT charpos; - /* This is the byte position. */ + /* This is the byte position. + It's mostly used as a charpos<->bytepos cache (i.e. it's not directly + used to implement the functionality of markers, but rather to (ab)use + markers as a cache for char<->byte mappings). */ EMACS_INT bytepos; }; @@ -1249,9 +1270,7 @@ struct Lisp_Marker specified int variable. */ struct Lisp_Intfwd { - int type : 16; /* = Lisp_Misc_Intfwd */ - unsigned gcmarkbit : 1; - int spacer : 15; + enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Int */ EMACS_INT *intvar; }; @@ -1261,9 +1280,7 @@ struct Lisp_Intfwd nil if it is zero. */ struct Lisp_Boolfwd { - int type : 16; /* = Lisp_Misc_Boolfwd */ - unsigned gcmarkbit : 1; - int spacer : 15; + enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ int *boolvar; }; @@ -1273,9 +1290,7 @@ struct Lisp_Boolfwd specified variable. */ struct Lisp_Objfwd { - int type : 16; /* = Lisp_Misc_Objfwd */ - unsigned gcmarkbit : 1; - int spacer : 15; + enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Obj */ Lisp_Object *objvar; }; @@ -1283,11 +1298,9 @@ struct Lisp_Objfwd current buffer. Value is byte index of slot within buffer. */ struct Lisp_Buffer_Objfwd { - int type : 16; /* = Lisp_Misc_Buffer_Objfwd */ - unsigned gcmarkbit : 1; - int spacer : 15; - Lisp_Object slottype; /* Qnil, Lisp_Int, Lisp_Symbol, or Lisp_String. */ + enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Buffer_Obj */ int offset; + Lisp_Object slottype; /* Qnil, Lisp_Int, Lisp_Symbol, or Lisp_String. */ }; /* struct Lisp_Buffer_Local_Value is used in a symbol value cell when @@ -1316,48 +1329,51 @@ struct Lisp_Buffer_Objfwd struct Lisp_Buffer_Local_Value { - int type : 16; /* = Lisp_Misc_Buffer_Local_Value */ - unsigned gcmarkbit : 1; - int spacer : 11; - /* 1 means that merely setting the variable creates a local binding for the current buffer */ unsigned int local_if_set : 1; - /* 1 means this variable is allowed to have frame-local bindings, - so check for them when looking for the proper binding. */ - unsigned int check_frame : 1; - /* 1 means that the binding now loaded was found - as a local binding for the buffer in the `buffer' slot. */ - unsigned int found_for_buffer : 1; - /* 1 means that the binding now loaded was found - as a local binding for the frame in the `frame' slot. */ - unsigned int found_for_frame : 1; - Lisp_Object realvalue; - /* The buffer and frame for which the loaded binding was found. */ - /* Having both is only needed if we want to allow variables that are - both buffer local and frame local (in which case, we currently give - precedence to the buffer-local binding). I don't think such - a combination is desirable. --Stef */ - Lisp_Object buffer, frame; - - /* A cons cell, (LOADED-BINDING . DEFAULT-VALUE). - - LOADED-BINDING is the binding now loaded. It is a cons cell - whose cdr is the binding's value. The cons cell may be an - element of a buffer's local-variable alist, or an element of a - frame's parameter alist, or it may be this cons cell. - - DEFAULT-VALUE is the variable's default value, seen when the - current buffer and selected frame do not have their own - bindings for the variable. When the default binding is loaded, - LOADED-BINDING is actually this very cons cell; thus, its car - points to itself. */ - Lisp_Object cdr; + /* 1 means this variable can have frame-local bindings, otherwise, it is + can have buffer-local bindings. The two cannot be combined. */ + unsigned int frame_local : 1; + /* 1 means that the binding now loaded was found. + Presumably equivalent to (defcell!=valcell) */ + unsigned int found : 1; + /* If non-NULL, a forwarding to the C var where it should also be set. */ + union Lisp_Fwd *fwd; /* Should never be (Buffer|Kboard)_Objfwd. */ + /* The buffer or frame for which the loaded binding was found. */ + Lisp_Object where; + /* A cons cell that holds the default value. It has the form + (SYMBOL . DEFAULT-VALUE). */ + Lisp_Object defcell; + /* The cons cell from `where's parameter alist. + It always has the form (SYMBOL . VALUE) + Note that if `forward' is non-nil, VALUE may be out of date. + Also if the currently loaded binding is the default binding, then + this is `eq'ual to defcell. */ + Lisp_Object valcell; }; +#define BLV_FOUND(blv) \ + (eassert ((blv)->found == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found) +#define SET_BLV_FOUND(blv, v) \ + (eassert ((v) == !EQ ((blv)->defcell, (blv)->valcell)), (blv)->found = (v)) + +#define BLV_VALUE(blv) (XCDR ((blv)->valcell)) +#define SET_BLV_VALUE(blv, v) (XSETCDR ((blv)->valcell, v)) + /* START and END are markers in the overlay's buffer, and PLIST is the overlay's property list. */ struct Lisp_Overlay +/* An overlay's real data content is: + - plist + - buffer + - insertion type of both ends + - start & start_byte + - end & end_byte + - next (singly linked list of overlays). + - start_next and end_next (singly linked list of markers). + I.e. 9words plus 2 bits, 3words of which are for external linked lists. +*/ { enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Overlay */ unsigned gcmarkbit : 1; @@ -1370,9 +1386,7 @@ struct Lisp_Overlay current kboard. */ struct Lisp_Kboard_Objfwd { - enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Kboard_Objfwd */ - unsigned gcmarkbit : 1; - int spacer : 15; + enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Kboard_Obj */ int offset; }; @@ -1401,9 +1415,9 @@ struct Lisp_Free #ifdef USE_LSB_TAG /* Try to make sure that sizeof(Lisp_Misc) preserves TYPEBITS-alignment. This assumes that Lisp_Marker is the largest of the alternatives and - that Lisp_Intfwd has the same size as "Lisp_Free w/o padding". */ + that Lisp_Misc_Any has the same size as "Lisp_Free w/o padding". */ char padding[((((sizeof (struct Lisp_Marker) - 1) >> GCTYPEBITS) + 1) - << GCTYPEBITS) - sizeof (struct Lisp_Intfwd)]; + << GCTYPEBITS) - sizeof (struct Lisp_Misc_Any)]; #endif }; @@ -1414,15 +1428,18 @@ union Lisp_Misc { struct Lisp_Misc_Any u_any; /* Supertype of all Misc types. */ struct Lisp_Free u_free; /* Includes padding to force alignment. */ - struct Lisp_Marker u_marker; - struct Lisp_Intfwd u_intfwd; - struct Lisp_Boolfwd u_boolfwd; - struct Lisp_Objfwd u_objfwd; - struct Lisp_Buffer_Objfwd u_buffer_objfwd; - struct Lisp_Buffer_Local_Value u_buffer_local_value; - struct Lisp_Overlay u_overlay; - struct Lisp_Kboard_Objfwd u_kboard_objfwd; - struct Lisp_Save_Value u_save_value; + struct Lisp_Marker u_marker; /* 5 */ + struct Lisp_Overlay u_overlay; /* 5 */ + struct Lisp_Save_Value u_save_value; /* 3 */ + }; + +union Lisp_Fwd + { + struct Lisp_Intfwd u_intfwd; /* 2 */ + struct Lisp_Boolfwd u_boolfwd; /* 2 */ + struct Lisp_Objfwd u_objfwd; /* 2 */ + struct Lisp_Buffer_Objfwd u_buffer_objfwd; /* 2 */ + struct Lisp_Kboard_Objfwd u_kboard_objfwd; /* 2 */ }; /* Lisp floating point type */ @@ -1440,9 +1457,9 @@ struct Lisp_Float }; #ifdef HIDE_LISP_IMPLEMENTATION -#define XFLOAT_DATA(f) (XFLOAT (f)->u.data_ + 0) +#define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data_ : XFLOAT (f)->u.data_) #else -#define XFLOAT_DATA(f) (XFLOAT (f)->u.data + 0) +#define XFLOAT_DATA(f) (0 ? XFLOAT (f)->u.data : XFLOAT (f)->u.data) /* This should be used only in alloc.c, which always disables HIDE_LISP_IMPLEMENTATION. */ #define XFLOAT_INIT(f,n) (XFLOAT (f)->u.data = (n)) @@ -1564,15 +1581,13 @@ typedef struct { #define VECTORP(x) (VECTORLIKEP (x) && !(XVECTOR (x)->size & PSEUDOVECTOR_FLAG)) #define OVERLAYP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Overlay) #define MARKERP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Marker) -#define INTFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Intfwd) -#define BOOLFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Boolfwd) -#define OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Objfwd) -#define BUFFER_OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Buffer_Objfwd) -#define BUFFER_LOCAL_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Buffer_Local_Value) -#define SOME_BUFFER_LOCAL_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Some_Buffer_Local_Value) -#define KBOARD_OBJFWDP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Kboard_Objfwd) #define SAVE_VALUEP(x) (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value) +#define INTFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Int) +#define BOOLFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Bool) +#define OBJFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Obj) +#define BUFFER_OBJFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Buffer_Obj) +#define KBOARD_OBJFWDP(x) (XFWDTYPE (x) == Lisp_Fwd_Kboard_Obj) /* True if object X is a pseudovector whose code is CODE. */ #define PSEUDOVECTORP(x, code) \ @@ -1754,7 +1769,8 @@ typedef struct { Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ DECL_ALIGN (struct Lisp_Subr, sname) = \ { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \ - fnname, minargs, maxargs, lname, intspec, 0}; \ + { .a ## maxargs = fnname }, \ + minargs, maxargs, lname, intspec, 0}; \ Lisp_Object fnname /* Note that the weird token-substitution semantics of ANSI C makes @@ -1784,29 +1800,49 @@ typedef struct { /* defsubr (Sname); is how we define the symbol for function `name' at start-up time. */ -extern void defsubr P_ ((struct Lisp_Subr *)); +extern void defsubr (struct Lisp_Subr *); #define MANY -2 #define UNEVALLED -1 -extern void defvar_lisp (const char *, Lisp_Object *); -extern void defvar_lisp_nopro (const char *, Lisp_Object *); -extern void defvar_bool (const char *, int *); -extern void defvar_int (const char *, EMACS_INT *); -extern void defvar_kboard (const char *, int); +extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); +extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); +extern void defvar_bool (struct Lisp_Boolfwd *, const char *, int *); +extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *); +extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); /* Macros we use to define forwarded Lisp variables. These are used in the syms_of_FILENAME functions. */ -#define DEFVAR_LISP(lname, vname, doc) defvar_lisp (lname, vname) -#define DEFVAR_LISP_NOPRO(lname, vname, doc) defvar_lisp_nopro (lname, vname) -#define DEFVAR_BOOL(lname, vname, doc) defvar_bool (lname, vname) -#define DEFVAR_INT(lname, vname, doc) defvar_int (lname, vname) +#define DEFVAR_LISP(lname, vname, doc) \ + do { \ + static struct Lisp_Objfwd o_fwd; \ + defvar_lisp (&o_fwd, lname, vname); \ + } while (0) +#define DEFVAR_LISP_NOPRO(lname, vname, doc) \ + do { \ + static struct Lisp_Objfwd o_fwd; \ + defvar_lisp_nopro (&o_fwd, lname, vname); \ + } while (0) +#define DEFVAR_BOOL(lname, vname, doc) \ + do { \ + static struct Lisp_Boolfwd b_fwd; \ + defvar_bool (&b_fwd, lname, vname); \ + } while (0) +#define DEFVAR_INT(lname, vname, doc) \ + do { \ + static struct Lisp_Intfwd i_fwd; \ + defvar_int (&i_fwd, lname, vname); \ + } while (0) -#define DEFVAR_KBOARD(lname, vname, doc) \ - defvar_kboard (lname, \ - (int)((char *)(¤t_kboard->vname) \ - - (char *)current_kboard)) +#define DEFVAR_KBOARD(lname, vname, doc) \ + do { \ + static struct Lisp_Kboard_Objfwd ko_fwd; \ + defvar_kboard (&ko_fwd, \ + lname, \ + (int)((char *)(¤t_kboard->vname) \ + - (char *)current_kboard)); \ + } while (0) @@ -1830,7 +1866,7 @@ extern void defvar_kboard (const char *, int); WHERE being a buffer or frame means we saw a buffer-local or frame-local value. Other values of WHERE mean an internal error. */ -typedef Lisp_Object (*specbinding_func) P_ ((Lisp_Object)); +typedef Lisp_Object (*specbinding_func) (Lisp_Object); struct specbinding { @@ -1841,11 +1877,11 @@ struct specbinding extern struct specbinding *specpdl; extern struct specbinding *specpdl_ptr; -extern int specpdl_size; +extern EMACS_INT specpdl_size; extern EMACS_INT max_specpdl_size; -#define SPECPDL_INDEX() (specpdl_ptr - specpdl) +#define SPECPDL_INDEX() ((int) (specpdl_ptr - specpdl)) /* Everything needed to describe an active condition case. */ struct handler @@ -1930,7 +1966,7 @@ extern char *stack_bottom; and (in particular) cannot call arbitrary Lisp code. */ #ifdef SYNC_INPUT -extern void process_pending_signals P_ ((void)); +extern void process_pending_signals (void); extern int pending_signals; #define ELSE_PENDING_SIGNALS \ else if (pending_signals) \ @@ -2203,7 +2239,7 @@ while (0) /* Call staticpro (&var) to protect static variable `var'. */ -void staticpro P_ ((Lisp_Object *)); +void staticpro (Lisp_Object *); /* Declare a Lisp-callable function. The MAXARGS parameter has the same meaning as in the DEFUN macro, and is used to construct a prototype. */ @@ -2226,7 +2262,8 @@ extern Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; extern Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive; extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; extern Lisp_Object Qtext_read_only; - +extern Lisp_Object Qinteractive_form; +extern Lisp_Object Qcircular_list; extern Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp; extern Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; extern Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; @@ -2246,7 +2283,7 @@ extern Lisp_Object Qinteger; extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; -extern void circular_list_error P_ ((Lisp_Object)) NO_RETURN; +extern void circular_list_error (Lisp_Object) NO_RETURN; EXFUN (Finteractive_form, 1); EXFUN (Fbyteorder, 0); @@ -2289,12 +2326,12 @@ EXFUN (Ffmakunbound, 1); EXFUN (Fsymbol_function, 1); EXFUN (Fsymbol_plist, 1); EXFUN (Fsymbol_name, 1); -extern Lisp_Object indirect_function P_ ((Lisp_Object)); +extern Lisp_Object indirect_function (Lisp_Object); EXFUN (Findirect_function, 2); EXFUN (Ffset, 2); EXFUN (Fsetplist, 2); EXFUN (Fsymbol_value, 1); -extern Lisp_Object find_symbol_value P_ ((Lisp_Object)); +extern Lisp_Object find_symbol_value (Lisp_Object); EXFUN (Fset, 2); EXFUN (Fdefault_value, 1); EXFUN (Fset_default, 2); @@ -2334,68 +2371,64 @@ EXFUN (Fsub1, 1); EXFUN (Fmake_variable_buffer_local, 1); extern struct Lisp_Symbol *indirect_variable (struct Lisp_Symbol *); -extern Lisp_Object long_to_cons P_ ((unsigned long)); -extern unsigned long cons_to_long P_ ((Lisp_Object)); -extern void args_out_of_range P_ ((Lisp_Object, Lisp_Object)) NO_RETURN; -extern void args_out_of_range_3 P_ ((Lisp_Object, Lisp_Object, - Lisp_Object)) NO_RETURN; -extern Lisp_Object wrong_type_argument P_ ((Lisp_Object, Lisp_Object)) NO_RETURN; -extern void store_symval_forwarding P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, struct buffer *)); -extern Lisp_Object do_symval_forwarding P_ ((Lisp_Object)); -extern Lisp_Object set_internal P_ ((Lisp_Object, Lisp_Object, struct buffer *, int)); -extern void syms_of_data P_ ((void)); -extern void init_data P_ ((void)); -extern void swap_in_global_binding P_ ((Lisp_Object)); +extern Lisp_Object long_to_cons (unsigned long); +extern unsigned long cons_to_long (Lisp_Object); +extern void args_out_of_range (Lisp_Object, Lisp_Object) NO_RETURN; +extern void args_out_of_range_3 (Lisp_Object, Lisp_Object, + Lisp_Object) NO_RETURN; +extern Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object) NO_RETURN; +extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); +extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, int); +extern void syms_of_data (void); +extern void init_data (void); +extern void swap_in_global_binding (struct Lisp_Symbol *); /* Defined in cmds.c */ EXFUN (Fend_of_line, 1); EXFUN (Fforward_char, 1); EXFUN (Fforward_line, 1); -extern int internal_self_insert P_ ((int, int)); -extern void syms_of_cmds P_ ((void)); -extern void keys_of_cmds P_ ((void)); +extern void syms_of_cmds (void); +extern void keys_of_cmds (void); /* Defined in coding.c */ EXFUN (Fcoding_system_p, 1); EXFUN (Fcoding_system_base, 1); EXFUN (Fcoding_system_eol_type, 1); EXFUN (Fcheck_coding_system, 1); -EXFUN (Fcheck_coding_system, 1); EXFUN (Fread_coding_system, 2); EXFUN (Fread_non_nil_coding_system, 1); EXFUN (Ffind_operation_coding_system, MANY); EXFUN (Fupdate_coding_systems_internal, 0); EXFUN (Fencode_coding_string, 4); EXFUN (Fdecode_coding_string, 4); -extern Lisp_Object detect_coding_system P_ ((const unsigned char *, EMACS_INT, - EMACS_INT, int, int, Lisp_Object)); -extern void init_coding P_ ((void)); -extern void init_coding_once P_ ((void)); -extern void syms_of_coding P_ ((void)); +extern Lisp_Object detect_coding_system (const unsigned char *, EMACS_INT, + EMACS_INT, int, int, Lisp_Object); +extern void init_coding (void); +extern void init_coding_once (void); +extern void syms_of_coding (void); /* Defined in character.c */ -extern void init_character_once P_ ((void)); -extern void syms_of_character P_ ((void)); +extern void init_character_once (void); +extern void syms_of_character (void); EXFUN (Funibyte_char_to_multibyte, 1); /* Defined in charset.c */ EXFUN (Fchar_bytes, 1); EXFUN (Fchar_width, 1); EXFUN (Fstring, MANY); -extern EMACS_INT chars_in_text P_ ((const unsigned char *, EMACS_INT)); -extern EMACS_INT multibyte_chars_in_text P_ ((const unsigned char *, EMACS_INT)); -extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object)); -extern int multibyte_char_to_unibyte_safe P_ ((int)); +extern EMACS_INT chars_in_text (const unsigned char *, EMACS_INT); +extern EMACS_INT multibyte_chars_in_text (const unsigned char *, EMACS_INT); +extern int multibyte_char_to_unibyte (int, Lisp_Object); +extern int multibyte_char_to_unibyte_safe (int); extern Lisp_Object Qcharset; -extern void init_charset P_ ((void)); -extern void init_charset_once P_ ((void)); -extern void syms_of_charset P_ ((void)); +extern void init_charset (void); +extern void init_charset_once (void); +extern void syms_of_charset (void); /* Structure forward declarations. */ struct charset; /* Defined in composite.c */ -extern void syms_of_composite P_ ((void)); +extern void syms_of_composite (void); /* Defined in syntax.c */ EXFUN (Fforward_word, 1); @@ -2404,28 +2437,31 @@ EXFUN (Fskip_chars_backward, 2); EXFUN (Fsyntax_table_p, 1); EXFUN (Fsyntax_table, 0); EXFUN (Fset_syntax_table, 1); -extern void init_syntax_once P_ ((void)); -extern void syms_of_syntax P_ ((void)); +extern void init_syntax_once (void); +extern void syms_of_syntax (void); /* Defined in fns.c */ +extern Lisp_Object QCrehash_size, QCrehash_threshold; extern int use_dialog_box; -extern int next_almost_prime P_ ((int)); -extern Lisp_Object larger_vector P_ ((Lisp_Object, int, Lisp_Object)); -extern void sweep_weak_hash_tables P_ ((void)); +extern int use_file_dialog; +extern int next_almost_prime (int); +extern Lisp_Object larger_vector (Lisp_Object, int, Lisp_Object); +extern void sweep_weak_hash_tables (void); +extern Lisp_Object Qcursor_in_echo_area; extern Lisp_Object Qstring_lessp; extern Lisp_Object Vfeatures; -extern Lisp_Object QCtest, QCweakness, Qequal, Qeq; -unsigned sxhash P_ ((Lisp_Object, int)); -Lisp_Object make_hash_table P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object)); -Lisp_Object copy_hash_table P_ ((struct Lisp_Hash_Table *)); -int hash_lookup P_ ((struct Lisp_Hash_Table *, Lisp_Object, unsigned *)); -int hash_put P_ ((struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, - unsigned)); -void hash_clear P_ ((struct Lisp_Hash_Table *)); -void init_weak_hash_tables P_ ((void)); -extern void init_fns P_ ((void)); +extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql; +unsigned sxhash (Lisp_Object, int); +Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object); +Lisp_Object copy_hash_table (struct Lisp_Hash_Table *); +int hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, unsigned *); +int hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, + unsigned); +void hash_clear (struct Lisp_Hash_Table *); +void init_weak_hash_tables (void); +extern void init_fns (void); EXFUN (Fsxhash, 1); EXFUN (Fmake_hash_table, MANY); EXFUN (Fmakehash, 1); @@ -2459,7 +2495,8 @@ EXFUN (Fstring_as_unibyte, 1); EXFUN (Fstring_to_multibyte, 1); EXFUN (Fstring_to_unibyte, 1); EXFUN (Fsubstring, 3); -extern Lisp_Object substring_both P_ ((Lisp_Object, int, int, int, int)); +extern Lisp_Object substring_both (Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT); EXFUN (Fnth, 2); EXFUN (Fnthcdr, 2); EXFUN (Fmemq, 2); @@ -2480,21 +2517,20 @@ EXFUN (Ffillarray, 2); EXFUN (Fnconc, MANY); EXFUN (Fmapcar, 2); EXFUN (Fmapconcat, 3); -EXFUN (Fy_or_n_p, 1); -extern Lisp_Object do_yes_or_no_p P_ ((Lisp_Object)); +extern Lisp_Object do_yes_or_no_p (Lisp_Object); EXFUN (Frequire, 3); EXFUN (Fprovide, 2); -extern Lisp_Object concat2 P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object concat3 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object nconc2 P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object assq_no_quit P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object assoc_no_quit P_ ((Lisp_Object, Lisp_Object)); -extern void clear_string_char_byte_cache P_ ((void)); -extern EMACS_INT string_char_to_byte P_ ((Lisp_Object, EMACS_INT)); -extern EMACS_INT string_byte_to_char P_ ((Lisp_Object, EMACS_INT)); -extern Lisp_Object string_make_multibyte P_ ((Lisp_Object)); -extern Lisp_Object string_to_multibyte P_ ((Lisp_Object)); -extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); +extern Lisp_Object concat2 (Lisp_Object, Lisp_Object); +extern Lisp_Object concat3 (Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object nconc2 (Lisp_Object, Lisp_Object); +extern Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object); +extern Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object); +extern void clear_string_char_byte_cache (void); +extern EMACS_INT string_char_to_byte (Lisp_Object, EMACS_INT); +extern EMACS_INT string_byte_to_char (Lisp_Object, EMACS_INT); +extern Lisp_Object string_make_multibyte (Lisp_Object); +extern Lisp_Object string_to_multibyte (Lisp_Object); +extern Lisp_Object string_make_unibyte (Lisp_Object); EXFUN (Fcopy_alist, 1); EXFUN (Fplist_get, 2); EXFUN (Fplist_put, 3); @@ -2503,24 +2539,28 @@ EXFUN (Frassoc, 2); EXFUN (Fstring_equal, 2); EXFUN (Fcompare_strings, 7); EXFUN (Fstring_lessp, 2); -extern void syms_of_fns P_ ((void)); +extern void syms_of_fns (void); /* Defined in floatfns.c */ -extern double extract_float P_ ((Lisp_Object)); +extern double extract_float (Lisp_Object); EXFUN (Ffloat, 1); EXFUN (Ftruncate, 2); -extern void init_floatfns P_ ((void)); -extern void syms_of_floatfns P_ ((void)); +extern void init_floatfns (void); +extern void syms_of_floatfns (void); +extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y); /* Defined in fringe.c */ -extern void syms_of_fringe P_ ((void)); -extern void init_fringe P_ ((void)); -extern void init_fringe_once P_ ((void)); +extern void syms_of_fringe (void); +extern void init_fringe (void); +extern void init_fringe_once (void); /* Defined in image.c */ +extern Lisp_Object QCascent, QCmargin, QCrelief, Qcount, Qextension_data; +extern Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; +extern Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask; EXFUN (Finit_image_library, 2); -extern void syms_of_image P_ ((void)); -extern void init_image P_ ((void)); +extern void syms_of_image (void); +extern void init_image (void); /* Defined in insdel.c */ extern Lisp_Object Qinhibit_modification_hooks; @@ -2571,85 +2611,99 @@ extern void adjust_markers_for_delete (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT); extern void replace_range (EMACS_INT, EMACS_INT, Lisp_Object, int, int, int); extern void replace_range_2 (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, - char *, EMACS_INT, EMACS_INT, int); + const char *, EMACS_INT, EMACS_INT, int); extern void syms_of_insdel (void); /* Defined in dispnew.c */ extern Lisp_Object selected_frame; +extern Lisp_Object Vwindow_system_version; extern EMACS_INT baud_rate; EXFUN (Fding, 1); EXFUN (Fredraw_frame, 1); EXFUN (Fredraw_display, 0); EXFUN (Fsleep_for, 2); EXFUN (Fredisplay, 1); -extern Lisp_Object sit_for P_ ((Lisp_Object, int, int)); -extern void init_display P_ ((void)); -extern void syms_of_display P_ ((void)); -extern void safe_bcopy P_ ((const char *, char *, int)); +extern Lisp_Object sit_for (Lisp_Object, int, int); +extern void init_display (void); +extern void syms_of_display (void); /* Defined in xdisp.c */ extern Lisp_Object Qinhibit_point_motion_hooks; extern Lisp_Object Qinhibit_redisplay, Qdisplay; extern Lisp_Object Qinhibit_eval_during_redisplay; extern Lisp_Object Qmessage_truncate_lines; -extern Lisp_Object Qimage; +extern Lisp_Object Qmenu_bar_update_hook; +extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; +extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; +extern Lisp_Object Qimage, Qtext, Qboth, Qboth_horiz, Qtext_image_horiz; +extern Lisp_Object Qspace, Qcenter, QCalign_to; +extern Lisp_Object Qbar, Qhbar, Qbox, Qhollow; +extern Lisp_Object Qleft_margin, Qright_margin; extern Lisp_Object Vmessage_log_max; +extern Lisp_Object QCdata, QCfile; +extern Lisp_Object QCmap; +extern Lisp_Object Qrisky_local_variable; +extern Lisp_Object Vinhibit_redisplay; extern int message_enable_multibyte; +extern int noninteractive_need_newline; +extern EMACS_INT scroll_margin; extern Lisp_Object echo_area_buffer[2]; -extern void check_message_stack P_ ((void)); -extern void setup_echo_area_for_printing P_ ((int)); -extern int push_message P_ ((void)); -extern Lisp_Object pop_message_unwind P_ ((Lisp_Object)); -extern Lisp_Object restore_message_unwind P_ ((Lisp_Object)); -extern void pop_message P_ ((void)); -extern void restore_message P_ ((void)); -extern Lisp_Object current_message P_ ((void)); -extern void set_message P_ ((const char *s, Lisp_Object, int, int)); -extern void clear_message P_ ((int, int)); -extern void message P_ ((/* char *, ... */)); -extern void message_nolog P_ ((/* char *, ... */)); -extern void message1 P_ ((char *)); -extern void message1_nolog P_ ((char *)); -extern void message2 P_ ((const char *, int, int)); -extern void message2_nolog P_ ((const char *, int, int)); -extern void message3 P_ ((Lisp_Object, int, int)); -extern void message3_nolog P_ ((Lisp_Object, int, int)); -extern void message_dolog P_ ((const char *, int, int, int)); -extern void message_with_string P_ ((char *, Lisp_Object, int)); -extern void message_log_maybe_newline P_ ((void)); -extern void update_echo_area P_ ((void)); -extern void truncate_echo_area P_ ((int)); -extern void redisplay P_ ((void)); +extern void add_to_log (const char *, Lisp_Object, Lisp_Object); +extern void check_message_stack (void); +extern void setup_echo_area_for_printing (int); +extern int push_message (void); +extern Lisp_Object pop_message_unwind (Lisp_Object); +extern Lisp_Object restore_message_unwind (Lisp_Object); +extern void pop_message (void); +extern void restore_message (void); +extern Lisp_Object current_message (void); +extern void set_message (const char *s, Lisp_Object, EMACS_INT, int); +extern void clear_message (int, int); +extern void message (const char *, ...); +extern void message_nolog (const char *, ...); +extern void message1 (const char *); +extern void message1_nolog (const char *); +extern void message2 (const char *, EMACS_INT, int); +extern void message2_nolog (const char *, EMACS_INT, int); +extern void message3 (Lisp_Object, EMACS_INT, int); +extern void message3_nolog (Lisp_Object, EMACS_INT, int); +extern void message_dolog (const char *, EMACS_INT, int, int); +extern void message_with_string (const char *, Lisp_Object, int); +extern void message_log_maybe_newline (void); +extern void update_echo_area (void); +extern void truncate_echo_area (EMACS_INT); +extern void redisplay (void); extern int check_point_in_composition - P_ ((struct buffer *, int, struct buffer *, int)); -extern void redisplay_preserve_echo_area P_ ((int)); -extern void prepare_menu_bars P_ ((void)); + (struct buffer *, EMACS_INT, struct buffer *, EMACS_INT); +extern void redisplay_preserve_echo_area (int); +extern void prepare_menu_bars (void); -void set_frame_cursor_types P_ ((struct frame *, Lisp_Object)); -extern void syms_of_xdisp P_ ((void)); -extern void init_xdisp P_ ((void)); -extern Lisp_Object safe_eval P_ ((Lisp_Object)); -extern int pos_visible_p P_ ((struct window *, int, int *, - int *, int *, int *, int *, int *)); +void set_frame_cursor_types (struct frame *, Lisp_Object); +extern void syms_of_xdisp (void); +extern void init_xdisp (void); +extern Lisp_Object safe_eval (Lisp_Object); +extern int pos_visible_p (struct window *, EMACS_INT, int *, + int *, int *, int *, int *, int *); /* Defined in xsettings.c */ -extern void syms_of_xsettings P_ ((void)); +extern void syms_of_xsettings (void); /* Defined in vm-limit.c. */ -extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ())); +extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *)); /* Defined in alloc.c */ -extern void check_pure_size P_ ((void)); -extern void allocate_string_data P_ ((struct Lisp_String *, int, int)); -extern void reset_malloc_hooks P_ ((void)); -extern void uninterrupt_malloc P_ ((void)); -extern void malloc_warning P_ ((char *)); -extern void memory_full P_ ((void)) NO_RETURN; -extern void buffer_memory_full P_ ((void)) NO_RETURN; -extern int survives_gc_p P_ ((Lisp_Object)); -extern void mark_object P_ ((Lisp_Object)); +extern void check_pure_size (void); +extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); +extern void reset_malloc_hooks (void); +extern void uninterrupt_malloc (void); +extern void malloc_warning (const char *); +extern void memory_full (void) NO_RETURN; +extern void buffer_memory_full (void) NO_RETURN; +extern int survives_gc_p (Lisp_Object); +extern void mark_object (Lisp_Object); extern Lisp_Object Vpurify_flag; extern Lisp_Object Vmemory_full; +extern Lisp_Object *stack_base; EXFUN (Fcons, 2); EXFUN (list1, 1); EXFUN (list2, 2); @@ -2658,55 +2712,56 @@ EXFUN (list4, 4); EXFUN (list5, 5); EXFUN (Flist, MANY); EXFUN (Fmake_list, 2); -extern Lisp_Object allocate_misc P_ ((void)); +extern Lisp_Object allocate_misc (void); EXFUN (Fmake_vector, 2); EXFUN (Fvector, MANY); EXFUN (Fmake_symbol, 1); EXFUN (Fmake_marker, 0); EXFUN (Fmake_string, 2); -extern Lisp_Object build_string P_ ((const char *)); -extern Lisp_Object make_string P_ ((const char *, int)); -extern Lisp_Object make_unibyte_string P_ ((const char *, int)); -extern Lisp_Object make_multibyte_string P_ ((const char *, int, int)); -extern Lisp_Object make_event_array P_ ((int, Lisp_Object *)); -extern Lisp_Object make_uninit_string P_ ((int)); -extern Lisp_Object make_uninit_multibyte_string P_ ((int, int)); -extern Lisp_Object make_string_from_bytes P_ ((const char *, int, int)); -extern Lisp_Object make_specified_string P_ ((const char *, int, int, int)); +extern Lisp_Object build_string (const char *); +extern Lisp_Object make_string (const char *, EMACS_INT); +extern Lisp_Object make_unibyte_string (const char *, EMACS_INT); +extern Lisp_Object make_multibyte_string (const char *, EMACS_INT, EMACS_INT); +extern Lisp_Object make_event_array (int, Lisp_Object *); +extern Lisp_Object make_uninit_string (EMACS_INT); +extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT); +extern Lisp_Object make_string_from_bytes (const char *, EMACS_INT, EMACS_INT); +extern Lisp_Object make_specified_string (const char *, + EMACS_INT, EMACS_INT, int); EXFUN (Fpurecopy, 1); -extern Lisp_Object make_pure_string P_ ((const char *, int, int, int)); +extern Lisp_Object make_pure_string (const char *, EMACS_INT, EMACS_INT, int); extern Lisp_Object make_pure_c_string (const char *data); -extern Lisp_Object pure_cons P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object make_pure_vector P_ ((EMACS_INT)); +extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object); +extern Lisp_Object make_pure_vector (EMACS_INT); EXFUN (Fgarbage_collect, 0); EXFUN (Fmake_byte_code, MANY); EXFUN (Fmake_bool_vector, 2); extern Lisp_Object Qchar_table_extra_slots; -extern struct Lisp_Vector *allocate_vector P_ ((EMACS_INT)); -extern struct Lisp_Vector *allocate_pseudovector P_ ((int memlen, int lisplen, EMACS_INT tag)); +extern struct Lisp_Vector *allocate_vector (EMACS_INT); +extern struct Lisp_Vector *allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag); #define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \ ((typ*) \ allocate_pseudovector \ (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag)) -extern struct Lisp_Hash_Table *allocate_hash_table P_ ((void)); -extern struct window *allocate_window P_ ((void)); -extern struct frame *allocate_frame P_ ((void)); -extern struct Lisp_Process *allocate_process P_ ((void)); -extern struct terminal *allocate_terminal P_ ((void)); +extern struct Lisp_Hash_Table *allocate_hash_table (void); +extern struct window *allocate_window (void); +extern struct frame *allocate_frame (void); +extern struct Lisp_Process *allocate_process (void); +extern struct terminal *allocate_terminal (void); extern int gc_in_progress; extern int abort_on_gc; -extern Lisp_Object make_float P_ ((double)); -extern void display_malloc_warning P_ ((void)); -extern int inhibit_garbage_collection P_ ((void)); -extern Lisp_Object make_save_value P_ ((void *, int)); -extern void free_misc P_ ((Lisp_Object)); -extern void free_marker P_ ((Lisp_Object)); -extern void free_cons P_ ((struct Lisp_Cons *)); -extern void init_alloc_once P_ ((void)); -extern void init_alloc P_ ((void)); -extern void syms_of_alloc P_ ((void)); -extern struct buffer * allocate_buffer P_ ((void)); -extern int valid_lisp_object_p P_ ((Lisp_Object)); +extern Lisp_Object make_float (double); +extern void display_malloc_warning (void); +extern int inhibit_garbage_collection (void); +extern Lisp_Object make_save_value (void *, int); +extern void free_misc (Lisp_Object); +extern void free_marker (Lisp_Object); +extern void free_cons (struct Lisp_Cons *); +extern void init_alloc_once (void); +extern void init_alloc (void); +extern void syms_of_alloc (void); +extern struct buffer * allocate_buffer (void); +extern int valid_lisp_object_p (Lisp_Object); /* Defined in chartab.c */ EXFUN (Fmake_char_table, 2); @@ -2719,23 +2774,28 @@ EXFUN (Fset_char_table_range, 3); EXFUN (Fset_char_table_default, 3); EXFUN (Foptimize_char_table, 2); EXFUN (Fmap_char_table, 2); -extern Lisp_Object copy_char_table P_ ((Lisp_Object)); -extern Lisp_Object sub_char_table_ref P_ ((Lisp_Object, int)); -extern Lisp_Object char_table_ref P_ ((Lisp_Object, int)); -extern Lisp_Object char_table_ref_and_range P_ ((Lisp_Object, int, - int *, int *)); -extern Lisp_Object char_table_set P_ ((Lisp_Object, int, Lisp_Object)); -extern Lisp_Object char_table_set_range P_ ((Lisp_Object, int, int, - Lisp_Object)); -extern int char_table_translate P_ ((Lisp_Object, int)); -extern void map_char_table P_ ((void (*) (Lisp_Object, Lisp_Object, - Lisp_Object), - Lisp_Object, Lisp_Object, Lisp_Object)); -extern void syms_of_chartab P_ ((void)); +extern Lisp_Object copy_char_table (Lisp_Object); +extern Lisp_Object sub_char_table_ref (Lisp_Object, int); +extern Lisp_Object char_table_ref (Lisp_Object, int); +extern Lisp_Object char_table_ref_and_range (Lisp_Object, int, + int *, int *); +extern Lisp_Object char_table_set (Lisp_Object, int, Lisp_Object); +extern Lisp_Object char_table_set_range (Lisp_Object, int, int, + Lisp_Object); +extern int char_table_translate (Lisp_Object, int); +extern void map_char_table (void (*) (Lisp_Object, Lisp_Object, + Lisp_Object), + Lisp_Object, Lisp_Object, Lisp_Object); +extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object), + Lisp_Object, Lisp_Object, + Lisp_Object, struct charset *, + unsigned, unsigned); +extern void syms_of_chartab (void); /* Defined in print.c */ extern Lisp_Object Vprin1_to_string_buffer; -extern void debug_print P_ ((Lisp_Object)); +extern Lisp_Object Vprint_level, Vprint_length; +extern void debug_print (Lisp_Object); EXFUN (Fprin1, 2); EXFUN (Fprin1_to_string, 2); EXFUN (Fprinc, 2); @@ -2744,23 +2804,27 @@ EXFUN (Fprint, 2); EXFUN (Ferror_message_string, 1); extern Lisp_Object Vstandard_output, Qstandard_output; extern Lisp_Object Qexternal_debugging_output; -extern void temp_output_buffer_setup P_ ((const char *)); +extern void temp_output_buffer_setup (const char *); extern int print_level, print_escape_newlines; extern Lisp_Object Qprint_escape_newlines; -extern void write_string P_ ((char *, int)); -extern void write_string_1 P_ ((char *, int, Lisp_Object)); -extern void print_error_message P_ ((Lisp_Object, Lisp_Object, char *, Lisp_Object)); +extern void write_string (const char *, int); +extern void write_string_1 (const char *, int, Lisp_Object); +extern void print_error_message (Lisp_Object, Lisp_Object, const char *, + Lisp_Object); extern Lisp_Object internal_with_output_to_temp_buffer - P_ ((const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object)); -extern void float_to_string P_ ((unsigned char *, double)); -extern void syms_of_print P_ ((void)); + (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); +extern void float_to_string (unsigned char *, double); +extern void syms_of_print (void); /* Defined in doprnt.c */ -extern int doprnt P_ ((char *, int, char *, char *, int, char **)); +extern EMACS_INT doprnt (char *, int, const char *, const char *, va_list); /* Defined in lread.c */ +extern Lisp_Object Vafter_load_alist; extern Lisp_Object Qvariable_documentation, Qstandard_input; +extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; extern Lisp_Object Vobarray, initial_obarray, Vstandard_input; +extern int load_in_progress; EXFUN (Fread, 1); EXFUN (Fread_from_string, 3); EXFUN (Fintern, 2); @@ -2770,27 +2834,29 @@ EXFUN (Fget_load_suffixes, 0); EXFUN (Fget_file_char, 0); EXFUN (Fread_char, 3); EXFUN (Fread_event, 3); -extern Lisp_Object read_filtered_event P_ ((int, int, int, int, Lisp_Object)); +extern Lisp_Object read_filtered_event (int, int, int, int, Lisp_Object); EXFUN (Feval_region, 4); -extern Lisp_Object check_obarray P_ ((Lisp_Object)); -extern Lisp_Object intern P_ ((const char *)); +extern Lisp_Object check_obarray (Lisp_Object); +extern Lisp_Object intern (const char *); extern Lisp_Object intern_c_string (const char *); -extern Lisp_Object make_symbol P_ ((char *)); -extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int)); +extern Lisp_Object make_symbol (const char *); +extern Lisp_Object oblookup (Lisp_Object, const char *, EMACS_INT, EMACS_INT); #define LOADHIST_ATTACH(x) \ - if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list) + do { \ + if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \ + } while (0) extern Lisp_Object Vcurrent_load_list; extern Lisp_Object Vload_history, Vload_suffixes, Vload_file_rep_suffixes; -extern int openp P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object *, Lisp_Object)); -extern int isfloat_string P_ ((char *, int)); -extern void map_obarray P_ ((Lisp_Object, void (*) (Lisp_Object, Lisp_Object), - Lisp_Object)); -extern void dir_warning P_ ((char *, Lisp_Object)); -extern void close_load_descs P_ ((void)); -extern void init_obarray P_ ((void)); -extern void init_lread P_ ((void)); -extern void syms_of_lread P_ ((void)); +extern int openp (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object *, Lisp_Object); +extern int isfloat_string (const char *, int); +extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object), + Lisp_Object); +extern void dir_warning (const char *, Lisp_Object); +extern void close_load_descs (void); +extern void init_obarray (void); +extern void init_lread (void); +extern void syms_of_lread (void); /* Defined in eval.c */ extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qmacro; @@ -2799,7 +2865,8 @@ extern Lisp_Object Vautoload_queue; extern Lisp_Object Vdebug_on_error; extern Lisp_Object Vsignaling_function; extern int handling_signal; -extern int interactive_p P_ ((int)); +extern int debug_on_next_call; +extern int interactive_p (int); /* To run a normal hook, use the appropriate function from the list below. The calling convention: @@ -2813,8 +2880,8 @@ EXFUN (Frun_hooks, MANY); EXFUN (Frun_hook_with_args, MANY); EXFUN (Frun_hook_with_args_until_success, MANY); EXFUN (Frun_hook_with_args_until_failure, MANY); -extern Lisp_Object run_hook_list_with_args P_ ((Lisp_Object, int, Lisp_Object *)); -extern void run_hook_with_args_2 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); +extern Lisp_Object run_hook_list_with_args (Lisp_Object, int, Lisp_Object *); +extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object); EXFUN (Fand, UNEVALLED); EXFUN (For, UNEVALLED); EXFUN (Fif, UNEVALLED); @@ -2834,48 +2901,56 @@ EXFUN (Fthrow, 2) NO_RETURN; EXFUN (Funwind_protect, UNEVALLED); EXFUN (Fcondition_case, UNEVALLED); EXFUN (Fsignal, 2); -extern void xsignal P_ ((Lisp_Object, Lisp_Object)) NO_RETURN; -extern void xsignal0 P_ ((Lisp_Object)) NO_RETURN; -extern void xsignal1 P_ ((Lisp_Object, Lisp_Object)) NO_RETURN; -extern void xsignal2 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)) NO_RETURN; -extern void xsignal3 P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)) NO_RETURN; -extern void signal_error P_ ((char *, Lisp_Object)) NO_RETURN; +extern void xsignal (Lisp_Object, Lisp_Object) NO_RETURN; +extern void xsignal0 (Lisp_Object) NO_RETURN; +extern void xsignal1 (Lisp_Object, Lisp_Object) NO_RETURN; +extern void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object) NO_RETURN; +extern void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) NO_RETURN; +extern void signal_error (const char *, Lisp_Object) NO_RETURN; EXFUN (Fautoload, 5); EXFUN (Fcommandp, 2); EXFUN (Feval, 1); EXFUN (Fapply, MANY); EXFUN (Ffuncall, MANY); EXFUN (Fbacktrace, 0); -extern Lisp_Object apply1 P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object call0 P_ ((Lisp_Object)); -extern Lisp_Object call1 P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object call2 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object call3 P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object call4 P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object call5 P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object call6 P_ ((Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)); +extern Lisp_Object apply1 (Lisp_Object, Lisp_Object); +extern Lisp_Object call0 (Lisp_Object); +extern Lisp_Object call1 (Lisp_Object, Lisp_Object); +extern Lisp_Object call2 (Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object call3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object call4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object call5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object call6 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object call7 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); EXFUN (Fdo_auto_save, 2); -extern Lisp_Object apply_lambda P_ ((Lisp_Object, Lisp_Object, int)); -extern Lisp_Object internal_catch P_ ((Lisp_Object, Lisp_Object (*) (Lisp_Object), Lisp_Object)); -extern Lisp_Object internal_lisp_condition_case P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object internal_condition_case P_ ((Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object))); -extern Lisp_Object internal_condition_case_1 P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object))); -extern Lisp_Object internal_condition_case_2 P_ ((Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object))); -extern void specbind P_ ((Lisp_Object, Lisp_Object)); -extern void record_unwind_protect P_ ((Lisp_Object (*) (Lisp_Object), Lisp_Object)); -extern Lisp_Object unbind_to P_ ((int, Lisp_Object)); -extern void error P_ ((/* char *, ... */)) NO_RETURN; -extern void do_autoload P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object un_autoload P_ ((Lisp_Object)); +extern Lisp_Object apply_lambda (Lisp_Object, Lisp_Object, int); +extern Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), Lisp_Object); +extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); +extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); +extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); +extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (int, Lisp_Object *), int, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); +extern void specbind (Lisp_Object, Lisp_Object); +extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); +extern Lisp_Object unbind_to (int, Lisp_Object); +extern void error (const char *, ...) NO_RETURN; +extern void verror (const char *, va_list) NO_RETURN; +extern void do_autoload (Lisp_Object, Lisp_Object); +extern Lisp_Object un_autoload (Lisp_Object); EXFUN (Ffetch_bytecode, 1); -extern void init_eval_once P_ ((void)); -extern Lisp_Object safe_call P_ ((int, Lisp_Object *)); -extern Lisp_Object safe_call1 P_ ((Lisp_Object, Lisp_Object)); +extern void init_eval_once (void); +extern Lisp_Object safe_call (int, Lisp_Object *); +extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); -extern void init_eval P_ ((void)); -extern void syms_of_eval P_ ((void)); +extern void init_eval (void); +extern void syms_of_eval (void); /* Defined in editfns.c */ +extern Lisp_Object last_nonmenu_event; +extern Lisp_Object Qfield; +extern Lisp_Object Vinhibit_field_text_motion; +extern Lisp_Object Vsystem_name; +extern Lisp_Object Vuser_login_name; EXFUN (Fpropertize, MANY); EXFUN (Fcurrent_message, 0); EXFUN (Fgoto_char, 1); @@ -2896,20 +2971,20 @@ EXFUN (Finsert_and_inherit, MANY); EXFUN (Finsert_before_markers, MANY); EXFUN (Finsert_buffer_substring, 3); EXFUN (Finsert_char, 3); -extern void insert1 P_ ((Lisp_Object)); +extern void insert1 (Lisp_Object); EXFUN (Feolp, 0); EXFUN (Feobp, 0); EXFUN (Fbolp, 0); EXFUN (Fbobp, 0); EXFUN (Fformat, MANY); EXFUN (Fmessage, MANY); -extern Lisp_Object format2 P_ ((char *, Lisp_Object, Lisp_Object)); +extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); EXFUN (Fbuffer_substring, 2); EXFUN (Fbuffer_string, 0); -extern Lisp_Object save_excursion_save P_ ((void)); -extern Lisp_Object save_restriction_save P_ ((void)); -extern Lisp_Object save_excursion_restore P_ ((Lisp_Object)); -extern Lisp_Object save_restriction_restore P_ ((Lisp_Object)); +extern Lisp_Object save_excursion_save (void); +extern Lisp_Object save_restriction_save (void); +extern Lisp_Object save_excursion_restore (Lisp_Object); +extern Lisp_Object save_restriction_restore (Lisp_Object); EXFUN (Fchar_to_string, 1); EXFUN (Fdelete_region, 2); EXFUN (Fnarrow_to_region, 2); @@ -2917,33 +2992,33 @@ EXFUN (Fwiden, 0); EXFUN (Fuser_login_name, 1); EXFUN (Fsystem_name, 0); EXFUN (Fcurrent_time, 0); -extern int clip_to_bounds P_ ((int, int, int)); -extern Lisp_Object make_buffer_string P_ ((int, int, int)); -extern Lisp_Object make_buffer_string_both P_ ((int, int, int, int, int)); -extern void init_editfns P_ ((void)); -extern void syms_of_editfns P_ ((void)); -extern Lisp_Object Vinhibit_field_text_motion; +extern EMACS_INT clip_to_bounds (EMACS_INT, EMACS_INT, EMACS_INT); +extern Lisp_Object make_buffer_string (EMACS_INT, EMACS_INT, int); +extern Lisp_Object make_buffer_string_both (EMACS_INT, EMACS_INT, EMACS_INT, + EMACS_INT, int); +extern void init_editfns (void); +extern void syms_of_editfns (void); EXFUN (Fconstrain_to_field, 5); EXFUN (Ffield_string, 1); EXFUN (Fdelete_field, 1); EXFUN (Ffield_beginning, 3); EXFUN (Ffield_end, 3); EXFUN (Ffield_string_no_properties, 1); -extern void set_time_zone_rule P_ ((char *)); +extern void set_time_zone_rule (const char *); /* Defined in buffer.c */ -extern int mouse_face_overlay_overlaps P_ ((Lisp_Object)); -extern void nsberror P_ ((Lisp_Object)) NO_RETURN; +extern int mouse_face_overlay_overlaps (Lisp_Object); +extern void nsberror (Lisp_Object) NO_RETURN; EXFUN (Fset_buffer_multibyte, 1); EXFUN (Foverlay_start, 1); EXFUN (Foverlay_end, 1); EXFUN (Foverlay_buffer, 1); -extern void adjust_overlays_for_insert P_ ((EMACS_INT, EMACS_INT)); -extern void adjust_overlays_for_delete P_ ((EMACS_INT, EMACS_INT)); -extern void fix_start_end_in_overlays P_ ((int, int)); -extern void report_overlay_modification P_ ((Lisp_Object, Lisp_Object, int, - Lisp_Object, Lisp_Object, Lisp_Object)); -extern int overlay_touches_p P_ ((int)); +extern void adjust_overlays_for_insert (EMACS_INT, EMACS_INT); +extern void adjust_overlays_for_delete (EMACS_INT, EMACS_INT); +extern void fix_start_end_in_overlays (EMACS_INT, EMACS_INT); +extern void report_overlay_modification (Lisp_Object, Lisp_Object, int, + Lisp_Object, Lisp_Object, Lisp_Object); +extern int overlay_touches_p (EMACS_INT); extern Lisp_Object Vbuffer_alist, Vinhibit_read_only; EXFUN (Fbuffer_list, 1); EXFUN (Fget_buffer, 1); @@ -2964,15 +3039,15 @@ EXFUN (Fbuffer_disable_undo, 1); EXFUN (Fbuffer_enable_undo, 1); EXFUN (Ferase_buffer, 0); extern Lisp_Object Qoverlayp; -extern Lisp_Object Qevaporate; -extern Lisp_Object get_truename_buffer P_ ((Lisp_Object)); +extern Lisp_Object Qpriority, Qwindow, Qevaporate, Qbefore_string, Qafter_string; +extern Lisp_Object get_truename_buffer (Lisp_Object); extern struct buffer *all_buffers; EXFUN (Fprevious_overlay_change, 1); EXFUN (Fbuffer_file_name, 1); -extern void init_buffer_once P_ ((void)); -extern void init_buffer P_ ((void)); -extern void syms_of_buffer P_ ((void)); -extern void keys_of_buffer P_ ((void)); +extern void init_buffer_once (void); +extern void init_buffer (void); +extern void syms_of_buffer (void); +extern void keys_of_buffer (void); /* Defined in marker.c */ @@ -2980,22 +3055,26 @@ EXFUN (Fmarker_position, 1); EXFUN (Fmarker_buffer, 1); EXFUN (Fcopy_marker, 2); EXFUN (Fset_marker, 3); -extern int marker_position P_ ((Lisp_Object)); -extern int marker_byte_position P_ ((Lisp_Object)); -extern void clear_charpos_cache P_ ((struct buffer *)); -extern int charpos_to_bytepos P_ ((int)); -extern int buf_charpos_to_bytepos P_ ((struct buffer *, int)); -extern int buf_bytepos_to_charpos P_ ((struct buffer *, int)); -extern void unchain_marker P_ ((struct Lisp_Marker *marker)); -extern Lisp_Object set_marker_restricted P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -extern Lisp_Object set_marker_both P_ ((Lisp_Object, Lisp_Object, int, int)); -extern Lisp_Object set_marker_restricted_both P_ ((Lisp_Object, Lisp_Object, - int, int)); -extern void syms_of_marker P_ ((void)); +extern EMACS_INT marker_position (Lisp_Object); +extern EMACS_INT marker_byte_position (Lisp_Object); +extern void clear_charpos_cache (struct buffer *); +extern EMACS_INT charpos_to_bytepos (EMACS_INT); +extern EMACS_INT buf_charpos_to_bytepos (struct buffer *, EMACS_INT); +extern EMACS_INT buf_bytepos_to_charpos (struct buffer *, EMACS_INT); +extern void unchain_marker (struct Lisp_Marker *marker); +extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); +extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT); +extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, + EMACS_INT, EMACS_INT); +extern void syms_of_marker (void); /* Defined in fileio.c */ extern Lisp_Object Qfile_error; +extern Lisp_Object Qfile_exists_p; +extern Lisp_Object Qfile_directory_p; +extern Lisp_Object Qinsert_file_contents; +extern Lisp_Object Vauto_save_list_file_name; EXFUN (Ffind_file_name_handler, 2); EXFUN (Ffile_name_as_directory, 1); EXFUN (Fmake_temp_name, 1); @@ -3008,7 +3087,7 @@ EXFUN (Ffile_exists_p, 1); EXFUN (Ffile_name_absolute_p, 1); EXFUN (Fdirectory_file_name, 1); EXFUN (Ffile_name_directory, 1); -extern Lisp_Object expand_and_dir_to_file P_ ((Lisp_Object, Lisp_Object)); +extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); EXFUN (Ffile_accessible_directory_p, 1); EXFUN (Funhandled_file_name_directory, 1); EXFUN (Ffile_directory_p, 1); @@ -3016,47 +3095,55 @@ EXFUN (Fwrite_region, 7); EXFUN (Ffile_readable_p, 1); EXFUN (Ffile_executable_p, 1); EXFUN (Fread_file_name, 6); -extern Lisp_Object close_file_unwind P_ ((Lisp_Object)); -extern Lisp_Object restore_point_unwind P_ ((Lisp_Object)); -extern void report_file_error P_ ((const char *, Lisp_Object)) NO_RETURN; -extern int internal_delete_file P_ ((Lisp_Object)); -extern void syms_of_fileio P_ ((void)); -extern Lisp_Object make_temp_name P_ ((Lisp_Object, int)); +extern Lisp_Object close_file_unwind (Lisp_Object); +extern Lisp_Object restore_point_unwind (Lisp_Object); +extern void report_file_error (const char *, Lisp_Object) NO_RETURN; +extern int internal_delete_file (Lisp_Object); +extern void syms_of_fileio (void); +extern Lisp_Object make_temp_name (Lisp_Object, int); EXFUN (Fmake_symbolic_link, 3); extern Lisp_Object Qdelete_file; /* Defined in abbrev.c */ -extern void syms_of_abbrev P_ ((void)); +extern void syms_of_abbrev (void); /* Defined in search.c */ -extern void shrink_regexp_cache P_ ((void)); +extern void shrink_regexp_cache (void); EXFUN (Fstring_match, 3); -extern void restore_search_regs P_ ((void)); +extern void restore_search_regs (void); EXFUN (Fmatch_data, 3); EXFUN (Fset_match_data, 2); EXFUN (Fmatch_beginning, 1); EXFUN (Fmatch_end, 1); -extern void record_unwind_save_match_data P_ ((void)); +extern void record_unwind_save_match_data (void); EXFUN (Flooking_at, 1); -extern int fast_string_match P_ ((Lisp_Object, Lisp_Object)); -extern int fast_c_string_match_ignore_case P_ ((Lisp_Object, const char *)); -extern int fast_string_match_ignore_case P_ ((Lisp_Object, Lisp_Object)); -extern EMACS_INT fast_looking_at P_ ((Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, Lisp_Object)); -extern int scan_buffer P_ ((int, EMACS_INT, EMACS_INT, int, int *, int)); -extern int scan_newline P_ ((EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, - int, int)); -extern int find_next_newline P_ ((EMACS_INT, int)); -extern int find_next_newline_no_quit P_ ((EMACS_INT, int)); -extern int find_before_next_newline P_ ((EMACS_INT, EMACS_INT, int)); -extern void syms_of_search P_ ((void)); -extern void clear_regexp_cache P_ ((void)); +extern int fast_string_match (Lisp_Object, Lisp_Object); +extern int fast_c_string_match_ignore_case (Lisp_Object, const char *); +extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); +extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, Lisp_Object); +extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT, + int *, int); +extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, + EMACS_INT, int); +extern EMACS_INT find_next_newline (EMACS_INT, int); +extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT); +extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT); +extern void syms_of_search (void); +extern void clear_regexp_cache (void); /* Defined in minibuf.c */ +extern Lisp_Object Qcompletion_ignore_case; +extern Lisp_Object Vcompletion_regexp_list; +extern Lisp_Object Vhistory_length; +extern Lisp_Object Vminibuffer_list; extern Lisp_Object last_minibuf_string; -extern void choose_minibuf_frame P_ ((void)); +extern int completion_ignore_case; +extern int history_delete_duplicates; +extern int minibuffer_auto_raise; +extern void choose_minibuf_frame (void); EXFUN (Fcompleting_read, 8); EXFUN (Fread_from_minibuffer, 7); EXFUN (Fread_variable, 2); @@ -3066,57 +3153,65 @@ EXFUN (Feval_minibuffer, 2); EXFUN (Fread_string, 5); EXFUN (Fread_no_blanks_input, 3); EXFUN (Fassoc_string, 3); -extern Lisp_Object get_minibuffer P_ ((int)); -extern void temp_echo_area_glyphs P_ ((Lisp_Object)); -extern void init_minibuf_once P_ ((void)); -extern void syms_of_minibuf P_ ((void)); +extern Lisp_Object get_minibuffer (int); +extern void temp_echo_area_glyphs (Lisp_Object); +extern void init_minibuf_once (void); +extern void syms_of_minibuf (void); /* Defined in callint.c */ extern Lisp_Object Qminus, Qplus, Vcurrent_prefix_arg; +extern Lisp_Object Qwhen; extern Lisp_Object Vcommand_history; +extern Lisp_Object Vmark_even_if_inactive; extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook; EXFUN (Fcall_interactively, 3); EXFUN (Fprefix_numeric_value, 1); -extern void syms_of_callint P_ ((void)); +extern void syms_of_callint (void); /* Defined in casefiddle.c */ +extern Lisp_Object Qidentity; EXFUN (Fdowncase, 1); EXFUN (Fupcase, 1); EXFUN (Fcapitalize, 1); EXFUN (Fupcase_region, 2); EXFUN (Fupcase_initials, 1); EXFUN (Fupcase_initials_region, 2); -extern void syms_of_casefiddle P_ ((void)); -extern void keys_of_casefiddle P_ ((void)); +extern void syms_of_casefiddle (void); +extern void keys_of_casefiddle (void); /* Defined in casetab.c */ EXFUN (Fset_case_table, 1); EXFUN (Fset_standard_case_table, 1); -extern void init_casetab_once P_ ((void)); -extern void syms_of_casetab P_ ((void)); +extern void init_casetab_once (void); +extern void syms_of_casetab (void); /* Defined in keyboard.c */ extern int echoing; extern Lisp_Object echo_message_buffer; extern struct kboard *echo_kboard; -extern void cancel_echoing P_ ((void)); +extern void cancel_echoing (void); extern Lisp_Object Qdisabled, QCfilter; +extern Lisp_Object Qabove_handle, Qhandle, Qbelow_handle; +extern Lisp_Object Qup, Qdown, Qbottom, Qend_scroll; +extern Lisp_Object Qtop, Qratio; extern Lisp_Object Vtty_erase_char, Vhelp_form, Vtop_level; extern Lisp_Object Vthrow_on_input; extern int input_pending; EXFUN (Fdiscard_input, 0); EXFUN (Frecursive_edit, 0); -EXFUN (Ftop_level, 0); +EXFUN (Ftop_level, 0) NO_RETURN; +EXFUN (Fexit_recursive_edit, 0) NO_RETURN; +EXFUN (Fabort_recursive_edit, 0) NO_RETURN; EXFUN (Fcommand_execute, 4); EXFUN (Finput_pending_p, 0); -extern Lisp_Object menu_bar_items P_ ((Lisp_Object)); -extern Lisp_Object tool_bar_items P_ ((Lisp_Object, int *)); +extern Lisp_Object menu_bar_items (Lisp_Object); +extern Lisp_Object tool_bar_items (Lisp_Object, int *); extern Lisp_Object Qvertical_scroll_bar; -extern void discard_mouse_events P_ ((void)); +extern void discard_mouse_events (void); EXFUN (Fevent_convert_list, 1); EXFUN (Fread_key_sequence, 5); EXFUN (Fset_input_interrupt_mode, 1); @@ -3125,18 +3220,18 @@ EXFUN (Fset_input_meta_mode, 2); EXFUN (Fset_quit_char, 1); EXFUN (Fset_input_mode, 4); extern Lisp_Object pending_funcalls; -extern int detect_input_pending P_ ((void)); -extern int detect_input_pending_ignore_squeezables P_ ((void)); -extern int detect_input_pending_run_timers P_ ((int)); -extern void safe_run_hooks P_ ((Lisp_Object)); -extern void cmd_error_internal P_ ((Lisp_Object, char *)); -extern Lisp_Object command_loop_1 P_ ((void)); -extern Lisp_Object recursive_edit_1 P_ ((void)); -extern void record_auto_save P_ ((void)); -extern void init_keyboard P_ ((void)); -extern void syms_of_keyboard P_ ((void)); -extern void keys_of_keyboard P_ ((void)); -extern char *push_key_description P_ ((unsigned int, char *, int)); +extern int detect_input_pending (void); +extern int detect_input_pending_ignore_squeezables (void); +extern int detect_input_pending_run_timers (int); +extern void safe_run_hooks (Lisp_Object); +extern void cmd_error_internal (Lisp_Object, const char *); +extern Lisp_Object command_loop_1 (void); +extern Lisp_Object recursive_edit_1 (void); +extern void record_auto_save (void); +extern void init_keyboard (void); +extern void syms_of_keyboard (void); +extern void keys_of_keyboard (void); +extern char *push_key_description (unsigned int, char *, int); /* Defined in indent.c */ @@ -3144,22 +3239,23 @@ EXFUN (Fvertical_motion, 2); EXFUN (Findent_to, 2); EXFUN (Fcurrent_column, 0); EXFUN (Fmove_to_column, 2); -extern double current_column P_ ((void)); -extern void invalidate_current_column P_ ((void)); -extern int indented_beyond_p P_ ((int, int, double)); -extern void syms_of_indent P_ ((void)); +extern double current_column (void); +extern void invalidate_current_column (void); +extern int indented_beyond_p (EMACS_INT, EMACS_INT, double); +extern void syms_of_indent (void); /* Defined in frame.c */ #ifdef HAVE_WINDOW_SYSTEM extern Lisp_Object Vx_resource_name; extern Lisp_Object Vx_resource_class; #endif /* HAVE_WINDOW_SYSTEM */ +extern Lisp_Object Qonly; extern Lisp_Object Qvisible; -extern void store_frame_param P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void store_in_alist P_ ((Lisp_Object *, Lisp_Object, Lisp_Object)); -extern Lisp_Object do_switch_frame P_ ((Lisp_Object, int, int, Lisp_Object)); -extern Lisp_Object get_frame_param P_ ((struct frame *, Lisp_Object)); -extern Lisp_Object frame_buffer_predicate P_ ((Lisp_Object)); +extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object); +extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object); +extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object); +extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); +extern Lisp_Object frame_buffer_predicate (Lisp_Object); EXFUN (Fframep, 1); EXFUN (Fselect_frame, 2); EXFUN (Fselected_frame, 0); @@ -3186,30 +3282,38 @@ EXFUN (Fset_frame_position, 3); EXFUN (Fraise_frame, 1); EXFUN (Fredirect_frame_focus, 2); EXFUN (Fset_frame_selected_window, 3); -extern Lisp_Object frame_buffer_list P_ ((Lisp_Object)); -extern void frames_discard_buffer P_ ((Lisp_Object)); -extern void set_frame_buffer_list P_ ((Lisp_Object, Lisp_Object)); -extern void frames_bury_buffer P_ ((Lisp_Object)); -extern void syms_of_frame P_ ((void)); +extern Lisp_Object frame_buffer_list (Lisp_Object); +extern void frames_discard_buffer (Lisp_Object); +extern void set_frame_buffer_list (Lisp_Object, Lisp_Object); +extern void frames_bury_buffer (Lisp_Object); +extern void syms_of_frame (void); /* Defined in emacs.c */ -extern Lisp_Object decode_env_path P_ ((char *, char *)); +extern char **initial_argv; +extern int initial_argc; +#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS) +extern int display_arg; +#endif +extern Lisp_Object decode_env_path (const char *, const char *); extern Lisp_Object Vinvocation_name, Vinvocation_directory; extern Lisp_Object Vbefore_init_time, Vafter_init_time; extern Lisp_Object Vinstallation_directory; extern Lisp_Object empty_unibyte_string, empty_multibyte_string; -EXFUN (Fkill_emacs, 1); +extern Lisp_Object Qfile_name_handler_alist; +extern Lisp_Object Vdynamic_library_alist; +extern void (*fatal_error_signal_hook) (void); +EXFUN (Fkill_emacs, 1) NO_RETURN; #if HAVE_SETLOCALE -void fixup_locale P_ ((void)); -void synchronize_system_messages_locale P_ ((void)); -void synchronize_system_time_locale P_ ((void)); +void fixup_locale (void); +void synchronize_system_messages_locale (void); +void synchronize_system_time_locale (void); #else #define setlocale(category, locale) #define fixup_locale() #define synchronize_system_messages_locale() #define synchronize_system_time_locale() #endif -void shut_down_emacs P_ ((int, int, Lisp_Object)); +void shut_down_emacs (int, int, Lisp_Object); /* Nonzero means don't do interactive redisplay and don't change tty modes. */ extern int noninteractive; @@ -3227,6 +3331,7 @@ extern int inhibit_window_system; extern int running_asynch_code; /* Defined in process.c */ +extern Lisp_Object QCtype, Qlocal; EXFUN (Fget_process, 1); EXFUN (Fget_buffer_process, 1); EXFUN (Fprocessp, 1); @@ -3235,94 +3340,100 @@ EXFUN (Fkill_process, 2); EXFUN (Fprocess_send_eof, 1); EXFUN (Fwaiting_for_user_input_p, 0); extern Lisp_Object Qprocessp; -extern void kill_buffer_processes P_ ((Lisp_Object)); -extern int wait_reading_process_output P_ ((int, int, int, int, - Lisp_Object, - struct Lisp_Process *, - int)); -extern void add_keyboard_wait_descriptor P_ ((int)); -extern void delete_keyboard_wait_descriptor P_ ((int)); -extern void add_gpm_wait_descriptor P_ ((int)); -extern void delete_gpm_wait_descriptor P_ ((int)); -extern void close_process_descs P_ ((void)); -extern void init_process P_ ((void)); -extern void syms_of_process P_ ((void)); -extern void setup_process_coding_systems P_ ((Lisp_Object)); +extern void kill_buffer_processes (Lisp_Object); +extern int wait_reading_process_output (int, int, int, int, + Lisp_Object, + struct Lisp_Process *, + int); +extern void add_keyboard_wait_descriptor (int); +extern void delete_keyboard_wait_descriptor (int); +extern void add_gpm_wait_descriptor (int); +extern void delete_gpm_wait_descriptor (int); +extern void close_process_descs (void); +extern void init_process (void); +extern void syms_of_process (void); +extern void setup_process_coding_systems (Lisp_Object); /* Defined in callproc.c */ extern Lisp_Object Vexec_path, Vexec_suffixes, Vexec_directory, Vdata_directory; extern Lisp_Object Vdoc_directory; +extern Lisp_Object Vshell_file_name; EXFUN (Fcall_process, MANY); -extern int child_setup P_ ((int, int, int, char **, int, Lisp_Object)); -extern void init_callproc_1 P_ ((void)); -extern void init_callproc P_ ((void)); -extern void set_initial_environment P_ ((void)); -extern void syms_of_callproc P_ ((void)); +extern int child_setup (int, int, int, char **, int, Lisp_Object); +extern void init_callproc_1 (void); +extern void init_callproc (void); +extern void set_initial_environment (void); +extern void syms_of_callproc (void); /* Defined in doc.c */ +extern Lisp_Object Qfunction_documentation; extern Lisp_Object Vdoc_file_name; EXFUN (Fsubstitute_command_keys, 1); EXFUN (Fdocumentation, 2); EXFUN (Fdocumentation_property, 3); -extern Lisp_Object read_doc_string P_ ((Lisp_Object)); -extern Lisp_Object get_doc_string P_ ((Lisp_Object, int, int)); -extern void syms_of_doc P_ ((void)); -extern int read_bytecode_char P_ ((int)); +extern Lisp_Object read_doc_string (Lisp_Object); +extern Lisp_Object get_doc_string (Lisp_Object, int, int); +extern void syms_of_doc (void); +extern int read_bytecode_char (int); /* Defined in bytecode.c */ extern Lisp_Object Qbytecode; EXFUN (Fbyte_code, 3); -extern void syms_of_bytecode P_ ((void)); +extern void syms_of_bytecode (void); extern struct byte_stack *byte_stack_list; -extern void mark_byte_stack P_ ((void)); -extern void unmark_byte_stack P_ ((void)); +extern void mark_byte_stack (void); +extern void unmark_byte_stack (void); /* Defined in macros.c */ extern Lisp_Object Qexecute_kbd_macro; EXFUN (Fexecute_kbd_macro, 3); EXFUN (Fcancel_kbd_macro_events, 0); -extern void init_macros P_ ((void)); -extern void syms_of_macros P_ ((void)); +extern void init_macros (void); +extern void syms_of_macros (void); /* Defined in undo.c */ +extern Lisp_Object Qapply; extern Lisp_Object Qinhibit_read_only; EXFUN (Fundo_boundary, 0); -extern void truncate_undo_list P_ ((struct buffer *)); -extern void record_marker_adjustment P_ ((Lisp_Object, int)); -extern void record_insert P_ ((int, int)); -extern void record_delete P_ ((int, Lisp_Object)); -extern void record_first_change P_ ((void)); -extern void record_change P_ ((int, int)); -extern void record_property_change P_ ((int, int, Lisp_Object, Lisp_Object, - Lisp_Object)); -extern void syms_of_undo P_ ((void)); +extern void truncate_undo_list (struct buffer *); +extern void record_marker_adjustment (Lisp_Object, EMACS_INT); +extern void record_insert (EMACS_INT, EMACS_INT); +extern void record_delete (EMACS_INT, Lisp_Object); +extern void record_first_change (void); +extern void record_change (EMACS_INT, EMACS_INT); +extern void record_property_change (EMACS_INT, EMACS_INT, + Lisp_Object, Lisp_Object, + Lisp_Object); +extern void syms_of_undo (void); extern Lisp_Object Vundo_outer_limit; /* Defined in textprop.c */ extern Lisp_Object Qfont, Qmouse_face; extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks; +extern Lisp_Object Qfront_sticky, Qrear_nonsticky; +extern Lisp_Object Qminibuffer_prompt; + EXFUN (Fnext_single_property_change, 4); EXFUN (Fnext_single_char_property_change, 4); EXFUN (Fprevious_single_property_change, 4); EXFUN (Fget_text_property, 3); EXFUN (Fput_text_property, 5); -EXFUN (Fget_text_property, 3); EXFUN (Fprevious_char_property_change, 2); EXFUN (Fnext_char_property_change, 2); -extern void report_interval_modification P_ ((Lisp_Object, Lisp_Object)); -extern Lisp_Object next_single_char_property_change P_ ((Lisp_Object, - Lisp_Object, - Lisp_Object, - Lisp_Object)); +extern void report_interval_modification (Lisp_Object, Lisp_Object); +extern Lisp_Object next_single_char_property_change (Lisp_Object, + Lisp_Object, + Lisp_Object, + Lisp_Object); /* Defined in menu.c */ -extern void syms_of_menu P_ ((void)); +extern void syms_of_menu (void); /* Defined in xmenu.c */ EXFUN (Fx_popup_menu, 2); EXFUN (Fx_popup_dialog, 3); -extern void syms_of_xmenu P_ ((void)); +extern void syms_of_xmenu (void); /* Defined in termchar.h */ struct tty_display_info; @@ -3332,122 +3443,164 @@ struct terminal; /* Defined in sysdep.c */ #ifndef HAVE_GET_CURRENT_DIR_NAME -extern char *get_current_dir_name P_ ((void)); +extern char *get_current_dir_name (void); +#endif +extern void stuff_char (char c); +extern void init_sigio (int); +extern void sys_subshell (void); +extern void sys_suspend (void); +extern void discard_tty_input (void); +extern void init_sys_modes (struct tty_display_info *); +extern void reset_sys_modes (struct tty_display_info *); +extern void init_all_sys_modes (void); +extern void reset_all_sys_modes (void); +extern void wait_for_termination (int); +extern void flush_pending_output (int); +extern void child_setup_tty (int); +extern void setup_pty (int); +extern int set_window_size (int, int, int); +extern void create_process (Lisp_Object, char **, Lisp_Object); +extern int emacs_open (const char *, int, int); +extern int emacs_close (int); +extern int emacs_read (int, char *, unsigned int); +extern int emacs_write (int, const char *, unsigned int); +#ifndef HAVE_MEMSET +extern void *memset (void *, int, size_t); +#endif +#ifndef HAVE_MEMCPY +extern void *memcpy (void *, void *, size_t); +#endif +#ifndef HAVE_MEMMOVE +extern void *memmove (void *, void *, size_t); +#endif +#ifndef HAVE_MEMCMP +extern int memcmp (void *, void *, size_t); #endif -extern void stuff_char P_ ((char c)); -extern void init_sigio P_ ((int)); -extern void sys_subshell P_ ((void)); -extern void sys_suspend P_ ((void)); -extern void discard_tty_input P_ ((void)); -extern void init_sys_modes P_ ((struct tty_display_info *)); -extern void reset_sys_modes P_ ((struct tty_display_info *)); -extern void init_all_sys_modes P_ ((void)); -extern void reset_all_sys_modes P_ ((void)); -extern void wait_for_termination P_ ((int)); -extern void flush_pending_output P_ ((int)); -extern void child_setup_tty P_ ((int)); -extern void setup_pty P_ ((int)); -extern int set_window_size P_ ((int, int, int)); -extern void create_process P_ ((Lisp_Object, char **, Lisp_Object)); -extern int emacs_open P_ ((const char *, int, int)); -extern int emacs_close P_ ((int)); -extern int emacs_read P_ ((int, char *, unsigned int)); -extern int emacs_write P_ ((int, const char *, unsigned int)); /* Defined in filelock.c */ +extern Lisp_Object Vtemporary_file_directory; EXFUN (Funlock_buffer, 0); EXFUN (Ffile_locked_p, 1); -extern void unlock_all_files P_ ((void)); -extern void lock_file P_ ((Lisp_Object)); -extern void unlock_file P_ ((Lisp_Object)); -extern void unlock_buffer P_ ((struct buffer *)); -extern void syms_of_filelock P_ ((void)); -extern void init_filelock P_ ((void)); +extern void unlock_all_files (void); +extern void lock_file (Lisp_Object); +extern void unlock_file (Lisp_Object); +extern void unlock_buffer (struct buffer *); +extern void syms_of_filelock (void); +extern void init_filelock (void); /* Defined in sound.c */ -extern void syms_of_sound P_ ((void)); -extern void init_sound P_ ((void)); +extern void syms_of_sound (void); +extern void init_sound (void); /* Defined in category.c */ -extern void init_category_once P_ ((void)); -extern Lisp_Object char_category_set P_ ((int)); -extern void syms_of_category P_ ((void)); +extern void init_category_once (void); +extern Lisp_Object char_category_set (int); +extern void syms_of_category (void); /* Defined in ccl.c */ -extern void syms_of_ccl P_ ((void)); +extern void syms_of_ccl (void); /* Defined in dired.c */ EXFUN (Ffile_attributes, 2); -extern void syms_of_dired P_ ((void)); -extern Lisp_Object directory_files_internal P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - int, Lisp_Object)); +extern void syms_of_dired (void); +extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + int, Lisp_Object); /* Defined in term.c */ -extern void syms_of_term P_ ((void)); -extern void fatal P_ ((const char *msgid, ...)) NO_RETURN; +extern int *char_ins_del_vector; +extern void syms_of_term (void); +extern void fatal (const char *msgid, ...) NO_RETURN; /* Defined in terminal.c */ +EXFUN (Fframe_terminal, 1); EXFUN (Fdelete_terminal, 2); -extern void syms_of_terminal P_ ((void)); +extern void syms_of_terminal (void); /* Defined in font.c */ -extern void syms_of_font P_ ((void)); -extern void init_font P_ ((void)); +extern void syms_of_font (void); +extern void init_font (void); #ifdef HAVE_WINDOW_SYSTEM /* Defined in fontset.c */ -extern void syms_of_fontset P_ ((void)); +extern void syms_of_fontset (void); EXFUN (Fset_fontset_font, 5); EXFUN (Fnew_fontset, 2); /* Defined in xfns.c, w32fns.c, or macfns.c */ +extern Lisp_Object Qfont_param; +extern Lisp_Object Vx_no_window_manager; EXFUN (Fxw_display_color_p, 1); EXFUN (Fx_file_dialog, 5); EXFUN (Fx_focus_frame, 1); #endif /* Defined in xfaces.c */ +extern Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe; +extern Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse, Qmenu; +extern Lisp_Object Qmode_line_inactive, Qvertical_border; +extern Lisp_Object Qface; +extern Lisp_Object Qnormal; +extern Lisp_Object QCfamily, QCweight, QCslant; +extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground; +extern Lisp_Object Vface_alternative_font_family_alist; +extern Lisp_Object Vface_font_rescale_alist; +extern Lisp_Object Vface_ignored_fonts; +extern Lisp_Object Vface_alternative_font_registry_alist; +extern Lisp_Object Vscalable_fonts_allowed; EXFUN (Fclear_face_cache, 1); EXFUN (Fx_load_color_file, 1); -extern void syms_of_xfaces P_ ((void)); +extern void syms_of_xfaces (void); #ifndef HAVE_GETLOADAVG /* Defined in getloadavg.c */ -extern int getloadavg P_ ((double *, int)); +extern int getloadavg (double *, int); #endif #ifdef HAVE_X_WINDOWS /* Defined in xfns.c */ -extern void syms_of_xfns P_ ((void)); +extern void syms_of_xfns (void); /* Defined in xsmfns.c */ -extern void syms_of_xsmfns P_ ((void)); +extern void syms_of_xsmfns (void); /* Defined in xselect.c */ EXFUN (Fx_send_client_event, 6); -extern void syms_of_xselect P_ ((void)); +extern void syms_of_xselect (void); /* Defined in xterm.c */ -extern void syms_of_xterm P_ ((void)); +extern void syms_of_xterm (void); #endif /* HAVE_X_WINDOWS */ +#ifdef HAVE_WINDOW_SYSTEM +/* Defined in xterm.c, nsterm.m, w32term.c */ +extern char *x_get_keysym_name (int); +#endif /* HAVE_WINDOW_SYSTEM */ + #ifdef MSDOS /* Defined in msdos.c */ EXFUN (Fmsdos_downcase_filename, 1); #endif +#ifdef HAVE_LIBXML2 +/* Defined in xml.c */ +extern void syms_of_xml (void); +#endif + #ifdef HAVE_MENUS /* Defined in (x|w32)fns.c, nsfns.m... */ -extern int have_menus_p P_ ((void)); +extern int have_menus_p (void); #endif #ifdef HAVE_DBUS /* Defined in dbusbind.c */ -int xd_pending_messages P_ ((void)); -void xd_read_queued_messages P_ ((void)); -void syms_of_dbusbind P_ ((void)); +void syms_of_dbusbind (void); #endif + +#ifdef DOS_NT +/* Defined in msdos.c, w32.c */ +extern char *emacs_root_dir (void); +#endif /* DOS_NT */ /* Nonzero means Emacs has already been initialized. Used during startup to detect startup of dumped Emacs. */ @@ -3455,28 +3608,22 @@ extern int initialized; extern int immediate_quit; /* Nonzero means ^G can quit instantly */ -extern POINTER_TYPE *xmalloc P_ ((size_t)); -extern POINTER_TYPE *xrealloc P_ ((POINTER_TYPE *, size_t)); -extern void xfree P_ ((POINTER_TYPE *)); +extern POINTER_TYPE *xmalloc (size_t); +extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); +extern void xfree (POINTER_TYPE *); -extern char *xstrdup P_ ((const char *)); +extern char *xstrdup (const char *); -extern char *egetenv P_ ((char *)); +extern char *egetenv (const char *); /* Set up the name of the machine we're running on. */ -extern void init_system_name P_ ((void)); +extern void init_system_name (void); /* Some systems (e.g., NT) use a different path separator than Unix, - in addition to a device separator. Default the path separator + in addition to a device separator. Set the path separator to '/', and don't test for a device separator in IS_ANY_SEP. */ -#ifdef WINDOWSNT -extern Lisp_Object Vdirectory_sep_char; -#endif - -#ifndef DIRECTORY_SEP #define DIRECTORY_SEP '/' -#endif #ifndef IS_DIRECTORY_SEP #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) #endif @@ -3579,7 +3726,7 @@ extern Lisp_Object Vdirectory_sep_char; extern Lisp_Object safe_alloca_unwind (Lisp_Object); #define USE_SAFE_ALLOCA \ - int sa_count = SPECPDL_INDEX (), sa_must_free = 0 + int sa_count = (int) SPECPDL_INDEX (), sa_must_free = 0 /* SAFE_ALLOCA allocates a simple buffer. */ diff --git a/src/lread.c b/src/lread.c index c96e391a2d3..66b1a8068c2 100644 --- a/src/lread.c +++ b/src/lread.c @@ -41,9 +41,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "blockinput.h" #ifdef MSDOS -#if __DJGPP__ < 2 -#include <unistd.h> /* to get X_OK */ -#endif #include "msdos.h" #endif @@ -51,22 +48,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif -#ifndef X_OK -#define X_OK 01 -#endif - #include <math.h> #ifdef HAVE_SETLOCALE #include <locale.h> #endif /* HAVE_SETLOCALE */ -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif #ifdef HAVE_FSEEKO #define file_offset off_t @@ -76,17 +64,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define file_tell ftell #endif -#ifndef USE_CRT_DLL -extern int errno; -#endif - /* hash table read constants */ Lisp_Object Qhash_table, Qdata; Lisp_Object Qtest, Qsize; Lisp_Object Qweakness; Lisp_Object Qrehash_size; Lisp_Object Qrehash_threshold; -extern Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness; Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; @@ -102,9 +85,6 @@ static Lisp_Object Qget_emacs_mule_file_char; static Lisp_Object Qload_force_doc_strings; -extern Lisp_Object Qevent_symbol_element_mask; -extern Lisp_Object Qfile_exists_p; - /* non-zero if inside `load' */ int load_in_progress; static Lisp_Object Qload_in_progress; @@ -178,13 +158,13 @@ static FILE *instream; static int read_pure; /* For use within read-from-string (this reader is non-reentrant!!) */ -static int read_from_string_index; -static int read_from_string_index_byte; -static int read_from_string_limit; +static EMACS_INT read_from_string_index; +static EMACS_INT read_from_string_index_byte; +static EMACS_INT read_from_string_limit; /* Number of characters read in the current call to Fread or Fread_from_string. */ -static int readchar_count; +static EMACS_INT readchar_count; /* This contains the last string skipped with #@. */ static char *saved_doc_string; @@ -230,18 +210,18 @@ int force_load_messages; static Lisp_Object Vbytecomp_version_regexp; -static int read_emacs_mule_char P_ ((int, int (*) (int, Lisp_Object), - Lisp_Object)); +static int read_emacs_mule_char (int, int (*) (int, Lisp_Object), + Lisp_Object); -static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, - Lisp_Object (*) (), int, - Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object)); -static Lisp_Object load_unwind P_ ((Lisp_Object)); -static Lisp_Object load_descriptor_unwind P_ ((Lisp_Object)); +static void readevalloop (Lisp_Object, FILE*, Lisp_Object, + Lisp_Object (*) (Lisp_Object), int, + Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object); +static Lisp_Object load_unwind (Lisp_Object); +static Lisp_Object load_descriptor_unwind (Lisp_Object); -static void invalid_syntax P_ ((const char *, int)) NO_RETURN; -static void end_of_file_error P_ (()) NO_RETURN; +static void invalid_syntax (const char *, int) NO_RETURN; +static void end_of_file_error (void) NO_RETURN; /* Functions that read one byte from the current source READCHARFUN @@ -250,9 +230,9 @@ static void end_of_file_error P_ (()) NO_RETURN; is 0 or positive, it unreads C, and the return value is not interesting. */ -static int readbyte_for_lambda P_ ((int, Lisp_Object)); -static int readbyte_from_file P_ ((int, Lisp_Object)); -static int readbyte_from_string P_ ((int, Lisp_Object)); +static int readbyte_for_lambda (int, Lisp_Object); +static int readbyte_from_file (int, Lisp_Object); +static int readbyte_from_string (int, Lisp_Object); /* Handle unreading and rereading of characters. Write READCHAR to read a character, @@ -273,13 +253,11 @@ static int readbyte_from_string P_ ((int, Lisp_Object)); static int unread_char; static int -readchar (readcharfun, multibyte) - Lisp_Object readcharfun; - int *multibyte; +readchar (Lisp_Object readcharfun, int *multibyte) { Lisp_Object tem; register int c; - int (*readbyte) P_ ((int, Lisp_Object)); + int (*readbyte) (int, Lisp_Object); unsigned char buf[MAX_MULTIBYTE_LENGTH]; int i, len; int emacs_mule_encoding = 0; @@ -293,7 +271,7 @@ readchar (readcharfun, multibyte) { register struct buffer *inbuffer = XBUFFER (readcharfun); - int pt_byte = BUF_PT_BYTE (inbuffer); + EMACS_INT pt_byte = BUF_PT_BYTE (inbuffer); if (pt_byte >= BUF_ZV_BYTE (inbuffer)) return -1; @@ -322,7 +300,7 @@ readchar (readcharfun, multibyte) { register struct buffer *inbuffer = XMARKER (readcharfun)->buffer; - int bytepos = marker_byte_position (readcharfun); + EMACS_INT bytepos = marker_byte_position (readcharfun); if (bytepos >= BUF_ZV_BYTE (inbuffer)) return -1; @@ -446,9 +424,7 @@ readchar (readcharfun, multibyte) If the stream is a user function, call it with the char as argument. */ static void -unreadchar (readcharfun, c) - Lisp_Object readcharfun; - int c; +unreadchar (Lisp_Object readcharfun, int c) { readchar_count--; if (c == -1) @@ -458,7 +434,7 @@ unreadchar (readcharfun, c) else if (BUFFERP (readcharfun)) { struct buffer *b = XBUFFER (readcharfun); - int bytepos = BUF_PT_BYTE (b); + EMACS_INT bytepos = BUF_PT_BYTE (b); BUF_PT (b)--; if (! NILP (b->enable_multibyte_characters)) @@ -471,7 +447,7 @@ unreadchar (readcharfun, c) else if (MARKERP (readcharfun)) { struct buffer *b = XMARKER (readcharfun)->buffer; - int bytepos = XMARKER (readcharfun)->bytepos; + EMACS_INT bytepos = XMARKER (readcharfun)->bytepos; XMARKER (readcharfun)->charpos--; if (! NILP (b->enable_multibyte_characters)) @@ -512,18 +488,14 @@ unreadchar (readcharfun, c) } static int -readbyte_for_lambda (c, readcharfun) - int c; - Lisp_Object readcharfun; +readbyte_for_lambda (int c, Lisp_Object readcharfun) { return read_bytecode_char (c >= 0); } static int -readbyte_from_file (c, readcharfun) - int c; - Lisp_Object readcharfun; +readbyte_from_file (int c, Lisp_Object readcharfun) { if (c >= 0) { @@ -554,9 +526,7 @@ readbyte_from_file (c, readcharfun) } static int -readbyte_from_string (c, readcharfun) - int c; - Lisp_Object readcharfun; +readbyte_from_string (int c, Lisp_Object readcharfun) { Lisp_Object string = XCAR (readcharfun); @@ -584,10 +554,7 @@ readbyte_from_string (c, readcharfun) extern char emacs_mule_bytes[256]; static int -read_emacs_mule_char (c, readbyte, readcharfun) - int c; - int (*readbyte) P_ ((int, Lisp_Object)); - Lisp_Object readcharfun; +read_emacs_mule_char (int c, int (*readbyte) (int, Lisp_Object), Lisp_Object readcharfun) { /* Emacs-mule coding uses at most 4-byte for one character. */ unsigned char buf[4]; @@ -646,19 +613,19 @@ read_emacs_mule_char (c, readbyte, readcharfun) } -static Lisp_Object read_internal_start P_ ((Lisp_Object, Lisp_Object, - Lisp_Object)); -static Lisp_Object read0 P_ ((Lisp_Object)); -static Lisp_Object read1 P_ ((Lisp_Object, int *, int)); +static Lisp_Object read_internal_start (Lisp_Object, Lisp_Object, + Lisp_Object); +static Lisp_Object read0 (Lisp_Object); +static Lisp_Object read1 (Lisp_Object, int *, int); -static Lisp_Object read_list P_ ((int, Lisp_Object)); -static Lisp_Object read_vector P_ ((Lisp_Object, int)); +static Lisp_Object read_list (int, Lisp_Object); +static Lisp_Object read_vector (Lisp_Object, int); -static Lisp_Object substitute_object_recurse P_ ((Lisp_Object, Lisp_Object, - Lisp_Object)); -static void substitute_object_in_subtree P_ ((Lisp_Object, - Lisp_Object)); -static void substitute_in_interval P_ ((INTERVAL, Lisp_Object)); +static Lisp_Object substitute_object_recurse (Lisp_Object, Lisp_Object, + Lisp_Object); +static void substitute_object_in_subtree (Lisp_Object, + Lisp_Object); +static void substitute_in_interval (INTERVAL, Lisp_Object); /* Get a character from the tty. */ @@ -685,10 +652,8 @@ static void substitute_in_interval P_ ((INTERVAL, Lisp_Object)); return Qnil if no input arrives within that time. */ Lisp_Object -read_filtered_event (no_switch_frame, ascii_required, error_nonascii, - input_method, seconds) - int no_switch_frame, ascii_required, error_nonascii, input_method; - Lisp_Object seconds; +read_filtered_event (int no_switch_frame, int ascii_required, + int error_nonascii, int input_method, Lisp_Object seconds) { Lisp_Object val, delayed_switch_frame; EMACS_TIME end_time; @@ -803,8 +768,7 @@ If the optional argument SECONDS is non-nil, it should be a number specifying the maximum number of seconds to wait for input. If no input arrives in that time, return nil. SECONDS may be a floating-point value. */) - (prompt, inherit_input_method, seconds) - Lisp_Object prompt, inherit_input_method, seconds; + (Lisp_Object prompt, Lisp_Object inherit_input_method, Lisp_Object seconds) { Lisp_Object val; @@ -826,8 +790,7 @@ If the optional argument SECONDS is non-nil, it should be a number specifying the maximum number of seconds to wait for input. If no input arrives in that time, return nil. SECONDS may be a floating-point value. */) - (prompt, inherit_input_method, seconds) - Lisp_Object prompt, inherit_input_method, seconds; + (Lisp_Object prompt, Lisp_Object inherit_input_method, Lisp_Object seconds) { if (! NILP (prompt)) message_with_string ("%s", prompt, 0); @@ -848,8 +811,7 @@ If the optional argument SECONDS is non-nil, it should be a number specifying the maximum number of seconds to wait for input. If no input arrives in that time, return nil. SECONDS may be a floating-point value. */) - (prompt, inherit_input_method, seconds) - Lisp_Object prompt, inherit_input_method, seconds; + (Lisp_Object prompt, Lisp_Object inherit_input_method, Lisp_Object seconds) { Lisp_Object val; @@ -864,7 +826,7 @@ floating-point value. */) DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, doc: /* Don't use this yourself. */) - () + (void) { register Lisp_Object val; BLOCK_INPUT; @@ -882,8 +844,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0, because of an incompatible change in the byte compiler. */ static int -safe_to_load_p (fd) - int fd; +safe_to_load_p (int fd) { char buf[512]; int nbytes, i; @@ -920,8 +881,7 @@ safe_to_load_p (fd) after loading a file successfully. */ static Lisp_Object -record_load_unwind (old) - Lisp_Object old; +record_load_unwind (Lisp_Object old) { return Vloads_in_progress = old; } @@ -929,15 +889,13 @@ record_load_unwind (old) /* This handler function is used via internal_condition_case_1. */ static Lisp_Object -load_error_handler (data) - Lisp_Object data; +load_error_handler (Lisp_Object data) { return Qnil; } static Lisp_Object -load_warn_old_style_backquotes (file) - Lisp_Object file; +load_warn_old_style_backquotes (Lisp_Object file) { if (!NILP (Vold_style_backquotes)) { @@ -953,7 +911,7 @@ DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0, doc: /* Return the suffixes that `load' should try if a suffix is \ required. This uses the variables `load-suffixes' and `load-file-rep-suffixes'. */) - () + (void) { Lisp_Object lst = Qnil, suffixes = Vload_suffixes, suffix, ext; while (CONSP (suffixes)) @@ -1008,8 +966,7 @@ Loading a file records its definitions, and its `provide' and car is the file name loaded. See `load-history'. Return t if the file exists and loads successfully. */) - (file, noerror, nomessage, nosuffix, must_suffix) - Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; + (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage, Lisp_Object nosuffix, Lisp_Object must_suffix) { register FILE *stream; register int fd = -1; @@ -1022,7 +979,7 @@ Return t if the file exists and loads successfully. */) int compiled = 0; Lisp_Object handler; int safe_p = 1; - char *fmode = "r"; + const char *fmode = "r"; Lisp_Object tmp[2]; int version; @@ -1153,8 +1110,7 @@ Return t if the file exists and loads successfully. */) specbind (Qold_style_backquotes, Qnil); record_unwind_protect (load_warn_old_style_backquotes, file); - if (!bcmp (SDATA (found) + SBYTES (found) - 4, - ".elc", 4) + if (!memcmp (SDATA (found) + SBYTES (found) - 4, ".elc", 4) || (fd >= 0 && (version = safe_to_load_p (fd)) > 0)) /* Load .elc files directly, but not when they are remote and have no handler! */ @@ -1310,8 +1266,7 @@ Return t if the file exists and loads successfully. */) } static Lisp_Object -load_unwind (arg) /* used as unwind-protect function in load */ - Lisp_Object arg; +load_unwind (Lisp_Object arg) /* used as unwind-protect function in load */ { FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer; if (stream != NULL) @@ -1324,8 +1279,7 @@ load_unwind (arg) /* used as unwind-protect function in load */ } static Lisp_Object -load_descriptor_unwind (oldlist) - Lisp_Object oldlist; +load_descriptor_unwind (Lisp_Object oldlist) { load_descriptor_list = oldlist; return Qnil; @@ -1335,7 +1289,7 @@ load_descriptor_unwind (oldlist) This is used when starting a subprocess. */ void -close_load_descs () +close_load_descs (void) { #ifndef WINDOWSNT Lisp_Object tail; @@ -1345,8 +1299,7 @@ close_load_descs () } static int -complete_filename_p (pathname) - Lisp_Object pathname; +complete_filename_p (Lisp_Object pathname) { register const unsigned char *s = SDATA (pathname); return (IS_DIRECTORY_SEP (s[0]) @@ -1362,8 +1315,7 @@ file name when searching. If non-nil, PREDICATE is used instead of `file-readable-p'. PREDICATE can also be an integer to pass to the access(2) function, in which case file-name-handlers are ignored. */) - (filename, path, suffixes, predicate) - Lisp_Object filename, path, suffixes, predicate; + (Lisp_Object filename, Lisp_Object path, Lisp_Object suffixes, Lisp_Object predicate) { Lisp_Object file; int fd = openp (path, filename, suffixes, &file, predicate); @@ -1394,11 +1346,7 @@ in which case file-name-handlers are ignored. */) but store the found remote file name in *STOREPTR. */ int -openp (path, str, suffixes, storeptr, predicate) - Lisp_Object path, str; - Lisp_Object suffixes; - Lisp_Object *storeptr; - Lisp_Object predicate; +openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) { register int fd; int fn_size = 100; @@ -1550,9 +1498,7 @@ openp (path, str, suffixes, storeptr, predicate) ENTIRE is 1 if loading that entire file, 0 if evaluating part of it. */ static void -build_load_history (filename, entire) - Lisp_Object filename; - int entire; +build_load_history (Lisp_Object filename, int entire) { register Lisp_Object tail, prev, newelt; register Lisp_Object tem, tem2; @@ -1611,17 +1557,15 @@ build_load_history (filename, entire) Vload_history); } -Lisp_Object -unreadpure (junk) /* Used as unwind-protect function in readevalloop */ - Lisp_Object junk; +static Lisp_Object +unreadpure (Lisp_Object junk) /* Used as unwind-protect function in readevalloop */ { read_pure = 0; return Qnil; } static Lisp_Object -readevalloop_1 (old) - Lisp_Object old; +readevalloop_1 (Lisp_Object old) { load_convert_to_unibyte = ! NILP (old); return Qnil; @@ -1631,7 +1575,7 @@ readevalloop_1 (old) information. */ static void -end_of_file_error () +end_of_file_error (void) { if (STRINGP (Vload_file_name)) xsignal1 (Qend_of_file, Vload_file_name); @@ -1647,15 +1591,13 @@ end_of_file_error () If the input is not from a buffer, they must be nil. */ static void -readevalloop (readcharfun, stream, sourcename, evalfun, - printflag, unibyte, readfun, start, end) - Lisp_Object readcharfun; - FILE *stream; - Lisp_Object sourcename; - Lisp_Object (*evalfun) (); - int printflag; - Lisp_Object unibyte, readfun; - Lisp_Object start, end; +readevalloop (Lisp_Object readcharfun, + FILE *stream, + Lisp_Object sourcename, + Lisp_Object (*evalfun) (Lisp_Object), + int printflag, + Lisp_Object unibyte, Lisp_Object readfun, + Lisp_Object start, Lisp_Object end) { register int c; register Lisp_Object val; @@ -1825,8 +1767,7 @@ DO-ALLOW-PRINT, if non-nil, specifies that `print' and related functions should work normally even if PRINTFLAG is nil. This function preserves the position of point. */) - (buffer, printflag, filename, unibyte, do_allow_print) - Lisp_Object buffer, printflag, filename, unibyte, do_allow_print; + (Lisp_Object buffer, Lisp_Object printflag, Lisp_Object filename, Lisp_Object unibyte, Lisp_Object do_allow_print) { int count = SPECPDL_INDEX (); Lisp_Object tem, buf; @@ -1869,8 +1810,7 @@ instead of `read' to read each expression. It gets one argument which is the input stream for reading characters. This function does not move point. */) - (start, end, printflag, read_function) - Lisp_Object start, end, printflag, read_function; + (Lisp_Object start, Lisp_Object end, Lisp_Object printflag, Lisp_Object read_function) { int count = SPECPDL_INDEX (); Lisp_Object tem, cbuf; @@ -1904,8 +1844,7 @@ STREAM or the value of `standard-input' may be: a string (takes text from string, starting at the beginning) t (read text line using minibuffer and use it, or read from standard input in batch mode). */) - (stream) - Lisp_Object stream; + (Lisp_Object stream) { if (NILP (stream)) stream = Vstandard_input; @@ -1922,8 +1861,7 @@ DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0, Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX). START and END optionally delimit a substring of STRING from which to read; they default to 0 and (length STRING) respectively. */) - (string, start, end) - Lisp_Object string, start, end; + (Lisp_Object string, Lisp_Object start, Lisp_Object end) { Lisp_Object ret; CHECK_STRING (string); @@ -1935,10 +1873,8 @@ START and END optionally delimit a substring of STRING from which to read; /* Function to set up the global context we need in toplevel read calls. */ static Lisp_Object -read_internal_start (stream, start, end) - Lisp_Object stream; - Lisp_Object start; /* Only used when stream is a string. */ - Lisp_Object end; /* Only used when stream is a string. */ +read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) +/* start, end only used when stream is a string. */ { Lisp_Object retval; @@ -1952,7 +1888,7 @@ read_internal_start (stream, start, end) if (STRINGP (stream) || ((CONSP (stream) && STRINGP (XCAR (stream))))) { - int startval, endval; + EMACS_INT startval, endval; Lisp_Object string; if (STRINGP (stream)) @@ -1996,9 +1932,7 @@ read_internal_start (stream, start, end) S is error string of length N (if > 0) */ static void -invalid_syntax (s, n) - const char *s; - int n; +invalid_syntax (const char *s, int n) { if (!n) n = strlen (s); @@ -2010,8 +1944,7 @@ invalid_syntax (s, n) are not allowed. */ static Lisp_Object -read0 (readcharfun) - Lisp_Object readcharfun; +read0 (Lisp_Object readcharfun) { register Lisp_Object val; int c; @@ -2031,9 +1964,7 @@ static char *read_buffer; If the escape sequence forces unibyte, return eight-bit char. */ static int -read_escape (readcharfun, stringp) - Lisp_Object readcharfun; - int stringp; +read_escape (Lisp_Object readcharfun, int stringp) { register int c = READCHAR; /* \u allows up to four hex digits, \U up to eight. Default to the @@ -2247,9 +2178,7 @@ read_escape (readcharfun, stringp) range. */ static Lisp_Object -read_integer (readcharfun, radix) - Lisp_Object readcharfun; - int radix; +read_integer (Lisp_Object readcharfun, int radix) { int ndigits = 0, invalid_p, c, sign = 0; /* We use a floating point number because */ @@ -2314,10 +2243,7 @@ read_integer (readcharfun, radix) FIRST_IN_LIST is nonzero if this is the first element of a list. */ static Lisp_Object -read1 (readcharfun, pch, first_in_list) - register Lisp_Object readcharfun; - int *pch; - int first_in_list; +read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) { register int c; int uninterned_symbol = 0; @@ -2483,8 +2409,7 @@ read1 (readcharfun, pch, first_in_list) invalid_syntax ("#&...", 5); val = Fmake_bool_vector (length, Qnil); - bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data, - size_in_chars); + memcpy (XBOOL_VECTOR (val)->data, SDATA (tmp), size_in_chars); /* Clear the extraneous bits in the last byte. */ if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR) XBOOL_VECTOR (val)->data[size_in_chars - 1] @@ -2696,22 +2621,35 @@ read1 (readcharfun, pch, first_in_list) } case '`': - if (first_in_list) - { - Vold_style_backquotes = Qt; - goto default_label; - } - else - { - Lisp_Object value; - - new_backquote_flag++; - value = read0 (readcharfun); - new_backquote_flag--; + { + int next_char = READCHAR; + UNREAD (next_char); + /* Transition from old-style to new-style: + If we see "(`" it used to mean old-style, which usually works + fine because ` should almost never appear in such a position + for new-style. But occasionally we need "(`" to mean new + style, so we try to distinguish the two by the fact that we + can either write "( `foo" or "(` foo", where the first + intends to use new-style whereas the second intends to use + old-style. For Emacs-25, we should completely remove this + first_in_list exception (old-style can still be obtained via + "(\`" anyway). */ + if (first_in_list && next_char == ' ') + { + Vold_style_backquotes = Qt; + goto default_label; + } + else + { + Lisp_Object value; - return Fcons (Qbackquote, Fcons (value, Qnil)); - } + new_backquote_flag++; + value = read0 (readcharfun); + new_backquote_flag--; + return Fcons (Qbackquote, Fcons (value, Qnil)); + } + } case ',': if (new_backquote_flag) { @@ -2774,7 +2712,7 @@ read1 (readcharfun, pch, first_in_list) ok = (next_next_char <= 040 || (next_next_char < 0200 - && (index ("\"';([#?", next_next_char) + && (strchr ("\"';([#?", next_next_char) || (!first_in_list && next_next_char == '`') || (new_backquote_flag && next_next_char == ',')))); } @@ -2782,7 +2720,7 @@ read1 (readcharfun, pch, first_in_list) { ok = (next_char <= 040 || (next_char < 0200 - && (index ("\"';()[]#?", next_char) + && (strchr ("\"';()[]#?", next_char) || (!first_in_list && next_char == '`') || (new_backquote_flag && next_char == ',')))); } @@ -2927,7 +2865,7 @@ read1 (readcharfun, pch, first_in_list) if (next_char <= 040 || (next_char < 0200 - && (index ("\"';([#?", next_char) + && (strchr ("\"';([#?", next_char) || (!first_in_list && next_char == '`') || (new_backquote_flag && next_char == ',')))) { @@ -2954,7 +2892,7 @@ read1 (readcharfun, pch, first_in_list) while (c > 040 && c != 0x8a0 /* NBSP */ && (c >= 0200 - || (!index ("\"';()[]#", c) + || (!strchr ("\"';()[]#", c) && !(!first_in_list && c == '`') && !(new_backquote_flag && c == ',')))) { @@ -3113,9 +3051,7 @@ read1 (readcharfun, pch, first_in_list) static Lisp_Object seen_list; static void -substitute_object_in_subtree (object, placeholder) - Lisp_Object object; - Lisp_Object placeholder; +substitute_object_in_subtree (Lisp_Object object, Lisp_Object placeholder) { Lisp_Object check_object; @@ -3150,10 +3086,7 @@ substitute_object_in_subtree (object, placeholder) } while (0) static Lisp_Object -substitute_object_recurse (object, placeholder, subtree) - Lisp_Object object; - Lisp_Object placeholder; - Lisp_Object subtree; +substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Object subtree) { /* If we find the placeholder, return the target object. */ if (EQ (placeholder, subtree)) @@ -3228,9 +3161,7 @@ substitute_object_recurse (object, placeholder, subtree) /* Helper function for substitute_object_recurse. */ static void -substitute_in_interval (interval, arg) - INTERVAL interval; - Lisp_Object arg; +substitute_in_interval (INTERVAL interval, Lisp_Object arg) { Lisp_Object object = Fcar (arg); Lisp_Object placeholder = Fcdr (arg); @@ -3246,13 +3177,10 @@ substitute_in_interval (interval, arg) #define EXP_INT 16 int -isfloat_string (cp, ignore_trailing) - register char *cp; - int ignore_trailing; +isfloat_string (const char *cp, int ignore_trailing) { - register int state; - - char *start = cp; + int state; + const char *start = cp; state = 0; if (*cp == '+' || *cp == '-') @@ -3303,7 +3231,8 @@ isfloat_string (cp, ignore_trailing) } return ((ignore_trailing - || (*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || (*cp == '\r') || (*cp == '\f')) + || *cp == 0 || *cp == ' ' || *cp == '\t' || *cp == '\n' + || *cp == '\r' || *cp == '\f') && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT) || state == (DOT_CHAR|TRAIL_INT) || state == (LEAD_INT|E_CHAR|EXP_INT) @@ -3313,9 +3242,7 @@ isfloat_string (cp, ignore_trailing) static Lisp_Object -read_vector (readcharfun, bytecodeflag) - Lisp_Object readcharfun; - int bytecodeflag; +read_vector (Lisp_Object readcharfun, int bytecodeflag) { register int i; register int size; @@ -3398,9 +3325,7 @@ read_vector (readcharfun, bytecodeflag) and make structure pure. */ static Lisp_Object -read_list (flag, readcharfun) - int flag; - register Lisp_Object readcharfun; +read_list (int flag, register Lisp_Object readcharfun) { /* -1 means check next element for defun, 0 means don't check, @@ -3588,14 +3513,13 @@ Lisp_Object initial_obarray; int oblookup_last_bucket_number; -static int hash_string (); +static int hash_string (const unsigned char *ptr, int len); /* Get an error if OBARRAY is not an obarray. If it is one, return it. */ Lisp_Object -check_obarray (obarray) - Lisp_Object obarray; +check_obarray (Lisp_Object obarray) { if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) { @@ -3610,8 +3534,7 @@ check_obarray (obarray) interned in the current obarray. */ Lisp_Object -intern (str) - const char *str; +intern (const char *str) { Lisp_Object tem; int len = strlen (str); @@ -3652,14 +3575,13 @@ intern_c_string (const char *str) /* Create an uninterned symbol with name STR. */ Lisp_Object -make_symbol (str) - char *str; +make_symbol (const char *str) { int len = strlen (str); - return Fmake_symbol ((!NILP (Vpurify_flag) - ? make_pure_string (str, len, len, 0) - : make_string (str, len))); + return Fmake_symbol (!NILP (Vpurify_flag) + ? make_pure_string (str, len, len, 0) + : make_string (str, len)); } DEFUN ("intern", Fintern, Sintern, 1, 2, 0, @@ -3667,8 +3589,7 @@ DEFUN ("intern", Fintern, Sintern, 1, 2, 0, If there is none, one is created by this function and returned. A second optional argument specifies the obarray to use; it defaults to the value of `obarray'. */) - (string, obarray) - Lisp_Object string, obarray; + (Lisp_Object string, Lisp_Object obarray) { register Lisp_Object tem, sym, *ptr; @@ -3696,7 +3617,8 @@ it defaults to the value of `obarray'. */) && EQ (obarray, initial_obarray)) { XSYMBOL (sym)->constant = 1; - XSYMBOL (sym)->value = sym; + XSYMBOL (sym)->redirect = SYMBOL_PLAINVAL; + SET_SYMBOL_VAL (XSYMBOL (sym), sym); } ptr = &XVECTOR (obarray)->contents[XINT (tem)]; @@ -3714,8 +3636,7 @@ NAME may be a string or a symbol. If it is a symbol, that exact symbol is searched for. A second optional argument specifies the obarray to use; it defaults to the value of `obarray'. */) - (name, obarray) - Lisp_Object name, obarray; + (Lisp_Object name, Lisp_Object obarray) { register Lisp_Object tem, string; @@ -3743,8 +3664,7 @@ The value is t if a symbol was found and deleted, nil otherwise. NAME may be a string or a symbol. If it is a symbol, that symbol is deleted, if it belongs to OBARRAY--no other symbol is deleted. OBARRAY defaults to the value of the variable `obarray'. */) - (name, obarray) - Lisp_Object name, obarray; + (Lisp_Object name, Lisp_Object obarray) { register Lisp_Object string, tem; int hash; @@ -3777,8 +3697,6 @@ OBARRAY defaults to the value of the variable `obarray'. */) error ("Attempt to unintern t or nil"); */ XSYMBOL (tem)->interned = SYMBOL_UNINTERNED; - XSYMBOL (tem)->constant = 0; - XSYMBOL (tem)->indirect_variable = 0; hash = oblookup_last_bucket_number; @@ -3816,10 +3734,7 @@ OBARRAY defaults to the value of the variable `obarray'. */) Also store the bucket number in oblookup_last_bucket_number. */ Lisp_Object -oblookup (obarray, ptr, size, size_byte) - Lisp_Object obarray; - register const char *ptr; - int size, size_byte; +oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte) { int hash; int obsize; @@ -3846,7 +3761,7 @@ oblookup (obarray, ptr, size, size_byte) { if (SBYTES (SYMBOL_NAME (tail)) == size_byte && SCHARS (SYMBOL_NAME (tail)) == size - && !bcmp (SDATA (SYMBOL_NAME (tail)), ptr, size_byte)) + && !memcmp (SDATA (SYMBOL_NAME (tail)), ptr, size_byte)) return tail; else if (XSYMBOL (tail)->next == 0) break; @@ -3856,9 +3771,7 @@ oblookup (obarray, ptr, size, size_byte) } static int -hash_string (ptr, len) - const unsigned char *ptr; - int len; +hash_string (const unsigned char *ptr, int len) { register const unsigned char *p = ptr; register const unsigned char *end = p + len; @@ -3875,10 +3788,7 @@ hash_string (ptr, len) } void -map_obarray (obarray, fn, arg) - Lisp_Object obarray; - void (*fn) P_ ((Lisp_Object, Lisp_Object)); - Lisp_Object arg; +map_obarray (Lisp_Object obarray, void (*fn) (Lisp_Object, Lisp_Object), Lisp_Object arg) { register int i; register Lisp_Object tail; @@ -3897,9 +3807,8 @@ map_obarray (obarray, fn, arg) } } -void -mapatoms_1 (sym, function) - Lisp_Object sym, function; +static void +mapatoms_1 (Lisp_Object sym, Lisp_Object function) { call1 (function, sym); } @@ -3907,8 +3816,7 @@ mapatoms_1 (sym, function) DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0, doc: /* Call FUNCTION on every symbol in OBARRAY. OBARRAY defaults to the value of `obarray'. */) - (function, obarray) - Lisp_Object function, obarray; + (Lisp_Object function, Lisp_Object obarray) { if (NILP (obarray)) obarray = Vobarray; obarray = check_obarray (obarray); @@ -3920,38 +3828,34 @@ OBARRAY defaults to the value of `obarray'. */) #define OBARRAY_SIZE 1511 void -init_obarray () +init_obarray (void) { Lisp_Object oblength; - int hash; - Lisp_Object *tem; XSETFASTINT (oblength, OBARRAY_SIZE); - Qnil = Fmake_symbol (make_pure_c_string ("nil")); Vobarray = Fmake_vector (oblength, make_number (0)); initial_obarray = Vobarray; staticpro (&initial_obarray); - /* Intern nil in the obarray */ - XSYMBOL (Qnil)->interned = SYMBOL_INTERNED_IN_INITIAL_OBARRAY; - XSYMBOL (Qnil)->constant = 1; - - /* These locals are to kludge around a pyramid compiler bug. */ - hash = hash_string ("nil", 3); - /* Separate statement here to avoid VAXC bug. */ - hash %= OBARRAY_SIZE; - tem = &XVECTOR (Vobarray)->contents[hash]; - *tem = Qnil; Qunbound = Fmake_symbol (make_pure_c_string ("unbound")); - XSYMBOL (Qnil)->function = Qunbound; - XSYMBOL (Qunbound)->value = Qunbound; + /* Set temporary dummy values to Qnil and Vpurify_flag to satisfy the + NILP (Vpurify_flag) check in intern_c_string. */ + Qnil = make_number (-1); Vpurify_flag = make_number (1); + Qnil = intern_c_string ("nil"); + + /* Fmake_symbol inits fields of new symbols with Qunbound and Qnil, + so those two need to be fixed manally. */ + SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound); XSYMBOL (Qunbound)->function = Qunbound; + XSYMBOL (Qunbound)->plist = Qnil; + /* XSYMBOL (Qnil)->function = Qunbound; */ + SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil); + XSYMBOL (Qnil)->constant = 1; + XSYMBOL (Qnil)->plist = Qnil; Qt = intern_c_string ("t"); - XSYMBOL (Qnil)->value = Qnil; - XSYMBOL (Qnil)->plist = Qnil; - XSYMBOL (Qt)->value = Qt; + SET_SYMBOL_VAL (XSYMBOL (Qt), Qt); XSYMBOL (Qt)->constant = 1; /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ @@ -3965,8 +3869,7 @@ init_obarray () } void -defsubr (sname) - struct Lisp_Subr *sname; +defsubr (struct Lisp_Subr *sname) { Lisp_Object sym; sym = intern_c_string (sname->symbol_name); @@ -3990,27 +3893,29 @@ defalias (sname, string) to a C variable of type int. Sample call: DEFVAR_INT ("emacs-priority", &emacs_priority, "Documentation"); */ void -defvar_int (const char *namestring, EMACS_INT *address) +defvar_int (struct Lisp_Intfwd *i_fwd, + const char *namestring, EMACS_INT *address) { - Lisp_Object sym, val; + Lisp_Object sym; sym = intern_c_string (namestring); - val = allocate_misc (); - XMISCTYPE (val) = Lisp_Misc_Intfwd; - XINTFWD (val)->intvar = address; - SET_SYMBOL_VALUE (sym, val); + i_fwd->type = Lisp_Fwd_Int; + i_fwd->intvar = address; + XSYMBOL (sym)->redirect = SYMBOL_FORWARDED; + SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)i_fwd); } /* Similar but define a variable whose value is t if address contains 1, nil if address contains 0. */ void -defvar_bool (const char *namestring, int *address) +defvar_bool (struct Lisp_Boolfwd *b_fwd, + const char *namestring, int *address) { - Lisp_Object sym, val; + Lisp_Object sym; sym = intern_c_string (namestring); - val = allocate_misc (); - XMISCTYPE (val) = Lisp_Misc_Boolfwd; - XBOOLFWD (val)->boolvar = address; - SET_SYMBOL_VALUE (sym, val); + b_fwd->type = Lisp_Fwd_Bool; + b_fwd->boolvar = address; + XSYMBOL (sym)->redirect = SYMBOL_FORWARDED; + SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)b_fwd); Vbyte_boolean_vars = Fcons (sym, Vbyte_boolean_vars); } @@ -4020,20 +3925,22 @@ defvar_bool (const char *namestring, int *address) gc-marked for some other reason, since marking the same slot twice can cause trouble with strings. */ void -defvar_lisp_nopro (const char *namestring, Lisp_Object *address) +defvar_lisp_nopro (struct Lisp_Objfwd *o_fwd, + const char *namestring, Lisp_Object *address) { - Lisp_Object sym, val; + Lisp_Object sym; sym = intern_c_string (namestring); - val = allocate_misc (); - XMISCTYPE (val) = Lisp_Misc_Objfwd; - XOBJFWD (val)->objvar = address; - SET_SYMBOL_VALUE (sym, val); + o_fwd->type = Lisp_Fwd_Obj; + o_fwd->objvar = address; + XSYMBOL (sym)->redirect = SYMBOL_FORWARDED; + SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)o_fwd); } void -defvar_lisp (const char *namestring, Lisp_Object *address) +defvar_lisp (struct Lisp_Objfwd *o_fwd, + const char *namestring, Lisp_Object *address) { - defvar_lisp_nopro (namestring, address); + defvar_lisp_nopro (o_fwd, namestring, address); staticpro (address); } @@ -4041,14 +3948,15 @@ defvar_lisp (const char *namestring, Lisp_Object *address) at a particular offset in the current kboard object. */ void -defvar_kboard (const char *namestring, int offset) +defvar_kboard (struct Lisp_Kboard_Objfwd *ko_fwd, + const char *namestring, int offset) { - Lisp_Object sym, val; + Lisp_Object sym; sym = intern_c_string (namestring); - val = allocate_misc (); - XMISCTYPE (val) = Lisp_Misc_Kboard_Objfwd; - XKBOARD_OBJFWD (val)->offset = offset; - SET_SYMBOL_VALUE (sym, val); + ko_fwd->type = Lisp_Fwd_Kboard_Obj; + ko_fwd->offset = offset; + XSYMBOL (sym)->redirect = SYMBOL_FORWARDED; + SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)ko_fwd); } /* Record the value of load-path used at the start of dumping @@ -4056,9 +3964,9 @@ defvar_kboard (const char *namestring, int offset) static Lisp_Object dump_path; void -init_lread () +init_lread (void) { - char *normal; + const char *normal; int turn_off_warning = 0; /* Compute the default load-path. */ @@ -4249,9 +4157,7 @@ init_lread () does not exist. Print it on stderr and put it in *Messages*. */ void -dir_warning (format, dirname) - char *format; - Lisp_Object dirname; +dir_warning (const char *format, Lisp_Object dirname) { char *buffer = (char *) alloca (SCHARS (dirname) + strlen (format) + 5); @@ -4264,7 +4170,7 @@ dir_warning (format, dirname) } void -syms_of_lread () +syms_of_lread (void) { defsubr (&Sread); defsubr (&Sread_from_string); diff --git a/src/m/alpha.h b/src/m/alpha.h index 5abf8bba726..3b6d7da92df 100644 --- a/src/m/alpha.h +++ b/src/m/alpha.h @@ -1,6 +1,7 @@ /* Machine description file for the alpha chip. - Copyright (C) 1994, 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1994, 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Author: Rainer Schoepf (according to authors.el) @@ -20,35 +21,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="note" - -NOTE-START -Use -opsystem=osf1 -NOTE-END - -*/ - #ifndef _LP64 -#define _LP64 /* This doesn't appear to be necessary - on OSF 4/5 -- fx. */ +#define _LP64 /* This doesn't appear to be necessary on OSF 4/5 -- fx. */ #endif -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Now define a symbol for the cpu type, if your compiler does not define it automatically. */ - /* __alpha defined automatically */ @@ -57,80 +35,31 @@ NOTE-END are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) -/* GNU malloc and the relocating allocator do not work together - with X. [Who wrote that?] */ - -/* May 1995: reportedly [Rainer Schoepf <schoepf@uni-mainz.de>] both the - system and the gnu malloc system work with "alpha-dec-osf3.0" and - "alpha-dec-osf3.2". */ - -/* May 1995: it seems to me [Morten Welinder <terra@diku.dk>] that both - mallocs work with "alpha-dec-osf2.0", but I daren't break anything - right now. Feel free to play if you want. */ - -/* #define SYSTEM_MALLOC */ - #ifdef __ELF__ -/* With ELF, make sure that all common symbols get allocated to in the - data section. Otherwise, the dump of temacs may miss variables in - the shared library that have been initialized. For example, with - GNU libc, __malloc_initialized would normally be resolved to the - shared library's .bss section, which is fatal. */ -# ifdef __GNUC__ -# define C_SWITCH_MACHINE -fno-common -# else -# error What gives? Fix me if DEC Unix supports ELF now. -# endif - -#undef UNEXEC -#define UNEXEC unexelf.o + #if !defined(GNU_LINUX) && !defined(__NetBSD__) #define DATA_START 0x140000000 #endif -#if (defined (__NetBSD__) || defined (__OpenBSD__)) -#define HAVE_TEXT_START -#endif - #else /* not __ELF__ */ /* Describe layout of the address space in an executing process. */ - -#define TEXT_START 0x120000000 #define DATA_START 0x140000000 -/* The program to be used for unexec. */ - -#define UNEXEC unexalpha.o - #endif /* __ELF__ */ -#if defined (GNU_LINUX) && __GNU_LIBRARY__ - 0 < 6 -/* This controls a conditional in main. */ -#define LINUX_SBRK_BUG -#endif - /* On the Alpha it's best to avoid including TERMIO since struct termio and struct termios are mutually incompatible. */ #define NO_TERMIO -#if defined (GNU_LINUX) || defined (__NetBSD__) || defined (__OpenBSD__) -# ifndef __ELF__ -# define COFF -# endif /* notdef __ELF__ */ -#endif - /* Many Alpha implementations (e.g. gas 2.8) can't handle DBL_MIN: they generate code that uses a signaling NaN instead of DBL_MIN. Define DBL_MIN_REPLACEMENT to be the next value larger than DBL_MIN: diff --git a/src/m/amdx86-64.h b/src/m/amdx86-64.h index 4bea30d12de..30aa2678717 100644 --- a/src/m/amdx86-64.h +++ b/src/m/amdx86-64.h @@ -1,6 +1,7 @@ /* machine description file for AMD x86-64. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + +Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,32 +18,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef i386 -/* Although we're running on an amd64 kernel, we're actually compiling for - the x86 architecture. The user should probably have provided an - explicit --build to `configure', but if everything else than the kernel - is running in i386 mode, then the bug is really ours: we should have - guessed better. */ -#include "m/intel386.h" -#else - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="linux" */ - #define BITS_PER_LONG 64 #define BITS_PER_EMACS_INT 64 -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Now define a symbol for the cpu type, if your compiler does not define it automatically: Ones defined so far include vax, m68000, ns16000, pyramid, @@ -58,77 +36,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ #undef DATA_SEG_BITS -#ifdef __FreeBSD__ - -/* The libraries for binaries native to the build host's architecture are - installed under /usr/lib in FreeBSD, and the ones that need special paths - are 32-bit compatibility libraries (installed under /usr/lib32). To build - a native binary of Emacs on FreeBSD/amd64 we can just point to /usr/lib. */ - -#undef START_FILES -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o - -/* The duplicate -lgcc is intentional in the definition of LIB_STANDARD. - The reason is that some functions in libgcc.a call functions from libc.a, - and some libc.a functions need functions from libgcc.a. Since most - versions of ld are one-pass linkers, we need to mention -lgcc twice, - or else we risk getting unresolved externals. */ -#undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o - -#elif defined(__OpenBSD__) - -#undef START_FILES -#define START_FILES pre-crt0.o /usr/lib/crt0.o /usr/lib/crtbegin.o -#undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtend.o - -#elif defined(__NetBSD__) - -/* LIB_STANDARD and START_FILES set correctly in s/netbsd.h */ - -#elif defined(SOLARIS2) - -#undef START_FILES -#undef LIB_STANDARD - -#elif defined(__APPLE__) - -/* LIB_STANDARD and START_FILES set correctly in s/darwin.h */ - -#else /* !__OpenBSD__ && !__FreeBSD__ && !__NetBSD__ && !SOLARIS2 - && !__APPLE__ */ -/* The duplicate -lgcc is intentional in the definition of LIB_STANDARD. - The reason is that some functions in libgcc.a call functions from libc.a, - and some libc.a functions need functions from libgcc.a. Since most - versions of ld are one-pass linkers, we need to mention -lgcc twice, - or else we risk getting unresolved externals. */ -#undef START_FILES -#undef LIB_STANDARD -#ifdef HAVE_LIB64_DIR -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#else -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o -#endif - -#endif /* __FreeBSD__ */ -#endif /* !i386 */ - /* arch-tag: 8a5e001d-e12e-4692-a3a6-0b15ba271c6e (do not change this comment) */ diff --git a/src/m/arm.h b/src/m/arm.h index b04c5ecc1d9..8b659bb5bd0 100644 --- a/src/m/arm.h +++ b/src/m/arm.h @@ -1,6 +1,7 @@ /* Machine description file for ARM-based non-RISCiX machines. - Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,30 +18,5 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. We can't - * do this on the arm with gcc, since the first 4 args are in registers. */ - -#ifdef __GNUC__ -#define NO_ARG_ARRAY -#else -#undef NO_ARG_ARRAY -#endif - -#define NO_REMAP - -/* armin76@gentoo.org reported that the lgcc_s flag is necessary to - build on ARM EABI under GNU/Linux (Bug#5518). */ -#ifdef GNU_LINUX -#define LIB_GCC -lgcc_s -#endif - /* arch-tag: 07856f0c-f0c8-4bd8-99af-0b7fa1e5ee42 (do not change this comment) */ diff --git a/src/m/hp800.h b/src/m/hp800.h index 5614141fe63..9998f701a6b 100644 --- a/src/m/hp800.h +++ b/src/m/hp800.h @@ -1,6 +1,7 @@ /* machine description file for hp9000 series 800 machines. - Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,119 +18,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="hpux" */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend the bit field into an int. In other words, if bit fields are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND - -/* Common definitions for HPUX and GNU/Linux. */ - -#if defined (__hpux) || defined (GNU_LINUX) - -/* Define NO_REMAP if memory segmentation makes it not work well - to change the boundary between the text section and data section - when Emacs is dumped. If you define this, the preloaded Lisp - code will not be sharable; but that's better than failing completely. */ - -#define NO_REMAP - -#endif /* __hpux or GNU_LINUX */ - -/* Stuff for just GNU/Linux. */ - -#ifdef GNU_LINUX - -/* Data type of load average, as read out of kmem. */ - -#define LOAD_AVE_TYPE long - -/* Convert that into an integer that is 100 for a load average of 1.0 */ - -#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) - -#endif /* GNU_LINUX */ - -/* Stuff for just HPUX. */ - -#ifdef __hpux - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ - -#define VIRT_ADDR_VARIES - -/* the data segment on this machine always starts at address 0x40000000. */ - -#define DATA_SEG_BITS 0x40000000 - -#define DATA_START 0x40000000 -#define TEXT_START 0x00000000 - -/* This machine requires completely different unexec code - which lives in a separate file. Specify the file name. */ - -#define UNEXEC unexhp9k800.o - -#define LIBS_MACHINE -#define LIBS_DEBUG - -/* Include the file bsdtty.h, since this machine has job control. */ -#define NEED_BSDTTY - -/* Data type of load average, as read out of kmem. */ - -#define LOAD_AVE_TYPE double - -/* Convert that into an integer that is 100 for a load average of 1.0 */ - -#define LOAD_AVE_CVT(x) ((int) (x * 100.0)) - -/* The symbol in the kernel where the load average is found - is named _avenrun. At this time there are two major flavors - of hp-ux (there is the s800 and s300 (s200) flavors). The - differences are thusly moved to the corresponding machine description file. -*/ - -/* no underscore please */ -#define LDAV_SYMBOL "avenrun" - -/* On USG systems these have different names. */ - -#define index strchr -#define rindex strrchr - -#endif /* __hpux */ - -/* Systems with GCC don't need to lose. */ -#ifdef __NetBSD__ -# ifdef __GNUC__ -# define alloca __builtin_alloca -# define HAVE_ALLOCA -# endif /* __GNUC__ */ -#endif /* __NetBSD__ */ - /* arch-tag: 809436e6-1645-4b92-b40d-2de5d6e7227c (do not change this comment) */ diff --git a/src/m/ia64.h b/src/m/ia64.h index 188697b7e89..bbf09ac878b 100644 --- a/src/m/ia64.h +++ b/src/m/ia64.h @@ -1,7 +1,9 @@ /* machine description file for the IA-64 architecture. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. - Contributed by David Mosberger <davidm@hpl.hp.com> + +Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. + +Contributed by David Mosberger <davidm@hpl.hp.com> This file is part of GNU Emacs. @@ -21,22 +23,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define BITS_PER_LONG 64 #define BITS_PER_EMACS_INT 64 -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Now define a symbol for the cpu type, if your compiler does not define it automatically. */ - /* __ia64__ defined automatically */ - /* Define the type to use. */ #define EMACS_INT long #define EMACS_UINT unsigned long @@ -46,24 +36,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) -#ifdef __ELF__ -#undef UNEXEC -#define UNEXEC unexelf.o -#endif - -#ifndef NOT_C_CODE - #ifdef REL_ALLOC #ifndef _MALLOC_INTERNAL /* "char *" because ralloc.c defines it that way. gmalloc.c thinks it @@ -74,9 +54,5 @@ extern void r_alloc_free (); #endif /* not _MALLOC_INTERNAL */ #endif /* REL_ALLOC */ -#endif /* not NOT_C_CODE */ - -#define HAVE_TEXT_START - /* arch-tag: 9b8e9fb2-2e49-4c22-b68f-11a488e77c66 (do not change this comment) */ diff --git a/src/m/ibmrs6000.h b/src/m/ibmrs6000.h index 757db149ed2..785719e908b 100644 --- a/src/m/ibmrs6000.h +++ b/src/m/ibmrs6000.h @@ -1,6 +1,7 @@ /* R2 AIX machine/system dependent defines - Copyright (C) 1988, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1988, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,73 +19,21 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="aix3-1" */ - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - -/* Now define a symbol for the cpu type, if your compiler - does not define it automatically. */ - -#define IBMR2AIX - -#ifndef UNEXEC -#define UNEXEC unexaix.o -#endif - -/* Define addresses, macros, change some setup for dump */ - -#define NO_REMAP - /* The data segment in this machine always starts at address 0x20000000. An address of data cannot be stored correctly in a Lisp object; we always lose the high bits. We must tell XPNTR to add them back. */ - -#ifndef USG5_4 -#define TEXT_START 0x10000000 #define DATA_START 0x20000000 -#define WORDS_BIG_ENDIAN #define DATA_SEG_BITS 0x20000000 -/* sfreed@unm.edu says add -bI:/usr/lpp/X11/bin/smt.exp for AIX 3.2.4. */ -/* marc@sti.com (Marc Pawliger) says ibmrs6000.inp is needed to avoid - linker error for updated X11R5 libraries, which references pthread library - which most machines don't have. We use the name .inp instead of .imp - because .inp is a better convention to use in make-dist for naming - random input files. */ -#ifdef THIS_IS_MAKEFILE /* Don't use this in configure. */ -#define LD_SWITCH_MACHINE -Wl,-bnodelcsect -#endif /* THIS_IS_MAKEFILE */ - #ifndef NLIST_STRUCT /* AIX supposedly doesn't use this interface, but on the RS/6000 it apparently does. */ #define NLIST_STRUCT #endif -/* -lpthreads seems to be necessary for Xlib in X11R6, and should be harmless - on older versions of X where it happens to exist. */ -#ifdef HAVE_LIBPTHREADS -#define LIBS_MACHINE -lrts -lIM -liconv -lpthreads -#else -/* IBM's X11R5 use -lIM and -liconv in AIX 3.2.2. */ -#define LIBS_MACHINE -lrts -lIM -liconv -#endif - -#else /* USG5_4 */ -#undef WORDS_BIG_ENDIAN -#define DATA_SEG_BITS 0 -#define LIBS_MACHINE -#endif /* USG5_4 */ - #undef ADDR_CORRECT #define ADDR_CORRECT(x) ((int)(x)) -#define START_FILES /*** BUILD 9008 - FIONREAD problem still exists in X-Windows. ***/ #define BROKEN_FIONREAD /* As we define BROKEN_FIONREAD, SIGIO will be undefined in systty.h. @@ -96,7 +45,5 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define BROKEN_SIGPTY #define BROKEN_SIGPOLL -#define ORDINARY_LINK - /* arch-tag: 028318ee-a7ae-4a08-804d-cc1e6588d003 (do not change this comment) */ diff --git a/src/m/ibmrs6000.inp b/src/m/ibmrs6000.inp deleted file mode 100644 index d7f3fddaf6f..00000000000 --- a/src/m/ibmrs6000.inp +++ /dev/null @@ -1,4 +0,0 @@ -#! -pthread_yield - -# arch-tag: fc6d01ea-c488-4862-bbdb-e8d3e0f6fdb3 diff --git a/src/m/ibms390.h b/src/m/ibms390.h index 794ab869511..0acc826a1ea 100644 --- a/src/m/ibms390.h +++ b/src/m/ibms390.h @@ -1,6 +1,7 @@ -/* machine description file template. - Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. +/* Machine description file for IBM S390 in 32-bit mode + +Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,34 +19,17 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="<name of system .h file here, without the s- or .h>" */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend the 24-bit bit field into an int. In other words, if bit fields are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) /* Define VIRT_ADDR_VARIES if the virtual addresses of @@ -54,7 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ Otherwise Emacs assumes that text space precedes data space, numerically. */ - #define VIRT_ADDR_VARIES /* arch-tag: d8a0ffa4-a8f0-4736-90d3-7fd7b21b8314 diff --git a/src/m/ibms390x.h b/src/m/ibms390x.h index 9429e4282bf..6cbfbbcdbd4 100644 --- a/src/m/ibms390x.h +++ b/src/m/ibms390x.h @@ -1,6 +1,7 @@ -/* machine description file for IBM S390 in 64-bit mode - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. +/* Machine description file for IBM S390 in 64-bit mode + +Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,34 +18,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* This file was made by copying the significant parts of amdx86-64.h - into ibms390.h. */ - - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="<name of system .h file here, without the s- or .h>" - -NOTE-START -IBM s390 64 bits (-machine=ibms390x64) - - The possibilities for -opsystem are: gnu-linux. - -NOTE-END */ +#include "ibms390.h" #define BITS_PER_LONG 64 #define BITS_PER_EMACS_INT 64 -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Define the type to use. */ #define EMACS_INT long #define EMACS_UINT unsigned long @@ -54,55 +32,13 @@ NOTE-END */ are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #undef EXPLICIT_SIGN_EXTEND -/* Data type of load average, as read out of kmem. */ - -#define LOAD_AVE_TYPE long - -/* Convert that into an integer that is 100 for a load average of 1.0 */ - -#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ - -#define VIRT_ADDR_VARIES - -/* Define HAVE_ALLOCA to say that the system provides a properly - working alloca function and it should be used. Undefine it if an - assembler-language alloca in the file alloca.s should be used. */ - -#define HAVE_ALLOCA - /* On the 64 bit architecture, we can use 60 bits for addresses */ - #define VALBITS 60 -#define LINKER $(CC) -nostdlib - /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ - #define XPNTR(a) XUINT (a) -#undef START_FILES -#ifdef HAVE_LIB64_DIR -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -#else -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o -#endif - -#undef LIB_STANDARD -#ifdef HAVE_LIB64_DIR -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#else -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o -#endif - /* arch-tag: 4b87653c-6add-4663-8691-7d9dc17b5519 (do not change this comment) */ diff --git a/src/m/intel386.h b/src/m/intel386.h index 8b3c5fff064..15601fae76e 100644 --- a/src/m/intel386.h +++ b/src/m/intel386.h @@ -1,6 +1,7 @@ /* Machine description file for intel 386. - Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,89 +19,15 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="note" - -NOTE-START -Intel 386 (-machine=intel386) - - The possibilities for -opsystem are: bsd4-2, usg5-2-2, usg5-3, - isc2-2, 386-ix, and linux. - - 18.58 should support a wide variety of operating systems. - Use linux for Linux. - It isn't clear what to do on an SCO system. - -NOTE-END */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -/* #define NO_ARG_ARRAY */ - -/* crt0.c, if it is used, should use the i386-bsd style of entry. - with no extra dummy args. On USG and XENIX, - NO_REMAP says this isn't used. */ - -#define CRT0_DUMMIES bogus_fp, - -#ifdef SOLARIS2 -/* Data type of load average, as read out of kmem. */ -#define LOAD_AVE_TYPE long - -/* Convert that into an integer that is 100 for a load average of 1.0 */ -/* This is totally uncalibrated. */ -#define LOAD_AVE_CVT(x) ((int) (((double) (x)) * 100.0 / FSCALE)) - -/* J.W.Hawtin@lut.ac.uk say Solaris 2.4 as well as Solaris 2.1 on X86 - requires -lkvm as well. - And handa@etl.gov.jp says that -lkvm needs -llelf, at least on 2.5. */ -#define LIBS_MACHINE -lkvm -lelf - -/* configure thinks solaris X86 has gethostname, but it does not work, - so undefine it. */ -#undef HAVE_GETHOSTNAME - -#else /* not SOLARIS2 */ -#ifdef USG5_4 /* Older USG systems do not support the load average. */ -/* Data type of load average, as read out of kmem. */ - -#define LOAD_AVE_TYPE long - -/* Convert that into an integer that is 100 for a load average of 1.0 */ -/* This is totally uncalibrated. */ - -#define LOAD_AVE_CVT(x) ((int) (((double) (x)) * 100.0 / FSCALE)) -#define FSCALE 256.0 -#endif /* USG5_4 */ -#endif /* not SOLARIS2 */ - -#ifdef USG -#define TEXT_START 0 -#endif /* USG */ - -#ifdef MSDOS -#define NO_REMAP -#endif - #ifdef WINDOWSNT #define VIRT_ADDR_VARIES #define DATA_START get_data_start () -#define NO_ARG_ARRAY #endif #ifdef GNU_LINUX /* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */ /* we cannot get the maximum address for brk */ #define ULIMIT_BREAK_VALUE (32*1024*1024) - -#define SEGMENT_MASK ((SEGMENT_SIZE)-1) #endif /* arch-tag: 746338f0-cb7b-4f49-a98c-cb50817cf2ec diff --git a/src/m/iris4d.h b/src/m/iris4d.h index 7c0ff78a069..31f08d05cfc 100644 --- a/src/m/iris4d.h +++ b/src/m/iris4d.h @@ -1,6 +1,7 @@ /* machine description file for Iris-4D machines. Use with s/irix*.h. - Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,66 +19,18 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend the bit field into an int. In other words, if bit fields are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND -/* This machine requires completely different unexec code - which lives in a separate file. Specify the file name. */ - -#undef UNEXEC -#define UNEXEC unexelf.o - -#define TEXT_START 0x400000 - -/* - * DATA_SEG_BITS forces extra bits to be or'd in with any pointers which - * were stored in a Lisp_Object (as Emacs uses fewer than 32 bits for - * the value field of a LISP_OBJECT). - */ - +/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers which + were stored in a Lisp_Object (as Emacs uses fewer than 32 bits for + the value field of a LISP_OBJECT). */ #define DATA_START 0x10000000 #define DATA_SEG_BITS 0x10000000 -#undef LIBS_MACHINE -#define LIBS_MACHINE -#define LIBS_DEBUG - -/* Use terminfo instead of termcap. */ - -#define TERMINFO - -/* Letter to use in finding device name of first pty, - if system supports pty's. 'a' means it is /dev/ptya0 */ - -#undef FIRST_PTY_LETTER -#define FIRST_PTY_LETTER 'q' - -#if _MIPS_SZLONG != 64 -/* fixme: should there be 64-bit definitions? (The ones below aren't OK.) */ - -/* The standard definitions of these macros would work ok, - but these are faster because the constants are short. */ - -#define XUINT(a) (((unsigned)(a) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS) - -#define XSET(var, type, ptr) \ - ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)) -#endif /* _LP64 */ - /* arch-tag: fff5e139-9ae0-465d-afec-837c41ea0aa6 (do not change this comment) */ diff --git a/src/m/m68k.h b/src/m/m68k.h index b844f12fd6f..8d53424ccec 100644 --- a/src/m/m68k.h +++ b/src/m/m68k.h @@ -1,6 +1,7 @@ /* Machine description file for generic Motorola 68k. - Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,14 +18,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - /* Now define a symbol for the cpu type, if your compiler does not define it automatically. */ - #ifndef m68k #define m68k #endif @@ -34,7 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND #ifdef GNU_LINUX @@ -42,8 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define DATA_SEG_BITS 0x80000000 #endif -#define NO_REMAP -#define TEXT_START 0 #endif /* arch-tag: 4eadd161-b4e8-4b82-82a1-e4ce7f42969d diff --git a/src/m/macppc.h b/src/m/macppc.h index 150fc356518..01735790b20 100644 --- a/src/m/macppc.h +++ b/src/m/macppc.h @@ -1,6 +1,7 @@ /* machine description file For the powerpc Macintosh. - Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,45 +18,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) -#if (defined (__NetBSD__) || defined (__OpenBSD__)) && defined (__ELF__) -#define HAVE_TEXT_START -#endif - -/* NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says this is needed - For MkLinux/LinuxPPC. */ - -#ifdef GNU_LINUX -#define LINKER $(CC) -nostdlib -/* s/gnu-linux.h defines this to `-z nocombreloc' which does not work here - because prefix-args is not used. */ -#undef LD_SWITCH_SYSTEM_TEMACS -#define LD_SWITCH_MACHINE_TEMACS -Xlinker -znocombreloc -#ifdef _ARCH_PPC64 -#undef START_FILES -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -#undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#endif -#endif - #ifdef _ARCH_PPC64 #ifndef _LP64 #define _LP64 diff --git a/src/m/mips.h b/src/m/mips.h index 7a84b6596c8..b3a754c2b61 100644 --- a/src/m/mips.h +++ b/src/m/mips.h @@ -1,6 +1,7 @@ /* m- file for Mips machines. - Copyright (C) 1987, 1992, 1999, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1987, 1992, 1999, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,57 +18,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="note" - -NOTE-START -This is used on GNU/Linux and netbsd. -NOTE-END */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#if ! (defined (__MIPSEL__) || defined (MIPSEL) || defined (_MIPSEL)) -#define WORDS_BIG_ENDIAN -#endif - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend the 24-bit bit field into an int. In other words, if bit fields are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND -/* Describe layout of the address space in an executing process. */ - -#define TEXT_START 0x00400000 - - -#if 0 /* These definitions were advantageous when not using - USE_LSB_TAG. With that, they get ignored but cause errors. */ - -#define DATA_SEG_BITS 0x10000000 - -/* The standard definitions of these macros would work ok, - but these are faster because the constants are short. */ - -#define XUINT(a) (((unsigned)(a) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS)) - -#define XSET(var, type, ptr) \ - ((var) = \ - ((int)(type) << VALBITS) \ - + (((unsigned) (ptr) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS))) - /* arch-tag: 8fd020ee-78a7-4d87-96ce-6129f52f7bee (do not change this comment) */ - -#endif /* 0 */ - diff --git a/src/m/sh3.h b/src/m/sh3.h index bb8e2937b01..ebfdb5b2d64 100644 --- a/src/m/sh3.h +++ b/src/m/sh3.h @@ -1,10 +1,4 @@ /* Machine description file for SuperH. */ -#ifdef __BIG_ENDIAN__ -# define WORDS_BIG_ENDIAN -#endif - -#define NO_ARG_ARRAY - /* arch-tag: 1b01b84f-f044-4afa-aa4b-caa54ec38966 (do not change this comment) */ diff --git a/src/m/sparc.h b/src/m/sparc.h index 3eeb87a2b0e..26ca3caaebe 100644 --- a/src/m/sparc.h +++ b/src/m/sparc.h @@ -1,6 +1,7 @@ /* machine description file for Sun 4 SPARC. - Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,64 +18,27 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="note" - -NOTE-START -Use -opsystem=sunos4 for operating system version 4, and --opsystem=bsd4-2 for earlier versions. -NOTE-END */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* __sparc__ is defined by the compiler by default. */ /* XINT must explicitly sign-extend This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) -/* Mask for address bits within a memory segment */ - -#define SEGMENT_MASK (SEGSIZ - 1) - #ifdef __arch64__ /* GCC, 64-bit ABI. */ -#define BITS_PER_LONG 64 -#ifdef __linux__ -#undef START_FILES -#define START_FILES pre-crt0.o /usr/lib64/crt1.o /usr/lib64/crti.o -/* The duplicate -lgcc is intentional in the definition of LIB_STANDARD. - The reason is that some functions in libgcc.a call functions from libc.a, - and some libc.a functions need functions from libgcc.a. Since most - versions of ld are one-pass linkers, we need to mention -lgcc twice, - or else we risk getting unresolved externals. */ -#undef LIB_STANDARD -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib64/crtn.o -#endif +#define BITS_PER_LONG 64 #ifndef _LP64 -#define _LP64 /* Done on Alpha -- not sure if it - should be here. -- fx */ -#endif +#define _LP64 /* Done on Alpha -- not sure if it should be here. -- fx */ #endif +#endif /* __arch64__ */ + /* arch-tag: 0a6f7882-33fd-4811-9832-7466c51e50f7 (do not change this comment) */ diff --git a/src/m/template.h b/src/m/template.h index 6e0dbb79844..4efc9158a45 100644 --- a/src/m/template.h +++ b/src/m/template.h @@ -1,6 +1,7 @@ /* machine description file template. - Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,21 +18,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="<name of system .h file here, without the s- or .h>" */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#define WORDS_BIG_ENDIAN - -/* Define NO_ARG_ARRAY if you cannot take the address of the first of a - * group of arguments and treat it as an array of the arguments. */ - -#define NO_ARG_ARRAY - /* Now define a symbol for the cpu type, if your compiler does not define it automatically. Ones defined so far include m68k and many others */ @@ -41,59 +27,30 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ are always unsigned. This flag only matters if you use USE_LISP_UNION_TYPE. */ - #define EXPLICIT_SIGN_EXTEND /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE long /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) -/* Define CANNOT_DUMP on machines where unexec does not work. - Then the function dump-emacs will not be defined - and temacs will do (load "loadup") automatically unless told otherwise. */ - -#define CANNOT_DUMP - /* Define VIRT_ADDR_VARIES if the virtual addresses of pure and impure space as loaded can vary, and even their relative order cannot be relied on. Otherwise Emacs assumes that text space precedes data space, numerically. */ - #define VIRT_ADDR_VARIES -/* Define NO_REMAP if memory segmentation makes it not work well - to change the boundary between the text section and data section - when Emacs is dumped. If you define this, the preloaded Lisp - code will not be sharable; but that's better than failing completely. */ - -#define NO_REMAP - -/* Some really obscure 4.2-based systems (like Sequent DYNIX) - * do not support asynchronous I/O (using SIGIO) on sockets, - * even though it works fine on tty's. If you have one of - * these systems, define the following, and then use it in - * config.h (or elsewhere) to decide when (not) to use SIGIO. - * - * You'd think this would go in an operating-system description file, - * but since it only occurs on some, but not all, BSD systems, the - * reasonable place to select for it is in the machine description - * file. - */ - -#define NO_SOCK_SIGIO - - -/* After adding support for a new system, modify the large case - statement in the `configure' script to recognize reasonable +/* After adding support for a new machine, modify the large case + statement in configure.in to recognize reasonable configuration names, and add a description of the system to `etc/MACHINES'. + Check for any tests of $machine in configure.in, and add an entry + for the new machine if needed. + If you've just fixed a problem in an existing configuration file, you should also check `etc/MACHINES' to make sure its descriptions of known problems in that configuration should be updated. */ diff --git a/src/m/vax.h b/src/m/vax.h index fa6cc1b5977..16e790a2769 100644 --- a/src/m/vax.h +++ b/src/m/vax.h @@ -1,6 +1,7 @@ /* machine description file for vax. - Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,43 +19,18 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* The following line tells the configuration script what sort of - operating system this machine is likely to run. - USUAL-OPSYS="note" - -NOTE-START -The vax (-machine=vax) runs zillions of different operating systems. - -NOTE-END */ - -/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word - is the most significant byte. */ - -#undef WORDS_BIG_ENDIAN - /* #define vax -- appears to be done automatically */ -/* crt0.c should use the vax-bsd style of entry, with no dummy args. */ - -#define CRT0_DUMMIES - -#ifdef BSD_SYSTEM /* USG systems I know of running on Vaxes do not actually support the load average, so disable it for them. */ /* Data type of load average, as read out of kmem. */ - #define LOAD_AVE_TYPE double /* Convert that into an integer that is 100 for a load average of 1.0 */ - #define LOAD_AVE_CVT(x) ((int) ((x) * 100.0)) -#endif /* BSD_SYSTEM */ - -#ifdef BSD4_2 #define HAVE_FTIME -#endif /* arch-tag: 508bdf7a-01a0-4ce0-8eba-0704d0df55a0 (do not change this comment) */ diff --git a/src/m/xtensa.h b/src/m/xtensa.h index d53686d9401..8e1da54b25b 100644 --- a/src/m/xtensa.h +++ b/src/m/xtensa.h @@ -2,13 +2,5 @@ Add a license notice if this grows to > 10 lines of code. */ -#define NO_ARG_ARRAY - -#ifdef __LITTLE_ENDIAN -#undef WORDS_BIG_ENDIAN -#else -#define WORDS_BIG_ENDIAN -#endif - /* arch-tag: fe5872de-d565-4d81-8fe0-ea19865b3e6a (do not change this comment) */ diff --git a/src/macros.c b/src/macros.c index 62aeb0fa635..c281c89aa3e 100644 --- a/src/macros.c +++ b/src/macros.c @@ -51,9 +51,7 @@ int executing_kbd_macro_iterations; Lisp_Object executing_kbd_macro; -extern Lisp_Object real_this_command; - -Lisp_Object Fexecute_kbd_macro (); +Lisp_Object Fexecute_kbd_macro (Lisp_Object macro, Lisp_Object count, Lisp_Object loopfunc); DEFUN ("start-kbd-macro", Fstart_kbd_macro, Sstart_kbd_macro, 1, 2, "P", doc: /* Record subsequent keyboard input, defining a keyboard macro. @@ -64,8 +62,7 @@ Non-nil arg (prefix arg) means append to last macro defined; this begins by re-executing that macro as if you typed it again. If optional second arg, NO-EXEC, is non-nil, do not re-execute last macro before appending to it. */) - (append, no_exec) - Lisp_Object append, no_exec; + (Lisp_Object append, Lisp_Object no_exec) { if (!NILP (current_kboard->defining_kbd_macro)) error ("Already defining kbd macro"); @@ -140,7 +137,7 @@ macro before appending to it. */) /* Finish defining the current keyboard macro. */ void -end_kbd_macro () +end_kbd_macro (void) { current_kboard->defining_kbd_macro = Qnil; update_mode_lines++; @@ -163,8 +160,7 @@ An argument of zero means repeat until error. In Lisp, optional second arg LOOPFUNC may be a function that is called prior to each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) - (repeat, loopfunc) - Lisp_Object repeat, loopfunc; + (Lisp_Object repeat, Lisp_Object loopfunc) { if (NILP (current_kboard->defining_kbd_macro)) error ("Not defining kbd macro"); @@ -194,8 +190,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) /* Store character c into kbd macro being defined */ void -store_kbd_macro_char (c) - Lisp_Object c; +store_kbd_macro_char (Lisp_Object c) { struct kboard *kb = current_kboard; @@ -223,7 +218,7 @@ store_kbd_macro_char (c) really belong to it. This is done in between editor commands. */ void -finalize_kbd_macro_chars () +finalize_kbd_macro_chars (void) { current_kboard->kbd_macro_end = current_kboard->kbd_macro_ptr; } @@ -231,7 +226,7 @@ finalize_kbd_macro_chars () DEFUN ("cancel-kbd-macro-events", Fcancel_kbd_macro_events, Scancel_kbd_macro_events, 0, 0, 0, doc: /* Cancel the events added to a keyboard macro for this command. */) - () + (void) { current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_end; return Qnil; @@ -240,8 +235,7 @@ DEFUN ("cancel-kbd-macro-events", Fcancel_kbd_macro_events, DEFUN ("store-kbd-macro-event", Fstore_kbd_macro_event, Sstore_kbd_macro_event, 1, 1, 0, doc: /* Store EVENT into the keyboard macro being defined. */) - (event) - Lisp_Object event; + (Lisp_Object event) { store_kbd_macro_char (event); return Qnil; @@ -258,8 +252,7 @@ defining others, use \\[name-last-kbd-macro]. In Lisp, optional second arg LOOPFUNC may be a function that is called prior to each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) - (prefix, loopfunc) - Lisp_Object prefix, loopfunc; + (Lisp_Object prefix, Lisp_Object loopfunc) { /* Don't interfere with recognition of the previous command from before this macro started. */ @@ -286,8 +279,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) Called when the unwind-protect in Fexecute_kbd_macro gets invoked. */ static Lisp_Object -pop_kbd_macro (info) - Lisp_Object info; +pop_kbd_macro (Lisp_Object info) { Lisp_Object tem; Vexecuting_kbd_macro = XCAR (info); @@ -305,8 +297,7 @@ COUNT is a repeat count, or nil for once, or 0 for infinite loop. Optional third arg LOOPFUNC may be a function that is called prior to each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) - (macro, count, loopfunc) - Lisp_Object macro, count, loopfunc; + (Lisp_Object macro, Lisp_Object count, Lisp_Object loopfunc) { Lisp_Object final; Lisp_Object tem; @@ -367,14 +358,14 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) } void -init_macros () +init_macros (void) { Vexecuting_kbd_macro = Qnil; executing_kbd_macro = Qnil; } void -syms_of_macros () +syms_of_macros (void) { Qexecute_kbd_macro = intern_c_string ("execute-kbd-macro"); staticpro (&Qexecute_kbd_macro); diff --git a/src/macros.h b/src/macros.h index 00b7b5ba421..761b5fdf514 100644 --- a/src/macros.h +++ b/src/macros.h @@ -41,16 +41,16 @@ extern Lisp_Object executing_kbd_macro; /* Finish defining the current keyboard macro. */ -extern void end_kbd_macro P_ ((void)); +extern void end_kbd_macro (void); /* Declare that all chars stored so far in the kbd macro being defined really belong to it. This is done in between editor commands. */ -extern void finalize_kbd_macro_chars P_ ((void)); +extern void finalize_kbd_macro_chars (void); /* Store a character into kbd macro being defined */ -extern void store_kbd_macro_char P_ ((Lisp_Object)); +extern void store_kbd_macro_char (Lisp_Object); /* arch-tag: 8edb7088-682f-4d1f-a4d9-0fbb7284234e (do not change this comment) */ diff --git a/src/makefile.w32-in b/src/makefile.w32-in index 591e38fb60d..21bdeb8443f 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in @@ -37,7 +37,7 @@ TEMACS = $(BLD)/temacs.exe TEMACS_TMP = $(BLD)/temacs.bin TLIB0 = $(BLD)/temacs0.$(A) TLIB1 = $(BLD)/temacs1.$(A) -TLIBW32 = $(BLD)/temacw32.$(A) +TLIB2 = $(BLD)/temacs2.$(A) TOBJ = $(BLD)/firstfile.$(O) TRES = $(BLD)/emacs.res TLASTLIB = $(BLD)/lastfile.$(A) @@ -62,7 +62,6 @@ OBJ1 = $(BLD)/alloc.$(O) \ $(BLD)/callint.$(O) \ $(BLD)/callproc.$(O) \ $(BLD)/casefiddle.$(O) \ - $(BLD)/cm.$(O) \ $(BLD)/cmds.$(O) \ $(BLD)/data.$(O) \ $(BLD)/dired.$(O) \ @@ -95,10 +94,10 @@ OBJ1 = $(BLD)/alloc.$(O) \ $(BLD)/scroll.$(O) \ $(BLD)/search.$(O) \ $(BLD)/sound.$(O) \ - $(BLD)/syntax.$(O) \ - $(BLD)/sysdep.$(O) \ + $(BLD)/syntax.$(O) + +OBJ2 = $(BLD)/sysdep.$(O) \ $(BLD)/term.$(O) \ - $(BLD)/termcap.$(O) \ $(BLD)/tparam.$(O) \ $(BLD)/undo.$(O) \ $(BLD)/unexw32.$(O) \ @@ -115,6 +114,7 @@ OBJ1 = $(BLD)/alloc.$(O) \ $(BLD)/vm-limit.$(O) \ $(BLD)/region-cache.$(O) \ $(BLD)/strftime.$(O) \ + $(BLD)/bidi.$(O) \ $(BLD)/charset.$(O) \ $(BLD)/character.$(O) \ $(BLD)/chartab.$(O) \ @@ -126,28 +126,27 @@ OBJ1 = $(BLD)/alloc.$(O) \ $(BLD)/fringe.$(O) \ $(BLD)/image.$(O) \ $(BLD)/terminal.$(O) \ - $(BLD)/menu.$(O) - -WIN32OBJ = $(BLD)/w32term.$(O) \ - $(BLD)/w32xfns.$(O) \ - $(BLD)/w32fns.$(O) \ - $(BLD)/xfaces.$(O) \ - $(BLD)/w32select.$(O) \ - $(BLD)/w32menu.$(O) \ - $(BLD)/w32reg.$(O) - -FONTOBJ = $(BLD)/w32font.$(O) $(BLD)/w32uniscribe.$(O) + $(BLD)/menu.$(O) \ + $(BLD)/w32term.$(O) \ + $(BLD)/w32xfns.$(O) \ + $(BLD)/w32fns.$(O) \ + $(BLD)/xfaces.$(O) \ + $(BLD)/w32select.$(O) \ + $(BLD)/w32menu.$(O) \ + $(BLD)/w32reg.$(O) \ + $(BLD)/w32font.$(O) \ + $(BLD)/w32uniscribe.$(O) LIBS = $(TLIB0) \ $(TLIB1) \ - $(TLIBW32) \ + $(TLIB2) \ $(TLASTLIB) \ $(WINMM) \ $(ADVAPI32) \ $(GDI32) \ $(COMDLG32) \ $(USER32) \ - $(MPR) \ + $(MPR) \ $(SHELL32) \ $(WINSPOOL) \ $(OLE32) \ @@ -175,7 +174,7 @@ $(EMACS): $(DOC) $(TEMACS) # (it is the preload heap size in MB). # temacs: stamp_BLD $(TEMACS) -$(TEMACS): $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES) \ +$(TEMACS): $(TLIB0) $(TLIB1) $(TLIB2) $(TLASTLIB) $(TOBJ) $(TRES) \ ../nt/$(BLD)/addsection.exe $(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS) "../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 21 @@ -191,16 +190,14 @@ make-buildobj-CMD: echo #define BUILDOBJ ^"\> buildobj.h echo $(OBJ0) \>> buildobj.h echo $(OBJ1) \>> buildobj.h - echo $(WIN32OBJ) \>> buildobj.h - echo $(FONTOBJ) \>> buildobj.h + echo $(OBJ2) \>> buildobj.h echo ^">> buildobj.h make-buildobj-SH: echo '#define BUILDOBJ $(DQUOTE)\' > buildobj.h echo $(OBJ0) '\' >> buildobj.h echo $(OBJ1) '\' >> buildobj.h - echo $(WIN32OBJ) '\' >> buildobj.h - echo $(FONTOBJ) '\' >> buildobj.h + echo $(OBJ2) '\' >> buildobj.h echo '$(DQUOTE)' >> buildobj.h bootstrap: bootstrap-emacs @@ -250,7 +247,7 @@ $(TLIB0): $(OBJ0) $(TLIB1): $(OBJ1) - $(DEL) $@ $(AR) $(AR_OUT)$@ $(ALL_DEPS) -$(TLIBW32): $(WIN32OBJ) $(FONTOBJ) +$(TLIB2): $(OBJ2) - $(DEL) $@ $(AR) $(AR_OUT)$@ $(ALL_DEPS) @@ -294,6 +291,52 @@ cleanall: clean - $(DEL_TREE) oo - $(DEL_TREE) oo-spd +## Arrange to make a tags table TAGS-LISP for ../lisp, +## plus TAGS for the C files, which includes ../lisp/TAGS by reference. +## +## This works only with GNU Make. + +TAGS: $(OBJ0) $(OBJ1) $(OBJ2) + $(MAKE) $(MFLAGS) TAGS-$(MAKETYPE) + +TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2) + $(MAKE) $(MFLAGS) TAGS-LISP-$(MAKETYPE) + +TAGS-gmake: + ../lib-src/$(BLD)/etags.exe --include=TAGS-LISP --include=../nt/TAGS \ + --regex=@../nt/emacs-src.tags \ + $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ0)) + ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ + $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1)) + ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ + $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2)) \ + $(CURDIR)/*.h + +TAGS-nmake: + echo This target is not supported with NMake + exit -1 + +frc: +TAGS-LISP-gmake: frc + $(MAKE) $(MFLAGS) -C ../lisp TAGS-LISP DEST=../src + +TAGS-LISP-nmake: + echo This target is not supported with NMake + exit -1 + +../nt/TAGS: frc + $(MAKE) $(MFLAGS) nt-TAGS-$(MAKETYPE) + +nt-TAGS-gmake: + $(MAKE) $(MFLAGS) -C ../nt TAGS + +nt-TAGS-nmake: + echo This target is not supported with NMake + exit -1 + +full-tags: TAGS TAGS-LISP ../nt/TAGS +.PHONY: full-tags + ### DEPENDENCIES ### EMACS_ROOT = .. @@ -338,6 +381,17 @@ $(BLD)/atimer.$(O) : \ $(SRC)/syssignal.h \ $(SRC)/systime.h +$(BLD)/bidi.$(O) : \ + $(SRC)/bidi.c \ + $(CONFIG_H) \ + $(SRC)/lisp.h \ + $(SRC)/bidimirror.h \ + $(SRC)/biditype.h \ + $(SRC)/buffer.h \ + $(SRC)/character.h \ + $(SRC)/dispextern.h \ + $(SRC)/w32gui.h + $(BLD)/buffer.$(O) : \ $(SRC)/buffer.c \ $(CONFIG_H) \ @@ -484,17 +538,6 @@ $(BLD)/chartab.$(O) : \ $(SRC)/character.h \ $(SRC)/charset.h -$(BLD)/cm.$(O) : \ - $(SRC)/cm.c \ - $(CONFIG_H) \ - $(SRC)/lisp.h \ - $(SRC)/cm.h \ - $(SRC)/dispextern.h \ - $(SRC)/frame.h \ - $(SRC)/termchar.h \ - $(SRC)/termhooks.h \ - $(SRC)/w32gui.h - $(BLD)/cmds.$(O) : \ $(SRC)/cmds.c \ $(CONFIG_H) \ @@ -700,6 +743,7 @@ $(BLD)/eval.$(O) : \ $(SRC)/commands.h \ $(SRC)/composite.h \ $(SRC)/dispextern.h \ + $(SRC)/frame.h \ $(SRC)/keyboard.h \ $(SRC)/systime.h \ $(SRC)/w32gui.h @@ -965,6 +1009,7 @@ $(BLD)/keyboard.$(O) : \ $(SRC)/keyboard.h \ $(SRC)/keymap.h \ $(SRC)/macros.h \ + $(SRC)/process.h \ $(SRC)/puresize.h \ $(SRC)/syntax.h \ $(SRC)/syssignal.h \ @@ -1343,7 +1388,6 @@ $(BLD)/sysdep.$(O) : \ $(EMACS_ROOT)/nt/inc/pwd.h \ $(EMACS_ROOT)/nt/inc/unistd.h \ $(EMACS_ROOT)/nt/inc/sys/file.h \ - $(EMACS_ROOT)/nt/inc/sys/ioctl.h \ $(EMACS_ROOT)/nt/inc/sys/socket.h \ $(EMACS_ROOT)/nt/inc/sys/time.h \ $(SRC)/lisp.h \ @@ -1356,6 +1400,7 @@ $(BLD)/sysdep.$(O) : \ $(SRC)/frame.h \ $(SRC)/keyboard.h \ $(SRC)/process.h \ + $(SRC)/sysselect.h \ $(SRC)/syssignal.h \ $(SRC)/systime.h \ $(SRC)/systty.h \ @@ -1397,13 +1442,6 @@ $(BLD)/term.$(O) : \ $(SRC)/w32gui.h \ $(SRC)/window.h -$(BLD)/termcap.$(O) : \ - $(SRC)/termcap.c \ - $(CONFIG_H) \ - $(EMACS_ROOT)/nt/inc/unistd.h \ - $(EMACS_ROOT)/nt/inc/sys/file.h \ - $(SRC)/lisp.h - $(BLD)/terminal.$(O) : \ $(SRC)/terminal.c \ $(CONFIG_H) \ @@ -1512,6 +1550,7 @@ $(BLD)/xdisp.$(O) : \ $(SRC)/systime.h \ $(SRC)/termchar.h \ $(SRC)/termhooks.h \ + $(SRC)/termopts.h \ $(SRC)/w32gui.h \ $(SRC)/w32term.h \ $(SRC)/window.h @@ -1710,4 +1749,4 @@ $(BLD)/w32uniscribe.$(O) : \ # Each object file depends on stamp_BLD, because in parallel builds we must # make sure $(BLD) exists before starting compilations. # -$(OBJ0) $(OBJ1) $(WIN32OBJ) $(FONTOBJ) $(BLD)/lastfile.$(O) $(BLD)/firstfile.$(O): stamp_BLD +$(OBJ0) $(OBJ1) $(OBJ2) $(BLD)/lastfile.$(O) $(BLD)/firstfile.$(O): stamp_BLD diff --git a/src/marker.c b/src/marker.c index b3381f9c369..3f8b78e81a8 100644 --- a/src/marker.c +++ b/src/marker.c @@ -27,20 +27,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Record one cached position found recently by buf_charpos_to_bytepos or buf_bytepos_to_charpos. */ -static int cached_charpos; -static int cached_bytepos; +static EMACS_INT cached_charpos; +static EMACS_INT cached_bytepos; static struct buffer *cached_buffer; static int cached_modiff; -static void byte_char_debug_check P_ ((struct buffer *, int, int)); +static void byte_char_debug_check (struct buffer *, EMACS_INT, EMACS_INT); /* Nonzero means enable debugging checks on byte/char correspondences. */ static int byte_debug_flag; void -clear_charpos_cache (b) - struct buffer *b; +clear_charpos_cache (struct buffer *b) { if (cached_buffer == b) cached_buffer = 0; @@ -61,12 +60,12 @@ clear_charpos_cache (b) #define CONSIDER(CHARPOS, BYTEPOS) \ { \ - int this_charpos = (CHARPOS); \ + EMACS_INT this_charpos = (CHARPOS); \ int changed = 0; \ \ if (this_charpos == charpos) \ { \ - int value = (BYTEPOS); \ + EMACS_INT value = (BYTEPOS); \ if (byte_debug_flag) \ byte_char_debug_check (b, charpos, value); \ return value; \ @@ -91,7 +90,7 @@ clear_charpos_cache (b) { \ if (best_above - best_below == best_above_byte - best_below_byte) \ { \ - int value = best_below_byte + (charpos - best_below); \ + EMACS_INT value = best_below_byte + (charpos - best_below); \ if (byte_debug_flag) \ byte_char_debug_check (b, charpos, value); \ return value; \ @@ -100,11 +99,9 @@ clear_charpos_cache (b) } static void -byte_char_debug_check (b, charpos, bytepos) - struct buffer *b; - int charpos, bytepos; +byte_char_debug_check (struct buffer *b, EMACS_INT charpos, EMACS_INT bytepos) { - int nchars = 0; + EMACS_INT nchars = 0; if (bytepos > BUF_GPT_BYTE (b)) { @@ -121,21 +118,18 @@ byte_char_debug_check (b, charpos, bytepos) abort (); } -int -charpos_to_bytepos (charpos) - int charpos; +EMACS_INT +charpos_to_bytepos (EMACS_INT charpos) { return buf_charpos_to_bytepos (current_buffer, charpos); } -int -buf_charpos_to_bytepos (b, charpos) - struct buffer *b; - int charpos; +EMACS_INT +buf_charpos_to_bytepos (struct buffer *b, EMACS_INT charpos) { struct Lisp_Marker *tail; - int best_above, best_above_byte; - int best_below, best_below_byte; + EMACS_INT best_above, best_above_byte; + EMACS_INT best_below, best_below_byte; if (charpos < BUF_BEG (b) || charpos > BUF_Z (b)) abort (); @@ -253,12 +247,11 @@ buf_charpos_to_bytepos (b, charpos) /* Used for debugging: recompute the bytepos corresponding to CHARPOS in the simplest, most reliable way. */ -int -verify_bytepos (charpos) - int charpos; +EMACS_INT +verify_bytepos (EMACS_INT charpos) { - int below = 1; - int below_byte = 1; + EMACS_INT below = 1; + EMACS_INT below_byte = 1; while (below != charpos) { @@ -276,12 +269,12 @@ verify_bytepos (charpos) #define CONSIDER(BYTEPOS, CHARPOS) \ { \ - int this_bytepos = (BYTEPOS); \ + EMACS_INT this_bytepos = (BYTEPOS); \ int changed = 0; \ \ if (this_bytepos == bytepos) \ { \ - int value = (CHARPOS); \ + EMACS_INT value = (CHARPOS); \ if (byte_debug_flag) \ byte_char_debug_check (b, value, bytepos); \ return value; \ @@ -306,7 +299,7 @@ verify_bytepos (charpos) { \ if (best_above - best_below == best_above_byte - best_below_byte) \ { \ - int value = best_below + (bytepos - best_below_byte); \ + EMACS_INT value = best_below + (bytepos - best_below_byte); \ if (byte_debug_flag) \ byte_char_debug_check (b, value, bytepos); \ return value; \ @@ -314,21 +307,18 @@ verify_bytepos (charpos) } \ } -int -bytepos_to_charpos (bytepos) - int bytepos; +EMACS_INT +bytepos_to_charpos (EMACS_INT bytepos) { return buf_bytepos_to_charpos (current_buffer, bytepos); } -int -buf_bytepos_to_charpos (b, bytepos) - struct buffer *b; - int bytepos; +EMACS_INT +buf_bytepos_to_charpos (struct buffer *b, EMACS_INT bytepos) { struct Lisp_Marker *tail; - int best_above, best_above_byte; - int best_below, best_below_byte; + EMACS_INT best_above, best_above_byte; + EMACS_INT best_below, best_below_byte; if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b)) abort (); @@ -443,8 +433,7 @@ buf_bytepos_to_charpos (b, bytepos) DEFUN ("marker-buffer", Fmarker_buffer, Smarker_buffer, 1, 1, 0, doc: /* Return the buffer that MARKER points into, or nil if none. Returns nil if MARKER points into a dead buffer. */) - (marker) - register Lisp_Object marker; + (register Lisp_Object marker) { register Lisp_Object buf; CHECK_MARKER (marker); @@ -464,8 +453,7 @@ Returns nil if MARKER points into a dead buffer. */) DEFUN ("marker-position", Fmarker_position, Smarker_position, 1, 1, 0, doc: /* Return the position MARKER points at, as a character number. Returns nil if MARKER points nowhere. */) - (marker) - Lisp_Object marker; + (Lisp_Object marker) { CHECK_MARKER (marker); if (XMARKER (marker)->buffer) @@ -480,10 +468,9 @@ BUFFER defaults to the current buffer. If POSITION is nil, makes marker point nowhere. Then it no longer slows down editing in any buffer. Returns MARKER. */) - (marker, position, buffer) - Lisp_Object marker, position, buffer; + (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) { - register int charno, bytepos; + register EMACS_INT charno, bytepos; register struct buffer *b; register struct Lisp_Marker *m; @@ -556,10 +543,9 @@ Returns MARKER. */) be outside the visible part. */ Lisp_Object -set_marker_restricted (marker, pos, buffer) - Lisp_Object marker, pos, buffer; +set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer) { - register int charno, bytepos; + register EMACS_INT charno, bytepos; register struct buffer *b; register struct Lisp_Marker *m; @@ -632,9 +618,7 @@ set_marker_restricted (marker, pos, buffer) character position and the corresponding byte position. */ Lisp_Object -set_marker_both (marker, buffer, charpos, bytepos) - Lisp_Object marker, buffer; - int charpos, bytepos; +set_marker_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos) { register struct buffer *b; register struct Lisp_Marker *m; @@ -682,9 +666,7 @@ set_marker_both (marker, buffer, charpos, bytepos) be outside the visible part. */ Lisp_Object -set_marker_restricted_both (marker, buffer, charpos, bytepos) - Lisp_Object marker, buffer; - int charpos, bytepos; +set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos) { register struct buffer *b; register struct Lisp_Marker *m; @@ -745,8 +727,7 @@ set_marker_restricted_both (marker, buffer, charpos, bytepos) including those in chain fields of markers. */ void -unchain_marker (marker) - register struct Lisp_Marker *marker; +unchain_marker (register struct Lisp_Marker *marker) { register struct Lisp_Marker *tail, *prev, *next; register struct buffer *b; @@ -795,9 +776,8 @@ unchain_marker (marker) /* Return the char position of marker MARKER, as a C integer. */ -int -marker_position (marker) - Lisp_Object marker; +EMACS_INT +marker_position (Lisp_Object marker) { register struct Lisp_Marker *m = XMARKER (marker); register struct buffer *buf = m->buffer; @@ -810,13 +790,12 @@ marker_position (marker) /* Return the byte position of marker MARKER, as a C integer. */ -int -marker_byte_position (marker) - Lisp_Object marker; +EMACS_INT +marker_byte_position (Lisp_Object marker) { register struct Lisp_Marker *m = XMARKER (marker); register struct buffer *buf = m->buffer; - register int i = m->bytepos; + register EMACS_INT i = m->bytepos; if (!buf) error ("Marker does not point anywhere"); @@ -827,17 +806,18 @@ marker_byte_position (marker) return i; } -DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 1, 2, 0, +DEFUN ("copy-marker", Fcopy_marker, Scopy_marker, 0, 2, 0, doc: /* Return a new marker pointing at the same place as MARKER. If argument is a number, makes a new marker pointing at that position in the current buffer. +If MARKER is not specified, the new marker does not point anywhere. The optional argument TYPE specifies the insertion type of the new marker; see `marker-insertion-type'. */) - (marker, type) - register Lisp_Object marker, type; + (register Lisp_Object marker, Lisp_Object type) { register Lisp_Object new; + if (!NILP (marker)) CHECK_TYPE (INTEGERP (marker) || MARKERP (marker), Qinteger_or_marker_p, marker); new = Fmake_marker (); @@ -851,8 +831,7 @@ DEFUN ("marker-insertion-type", Fmarker_insertion_type, Smarker_insertion_type, 1, 1, 0, doc: /* Return insertion type of MARKER: t if it stays after inserted text. The value nil means the marker stays before text inserted there. */) - (marker) - register Lisp_Object marker; + (register Lisp_Object marker) { CHECK_MARKER (marker); return XMARKER (marker)->insertion_type ? Qt : Qnil; @@ -863,8 +842,7 @@ DEFUN ("set-marker-insertion-type", Fset_marker_insertion_type, doc: /* Set the insertion-type of MARKER to TYPE. If TYPE is t, it means the marker advances when you insert text at it. If TYPE is nil, it means the marker stays behind when you insert text at it. */) - (marker, type) - Lisp_Object marker, type; + (Lisp_Object marker, Lisp_Object type) { CHECK_MARKER (marker); @@ -875,11 +853,10 @@ If TYPE is nil, it means the marker stays behind when you insert text at it. */ DEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, Sbuffer_has_markers_at, 1, 1, 0, doc: /* Return t if there are markers pointing at POSITION in the current buffer. */) - (position) - Lisp_Object position; + (Lisp_Object position) { register struct Lisp_Marker *tail; - register int charno; + register EMACS_INT charno; charno = XINT (position); @@ -898,8 +875,7 @@ DEFUN ("buffer-has-markers-at", Fbuffer_has_markers_at, Sbuffer_has_markers_at, /* For debugging -- count the markers in buffer BUF. */ int -count_markers (buf) - struct buffer *buf; +count_markers (struct buffer *buf) { int total = 0; struct Lisp_Marker *tail; @@ -911,7 +887,7 @@ count_markers (buf) } void -syms_of_marker () +syms_of_marker (void) { defsubr (&Smarker_position); defsubr (&Smarker_buffer); diff --git a/src/md5.c b/src/md5.c index 37ae2e6acb5..6e7f651189e 100644 --- a/src/md5.c +++ b/src/md5.c @@ -1,7 +1,7 @@ /* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation, Inc. + 2005, 2006, 2007, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -40,7 +40,7 @@ #ifdef _LIBC # include <endian.h> # if __BYTE_ORDER == __BIG_ENDIAN -# define WORDS_BIG_ENDIAN 1 +# define WORDS_BIGENDIAN 1 # endif /* We need to keep the namespace clean so define the MD5 function protected using leading __ . */ @@ -55,7 +55,7 @@ #include "md5.h" -#ifdef WORDS_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN # define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else @@ -71,8 +71,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void -md5_init_ctx (ctx) - struct md5_ctx *ctx; +md5_init_ctx (struct md5_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; @@ -89,9 +88,7 @@ md5_init_ctx (ctx) IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * -md5_read_ctx (ctx, resbuf) - const struct md5_ctx *ctx; - void *resbuf; +md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); @@ -107,9 +104,7 @@ md5_read_ctx (ctx, resbuf) IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * -md5_finish_ctx (ctx, resbuf) - struct md5_ctx *ctx; - void *resbuf; +md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; @@ -138,9 +133,7 @@ md5_finish_ctx (ctx, resbuf) resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int -md5_stream (stream, resblock) - FILE *stream; - void *resblock; +md5_stream (FILE *stream, void *resblock) { /* Important: BLOCKSIZE must be a multiple of 64. */ #define BLOCKSIZE 4096 @@ -195,10 +188,7 @@ md5_stream (stream, resblock) output yields to the wanted ASCII representation of the message digest. */ void * -md5_buffer (buffer, len, resblock) - const char *buffer; - size_t len; - void *resblock; +md5_buffer (const char *buffer, size_t len, void *resblock) { struct md5_ctx ctx; @@ -214,10 +204,7 @@ md5_buffer (buffer, len, resblock) void -md5_process_bytes (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; +md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) { /* const void aligned_buffer = buffer; */ @@ -287,10 +274,7 @@ md5_process_bytes (buffer, len, ctx) It is assumed that LEN % 64 == 0. */ void -md5_process_block (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; +md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; diff --git a/src/md5.h b/src/md5.h index a23dbd089ba..cf9566b864b 100644 --- a/src/md5.h +++ b/src/md5.h @@ -97,21 +97,21 @@ struct md5_ctx /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ -extern void md5_init_ctx __P ((struct md5_ctx *ctx)); +extern void md5_init_ctx (struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ -extern void md5_process_block __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_block (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ -extern void md5_process_bytes __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_bytes (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -120,7 +120,7 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len, IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); +extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is @@ -129,20 +129,20 @@ extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); +extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ -extern int md5_stream __P ((FILE *stream, void *resblock)); +extern int md5_stream (FILE *stream, void *resblock); /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *md5_buffer __P ((const char *buffer, size_t len, - void *resblock)); +extern void *md5_buffer (const char *buffer, size_t len, + void *resblock); #endif /* md5.h */ diff --git a/src/mem-limits.h b/src/mem-limits.h index d811968b13f..9ec1558527d 100644 --- a/src/mem-limits.h +++ b/src/mem-limits.h @@ -25,17 +25,6 @@ extern int etext; /* Some systems need this before <sys/resource.h>. */ #include <sys/types.h> -#ifdef _LIBC - -#include <sys/resource.h> -#define BSD4_2 /* Tell code below to use getrlimit. */ - -/* Old Linux startup code won't define __data_start. */ -extern int etext, __data_start; weak_extern (__data_start) -#define start_of_data() (&__data_start ?: &etext) - -#else /* not _LIBC */ - #ifdef HAVE_SYS_RESOURCE_H # include <sys/time.h> # include <sys/resource.h> @@ -45,37 +34,9 @@ extern int etext, __data_start; weak_extern (__data_start) # endif #endif -#ifdef CYGWIN -#define BSD4_2 -#endif - -#ifndef BSD4_2 -#ifndef USG -#ifndef MSDOS -#ifndef WINDOWSNT -#include <sys/vlimit.h> -#endif /* not WINDOWSNT */ -#endif /* not MSDOS */ -#endif /* not USG */ -#else /* if BSD4_2 */ -#include <sys/time.h> -#include <sys/resource.h> -#endif /* BSD4_2 */ - -#ifdef emacs -/* The important properties of this type are that 1) it's a pointer, and - 2) arithmetic on it should work as if the size of the object pointed - to has a size of 1. */ -typedef POINTER_TYPE *POINTER; - typedef unsigned long SIZE; -#ifdef NULL -#undef NULL -#endif -#define NULL ((POINTER) 0) - -extern POINTER start_of_data (); +extern char *start_of_data (void); #if defined USE_LSB_TAG #define EXCEEDS_LISP_PTR(ptr) 0 #elif defined DATA_SEG_BITS @@ -85,26 +46,5 @@ extern POINTER start_of_data (); #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS) #endif -#ifdef DATA_START -#define start_of_data() ((char *)DATA_START) -#endif - -#ifdef BSD_SYSTEM -#ifndef DATA_SEG_BITS -#ifndef DATA_START -extern char etext; -#define start_of_data() &etext -#endif -#endif -#endif - -#else /* not emacs */ -extern char etext; -#define start_of_data() &etext -#endif /* not emacs */ - -#endif /* not _LIBC */ - - /* arch-tag: fe39244e-e54f-4208-b7aa-02556f7841c5 (do not change this comment) */ diff --git a/src/menu.c b/src/menu.c index bfe54a53328..05a296e45fc 100644 --- a/src/menu.c +++ b/src/menu.c @@ -61,12 +61,6 @@ extern HMENU current_popup_menu; #define HAVE_BOXES 1 #endif -/* The timestamp of the last input event Emacs received from the X server. */ -/* Defined in keyboard.c. */ -extern unsigned long last_event_timestamp; - -extern Lisp_Object QCtoggle, QCradio; - Lisp_Object menu_items; /* If non-nil, means that the global vars defined here are already in use. @@ -87,7 +81,7 @@ int menu_items_n_panes; static int menu_items_submenu_depth; void -init_menu_items () +init_menu_items (void) { if (!NILP (menu_items_inuse)) error ("Trying to use a menu from within a menu-entry"); @@ -107,13 +101,12 @@ init_menu_items () /* Call at the end of generating the data in menu_items. */ void -finish_menu_items () +finish_menu_items (void) { } Lisp_Object -unuse_menu_items (dummy) - Lisp_Object dummy; +unuse_menu_items (Lisp_Object dummy) { return menu_items_inuse = Qnil; } @@ -122,7 +115,7 @@ unuse_menu_items (dummy) in menu_items. */ void -discard_menu_items () +discard_menu_items (void) { /* Free the structure if it is especially large. Otherwise, hold on to it, to save time. */ @@ -134,19 +127,20 @@ discard_menu_items () xassert (NILP (menu_items_inuse)); } +#ifdef HAVE_NS static Lisp_Object cleanup_popup_menu (Lisp_Object arg) { discard_menu_items (); return Qnil; } +#endif /* This undoes save_menu_items, and it is called by the specpdl unwind mechanism. */ static Lisp_Object -restore_menu_items (saved) - Lisp_Object saved; +restore_menu_items (Lisp_Object saved) { menu_items = XCAR (saved); menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil); @@ -164,7 +158,7 @@ restore_menu_items (saved) It will be restored when the specpdl is unwound. */ void -save_menu_items () +save_menu_items (void) { Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil, make_number (menu_items_used), @@ -179,7 +173,7 @@ save_menu_items () /* Make the menu_items vector twice as large. */ static void -grow_menu_items () +grow_menu_items (void) { menu_items_allocated *= 2; menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); @@ -188,7 +182,7 @@ grow_menu_items () /* Begin a submenu. */ static void -push_submenu_start () +push_submenu_start (void) { if (menu_items_used + 1 > menu_items_allocated) grow_menu_items (); @@ -200,7 +194,7 @@ push_submenu_start () /* End a submenu. */ static void -push_submenu_end () +push_submenu_end (void) { if (menu_items_used + 1 > menu_items_allocated) grow_menu_items (); @@ -212,7 +206,7 @@ push_submenu_end () /* Indicate boundary between left and right. */ static void -push_left_right_boundary () +push_left_right_boundary (void) { if (menu_items_used + 1 > menu_items_allocated) grow_menu_items (); @@ -224,8 +218,7 @@ push_left_right_boundary () NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ static void -push_menu_pane (name, prefix_vec) - Lisp_Object name, prefix_vec; +push_menu_pane (Lisp_Object name, Lisp_Object prefix_vec) { if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) grow_menu_items (); @@ -246,8 +239,7 @@ push_menu_pane (name, prefix_vec) item, one of nil, `toggle' or `radio'. */ static void -push_menu_item (name, enable, key, def, equiv, type, selected, help) - Lisp_Object name, enable, key, def, equiv, type, selected, help; +push_menu_item (Lisp_Object name, Lisp_Object enable, Lisp_Object key, Lisp_Object def, Lisp_Object equiv, Lisp_Object type, Lisp_Object selected, Lisp_Object help) { if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) grow_menu_items (); @@ -272,8 +264,8 @@ struct skp int notbuttons; }; -static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - void *)); +static void single_menu_item (Lisp_Object, Lisp_Object, Lisp_Object, + void *); /* This is a recursive subroutine of keymap_panes. It handles one keymap, KEYMAP. @@ -332,9 +324,7 @@ single_keymap_panes (Lisp_Object keymap, Lisp_Object pane_name, If we encounter submenus deeper than SKP->MAXDEPTH levels, ignore them. */ static void -single_menu_item (key, item, dummy, skp_v) - Lisp_Object key, item, dummy; - void *skp_v; +single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *skp_v) { Lisp_Object map, item_string, enabled; struct gcpro gcpro1, gcpro2; @@ -456,9 +446,7 @@ single_menu_item (key, item, dummy, skp_v) and generate menu panes for them in menu_items. */ static void -keymap_panes (keymaps, nmaps) - Lisp_Object *keymaps; - int nmaps; +keymap_panes (Lisp_Object *keymaps, int nmaps) { int mapno; @@ -477,8 +465,7 @@ keymap_panes (keymaps, nmaps) /* Push the items in a single pane defined by the alist PANE. */ static void -list_of_items (pane) - Lisp_Object pane; +list_of_items (Lisp_Object pane) { Lisp_Object tail, item, item1; @@ -505,8 +492,7 @@ list_of_items (pane) alist-of-alists MENU. This handles old-fashioned calls to x-popup-menu. */ void -list_of_panes (menu) - Lisp_Object menu; +list_of_panes (Lisp_Object menu) { Lisp_Object tail; @@ -531,8 +517,7 @@ list_of_panes (menu) whose event type is ITEM_KEY (with string ITEM_NAME) and whose contents come from the list of keymaps MAPS. */ int -parse_single_submenu (item_key, item_name, maps) - Lisp_Object item_key, item_name, maps; +parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object maps) { Lisp_Object length; int len; @@ -583,7 +568,7 @@ parse_single_submenu (item_key, item_name, maps) /* Allocate a widget_value, blocking input. */ widget_value * -xmalloc_widget_value () +xmalloc_widget_value (void) { widget_value *value; @@ -600,8 +585,7 @@ xmalloc_widget_value () must be left alone. */ void -free_menubar_widget_value_tree (wv) - widget_value *wv; +free_menubar_widget_value_tree (widget_value *wv) { if (! wv) return; @@ -627,8 +611,7 @@ free_menubar_widget_value_tree (wv) in menu_items starting at index START, up to index END. */ widget_value * -digest_single_submenu (start, end, top_level_items) - int start, end, top_level_items; +digest_single_submenu (int start, int end, int top_level_items) { widget_value *wv, *prev_wv, *save_wv, *first_wv; int i; @@ -679,7 +662,7 @@ digest_single_submenu (start, end, top_level_items) { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; panes_seen++; @@ -697,6 +680,12 @@ digest_single_submenu (start, end, top_level_items) ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); } +#elif defined (USE_LUCID) && defined (HAVE_XFT) + if (STRINGP (pane_name)) + { + pane_name = ENCODE_UTF_8 (pane_name); + ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name); + } #elif !defined (HAVE_MULTILINGUAL_MENU) if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) { @@ -770,6 +759,18 @@ digest_single_submenu (start, end, top_level_items) descrip = ENCODE_SYSTEM (descrip); ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); } +#elif USE_LUCID + if (STRINGP (item_name)) + { + item_name = ENCODE_UTF_8 (item_name); + ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name); + } + + if (STRINGP (descrip)) + { + descrip = ENCODE_UTF_8 (descrip); + ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); + } #elif !defined (HAVE_MULTILINGUAL_MENU) if (STRING_MULTIBYTE (item_name)) { @@ -838,8 +839,7 @@ digest_single_submenu (start, end, top_level_items) tree is constructed, and small strings are relocated. So we must wait until no GC can happen before storing pointers into lisp values. */ void -update_submenu_strings (first_wv) - widget_value *first_wv; +update_submenu_strings (widget_value *first_wv) { widget_value *wv; @@ -873,11 +873,7 @@ update_submenu_strings (first_wv) VECTOR is an array of menu events for the whole menu. */ void -find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) - FRAME_PTR f; - int menu_bar_items_used; - Lisp_Object vector; - void *client_data; +find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object vector, void *client_data) { Lisp_Object prefix, entry; Lisp_Object *subprefix_stack; @@ -1064,13 +1060,12 @@ keyboard input, then this normally results in a quit and `x-popup-menu' does not return. But if POSITION is a mouse button event (indicating that the user invoked the menu with the mouse) then no quit occurs and `x-popup-menu' returns nil. */) - (position, menu) - Lisp_Object position, menu; + (Lisp_Object position, Lisp_Object menu) { Lisp_Object keymap, tem; int xpos = 0, ypos = 0; Lisp_Object title; - char *error_name = NULL; + const char *error_name = NULL; Lisp_Object selection = Qnil; FRAME_PTR f = NULL; Lisp_Object x, y, window; @@ -1146,12 +1141,12 @@ no quit occurs and `x-popup-menu' returns nil. */) Lisp_Object bar_window; enum scroll_bar_part part; unsigned long time; - void (*mouse_position_hook) P_ ((struct frame **, int, - Lisp_Object *, - enum scroll_bar_part *, - Lisp_Object *, - Lisp_Object *, - unsigned long *)) = + void (*mouse_position_hook) (struct frame **, int, + Lisp_Object *, + enum scroll_bar_part *, + Lisp_Object *, + Lisp_Object *, + unsigned long *) = FRAME_TERMINAL (new_f)->mouse_position_hook; if (mouse_position_hook) @@ -1350,7 +1345,7 @@ no quit occurs and `x-popup-menu' returns nil. */) } void -syms_of_menu () +syms_of_menu (void) { staticpro (&menu_items); menu_items = Qnil; diff --git a/src/menu.h b/src/menu.h index 5f3c3d24e22..5e62327da9f 100644 --- a/src/menu.h +++ b/src/menu.h @@ -21,17 +21,24 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ extern Lisp_Object Vmenu_updating_frame; -extern void init_menu_items P_ ((void)); -extern void finish_menu_items P_ ((void)); -extern void discard_menu_items P_ ((void)); -extern void save_menu_items P_ ((void)); -extern int parse_single_submenu P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); -extern void list_of_panes P_ ((Lisp_Object)); -#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) -extern void free_menubar_widget_value_tree P_ ((widget_value *)); -extern void update_submenu_strings P_ ((widget_value *)); -extern void find_and_call_menu_selection P_ ((FRAME_PTR, int, - Lisp_Object, void *)); +extern void x_set_menu_bar_lines (struct frame *f, + Lisp_Object value, + Lisp_Object oldval); + +extern void init_menu_items (void); +extern void finish_menu_items (void); +extern void discard_menu_items (void); +extern void save_menu_items (void); +extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object); +extern void list_of_panes (Lisp_Object); +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \ + || defined (HAVE_NS) +extern void free_menubar_widget_value_tree (widget_value *); +extern void update_submenu_strings (widget_value *); +extern void find_and_call_menu_selection (FRAME_PTR, int, + Lisp_Object, void *); +extern widget_value *xmalloc_widget_value (void); +extern widget_value *digest_single_submenu (int, int, int); #endif #ifdef HAVE_X_WINDOWS @@ -39,11 +46,11 @@ extern void mouse_position_for_popup (FRAME_PTR f, int *x, int *y); #endif extern Lisp_Object w32_menu_show (FRAME_PTR, int, int, int, int, - Lisp_Object, char **); + Lisp_Object, const char **); extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, int, int, - Lisp_Object, char **); + Lisp_Object, const char **); extern Lisp_Object xmenu_show (FRAME_PTR, int, int, int, int, - Lisp_Object, char **, EMACS_UINT); + Lisp_Object, const char **, EMACS_UINT); #endif /* MENU_H */ /* arch-tag: c32b2778-724d-4e85-81d7-45f98530a988 diff --git a/src/minibuf.c b/src/minibuf.c index 564346fd472..f3a24afc199 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -143,18 +143,13 @@ Lisp_Object Qcase_fold_search; Lisp_Object Qread_expression_history; -extern Lisp_Object Voverriding_local_map; - -extern Lisp_Object Qmouse_face; - -extern Lisp_Object Qfield; /* Put minibuf on currently selected frame's minibuffer. We do this whenever the user starts a new minibuffer or when a minibuffer exits. */ void -choose_minibuf_frame () +choose_minibuf_frame (void) { if (FRAMEP (selected_frame) && FRAME_LIVE_P (XFRAME (selected_frame)) @@ -193,8 +188,7 @@ choose_minibuf_frame () } Lisp_Object -choose_minibuf_frame_1 (ignore) - Lisp_Object ignore; +choose_minibuf_frame_1 (Lisp_Object ignore) { choose_minibuf_frame (); return Qnil; @@ -205,8 +199,7 @@ DEFUN ("set-minibuffer-window", Fset_minibuffer_window, doc: /* Specify which minibuffer window to use for the minibuffer. This affects where the minibuffer is displayed if you put text in it without invoking the usual minibuffer commands. */) - (window) - Lisp_Object window; + (Lisp_Object window) { CHECK_WINDOW (window); if (! MINI_WINDOW_P (XWINDOW (window))) @@ -220,31 +213,30 @@ without invoking the usual minibuffer commands. */) /* Actual minibuffer invocation. */ -static Lisp_Object read_minibuf_unwind P_ ((Lisp_Object)); -static Lisp_Object run_exit_minibuf_hook P_ ((Lisp_Object)); -static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - int, Lisp_Object, - Lisp_Object, Lisp_Object, - int, int)); -static Lisp_Object read_minibuf_noninteractive P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - int, Lisp_Object, - Lisp_Object, Lisp_Object, - int, int)); -static Lisp_Object string_to_object P_ ((Lisp_Object, Lisp_Object)); +static Lisp_Object read_minibuf_unwind (Lisp_Object); +static Lisp_Object run_exit_minibuf_hook (Lisp_Object); +static Lisp_Object read_minibuf (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + int, Lisp_Object, + Lisp_Object, Lisp_Object, + int, int); +static Lisp_Object read_minibuf_noninteractive (Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object, + int, Lisp_Object, + Lisp_Object, Lisp_Object, + int, int); +static Lisp_Object string_to_object (Lisp_Object, Lisp_Object); /* Read a Lisp object from VAL and return it. If VAL is an empty string, and DEFALT is a string, read from DEFALT instead of VAL. */ static Lisp_Object -string_to_object (val, defalt) - Lisp_Object val, defalt; +string_to_object (Lisp_Object val, Lisp_Object defalt) { struct gcpro gcpro1, gcpro2; Lisp_Object expr_and_pos; - int pos; + EMACS_INT pos; GCPRO2 (val, defalt); @@ -262,7 +254,7 @@ string_to_object (val, defalt) { /* Ignore trailing whitespace; any other trailing junk is an error. */ - int i; + EMACS_INT i; pos = string_char_to_byte (val, pos); for (i = pos; i < SBYTES (val); i++) { @@ -281,19 +273,12 @@ string_to_object (val, defalt) from read_minibuf to do the job if noninteractive. */ static Lisp_Object -read_minibuf_noninteractive (map, initial, prompt, backup_n, expflag, - histvar, histpos, defalt, allow_props, - inherit_input_method) - Lisp_Object map; - Lisp_Object initial; - Lisp_Object prompt; - Lisp_Object backup_n; - int expflag; - Lisp_Object histvar; - Lisp_Object histpos; - Lisp_Object defalt; - int allow_props; - int inherit_input_method; +read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, + Lisp_Object prompt, Lisp_Object backup_n, + int expflag, + Lisp_Object histvar, Lisp_Object histpos, + Lisp_Object defalt, + int allow_props, int inherit_input_method) { int size, len; char *line, *s; @@ -342,8 +327,7 @@ DEFUN ("minibufferp", Fminibufferp, doc: /* Return t if BUFFER is a minibuffer. No argument or nil as argument means use current buffer as BUFFER. BUFFER can be a buffer or a buffer name. */) - (buffer) - Lisp_Object buffer; + (Lisp_Object buffer) { Lisp_Object tem; @@ -362,7 +346,7 @@ DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end, Sminibuffer_prompt_end, 0, 0, 0, doc: /* Return the buffer position of the end of the minibuffer prompt. Return (point-min) if current buffer is not a minibuffer. */) - () + (void) { /* This function is written to be most efficient when there's a prompt. */ Lisp_Object beg, end, tem; @@ -384,9 +368,9 @@ DEFUN ("minibuffer-contents", Fminibuffer_contents, Sminibuffer_contents, 0, 0, 0, doc: /* Return the user input in a minibuffer as a string. If the current buffer is not a minibuffer, return its entire contents. */) - () + (void) { - int prompt_end = XINT (Fminibuffer_prompt_end ()); + EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ()); return make_buffer_string (prompt_end, ZV, 1); } @@ -394,9 +378,9 @@ DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties, Sminibuffer_contents_no_properties, 0, 0, 0, doc: /* Return the user input in a minibuffer as a string, without text-properties. If the current buffer is not a minibuffer, return its entire contents. */) - () + (void) { - int prompt_end = XINT (Fminibuffer_prompt_end ()); + EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ()); return make_buffer_string (prompt_end, ZV, 0); } @@ -405,9 +389,9 @@ DEFUN ("minibuffer-completion-contents", Fminibuffer_completion_contents, doc: /* Return the user input in a minibuffer before point as a string. That is what completion commands operate on. If the current buffer is not a minibuffer, return its entire contents. */) - () + (void) { - int prompt_end = XINT (Fminibuffer_prompt_end ()); + EMACS_INT prompt_end = XINT (Fminibuffer_prompt_end ()); if (PT < prompt_end) error ("Cannot do completion in the prompt"); return make_buffer_string (prompt_end, PT, 1); @@ -438,18 +422,10 @@ If the current buffer is not a minibuffer, return its entire contents. */) current input method. */ static Lisp_Object -read_minibuf (map, initial, prompt, backup_n, expflag, - histvar, histpos, defalt, allow_props, inherit_input_method) - Lisp_Object map; - Lisp_Object initial; - Lisp_Object prompt; - Lisp_Object backup_n; - int expflag; - Lisp_Object histvar; - Lisp_Object histpos; - Lisp_Object defalt; - int allow_props; - int inherit_input_method; +read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, + Lisp_Object backup_n, int expflag, + Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, + int allow_props, int inherit_input_method) { Lisp_Object val; int count = SPECPDL_INDEX (); @@ -463,9 +439,6 @@ read_minibuf (map, initial, prompt, backup_n, expflag, Lisp_Object empty_minibuf; Lisp_Object dummy, frame; - extern Lisp_Object Qfront_sticky; - extern Lisp_Object Qrear_nonsticky; - specbind (Qminibuffer_default, defalt); /* If Vminibuffer_completing_file_name is `lambda' on entry, it was t @@ -839,12 +812,10 @@ read_minibuf (map, initial, prompt, backup_n, expflag, used for nonrecursive minibuffer invocations */ Lisp_Object -get_minibuffer (depth) - int depth; +get_minibuffer (int depth) { Lisp_Object tail, num, buf; char name[24]; - extern Lisp_Object nconc2 (); XSETFASTINT (num, depth); tail = Fnthcdr (num, Vminibuffer_list); @@ -884,8 +855,7 @@ get_minibuffer (depth) } static Lisp_Object -run_exit_minibuf_hook (data) - Lisp_Object data; +run_exit_minibuf_hook (Lisp_Object data) { if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound) && !NILP (Vrun_hooks)) @@ -898,8 +868,7 @@ run_exit_minibuf_hook (data) not, and it restores the current window, buffer, etc. */ static Lisp_Object -read_minibuf_unwind (data) - Lisp_Object data; +read_minibuf_unwind (Lisp_Object data) { Lisp_Object old_deactivate_mark; Lisp_Object window; @@ -1001,9 +970,7 @@ POSITION in the minibuffer. Any integer value less than or equal to one puts point at the beginning of the string. *Note* that this behavior differs from the way such arguments are used in `completing-read' and some related functions, which use zero-indexing for POSITION. */) - (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method) - Lisp_Object prompt, initial_contents, keymap, read, hist, default_value; - Lisp_Object inherit_input_method; + (Lisp_Object prompt, Lisp_Object initial_contents, Lisp_Object keymap, Lisp_Object read, Lisp_Object hist, Lisp_Object default_value, Lisp_Object inherit_input_method) { Lisp_Object histvar, histpos, val; struct gcpro gcpro1; @@ -1045,8 +1012,7 @@ Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS is a string to insert in the minibuffer before reading. \(INITIAL-CONTENTS can also be a cons of a string and an integer. Such arguments are used as in `read-from-minibuffer'.) */) - (prompt, initial_contents) - Lisp_Object prompt, initial_contents; + (Lisp_Object prompt, Lisp_Object initial_contents) { CHECK_STRING (prompt); return read_minibuf (Vminibuffer_local_map, initial_contents, @@ -1060,8 +1026,7 @@ Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS is a string to insert in the minibuffer before reading. \(INITIAL-CONTENTS can also be a cons of a string and an integer. Such arguments are used as in `read-from-minibuffer'.) */) - (prompt, initial_contents) - Lisp_Object prompt, initial_contents; + (Lisp_Object prompt, Lisp_Object initial_contents) { return Feval (read_minibuf (Vread_expression_map, initial_contents, prompt, Qnil, 1, Qread_expression_history, @@ -1085,9 +1050,7 @@ Fourth arg DEFAULT-VALUE is the default value or the list of default values. empty string. Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits the current input method and the setting of `enable-multibyte-characters'. */) - (prompt, initial_input, history, default_value, inherit_input_method) - Lisp_Object prompt, initial_input, history, default_value; - Lisp_Object inherit_input_method; + (Lisp_Object prompt, Lisp_Object initial_input, Lisp_Object history, Lisp_Object default_value, Lisp_Object inherit_input_method) { Lisp_Object val; val = Fread_from_minibuffer (prompt, initial_input, Qnil, @@ -1108,8 +1071,7 @@ Such values are treated as in `read-from-minibuffer', but are normally not useful in this function.) Third arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits the current input method and the setting of`enable-multibyte-characters'. */) - (prompt, initial, inherit_input_method) - Lisp_Object prompt, initial, inherit_input_method; + (Lisp_Object prompt, Lisp_Object initial, Lisp_Object inherit_input_method) { CHECK_STRING (prompt); return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil, @@ -1121,8 +1083,7 @@ DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, doc: /* Read the name of a command and return as a symbol. Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element if it is a list. */) - (prompt, default_value) - Lisp_Object prompt, default_value; + (Lisp_Object prompt, Lisp_Object default_value) { Lisp_Object name, default_string; @@ -1144,8 +1105,7 @@ if it is a list. */) DEFUN ("read-function", Fread_function, Sread_function, 1, 1, 0, doc: /* One arg PROMPT, a string. Read the name of a function and return as a symbol. Prompt with PROMPT. */) - (prompt) - Lisp_Object prompt; + (Lisp_Object prompt) { return Fintern (Fcompleting_read (prompt, Vobarray, Qfboundp, Qt, Qnil, Qnil, Qnil, Qnil), Qnil); @@ -1157,8 +1117,7 @@ DEFUN ("read-variable", Fread_variable, Sread_variable, 1, 2, 0, Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element if it is a list. A user variable is one for which `user-variable-p' returns non-nil. */) - (prompt, default_value) - Lisp_Object prompt, default_value; + (Lisp_Object prompt, Lisp_Object default_value) { Lisp_Object name, default_string; @@ -1190,8 +1149,7 @@ If `read-buffer-completion-ignore-case' is non-nil, completion ignores case while reading the buffer name. If `read-buffer-function' is non-nil, this works by calling it as a function, instead of the usual behavior. */) - (prompt, def, require_match) - Lisp_Object prompt, def, require_match; + (Lisp_Object prompt, Lisp_Object def, Lisp_Object require_match) { Lisp_Object args[4], result; unsigned char *s; @@ -1249,8 +1207,7 @@ function, instead of the usual behavior. */) } static Lisp_Object -minibuf_conform_representation (string, basis) - Lisp_Object string, basis; +minibuf_conform_representation (Lisp_Object string, Lisp_Object basis) { if (STRING_MULTIBYTE (string) == STRING_MULTIBYTE (basis)) return string; @@ -1292,8 +1249,7 @@ or the symbol from the obarray. If COLLECTION is a hash-table, predicate is called with two arguments: the key and the value. Additionally to this predicate, `completion-regexp-list' is used to further constrain the set of candidates. */) - (string, collection, predicate) - Lisp_Object string, collection, predicate; + (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate) { Lisp_Object bestmatch, tail, elt, eltstring; /* Size in bytes of BESTMATCH. */ @@ -1564,8 +1520,7 @@ is used to further constrain the set of candidates. An obsolete optional fourth argument HIDE-SPACES is still accepted for backward compatibility. If non-nil, strings in COLLECTION that start with a space are ignored unless STRING itself starts with a space. */) - (string, collection, predicate, hide_spaces) - Lisp_Object string, collection, predicate, hide_spaces; + (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate, Lisp_Object hide_spaces) { Lisp_Object tail, elt, eltstring; Lisp_Object allmatches; @@ -1774,9 +1729,7 @@ If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits Completion ignores case if the ambient value of `completion-ignore-case' is non-nil. */) - (prompt, collection, predicate, require_match, initial_input, hist, def, inherit_input_method) - Lisp_Object prompt, collection, predicate, require_match, initial_input; - Lisp_Object hist, def, inherit_input_method; + (Lisp_Object prompt, Lisp_Object collection, Lisp_Object predicate, Lisp_Object require_match, Lisp_Object initial_input, Lisp_Object hist, Lisp_Object def, Lisp_Object inherit_input_method) { Lisp_Object val, histvar, histpos, position; Lisp_Object init; @@ -1843,7 +1796,7 @@ Completion ignores case if the ambient value of RETURN_UNGCPRO (unbind_to (count, val)); } -Lisp_Object Fassoc_string (); +Lisp_Object Fassoc_string (register Lisp_Object key, Lisp_Object list, Lisp_Object case_fold); /* Test whether TXT is an exact completion. */ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, @@ -1851,8 +1804,7 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, Takes the same arguments as `all-completions' and `try-completion'. If COLLECTION is a function, it is called with three arguments: the values STRING, PREDICATE and `lambda'. */) - (string, collection, predicate) - Lisp_Object string, collection, predicate; + (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate) { Lisp_Object regexps, tail, tem = Qnil; int i = 0; @@ -1970,8 +1922,7 @@ If the argument FLAG is nil, invoke `try-completion', if it's t, invoke The arguments STRING and PREDICATE are as in `try-completion', `all-completions', and `test-completion'. */) - (string, predicate, flag) - Lisp_Object string, predicate, flag; + (Lisp_Object string, Lisp_Object predicate, Lisp_Object flag) { if (NILP (flag)) return Ftry_completion (string, Vbuffer_alist, predicate); @@ -2015,9 +1966,7 @@ is ignored. Unlike `assoc', KEY can also match an entry in LIST consisting of a single string, rather than a cons cell whose car is a string. */) - (key, list, case_fold) - register Lisp_Object key; - Lisp_Object list, case_fold; + (register Lisp_Object key, Lisp_Object list, Lisp_Object case_fold) { register Lisp_Object tail; @@ -2046,7 +1995,7 @@ single string, rather than a cons cell whose car is a string. */) DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0, doc: /* Return current depth of activations of minibuffer, a nonnegative integer. */) - () + (void) { return make_number (minibuf_level); } @@ -2054,21 +2003,21 @@ DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0, DEFUN ("minibuffer-prompt", Fminibuffer_prompt, Sminibuffer_prompt, 0, 0, 0, doc: /* Return the prompt string of the currently-active minibuffer. If no minibuffer is active, return nil. */) - () + (void) { return Fcopy_sequence (minibuf_prompt); } void -init_minibuf_once () +init_minibuf_once (void) { Vminibuffer_list = Qnil; staticpro (&Vminibuffer_list); } void -syms_of_minibuf () +syms_of_minibuf (void) { minibuf_level = 0; minibuf_prompt = Qnil; diff --git a/src/mktime.c b/src/mktime.c index 20c1092a62a..3570cecd451 100644 --- a/src/mktime.c +++ b/src/mktime.c @@ -57,14 +57,6 @@ # define mktime my_mktime #endif /* DEBUG */ -#ifndef __P -# if defined __GNUC__ || (defined __STDC__ && __STDC__) -# define __P(args) args -# else -# define __P(args) () -# endif /* GCC. */ -#endif /* Not __P. */ - #ifndef CHAR_BIT # define CHAR_BIT 8 #endif diff --git a/src/msdos.c b/src/msdos.c index a413184f966..0957221f597 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -29,17 +29,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <setjmp.h> #include "lisp.h" #include <stdio.h> -#include <stdlib.h> #include <time.h> #include <sys/param.h> #include <sys/time.h> #include <dos.h> #include <errno.h> -#include <string.h> /* for bzero and string functions */ #include <sys/stat.h> /* for _fixpath */ #include <unistd.h> /* for chdir, dup, dup2, etc. */ #include <dir.h> /* for getdisk */ -#if __DJGPP__ >= 2 #pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */ #include <fcntl.h> #include <io.h> /* for setmode */ @@ -47,7 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/farptr.h> /* for _farsetsel, _farnspokeb */ #include <libc/dosio.h> /* for _USE_LFN */ #include <conio.h> /* for cputs */ -#endif #include "msdos.h" #include "systime.h" @@ -70,8 +66,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <pc.h> #include <ctype.h> /* #include <process.h> */ -/* Damn that local process.h! Instead we can define P_WAIT ourselves. */ +/* Damn that local process.h! Instead we can define P_WAIT and + spawnve ourselves. */ #define P_WAIT 1 +extern int spawnve (int, const char *, char *const [], char *const []); #ifndef _USE_LFN #define _USE_LFN 0 @@ -81,8 +79,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define _dos_ds _go32_info_block.selector_for_linear_memory #endif -#if __DJGPP__ > 1 - #include <signal.h> #include "syssignal.h" @@ -104,10 +100,9 @@ int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); #endif /* GNU_MALLOC */ #endif /* not SYSTEM_MALLOC */ -#endif /* __DJGPP__ > 1 */ static unsigned long -event_timestamp () +event_timestamp (void) { struct time t; unsigned long s; @@ -143,7 +138,7 @@ static int mouse_button_translate[NUM_MOUSE_BUTTONS]; static int mouse_button_count; void -mouse_on () +mouse_on (void) { union REGS regs; @@ -160,7 +155,7 @@ mouse_on () } void -mouse_off () +mouse_off (void) { union REGS regs; @@ -200,8 +195,7 @@ DEFUN ("msdos-set-mouse-buttons", Fmsdos_set_mouse_buttons, Smsdos_set_mouse_but This is useful with mice that report the number of buttons inconsistently, e.g., if the number of buttons is reported as 3, but Emacs only sees 2 of them. This happens with wheeled mice on Windows 9X, for example. */) - (nbuttons) - Lisp_Object nbuttons; + (Lisp_Object nbuttons) { int n; @@ -227,8 +221,7 @@ mouse_get_xy (int *x, int *y) } void -mouse_moveto (x, y) - int x, y; +mouse_moveto (int x, int y) { union REGS regs; struct tty_display_info *tty = CURTTY (); @@ -242,8 +235,7 @@ mouse_moveto (x, y) } static int -mouse_pressed (b, xp, yp) - int b, *xp, *yp; +mouse_pressed (int b, int *xp, int *yp) { union REGS regs; @@ -258,8 +250,7 @@ mouse_pressed (b, xp, yp) } static int -mouse_released (b, xp, yp) - int b, *xp, *yp; +mouse_released (int b, int *xp, int *yp) { union REGS regs; @@ -274,8 +265,7 @@ mouse_released (b, xp, yp) } static int -mouse_button_depressed (b, xp, yp) - int b, *xp, *yp; +mouse_button_depressed (int b, int *xp, int *yp) { union REGS regs; @@ -293,12 +283,9 @@ mouse_button_depressed (b, xp, yp) } void -mouse_get_pos (f, insist, bar_window, part, x, y, time) - FRAME_PTR *f; - int insist; - Lisp_Object *bar_window, *x, *y; - enum scroll_bar_part *part; - unsigned long *time; +mouse_get_pos (FRAME_PTR *f, int insist, Lisp_Object *bar_window, + enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, + unsigned long *time) { int ix, iy; Lisp_Object frame, tail; @@ -316,7 +303,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time) } static void -mouse_check_moved () +mouse_check_moved (void) { int x, y; @@ -343,7 +330,7 @@ mouse_clear_clicks (void) } void -mouse_init () +mouse_init (void) { union REGS regs; struct tty_display_info *tty = CURTTY (); @@ -427,7 +414,6 @@ extern Lisp_Object Qbar, Qhbar; colors for newly-created frames. */ static int initial_screen_colors[2]; -#if __DJGPP__ > 1 /* Update the screen from a part of relocated DOS/V screen buffer which begins at OFFSET and includes COUNT characters. */ static void @@ -444,79 +430,20 @@ dosv_refresh_virtual_screen (int offset, int count) regs.x.cx = count; __dpmi_int (0x10, ®s); } -#endif static void -dos_direct_output (y, x, buf, len) - int x, y; - char *buf; - int len; +dos_direct_output (int y, int x, char *buf, int len) { int t0 = 2 * (x + y * screen_size_X); int t = t0 + (int) ScreenPrimary; int l0 = len; -#if (__DJGPP__ < 2) - while (--len >= 0) { - dosmemput (buf++, 1, t); - t += 2; - } -#else /* This is faster. */ for (_farsetsel (_dos_ds); --len >= 0; t += 2, buf++) _farnspokeb (t, *buf); if (screen_virtual_segment) dosv_refresh_virtual_screen (t0, l0); -#endif -} -#endif - -/* Flash the screen as a substitute for BEEPs. */ - -#if (__DJGPP__ < 2) -static void -do_visible_bell (xorattr) - unsigned char xorattr; -{ - asm volatile - (" movb $1,%%dl \n\ -visible_bell_0: \n\ - movl _ScreenPrimary,%%eax \n\ - call dosmemsetup \n\ - movl %%eax,%%ebx \n\ - movl %1,%%ecx \n\ - movb %0,%%al \n\ - incl %%ebx \n\ -visible_bell_1: \n\ - xorb %%al,%%gs:(%%ebx) \n\ - addl $2,%%ebx \n\ - decl %%ecx \n\ - jne visible_bell_1 \n\ - decb %%dl \n\ - jne visible_bell_3 \n\ -visible_bell_2: \n\ - movzwl %%ax,%%eax \n\ - movzwl %%ax,%%eax \n\ - movzwl %%ax,%%eax \n\ - movzwl %%ax,%%eax \n\ - decw %%cx \n\ - jne visible_bell_2 \n\ - jmp visible_bell_0 \n\ -visible_bell_3:" - : /* no output */ - : "m" (xorattr), "g" (screen_size) - : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx"); -} - -static void -ScreenVisualBell (void) -{ - /* This creates an xor-mask that will swap the default fore- and - background colors. */ - do_visible_bell (((FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ()) - ^ FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ())) - * 0x11) & 0x7f); } #endif @@ -572,8 +499,7 @@ vga_installed (void) ROWS x COLS frame. */ void -dos_set_window_size (rows, cols) - int *rows, *cols; +dos_set_window_size (int *rows, int *cols) { char video_name[30]; union REGS regs; @@ -590,8 +516,7 @@ dos_set_window_size (rows, cols) /* If the user specified a special video mode for these dimensions, use that mode. */ sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols); - video_mode = XSYMBOL (Fintern_soft (build_string (video_name), - Qnil))-> value; + video_mode = Fsymbol_value (Fintern_soft (build_string (video_name), Qnil)); if (INTEGERP (video_mode) && (video_mode_value = XINT (video_mode)) > 0) @@ -611,9 +536,6 @@ dos_set_window_size (rows, cols) /* Find one of the dimensions supported by standard EGA/VGA which gives us at least the required dimensions. */ - -#if __DJGPP__ > 1 - else { static struct { @@ -642,41 +564,6 @@ dos_set_window_size (rows, cols) } } -#else /* not __DJGPP__ > 1 */ - - else if (*rows <= 25) - { - if (current_rows != 25 || current_cols != 80) - { - regs.x.ax = 3; - int86 (0x10, ®s, ®s); - regs.x.ax = 0x1101; - regs.h.bl = 0; - int86 (0x10, ®s, ®s); - regs.x.ax = 0x1200; - regs.h.bl = 32; - int86 (0x10, ®s, ®s); - regs.x.ax = 3; - int86 (0x10, ®s, ®s); - } - } - else if (*rows <= 50) - if (have_vga && (current_rows != 50 || current_cols != 80) - || *rows <= 43 && (current_rows != 43 || current_cols != 80)) - { - regs.x.ax = 3; - int86 (0x10, ®s, ®s); - regs.x.ax = 0x1112; - regs.h.bl = 0; - int86 (0x10, ®s, ®s); - regs.x.ax = 0x1200; - regs.h.bl = 32; - int86 (0x10, ®s, ®s); - regs.x.ax = 0x0100; - regs.x.cx = 7; - int86 (0x10, ®s, ®s); - } -#endif /* not __DJGPP__ > 1 */ if (have_mouse) { @@ -693,7 +580,6 @@ dos_set_window_size (rows, cols) screen_size_Y = *rows; screen_size = *cols * *rows; -#if __DJGPP__ > 1 /* If the dimensions changed, the mouse highlight info is invalid. */ if (current_rows != *rows || current_cols != *cols) { @@ -708,7 +594,6 @@ dos_set_window_size (rows, cols) dpyinfo->mouse_face_window = Qnil; } } -#endif /* Enable bright background colors. */ bright_bg (); @@ -723,7 +608,7 @@ dos_set_window_size (rows, cols) the mouse cursor may need to be refreshed. */ static void -mouse_off_maybe () +mouse_off_maybe (void) { int x, y; @@ -747,7 +632,6 @@ mouse_off_maybe () static void msdos_set_cursor_shape (struct frame *f, int start_line, int width) { -#if __DJGPP__ > 1 unsigned desired_cursor; __dpmi_regs regs; int max_line, top_line, bot_line; @@ -824,7 +708,6 @@ msdos_set_cursor_shape (struct frame *f, int start_line, int width) regs.h.ah = 1; regs.x.cx = desired_cursor; __dpmi_int (0x10, ®s); -#endif /* __DJGPP__ > 1 */ } static void @@ -944,7 +827,7 @@ IT_set_face (int face) bg = tem2; } if (tty->termscript) - fprintf (tty->termscript, "<FACE %d: %d/%d[FG:%d/BG:%d]>", face, + fprintf (tty->termscript, "<FACE %d: %lu/%lu[FG:%lu/BG:%lu]>", face, fp->foreground, fp->background, fg, bg); if (fg >= 0 && fg < 16) { @@ -976,12 +859,6 @@ IT_write_glyphs (struct frame *f, struct glyph *str, int str_len) struct frame *sf; unsigned char *conversion_buffer; - /* Do we need to consider conversion of unibyte characters to - multibyte? */ - int convert_unibyte_characters - = (NILP (current_buffer->enable_multibyte_characters) - && unibyte_display_via_language_environment); - /* If terminal_coding does any conversion, use it, otherwise use safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here because it always returns 1 if terminal_coding.src_multibyte is 1. */ @@ -1297,8 +1174,6 @@ fast_find_position (struct window *w, int pos, int *hpos, int *vpos) static void IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p) { - struct frame *f = XFRAME (w->frame); - struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); struct glyph_row *row; if (mode_line_p) @@ -1308,9 +1183,8 @@ IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p) if (row->enabled_p) { - extern Lisp_Object Qhelp_echo; struct glyph *glyph, *end; - Lisp_Object help, map; + Lisp_Object help; /* Find the glyph under X. */ glyph = (row->glyphs[TEXT_AREA] @@ -1447,7 +1321,6 @@ IT_note_mouse_highlight (struct frame *f, int x, int y) /* Check for mouse-face and help-echo. */ { - extern Lisp_Object Qmouse_face; Lisp_Object mouse_face, overlay, position, *overlay_vec; int noverlays, obegv, ozv; struct buffer *obuf; @@ -1572,7 +1445,6 @@ IT_note_mouse_highlight (struct frame *f, int x, int y) /* Look for a `help-echo' property. */ { Lisp_Object help; - extern Lisp_Object Qhelp_echo; /* Check overlays first. */ help = Qnil; @@ -1712,14 +1584,16 @@ IT_display_cursor (int on) ScreenSetCursor (current_pos_Y, current_pos_X); cursor_cleared = 0; if (tty->termscript) - fprintf (tty->termscript, "\nCURSOR ON"); + fprintf (tty->termscript, "\nCURSOR ON (%dx%d)", + current_pos_Y, current_pos_X); } else if (!on && !cursor_cleared) { ScreenSetCursor (-1, -1); cursor_cleared = 1; if (tty->termscript) - fprintf (tty->termscript, "\nCURSOR OFF"); + fprintf (tty->termscript, "\nCURSOR OFF (%dx%d)", + current_pos_Y, current_pos_X); } } @@ -1969,10 +1843,7 @@ IT_copy_glyphs (int xfrom, int xto, size_t len, int ypos) /* Insert and delete glyphs. */ static void -IT_insert_glyphs (f, start, len) - struct frame *f; - register struct glyph *start; - register int len; +IT_insert_glyphs (struct frame *f, struct glyph *start, int len) { int shift_by_width = screen_size_X - (new_pos_X + len); @@ -1985,19 +1856,17 @@ IT_insert_glyphs (f, start, len) } static void -IT_delete_glyphs (f, n) - struct frame *f; - register int n; +IT_delete_glyphs (struct frame *f, int n) { abort (); } /* set-window-configuration on window.c needs this. */ void -x_set_menu_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { + extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); + set_menu_bar_lines (f, value, oldval); } @@ -2041,7 +1910,6 @@ IT_set_terminal_modes (struct terminal *term) startup_screen_size_Y = screen_size_Y; startup_screen_attrib = ScreenAttrib; -#if __DJGPP__ > 1 /* Is DOS/V (or any other RSIS software which relocates the screen) installed? */ { @@ -2065,14 +1933,13 @@ IT_set_terminal_modes (struct terminal *term) already point to the relocated buffer address returned by the Int 10h/AX=FEh call above. DJGPP v2.02 and later sets ScreenPrimary to that address at startup under DOS/V. */ - if (regs.x.es != (ScreenPrimary >> 4) & 0xffff) + if (regs.x.es != ((ScreenPrimary >> 4) & 0xffff)) screen_old_address = ScreenPrimary; screen_virtual_segment = regs.x.es; screen_virtual_offset = regs.x.di; ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset; } } -#endif /* __DJGPP__ > 1 */ ScreenGetCursor (&startup_pos_Y, &startup_pos_X); ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); @@ -2170,8 +2037,7 @@ IT_set_terminal_window (struct frame *f, int foo) DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors, Smsdos_remember_default_colors, 1, 1, 0, doc: /* Remember the screen colors of the current frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -2184,12 +2050,12 @@ DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors, frame colors are reversed. */ initial_screen_colors[0] = FRAME_FOREGROUND_PIXEL (f); initial_screen_colors[1] = FRAME_BACKGROUND_PIXEL (f); + + return Qnil; } void -IT_set_frame_parameters (f, alist) - struct frame *f; - Lisp_Object alist; +IT_set_frame_parameters (struct frame *f, Lisp_Object alist) { Lisp_Object tail; int i, j, length = XINT (Flength (alist)); @@ -2199,33 +2065,22 @@ IT_set_frame_parameters (f, alist) = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); /* Do we have to reverse the foreground and background colors? */ int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); - int need_to_reverse, was_reverse = reverse; int redraw = 0, fg_set = 0, bg_set = 0; unsigned long orig_fg, orig_bg; - Lisp_Object frame_bg, frame_fg; - extern Lisp_Object Qdefault, QCforeground, QCbackground; struct tty_display_info *tty = FRAME_TTY (f); /* If we are creating a new frame, begin with the original screen colors used for the initial frame. */ - if (EQ (alist, Vdefault_frame_alist) + if (!f->default_face_done_p && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) { FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; init_frame_faces (f); + f->default_face_done_p = 1; } - orig_fg = FRAME_FOREGROUND_PIXEL (f); - orig_bg = FRAME_BACKGROUND_PIXEL (f); - frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist)); - frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist)); - /* frame_fg and frame_bg could be nil if, for example, - f->param_alist is nil, e.g. if we are called from - Fmake_terminal_frame. */ - if (NILP (frame_fg)) - frame_fg = build_string (unspecified_fg); - if (NILP (frame_bg)) - frame_bg = build_string (unspecified_bg); + orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); + orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f); /* Extract parm names and values into those vectors. */ i = 0; @@ -2253,58 +2108,75 @@ IT_set_frame_parameters (f, alist) reverse = EQ (val, Qt); } - need_to_reverse = reverse && !was_reverse; - if (tty->termscript && need_to_reverse) + if (tty->termscript && reverse) fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); /* Now process the alist elements in reverse of specified order. */ for (i--; i >= 0; i--) { - Lisp_Object prop, val, frame; + Lisp_Object prop, val; prop = parms[i]; val = values[i]; if (EQ (prop, Qforeground_color)) { - unsigned long new_color = load_color (f, NULL, val, need_to_reverse + unsigned long new_color = load_color (f, NULL, val, reverse ? LFACE_BACKGROUND_INDEX : LFACE_FOREGROUND_INDEX); if (new_color != FACE_TTY_DEFAULT_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_BG_COLOR) { - FRAME_FOREGROUND_PIXEL (f) = new_color; - /* Make sure the foreground of the default face for this - frame is changed as well. */ - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCforeground, - val, frame); - fg_set = 1; + if (!reverse) + { + FRAME_FOREGROUND_PIXEL (f) = new_color; + /* Make sure the foreground of the default face for + this frame is changed as well. */ + update_face_from_frame_parameter (f, Qforeground_color, val); + fg_set = 1; + if (tty->termscript) + fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); + } + else + { + FRAME_BACKGROUND_PIXEL (f) = new_color; + update_face_from_frame_parameter (f, Qbackground_color, val); + bg_set = 1; + if (tty->termscript) + fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); + } redraw = 1; - if (tty->termscript) - fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); } } else if (EQ (prop, Qbackground_color)) { - unsigned long new_color = load_color (f, NULL, val, need_to_reverse + unsigned long new_color = load_color (f, NULL, val, reverse ? LFACE_FOREGROUND_INDEX : LFACE_BACKGROUND_INDEX); if (new_color != FACE_TTY_DEFAULT_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_BG_COLOR) { - FRAME_BACKGROUND_PIXEL (f) = new_color; - /* Make sure the background of the default face for this - frame is changed as well. */ - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCbackground, - val, frame); - bg_set = 1; + if (!reverse) + { + FRAME_BACKGROUND_PIXEL (f) = new_color; + /* Make sure the background of the default face for + this frame is changed as well. */ + bg_set = 1; + update_face_from_frame_parameter (f, Qbackground_color, val); + if (tty->termscript) + fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); + } + else + { + FRAME_FOREGROUND_PIXEL (f) = new_color; + fg_set = 1; + update_face_from_frame_parameter (f, Qforeground_color, val); + if (tty->termscript) + fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); + } redraw = 1; - if (tty->termscript) - fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); } } else if (EQ (prop, Qtitle)) @@ -2318,9 +2190,10 @@ IT_set_frame_parameters (f, alist) IT_set_cursor_type (f, val); if (tty->termscript) fprintf (tty->termscript, "<CTYPE: %s>\n", - EQ (val, Qbar) || EQ (val, Qhbar) - || CONSP (val) && (EQ (XCAR (val), Qbar) - || EQ (XCAR (val), Qhbar)) + EQ (val, Qbar) + || EQ (val, Qhbar) + || (CONSP (val) && (EQ (XCAR (val), Qbar) + || EQ (XCAR (val), Qhbar))) ? "bar" : "box"); } else if (EQ (prop, Qtty_type)) @@ -2335,24 +2208,20 @@ IT_set_frame_parameters (f, alist) /* If they specified "reverse", but not the colors, we need to swap the current frame colors. */ - if (need_to_reverse) + if (reverse) { - Lisp_Object frame; - if (!fg_set) { - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCforeground, - tty_color_name (f, orig_bg), - frame); + FRAME_FOREGROUND_PIXEL (f) = orig_bg; + update_face_from_frame_parameter (f, Qforeground_color, + tty_color_name (f, orig_bg)); redraw = 1; } if (!bg_set) { - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCbackground, - tty_color_name (f, orig_fg), - frame); + FRAME_BACKGROUND_PIXEL (f) = orig_fg; + update_face_from_frame_parameter (f, Qbackground_color, + tty_color_name (f, orig_fg)); redraw = 1; } } @@ -2373,7 +2242,7 @@ extern void init_frame_faces (FRAME_PTR); /* Do we need the internal terminal? */ void -internal_terminal_init () +internal_terminal_init (void) { static int init_needed = 1; char *term = getenv ("TERM"), *colors; @@ -2509,10 +2378,8 @@ initialize_msdos_display (struct terminal *term) term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */ } -dos_get_saved_screen (screen, rows, cols) - char **screen; - int *rows; - int *cols; +int +dos_get_saved_screen (char **screen, int *rows, int *cols) { #ifndef HAVE_X_WINDOWS *screen = startup_screen_buffer; @@ -2659,11 +2526,11 @@ static struct keyboard_layout_list struct dos_keyboard_map *keyboard_map; } keyboard_layout_list[] = { - 1, &us_keyboard, - 33, &fr_keyboard, - 39, &it_keyboard, - 45, &dk_keyboard, - 81, &jp_keyboard + { 1, &us_keyboard }, + { 33, &fr_keyboard }, + { 39, &it_keyboard }, + { 45, &dk_keyboard }, + { 81, &jp_keyboard } }; static struct dos_keyboard_map *keyboard; @@ -2671,9 +2538,7 @@ static int keyboard_map_all; static int international_keyboard; int -dos_set_keyboard (code, always) - int code; - int always; +dos_set_keyboard (int code, int always) { int i; _go32_dpmi_registers regs; @@ -2710,17 +2575,17 @@ static struct unsigned char keypad_code; /* keypad code */ unsigned char editkey_code; /* edit key */ } keypad_translate_map[] = { - '0', '0', 0xb0, /* kp-0 */ 0x63, /* insert */ - '1', '1', 0xb1, /* kp-1 */ 0x57, /* end */ - '2', '2', 0xb2, /* kp-2 */ 0x54, /* down */ - '3', '3', 0xb3, /* kp-3 */ 0x56, /* next */ - '4', '4', 0xb4, /* kp-4 */ 0x51, /* left */ - '5', '5', 0xb5, /* kp-5 */ 0xb5, /* kp-5 */ - '6', '6', 0xb6, /* kp-6 */ 0x53, /* right */ - '7', '7', 0xb7, /* kp-7 */ 0x50, /* home */ - '8', '8', 0xb8, /* kp-8 */ 0x52, /* up */ - '9', '9', 0xb9, /* kp-9 */ 0x55, /* prior */ - '.', '-', 0xae, /* kp-decimal */ 0xff /* delete */ + { '0', '0', 0xb0, /* kp-0 */ 0x63 /* insert */ }, + { '1', '1', 0xb1, /* kp-1 */ 0x57 /* end */ }, + { '2', '2', 0xb2, /* kp-2 */ 0x54 /* down */ }, + { '3', '3', 0xb3, /* kp-3 */ 0x56 /* next */ }, + { '4', '4', 0xb4, /* kp-4 */ 0x51 /* left */ }, + { '5', '5', 0xb5, /* kp-5 */ 0xb5 /* kp-5 */ }, + { '6', '6', 0xb6, /* kp-6 */ 0x53 /* right */ }, + { '7', '7', 0xb7, /* kp-7 */ 0x50 /* home */ }, + { '8', '8', 0xb8, /* kp-8 */ 0x52 /* up */ }, + { '9', '9', 0xb9, /* kp-9 */ 0x55 /* prior */ }, + { '.', '-', 0xae, /* kp-decimal */ 0xff /* delete */} }; static struct @@ -2728,11 +2593,11 @@ static struct unsigned char char_code; /* normal code */ unsigned char keypad_code; /* keypad code */ } grey_key_translate_map[] = { - '/', 0xaf, /* kp-decimal */ - '*', 0xaa, /* kp-multiply */ - '-', 0xad, /* kp-subtract */ - '+', 0xab, /* kp-add */ - '\r', 0x8d /* kp-enter */ + { '/', 0xaf /* kp-decimal */ }, + { '*', 0xaa /* kp-multiply */ }, + { '-', 0xad /* kp-subtract */ }, + { '+', 0xab /* kp-add */ }, + { '\r', 0x8d /* kp-enter */ } }; static unsigned short @@ -2940,8 +2805,7 @@ ibmpc_translate_map[] = #define HYPER_P 0x8000 /* pseudo */ static int -dos_get_modifiers (keymask) - int *keymask; +dos_get_modifiers (int *keymask) { union REGS regs; int mask, modifiers = 0; @@ -3023,13 +2887,13 @@ dos_get_modifiers (keymask) #define NUM_RECENT_DOSKEYS (100) int recent_doskeys_index; /* Index for storing next element into recent_doskeys */ int total_doskeys; /* Total number of elements stored into recent_doskeys */ -Lisp_Object recent_doskeys; /* A vector, holding the last 100 keystrokes */ +Lisp_Object recent_doskeys; /* A vector, holding the last 100 keystrokes */ DEFUN ("recent-doskeys", Frecent_doskeys, Srecent_doskeys, 0, 0, 0, doc: /* Return vector of last 100 keyboard input values seen in dos_rawgetc. Each input key receives two values in this vector: first the ASCII code, and then the scan code. */) - () + (void) { Lisp_Object val, *keys = XVECTOR (recent_doskeys)->contents; @@ -3038,19 +2902,17 @@ and then the scan code. */) else { val = Fvector (NUM_RECENT_DOSKEYS, keys); - bcopy (keys + recent_doskeys_index, - XVECTOR (val)->contents, - (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); - bcopy (keys, - XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, - recent_doskeys_index * sizeof (Lisp_Object)); + memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index, + (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); + memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, + keys, recent_doskeys_index * sizeof (Lisp_Object)); return val; } } /* Get a char from keyboard. Function keys are put into the event queue. */ static int -dos_rawgetc () +dos_rawgetc (void) { struct input_event event; union REGS regs; @@ -3261,7 +3123,6 @@ dos_rawgetc () break; } - make_event: if (code == 0) continue; @@ -3369,14 +3230,14 @@ dos_rawgetc () /* If only one button is pressed, wait 100 msec and check again. This way, Speedy Gonzales isn't punished, while the slow get their chance. */ - if (press && mouse_pressed (1-but, &x2, &y2) - || !press && mouse_released (1-but, &x2, &y2)) + if ((press && mouse_pressed (1-but, &x2, &y2)) + || (!press && mouse_released (1-but, &x2, &y2))) button_num = 2; else { delay (100); - if (press && mouse_pressed (1-but, &x2, &y2) - || !press && mouse_released (1-but, &x2, &y2)) + if ((press && mouse_pressed (1-but, &x2, &y2)) + || (!press && mouse_released (1-but, &x2, &y2))) button_num = 2; } } @@ -3401,8 +3262,8 @@ dos_rawgetc () static int prev_get_char = -1; /* Return 1 if a key is ready to be read without suspending execution. */ - -dos_keysns () +int +dos_keysns (void) { if (prev_get_char != -1) return 1; @@ -3411,8 +3272,8 @@ dos_keysns () } /* Read a key. Return -1 if no key is ready. */ - -dos_keyread () +int +dos_keyread (void) { if (prev_get_char != -1) { @@ -3441,7 +3302,7 @@ static char *menu_help_message, *prev_menu_help_message; static int menu_help_paneno, menu_help_itemno; static XMenu * -IT_menu_create () +IT_menu_create (void) { XMenu *menu; @@ -3610,7 +3471,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help) /* Report availability of menus. */ int -have_menus_p () { return 1; } +have_menus_p (void) { return 1; } /* Create a brand new menu structure. */ @@ -3812,10 +3673,12 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, if (0 <= dy && dy < state[i].menu->count) { if (!state[i].menu->submenu[dy]) - if (state[i].menu->panenumber[dy]) - result = XM_SUCCESS; - else - result = XM_IA_SELECT; + { + if (state[i].menu->panenumber[dy]) + result = XM_SUCCESS; + else + result = XM_IA_SELECT; + } *pane = state[i].pane - 1; *selidx = dy; /* We hit some part of a menu, so drop extra menus that @@ -3968,8 +3831,7 @@ void msdos_downcase_filename (unsigned char *); /* Destructively turn backslashes into slashes. */ void -dostounix_filename (p) - register char *p; +dostounix_filename (char *p) { msdos_downcase_filename (p); @@ -3984,8 +3846,7 @@ dostounix_filename (p) /* Destructively turn slashes into backslashes. */ void -unixtodos_filename (p) - register char *p; +unixtodos_filename (char *p) { if (p[1] == ':' && *p >= 'A' && *p <= 'Z') { @@ -4004,9 +3865,7 @@ unixtodos_filename (p) /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */ int -getdefdir (drive, dst) - int drive; - char *dst; +getdefdir (int drive, char *dst) { char in_path[4], *p = in_path, e = errno; @@ -4045,9 +3904,7 @@ emacs_root_dir (void) /* Remove all CR's that are followed by a LF. */ int -crlf_to_lf (n, buf) - register int n; - register unsigned char *buf; +crlf_to_lf (int n, unsigned char *buf) { unsigned char *np = buf, *startp = buf, *endp = buf + n; @@ -4068,199 +3925,10 @@ crlf_to_lf (n, buf) return np - startp; } -#if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 - -/* In DJGPP v2.0, library `write' can call `malloc', which might - cause relocation of the buffer whose address we get in ADDR. - Here is a version of `write' that avoids calling `malloc', - to serve us until such time as the library is fixed. - Actually, what we define here is called `__write', because - `write' is a stub that just jmp's to `__write' (to be - POSIXLY-correct with respect to the global name-space). */ - -#include <io.h> /* for _write */ -#include <libc/dosio.h> /* for __file_handle_modes[] */ - -static char xbuf[64 * 1024]; /* DOS cannot write more in one chunk */ - -#define XBUF_END (xbuf + sizeof (xbuf) - 1) - -int -__write (int handle, const void *buffer, size_t count) -{ - if (count == 0) - return 0; - - if(__file_handle_modes[handle] & O_BINARY) - return _write (handle, buffer, count); - else - { - char *xbp = xbuf; - const char *bp = buffer; - int total_written = 0; - int nmoved = 0, ncr = 0; - - while (count) - { - /* The next test makes sure there's space for at least 2 more - characters in xbuf[], so both CR and LF can be put there. */ - if (xbp < XBUF_END) - { - if (*bp == '\n') - { - ncr++; - *xbp++ = '\r'; - } - *xbp++ = *bp++; - nmoved++; - count--; - } - if (xbp >= XBUF_END || !count) - { - size_t to_write = nmoved + ncr; - int written = _write (handle, xbuf, to_write); - - if (written == -1) - return -1; - else - total_written += nmoved; /* CRs aren't counted in ret value */ - - /* If some, but not all were written (disk full?), return - an estimate of the total written bytes not counting CRs. */ - if (written < to_write) - return total_written - (to_write - written) * nmoved/to_write; - - nmoved = 0; - ncr = 0; - xbp = xbuf; - } - } - return total_written; - } -} - -/* A low-level file-renaming function which works around Windows 95 bug. - This is pulled directly out of DJGPP v2.01 library sources, and only - used when you compile with DJGPP v2.0. */ - -#include <io.h> - -int _rename(const char *old, const char *new) -{ - __dpmi_regs r; - int olen = strlen(old) + 1; - int i; - int use_lfn = _USE_LFN; - char tempfile[FILENAME_MAX]; - const char *orig = old; - int lfn_fd = -1; - - r.x.dx = __tb_offset; - r.x.di = __tb_offset + olen; - r.x.ds = r.x.es = __tb_segment; - - if (use_lfn) - { - /* Windows 95 bug: for some filenames, when you rename - file -> file~ (as in Emacs, to leave a backup), the - short 8+3 alias doesn't change, which effectively - makes OLD and NEW the same file. We must rename - through a temporary file to work around this. */ - - char *pbase = 0, *p; - static char try_char[] = "abcdefghijklmnopqrstuvwxyz012345789"; - int idx = sizeof(try_char) - 1; - - /* Generate a temporary name. Can't use `tmpnam', since $TMPDIR - might point to another drive, which will fail the DOS call. */ - strcpy(tempfile, old); - for (p = tempfile; *p; p++) /* ensure temporary is on the same drive */ - if (*p == '/' || *p == '\\' || *p == ':') - pbase = p; - if (pbase) - pbase++; - else - pbase = tempfile; - strcpy(pbase, "X$$djren$$.$$temp$$"); - - do - { - if (idx <= 0) - return -1; - *pbase = try_char[--idx]; - } while (_chmod(tempfile, 0) != -1); - - r.x.ax = 0x7156; - _put_path2(tempfile, olen); - _put_path(old); - __dpmi_int(0x21, &r); - if (r.x.flags & 1) - { - errno = __doserr_to_errno(r.x.ax); - return -1; - } - - /* Now create a file with the original name. This will - ensure that NEW will always have a 8+3 alias - different from that of OLD. (Seems to be required - when NameNumericTail in the Registry is set to 0.) */ - lfn_fd = _creat(old, 0); - - olen = strlen(tempfile) + 1; - old = tempfile; - r.x.di = __tb_offset + olen; - } - - for (i=0; i<2; i++) - { - if(use_lfn) - r.x.ax = 0x7156; - else - r.h.ah = 0x56; - _put_path2(new, olen); - _put_path(old); - __dpmi_int(0x21, &r); - if(r.x.flags & 1) - { - if (r.x.ax == 5 && i == 0) /* access denied */ - remove(new); /* and try again */ - else - { - errno = __doserr_to_errno(r.x.ax); - - /* Restore to original name if we renamed it to temporary. */ - if (use_lfn) - { - if (lfn_fd != -1) - { - _close (lfn_fd); - remove (orig); - } - _put_path2(orig, olen); - _put_path(tempfile); - r.x.ax = 0x7156; - __dpmi_int(0x21, &r); - } - return -1; - } - } - else - break; - } - - /* Success. Delete the file possibly created to work - around the Windows 95 bug. */ - if (lfn_fd != -1) - return (_close (lfn_fd) == 0) ? remove (orig) : -1; - return 0; -} - -#endif /* __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 */ - DEFUN ("msdos-long-file-names", Fmsdos_long_file_names, Smsdos_long_file_names, 0, 0, 0, doc: /* Return non-nil if long file names are supported on MS-DOS. */) - () + (void) { return (_USE_LFN ? Qt : Qnil); } @@ -4268,8 +3936,7 @@ DEFUN ("msdos-long-file-names", Fmsdos_long_file_names, Smsdos_long_file_names, /* Convert alphabetic characters in a filename to lower-case. */ void -msdos_downcase_filename (p) - register unsigned char *p; +msdos_downcase_filename (unsigned char *p) { /* Always lower-case drive letters a-z, even if the filesystem preserves case in filenames. @@ -4295,8 +3962,7 @@ DEFUN ("msdos-downcase-filename", Fmsdos_downcase_filename, Smsdos_downcase_file When long filenames are supported, doesn't change FILENAME. If FILENAME is not a string, returns nil. The argument object is never altered--the value is a copy. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object tem; @@ -4313,8 +3979,7 @@ The argument object is never altered--the value is a copy. */) static char emacsroot[MAXPATHLEN]; char * -rootrelativepath (rel) - char *rel; +rootrelativepath (char *rel) { static char result[MAXPATHLEN + 10]; @@ -4329,10 +3994,7 @@ rootrelativepath (rel) break if one or more of these are missing. */ void -init_environment (argc, argv, skip_args) - int argc; - char **argv; - int skip_args; +init_environment (int argc, char **argv, int skip_args) { char *s, *t, *root; int len, i; @@ -4502,39 +4164,6 @@ init_environment (argc, argv, skip_args) static int break_stat; /* BREAK check mode status. */ static int stdin_stat; /* stdin IOCTL status. */ -#if __DJGPP__ < 2 - -/* These must be global. */ -static _go32_dpmi_seginfo ctrl_break_vector; -static _go32_dpmi_registers ctrl_break_regs; -static int ctrlbreakinstalled = 0; - -/* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */ - -void -ctrl_break_func (regs) - _go32_dpmi_registers *regs; -{ - Vquit_flag = Qt; -} - -void -install_ctrl_break_check () -{ - if (!ctrlbreakinstalled) - { - /* Don't press Ctrl-Break if you don't have either DPMI or Emacs - was compiler with Djgpp 1.11 maintenance level 5 or later! */ - ctrlbreakinstalled = 1; - ctrl_break_vector.pm_offset = (int) ctrl_break_func; - _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector, - &ctrl_break_regs); - _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector); - } -} - -#endif /* __DJGPP__ < 2 */ - /* Turn off Dos' Ctrl-C checking and inhibit interpretation of control chars by DOS. Determine the keyboard type. */ @@ -4547,13 +4176,10 @@ dos_ttraw (struct tty_display_info *tty) /* If we are called for the initial terminal, it's too early to do anything, and termscript isn't set up. */ if (tty->terminal->type == output_initial) - return; + return 2; break_stat = getcbrk (); setcbrk (0); -#if __DJGPP__ < 2 - install_ctrl_break_check (); -#endif if (first_time) { @@ -4585,56 +4211,30 @@ dos_ttraw (struct tty_display_info *tty) mouse_button_count = outregs.x.bx; #ifndef HAVE_X_WINDOWS -#if __DJGPP__ >= 2 /* Save the cursor shape used outside Emacs. */ outside_cursor = _farpeekw (_dos_ds, 0x460); #endif -#endif } first_time = 0; -#if __DJGPP__ >= 2 - stdin_stat = setmode (fileno (stdin), O_BINARY); return (stdin_stat != -1); } else return (setmode (fileno (stdin), O_BINARY) != -1); - -#else /* __DJGPP__ < 2 */ - - } - - /* I think it is wrong to overwrite `stdin_stat' every time - but the first one this function is called, but I don't - want to change the way it used to work in v1.x.--EZ */ - - inregs.x.ax = 0x4400; /* Get IOCTL status. */ - inregs.x.bx = 0x00; /* 0 = stdin. */ - intdos (&inregs, &outregs); - stdin_stat = outregs.h.dl; - - inregs.x.dx = stdin_stat | 0x0020; /* raw mode */ - inregs.x.ax = 0x4401; /* Set IOCTL status */ - intdos (&inregs, &outregs); - return !outregs.x.cflag; - -#endif /* __DJGPP__ < 2 */ } /* Restore status of standard input and Ctrl-C checking. */ int -dos_ttcooked () +dos_ttcooked (void) { union REGS inregs, outregs; setcbrk (break_stat); mouse_off (); -#if __DJGPP__ >= 2 - #ifndef HAVE_X_WINDOWS /* Restore the cursor shape we found on startup. */ if (outside_cursor) @@ -4646,16 +4246,6 @@ dos_ttcooked () #endif return (setmode (fileno (stdin), stdin_stat) != -1); - -#else /* not __DJGPP__ >= 2 */ - - inregs.x.ax = 0x4401; /* Set IOCTL status. */ - inregs.x.bx = 0x00; /* 0 = stdin. */ - inregs.x.dx = stdin_stat; - intdos (&inregs, &outregs); - return !outregs.x.cflag; - -#endif /* not __DJGPP__ >= 2 */ } @@ -4664,11 +4254,8 @@ dos_ttcooked () file TEMPOUT and stderr to TEMPERR. */ int -run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv) - unsigned char **argv; - const char *working_dir; - int tempin, tempout, temperr; - char **envv; +run_msdos_command (unsigned char **argv, const char *working_dir, + int tempin, int tempout, int temperr, char **envv) { char *saveargv1, *saveargv2, *lowcase_argv0, *pa, *pl; char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ @@ -4735,8 +4322,6 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv) dup2 (tempout, 1); dup2 (temperr, 2); -#if __DJGPP__ > 1 - if (msshell && !argv[3]) { /* MS-DOS native shells are too restrictive. For starters, they @@ -4777,10 +4362,7 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv) result = 0; /* emulate Unixy shell behavior with empty cmd line */ } else - -#endif /* __DJGPP__ > 1 */ - - result = spawnve (P_WAIT, argv[0], argv, envv); + result = spawnve (P_WAIT, argv[0], (char **)argv, envv); dup2 (inbak, 0); dup2 (outbak, 1); @@ -4814,98 +4396,20 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv) } void -croak (badfunc) - char *badfunc; +croak (char *badfunc) { fprintf (stderr, "%s not yet implemented\r\n", badfunc); reset_all_sys_modes (); exit (1); } -#if __DJGPP__ < 2 - -/* ------------------------- Compatibility functions ------------------- - * gethostname - * gettimeofday - */ - -/* Hostnames for a pc are not really funny, - but they are used in change log so we emulate the best we can. */ - -gethostname (p, size) - char *p; - int size; -{ - char *q = egetenv ("HOSTNAME"); - - if (!q) q = "pc"; - strcpy (p, q); - return 0; -} - -/* When time zones are set from Ms-Dos too many C-libraries are playing - tricks with time values. We solve this by defining our own version - of `gettimeofday' bypassing GO32. Our version needs to be initialized - once and after each call to `tzset' with TZ changed. That is - accomplished by aliasing tzset to init_gettimeofday. */ - -static struct tm time_rec; - -int -gettimeofday (struct timeval *tp, struct timezone *tzp) -{ - if (tp) - { - struct time t; - struct tm tm; - - gettime (&t); - if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */ - { - struct date d; - getdate (&d); - time_rec.tm_year = d.da_year - 1900; - time_rec.tm_mon = d.da_mon - 1; - time_rec.tm_mday = d.da_day; - } - - time_rec.tm_hour = t.ti_hour; - time_rec.tm_min = t.ti_min; - time_rec.tm_sec = t.ti_sec; - - tm = time_rec; - tm.tm_gmtoff = dos_timezone_offset; - - tp->tv_sec = mktime (&tm); /* may modify tm */ - tp->tv_usec = t.ti_hund * (1000000 / 100); - } - /* Ignore tzp; it's obsolescent. */ - return 0; -} - -#endif /* __DJGPP__ < 2 */ - /* - * A list of unimplemented functions that we silently ignore. + * A few unimplemented functions that we silently ignore. */ - -#if __DJGPP__ < 2 -unsigned alarm (s) unsigned s; {} -fork () { return 0; } -int kill (x, y) int x, y; { return -1; } -nice (p) int p; {} -void volatile pause () {} -sigsetmask (x) int x; { return 0; } -sigblock (mask) int mask; { return 0; } -#endif - -setpgrp () {return 0; } -setpriority (x,y,z) int x,y,z; { return 0; } - -#if __DJGPP__ > 1 -#if __DJGPP_MINOR__ < 2 - -#ifdef POSIX_SIGNALS +int setpgrp (void) {return 0; } +int setpriority (int x, int y, int z) { return 0; } + +#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 /* Augment DJGPP library POSIX signal functions. This is needed as of DJGPP v2.01, but might be in the library in later releases. */ @@ -4928,17 +4432,13 @@ static sighandler_t prev_handlers[320]; /* A signal handler which just records that a signal occurred (it will be raised later, if and when the signal is unblocked). */ static void -sig_suspender (signo) - int signo; +sig_suspender (int signo) { sigaddset (&msdos_pending_signals, signo); } int -sigprocmask (how, new_set, old_set) - int how; - const sigset_t *new_set; - sigset_t *old_set; +sigprocmask (int how, const sigset_t *new_set, sigset_t *old_set) { int signo; sigset_t new_mask; @@ -5004,14 +4504,7 @@ sigprocmask (how, new_set, old_set) return 0; } -#else /* not POSIX_SIGNALS */ - -sigsetmask (x) int x; { return 0; } -sigblock (mask) int mask; { return 0; } - -#endif /* not POSIX_SIGNALS */ #endif /* not __DJGPP_MINOR__ < 2 */ -#endif /* __DJGPP__ > 1 */ #ifndef HAVE_SELECT #include "sysselect.h" @@ -5047,10 +4540,8 @@ dos_yield_time_slice (void) /* We don't have to call timer_check here because wait_reading_process_output takes care of that. */ int -sys_select (nfds, rfds, wfds, efds, timeout) - int nfds; - SELECT_TYPE *rfds, *wfds, *efds; - EMACS_TIME *timeout; +sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, + EMACS_TIME *timeout) { int check_input; struct time t; @@ -5120,11 +4611,10 @@ sys_select (nfds, rfds, wfds, efds, timeout) #ifdef chdir #undef chdir -extern int chdir (); +extern int chdir (const char *); int -sys_chdir (path) - const char* path; +sys_chdir (const char *path) { int len = strlen (path); char *tmp = (char *)path; @@ -5153,7 +4643,7 @@ sys_chdir (path) extern void tzset (void); void -init_gettimeofday () +init_gettimeofday (void) { time_t ltm, gtm; struct tm *lstm; @@ -5171,9 +4661,7 @@ init_gettimeofday () #ifdef abort #undef abort void -dos_abort (file, line) - char *file; - int line; +dos_abort (char *file, int line) { char buffer1[200], buffer2[400]; int i, j; @@ -5189,12 +4677,11 @@ dos_abort (file, line) } #else void -abort () +abort (void) { dos_ttcooked (); ScreenSetCursor (10, 0); cputs ("\r\n\nEmacs aborted!\r\n"); -#if __DJGPP__ > 1 #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 if (screen_virtual_segment) dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X); @@ -5204,19 +4691,12 @@ abort () #else /* __DJGPP_MINOR__ >= 2 */ raise (SIGABRT); #endif /* __DJGPP_MINOR__ >= 2 */ -#endif exit (2); } #endif -/* The following variables are required so that cus-start.el won't - complain about unbound variables. */ -#ifndef subprocesses -/* Nonzero means delete a process right away if it exits (process.c). */ -static int delete_exited_processes; -#endif - -syms_of_msdos () +void +syms_of_msdos (void) { recent_doskeys = Fmake_vector (make_number (NUM_RECENT_DOSKEYS), Qnil); staticpro (&recent_doskeys); @@ -5224,7 +4704,7 @@ syms_of_msdos () #ifndef HAVE_X_WINDOWS /* The following two are from xfns.c: */ - Qreverse = intern ("reverse"); + Qreverse = intern_c_string ("reverse"); staticpro (&Qreverse); DEFVAR_LISP ("dos-unsupported-char-glyph", &Vdos_unsupported_char_glyph, @@ -5233,12 +4713,6 @@ This variable is used only by MS-DOS terminals. */); Vdos_unsupported_char_glyph = make_number ('\177'); #endif -#ifndef subprocesses - DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, - doc: /* *Non-nil means delete processes immediately when they exit. -A value of nil means don't delete them until `list-processes' is run. */); - delete_exited_processes = 0; -#endif defsubr (&Srecent_doskeys); defsubr (&Smsdos_long_file_names); diff --git a/src/msdos.h b/src/msdos.h index bf44d3a9aa4..fe9964af25e 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -23,7 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <dpmi.h> int dos_ttraw (struct tty_display_info *); -int dos_ttcooked (); +int dos_ttcooked (void); int dos_get_saved_screen (char **, int *, int *); int dos_set_keyboard (int, int); void dos_set_window_size (int *, int *); @@ -32,15 +32,13 @@ int getdefdir (int, char*); void unixtodos_filename (char *); void dostounix_filename (char *); char *rootrelativepath (char *); -void init_environment (); -void internal_terminal_init (); -void ctrl_break_func (_go32_dpmi_registers *); -void install_ctrl_break_check (); +void init_environment (int, char **, int); +void internal_terminal_init (void); extern int have_mouse; -void mouse_init (); -void mouse_on (); -void mouse_off (); +void mouse_init (void); +void mouse_on (void); +void mouse_off (void); void mouse_moveto (int, int); #ifndef HAVE_X_WINDOWS @@ -70,13 +68,12 @@ struct window; /* Defined in xfns.c; emulated on msdos.c */ -extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern int x_pixel_width P_ ((struct frame *)); -extern int x_pixel_height P_ ((struct frame *)); +extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +extern int x_pixel_width (struct frame *); +extern int x_pixel_height (struct frame *); #define XFreeGC (void) #define x_destroy_bitmap(p1,p2) -#define load_pixmap(p1,p2,p3,p4) (0) #define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9) #define DisplayWidth(p1,p2) (SELECTED_FRAME()->text_cols) #define DisplayHeight(p1,p2) (SELECTED_FRAME()->text_lines) diff --git a/src/ndir.h b/src/ndir.h index d7bac9d3fae..92d198334b7 100644 --- a/src/ndir.h +++ b/src/ndir.h @@ -32,11 +32,10 @@ typedef struct char dd_buf[DIRBLKSIZ]; /* directory block */ } DIR; /* stream data from opendir() */ -extern DIR *opendir(); -extern struct direct *readdir(); -extern long telldir(); -extern void seekdir(); -extern void closedir(); +extern DIR *opendir (char *); +extern struct direct *readdir (DIR *); +extern void seekdir (DIR *, long); +extern void closedir (DIR *); #define rewinddir( dirp ) seekdir( dirp, 0L ) diff --git a/src/ns.mk b/src/ns.mk new file mode 100644 index 00000000000..d674466a407 --- /dev/null +++ b/src/ns.mk @@ -0,0 +1,39 @@ +### autodeps.mk --- src/Makefile fragment for GNU Emacs + +## Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + +## This file is part of GNU Emacs. + +## GNU Emacs is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## GNU Emacs is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +### Commentary: + +## This is inserted in src/Makefile if HAVE_NS. + +## The only reason this is in a separate file is because $ns_appdir, +## which appears as a target, is empty on non-NS builds. Some makes +## do not like empty targets, even if they are never used. + +${ns_appdir}: ${ns_appsrc} + rm -fr ${ns_appdir} + mkdir -p ${ns_appdir} + ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - ) + +${ns_appbindir}Emacs: emacs${EXEEXT} + mkdir -p ${ns_appbindir} + cp -f emacs${EXEEXT} ${ns_appbindir}Emacs + +ns-app: ${ns_appdir} ${ns_appbindir}Emacs + +### ns.mk ends here diff --git a/src/nsfns.m b/src/nsfns.m index 7e7fd48caf0..db8bbeb5f76 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -27,7 +27,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include <config.h> #include <signal.h> #include <math.h> @@ -83,6 +83,10 @@ extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle; extern Lisp_Object Qnone; extern Lisp_Object Vframe_title_format; +/* The below are defined in frame.c. */ + +extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode; + Lisp_Object Qbuffered; Lisp_Object Qfontsize; @@ -121,7 +125,7 @@ check_ns (void) /* Nonzero if we can use mouse menus. */ int -have_menus_p () +have_menus_p (void) { return NSApp != nil; } @@ -224,7 +228,8 @@ ns_get_screen (Lisp_Object screen) else { struct ns_display_info *dpyinfo = terminal->display_info.ns; - f = (dpyinfo->x_focus_frame || dpyinfo->x_highlight_frame); + f = dpyinfo->x_focus_frame + ? dpyinfo->x_focus_frame : dpyinfo->x_highlight_frame; } return ((f && FRAME_NS_P (f)) ? [[FRAME_NS_VIEW (f) window] screen] @@ -235,8 +240,7 @@ ns_get_screen (Lisp_Object screen) /* Return the X display structure for the display named NAME. Open a new connection if necessary. */ struct ns_display_info * -ns_display_info_for_name (name) - Lisp_Object name; +ns_display_info_for_name (Lisp_Object name) { Lisp_Object names; struct ns_display_info *dpyinfo; @@ -920,9 +924,7 @@ ns_cursor_type_to_lisp (int arg) /* This is the same as the xfns.c definition. */ void -x_set_cursor_type (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { set_frame_cursor_types (f, arg); @@ -944,7 +946,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) #define Xstr(x) Str(x) static Lisp_Object -ns_appkit_version_str () +ns_appkit_version_str (void) { char tmp[80]; @@ -963,7 +965,7 @@ ns_appkit_version_str () have into a single int. For a better picture of the implementation running, use ns_appkit_version_str.*/ static int -ns_appkit_version_int () +ns_appkit_version_int (void) { #ifdef NS_IMPL_GNUSTEP return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION; @@ -1039,6 +1041,7 @@ frame_parm_handler ns_frame_parm_handlers[] = x_set_font_backend, /* generic OK */ x_set_alpha, 0, /* x_set_sticky */ + 0, /* x_set_tool_bar_position */ }; @@ -1058,8 +1061,7 @@ If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, then `default-minibuffer-frame' must be a frame whose minibuffer can be shared by the new frame. */) - (parms) - Lisp_Object parms; + (Lisp_Object parms) { static int desc_ctr = 1; struct frame *f; @@ -1154,7 +1156,7 @@ be shared by the new frame. */) f->output_method = output_ns; f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns)); - bzero (f->output_data.ns, sizeof (*(f->output_data.ns))); + memset (f->output_data.ns, 0, sizeof (*(f->output_data.ns))); FRAME_FONTSET (f) = -1; @@ -1234,10 +1236,18 @@ be shared by the new frame. */) init_frame_faces (f); - x_default_parameter (f, parms, Qmenu_bar_lines, make_number (0), "menuBar", - "menuBar", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qtool_bar_lines, make_number (0), "toolBar", - "toolBar", RES_TYPE_NUMBER); + /* The X resources controlling the menu-bar and tool-bar are + processed specially at startup, and reflected in the mode + variables; ignore them here. */ + x_default_parameter (f, parms, Qmenu_bar_lines, + NILP (Vmenu_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qtool_bar_lines, + NILP (Vtool_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title", @@ -1360,8 +1370,7 @@ be shared by the new frame. */) DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, doc: /* Set the input focus to FRAME. FRAME nil means use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f = check_ns_frame (frame); struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); @@ -1382,8 +1391,7 @@ FRAME nil means use the selected frame. */) DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, 0, 1, "", doc: /* Pop up the font panel. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { id fm; struct frame *f; @@ -1408,8 +1416,7 @@ DEFUN ("ns-popup-font-panel", Fns_popup_font_panel, Sns_popup_font_panel, DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel, 0, 1, "", doc: /* Pop up the color panel. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; @@ -1432,8 +1439,7 @@ DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0, Optional arg DIR, if non-nil, supplies a default directory. Optional arg ISLOAD, if non-nil, means read a file name for saving. Optional arg INIT, if non-nil, provides a default file name to use. */) - (prompt, dir, isLoad, init) - Lisp_Object prompt, dir, isLoad, init; + (Lisp_Object prompt, Lisp_Object dir, Lisp_Object isLoad, Lisp_Object init) { static id fileDelegate = nil; int ret; @@ -1497,8 +1503,7 @@ Optional arg INIT, if non-nil, provides a default file name to use. */) DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0, doc: /* Return the value of the property NAME of OWNER from the defaults database. If OWNER is nil, Emacs is assumed. */) - (owner, name) - Lisp_Object owner, name; + (Lisp_Object owner, Lisp_Object name) { const char *value; @@ -1522,8 +1527,7 @@ DEFUN ("ns-set-resource", Fns_set_resource, Sns_set_resource, 3, 3, 0, doc: /* Set property NAME of OWNER to VALUE, from the defaults database. If OWNER is nil, Emacs is assumed. If VALUE is nil, the default is removed. */) - (owner, name, value) - Lisp_Object owner, name, value; + (Lisp_Object owner, Lisp_Object name, Lisp_Object value) { check_ns (); if (NILP (owner)) @@ -1551,8 +1555,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, doc: /* This function is a no-op. It is only present for completeness. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); /* This function has no real equivalent under NeXTstep. Return nil to @@ -1565,8 +1568,7 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, doc: /* Return the vendor ID string of Nextstep display server DISPLAY. DISPLAY should be either a frame or a display name (a string). If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { #ifdef NS_IMPL_GNUSTEP return build_string ("GNU"); @@ -1585,8 +1587,7 @@ release number. See also the function `x-server-vendor'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { /*NOTE: it is unclear what would best correspond with "protocol"; we return 10.3, meaning Panther, since this is roughly the @@ -1604,8 +1605,7 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, doc: /* Return the number of screens on Nextstep display server DISPLAY. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { int num; @@ -1621,8 +1621,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, doc: /* Return the height of Nextstep display server DISPLAY, in millimeters. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) @@ -1635,8 +1634,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, doc: /* Return the width of Nextstep display server DISPLAY, in millimeters. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) @@ -1650,8 +1648,7 @@ DEFUN ("x-display-backing-store", Fx_display_backing_store, The value may be `buffered', `retained', or `non-retained'. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); switch ([ns_get_window (display) backingType]) @@ -1676,8 +1673,7 @@ The value is one of the symbols `static-gray', `gray-scale', `static-color', `pseudo-color', `true-color', or `direct-color'. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; check_ns (); @@ -1705,8 +1701,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be a frame, the display name as a string, or a terminal ID. If omitted or nil, the selected frame's display is used. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); switch ([ns_get_window (display) backingType]) @@ -1730,8 +1725,7 @@ DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, doc: /* Open a connection to a Nextstep display server. DISPLAY is the name of the display to connect to. Optional arguments XRM-STRING and MUST-SUCCEED are currently ignored. */) - (display, resource_string, must_succeed) - Lisp_Object display, resource_string, must_succeed; + (Lisp_Object display, Lisp_Object resource_string, Lisp_Object must_succeed) { struct ns_display_info *dpyinfo; @@ -1769,8 +1763,7 @@ DEFUN ("x-close-connection", Fx_close_connection, Sx_close_connection, 1, 1, 0, doc: /* Close the connection to the current Nextstep display server. The argument DISPLAY is currently ignored. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); /*ns_delete_terminal (dpyinfo->terminal); */ @@ -1781,7 +1774,7 @@ The argument DISPLAY is currently ignored. */) DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, doc: /* Return the list of display names that Emacs has connections to. */) - () + (void) { Lisp_Object tail, result; @@ -1796,7 +1789,7 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, DEFUN ("ns-hide-others", Fns_hide_others, Sns_hide_others, 0, 0, 0, doc: /* Hides all applications other than Emacs. */) - () + (void) { check_ns (); [NSApp hideOtherApplications: NSApp]; @@ -1809,8 +1802,7 @@ DEFUN ("ns-hide-emacs", Fns_hide_emacs, Sns_hide_emacs, Otherwise if Emacs is hidden, it is unhidden. If ON is equal to `activate', Emacs is unhidden and becomes the active application. */) - (on) - Lisp_Object on; + (Lisp_Object on) { check_ns (); if (EQ (on, intern ("activate"))) @@ -1829,7 +1821,7 @@ the active application. */) DEFUN ("ns-emacs-info-panel", Fns_emacs_info_panel, Sns_emacs_info_panel, 0, 0, 0, doc: /* Shows the 'Info' or 'About' panel for Emacs. */) - () + (void) { check_ns (); [NSApp orderFrontStandardAboutPanel: nil]; @@ -1842,8 +1834,7 @@ DEFUN ("ns-font-name", Fns_font_name, Sns_font_name, 1, 1, 0, NAME should be a string containing either the font name or an XLFD font descriptor. If string contains `fontset' and not `fontset-startup', it is left alone. */) - (name) - Lisp_Object name; + (Lisp_Object name) { char *nm; CHECK_STRING (name); @@ -1861,8 +1852,7 @@ font descriptor. If string contains `fontset' and not DEFUN ("ns-list-colors", Fns_list_colors, Sns_list_colors, 0, 1, 0, doc: /* Return a list of all available colors. The optional argument FRAME is currently ignored. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { Lisp_Object list = Qnil; NSEnumerator *colorlists; @@ -1901,7 +1891,7 @@ The optional argument FRAME is currently ignored. */) DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0, doc: /* List available Nextstep services by querying NSApp. */) - () + (void) { Lisp_Object ret = Qnil; NSMenu *svcs; @@ -1955,8 +1945,7 @@ DEFUN ("ns-perform-service", Fns_perform_service, Sns_perform_service, SEND should be either a string or nil. The return value is the result of the service, as string, or nil if there was no result. */) - (service, send) - Lisp_Object service, send; + (Lisp_Object service, Lisp_Object send) { id pb; NSString *svcName; @@ -1984,8 +1973,7 @@ there was no result. */) DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, Sns_convert_utf8_nfd_to_nfc, 1, 1, 0, doc: /* Return an NFC string that matches the UTF-8 NFD string STR. */) - (str) - Lisp_Object str; + (Lisp_Object str) { /* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping, remove this. */ @@ -2014,8 +2002,7 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc, string or a number containing the resulting script value. Otherwise, 1 is returned. */ static int -ns_do_applescript (script, result) - Lisp_Object script, *result; +ns_do_applescript (Lisp_Object script, Lisp_Object *result) { NSAppleEventDescriptor *desc; NSDictionary* errorDict; @@ -2072,8 +2059,7 @@ DEFUN ("ns-do-applescript", Fns_do_applescript, Sns_do_applescript, 1, 1, 0, If compilation and execution are successful, the resulting script value is returned as a string, a number or, in the case of other constructs, t. In case the execution fails, an error is signaled. */) - (script) - Lisp_Object script; + (Lisp_Object script) { Lisp_Object result; long status; @@ -2119,8 +2105,7 @@ check_x_display_info (Lisp_Object frame) void -x_set_scroll_bar_default_width (f) - struct frame *f; +x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT; @@ -2200,7 +2185,7 @@ x_screen_planes (struct frame *f) void -x_sync (Lisp_Object frame) +x_sync (struct frame *f) { /* XXX Not implemented XXX */ return; @@ -2218,8 +2203,7 @@ x_sync (Lisp_Object frame) DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, doc: /* Return t if the current Nextstep display supports the color COLOR. The optional argument FRAME is currently ignored. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { NSColor * col; check_ns (); @@ -2229,8 +2213,7 @@ The optional argument FRAME is currently ignored. */) DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, doc: /* Internal function called by `color-values', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { NSColor * col; CGFloat red, green, blue, alpha; @@ -2254,8 +2237,7 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; NSString *colorSpace; @@ -2276,8 +2258,7 @@ Note that color displays do support shades of gray. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { NSWindowDepth depth; check_ns (); @@ -2293,8 +2274,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) [ns_get_screen (display) frame].size.width); @@ -2307,8 +2287,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number ((int) [ns_get_screen (display) frame].size.height); @@ -2325,8 +2304,7 @@ reserved for the Mac menu, dock, and so forth. The screen queried corresponds to DISPLAY, which should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { int top; NSScreen *screen; @@ -2355,8 +2333,7 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { check_ns (); return make_number @@ -2370,12 +2347,12 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame, a display name (a string), or terminal ID. If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { + struct ns_display_info *dpyinfo; check_ns (); - struct ns_display_info *dpyinfo = check_ns_display_info (display); - + + dpyinfo = check_ns_display_info (display); /* We force 24+ bit depths to 24-bit to prevent an overflow. */ return make_number (1 << min (dpyinfo->n_planes, 24)); } @@ -2386,11 +2363,14 @@ Lisp_Object tip_frame; /* TODO: move to xdisp or similar */ static void -compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) - struct frame *f; - Lisp_Object parms, dx, dy; - int width, height; - int *root_x, *root_y; +compute_tip_xy (struct frame *f, + Lisp_Object parms, + Lisp_Object dx, + Lisp_Object dy, + int width, + int height, + int *root_x, + int *root_y) { Lisp_Object left, top; EmacsView *view = FRAME_NS_VIEW (f); @@ -2398,22 +2378,27 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) /* Start with user-specified or mouse position. */ left = Fcdr (Fassq (Qleft, parms)); - if (INTEGERP (left)) - pt.x = XINT (left); - else - pt.x = last_mouse_motion_position.x; top = Fcdr (Fassq (Qtop, parms)); - if (INTEGERP (top)) - pt.y = XINT (top); - else - pt.y = last_mouse_motion_position.y; - - /* Convert to screen coordinates */ - pt = [view convertPoint: pt toView: nil]; - pt = [[view window] convertBaseToScreen: pt]; + if (!INTEGERP (left) || !INTEGERP (top)) + { + pt = last_mouse_motion_position; + /* Convert to screen coordinates */ + pt = [view convertPoint: pt toView: nil]; + pt = [[view window] convertBaseToScreen: pt]; + } + else + { + /* Absolute coordinates. */ + pt.x = XINT (left); + pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top) + - height; + } + /* Ensure in bounds. (Note, screen origin = lower left.) */ - if (pt.x + XINT (dx) <= 0) + if (INTEGERP (left)) + *root_x = pt.x; + else if (pt.x + XINT (dx) <= 0) *root_x = 0; /* Can happen for negative dx */ else if (pt.x + XINT (dx) + width <= x_display_pixel_width (FRAME_NS_DISPLAY_INFO (f))) @@ -2426,7 +2411,9 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) /* Put it left justified on the screen -- it ought to fit that way. */ *root_x = 0; - if (pt.y - XINT (dy) - height >= 0) + if (INTEGERP (top)) + *root_y = pt.y; + else if (pt.y - XINT (dy) - height >= 0) /* It fits below the pointer. */ *root_y = pt.y - height - XINT (dy); else if (pt.y + XINT (dy) + height @@ -2461,8 +2448,7 @@ DY added (default is -10). A tooltip's maximum size is specified by `x-max-tooltip-size'. Text larger than the specified size is clipped. */) - (string, frame, parms, timeout, dx, dy) - Lisp_Object string, frame, parms, timeout, dx, dy; + (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy) { int root_x, root_y; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -2518,7 +2504,7 @@ Text larger than the specified size is clipped. */) DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, doc: /* Hide the current tooltip window, if there is any. Value is t if tooltip was open, nil otherwise. */) - () + (void) { if (ns_tooltip == nil || ![ns_tooltip isActive]) return Qnil; @@ -2608,11 +2594,11 @@ Value is t if tooltip was open, nil otherwise. */) void -syms_of_nsfns () +syms_of_nsfns (void) { int i; - Qfontsize = intern ("fontsize"); + Qfontsize = intern_c_string ("fontsize"); staticpro (&Qfontsize); DEFVAR_LISP ("ns-icon-type-alist", &Vns_icon_type_alist, diff --git a/src/nsfont.m b/src/nsfont.m index 59d5ee73db1..115986774d8 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -22,7 +22,7 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include <config.h> #include <setjmp.h> #include "lisp.h" @@ -161,7 +161,9 @@ static NSFontDescriptor /* Converts NSFont descriptor to FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, etc.. */ static Lisp_Object -ns_descriptor_to_entity (NSFontDescriptor *desc, Lisp_Object extra, char *style) +ns_descriptor_to_entity (NSFontDescriptor *desc, + Lisp_Object extra, + const char *style) { Lisp_Object font_entity = font_make_entity (); /* NSString *psName = [desc postscriptName]; */ @@ -223,7 +225,7 @@ ns_descriptor_to_entity (NSFontDescriptor *desc, Lisp_Object extra, char *style) /* Default font entity. */ static Lisp_Object -ns_fallback_entity () +ns_fallback_entity (void) { return ns_descriptor_to_entity ([[NSFont userFixedPitchFontOfSize: 0] fontDescriptor], Qnil, NULL); @@ -776,8 +778,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) xmalloc (0x100 * sizeof (struct font_metrics *)); if (!font_info->glyphs || !font_info->metrics) return Qnil; - bzero (font_info->glyphs, 0x100 * sizeof (unsigned short *)); - bzero (font_info->metrics, 0x100 * sizeof (struct font_metrics *)); + memset (font_info->glyphs, 0, 0x100 * sizeof (unsigned short *)); + memset (font_info->metrics, 0, 0x100 * sizeof (struct font_metrics *)); BLOCK_INPUT; @@ -816,8 +818,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) [font_info->nsfont retain]; /* set up ns_font (defined in nsgui.h) */ - font_info->name = (char *)xmalloc (strlen (fontName) + 1); - bcopy (fontName, font_info->name, strlen (fontName) + 1); + font_info->name = (char *)xmalloc (strlen (fontName)+1); + strcpy (font_info->name, fontName); font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask; font_info->ital = synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask); @@ -972,7 +974,7 @@ nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs, int totalWidth = 0; int i; - bzero (metrics, sizeof (struct font_metrics)); + memset (metrics, 0, sizeof (struct font_metrics)); for (i =0; i<nglyphs; i++) { @@ -1395,7 +1397,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) sfont = [font_info->nsfont screenFont]; font_info->metrics[block] = xmalloc (0x100 * sizeof (struct font_metrics)); - bzero (font_info->metrics[block], 0x100 * sizeof (struct font_metrics)); + memset (font_info->metrics[block], 0, 0x100 * sizeof (struct font_metrics)); if (!(font_info->metrics[block])) abort (); @@ -1510,7 +1512,7 @@ ns_dump_glyphstring (struct glyph_string *s) void -syms_of_nsfont () +syms_of_nsfont (void) { nsfont_driver.type = Qns; register_font_driver (&nsfont_driver, NULL); diff --git a/src/nsimage.m b/src/nsimage.m index 09a78e20809..a42950d1f52 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -27,7 +27,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include <config.h> #include <setjmp.h> #include "lisp.h" @@ -83,19 +83,21 @@ int ns_load_image (struct frame *f, struct image *img, Lisp_Object spec_file, Lisp_Object spec_data) { - NSTRACE (ns_load_image); - - EmacsImage *eImg; + EmacsImage *eImg = nil; NSSize size; - if (NILP (spec_data)) + NSTRACE (ns_load_image); + + if (STRINGP (spec_file)) { eImg = [EmacsImage allocInitFromFile: spec_file]; } - else + else if (STRINGP (spec_data)) { - NSData *data = [NSData dataWithBytes: SDATA (spec_data) - length: SBYTES (spec_data)]; + NSData *data; + + data = [NSData dataWithBytes: SDATA (spec_data) + length: SBYTES (spec_data)]; eImg = [[EmacsImage alloc] initWithData: data]; [eImg setPixmapData]; } @@ -315,9 +317,9 @@ static EmacsImage *ImageList = nil; [self addRepresentation: bmRep]; - bzero (planes[0], w*h); - bzero (planes[1], w*h); - bzero (planes[2], w*h); + memset (planes[0], 0, w*h); + memset (planes[1], 0, w*h); + memset (planes[2], 0, w*h); [self setXBMColor: [NSColor blackColor]]; return self; } @@ -379,7 +381,7 @@ static EmacsImage *ImageList = nil; [bmRep getBitmapDataPlanes: pixmapData]; for (i =0; i<4; i++) - bzero (pixmapData[i], width*height); + memset (pixmapData[i], 0, width*height); [self addRepresentation: bmRep]; return self; } diff --git a/src/nsmenu.m b/src/nsmenu.m index f85ebc165af..d0276c50bf7 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -105,7 +105,7 @@ free_frame_menubar (struct frame *f) int -popup_activated () +popup_activated (void) { return popup_activated_flag; } @@ -219,8 +219,8 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) /* Save the frame's previous menu bar contents data */ if (previous_menu_items_used) - bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, - previous_menu_items_used * sizeof (Lisp_Object)); + memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, + previous_menu_items_used * sizeof (Lisp_Object)); /* parse stage 1: extract from lisp */ save_menu_items (); @@ -509,8 +509,7 @@ set_frame_menubar (struct frame *f, int first_time, int deep_p) /* Utility (from macmenu.c): is this item a separator? */ static int -name_is_separator (name) - const char *name; +name_is_separator ( const char *name) { const char *start = name; @@ -601,9 +600,9 @@ name_is_separator (name) NSMenuItem get ignored. For now we try to display a super-single letter combo, and return the others as strings to be appended to the item title. (This is signaled by setting keyEquivModMask to 0 for now.) */ --(NSString *)parseKeyEquiv: (char *)key +-(NSString *)parseKeyEquiv: (const char *)key { - char *tpos = key; + const char *tpos = key; keyEquivModMask = NSCommandKeyMask; if (!key || !strlen (key)) @@ -720,7 +719,7 @@ name_is_separator (name) /* adds an empty submenu and returns it */ -- (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f +- (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f { NSString *titleStr = [NSString stringWithUTF8String: title]; NSMenuItem *item = [self addItemWithTitle: titleStr @@ -737,19 +736,21 @@ name_is_separator (name) keymaps: (int)keymaps { EmacsView *view = FRAME_NS_VIEW (f); + NSEvent *e, *event; + long retVal; + /* p = [view convertPoint:p fromView: nil]; */ p.y = NSHeight ([view frame]) - p.y; - NSEvent *e = [[view window] currentEvent]; - NSEvent *event = [NSEvent mouseEventWithType: NSRightMouseDown - location: p - modifierFlags: 0 - timestamp: [e timestamp] - windowNumber: [[view window] windowNumber] - context: [e context] - eventNumber: 0/*[e eventNumber] */ - clickCount: 1 - pressure: 0]; - long retVal; + e = [[view window] currentEvent]; + event = [NSEvent mouseEventWithType: NSRightMouseDown + location: p + modifierFlags: 0 + timestamp: [e timestamp] + windowNumber: [[view window] windowNumber] + context: [e context] + eventNumber: 0/*[e eventNumber] */ + clickCount: 1 + pressure: 0]; context_menu_value = -1; [NSMenu popUpContextMenu: self withEvent: event forView: view]; @@ -772,7 +773,7 @@ name_is_separator (name) Lisp_Object ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, char **error) + Lisp_Object title, const char **error) { EmacsMenu *pmenu; NSPoint p; @@ -835,7 +836,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); @@ -999,7 +1000,10 @@ free_frame_tool_bar (FRAME_PTR f) Under NS we just hide the toolbar until it might be needed again. -------------------------------------------------------------------------- */ { + BLOCK_INPUT; [[FRAME_NS_VIEW (f) toolbar] setVisible: NO]; + FRAME_TOOLBAR_HEIGHT (f) = 0; + UNBLOCK_INPUT; } void @@ -1009,8 +1013,11 @@ update_frame_tool_bar (FRAME_PTR f) -------------------------------------------------------------------------- */ { int i; - EmacsToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar]; + EmacsView *view = FRAME_NS_VIEW (f); + NSWindow *window = [view window]; + EmacsToolbar *toolbar = [view toolbar]; + BLOCK_INPUT; [toolbar clearActive]; /* update EmacsToolbar as in GtkUtils, build items list */ @@ -1026,7 +1033,7 @@ update_frame_tool_bar (FRAME_PTR f) struct image *img; Lisp_Object image; Lisp_Object helpObj; - char *helpText; + const char *helpText; /* If image is a vector, choose the image according to the button state. */ @@ -1094,6 +1101,10 @@ update_frame_tool_bar (FRAME_PTR f) [newDict release]; } + FRAME_TOOLBAR_HEIGHT (f) = + NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) + - FRAME_NS_TITLEBAR_HEIGHT (f); + UNBLOCK_INPUT; } @@ -1142,7 +1153,7 @@ update_frame_tool_bar (FRAME_PTR f) } - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx - helpText: (char *)help enabled: (BOOL)enabled + helpText: (const char *)help enabled: (BOOL)enabled { /* 1) come up w/identifier */ NSString *identifier @@ -1742,7 +1753,7 @@ void process_dialog (id window, Lisp_Object list) DEFUN ("ns-reset-menu", Fns_reset_menu, Sns_reset_menu, 0, 0, 0, doc: /* Cause the NS menu to be re-calculated. */) - () + (void) { set_frame_menubar (SELECTED_FRAME (), 1, 0); return Qnil; @@ -1772,15 +1783,14 @@ otherwise it is "Question". If the user gets rid of the dialog box without making a valid choice, for instance using the window manager, then this produces a quit and `x-popup-dialog' does not return. */) - (position, contents, header) - Lisp_Object position, contents, header; + (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { return ns_popup_dialog (position, contents, header); } DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0, doc: /* Return t if a menu or popup dialog is active. */) - () + (void) { return popup_activated () ? Qt : Qnil; } @@ -1792,13 +1802,13 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_ ========================================================================== */ void -syms_of_nsmenu () +syms_of_nsmenu (void) { defsubr (&Sx_popup_dialog); defsubr (&Sns_reset_menu); defsubr (&Smenu_or_popup_active_p); - Qdebug_on_next_call = intern ("debug-on-next-call"); + Qdebug_on_next_call = intern_c_string ("debug-on-next-call"); staticpro (&Qdebug_on_next_call); } diff --git a/src/nsselect.m b/src/nsselect.m index e4f5f0c613e..786ca36069c 100644 --- a/src/nsselect.m +++ b/src/nsselect.m @@ -27,16 +27,17 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include <config.h> #include <setjmp.h> #include "lisp.h" #include "nsterm.h" #include "termhooks.h" +#include "keyboard.h" #define CUT_BUFFER_SUPPORT -Lisp_Object QPRIMARY, QSECONDARY, QTEXT, QFILE_NAME; +Lisp_Object QCLIPBOARD, QSECONDARY, QTEXT, QFILE_NAME; static Lisp_Object Vns_sent_selection_hooks; static Lisp_Object Vns_lost_selection_hooks; @@ -45,6 +46,8 @@ static Lisp_Object Vselection_converter_alist; static Lisp_Object Qforeign_selection; +/* NSGeneralPboard is pretty much analogous to X11 CLIPBOARD */ +NSString *NXPrimaryPboard; NSString *NXSecondaryPboard; @@ -60,7 +63,8 @@ static NSString * symbol_to_nsstring (Lisp_Object sym) { CHECK_SYMBOL (sym); - if (EQ (sym, QPRIMARY)) return NSGeneralPboard; + if (EQ (sym, QCLIPBOARD)) return NSGeneralPboard; + if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; if (EQ (sym, QTEXT)) return NSStringPboardType; return [NSString stringWithUTF8String: SDATA (XSYMBOL (sym)->xname)]; @@ -71,6 +75,8 @@ static Lisp_Object ns_string_to_symbol (NSString *t) { if ([t isEqualToString: NSGeneralPboard]) + return QCLIPBOARD; + if ([t isEqualToString: NXPrimaryPboard]) return QPRIMARY; if ([t isEqualToString: NXSecondaryPboard]) return QSECONDARY; @@ -378,8 +384,7 @@ DEFUN ("x-own-selection-internal", Fx_own_selection_internal, SELECTION-NAME is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. VALUE is typically a string, or a cons of two markers, but may be anything that the functions on `selection-converter-alist' know about. */) - (selection_name, selection_value) - Lisp_Object selection_name, selection_value; + (Lisp_Object selection_name, Lisp_Object selection_value) { id pb; Lisp_Object old_value, new_value; @@ -413,8 +418,7 @@ anything that the functions on `selection-converter-alist' know about. */) DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal, Sx_disown_selection_internal, 1, 2, 0, doc: /* If we own the selection SELECTION, disown it. */) - (selection_name, time) - Lisp_Object selection_name, time; + (Lisp_Object selection_name, Lisp_Object time) { id pb; check_ns (); @@ -434,8 +438,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'.) */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { id pb; NSArray *types; @@ -458,8 +461,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'.) */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { check_ns (); CHECK_SYMBOL (selection); @@ -475,8 +477,7 @@ DEFUN ("x-get-selection-internal", Fx_get_selection_internal, SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names.) TYPE is the type of data desired, typically `STRING'. */) - (selection_name, target_type) - Lisp_Object selection_name, target_type; + (Lisp_Object selection_name, Lisp_Object target_type) { Lisp_Object val; @@ -501,8 +502,7 @@ TYPE is the type of data desired, typically `STRING'. */) DEFUN ("ns-get-cut-buffer-internal", Fns_get_cut_buffer_internal, Sns_get_cut_buffer_internal, 1, 1, 0, doc: /* Returns the value of the named cut buffer. */) - (buffer) - Lisp_Object buffer; + (Lisp_Object buffer) { id pb; check_ns (); @@ -516,8 +516,7 @@ DEFUN ("ns-rotate-cut-buffers-internal", Fns_rotate_cut_buffers_internal, doc: /* Rotate the values of the cut buffers by N steps. Positive N means move values forward, negative means backward. CURRENTLY NOT IMPLEMENTED UNDER NEXTSTEP. */ ) - (n) - Lisp_Object n; + (Lisp_Object n) { /* XXX This function is unimplemented under NeXTstep XXX */ Fsignal (Qquit, Fcons (build_string ( @@ -529,8 +528,7 @@ backward. CURRENTLY NOT IMPLEMENTED UNDER NEXTSTEP. */ ) DEFUN ("ns-store-cut-buffer-internal", Fns_store_cut_buffer_internal, Sns_store_cut_buffer_internal, 2, 2, 0, doc: /* Sets the value of the named cut buffer (typically CUT_BUFFER0). */) - (buffer, string) - Lisp_Object buffer, string; + (Lisp_Object buffer, Lisp_Object string) { id pb; check_ns (); @@ -544,16 +542,17 @@ DEFUN ("ns-store-cut-buffer-internal", Fns_store_cut_buffer_internal, void nxatoms_of_nsselect (void) { - NXSecondaryPboard = @"Selection"; + NXPrimaryPboard = @"Selection"; + NXSecondaryPboard = @"Secondary"; } void syms_of_nsselect (void) { - QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); - QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY); - QTEXT = intern ("TEXT"); staticpro (&QTEXT); - QFILE_NAME = intern ("FILE_NAME"); staticpro (&QFILE_NAME); + QCLIPBOARD = intern_c_string ("CLIPBOARD"); staticpro (&QCLIPBOARD); + QSECONDARY = intern_c_string ("SECONDARY"); staticpro (&QSECONDARY); + QTEXT = intern_c_string ("TEXT"); staticpro (&QTEXT); + QFILE_NAME = intern_c_string ("FILE_NAME"); staticpro (&QFILE_NAME); defsubr (&Sx_disown_selection_internal); defsubr (&Sx_get_selection_internal); @@ -606,7 +605,7 @@ The functions are called with one argument, the selection type\n\ \(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD')."); Vns_lost_selection_hooks = Qnil; - Qforeign_selection = intern ("foreign-selection"); + Qforeign_selection = intern_c_string ("foreign-selection"); staticpro (&Qforeign_selection); } diff --git a/src/nsterm.h b/src/nsterm.h index 01086e63b69..21b18f15cae 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "frame.h" #include "character.h" #include "font.h" +#include "sysselect.h" #ifdef HAVE_NS @@ -113,10 +114,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - initWithTitle: (NSString *)title frame: (struct frame *)f; - (void)setFrame: (struct frame *)f; - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */ -- (NSString *)parseKeyEquiv: (char *)key; +- (NSString *)parseKeyEquiv: (const char *)key; - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr; - (void)fillWithWidgetValue: (void *)wvptr; -- (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f; +- (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f; - (void) clear; - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f keymaps: (int)keymaps; @@ -143,7 +144,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - (void) clearActive; - (BOOL) changed; - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx - helpText: (char *)help + helpText: (const char *)help enabled: (BOOL)enabled; /* delegate methods */ - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar @@ -606,7 +607,7 @@ struct x_output #define NS_FACE_FOREGROUND(f) ((f)->foreground) #define NS_FACE_BACKGROUND(f) ((f)->background) #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height) -#define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) +#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height) #define FONT_WIDTH(f) ((f)->max_width) #define FONT_HEIGHT(f) ((f)->height) @@ -712,7 +713,9 @@ extern void ns_set_name_as_filename (struct frame *f); extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg); extern int -ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, +ns_defined_color (struct frame *f, + const char *name, + XColor *color_def, int alloc, char makeIndex); extern void ns_query_color (void *col, XColor *color_def, int setPixel); @@ -742,10 +745,34 @@ extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f, extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header); -/* two more prototypes that should be moved to a more general include file */ +/* More prototypes that should be moved to a more general include file */ extern void set_frame_menubar (struct frame *f, int first_time, int deep_p); extern void x_set_window_size (struct frame *f, int change_grav, int cols, int rows); +extern void x_sync (struct frame *); +extern Lisp_Object x_get_focus_frame (struct frame *); +extern void x_set_mouse_position (struct frame *f, int h, int v); +extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); +extern void x_make_frame_visible (struct frame *f); +extern void x_make_frame_invisible (struct frame *f); +extern void x_iconify_frame (struct frame *f); +extern int x_char_width (struct frame *f); +extern int x_char_height (struct frame *f); +extern int x_pixel_width (struct frame *f); +extern int x_pixel_height (struct frame *f); +extern void x_set_frame_alpha (struct frame *f); +extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +extern void x_set_tool_bar_lines (struct frame *f, + Lisp_Object value, + Lisp_Object oldval); +extern void x_activate_menubar (struct frame *); +extern void free_frame_menubar (struct frame *); + +extern void ns_init_paths (void); +extern void syms_of_nsterm (void); +extern void syms_of_nsfns (void); +extern void syms_of_nsmenu (void); +extern void syms_of_nsselect (void); /* From nsimage.m, needed in image.c */ struct image; @@ -760,10 +787,12 @@ extern unsigned long ns_get_pixel (void *img, int x, int y); extern void ns_put_pixel (void *img, int x, int y, unsigned long argb); extern void ns_set_alpha (void *img, int x, int y, unsigned char a); -extern int x_display_pixel_height P_ ((struct ns_display_info *)); -extern int x_display_pixel_width P_ ((struct ns_display_info *)); +extern int x_display_pixel_height (struct ns_display_info *); +extern int x_display_pixel_width (struct ns_display_info *); /* This in nsterm.m */ +extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); extern unsigned long ns_get_rgb_color (struct frame *f, float r, float g, float b, float a); extern NSPoint last_mouse_motion_position; diff --git a/src/nsterm.m b/src/nsterm.m index d1b984d5382..247ef4dd40c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -27,7 +27,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include <config.h> #include <math.h> #include <sys/types.h> @@ -306,7 +306,7 @@ append2 (Lisp_Object list, Lisp_Object item) void -ns_init_paths () +ns_init_paths (void) /* -------------------------------------------------------------------------- Used to allow emacs to find its resources under Emacs.app Called from emacs.c at startup. @@ -489,7 +489,7 @@ ns_retain_object (void *obj) void * -ns_alloc_autorelease_pool () +ns_alloc_autorelease_pool (void) /* -------------------------------------------------------------------------- Allocate a pool for temporary objects (callable from C) -------------------------------------------------------------------------- */ @@ -800,7 +800,7 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, int area, BOOL gc) static void -ns_ring_bell () +ns_ring_bell (struct frame *f) /* -------------------------------------------------------------------------- "Beep" routine -------------------------------------------------------------------------- */ @@ -1148,15 +1148,15 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) /* NOTE: previously this would generate wrong result if toolbar not yet displayed and fixing toolbar_height=32 helped, but now (200903) seems no longer needed */ - FRAME_NS_TOOLBAR_HEIGHT (f) = + FRAME_TOOLBAR_HEIGHT (f) = NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)]) - FRAME_NS_TITLEBAR_HEIGHT (f); else - FRAME_NS_TOOLBAR_HEIGHT (f) = 0; + FRAME_TOOLBAR_HEIGHT (f) = 0; wr.size.width = pixelwidth + f->border_width; wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f) - + FRAME_NS_TOOLBAR_HEIGHT (f); + + FRAME_TOOLBAR_HEIGHT (f); /* constrain to screen if we can */ if (screen) @@ -1196,12 +1196,14 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows) difference between the real width and Emacs' imagined one. For right-hand bars, don't worry about it since the extra is never used. (Obviously doesn't work for vertically split windows tho..) */ - NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) - ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) - - NS_SCROLL_BAR_WIDTH (f), 0) - : NSMakePoint (0, 0); - [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)]; - [view setBoundsOrigin: origin]; + { + NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) + ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) + - NS_SCROLL_BAR_WIDTH (f), 0) + : NSMakePoint (0, 0); + [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)]; + [view setBoundsOrigin: origin]; + } change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */ FRAME_PIXEL_WIDTH (f) = pixelwidth; @@ -1517,7 +1519,10 @@ ns_query_color(void *col, XColor *color_def, int setPixel) int -ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc, +ns_defined_color (struct frame *f, + const char *name, + XColor *color_def, + int alloc, char makeIndex) /* -------------------------------------------------------------------------- Return 1 if named color found, and set color_def rgb accordingly. @@ -1797,6 +1802,9 @@ ns_define_frame_cursor (struct frame *f, Cursor cursor) EmacsView *view = FRAME_NS_VIEW (f); FRAME_POINTER_TYPE (f) = cursor; [[view window] invalidateCursorRectsForView: view]; + /* Redisplay assumes this function also draws the changed frame + cursor, but this function doesn't, so do it explicitly. */ + x_update_cursor (f, 1); } } @@ -2173,11 +2181,11 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, { EmacsImage **newBimgs = xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *)); - bzero (newBimgs, max_used_fringe_bitmap * sizeof (EmacsImage *)); + memset (newBimgs, 0, max_used_fringe_bitmap * sizeof (EmacsImage *)); if (nBimgs) { - bcopy (bimgs, newBimgs, nBimgs * sizeof (EmacsImage *)); + memcpy (newBimgs, bimgs, nBimgs * sizeof (EmacsImage *)); xfree (bimgs); } @@ -2194,9 +2202,8 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ? -FRAME_INTERNAL_BORDER_WIDTH (f) : 0; int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ? - FRAME_INTERNAL_BORDER_WIDTH (f) : 0; - if (yAdjust) - yIncr += FRAME_INTERNAL_BORDER_WIDTH (f); + FRAME_INTERNAL_BORDER_WIDTH (f) : 0 + + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0); NSRect r = NSMakeRect (p->bx+xAdjust, p->by+yAdjust, p->nx, p->ny+yIncr); NSRectClip (r); [ns_lookup_indexed_color(face->background, f) set]; @@ -2254,6 +2261,11 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, struct frame *f = WINDOW_XFRAME (w); struct glyph *phys_cursor_glyph; int overspill; + struct glyph *cursor_glyph; + + /* If cursor is out of bounds, don't draw garbage. This can happen + in mini-buffer windows when switching between echo area glyphs + and mini-buffer. */ NSTRACE (dumpcursor); //fprintf(stderr, "drawcursor (%d,%d) activep = %d\tonp = %d\tc_type = %d\twidth = %d\n",x,y, active_p,on_p,cursor_type,cursor_width); @@ -2331,6 +2343,13 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, case BAR_CURSOR: s = r; s.size.width = min (cursor_width, 2); //FIXME(see above) + + /* If the character under cursor is R2L, draw the bar cursor + on the right of its glyph, rather than on the left. */ + cursor_glyph = get_phys_cursor_glyph (w); + if ((cursor_glyph->resolved_level & 1) != 0) + s.origin.x += cursor_glyph->pixel_width - s.size.width; + NSRectFill (s); break; } @@ -2385,7 +2404,7 @@ show_hourglass (struct atimer *timer) void -hide_hourglass () +hide_hourglass (void) { if (!hourglass_shown_p) return; @@ -3416,16 +3435,14 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) ========================================================================== */ int -x_display_pixel_height (dpyinfo) - struct ns_display_info *dpyinfo; +x_display_pixel_height (struct ns_display_info *dpyinfo) { NSScreen *screen = [NSScreen mainScreen]; return [screen frame].size.height; } int -x_display_pixel_width (dpyinfo) - struct ns_display_info *dpyinfo; +x_display_pixel_width (struct ns_display_info *dpyinfo) { NSScreen *screen = [NSScreen mainScreen]; return [screen frame].size.width; @@ -3704,7 +3721,7 @@ ns_term_init (Lisp_Object display_name) name: nil object: nil]; */ dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info)); - bzero (dpyinfo, sizeof (struct ns_display_info)); + memset (dpyinfo, 0, sizeof (struct ns_display_info)); ns_initialize_display_info (dpyinfo); terminal = ns_create_terminal (dpyinfo); @@ -4897,16 +4914,16 @@ ns_term_shutdown (int sig) rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, frameSize.height #ifdef NS_IMPL_GNUSTEP - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + 3 - - FRAME_NS_TOOLBAR_HEIGHT (emacsframe)); + - FRAME_TOOLBAR_HEIGHT (emacsframe)); #else - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) - - FRAME_NS_TOOLBAR_HEIGHT (emacsframe)); + - FRAME_TOOLBAR_HEIGHT (emacsframe)); #endif if (rows < MINHEIGHT) rows = MINHEIGHT; frameSize.height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (emacsframe, rows) + FRAME_NS_TITLEBAR_HEIGHT (emacsframe) - + FRAME_NS_TOOLBAR_HEIGHT (emacsframe); + + FRAME_TOOLBAR_HEIGHT (emacsframe); #ifdef NS_IMPL_COCOA { /* this sets window title to have size in it; the wm does this under GS */ @@ -5117,7 +5134,7 @@ ns_term_shutdown (int sig) [toggleButton setTarget: self]; [toggleButton setAction: @selector (toggleToolbar: )]; #endif - FRAME_NS_TOOLBAR_HEIGHT (f) = 0; + FRAME_TOOLBAR_HEIGHT (f) = 0; tem = f->icon_name; if (!NILP (tem)) @@ -5759,9 +5776,10 @@ ns_term_shutdown (int sig) NSTRACE (judge); if (condemned) { + EmacsView *view; BLOCK_INPUT; /* ensure other scrollbar updates after deletion */ - EmacsView *view = (EmacsView *)FRAME_NS_VIEW (frame); + view = (EmacsView *)FRAME_NS_VIEW (frame); if (view != nil) view->scrollbarsNeedingUpdate++; [self removeFromSuperview]; @@ -6138,7 +6156,7 @@ ns_xlfd_to_fontname (const char *xlfd) void -syms_of_nsterm () +syms_of_nsterm (void) { NSTRACE (syms_of_nsterm); diff --git a/src/point.h b/src/point.h deleted file mode 100644 index 0156e1baed2..00000000000 --- a/src/point.h +++ /dev/null @@ -1,8 +0,0 @@ -#define point_width 5 -#define point_height 19 -static char point_bits[] = { - 0x1f, 0x0e, 0x0e, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x04, 0x0e, 0x0e, 0x1f}; - -/* arch-tag: a8dad510-7254-4964-b71e-bb6f81cce572 - (do not change this comment) */ diff --git a/src/prefix-args.c b/src/prefix-args.c deleted file mode 100644 index d29085a3dff..00000000000 --- a/src/prefix-args.c +++ /dev/null @@ -1,84 +0,0 @@ -/* prefix-args.c - echo each argument, prefixed by a string. - Copyright (C) 1992, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* Jim Blandy <jimb@occs.cs.oberlin.edu> - September 1992 - - When using GCC 2 as the linker in the build process, options - intended for the linker need to be prefixed with the "-Xlinker" - option. If an option takes an argument, we need to use -Xlinker - twice - once for the option and once for its argument. For - example, to run the linker with the options "-Bstatic" "-e" - "_start", you'd need to pass the following options to GCC: - - -Xlinker -Bstatic -Xlinker -e -Xlinker _start. - - The Emacs makefile used to use a Bourne Shell `for' loop to prefix - each linker option with "-Xlinker", but 1) the for loop was hairier - than one might hope because it had to work when there were no - arguments to pass to the linker - the shell barfs on a loop like - this: - - for arg in ; do echo -Xlinker "$arg"; done - - and 2) the whole compilation command containing this loop seems to - exit with a non-zero status and halt the build under Ultrix. - - If I can't write a completely portable program to do this in C, - I'm quitting and taking up gardening. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if STDC_HEADERS -# include <stdlib.h> /* for proper declaration of `exit' */ -#endif - -#include <stdio.h> -#include <stdlib.h> - -int -main (argc, argv) - int argc; - char **argv; -{ - char *progname; - char *prefix; - - progname = argv[0]; - argc--, argv++; - - if (argc < 1) - { - fprintf (stderr, "Usage: %s PREFIX ARGS...\n\ -Echo each ARG preceded by PREFIX and a space.\n", progname); - exit (2); - } - - prefix = argv[0]; - argc--, argv++; - - for (; argc > 0; argc--, argv++) - printf ("%s %s%c", prefix, argv[0], (argc > 1) ? ' ' : '\n'); - - exit (0); -} - -/* arch-tag: 08136d70-e5c0-49c7-bcd8-b4850233977a - (do not change this comment) */ diff --git a/src/print.c b/src/print.c index 43f17a7c15d..ea88ba72f65 100644 --- a/src/print.c +++ b/src/print.c @@ -42,7 +42,6 @@ Lisp_Object Vstandard_output, Qstandard_output; Lisp_Object Qtemp_buffer_setup_hook; /* These are used to print like we read. */ -extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; Lisp_Object Vfloat_output_format, Qfloat_output_format; @@ -97,11 +96,11 @@ Lisp_Object being_printed[PRINT_CIRCLE]; char *print_buffer; /* Size allocated in print_buffer. */ -int print_buffer_size; +EMACS_INT print_buffer_size; /* Chars stored in print_buffer. */ -int print_buffer_pos; +EMACS_INT print_buffer_pos; /* Bytes stored in print_buffer. */ -int print_buffer_pos_byte; +EMACS_INT print_buffer_pos_byte; /* Maximum length of list to print in full; noninteger means effectively infinity */ @@ -161,14 +160,7 @@ Lisp_Object Vprint_number_table; #define PRINT_NUMBER_OBJECT(table,i) XVECTOR ((table))->contents[(i) * 2] #define PRINT_NUMBER_STATUS(table,i) XVECTOR ((table))->contents[(i) * 2 + 1] -/* Nonzero means print newline to stdout before next minibuffer message. - Defined in xdisp.c */ - -extern int noninteractive_need_newline; - -extern int minibuffer_auto_raise; - -void print_interval (); +void print_interval (INTERVAL interval, Lisp_Object printcharfun); /* GDB resets this to zero on W32 to disable OutputDebugString calls. */ int print_output_debug_flag = 1; @@ -185,8 +177,8 @@ int print_output_debug_flag = 1; #define PRINTDECLARE \ struct buffer *old = current_buffer; \ - int old_point = -1, start_point = -1; \ - int old_point_byte = -1, start_point_byte = -1; \ + EMACS_INT old_point = -1, start_point = -1; \ + EMACS_INT old_point_byte = -1, start_point_byte = -1; \ int specpdl_count = SPECPDL_INDEX (); \ int free_print_buffer = 0; \ int multibyte = !NILP (current_buffer->enable_multibyte_characters); \ @@ -287,10 +279,9 @@ int print_output_debug_flag = 1; when there is a recursive call to print. */ static Lisp_Object -print_unwind (saved_text) - Lisp_Object saved_text; +print_unwind (Lisp_Object saved_text) { - bcopy (SDATA (saved_text), print_buffer, SCHARS (saved_text)); + memcpy (print_buffer, SDATA (saved_text), SCHARS (saved_text)); return Qnil; } @@ -301,9 +292,7 @@ print_unwind (saved_text) argument. */ static void -printchar (ch, fun) - unsigned int ch; - Lisp_Object fun; +printchar (unsigned int ch, Lisp_Object fun) { if (!NILP (fun) && !EQ (fun, Qt)) call1 (fun, make_number (ch)); @@ -319,7 +308,7 @@ printchar (ch, fun) if (print_buffer_pos_byte + len >= print_buffer_size) print_buffer = (char *) xrealloc (print_buffer, print_buffer_size *= 2); - bcopy (str, print_buffer + print_buffer_pos_byte, len); + memcpy (print_buffer + print_buffer_pos_byte, str, len); print_buffer_pos += 1; print_buffer_pos_byte += len; } @@ -353,11 +342,8 @@ printchar (ch, fun) to data in a Lisp string. Otherwise that is not safe. */ static void -strout (ptr, size, size_byte, printcharfun, multibyte) - char *ptr; - int size, size_byte; - Lisp_Object printcharfun; - int multibyte; +strout (const char *ptr, EMACS_INT size, EMACS_INT size_byte, + Lisp_Object printcharfun, int multibyte) { if (size < 0) size_byte = size = strlen (ptr); @@ -370,7 +356,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte) print_buffer = (char *) xrealloc (print_buffer, print_buffer_size); } - bcopy (ptr, print_buffer + print_buffer_pos_byte, size_byte); + memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte); print_buffer_pos += size; print_buffer_pos_byte += size_byte; } @@ -409,7 +395,7 @@ strout (ptr, size, size_byte, printcharfun, multibyte) else { /* PRINTCHARFUN is a Lisp function. */ - int i = 0; + EMACS_INT i = 0; if (size == size_byte) { @@ -440,13 +426,11 @@ strout (ptr, size, size_byte, printcharfun, multibyte) because printing one char can relocate. */ static void -print_string (string, printcharfun) - Lisp_Object string; - Lisp_Object printcharfun; +print_string (Lisp_Object string, Lisp_Object printcharfun) { if (EQ (printcharfun, Qt) || NILP (printcharfun)) { - int chars; + EMACS_INT chars; if (print_escape_nonascii) string = string_escape_byte8 (string); @@ -462,14 +446,14 @@ print_string (string, printcharfun) convert STRING to a multibyte string containing the same character codes. */ Lisp_Object newstr; - int bytes; + EMACS_INT bytes; chars = SBYTES (string); bytes = parse_str_to_multibyte (SDATA (string), chars); if (chars < bytes) { newstr = make_uninit_multibyte_string (chars, bytes); - bcopy (SDATA (string), SDATA (newstr), chars); + memcpy (SDATA (newstr), SDATA (string), chars); str_to_multibyte (SDATA (newstr), bytes, chars); string = newstr; } @@ -480,7 +464,7 @@ print_string (string, printcharfun) if (EQ (printcharfun, Qt)) { /* Output to echo area. */ - int nbytes = SBYTES (string); + EMACS_INT nbytes = SBYTES (string); char *buffer; /* Copy the string contents so that relocation of STRING by @@ -488,7 +472,7 @@ print_string (string, printcharfun) USE_SAFE_ALLOCA; SAFE_ALLOCA (buffer, char *, nbytes); - bcopy (SDATA (string), buffer, nbytes); + memcpy (buffer, SDATA (string), nbytes); strout (buffer, chars, SBYTES (string), printcharfun, STRING_MULTIBYTE (string)); @@ -505,9 +489,9 @@ print_string (string, printcharfun) { /* Otherwise, string may be relocated by printing one char. So re-fetch the string address for each character. */ - int i; - int size = SCHARS (string); - int size_byte = SBYTES (string); + EMACS_INT i; + EMACS_INT size = SCHARS (string); + EMACS_INT size_byte = SBYTES (string); struct gcpro gcpro1; GCPRO1 (string); if (size == size_byte) @@ -530,8 +514,7 @@ print_string (string, printcharfun) DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0, doc: /* Output character CHARACTER to stream PRINTCHARFUN. PRINTCHARFUN defaults to the value of `standard-output' (which see). */) - (character, printcharfun) - Lisp_Object character, printcharfun; + (Lisp_Object character, Lisp_Object printcharfun) { PRINTDECLARE; @@ -549,9 +532,7 @@ PRINTCHARFUN defaults to the value of `standard-output' (which see). */) Do not use this on the contents of a Lisp string. */ void -write_string (data, size) - char *data; - int size; +write_string (const char *data, int size) { PRINTDECLARE; Lisp_Object printcharfun; @@ -568,10 +549,7 @@ write_string (data, size) Do not use this on the contents of a Lisp string. */ void -write_string_1 (data, size, printcharfun) - char *data; - int size; - Lisp_Object printcharfun; +write_string_1 (const char *data, int size, Lisp_Object printcharfun) { PRINTDECLARE; @@ -582,8 +560,7 @@ write_string_1 (data, size, printcharfun) void -temp_output_buffer_setup (bufname) - const char *bufname; +temp_output_buffer_setup (const char *bufname) { int count = SPECPDL_INDEX (); register struct buffer *old = current_buffer; @@ -616,10 +593,7 @@ temp_output_buffer_setup (bufname) } Lisp_Object -internal_with_output_to_temp_buffer (bufname, function, args) - const char *bufname; - Lisp_Object (*function) P_ ((Lisp_Object)); - Lisp_Object args; +internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args) { int count = SPECPDL_INDEX (); Lisp_Object buf, val; @@ -670,8 +644,7 @@ temporarily selected. But it doesn't run `temp-buffer-show-hook' if it uses `temp-buffer-show-function'. usage: (with-output-to-temp-buffer BUFNAME BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { struct gcpro gcpro1; Lisp_Object name; @@ -695,16 +668,15 @@ usage: (with-output-to-temp-buffer BUFNAME BODY...) */) } -static void print (); -static void print_preprocess (); -static void print_preprocess_string (); -static void print_object (); +static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); +static void print_preprocess (Lisp_Object obj); +static void print_preprocess_string (INTERVAL interval, Lisp_Object arg); +static void print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, doc: /* Output a newline to stream PRINTCHARFUN. If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */) - (printcharfun) - Lisp_Object printcharfun; + (Lisp_Object printcharfun) { PRINTDECLARE; @@ -739,8 +711,7 @@ of these: If PRINTCHARFUN is omitted, the value of `standard-output' (which see) is used instead. */) - (object, printcharfun) - Lisp_Object object, printcharfun; + (Lisp_Object object, Lisp_Object printcharfun) { PRINTDECLARE; @@ -766,8 +737,7 @@ OBJECT is any of the Lisp data types: a number, a string, a symbol, a list, a buffer, a window, a frame, etc. A printed representation of an object is text which describes that object. */) - (object, noescape) - Lisp_Object object, noescape; + (Lisp_Object object, Lisp_Object noescape) { Lisp_Object printcharfun; /* struct gcpro gcpro1, gcpro2; */ @@ -835,8 +805,7 @@ of these: If PRINTCHARFUN is omitted, the value of `standard-output' (which see) is used instead. */) - (object, printcharfun) - Lisp_Object object, printcharfun; + (Lisp_Object object, Lisp_Object printcharfun) { PRINTDECLARE; @@ -871,8 +840,7 @@ of these: If PRINTCHARFUN is omitted, the value of `standard-output' (which see) is used instead. */) - (object, printcharfun) - Lisp_Object object, printcharfun; + (Lisp_Object object, Lisp_Object printcharfun) { PRINTDECLARE; struct gcpro gcpro1; @@ -897,11 +865,10 @@ DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugg doc: /* Write CHARACTER to stderr. You can call print while debugging emacs, and pass it this function to make it write to the debugging output. */) - (character) - Lisp_Object character; + (Lisp_Object character) { CHECK_NUMBER (character); - putc (XINT (character), stderr); + putc ((int) XINT (character), stderr); #ifdef WINDOWSNT /* Send the output to a debugger (nothing happens if there isn't one). */ @@ -919,8 +886,7 @@ to make it write to the debugging output. */) print_output_debug_flag from being optimized away. */ void -debug_output_compilation_hack (x) - int x; +debug_output_compilation_hack (int x) { print_output_debug_flag = x; } @@ -941,8 +907,7 @@ DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugg If FILE is nil, reset target to the initial stderr stream. Optional arg APPEND non-nil (interactively, with prefix arg) means append to existing target file. */) - (file, append) - Lisp_Object file, append; + (Lisp_Object file, Lisp_Object append) { if (initial_stderr_stream != NULL) { @@ -974,16 +939,14 @@ append to existing target file. */) /* This is the interface for debugging printing. */ void -debug_print (arg) - Lisp_Object arg; +debug_print (Lisp_Object arg) { Fprin1 (arg, Qexternal_debugging_output); fprintf (stderr, "\r\n"); } void -safe_debug_print (arg) - Lisp_Object arg; +safe_debug_print (Lisp_Object arg) { int valid = valid_lisp_object_p (arg); @@ -1002,8 +965,7 @@ DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, doc: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message. See Info anchor `(elisp)Definition of signal' for some details on how this error message is constructed. */) - (obj) - Lisp_Object obj; + (Lisp_Object obj) { struct buffer *old = current_buffer; Lisp_Object value; @@ -1037,10 +999,8 @@ error message is constructed. */) CALLER is the Lisp function inside which the error was signaled. */ void -print_error_message (data, stream, context, caller) - Lisp_Object data, stream; - char *context; - Lisp_Object caller; +print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, + Lisp_Object caller) { Lisp_Object errname, errmsg, file_error, tail; struct gcpro gcpro1; @@ -1055,7 +1015,7 @@ print_error_message (data, stream, context, caller) { Lisp_Object cname = SYMBOL_NAME (caller); char *name = alloca (SBYTES (cname)); - bcopy (SDATA (cname), name, SBYTES (cname)); + memcpy (name, SDATA (cname), SBYTES (cname)); message_dolog (name, SBYTES (cname), 0, 0); message_dolog (": ", 2, 0, 0); } @@ -1125,9 +1085,7 @@ print_error_message (data, stream, context, caller) */ void -float_to_string (buf, data) - unsigned char *buf; - double data; +float_to_string (unsigned char *buf, double data) { unsigned char *cp; int width; @@ -1250,10 +1208,7 @@ float_to_string (buf, data) static void -print (obj, printcharfun, escapeflag) - Lisp_Object obj; - register Lisp_Object printcharfun; - int escapeflag; +print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag) { new_backquote_output = 0; @@ -1312,8 +1267,7 @@ print (obj, printcharfun, escapeflag) The status fields of Vprint_number_table mean whether each object appears more than once in OBJ: Qnil at the first time, and Qt after that . */ static void -print_preprocess (obj) - Lisp_Object obj; +print_preprocess (Lisp_Object obj) { int i; EMACS_INT size; @@ -1433,9 +1387,7 @@ print_preprocess (obj) } static void -print_preprocess_string (interval, arg) - INTERVAL interval; - Lisp_Object arg; +print_preprocess_string (INTERVAL interval, Lisp_Object arg) { print_preprocess (interval->plist); } @@ -1443,9 +1395,8 @@ print_preprocess_string (interval, arg) /* A flag to control printing of `charset' text property. The default value is Qdefault. */ Lisp_Object Vprint_charset_text_property; -extern Lisp_Object Qdefault; -static void print_check_string_charset_prop (); +static void print_check_string_charset_prop (INTERVAL interval, Lisp_Object string); #define PRINT_STRING_NON_CHARSET_FOUND 1 #define PRINT_STRING_UNSAFE_CHARSET_FOUND 2 @@ -1454,9 +1405,7 @@ static void print_check_string_charset_prop (); static int print_check_string_result; static void -print_check_string_charset_prop (interval, string) - INTERVAL interval; - Lisp_Object string; +print_check_string_charset_prop (INTERVAL interval, Lisp_Object string) { Lisp_Object val; @@ -1481,8 +1430,8 @@ print_check_string_charset_prop (interval, string) || ! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) { int i, c; - int charpos = interval->position; - int bytepos = string_char_to_byte (string, charpos); + EMACS_INT charpos = interval->position; + EMACS_INT bytepos = string_char_to_byte (string, charpos); Lisp_Object charset; charset = XCAR (XCDR (val)); @@ -1503,8 +1452,7 @@ print_check_string_charset_prop (interval, string) static Lisp_Object print_prune_charset_plist; static Lisp_Object -print_prune_string_charset (string) - Lisp_Object string; +print_prune_string_charset (Lisp_Object string) { print_check_string_result = 0; traverse_intervals (STRING_INTERVALS (string), 0, @@ -1528,10 +1476,7 @@ print_prune_string_charset (string) } static void -print_object (obj, printcharfun, escapeflag) - Lisp_Object obj; - register Lisp_Object printcharfun; - int escapeflag; +print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag) { char buf[40]; @@ -1618,10 +1563,10 @@ print_object (obj, printcharfun, escapeflag) print_string (obj, printcharfun); else { - register int i, i_byte; + register EMACS_INT i, i_byte; struct gcpro gcpro1; unsigned char *str; - int size_byte; + EMACS_INT size_byte; /* 1 means we must ensure that the next character we output cannot be taken as part of a hex character escape. */ int need_nonhex = 0; @@ -1739,7 +1684,8 @@ print_object (obj, printcharfun, escapeflag) register unsigned char *p = SDATA (SYMBOL_NAME (obj)); register unsigned char *end = p + SBYTES (SYMBOL_NAME (obj)); register int c; - int i, i_byte, size_byte; + int i, i_byte; + EMACS_INT size_byte; Lisp_Object name; name = SYMBOL_NAME (obj); @@ -1858,7 +1804,8 @@ print_object (obj, printcharfun, escapeflag) } { - int print_length, i; + EMACS_INT print_length; + int i; Lisp_Object halftail = obj; /* Negative values of print-length are invalid in CL. @@ -1953,7 +1900,7 @@ print_object (obj, printcharfun, escapeflag) register int i; register unsigned char c; struct gcpro gcpro1; - int size_in_chars + EMACS_INT size_in_chars = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) / BOOL_VECTOR_BITS_PER_CHAR); @@ -2039,7 +1986,8 @@ print_object (obj, printcharfun, escapeflag) else if (HASH_TABLE_P (obj)) { struct Lisp_Hash_Table *h = XHASH_TABLE (obj); - int i, real_size, size; + int i; + EMACS_INT real_size, size; #if 0 strout ("#<hash-table", -1, -1, printcharfun, 0); if (SYMBOLP (h->test)) @@ -2205,7 +2153,7 @@ print_object (obj, printcharfun, escapeflag) { register int i; register Lisp_Object tem; - int real_size = size; + EMACS_INT real_size = size; /* Don't print more elements than the specified maximum. */ if (NATNUMP (Vprint_length) @@ -2237,7 +2185,7 @@ print_object (obj, printcharfun, escapeflag) strout ("in no buffer", -1, -1, printcharfun, 0); else { - sprintf (buf, "at %d", marker_position (obj)); + sprintf (buf, "at %ld", (long)marker_position (obj)); strout (buf, -1, -1, printcharfun, 0); strout (" in ", -1, -1, printcharfun, 0); print_string (XMARKER (obj)->buffer->name, printcharfun); @@ -2251,9 +2199,9 @@ print_object (obj, printcharfun, escapeflag) strout ("in no buffer", -1, -1, printcharfun, 0); else { - sprintf (buf, "from %d to %d in ", - marker_position (OVERLAY_START (obj)), - marker_position (OVERLAY_END (obj))); + sprintf (buf, "from %ld to %ld in ", + (long)marker_position (OVERLAY_START (obj)), + (long)marker_position (OVERLAY_END (obj))); strout (buf, -1, -1, printcharfun, 0); print_string (XMARKER (OVERLAY_START (obj))->buffer->name, printcharfun); @@ -2267,70 +2215,6 @@ print_object (obj, printcharfun, escapeflag) strout ("#<misc free cell>", -1, -1, printcharfun, 0); break; - case Lisp_Misc_Intfwd: - sprintf (buf, "#<intfwd to %ld>", (long) *XINTFWD (obj)->intvar); - strout (buf, -1, -1, printcharfun, 0); - break; - - case Lisp_Misc_Boolfwd: - sprintf (buf, "#<boolfwd to %s>", - (*XBOOLFWD (obj)->boolvar ? "t" : "nil")); - strout (buf, -1, -1, printcharfun, 0); - break; - - case Lisp_Misc_Objfwd: - strout ("#<objfwd to ", -1, -1, printcharfun, 0); - print_object (*XOBJFWD (obj)->objvar, printcharfun, escapeflag); - PRINTCHAR ('>'); - break; - - case Lisp_Misc_Buffer_Objfwd: - strout ("#<buffer_objfwd to ", -1, -1, printcharfun, 0); - print_object (PER_BUFFER_VALUE (current_buffer, - XBUFFER_OBJFWD (obj)->offset), - printcharfun, escapeflag); - PRINTCHAR ('>'); - break; - - case Lisp_Misc_Kboard_Objfwd: - strout ("#<kboard_objfwd to ", -1, -1, printcharfun, 0); - print_object (*(Lisp_Object *) ((char *) current_kboard - + XKBOARD_OBJFWD (obj)->offset), - printcharfun, escapeflag); - PRINTCHAR ('>'); - break; - - case Lisp_Misc_Buffer_Local_Value: - strout ("#<buffer_local_value ", -1, -1, printcharfun, 0); - if (XBUFFER_LOCAL_VALUE (obj)->local_if_set) - strout ("[local-if-set] ", -1, -1, printcharfun, 0); - strout ("[realvalue] ", -1, -1, printcharfun, 0); - print_object (XBUFFER_LOCAL_VALUE (obj)->realvalue, - printcharfun, escapeflag); - if (XBUFFER_LOCAL_VALUE (obj)->found_for_buffer) - strout ("[local in buffer] ", -1, -1, printcharfun, 0); - else - strout ("[buffer] ", -1, -1, printcharfun, 0); - print_object (XBUFFER_LOCAL_VALUE (obj)->buffer, - printcharfun, escapeflag); - if (XBUFFER_LOCAL_VALUE (obj)->check_frame) - { - if (XBUFFER_LOCAL_VALUE (obj)->found_for_frame) - strout ("[local in frame] ", -1, -1, printcharfun, 0); - else - strout ("[frame] ", -1, -1, printcharfun, 0); - print_object (XBUFFER_LOCAL_VALUE (obj)->frame, - printcharfun, escapeflag); - } - strout ("[alist-elt] ", -1, -1, printcharfun, 0); - print_object (XCAR (XBUFFER_LOCAL_VALUE (obj)->cdr), - printcharfun, escapeflag); - strout ("[default-value] ", -1, -1, printcharfun, 0); - print_object (XCDR (XBUFFER_LOCAL_VALUE (obj)->cdr), - printcharfun, escapeflag); - PRINTCHAR ('>'); - break; - case Lisp_Misc_Save_Value: strout ("#<save_value ", -1, -1, printcharfun, 0); sprintf(buf, "ptr=0x%08lx int=%d", @@ -2371,9 +2255,7 @@ print_object (obj, printcharfun, escapeflag) This is part of printing a string that has text properties. */ void -print_interval (interval, printcharfun) - INTERVAL interval; - Lisp_Object printcharfun; +print_interval (INTERVAL interval, Lisp_Object printcharfun) { if (NILP (interval->plist)) return; @@ -2388,7 +2270,7 @@ print_interval (interval, printcharfun) void -syms_of_print () +syms_of_print (void) { Qtemp_buffer_setup_hook = intern_c_string ("temp-buffer-setup-hook"); staticpro (&Qtemp_buffer_setup_hook); diff --git a/src/process.c b/src/process.c index 3e2aa61ffe6..e1515065957 100644 --- a/src/process.c +++ b/src/process.c @@ -21,17 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <signal.h> - -/* This file is split into two parts by the following preprocessor - conditional. The 'then' clause contains all of the support for - asynchronous subprocesses. The 'else' clause contains stub - versions of some of the asynchronous subprocess routines that are - often called elsewhere in Emacs, so we don't have to #ifdef the - sections that call them. */ - - -#ifdef subprocesses - #include <stdio.h> #include <errno.h> #include <setjmp.h> @@ -42,16 +31,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif -#ifdef STDC_HEADERS -#include <stdlib.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #include <fcntl.h> -#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ +/* Only MS-DOS does not define `subprocesses'. */ +#ifdef subprocesses + #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> @@ -67,40 +55,34 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/un.h> #endif #endif -#endif /* HAVE_SOCKETS */ -#if defined(BSD_SYSTEM) +#if defined(HAVE_SYS_IOCTL_H) #include <sys/ioctl.h> -#if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) -#include <fcntl.h> -#endif /* HAVE_PTYS and no O_NDELAY */ -#endif /* BSD_SYSTEM */ +#if defined(HAVE_NET_IF_H) +#include <net/if.h> +#endif /* HAVE_NET_IF_H */ +#endif /* HAVE_SYS_IOCTL_H */ #ifdef NEED_BSDTTY #include <bsdtty.h> #endif -/* Can we use SIOCGIFCONF and/or SIOCGIFADDR */ -#ifdef HAVE_SOCKETS -#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_NET_IF_H) -/* sys/ioctl.h may have been included already */ -#ifndef SIOCGIFADDR -#include <sys/ioctl.h> -#endif -#include <net/if.h> -#endif -#endif - -#ifdef HAVE_SYS_WAIT -#include <sys/wait.h> -#endif - #ifdef HAVE_RES_INIT #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> #endif +#ifdef HAVE_UTIL_H +#include <util.h> +#endif + +#ifdef HAVE_PTY_H +#include <pty.h> +#endif + +#endif /* subprocesses */ + #include "lisp.h" #include "systime.h" #include "systty.h" @@ -119,10 +101,40 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "dispextern.h" #include "composite.h" #include "atimer.h" +#include "sysselect.h" +#include "syssignal.h" +#include "syswait.h" +#ifdef HAVE_GNUTLS +#include "gnutls.h" +#endif #if defined (USE_GTK) || defined (HAVE_GCONF) #include "xgselect.h" #endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ +#ifdef HAVE_NS +#include "nsterm.h" +#endif + +extern int timers_run; + +Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid; +Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime; +Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; +Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime; +Lisp_Object QCname, QCtype; + +/* Non-zero if keyboard input is on hold, zero otherwise. */ + +static int kbd_is_on_hold; + +/* Nonzero means delete a process right away if it exits. */ +static int delete_exited_processes; + +/* Nonzero means don't run process sentinels. This is used + when exiting. */ +int inhibit_sentinels; + +#ifdef subprocesses Lisp_Object Qprocessp; Lisp_Object Qrun, Qstop, Qsignal; @@ -135,7 +147,7 @@ Lisp_Object Qipv6; Lisp_Object QCport, QCspeed, QCprocess; Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; -Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; +Lisp_Object QCbuffer, QChost, QCservice; Lisp_Object QClocal, QCremote, QCcoding; Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; Lisp_Object QCsentinel, QClog, QCoptions, QCplist; @@ -151,53 +163,19 @@ extern Lisp_Object QCfamily; /* QCfilter is defined in keyboard.c. */ extern Lisp_Object QCfilter; -Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid; -Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime; -Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; -Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime; - -#ifdef HAVE_SOCKETS #define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) #define NETCONN1_P(p) (EQ ((p)->type, Qnetwork)) #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) -#else -#define NETCONN_P(p) 0 -#define NETCONN1_P(p) 0 -#define SERIALCONN_P(p) 0 -#define SERIALCONN1_P(p) 0 -#endif /* HAVE_SOCKETS */ /* Define first descriptor number available for subprocesses. */ #define FIRST_PROC_DESC 3 -/* Define SIGCHLD as an alias for SIGCLD. There are many conditionals - testing SIGCHLD. */ - -#if !defined (SIGCHLD) && defined (SIGCLD) -#define SIGCHLD SIGCLD -#endif /* SIGCLD */ - -#include "syssignal.h" - -#include "syswait.h" - -extern char *get_operating_system_release (); - -/* Serial processes require termios or Windows. */ -#if defined (HAVE_TERMIOS) || defined (WINDOWSNT) -#define HAVE_SERIAL -#endif +extern const char *get_operating_system_release (void); -#ifdef HAVE_SERIAL /* From sysdep.c or w32.c */ extern int serial_open (char *port); extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact); -#endif - -#ifndef USE_CRT_DLL -extern int errno; -#endif #ifndef HAVE_H_ERRNO extern int h_errno; @@ -216,11 +194,12 @@ int update_tick; /* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ +/* Only W32 has this, it really means that select can't take write mask. */ #ifdef BROKEN_NON_BLOCKING_CONNECT #undef NON_BLOCKING_CONNECT +#define SELECT_CANT_DO_WRITE_MASK #else #ifndef NON_BLOCKING_CONNECT -#ifdef HAVE_SOCKETS #ifdef HAVE_SELECT #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) #if defined (O_NONBLOCK) || defined (O_NDELAY) @@ -230,7 +209,6 @@ int update_tick; #endif /* O_NONBLOCK || O_NDELAY */ #endif /* HAVE_GETPEERNAME || GNU_LINUX */ #endif /* HAVE_SELECT */ -#endif /* HAVE_SOCKETS */ #endif /* NON_BLOCKING_CONNECT */ #endif /* BROKEN_NON_BLOCKING_CONNECT */ @@ -243,13 +221,11 @@ int update_tick; #undef DATAGRAM_SOCKETS #else #ifndef DATAGRAM_SOCKETS -#ifdef HAVE_SOCKETS #if defined (HAVE_SELECT) || defined (FIONREAD) #if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) #define DATAGRAM_SOCKETS #endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */ #endif /* HAVE_SELECT || FIONREAD */ -#endif /* HAVE_SOCKETS */ #endif /* DATAGRAM_SOCKETS */ #endif /* BROKEN_DATAGRAM_SOCKETS */ @@ -286,14 +262,11 @@ static Lisp_Object Vprocess_adaptive_read_buffering; #define process_output_delay_count 0 #endif - -#include "sysselect.h" - -static int keyboard_bit_set P_ ((SELECT_TYPE *)); -static void deactivate_process P_ ((Lisp_Object)); -static void status_notify P_ ((struct Lisp_Process *)); -static int read_process_output P_ ((Lisp_Object, int)); -static void create_pty P_ ((Lisp_Object)); +static int keyboard_bit_set (SELECT_TYPE *); +static void deactivate_process (Lisp_Object); +static void status_notify (struct Lisp_Process *); +static int read_process_output (Lisp_Object, int); +static void create_pty (Lisp_Object); /* If we support a window system, turn on the code to poll periodically to detect C-g. It isn't actually used when doing interrupt input. */ @@ -301,11 +274,9 @@ static void create_pty P_ ((Lisp_Object)); #define POLL_FOR_INPUT #endif -static Lisp_Object get_process (); -static void exec_sentinel (); +static Lisp_Object get_process (register Lisp_Object name); +static void exec_sentinel (Lisp_Object proc, Lisp_Object reason); -extern int timers_run; - /* Mask of bits indicating the descriptors that we wait for input on. */ static SELECT_TYPE input_wait_mask; @@ -318,9 +289,9 @@ static SELECT_TYPE non_keyboard_wait_mask; static SELECT_TYPE non_process_wait_mask; -/* Mask for the gpm mouse input descriptor. */ +/* Mask for selecting for write. */ -static SELECT_TYPE gpm_wait_mask; +static SELECT_TYPE write_mask; #ifdef NON_BLOCKING_CONNECT /* Mask of bits indicating the descriptors that we wait for connect to @@ -333,21 +304,15 @@ static SELECT_TYPE connect_wait_mask; static int num_pending_connects; #define IF_NON_BLOCKING_CONNECT(s) s -#else +#else /* NON_BLOCKING_CONNECT */ #define IF_NON_BLOCKING_CONNECT(s) -#endif +#endif /* NON_BLOCKING_CONNECT */ /* The largest descriptor currently in use for a process object. */ static int max_process_desc; -/* The largest descriptor currently in use for keyboard input. */ -static int max_keyboard_desc; - -/* The largest descriptor currently in use for gpm mouse input. */ -static int max_gpm_desc; - -/* Nonzero means delete a process right away if it exits. */ -static int delete_exited_processes; +/* The largest descriptor currently in use for input. */ +static int max_input_desc; /* Indexed by descriptor, gives the process (if any) for that descriptor */ Lisp_Object chan_process[MAXDESC]; @@ -384,18 +349,90 @@ struct sockaddr_and_len { /* Maximum number of bytes to send to a pty without an eof. */ static int pty_max_bytes; -/* Nonzero means don't run process sentinels. This is used - when exiting. */ -int inhibit_sentinels; + -#ifdef HAVE_PTYS -#ifdef HAVE_PTY_H -#include <pty.h> -#endif -/* The file name of the pty opened by allocate_pty. */ +struct fd_callback_data +{ + fd_callback func; + void *data; +#define FOR_READ 1 +#define FOR_WRITE 2 + int condition; /* mask of the defines above. */ +} fd_callback_info[MAXDESC]; + + +/* Add a file descriptor FD to be monitored for when read is possible. + When read is possible, call FUNC with argument DATA. */ + +void +add_read_fd (int fd, fd_callback func, void *data) +{ + xassert (fd < MAXDESC); + add_keyboard_wait_descriptor (fd); + + fd_callback_info[fd].func = func; + fd_callback_info[fd].data = data; + fd_callback_info[fd].condition |= FOR_READ; +} + +/* Stop monitoring file descriptor FD for when read is possible. */ + +void +delete_read_fd (int fd) +{ + xassert (fd < MAXDESC); + delete_keyboard_wait_descriptor (fd); + + fd_callback_info[fd].condition &= ~FOR_READ; + if (fd_callback_info[fd].condition == 0) + { + fd_callback_info[fd].func = 0; + fd_callback_info[fd].data = 0; + } +} + +/* Add a file descriptor FD to be monitored for when write is possible. + When write is possible, call FUNC with argument DATA. */ + +void +add_write_fd (int fd, fd_callback func, void *data) +{ + xassert (fd < MAXDESC); + FD_SET (fd, &write_mask); + if (fd > max_input_desc) + max_input_desc = fd; + + fd_callback_info[fd].func = func; + fd_callback_info[fd].data = data; + fd_callback_info[fd].condition |= FOR_WRITE; +} + +/* Stop monitoring file descriptor FD for when write is possible. */ + +void +delete_write_fd (int fd) +{ + int lim = max_input_desc; + + xassert (fd < MAXDESC); + FD_CLR (fd, &write_mask); + fd_callback_info[fd].condition &= ~FOR_WRITE; + if (fd_callback_info[fd].condition == 0) + { + fd_callback_info[fd].func = 0; + fd_callback_info[fd].data = 0; + + if (fd == max_input_desc) + for (fd = lim; fd >= 0; fd--) + if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask)) + { + max_input_desc = fd; + break; + } + + } +} -static char pty_name[24]; -#endif /* Compute the Lisp form of the process status, p->status, from the numeric status that was returned by `wait'. */ @@ -403,8 +440,7 @@ static char pty_name[24]; static Lisp_Object status_convert (int); static void -update_status (p) - struct Lisp_Process *p; +update_status (struct Lisp_Process *p) { eassert (p->raw_status_new); p->status = status_convert (p->raw_status); @@ -433,11 +469,7 @@ status_convert (int w) and store them individually through the three pointers. */ static void -decode_status (l, symbol, code, coredump) - Lisp_Object l; - Lisp_Object *symbol; - int *code; - int *coredump; +decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, int *coredump) { Lisp_Object tem; @@ -460,8 +492,7 @@ decode_status (l, symbol, code, coredump) /* Return a string describing a process status list. */ static Lisp_Object -status_message (p) - struct Lisp_Process *p; +status_message (struct Lisp_Process *p) { Lisp_Object status = p->status; Lisp_Object symbol; @@ -517,13 +548,16 @@ status_message (p) #ifdef HAVE_PTYS +/* The file name of the pty opened by allocate_pty. */ +static char pty_name[24]; + /* Open an available pty, returning a file descriptor. Return -1 on failure. The file name of the terminal corresponding to the pty is left in the variable pty_name. */ static int -allocate_pty () +allocate_pty (void) { register int c, i; int fd; @@ -597,8 +631,7 @@ allocate_pty () #endif /* HAVE_PTYS */ static Lisp_Object -make_process (name) - Lisp_Object name; +make_process (Lisp_Object name) { register Lisp_Object val, tem, name1; register struct Lisp_Process *p; @@ -624,6 +657,12 @@ make_process (name) p->read_output_skip = 0; #endif +#ifdef HAVE_GNUTLS + p->gnutls_initstage = GNUTLS_STAGE_EMPTY; + p->gnutls_log_level = 0; + p->gnutls_p = 0; +#endif + /* If name is already in use, modify it until it is unused. */ name1 = name; @@ -642,8 +681,7 @@ make_process (name) } static void -remove_process (proc) - register Lisp_Object proc; +remove_process (register Lisp_Object proc) { register Lisp_Object pair; @@ -653,52 +691,17 @@ remove_process (proc) deactivate_process (proc); } -/* Setup coding systems of PROCESS. */ - -void -setup_process_coding_systems (process) - Lisp_Object process; -{ - struct Lisp_Process *p = XPROCESS (process); - int inch = p->infd; - int outch = p->outfd; - Lisp_Object coding_system; - - if (inch < 0 || outch < 0) - return; - - if (!proc_decode_coding_system[inch]) - proc_decode_coding_system[inch] - = (struct coding_system *) xmalloc (sizeof (struct coding_system)); - coding_system = p->decode_coding_system; - if (! NILP (p->filter)) - ; - else if (BUFFERP (p->buffer)) - { - if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) - coding_system = raw_text_coding_system (coding_system); - } - setup_coding_system (coding_system, proc_decode_coding_system[inch]); - - if (!proc_encode_coding_system[outch]) - proc_encode_coding_system[outch] - = (struct coding_system *) xmalloc (sizeof (struct coding_system)); - setup_coding_system (p->encode_coding_system, - proc_encode_coding_system[outch]); -} DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, doc: /* Return t if OBJECT is a process. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return PROCESSP (object) ? Qt : Qnil; } DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0, doc: /* Return the process named NAME, or nil if there is none. */) - (name) - register Lisp_Object name; + (register Lisp_Object name) { if (PROCESSP (name)) return name; @@ -706,35 +709,13 @@ DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0, return Fcdr (Fassoc (name, Vprocess_alist)); } -DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, - doc: /* Return the (or a) process associated with BUFFER. -BUFFER may be a buffer or the name of one. */) - (buffer) - register Lisp_Object buffer; -{ - register Lisp_Object buf, tail, proc; - - if (NILP (buffer)) return Qnil; - buf = Fget_buffer (buffer); - if (NILP (buf)) return Qnil; - - for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) - { - proc = Fcdr (XCAR (tail)); - if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf)) - return proc; - } - return Qnil; -} - /* This is how commands for the user decode process arguments. It accepts a process, a process name, a buffer, a buffer name, or nil. Buffers denote the first process in the buffer, and nil denotes the current buffer. */ static Lisp_Object -get_process (name) - register Lisp_Object name; +get_process (register Lisp_Object name) { register Lisp_Object proc, obj; if (STRINGP (name)) @@ -780,8 +761,7 @@ DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0, doc: /* Delete PROCESS: kill it and forget about it immediately. PROCESS may be a process, a buffer, the name of a process or buffer, or nil, indicating the current buffer's process. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { register struct Lisp_Process *p; @@ -848,8 +828,7 @@ failed -- when a non-blocking connection has failed. nil -- if arg is a process name and no such process exists. PROCESS may be a process, a buffer, the name of a process, or nil, indicating the current buffer's process. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { register struct Lisp_Process *p; register Lisp_Object status; @@ -884,8 +863,7 @@ DEFUN ("process-exit-status", Fprocess_exit_status, Sprocess_exit_status, 1, 1, 0, doc: /* Return the exit status of PROCESS or the signal number that killed it. If PROCESS has not yet exited or died, return 0. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); if (XPROCESS (process)->raw_status_new) @@ -899,8 +877,7 @@ DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0, doc: /* Return the process id of PROCESS. This is the pid of the external process which PROCESS uses or talks to. For a network connection, this value is nil. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { /* Assignment to EMACS_INT stops GCC whining about limited range of data type. */ @@ -915,8 +892,7 @@ DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0, doc: /* Return the name of PROCESS, as a string. This is the name of the program invoked in PROCESS, possibly modified to make it unique among process names. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->name; @@ -928,8 +904,7 @@ This is a list of strings, the first string being the program executed and the rest of the strings being the arguments given to it. For a network or serial process, this is nil (process is running) or t \(process is stopped). */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->command; @@ -939,8 +914,7 @@ DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, doc: /* Return the name of the terminal PROCESS uses, or nil if none. This is the terminal that the process itself reads and writes on, not the name of the pty that Emacs uses to talk with that terminal. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->tty_name; @@ -949,8 +923,7 @@ not the name of the pty that Emacs uses to talk with that terminal. */) DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, 2, 2, 0, doc: /* Set buffer associated with PROCESS to BUFFER (a buffer, or nil). */) - (process, buffer) - register Lisp_Object process, buffer; + (register Lisp_Object process, Lisp_Object buffer) { struct Lisp_Process *p; @@ -969,8 +942,7 @@ DEFUN ("process-buffer", Fprocess_buffer, Sprocess_buffer, 1, 1, 0, doc: /* Return the buffer PROCESS is associated with. Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->buffer; @@ -979,8 +951,7 @@ Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */) DEFUN ("process-mark", Fprocess_mark, Sprocess_mark, 1, 1, 0, doc: /* Return the marker for the end of the last output from PROCESS. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->mark; @@ -1002,8 +973,7 @@ The string argument is normally a multibyte string, except: - if `default-enable-multibyte-characters' is nil, it is a unibyte string (the result of converting the decoded input multibyte string to unibyte with `string-make-unibyte'). */) - (process, filter) - register Lisp_Object process, filter; + (register Lisp_Object process, Lisp_Object filter) { struct Lisp_Process *p; @@ -1045,8 +1015,7 @@ DEFUN ("process-filter", Fprocess_filter, Sprocess_filter, 1, 1, 0, doc: /* Returns the filter function of PROCESS; nil if none. See `set-process-filter' for more info on filter functions. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->filter; @@ -1057,8 +1026,7 @@ DEFUN ("set-process-sentinel", Fset_process_sentinel, Sset_process_sentinel, doc: /* Give PROCESS the sentinel SENTINEL; nil for none. The sentinel is called as a function when the process changes state. It gets two arguments: the process, and a string describing the change. */) - (process, sentinel) - register Lisp_Object process, sentinel; + (register Lisp_Object process, Lisp_Object sentinel) { struct Lisp_Process *p; @@ -1075,8 +1043,7 @@ DEFUN ("process-sentinel", Fprocess_sentinel, Sprocess_sentinel, 1, 1, 0, doc: /* Return the sentinel of PROCESS; nil if none. See `set-process-sentinel' for more info on sentinels. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->sentinel; @@ -1085,8 +1052,7 @@ See `set-process-sentinel' for more info on sentinels. */) DEFUN ("set-process-window-size", Fset_process_window_size, Sset_process_window_size, 3, 3, 0, doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) - (process, height, width) - register Lisp_Object process, height, width; + (register Lisp_Object process, Lisp_Object height, Lisp_Object width) { CHECK_PROCESS (process); CHECK_NATNUM (height); @@ -1117,36 +1083,20 @@ is more appropriate for saving the process buffer. Binding the variable `inherit-process-coding-system' to non-nil before starting the process is an alternative way of setting the inherit flag for the process which will run. */) - (process, flag) - register Lisp_Object process, flag; + (register Lisp_Object process, Lisp_Object flag) { CHECK_PROCESS (process); XPROCESS (process)->inherit_coding_system_flag = !NILP (flag); return flag; } -DEFUN ("process-inherit-coding-system-flag", - Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, - 1, 1, 0, - doc: /* Return the value of inherit-coding-system flag for PROCESS. -If this flag is t, `buffer-file-coding-system' of the buffer -associated with PROCESS will inherit the coding system used to decode -the process output. */) - (process) - register Lisp_Object process; -{ - CHECK_PROCESS (process); - return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil; -} - DEFUN ("set-process-query-on-exit-flag", Fset_process_query_on_exit_flag, Sset_process_query_on_exit_flag, 2, 2, 0, doc: /* Specify if query is needed for PROCESS when Emacs is exited. If the second argument FLAG is non-nil, Emacs will query the user before exiting or killing a buffer if PROCESS is running. */) - (process, flag) - register Lisp_Object process, flag; + (register Lisp_Object process, Lisp_Object flag) { CHECK_PROCESS (process); XPROCESS (process)->kill_without_query = NILP (flag); @@ -1157,15 +1107,14 @@ DEFUN ("process-query-on-exit-flag", Fprocess_query_on_exit_flag, Sprocess_query_on_exit_flag, 1, 1, 0, doc: /* Return the current value of query-on-exit flag for PROCESS. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return (XPROCESS (process)->kill_without_query ? Qnil : Qt); } #ifdef DATAGRAM_SOCKETS -Lisp_Object Fprocess_datagram_address (); +Lisp_Object Fprocess_datagram_address (Lisp_Object process); #endif DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, @@ -1178,8 +1127,7 @@ connection. If KEY is t, the complete contact information for the connection is returned, else the specific value for the keyword KEY is returned. See `make-network-process' or `make-serial-process' for a list of keywords. */) - (process, key) - register Lisp_Object process, key; + (register Lisp_Object process, Lisp_Object key) { Lisp_Object contact; @@ -1207,8 +1155,7 @@ list of keywords. */) DEFUN ("process-plist", Fprocess_plist, Sprocess_plist, 1, 1, 0, doc: /* Return the plist of PROCESS. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return XPROCESS (process)->plist; @@ -1217,8 +1164,7 @@ DEFUN ("process-plist", Fprocess_plist, Sprocess_plist, DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist, 2, 2, 0, doc: /* Replace the plist of PROCESS with PLIST. Returns PLIST. */) - (process, plist) - register Lisp_Object process, plist; + (register Lisp_Object process, Lisp_Object plist) { CHECK_PROCESS (process); CHECK_LIST (plist); @@ -1233,8 +1179,7 @@ DEFUN ("process-connection", Fprocess_connection, Sprocess_connection, 1, 1, 0, doc: /* Return the connection type of PROCESS. The value is nil for a pipe, t or `pty' for a pty, or `stream' for a socket connection. */) - (process) - Lisp_Object process; + (Lisp_Object process) { return XPROCESS (process)->type; } @@ -1245,15 +1190,13 @@ DEFUN ("process-type", Fprocess_type, Sprocess_type, 1, 1, 0, The value is either the symbol `real', `network', or `serial'. PROCESS may be a process, a buffer, the name of a process or buffer, or nil, indicating the current buffer's process. */) - (process) - Lisp_Object process; + (Lisp_Object process) { Lisp_Object proc; proc = get_process (process); return XPROCESS (proc)->type; } -#ifdef HAVE_SOCKETS DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address, 1, 2, 0, doc: /* Convert network ADDRESS from internal format to a string. @@ -1262,8 +1205,7 @@ An 8 or 9 element vector represents an IPv6 address (with port number). If optional second argument OMIT-PORT is non-nil, don't include a port number in the string, even when present in ADDRESS. Returns nil if format of ADDRESS is invalid. */) - (address, omit_port) - Lisp_Object address, omit_port; + (Lisp_Object address, Lisp_Object omit_port) { if (NILP (address)) return Qnil; @@ -1328,11 +1270,9 @@ Returns nil if format of ADDRESS is invalid. */) return Qnil; } -#endif static Lisp_Object -list_processes_1 (query_only) - Lisp_Object query_only; +list_processes_1 (Lisp_Object query_only) { register Lisp_Object tail, tem; Lisp_Object proc, minspace, tem1; @@ -1566,8 +1506,7 @@ If optional argument QUERY-ONLY is non-nil, only processes with the query-on-exit flag set will be listed. Any process listed as exited or signaled is actually eliminated after the listing is made. */) - (query_only) - Lisp_Object query_only; + (Lisp_Object query_only) { internal_with_output_to_temp_buffer ("*Process List*", list_processes_1, query_only); @@ -1576,14 +1515,14 @@ after the listing is made. */) DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0, doc: /* Return a list of all processes. */) - () + (void) { return Fmapcar (Qcdr, Vprocess_alist); } /* Starting asynchronous inferior processes. */ -static Lisp_Object start_process_unwind (); +static Lisp_Object start_process_unwind (Lisp_Object proc); DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, doc: /* Start a program in a subprocess. Return the process object for it. @@ -1604,9 +1543,7 @@ the command through a shell and redirect one of them using the shell syntax. usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) - (nargs, args) - int nargs; - register Lisp_Object *args; + (int nargs, register Lisp_Object *args) { Lisp_Object buffer, name, program, proc, current_dir, tem; register unsigned char **new_argv; @@ -1669,6 +1606,12 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) XPROCESS (proc)->filter = Qnil; XPROCESS (proc)->command = Flist (nargs - 2, args + 2); +#ifdef HAVE_GNUTLS + /* AKA GNUTLS_INITSTAGE(proc). */ + XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY; + XPROCESS (proc)->gnutls_cred_type = Qnil; +#endif + #ifdef ADAPTIVE_READ_BUFFERING XPROCESS (proc)->adaptive_read_buffering = (NILP (Vprocess_adaptive_read_buffering) ? 0 @@ -1829,8 +1772,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) an error and the process wasn't started successfully, so we should remove it from the process list. */ static Lisp_Object -start_process_unwind (proc) - Lisp_Object proc; +start_process_unwind (Lisp_Object proc) { if (!PROCESSP (proc)) abort (); @@ -1843,37 +1785,14 @@ start_process_unwind (proc) } static void -create_process_1 (timer) - struct atimer *timer; +create_process_1 (struct atimer *timer) { /* Nothing to do. */ } -#if 0 /* This doesn't work; see the note before sigchld_handler. */ -#ifdef USG -#ifdef SIGCHLD -/* Mimic blocking of signals on system V, which doesn't really have it. */ - -/* Nonzero means we got a SIGCHLD when it was supposed to be blocked. */ -int sigchld_deferred; - -SIGTYPE -create_process_sigchld () -{ - signal (SIGCHLD, create_process_sigchld); - - sigchld_deferred = 1; -} -#endif -#endif -#endif - void -create_process (process, new_argv, current_dir) - Lisp_Object process; - char **new_argv; - Lisp_Object current_dir; +create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) { int inchannel, outchannel; pid_t pid; @@ -1881,7 +1800,6 @@ create_process (process, new_argv, current_dir) #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) int wait_child_setup[2]; #endif -#ifdef POSIX_SIGNALS sigset_t procmask; sigset_t blocked; struct sigaction sigint_action; @@ -1889,13 +1807,6 @@ create_process (process, new_argv, current_dir) #ifdef AIX struct sigaction sighup_action; #endif -#else /* !POSIX_SIGNALS */ -#if 0 -#ifdef SIGCHLD - SIGTYPE (*sigchld)(); -#endif -#endif /* 0 */ -#endif /* !POSIX_SIGNALS */ /* Use volatile to protect variables from being clobbered by longjmp. */ volatile int forkin, forkout; volatile int pty_flag = 0; @@ -1967,12 +1878,6 @@ create_process (process, new_argv, current_dir) } #endif -#if 0 - /* Replaced by close_process_descs */ - set_exclusive_use (inchannel); - set_exclusive_use (outchannel); -#endif - #ifdef O_NONBLOCK fcntl (inchannel, F_SETFL, O_NONBLOCK); fcntl (outchannel, F_SETFL, O_NONBLOCK); @@ -2000,7 +1905,6 @@ create_process (process, new_argv, current_dir) /* Delay interrupts until we have a chance to store the new fork's pid in its process structure */ -#ifdef POSIX_SIGNALS sigemptyset (&blocked); #ifdef SIGCHLD sigaddset (&blocked, SIGCHLD); @@ -2017,18 +1921,6 @@ create_process (process, new_argv, current_dir) #endif #endif /* HAVE_WORKING_VFORK */ sigprocmask (SIG_BLOCK, &blocked, &procmask); -#else /* !POSIX_SIGNALS */ -#ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) - sigsetmask (sigmask (SIGCHLD)); -#else /* ordinary USG */ -#if 0 - sigchld_deferred = 0; - sigchld = signal (SIGCHLD, create_process_sigchld); -#endif -#endif /* ordinary USG */ -#endif /* SIGCHLD */ -#endif /* !POSIX_SIGNALS */ FD_SET (inchannel, &input_wait_mask); FD_SET (inchannel, &non_keyboard_wait_mask); @@ -2074,7 +1966,7 @@ create_process (process, new_argv, current_dir) process_set_signal to fail on SGI when using a pipe. */ setsid (); /* Make the pty's terminal the controlling terminal. */ - if (pty_flag) + if (pty_flag && xforkin >= 0) { #ifdef TIOCSCTTY /* We ignore the return value @@ -2090,7 +1982,7 @@ create_process (process, new_argv, current_dir) setpgrp (); #endif /* USG */ #endif /* not HAVE_SETSID */ -#if defined (HAVE_TERMIOS) && defined (LDISC1) +#if defined (LDISC1) if (pty_flag && xforkin >= 0) { struct termios t; @@ -2117,8 +2009,11 @@ create_process (process, new_argv, current_dir) /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? I can't test it since I don't have 4.3. */ int j = emacs_open ("/dev/tty", O_RDWR, 0); - ioctl (j, TIOCNOTTY, 0); - emacs_close (j); + if (j >= 0) + { + ioctl (j, TIOCNOTTY, 0); + emacs_close (j); + } #ifndef USG /* In order to get a controlling terminal on some versions of BSD, it is necessary to put the process in pgrp 0 @@ -2179,19 +2074,7 @@ create_process (process, new_argv, current_dir) signal (SIGQUIT, SIG_DFL); /* Stop blocking signals in the child. */ -#ifdef POSIX_SIGNALS sigprocmask (SIG_SETMASK, &procmask, 0); -#else /* !POSIX_SIGNALS */ -#ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) - sigsetmask (SIGEMPTYMASK); -#else /* ordinary USG */ -#if 0 - signal (SIGCHLD, sigchld); -#endif -#endif /* ordinary USG */ -#endif /* SIGCHLD */ -#endif /* !POSIX_SIGNALS */ if (pty_flag) child_setup_tty (xforkout); @@ -2273,7 +2156,6 @@ create_process (process, new_argv, current_dir) /* Restore the signal state whether vfork succeeded or not. (We will signal an error, below, if it failed.) */ -#ifdef POSIX_SIGNALS #ifdef HAVE_WORKING_VFORK /* Restore the parent's signal handlers. */ sigaction (SIGINT, &sigint_action, 0); @@ -2284,21 +2166,6 @@ create_process (process, new_argv, current_dir) #endif /* HAVE_WORKING_VFORK */ /* Stop blocking signals in the parent. */ sigprocmask (SIG_SETMASK, &procmask, 0); -#else /* !POSIX_SIGNALS */ -#ifdef SIGCHLD -#if defined (BSD_SYSTEM) || defined (HPUX) - sigsetmask (SIGEMPTYMASK); -#else /* ordinary USG */ -#if 0 - signal (SIGCHLD, sigchld); - /* Now really handle any of these signals - that came in during this function. */ - if (sigchld_deferred) - kill (getpid (), SIGCHLD); -#endif -#endif /* ordinary USG */ -#endif /* SIGCHLD */ -#endif /* !POSIX_SIGNALS */ /* Now generate the error if vfork failed. */ if (pid < 0) @@ -2306,8 +2173,7 @@ create_process (process, new_argv, current_dir) } void -create_pty (process) - Lisp_Object process; +create_pty (Lisp_Object process) { int inchannel, outchannel; @@ -2388,15 +2254,11 @@ create_pty (process) } -#ifdef HAVE_SOCKETS - /* Convert an internal struct sockaddr to a lisp object (vector or string). The address family of sa is not included in the result. */ static Lisp_Object -conv_sockaddr_to_lisp (sa, len) - struct sockaddr *sa; - int len; +conv_sockaddr_to_lisp (struct sockaddr *sa, int len) { Lisp_Object address; int i; @@ -2406,7 +2268,7 @@ conv_sockaddr_to_lisp (sa, len) /* Workaround for a bug in getsockname on BSD: Names bound to sockets in the UNIX domain are inaccessible; getsockname returns a zero length name. */ - if (len < OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family)) + if (len < offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family)) return empty_unibyte_string; switch (sa->sa_family) @@ -2446,7 +2308,7 @@ conv_sockaddr_to_lisp (sa, len) } #endif default: - len -= OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family); + len -= offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family); address = Fcons (make_number (sa->sa_family), Fmake_vector (make_number (len), Qnil)); p = XVECTOR (XCDR (address)); @@ -2465,9 +2327,7 @@ conv_sockaddr_to_lisp (sa, len) /* Get family and required size for sockaddr structure to hold ADDRESS. */ static int -get_lisp_to_sockaddr_size (address, familyp) - Lisp_Object address; - int *familyp; +get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp) { register struct Lisp_Vector *p; @@ -2512,17 +2372,13 @@ get_lisp_to_sockaddr_size (address, familyp) we return after zeroing *SA. */ static void -conv_lisp_to_sockaddr (family, address, sa, len) - int family; - Lisp_Object address; - struct sockaddr *sa; - int len; +conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int len) { register struct Lisp_Vector *p; register unsigned char *cp = NULL; register int i; - bzero (sa, len); + memset (sa, 0, len); if (VECTORP (address)) { @@ -2586,8 +2442,7 @@ conv_lisp_to_sockaddr (family, address, sa, len) DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_address, 1, 1, 0, doc: /* Get the current datagram address associated with PROCESS. */) - (process) - Lisp_Object process; + (Lisp_Object process) { int channel; @@ -2605,8 +2460,7 @@ DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_proce 2, 2, 0, doc: /* Set the datagram address for PROCESS to ADDRESS. Returns nil upon error setting address, ADDRESS otherwise. */) - (process, address) - Lisp_Object process, address; + (Lisp_Object process, Lisp_Object address) { int channel; int family, len; @@ -2630,7 +2484,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */) static const struct socket_options { /* The name of this option. Should be lowercase version of option name without SO_ prefix. */ - char *name; + const char *name; /* Option level SOL_... */ int optlevel; /* Option number SO_... */ @@ -2673,9 +2527,7 @@ static const struct socket_options { */ static int -set_socket_option (s, opt, val) - int s; - Lisp_Object opt, val; +set_socket_option (int s, Lisp_Object opt, Lisp_Object val) { char *name; const struct socket_options *sopt; @@ -2719,12 +2571,12 @@ set_socket_option (s, opt, val) /* This is broken, at least in the Linux 2.4 kernel. To unbind, the arg must be a zero integer, not the empty string. This should work on all systems. KFS. 2003-09-23. */ - bzero (devname, sizeof devname); + memset (devname, 0, sizeof devname); if (STRINGP (val)) { char *arg = (char *) SDATA (val); int len = min (strlen (arg), IFNAMSIZ); - bcopy (arg, devname, len); + memcpy (devname, arg, len); } else if (!NILP (val)) error ("Bad option value for %s", name); @@ -2769,9 +2621,7 @@ DEFUN ("set-network-process-option", See `make-network-process' for a list of options and values. If optional fourth arg NO-ERROR is non-nil, don't signal an error if OPTION is not a supported option, return nil instead; otherwise return t. */) - (process, option, value, no_error) - Lisp_Object process, option, value; - Lisp_Object no_error; + (Lisp_Object process, Lisp_Object option, Lisp_Object value, Lisp_Object no_error) { int s; struct Lisp_Process *p; @@ -2798,7 +2648,6 @@ OPTION is not a supported option, return nil instead; otherwise return t. */) } -#ifdef HAVE_SERIAL DEFUN ("serial-process-configure", Fserial_process_configure, Sserial_process_configure, @@ -2858,9 +2707,7 @@ Examples: \(serial-process-configure :port "\\\\.\\COM13" :bytesize 7) usage: (serial-process-configure &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { struct Lisp_Process *p; Lisp_Object contact = Qnil; @@ -2977,9 +2824,7 @@ Examples: \(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil) usage: (make-serial-process &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { int fd = -1; Lisp_Object proc, contact, port; @@ -3091,14 +2936,13 @@ usage: (make-serial-process &rest ARGS) */) p->inherit_coding_system_flag = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); - Fserial_process_configure(nargs, args); + Fserial_process_configure (nargs, args); specpdl_ptr = specpdl + specpdl_count; UNGCPRO; return proc; } -#endif /* HAVE_SERIAL */ /* Create a network stream/datagram client/server process. Treated exactly like a normal process when reading and writing. Primary @@ -3258,9 +3102,7 @@ The original argument list, modified with the actual connection information, is available via the `process-contact' function. usage: (make-network-process &rest ARGS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object proc; Lisp_Object contact; @@ -3268,7 +3110,8 @@ usage: (make-network-process &rest ARGS) */) #ifdef HAVE_GETADDRINFO struct addrinfo ai, *res, *lres; struct addrinfo hints; - char *portstring, portbuf[128]; + const char *portstring; + char portbuf[128]; #else /* HAVE_GETADDRINFO */ struct _emacs_addrinfo { @@ -3413,13 +3256,29 @@ usage: (make-network-process &rest ARGS) */) /* :service SERVICE -- string, integer (port number), or t (random port). */ service = Fplist_get (contact, QCservice); + /* :host HOST -- hostname, ip address, or 'local for localhost. */ + host = Fplist_get (contact, QChost); + if (!NILP (host)) + { + if (EQ (host, Qlocal)) + /* Depending on setup, "localhost" may map to different IPv4 and/or + IPv6 addresses, so it's better to be explicit. (Bug#6781) */ + host = build_string ("127.0.0.1"); + CHECK_STRING (host); + } + #ifdef HAVE_LOCAL_SOCKETS if (family == AF_LOCAL) { - /* Host is not used. */ - host = Qnil; + if (!NILP (host)) + { + message (":family local ignores the :host \"%s\" property", + SDATA (host)); + contact = Fplist_put (contact, QChost, Qnil); + host = Qnil; + } CHECK_STRING (service); - bzero (&address_un, sizeof address_un); + memset (&address_un, 0, sizeof address_un); address_un.sun_family = AF_LOCAL; strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path); ai.ai_addr = (struct sockaddr *) &address_un; @@ -3428,15 +3287,6 @@ usage: (make-network-process &rest ARGS) */) } #endif - /* :host HOST -- hostname, ip address, or 'local for localhost. */ - host = Fplist_get (contact, QChost); - if (!NILP (host)) - { - if (EQ (host, Qlocal)) - host = build_string ("localhost"); - CHECK_STRING (host); - } - /* Slow down polling to every ten seconds. Some kernels have a bug which causes retrying connect to fail after a connect. Polling can interfere with gethostbyname too. */ @@ -3484,7 +3334,7 @@ usage: (make-network-process &rest ARGS) */) ret = getaddrinfo (SDATA (host), portstring, &hints, &res); if (ret) #ifdef HAVE_GAI_STRERROR - error ("%s/%s %s", SDATA (host), portstring, gai_strerror(ret)); + error ("%s/%s %s", SDATA (host), portstring, gai_strerror (ret)); #else error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret); #endif @@ -3512,7 +3362,7 @@ usage: (make-network-process &rest ARGS) */) port = svc_info->s_port; } - bzero (&address_in, sizeof address_in); + memset (&address_in, 0, sizeof address_in); address_in.sin_family = family; address_in.sin_addr.s_addr = INADDR_ANY; address_in.sin_port = port; @@ -3536,8 +3386,8 @@ usage: (make-network-process &rest ARGS) */) if (host_info_ptr) { - bcopy (host_info_ptr->h_addr, (char *) &address_in.sin_addr, - host_info_ptr->h_length); + memcpy (&address_in.sin_addr, host_info_ptr->h_addr, + host_info_ptr->h_length); family = host_info_ptr->h_addrtype; address_in.sin_family = family; } @@ -3549,8 +3399,8 @@ usage: (make-network-process &rest ARGS) */) if (numeric_addr == -1) error ("Unknown host \"%s\"", SDATA (host)); - bcopy ((char *)&numeric_addr, (char *) &address_in.sin_addr, - sizeof (address_in.sin_addr)); + memcpy (&address_in.sin_addr, &numeric_addr, + sizeof (address_in.sin_addr)); } } @@ -3653,23 +3503,9 @@ usage: (make-network-process &rest ARGS) */) immediate_quit = 1; QUIT; - /* This turns off all alarm-based interrupts; the - bind_polling_period call above doesn't always turn all the - short-interval ones off, especially if interrupt_input is - set. - - It'd be nice to be able to control the connect timeout - though. Would non-blocking connect calls be portable? - - This used to be conditioned by HAVE_GETADDRINFO. Why? */ - - turn_on_atimers (0); - ret = connect (s, lres->ai_addr, lres->ai_addrlen); xerrno = errno; - turn_on_atimers (1); - if (ret == 0 || xerrno == EISCONN) { /* The unwind-protect will be discarded afterwards. @@ -3689,6 +3525,40 @@ usage: (make-network-process &rest ARGS) */) #endif #endif +#ifndef WINDOWSNT + if (xerrno == EINTR) + { + /* Unlike most other syscalls connect() cannot be called + again. (That would return EALREADY.) The proper way to + wait for completion is select(). */ + int sc, len; + SELECT_TYPE fdset; + retry_select: + FD_ZERO (&fdset); + FD_SET (s, &fdset); + QUIT; + sc = select (s + 1, (SELECT_TYPE *)0, &fdset, (SELECT_TYPE *)0, + (EMACS_TIME *)0); + if (sc == -1) + { + if (errno == EINTR) + goto retry_select; + else + report_file_error ("select failed", Qnil); + } + eassert (sc > 0); + + len = sizeof xerrno; + eassert (FD_ISSET (s, &fdset)); + if (getsockopt (s, SOL_SOCKET, SO_ERROR, &xerrno, &len) == -1) + report_file_error ("getsockopt failed", Qnil); + if (xerrno) + errno = xerrno, report_file_error ("error during connect", Qnil); + else + break; + } +#endif /* !WINDOWSNT */ + immediate_quit = 0; /* Discard the unwind protect closing S. */ @@ -3696,8 +3566,10 @@ usage: (make-network-process &rest ARGS) */) emacs_close (s); s = -1; +#ifdef WINDOWSNT if (xerrno == EINTR) goto retry_connect; +#endif } if (s >= 0) @@ -3712,7 +3584,7 @@ usage: (make-network-process &rest ARGS) */) if (is_server) { Lisp_Object remote; - bzero (datagram_address[s].sa, lres->ai_addrlen); + memset (datagram_address[s].sa, 0, lres->ai_addrlen); if (remote = Fplist_get (contact, QCremote), !NILP (remote)) { int rfamily, rlen; @@ -3723,7 +3595,7 @@ usage: (make-network-process &rest ARGS) */) } } else - bcopy (lres->ai_addr, datagram_address[s].sa, lres->ai_addrlen); + memcpy (datagram_address[s].sa, lres->ai_addr, lres->ai_addrlen); } #endif contact = Fplist_put (contact, QCaddress, @@ -3735,7 +3607,7 @@ usage: (make-network-process &rest ARGS) */) int len1 = sizeof (sa1); if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp (&sa1, len1)); + conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1)); } #endif } @@ -3826,6 +3698,7 @@ usage: (make-network-process &rest ARGS) */) if (!FD_ISSET (inch, &connect_wait_mask)) { FD_SET (inch, &connect_wait_mask); + FD_SET (inch, &write_mask); num_pending_connects++; } } @@ -3936,10 +3809,9 @@ usage: (make-network-process &rest ARGS) */) UNGCPRO; return proc; } -#endif /* HAVE_SOCKETS */ -#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) +#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) #ifdef SIOCGIFCONF DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, @@ -3947,7 +3819,7 @@ DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_lis Each element is a cons, the car of which is a string containing the interface name, and the cdr is the network address in internal format; see the description of ADDRESS in `make-network-process'. */) - () + (void) { struct ifconf ifconf; struct ifreq *ifreqs = NULL; @@ -3961,7 +3833,7 @@ format; see the description of ADDRESS in `make-network-process'. */) again: ifaces += 25; - buf_size = ifaces * sizeof(ifreqs[0]); + buf_size = ifaces * sizeof (ifreqs[0]); ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size); if (!ifreqs) { @@ -3990,7 +3862,7 @@ format; see the description of ADDRESS in `make-network-process'. */) char namebuf[sizeof (ifq->ifr_name) + 1]; if (ifq->ifr_addr.sa_family != AF_INET) continue; - bcopy (ifq->ifr_name, namebuf, sizeof (ifq->ifr_name)); + memcpy (namebuf, ifq->ifr_name, sizeof (ifq->ifr_name)); namebuf[sizeof (ifq->ifr_name)] = 0; res = Fcons (Fcons (build_string (namebuf), conv_sockaddr_to_lisp (&ifq->ifr_addr, @@ -4082,8 +3954,7 @@ The return value is a list (ADDR BCAST NETMASK HWADDR FLAGS), where ADDR is the layer 3 address, BCAST is the layer 3 broadcast address, NETMASK is the layer 3 network mask, HWADDR is the layer 2 addres, and FLAGS is the current flags of the interface. */) - (ifname) - Lisp_Object ifname; + (Lisp_Object ifname) { struct ifreq rq; Lisp_Object res = Qnil; @@ -4093,7 +3964,7 @@ FLAGS is the current flags of the interface. */) CHECK_STRING (ifname); - bzero (rq.ifr_name, sizeof rq.ifr_name); + memset (rq.ifr_name, 0, sizeof rq.ifr_name); strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name)); s = socket (AF_INET, SOCK_STREAM, 0); @@ -4183,13 +4054,12 @@ FLAGS is the current flags of the interface. */) return any ? res : Qnil; } #endif -#endif /* HAVE_SOCKETS */ +#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */ /* Turn off input and output for process PROC. */ void -deactivate_process (proc) - Lisp_Object proc; +deactivate_process (Lisp_Object proc) { register int inchannel, outchannel; register struct Lisp_Process *p = XPROCESS (proc); @@ -4232,6 +4102,7 @@ deactivate_process (proc) if (FD_ISSET (inchannel, &connect_wait_mask)) { FD_CLR (inchannel, &connect_wait_mask); + FD_CLR (inchannel, &write_mask); if (--num_pending_connects < 0) abort (); } @@ -4249,31 +4120,6 @@ deactivate_process (proc) } } -/* Close all descriptors currently in use for communication - with subprocess. This is used in a newly-forked subprocess - to get rid of irrelevant descriptors. */ - -void -close_process_descs () -{ -#ifndef WINDOWSNT - int i; - for (i = 0; i < MAXDESC; i++) - { - Lisp_Object process; - process = chan_process[i]; - if (!NILP (process)) - { - int in = XPROCESS (process)->infd; - int out = XPROCESS (process)->outfd; - if (in >= 0) - emacs_close (in); - if (out >= 0 && in != out) - emacs_close (out); - } - } -#endif -} DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, 0, 4, 0, @@ -4292,8 +4138,7 @@ If optional fourth arg JUST-THIS-ONE is non-nil, only accept output from PROCESS, suspending reading output from other processes. If JUST-THIS-ONE is an integer, don't run any timers either. Return non-nil if we received any output before the timeout expired. */) - (process, seconds, millisec, just_this_one) - register Lisp_Object process, seconds, millisec, just_this_one; + (register Lisp_Object process, Lisp_Object seconds, Lisp_Object millisec, Lisp_Object just_this_one) { int secs, usecs = 0; @@ -4347,9 +4192,7 @@ Return non-nil if we received any output before the timeout expired. */) static int connect_counter = 0; static void -server_accept_connection (server, channel) - Lisp_Object server; - int channel; +server_accept_connection (Lisp_Object server, int channel) { Lisp_Object proc, caller, name, buffer; Lisp_Object contact, host, service; @@ -4426,7 +4269,7 @@ server_accept_connection (server, channel) int i; args[0] = build_string ("%x:%x:%x:%x:%x:%x:%x:%x"); for (i = 0; i < 8; i++) - args[i+1] = make_number (ntohs(ip6[i])); + args[i+1] = make_number (ntohs (ip6[i])); host = Fformat (9, args); service = make_number (ntohs (saddr.in.sin_port)); @@ -4565,8 +4408,7 @@ server_accept_connection (server, channel) static int waiting_for_user_input_p; static Lisp_Object -wait_reading_process_output_unwind (data) - Lisp_Object data; +wait_reading_process_output_unwind (Lisp_Object data) { waiting_for_user_input_p = XINT (data); return Qnil; @@ -4574,7 +4416,7 @@ wait_reading_process_output_unwind (data) /* This is here so breakpoints can be put on it. */ static void -wait_reading_process_output_1 () +wait_reading_process_output_1 (void) { } @@ -4587,10 +4429,7 @@ wait_reading_process_output_1 () #ifndef select static INLINE int -select_wrapper (n, rfd, wfd, xfd, tmo) - int n; - SELECT_TYPE *rfd, *wfd, *xfd; - EMACS_TIME *tmo; +select_wrapper (int n, fd_set *rfd, fd_set *wfd, fd_set *xfd, struct timeval *tmo) { return select (n, rfd, wfd, xfd, tmo); } @@ -4635,19 +4474,15 @@ select_wrapper (n, rfd, wfd, xfd, tmo) Otherwise, return true if we received input from any process. */ int -wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, - wait_for_cell, wait_proc, just_wait_proc) - int time_limit, microsecs, read_kbd, do_display; - Lisp_Object wait_for_cell; - struct Lisp_Process *wait_proc; - int just_wait_proc; +wait_reading_process_output (int time_limit, int microsecs, int read_kbd, + int do_display, + Lisp_Object wait_for_cell, + struct Lisp_Process *wait_proc, int just_wait_proc) { register int channel, nfds; SELECT_TYPE Available; -#ifdef NON_BLOCKING_CONNECT - SELECT_TYPE Connecting; - int check_connect; -#endif + SELECT_TYPE Writeok; + int check_write; int check_delay, no_avail; int xerrno; Lisp_Object proc; @@ -4657,9 +4492,11 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, int count = SPECPDL_INDEX (); FD_ZERO (&Available); -#ifdef NON_BLOCKING_CONNECT - FD_ZERO (&Connecting); -#endif + FD_ZERO (&Writeok); + + if (time_limit == 0 && microsecs == 0 && wait_proc && !NILP (Vinhibit_quit) + && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit))) + message ("Blocking call to accept-process-output with quit inhibited!!"); /* If wait_proc is a process to watch, set wait_channel accordingly. */ if (wait_proc != NULL) @@ -4791,16 +4628,16 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (update_tick != process_tick) { SELECT_TYPE Atemp; -#ifdef NON_BLOCKING_CONNECT SELECT_TYPE Ctemp; -#endif - Atemp = input_wait_mask; - IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); + if (kbd_on_hold_p ()) + FD_ZERO (&Atemp); + else + Atemp = input_wait_mask; + Ctemp = write_mask; EMACS_SET_SECS_USECS (timeout, 0, 0); - if ((select (max (max (max_process_desc, max_keyboard_desc), - max_gpm_desc) + 1, + if ((select (max (max_process_desc, max_input_desc) + 1, &Atemp, #ifdef NON_BLOCKING_CONNECT (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), @@ -4871,13 +4708,13 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, break; FD_SET (wait_proc->infd, &Available); check_delay = 0; - IF_NON_BLOCKING_CONNECT (check_connect = 0); + check_write = 0; } else if (!NILP (wait_for_cell)) { Available = non_process_wait_mask; check_delay = 0; - IF_NON_BLOCKING_CONNECT (check_connect = 0); + check_write = 0; } else { @@ -4885,7 +4722,12 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, Available = non_keyboard_wait_mask; else Available = input_wait_mask; - IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0)); + Writeok = write_mask; +#ifdef SELECT_CANT_DO_WRITE_MASK + check_write = 0; +#else + check_write = 1; +#endif check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; } @@ -4910,10 +4752,6 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, } else { -#ifdef NON_BLOCKING_CONNECT - if (check_connect) - Connecting = connect_wait_mask; -#endif #ifdef ADAPTIVE_READ_BUFFERING /* Set the timeout for adaptive read buffering if any @@ -4955,15 +4793,10 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, #else nfds = select #endif - (max (max (max_process_desc, max_keyboard_desc), - max_gpm_desc) + 1, - &Available, -#ifdef NON_BLOCKING_CONNECT - (check_connect ? &Connecting : (SELECT_TYPE *)0), -#else - (SELECT_TYPE *)0, -#endif - (SELECT_TYPE *)0, &timeout); + (max (max_process_desc, max_input_desc) + 1, + &Available, + (check_write ? &Writeok : (SELECT_TYPE *)0), + (SELECT_TYPE *)0, &timeout); } xerrno = errno; @@ -5003,7 +4836,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (no_avail) { FD_ZERO (&Available); - IF_NON_BLOCKING_CONNECT (check_connect = 0); + check_write = 0; } #if 0 /* When polling is used, interrupt_input is 0, @@ -5099,12 +4932,26 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (no_avail || nfds == 0) continue; + for (channel = 0; channel <= max_input_desc; ++channel) + { + struct fd_callback_data *d = &fd_callback_info[channel]; + if (FD_ISSET (channel, &Available) + && d->func != 0 + && (d->condition & FOR_READ) != 0) + d->func (channel, d->data, 1); + if (FD_ISSET (channel, &write_mask) + && d->func != 0 + && (d->condition & FOR_WRITE) != 0) + d->func (channel, d->data, 0); + } + /* Really FIRST_PROC_DESC should be 0 on Unix, but this is safer in the short run. */ for (channel = 0; channel <= max_process_desc; channel++) { if (FD_ISSET (channel, &Available) - && FD_ISSET (channel, &non_keyboard_wait_mask)) + && FD_ISSET (channel, &non_keyboard_wait_mask) + && !FD_ISSET (channel, &non_process_wait_mask)) { int nread; @@ -5209,12 +5056,13 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, } } #ifdef NON_BLOCKING_CONNECT - if (check_connect && FD_ISSET (channel, &Connecting) + if (FD_ISSET (channel, &Writeok) && FD_ISSET (channel, &connect_wait_mask)) { struct Lisp_Process *p; FD_CLR (channel, &connect_wait_mask); + FD_CLR (channel, &write_mask); if (--num_pending_connects < 0) abort (); @@ -5228,23 +5076,23 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. So only use it on systems where it is known to work. */ { - int xlen = sizeof(xerrno); - if (getsockopt(channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) + int xlen = sizeof (xerrno); + if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) xerrno = errno; } #else { struct sockaddr pname; - int pnamelen = sizeof(pname); + int pnamelen = sizeof (pname); /* If connection failed, getpeername will fail. */ xerrno = 0; - if (getpeername(channel, &pname, &pnamelen) < 0) + if (getpeername (channel, &pname, &pnamelen) < 0) { /* Obtain connect failure code through error slippage. */ char dummy; xerrno = errno; - if (errno == ENOTCONN && read(channel, &dummy, 1) < 0) + if (errno == ENOTCONN && read (channel, &dummy, 1) < 0) xerrno = errno; } } @@ -5291,15 +5139,13 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, /* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */ static Lisp_Object -read_process_output_call (fun_and_args) - Lisp_Object fun_and_args; +read_process_output_call (Lisp_Object fun_and_args) { return apply1 (XCAR (fun_and_args), XCDR (fun_and_args)); } static Lisp_Object -read_process_output_error_handler (error) - Lisp_Object error; +read_process_output_error_handler (Lisp_Object error) { cmd_error_internal (error, "error in process filter: "); Vinhibit_quit = Qt; @@ -5320,23 +5166,23 @@ read_process_output_error_handler (error) for decoding. */ static int -read_process_output (proc, channel) - Lisp_Object proc; - register int channel; +read_process_output (Lisp_Object proc, register int channel) { register int nbytes; char *chars; register Lisp_Object outstream; register struct Lisp_Process *p = XPROCESS (proc); - register int opoint; + register EMACS_INT opoint; struct coding_system *coding = proc_decode_coding_system[channel]; int carryover = p->decoding_carryover; int readmax = 4096; + int count = SPECPDL_INDEX (); + Lisp_Object odeactivate; chars = (char *) alloca (carryover + readmax); if (carryover) /* See the comment above. */ - bcopy (SDATA (p->decoding_buf), chars, carryover); + memcpy (chars, SDATA (p->decoding_buf), carryover); #ifdef DATAGRAM_SOCKETS /* We have a working select, so proc_buffered_char is always -1. */ @@ -5350,7 +5196,13 @@ read_process_output (proc, channel) #endif if (proc_buffered_char[channel] < 0) { - nbytes = emacs_read (channel, chars + carryover, readmax); +#ifdef HAVE_GNUTLS + if (XPROCESS (proc)->gnutls_p) + nbytes = emacs_gnutls_read (channel, XPROCESS (proc), + chars + carryover, readmax); + else +#endif + nbytes = emacs_read (channel, chars + carryover, readmax); #ifdef ADAPTIVE_READ_BUFFERING if (nbytes > 0 && p->adaptive_read_buffering) { @@ -5383,7 +5235,13 @@ read_process_output (proc, channel) { chars[carryover] = proc_buffered_char[channel]; proc_buffered_char[channel] = -1; - nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1); +#ifdef HAVE_GNUTLS + if (XPROCESS (proc)->gnutls_p) + nbytes = emacs_gnutls_read (channel, XPROCESS (proc), + chars + carryover + 1, readmax - 1); + else +#endif + nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1); if (nbytes < 0) nbytes = 1; else @@ -5404,15 +5262,16 @@ read_process_output (proc, channel) /* Now set NBYTES how many bytes we must decode. */ nbytes += carryover; + odeactivate = Vdeactivate_mark; + /* There's no good reason to let process filters change the current + buffer, and many callers of accept-process-output, sit-for, and + friends don't expect current-buffer to be changed from under them. */ + record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + /* Read and dispose of the process output. */ outstream = p->filter; if (!NILP (outstream)) { - /* We inhibit quit here instead of just catching it so that - hitting ^G when a filter happens to be running won't screw - it up. */ - int count = SPECPDL_INDEX (); - Lisp_Object odeactivate; Lisp_Object obuffer, okeymap; Lisp_Object text; int outer_running_asynch_code = running_asynch_code; @@ -5420,10 +5279,12 @@ read_process_output (proc, channel) /* No need to gcpro these, because all we do with them later is test them for EQness, and none of them should be a string. */ - odeactivate = Vdeactivate_mark; XSETBUFFER (obuffer, current_buffer); okeymap = current_buffer->keymap; + /* We inhibit quit here instead of just catching it so that + hitting ^G when a filter happens to be running won't screw + it up. */ specbind (Qinhibit_quit, Qt); specbind (Qlast_nonmenu_event, Qt); @@ -5477,8 +5338,8 @@ read_process_output (proc, channel) { if (SCHARS (p->decoding_buf) < coding->carryover_bytes) p->decoding_buf = make_uninit_string (coding->carryover_bytes); - bcopy (coding->carryover, SDATA (p->decoding_buf), - coding->carryover_bytes); + memcpy (SDATA (p->decoding_buf), coding->carryover, + coding->carryover_bytes); p->decoding_carryover = coding->carryover_bytes; } if (SBYTES (text) > 0) @@ -5492,9 +5353,6 @@ read_process_output (proc, channel) restore_search_regs (); running_asynch_code = outer_running_asynch_code; - /* Handling the process output should not deactivate the mark. */ - Vdeactivate_mark = odeactivate; - /* Restore waiting_for_user_input_p as it was when we were called, in case the filter clobbered it. */ waiting_for_user_input_p = waiting; @@ -5510,27 +5368,19 @@ read_process_output (proc, channel) cause trouble (for example it would make sit_for return). */ if (waiting_for_user_input_p == -1) record_asynch_buffer_change (); - - unbind_to (count, Qnil); - return nbytes; } /* If no filter, write into buffer if it isn't dead. */ - if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) + else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) { Lisp_Object old_read_only; - int old_begv, old_zv; - int old_begv_byte, old_zv_byte; - Lisp_Object odeactivate; - int before, before_byte; - int opoint_byte; + EMACS_INT old_begv, old_zv; + EMACS_INT old_begv_byte, old_zv_byte; + EMACS_INT before, before_byte; + EMACS_INT opoint_byte; Lisp_Object text; struct buffer *b; - int count = SPECPDL_INDEX (); - - odeactivate = Vdeactivate_mark; - record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); Fset_buffer (p->buffer); opoint = PT; opoint_byte = PT_BYTE; @@ -5580,8 +5430,8 @@ read_process_output (proc, channel) { if (SCHARS (p->decoding_buf) < coding->carryover_bytes) p->decoding_buf = make_uninit_string (coding->carryover_bytes); - bcopy (coding->carryover, SDATA (p->decoding_buf), - coding->carryover_bytes); + memcpy (SDATA (p->decoding_buf), coding->carryover, + coding->carryover_bytes); p->decoding_carryover = coding->carryover_bytes; } /* Adjust the multibyteness of TEXT to that of the buffer. */ @@ -5628,23 +5478,15 @@ read_process_output (proc, channel) if (old_begv != BEGV || old_zv != ZV) Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); - /* Handling the process output should not deactivate the mark. */ - Vdeactivate_mark = odeactivate; current_buffer->read_only = old_read_only; SET_PT_BOTH (opoint, opoint_byte); - unbind_to (count, Qnil); } - return nbytes; -} + /* Handling the process output should not deactivate the mark. */ + Vdeactivate_mark = odeactivate; -DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, - 0, 0, 0, - doc: /* Returns non-nil if Emacs is waiting for input from the user. -This is intended for use by asynchronous process output filters and sentinels. */) - () -{ - return (waiting_for_user_input_p ? Qt : Qnil); + unbind_to (count, Qnil); + return nbytes; } /* Sending data to subprocess */ @@ -5653,7 +5495,7 @@ jmp_buf send_process_frame; Lisp_Object process_sent_to; SIGTYPE -send_process_trap () +send_process_trap (int ignore) { SIGNAL_THREAD_CHECK (SIGPIPE); sigunblock (sigmask (SIGPIPE)); @@ -5671,18 +5513,15 @@ send_process_trap () This function can evaluate Lisp code and can garbage collect. */ static void -send_process (proc, buf, len, object) - volatile Lisp_Object proc; - unsigned char *volatile buf; - volatile int len; - volatile Lisp_Object object; +send_process (volatile Lisp_Object proc, const unsigned char *volatile buf, + volatile EMACS_INT len, volatile Lisp_Object object) { /* Use volatile to protect variables from being clobbered by longjmp. */ struct Lisp_Process *p = XPROCESS (proc); - int rv; + EMACS_INT rv; struct coding_system *coding; struct gcpro gcpro1; - SIGTYPE (*volatile old_sigpipe) (); + SIGTYPE (*volatile old_sigpipe) (int); GCPRO1 (object); @@ -5745,8 +5584,8 @@ send_process (proc, buf, len, object) coding->dst_object = Qt; if (BUFFERP (object)) { - int from_byte, from, to; - int save_pt, save_pt_byte; + EMACS_INT from_byte, from, to; + EMACS_INT save_pt, save_pt_byte; struct buffer *cur = current_buffer; set_buffer_internal (XBUFFER (object)); @@ -5798,41 +5637,13 @@ send_process (proc, buf, len, object) process_sent_to = proc; while (len > 0) { - int this = len; - - /* Decide how much data we can send in one batch. - Long lines need to be split into multiple batches. */ - if (p->pty_flag) - { - /* Starting this at zero is always correct when not the first - iteration because the previous iteration ended by sending C-d. - It may not be correct for the first iteration - if a partial line was sent in a separate send_process call. - If that proves worth handling, we need to save linepos - in the process object. */ - int linepos = 0; - unsigned char *ptr = (unsigned char *) buf; - unsigned char *end = (unsigned char *) buf + len; - - /* Scan through this text for a line that is too long. */ - while (ptr != end && linepos < pty_max_bytes) - { - if (*ptr == '\n') - linepos = 0; - else - linepos++; - ptr++; - } - /* If we found one, break the line there - and put in a C-d to force the buffer through. */ - this = ptr - buf; - } + EMACS_INT this = len; /* Send this batch, using one or more write calls. */ while (this > 0) { int outfd = p->outfd; - old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); + old_sigpipe = (SIGTYPE (*) (int)) signal (SIGPIPE, send_process_trap); #ifdef DATAGRAM_SOCKETS if (DATAGRAM_CHAN_P (outfd)) { @@ -5849,7 +5660,14 @@ send_process (proc, buf, len, object) else #endif { - rv = emacs_write (outfd, (char *) buf, this); +#ifdef HAVE_GNUTLS + if (XPROCESS (proc)->gnutls_p) + rv = emacs_gnutls_write (outfd, + XPROCESS (proc), + (char *) buf, this); + else +#endif + rv = emacs_write (outfd, (char *) buf, this); #ifdef ADAPTIVE_READ_BUFFERING if (p->read_output_delay > 0 && p->adaptive_read_buffering == 1) @@ -5931,11 +5749,6 @@ send_process (proc, buf, len, object) len -= rv; this -= rv; } - - /* If we sent just part of the string, put in an EOF (C-d) - to force it through, before we send the rest. */ - if (len > 0) - Fprocess_send_eof (proc); } } else @@ -5962,11 +5775,10 @@ Called from program, takes three arguments, PROCESS, START and END. If the region is more than 500 characters long, it is sent in several bunches. This may happen even for shorter regions. Output from processes can arrive in between bunches. */) - (process, start, end) - Lisp_Object process, start, end; + (Lisp_Object process, Lisp_Object start, Lisp_Object end) { Lisp_Object proc; - int start1, end1; + EMACS_INT start1, end1; proc = get_process (process); validate_region (&start, &end); @@ -5990,8 +5802,7 @@ nil, indicating the current buffer's process. If STRING is more than 500 characters long, it is sent in several bunches. This may happen even for shorter strings. Output from processes can arrive in between bunches. */) - (process, string) - Lisp_Object process, string; + (Lisp_Object process, Lisp_Object string) { Lisp_Object proc; CHECK_STRING (string); @@ -6004,8 +5815,7 @@ Output from processes can arrive in between bunches. */) /* Return the foreground process group for the tty/pty that the process P uses. */ static int -emacs_get_tty_pgrp (p) - struct Lisp_Process *p; +emacs_get_tty_pgrp (struct Lisp_Process *p) { int gid = -1; @@ -6033,8 +5843,7 @@ DEFUN ("process-running-child-p", Fprocess_running_child_p, doc: /* Return t if PROCESS has given the terminal to a child. If the operating system does not make it possible to find out, return t unconditionally. */) - (process) - Lisp_Object process; + (Lisp_Object process) { /* Initialize in case ioctl doesn't exist or gives an error, in a way that will cause returning t. */ @@ -6074,11 +5883,8 @@ return t unconditionally. */) their uid, for which killpg would return an EPERM error. */ static void -process_send_signal (process, signo, current_group, nomsg) - Lisp_Object process; - int signo; - Lisp_Object current_group; - int nomsg; +process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, + int nomsg) { Lisp_Object proc; register struct Lisp_Process *p; @@ -6108,9 +5914,6 @@ process_send_signal (process, signo, current_group, nomsg) /* If possible, send signals to the entire pgrp by sending an input character to it. */ - /* TERMIOS is the latest and bestest, and seems most likely to - work. If the system has it, use it. */ -#ifdef HAVE_TERMIOS struct termios t; cc_t *sig_char = NULL; @@ -6142,65 +5945,6 @@ process_send_signal (process, signo, current_group, nomsg) } /* If we can't send the signal with a character, fall through and send it another way. */ -#else /* ! HAVE_TERMIOS */ - - /* On Berkeley descendants, the following IOCTL's retrieve the - current control characters. */ -#if defined (TIOCGLTC) && defined (TIOCGETC) - - struct tchars c; - struct ltchars lc; - - switch (signo) - { - case SIGINT: - ioctl (p->infd, TIOCGETC, &c); - send_process (proc, &c.t_intrc, 1, Qnil); - return; - case SIGQUIT: - ioctl (p->infd, TIOCGETC, &c); - send_process (proc, &c.t_quitc, 1, Qnil); - return; -#ifdef SIGTSTP - case SIGTSTP: - ioctl (p->infd, TIOCGLTC, &lc); - send_process (proc, &lc.t_suspc, 1, Qnil); - return; -#endif /* ! defined (SIGTSTP) */ - } - -#else /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ - - /* On SYSV descendants, the TCGETA ioctl retrieves the current control - characters. */ -#ifdef TCGETA - struct termio t; - switch (signo) - { - case SIGINT: - ioctl (p->infd, TCGETA, &t); - send_process (proc, &t.c_cc[VINTR], 1, Qnil); - return; - case SIGQUIT: - ioctl (p->infd, TCGETA, &t); - send_process (proc, &t.c_cc[VQUIT], 1, Qnil); - return; -#ifdef SIGTSTP - case SIGTSTP: - ioctl (p->infd, TCGETA, &t); - send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); - return; -#endif /* ! defined (SIGTSTP) */ - } -#else /* ! defined (TCGETA) */ - Your configuration files are messed up. - /* If your system configuration files define SIGNALS_VIA_CHARACTERS, - you'd better be using one of the alternatives above! */ -#endif /* ! defined (TCGETA) */ -#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ - /* In this case, the code above should alway return. */ - abort (); -#endif /* ! defined HAVE_TERMIOS */ /* The code above may fall through if it can't handle the signal. */ @@ -6298,8 +6042,7 @@ rather than the shell. If CURRENT-GROUP is `lambda', and if the shell owns the terminal, don't send the signal. */) - (process, current_group) - Lisp_Object process, current_group; + (Lisp_Object process, Lisp_Object current_group) { process_send_signal (process, SIGINT, current_group, 0); return process; @@ -6308,8 +6051,7 @@ don't send the signal. */) DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, doc: /* Kill process PROCESS. May be process or name of one. See function `interrupt-process' for more details on usage. */) - (process, current_group) - Lisp_Object process, current_group; + (Lisp_Object process, Lisp_Object current_group) { process_send_signal (process, SIGKILL, current_group, 0); return process; @@ -6318,8 +6060,7 @@ See function `interrupt-process' for more details on usage. */) DEFUN ("quit-process", Fquit_process, Squit_process, 0, 2, 0, doc: /* Send QUIT signal to process PROCESS. May be process or name of one. See function `interrupt-process' for more details on usage. */) - (process, current_group) - Lisp_Object process, current_group; + (Lisp_Object process, Lisp_Object current_group) { process_send_signal (process, SIGQUIT, current_group, 0); return process; @@ -6330,10 +6071,8 @@ DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0, See function `interrupt-process' for more details on usage. If PROCESS is a network or serial process, inhibit handling of incoming traffic. */) - (process, current_group) - Lisp_Object process, current_group; + (Lisp_Object process, Lisp_Object current_group) { -#ifdef HAVE_SOCKETS if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) { struct Lisp_Process *p; @@ -6348,7 +6087,6 @@ traffic. */) p->command = Qt; return process; } -#endif #ifndef SIGTSTP error ("No SIGTSTP support"); #else @@ -6362,10 +6100,8 @@ DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0, See function `interrupt-process' for more details on usage. If PROCESS is a network or serial process, resume handling of incoming traffic. */) - (process, current_group) - Lisp_Object process, current_group; + (Lisp_Object process, Lisp_Object current_group) { -#ifdef HAVE_SOCKETS if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) { struct Lisp_Process *p; @@ -6380,15 +6116,13 @@ traffic. */) #ifdef WINDOWSNT if (fd_info[ p->infd ].flags & FILE_SERIAL) PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR); -#endif -#ifdef HAVE_TERMIOS +#else /* not WINDOWSNT */ tcflush (p->infd, TCIFLUSH); -#endif +#endif /* not WINDOWSNT */ } p->command = Qnil; return process; } -#endif #ifdef SIGCONT process_send_signal (process, SIGCONT, current_group, 0); #else @@ -6404,8 +6138,7 @@ PROCESS may also be a number specifying the process id of the process to signal; in this case, the process need not be a child of this Emacs. SIGCODE may be an integer, or a symbol whose name is a signal name. */) - (process, sigcode) - Lisp_Object process, sigcode; + (Lisp_Object process, Lisp_Object sigcode) { pid_t pid; @@ -6458,7 +6191,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) CHECK_SYMBOL (sigcode); name = SDATA (SYMBOL_NAME (sigcode)); - if (!strncmp(name, "SIG", 3) || !strncmp(name, "sig", 3)) + if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3)) name += 3; if (0) @@ -6572,8 +6305,7 @@ through a pipe (as opposed to a pty), then you cannot send any more text to PROCESS after you call this function. If PROCESS is a serial process, wait until all output written to the process has been transmitted to the serial port. */) - (process) - Lisp_Object process; + (Lisp_Object process) { Lisp_Object proc; struct coding_system *coding; @@ -6600,10 +6332,10 @@ process has been transmitted to the serial port. */) send_process (proc, "\004", 1, Qnil); else if (EQ (XPROCESS (proc)->type, Qserial)) { -#ifdef HAVE_TERMIOS +#ifndef WINDOWSNT if (tcdrain (XPROCESS (proc)->outfd) != 0) error ("tcdrain() failed: %s", emacs_strerror (errno)); -#endif +#endif /* not WINDOWSNT */ /* Do nothing on Windows because writes are blocking. */ } else @@ -6632,39 +6364,16 @@ process has been transmitted to the serial port. */) if (!proc_encode_coding_system[new_outfd]) proc_encode_coding_system[new_outfd] = (struct coding_system *) xmalloc (sizeof (struct coding_system)); - bcopy (proc_encode_coding_system[old_outfd], - proc_encode_coding_system[new_outfd], - sizeof (struct coding_system)); - bzero (proc_encode_coding_system[old_outfd], - sizeof (struct coding_system)); + memcpy (proc_encode_coding_system[new_outfd], + proc_encode_coding_system[old_outfd], + sizeof (struct coding_system)); + memset (proc_encode_coding_system[old_outfd], 0, + sizeof (struct coding_system)); XPROCESS (proc)->outfd = new_outfd; } return process; } - -/* Kill all processes associated with `buffer'. - If `buffer' is nil, kill all processes */ - -void -kill_buffer_processes (buffer) - Lisp_Object buffer; -{ - Lisp_Object tail, proc; - - for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) - { - proc = XCDR (XCAR (tail)); - if (PROCESSP (proc) - && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) - { - if (NETCONN_P (proc) || SERIALCONN_P (proc)) - Fdelete_process (proc); - else if (XPROCESS (proc)->infd >= 0) - process_send_signal (proc, SIGHUP, Qnil, 1); - } - } -} /* On receipt of a signal that a child status has changed, loop asking about children with changed statuses until the system says there @@ -6693,13 +6402,11 @@ kill_buffer_processes (buffer) #ifdef SIGCHLD SIGTYPE -sigchld_handler (signo) - int signo; +sigchld_handler (int signo) { int old_errno = errno; Lisp_Object proc; - register struct Lisp_Process *p; - extern EMACS_TIME *input_available_clear_time; + struct Lisp_Process *p; SIGNAL_THREAD_CHECK (signo); @@ -6726,11 +6433,6 @@ sigchld_handler (signo) /* PID == 0 means no processes found, PID == -1 means a real failure. We have done all our job, so return. */ - /* USG systems forget handlers when they are used; - must reestablish each time */ -#if defined (USG) && !defined (POSIX_SIGNALS) - signal (signo, sigchld_handler); /* WARNING - must come after wait3() */ -#endif errno = old_errno; return; } @@ -6831,9 +6533,6 @@ sigchld_handler (signo) #if (defined WINDOWSNT \ || (defined USG && !defined GNU_LINUX \ && !(defined HPUX && defined WNOHANG))) -#if defined (USG) && ! defined (POSIX_SIGNALS) - signal (signo, sigchld_handler); -#endif errno = old_errno; return; #endif /* USG, but not HPUX with WNOHANG */ @@ -6843,16 +6542,14 @@ sigchld_handler (signo) static Lisp_Object -exec_sentinel_unwind (data) - Lisp_Object data; +exec_sentinel_unwind (Lisp_Object data) { XPROCESS (XCAR (data))->sentinel = XCDR (data); return Qnil; } static Lisp_Object -exec_sentinel_error_handler (error) - Lisp_Object error; +exec_sentinel_error_handler (Lisp_Object error) { cmd_error_internal (error, "error in process sentinel: "); Vinhibit_quit = Qt; @@ -6862,8 +6559,7 @@ exec_sentinel_error_handler (error) } static void -exec_sentinel (proc, reason) - Lisp_Object proc, reason; +exec_sentinel (Lisp_Object proc, Lisp_Object reason) { Lisp_Object sentinel, obuffer, odeactivate, okeymap; register struct Lisp_Process *p = XPROCESS (proc); @@ -6880,6 +6576,11 @@ exec_sentinel (proc, reason) XSETBUFFER (obuffer, current_buffer); okeymap = current_buffer->keymap; + /* There's no good reason to let sentinels change the current + buffer, and many callers of accept-process-output, sit-for, and + friends don't expect current-buffer to be changed from under them. */ + record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + sentinel = p->sentinel; if (NILP (sentinel)) return; @@ -6943,8 +6644,7 @@ exec_sentinel (proc, reason) but can be done at other times. */ static void -status_notify (deleting_process) - struct Lisp_Process *deleting_process; +status_notify (struct Lisp_Process *deleting_process) { register Lisp_Object proc, buffer; Lisp_Object tail, msg; @@ -7017,12 +6717,10 @@ status_notify (deleting_process) when a process becomes runnable. */ else if (!EQ (symbol, Qrun) && !NILP (buffer)) { - Lisp_Object ro, tem; + Lisp_Object tem; struct buffer *old = current_buffer; - int opoint, opoint_byte; - int before, before_byte; - - ro = XBUFFER (buffer)->read_only; + EMACS_INT opoint, opoint_byte; + EMACS_INT before, before_byte; /* Avoid error if buffer is deleted (probably that's why the process is dead, too) */ @@ -7073,8 +6771,7 @@ DEFUN ("set-process-coding-system", Fset_process_coding_system, doc: /* Set coding systems of PROCESS to DECODING and ENCODING. DECODING will be used to decode subprocess output and ENCODING to encode subprocess input. */) - (process, decoding, encoding) - register Lisp_Object process, decoding, encoding; + (register Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding) { register struct Lisp_Process *p; @@ -7097,8 +6794,7 @@ encode subprocess input. */) DEFUN ("process-coding-system", Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0, doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */) - (process) - register Lisp_Object process; + (register Lisp_Object process) { CHECK_PROCESS (process); return Fcons (XPROCESS (process)->decode_coding_system, @@ -7112,8 +6808,7 @@ If FLAG is non-nil, the filter is given multibyte strings. If FLAG is nil, the filter is given unibyte strings. In this case, all character code conversion except for end-of-line conversion is suppressed. */) - (process, flag) - Lisp_Object process, flag; + (Lisp_Object process, Lisp_Object flag) { register struct Lisp_Process *p; @@ -7129,8 +6824,7 @@ suppressed. */) DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, Sprocess_filter_multibyte_p, 1, 1, 0, doc: /* Return t if a multibyte string is given to PROCESS's filter.*/) - (process) - Lisp_Object process; + (Lisp_Object process) { register struct Lisp_Process *p; struct coding_system *coding; @@ -7143,87 +6837,458 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, -/* Add DESC to the set of keyboard input descriptors. */ void -add_keyboard_wait_descriptor (desc) - int desc; +add_gpm_wait_descriptor (int desc) { - FD_SET (desc, &input_wait_mask); - FD_SET (desc, &non_process_wait_mask); - if (desc > max_keyboard_desc) - max_keyboard_desc = desc; + add_keyboard_wait_descriptor (desc); +} + +void +delete_gpm_wait_descriptor (int desc) +{ + delete_keyboard_wait_descriptor (desc); +} + +/* Return nonzero if *MASK has a bit set + that corresponds to one of the keyboard input descriptors. */ + +static int +keyboard_bit_set (fd_set *mask) +{ + int fd; + + for (fd = 0; fd <= max_input_desc; fd++) + if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask) + && !FD_ISSET (fd, &non_keyboard_wait_mask)) + return 1; + + return 0; +} + +#else /* not subprocesses */ + +/* Defined on msdos.c. */ +extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, + EMACS_TIME *); + +/* Implementation of wait_reading_process_output, assuming that there + are no subprocesses. Used only by the MS-DOS build. + + Wait for timeout to elapse and/or keyboard input to be available. + + time_limit is: + timeout in seconds, or + zero for no limit, or + -1 means gobble data immediately available but don't wait for any. + + read_kbd is a Lisp_Object: + 0 to ignore keyboard input, or + 1 to return when input is available, or + -1 means caller will actually read the input, so don't throw to + the quit handler. + + see full version for other parameters. We know that wait_proc will + always be NULL, since `subprocesses' isn't defined. + + do_display != 0 means redisplay should be done to show subprocess + output that arrives. + + Return true if we received input from any process. */ + +int +wait_reading_process_output (int time_limit, int microsecs, int read_kbd, + int do_display, + Lisp_Object wait_for_cell, + struct Lisp_Process *wait_proc, int just_wait_proc) +{ + register int nfds; + EMACS_TIME end_time, timeout; + SELECT_TYPE waitchannels; + int xerrno; + + /* What does time_limit really mean? */ + if (time_limit || microsecs) + { + EMACS_GET_TIME (end_time); + EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); + EMACS_ADD_TIME (end_time, end_time, timeout); + } + + /* Turn off periodic alarms (in case they are in use) + and then turn off any other atimers, + because the select emulator uses alarms. */ + stop_polling (); + turn_on_atimers (0); + + while (1) + { + int timeout_reduced_for_timers = 0; + + /* If calling from keyboard input, do not quit + since we want to return C-g as an input character. + Otherwise, do pending quit if requested. */ + if (read_kbd >= 0) + QUIT; + + /* Exit now if the cell we're waiting for became non-nil. */ + if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) + break; + + /* Compute time from now till when time limit is up */ + /* Exit if already run out */ + if (time_limit == -1) + { + /* -1 specified for timeout means + gobble output available now + but don't wait at all. */ + + EMACS_SET_SECS_USECS (timeout, 0, 0); + } + else if (time_limit || microsecs) + { + EMACS_GET_TIME (timeout); + EMACS_SUB_TIME (timeout, end_time, timeout); + if (EMACS_TIME_NEG_P (timeout)) + break; + } + else + { + EMACS_SET_SECS_USECS (timeout, 100000, 0); + } + + /* If our caller will not immediately handle keyboard events, + run timer events directly. + (Callers that will immediately read keyboard events + call timer_delay on their own.) */ + if (NILP (wait_for_cell)) + { + EMACS_TIME timer_delay; + + do + { + int old_timers_run = timers_run; + timer_delay = timer_check (1); + if (timers_run != old_timers_run && do_display) + /* We must retry, since a timer may have requeued itself + and that could alter the time delay. */ + redisplay_preserve_echo_area (14); + else + break; + } + while (!detect_input_pending ()); + + /* If there is unread keyboard input, also return. */ + if (read_kbd != 0 + && requeued_events_pending_p ()) + break; + + if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) + { + EMACS_TIME difference; + EMACS_SUB_TIME (difference, timer_delay, timeout); + if (EMACS_TIME_NEG_P (difference)) + { + timeout = timer_delay; + timeout_reduced_for_timers = 1; + } + } + } + + /* Cause C-g and alarm signals to take immediate action, + and cause input available signals to zero out timeout. */ + if (read_kbd < 0) + set_waiting_for_input (&timeout); + + /* Wait till there is something to do. */ + + if (! read_kbd && NILP (wait_for_cell)) + FD_ZERO (&waitchannels); + else + FD_SET (0, &waitchannels); + + /* If a frame has been newly mapped and needs updating, + reprocess its display stuff. */ + if (frame_garbaged && do_display) + { + clear_waiting_for_input (); + redisplay_preserve_echo_area (15); + if (read_kbd < 0) + set_waiting_for_input (&timeout); + } + + if (read_kbd && detect_input_pending ()) + { + nfds = 0; + FD_ZERO (&waitchannels); + } + else + nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0, + &timeout); + + xerrno = errno; + + /* Make C-g and alarm signals set flags again */ + clear_waiting_for_input (); + + /* If we woke up due to SIGWINCH, actually change size now. */ + do_pending_window_change (0); + + if (time_limit && nfds == 0 && ! timeout_reduced_for_timers) + /* We waited the full specified time, so return now. */ + break; + + if (nfds == -1) + { + /* If the system call was interrupted, then go around the + loop again. */ + if (xerrno == EINTR) + FD_ZERO (&waitchannels); + else + error ("select error: %s", emacs_strerror (xerrno)); + } + + /* Check for keyboard input */ + + if (read_kbd + && detect_input_pending_run_timers (do_display)) + { + swallow_events (do_display); + if (detect_input_pending_run_timers (do_display)) + break; + } + + /* If there is unread keyboard input, also return. */ + if (read_kbd + && requeued_events_pending_p ()) + break; + + /* If wait_for_cell. check for keyboard input + but don't run any timers. + ??? (It seems wrong to me to check for keyboard + input at all when wait_for_cell, but the code + has been this way since July 1994. + Try changing this after version 19.31.) */ + if (! NILP (wait_for_cell) + && detect_input_pending ()) + { + swallow_events (do_display); + if (detect_input_pending ()) + break; + } + + /* Exit now if the cell we're waiting for became non-nil. */ + if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) + break; + } + + start_polling (); + + return 0; } -static int add_gpm_wait_descriptor_called_flag; +#endif /* not subprocesses */ + +/* The following functions are needed even if async subprocesses are + not supported. Some of them are no-op stubs in that case. */ + +/* Add DESC to the set of keyboard input descriptors. */ void -add_gpm_wait_descriptor (desc) - int desc; +add_keyboard_wait_descriptor (int desc) { - if (! add_gpm_wait_descriptor_called_flag) - FD_CLR (0, &input_wait_mask); - add_gpm_wait_descriptor_called_flag = 1; +#ifdef subprocesses /* actually means "not MSDOS" */ FD_SET (desc, &input_wait_mask); - FD_SET (desc, &gpm_wait_mask); - if (desc > max_gpm_desc) - max_gpm_desc = desc; + FD_SET (desc, &non_process_wait_mask); + if (desc > max_input_desc) + max_input_desc = desc; +#endif } /* From now on, do not expect DESC to give keyboard input. */ void -delete_keyboard_wait_descriptor (desc) - int desc; +delete_keyboard_wait_descriptor (int desc) { +#ifdef subprocesses int fd; - int lim = max_keyboard_desc; + int lim = max_input_desc; FD_CLR (desc, &input_wait_mask); FD_CLR (desc, &non_process_wait_mask); - if (desc == max_keyboard_desc) + if (desc == max_input_desc) for (fd = 0; fd < lim; fd++) - if (FD_ISSET (fd, &input_wait_mask) - && !FD_ISSET (fd, &non_keyboard_wait_mask) - && !FD_ISSET (fd, &gpm_wait_mask)) - max_keyboard_desc = fd; + if (FD_ISSET (fd, &input_wait_mask) || FD_ISSET (fd, &write_mask)) + max_input_desc = fd; +#endif } +/* Setup coding systems of PROCESS. */ + void -delete_gpm_wait_descriptor (desc) - int desc; +setup_process_coding_systems (Lisp_Object process) { - int fd; - int lim = max_gpm_desc; +#ifdef subprocesses + struct Lisp_Process *p = XPROCESS (process); + int inch = p->infd; + int outch = p->outfd; + Lisp_Object coding_system; - FD_CLR (desc, &input_wait_mask); - FD_CLR (desc, &non_process_wait_mask); + if (inch < 0 || outch < 0) + return; - if (desc == max_gpm_desc) - for (fd = 0; fd < lim; fd++) - if (FD_ISSET (fd, &input_wait_mask) - && !FD_ISSET (fd, &non_keyboard_wait_mask) - && !FD_ISSET (fd, &non_process_wait_mask)) - max_gpm_desc = fd; + if (!proc_decode_coding_system[inch]) + proc_decode_coding_system[inch] + = (struct coding_system *) xmalloc (sizeof (struct coding_system)); + coding_system = p->decode_coding_system; + if (! NILP (p->filter)) + ; + else if (BUFFERP (p->buffer)) + { + if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) + coding_system = raw_text_coding_system (coding_system); + } + setup_coding_system (coding_system, proc_decode_coding_system[inch]); + + if (!proc_encode_coding_system[outch]) + proc_encode_coding_system[outch] + = (struct coding_system *) xmalloc (sizeof (struct coding_system)); + setup_coding_system (p->encode_coding_system, + proc_encode_coding_system[outch]); +#endif } -/* Return nonzero if *MASK has a bit set - that corresponds to one of the keyboard input descriptors. */ +/* Close all descriptors currently in use for communication + with subprocess. This is used in a newly-forked subprocess + to get rid of irrelevant descriptors. */ -static int -keyboard_bit_set (mask) - SELECT_TYPE *mask; +void +close_process_descs (void) { - int fd; +#ifndef DOS_NT + int i; + for (i = 0; i < MAXDESC; i++) + { + Lisp_Object process; + process = chan_process[i]; + if (!NILP (process)) + { + int in = XPROCESS (process)->infd; + int out = XPROCESS (process)->outfd; + if (in >= 0) + emacs_close (in); + if (out >= 0 && in != out) + emacs_close (out); + } + } +#endif +} - for (fd = 0; fd <= max_keyboard_desc; fd++) - if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask) - && !FD_ISSET (fd, &non_keyboard_wait_mask)) - return 1; +DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, + doc: /* Return the (or a) process associated with BUFFER. +BUFFER may be a buffer or the name of one. */) + (register Lisp_Object buffer) +{ +#ifdef subprocesses + register Lisp_Object buf, tail, proc; - return 0; + if (NILP (buffer)) return Qnil; + buf = Fget_buffer (buffer); + if (NILP (buf)) return Qnil; + + for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) + { + proc = Fcdr (XCAR (tail)); + if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf)) + return proc; + } +#endif /* subprocesses */ + return Qnil; } + +DEFUN ("process-inherit-coding-system-flag", + Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, + 1, 1, 0, + doc: /* Return the value of inherit-coding-system flag for PROCESS. +If this flag is t, `buffer-file-coding-system' of the buffer +associated with PROCESS will inherit the coding system used to decode +the process output. */) + (register Lisp_Object process) +{ +#ifdef subprocesses + CHECK_PROCESS (process); + return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil; +#else + /* Ignore the argument and return the value of + inherit-process-coding-system. */ + return inherit_process_coding_system ? Qt : Qnil; +#endif +} + +/* Kill all processes associated with `buffer'. + If `buffer' is nil, kill all processes */ + +void +kill_buffer_processes (Lisp_Object buffer) +{ +#ifdef subprocesses + Lisp_Object tail, proc; + + for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) + { + proc = XCDR (XCAR (tail)); + if (PROCESSP (proc) + && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) + { + if (NETCONN_P (proc) || SERIALCONN_P (proc)) + Fdelete_process (proc); + else if (XPROCESS (proc)->infd >= 0) + process_send_signal (proc, SIGHUP, Qnil, 1); + } + } +#else /* subprocesses */ + /* Since we have no subprocesses, this does nothing. */ +#endif /* subprocesses */ +} + +DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, + 0, 0, 0, + doc: /* Returns non-nil if Emacs is waiting for input from the user. +This is intended for use by asynchronous process output filters and sentinels. */) + (void) +{ +#ifdef subprocesses + return (waiting_for_user_input_p ? Qt : Qnil); +#else + return Qnil; +#endif +} + +/* Stop reading input from keyboard sources. */ + +void +hold_keyboard_input (void) +{ + kbd_is_on_hold = 1; +} + +/* Resume reading input from keyboard sources. */ + +void +unhold_keyboard_input (void) +{ + kbd_is_on_hold = 0; +} + +/* Return non-zero if keyboard input is on hold, zero otherwise. */ + +int +kbd_on_hold_p (void) +{ + return kbd_is_on_hold; +} + /* Enumeration of and access to system processes a-la ps(1). */ @@ -7233,7 +7298,7 @@ DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes, If this functionality is unsupported, return nil. See `process-attributes' for getting attributes of a process given its ID. */) - () + (void) { return list_system_processes (); } @@ -7289,16 +7354,16 @@ integer or floating point values. pmem -- percents of total physical memory used by process's resident set (floating-point number) args -- command line which invoked the process (string). */) - (pid) - - Lisp_Object pid; + ( Lisp_Object pid) { return system_process_attributes (pid); } + void -init_process () +init_process (void) { +#ifdef subprocesses register int i; inhibit_sentinels = 0; @@ -7313,7 +7378,9 @@ init_process () FD_ZERO (&input_wait_mask); FD_ZERO (&non_keyboard_wait_mask); FD_ZERO (&non_process_wait_mask); + FD_ZERO (&write_mask); max_process_desc = 0; + memset (fd_callback_info, 0, sizeof (fd_callback_info)); #ifdef NON_BLOCKING_CONNECT FD_ZERO (&connect_wait_mask); @@ -7341,13 +7408,12 @@ init_process () chan_process[i] = Qnil; proc_buffered_char[i] = -1; } - bzero (proc_decode_coding_system, sizeof proc_decode_coding_system); - bzero (proc_encode_coding_system, sizeof proc_encode_coding_system); + memset (proc_decode_coding_system, 0, sizeof proc_decode_coding_system); + memset (proc_encode_coding_system, 0, sizeof proc_encode_coding_system); #ifdef DATAGRAM_SOCKETS - bzero (datagram_address, sizeof datagram_address); + memset (datagram_address, 0, sizeof datagram_address); #endif -#ifdef HAVE_SOCKETS { Lisp_Object subfeatures = Qnil; const struct socket_options *sopt; @@ -7383,25 +7449,28 @@ init_process () Fprovide (intern_c_string ("make-network-process"), subfeatures); } -#endif /* HAVE_SOCKETS */ #if defined (DARWIN_OS) /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive processes. As such, we only change the default value. */ if (initialized) { - char *release = get_operating_system_release(); + const char *release = get_operating_system_release (); if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION && release[1] == '.')) { Vprocess_connection_type = Qnil; } } #endif +#endif /* subprocesses */ + kbd_is_on_hold = 0; } void -syms_of_process () +syms_of_process (void) { +#ifdef subprocesses + Qprocessp = intern_c_string ("processp"); staticpro (&Qprocessp); Qrun = intern_c_string ("run"); @@ -7472,17 +7541,12 @@ syms_of_process () staticpro (&Qnetwork); Qserial = intern_c_string ("serial"); staticpro (&Qserial); - - QCname = intern_c_string (":name"); - staticpro (&QCname); QCbuffer = intern_c_string (":buffer"); staticpro (&QCbuffer); QChost = intern_c_string (":host"); staticpro (&QChost); QCservice = intern_c_string (":service"); staticpro (&QCservice); - QCtype = intern_c_string (":type"); - staticpro (&QCtype); QClocal = intern_c_string (":local"); staticpro (&QClocal); QCremote = intern_c_string (":remote"); @@ -7514,6 +7578,13 @@ syms_of_process () staticpro (&deleted_pid_list); #endif +#endif /* subprocesses */ + + QCname = intern_c_string (":name"); + staticpro (&QCname); + QCtype = intern_c_string (":type"); + staticpro (&QCtype); + Qeuid = intern_c_string ("euid"); staticpro (&Qeuid); Qegid = intern_c_string ("egid"); @@ -7583,6 +7654,7 @@ A value of nil means don't delete them until `list-processes' is run. */); delete_exited_processes = 1; +#ifdef subprocesses DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type, doc: /* Control type of device used to communicate with subprocesses. Values are nil to use a pipe, or t or `pty' to use a pty. @@ -7607,7 +7679,6 @@ The variable takes effect when `start-process' is called. */); defsubr (&Sprocessp); defsubr (&Sget_process); - defsubr (&Sget_buffer_process); defsubr (&Sdelete_process); defsubr (&Sprocess_status); defsubr (&Sprocess_exit_status); @@ -7624,7 +7695,6 @@ The variable takes effect when `start-process' is called. */); defsubr (&Sprocess_sentinel); defsubr (&Sset_process_window_size); defsubr (&Sset_process_inherit_coding_system_flag); - defsubr (&Sprocess_inherit_coding_system_flag); defsubr (&Sset_process_query_on_exit_flag); defsubr (&Sprocess_query_on_exit_flag); defsubr (&Sprocess_contact); @@ -7633,23 +7703,19 @@ The variable takes effect when `start-process' is called. */); defsubr (&Slist_processes); defsubr (&Sprocess_list); defsubr (&Sstart_process); -#ifdef HAVE_SERIAL defsubr (&Sserial_process_configure); defsubr (&Smake_serial_process); -#endif /* HAVE_SERIAL */ -#ifdef HAVE_SOCKETS defsubr (&Sset_network_process_option); defsubr (&Smake_network_process); defsubr (&Sformat_network_address); -#endif /* HAVE_SOCKETS */ -#if defined(HAVE_SOCKETS) && defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) +#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) #ifdef SIOCGIFCONF defsubr (&Snetwork_interface_list); #endif #if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) defsubr (&Snetwork_interface_info); #endif -#endif /* HAVE_SOCKETS ... */ +#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */ #ifdef DATAGRAM_SOCKETS defsubr (&Sprocess_datagram_address); defsubr (&Sset_process_datagram_address); @@ -7671,449 +7737,8 @@ The variable takes effect when `start-process' is called. */); defsubr (&Sprocess_coding_system); defsubr (&Sset_process_filter_multibyte); defsubr (&Sprocess_filter_multibyte_p); - defsubr (&Slist_system_processes); - defsubr (&Sprocess_attributes); -} - - -#else /* not subprocesses */ - -#include <sys/types.h> -#include <errno.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <fcntl.h> -#include <setjmp.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "lisp.h" -#include "systime.h" -#include "character.h" -#include "coding.h" -#include "termopts.h" -#include "sysselect.h" - -extern int frame_garbaged; - -extern EMACS_TIME timer_check (); -extern int timers_run; - -Lisp_Object QCtype, QCname; - -Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid; -Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime; -Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; -Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime; - -/* As described above, except assuming that there are no subprocesses: - - Wait for timeout to elapse and/or keyboard input to be available. - - time_limit is: - timeout in seconds, or - zero for no limit, or - -1 means gobble data immediately available but don't wait for any. - - read_kbd is a Lisp_Object: - 0 to ignore keyboard input, or - 1 to return when input is available, or - -1 means caller will actually read the input, so don't throw to - the quit handler. - - see full version for other parameters. We know that wait_proc will - always be NULL, since `subprocesses' isn't defined. - - do_display != 0 means redisplay should be done to show subprocess - output that arrives. - - Return true if we received input from any process. */ - -int -wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, - wait_for_cell, wait_proc, just_wait_proc) - int time_limit, microsecs, read_kbd, do_display; - Lisp_Object wait_for_cell; - struct Lisp_Process *wait_proc; - int just_wait_proc; -{ - register int nfds; - EMACS_TIME end_time, timeout; - SELECT_TYPE waitchannels; - int xerrno; - - /* What does time_limit really mean? */ - if (time_limit || microsecs) - { - EMACS_GET_TIME (end_time); - EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); - EMACS_ADD_TIME (end_time, end_time, timeout); - } - - /* Turn off periodic alarms (in case they are in use) - and then turn off any other atimers, - because the select emulator uses alarms. */ - stop_polling (); - turn_on_atimers (0); - - while (1) - { - int timeout_reduced_for_timers = 0; - - /* If calling from keyboard input, do not quit - since we want to return C-g as an input character. - Otherwise, do pending quit if requested. */ - if (read_kbd >= 0) - QUIT; - - /* Exit now if the cell we're waiting for became non-nil. */ - if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) - break; - - /* Compute time from now till when time limit is up */ - /* Exit if already run out */ - if (time_limit == -1) - { - /* -1 specified for timeout means - gobble output available now - but don't wait at all. */ - - EMACS_SET_SECS_USECS (timeout, 0, 0); - } - else if (time_limit || microsecs) - { - EMACS_GET_TIME (timeout); - EMACS_SUB_TIME (timeout, end_time, timeout); - if (EMACS_TIME_NEG_P (timeout)) - break; - } - else - { - EMACS_SET_SECS_USECS (timeout, 100000, 0); - } - - /* If our caller will not immediately handle keyboard events, - run timer events directly. - (Callers that will immediately read keyboard events - call timer_delay on their own.) */ - if (NILP (wait_for_cell)) - { - EMACS_TIME timer_delay; - - do - { - int old_timers_run = timers_run; - timer_delay = timer_check (1); - if (timers_run != old_timers_run && do_display) - /* We must retry, since a timer may have requeued itself - and that could alter the time delay. */ - redisplay_preserve_echo_area (14); - else - break; - } - while (!detect_input_pending ()); - - /* If there is unread keyboard input, also return. */ - if (read_kbd != 0 - && requeued_events_pending_p ()) - break; - - if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) - { - EMACS_TIME difference; - EMACS_SUB_TIME (difference, timer_delay, timeout); - if (EMACS_TIME_NEG_P (difference)) - { - timeout = timer_delay; - timeout_reduced_for_timers = 1; - } - } - } - - /* Cause C-g and alarm signals to take immediate action, - and cause input available signals to zero out timeout. */ - if (read_kbd < 0) - set_waiting_for_input (&timeout); - - /* Wait till there is something to do. */ - - if (! read_kbd && NILP (wait_for_cell)) - FD_ZERO (&waitchannels); - else - FD_SET (0, &waitchannels); - - /* If a frame has been newly mapped and needs updating, - reprocess its display stuff. */ - if (frame_garbaged && do_display) - { - clear_waiting_for_input (); - redisplay_preserve_echo_area (15); - if (read_kbd < 0) - set_waiting_for_input (&timeout); - } - - if (read_kbd && detect_input_pending ()) - { - nfds = 0; - FD_ZERO (&waitchannels); - } - else - nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0, - &timeout); - - xerrno = errno; - - /* Make C-g and alarm signals set flags again */ - clear_waiting_for_input (); - /* If we woke up due to SIGWINCH, actually change size now. */ - do_pending_window_change (0); - - if (time_limit && nfds == 0 && ! timeout_reduced_for_timers) - /* We waited the full specified time, so return now. */ - break; - - if (nfds == -1) - { - /* If the system call was interrupted, then go around the - loop again. */ - if (xerrno == EINTR) - FD_ZERO (&waitchannels); - else - error ("select error: %s", emacs_strerror (xerrno)); - } -#ifdef SOLARIS2 - else if (nfds > 0 && (waitchannels & 1) && interrupt_input) - /* System sometimes fails to deliver SIGIO. */ - kill (getpid (), SIGIO); -#endif -#ifdef SIGIO - if (read_kbd && interrupt_input && (waitchannels & 1)) - kill (getpid (), SIGIO); -#endif - - /* Check for keyboard input */ - - if (read_kbd - && detect_input_pending_run_timers (do_display)) - { - swallow_events (do_display); - if (detect_input_pending_run_timers (do_display)) - break; - } - - /* If there is unread keyboard input, also return. */ - if (read_kbd - && requeued_events_pending_p ()) - break; - - /* If wait_for_cell. check for keyboard input - but don't run any timers. - ??? (It seems wrong to me to check for keyboard - input at all when wait_for_cell, but the code - has been this way since July 1994. - Try changing this after version 19.31.) */ - if (! NILP (wait_for_cell) - && detect_input_pending ()) - { - swallow_events (do_display); - if (detect_input_pending ()) - break; - } - - /* Exit now if the cell we're waiting for became non-nil. */ - if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) - break; - } - - start_polling (); - - return 0; -} - - -/* Don't confuse make-docfile by having two doc strings for this function. - make-docfile does not pay attention to #if, for good reason! */ -DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, - 0) - (name) - register Lisp_Object name; -{ - return Qnil; -} - - /* Don't confuse make-docfile by having two doc strings for this function. - make-docfile does not pay attention to #if, for good reason! */ -DEFUN ("process-inherit-coding-system-flag", - Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, - 1, 1, 0, - 0) - (process) - register Lisp_Object process; -{ - /* Ignore the argument and return the value of - inherit-process-coding-system. */ - return inherit_process_coding_system ? Qt : Qnil; -} - -/* Kill all processes associated with `buffer'. - If `buffer' is nil, kill all processes. - Since we have no subprocesses, this does nothing. */ - -void -kill_buffer_processes (buffer) - Lisp_Object buffer; -{ -} - -DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes, - 0, 0, 0, - doc: /* Return a list of numerical process IDs of all running processes. -If this functionality is unsupported, return nil. - -See `process-attributes' for getting attributes of a process given its ID. */) - () -{ - return list_system_processes (); -} - -DEFUN ("process-attributes", Fprocess_attributes, - Sprocess_attributes, 1, 1, 0, - doc: /* Return attributes of the process given by its PID, a number. - -Value is an alist where each element is a cons cell of the form - - \(KEY . VALUE) - -If this functionality is unsupported, the value is nil. - -See `list-system-processes' for getting a list of all process IDs. - -The KEYs of the attributes that this function may return are listed -below, together with the type of the associated VALUE (in parentheses). -Not all platforms support all of these attributes; unsupported -attributes will not appear in the returned alist. -Unless explicitly indicated otherwise, numbers can have either -integer or floating point values. - - euid -- Effective user User ID of the process (number) - user -- User name corresponding to euid (string) - egid -- Effective user Group ID of the process (number) - group -- Group name corresponding to egid (string) - comm -- Command name (executable name only) (string) - state -- Process state code, such as "S", "R", or "T" (string) - ppid -- Parent process ID (number) - pgrp -- Process group ID (number) - sess -- Session ID, i.e. process ID of session leader (number) - ttname -- Controlling tty name (string) - tpgid -- ID of foreground process group on the process's tty (number) - minflt -- number of minor page faults (number) - majflt -- number of major page faults (number) - cminflt -- cumulative number of minor page faults (number) - cmajflt -- cumulative number of major page faults (number) - utime -- user time used by the process, in the (HIGH LOW USEC) format - stime -- system time used by the process, in the (HIGH LOW USEC) format - time -- sum of utime and stime, in the (HIGH LOW USEC) format - cutime -- user time used by the process and its children, (HIGH LOW USEC) - cstime -- system time used by the process and its children, (HIGH LOW USEC) - ctime -- sum of cutime and cstime, in the (HIGH LOW USEC) format - pri -- priority of the process (number) - nice -- nice value of the process (number) - thcount -- process thread count (number) - start -- time the process started, in the (HIGH LOW USEC) format - vsize -- virtual memory size of the process in KB's (number) - rss -- resident set size of the process in KB's (number) - etime -- elapsed time the process is running, in (HIGH LOW USEC) format - pcpu -- percents of CPU time used by the process (floating-point number) - pmem -- percents of total physical memory used by process's resident set - (floating-point number) - args -- command line which invoked the process (string). */) - (pid) - - Lisp_Object pid; -{ - return system_process_attributes (pid); -} - -void -init_process () -{ -} - -void -syms_of_process () -{ - QCtype = intern_c_string (":type"); - staticpro (&QCtype); - QCname = intern_c_string (":name"); - staticpro (&QCname); - QCtype = intern_c_string (":type"); - staticpro (&QCtype); - QCname = intern_c_string (":name"); - staticpro (&QCname); - Qeuid = intern_c_string ("euid"); - staticpro (&Qeuid); - Qegid = intern_c_string ("egid"); - staticpro (&Qegid); - Quser = intern_c_string ("user"); - staticpro (&Quser); - Qgroup = intern_c_string ("group"); - staticpro (&Qgroup); - Qcomm = intern_c_string ("comm"); - staticpro (&Qcomm); - Qstate = intern_c_string ("state"); - staticpro (&Qstate); - Qppid = intern_c_string ("ppid"); - staticpro (&Qppid); - Qpgrp = intern_c_string ("pgrp"); - staticpro (&Qpgrp); - Qsess = intern_c_string ("sess"); - staticpro (&Qsess); - Qttname = intern_c_string ("ttname"); - staticpro (&Qttname); - Qtpgid = intern_c_string ("tpgid"); - staticpro (&Qtpgid); - Qminflt = intern_c_string ("minflt"); - staticpro (&Qminflt); - Qmajflt = intern_c_string ("majflt"); - staticpro (&Qmajflt); - Qcminflt = intern_c_string ("cminflt"); - staticpro (&Qcminflt); - Qcmajflt = intern_c_string ("cmajflt"); - staticpro (&Qcmajflt); - Qutime = intern_c_string ("utime"); - staticpro (&Qutime); - Qstime = intern_c_string ("stime"); - staticpro (&Qstime); - Qtime = intern_c_string ("time"); - staticpro (&Qtime); - Qcutime = intern_c_string ("cutime"); - staticpro (&Qcutime); - Qcstime = intern_c_string ("cstime"); - staticpro (&Qcstime); - Qctime = intern_c_string ("ctime"); - staticpro (&Qctime); - Qpri = intern_c_string ("pri"); - staticpro (&Qpri); - Qnice = intern_c_string ("nice"); - staticpro (&Qnice); - Qthcount = intern_c_string ("thcount"); - staticpro (&Qthcount); - Qstart = intern_c_string ("start"); - staticpro (&Qstart); - Qvsize = intern_c_string ("vsize"); - staticpro (&Qvsize); - Qrss = intern_c_string ("rss"); - staticpro (&Qrss); - Qetime = intern_c_string ("etime"); - staticpro (&Qetime); - Qpcpu = intern_c_string ("pcpu"); - staticpro (&Qpcpu); - Qpmem = intern_c_string ("pmem"); - staticpro (&Qpmem); - Qargs = intern_c_string ("args"); - staticpro (&Qargs); +#endif /* subprocesses */ defsubr (&Sget_buffer_process); defsubr (&Sprocess_inherit_coding_system_flag); @@ -8121,8 +7746,5 @@ syms_of_process () defsubr (&Sprocess_attributes); } - -#endif /* not subprocesses */ - /* arch-tag: 3706c011-7b9a-4117-bd4f-59e7f701a4c4 (do not change this comment) */ diff --git a/src/process.h b/src/process.h index a8cd0a02da6..0350e95310d 100644 --- a/src/process.h +++ b/src/process.h @@ -24,6 +24,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif +#ifdef HAVE_GNUTLS +#include "gnutls.h" +#endif + /* This structure records information about a subprocess or network connection. @@ -76,6 +80,10 @@ struct Lisp_Process /* Working buffer for encoding. */ Lisp_Object encoding_buf; +#ifdef HAVE_GNUTLS + Lisp_Object gnutls_cred_type; +#endif + /* After this point, there are no Lisp_Objects any more. */ /* alloc.c assumes that `pid' is the first such non-Lisp slot. */ @@ -121,6 +129,15 @@ struct Lisp_Process needs to be synced to `status'. */ unsigned int raw_status_new : 1; int raw_status; + +#ifdef HAVE_GNUTLS + gnutls_initstage_t gnutls_initstage; + gnutls_session_t gnutls_state; + gnutls_certificate_client_credentials gnutls_x509_cred; + gnutls_anon_client_credentials_t gnutls_anon_cred; + int gnutls_log_level; + int gnutls_p; +#endif }; /* Every field in the preceding structure except for the first two @@ -142,7 +159,7 @@ extern int synch_process_alive; to Fcall_process. */ /* Nonzero => this is a string explaining death of synchronous subprocess. */ -extern char *synch_process_death; +extern const char *synch_process_death; /* Nonzero => this is the signal number that terminated the subprocess. */ extern int synch_process_termsig; @@ -166,9 +183,23 @@ extern Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime; extern Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; extern Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtpgid, Qcstime; extern Lisp_Object Qtime, Qctime; +extern Lisp_Object QCport, QCspeed, QCprocess; +extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; +extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; extern Lisp_Object list_system_processes (void); extern Lisp_Object system_process_attributes (Lisp_Object); +extern void hold_keyboard_input (void); +extern void unhold_keyboard_input (void); +extern int kbd_on_hold_p (void); + +typedef void (*fd_callback)(int fd, void *data, int for_read); + +extern void add_read_fd (int fd, fd_callback func, void *data); +extern void delete_read_fd (int fd); +extern void add_write_fd (int fd, fd_callback func, void *data); +extern void delete_write_fd (int fd); + /* arch-tag: dffedfc4-d7bc-4b58-a26f-c16155449c72 (do not change this comment) */ diff --git a/src/puresize.h b/src/puresize.h index 4e97e3731b7..3c7f92228a0 100644 --- a/src/puresize.h +++ b/src/puresize.h @@ -72,7 +72,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ { if (PURE_P (obj)) \ pure_write_error (); } -extern void pure_write_error P_ ((void)) NO_RETURN; +extern void pure_write_error (void) NO_RETURN; /* Define PURE_P. */ @@ -87,7 +87,6 @@ extern EMACS_INT pure[]; && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) #else /* not VIRT_ADDR_VARIES */ -#ifdef PNTR_COMPARISON_TYPE /* When PNTR_COMPARISON_TYPE is not the default (unsigned int). */ extern char my_edata[]; @@ -95,14 +94,6 @@ extern char my_edata[]; #define PURE_P(obj) \ ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata) -#else /* not VIRT_ADDRESS_VARIES, not PNTR_COMPARISON_TYPE */ - -extern char my_edata[]; - -#define PURE_P(obj) \ - (XPNTR (obj) < (unsigned int) my_edata) - -#endif /* PNTR_COMPARISON_TYPE */ #endif /* VIRT_ADDRESS_VARIES */ /* arch-tag: fd9b0a91-a70e-4729-a75a-6bb4ca1ce14f diff --git a/src/ralloc.c b/src/ralloc.c index 7ccbdc7daf7..5f2b52fcc4b 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -37,14 +37,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ typedef POINTER_TYPE *POINTER; typedef size_t SIZE; -/* Declared in dispnew.c, this version doesn't screw up if regions - overlap. */ - -extern void safe_bcopy (); - #ifdef DOUG_LEA_MALLOC #define M_TOP_PAD -2 -extern int mallopt (); +extern int mallopt (int, int); #else /* not DOUG_LEA_MALLOC */ #ifndef SYSTEM_MALLOC extern size_t __malloc_extra_blocks; @@ -61,9 +56,6 @@ typedef void *POINTER; #include <unistd.h> #include <malloc.h> -#define safe_bcopy(x, y, z) memmove (y, x, z) -#define bzero(x, len) memset (x, 0, len) - #endif /* not emacs */ @@ -81,13 +73,13 @@ typedef void *POINTER; static int r_alloc_initialized = 0; -static void r_alloc_init (); +static void r_alloc_init (void); /* Declarations for working with the malloc, ralloc, and system breaks. */ /* Function to set the real break value. */ -POINTER (*real_morecore) (); +POINTER (*real_morecore) (long int); /* The break value, as seen by malloc. */ static POINTER virtual_break_value; @@ -119,7 +111,7 @@ static int extra_bytes; from the system. */ #ifndef SYSTEM_MALLOC -extern POINTER (*__morecore) (); +extern POINTER (*__morecore) (long int); #endif @@ -210,8 +202,7 @@ static int r_alloc_freeze_level; /* Find the heap that ADDRESS falls within. */ static heap_ptr -find_heap (address) - POINTER address; +find_heap (POINTER address) { heap_ptr heap; @@ -243,9 +234,7 @@ find_heap (address) allocate the memory. */ static POINTER -obtain (address, size) - POINTER address; - SIZE size; +obtain (POINTER address, SIZE size) { heap_ptr heap; SIZE already_available; @@ -326,7 +315,7 @@ obtain (address, size) it can also eliminate the last heap entirely. */ static void -relinquish () +relinquish (void) { register heap_ptr h; long excess = 0; @@ -385,7 +374,7 @@ relinquish () above where malloc gets space. */ long -r_alloc_size_in_use () +r_alloc_size_in_use (void) { return (char *) break_value - (char *) virtual_break_value; } @@ -396,8 +385,7 @@ r_alloc_size_in_use () to that block. */ static bloc_ptr -find_bloc (ptr) - POINTER *ptr; +find_bloc (POINTER *ptr) { register bloc_ptr p = first_bloc; @@ -422,8 +410,7 @@ find_bloc (ptr) memory for the new block. */ static bloc_ptr -get_bloc (size) - SIZE size; +get_bloc (SIZE size) { register bloc_ptr new_bloc; register heap_ptr heap; @@ -478,10 +465,7 @@ get_bloc (size) Do not touch the contents of blocs or break_value. */ static int -relocate_blocs (bloc, heap, address) - bloc_ptr bloc; - heap_ptr heap; - POINTER address; +relocate_blocs (bloc_ptr bloc, heap_ptr heap, POINTER address) { register bloc_ptr b = bloc; @@ -535,44 +519,12 @@ relocate_blocs (bloc, heap, address) return 1; } - -/* Reorder the bloc BLOC to go before bloc BEFORE in the doubly linked list. - This is necessary if we put the memory of space of BLOC - before that of BEFORE. */ - -static void -reorder_bloc (bloc, before) - bloc_ptr bloc, before; -{ - bloc_ptr prev, next; - - /* Splice BLOC out from where it is. */ - prev = bloc->prev; - next = bloc->next; - - if (prev) - prev->next = next; - if (next) - next->prev = prev; - - /* Splice it in before BEFORE. */ - prev = before->prev; - - if (prev) - prev->next = bloc; - bloc->prev = prev; - - before->prev = bloc; - bloc->next = before; -} /* Update the records of which heaps contain which blocs, starting with heap HEAP and bloc BLOC. */ static void -update_heap_bloc_correspondence (bloc, heap) - bloc_ptr bloc; - heap_ptr heap; +update_heap_bloc_correspondence (bloc_ptr bloc, heap_ptr heap) { register bloc_ptr b; @@ -634,9 +586,7 @@ update_heap_bloc_correspondence (bloc, heap) that come after BLOC in memory. */ static int -resize_bloc (bloc, size) - bloc_ptr bloc; - SIZE size; +resize_bloc (bloc_ptr bloc, SIZE size) { register bloc_ptr b; heap_ptr heap; @@ -689,7 +639,7 @@ resize_bloc (bloc, size) } else { - safe_bcopy (b->data, b->new_data, b->size); + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } @@ -700,8 +650,8 @@ resize_bloc (bloc, size) } else { - safe_bcopy (bloc->data, bloc->new_data, old_size); - bzero ((char *) bloc->new_data + old_size, size - old_size); + memmove (bloc->new_data, bloc->data, old_size); + memset (bloc->new_data + old_size, 0, size - old_size); *bloc->variable = bloc->data = bloc->new_data; } } @@ -716,7 +666,7 @@ resize_bloc (bloc, size) } else { - safe_bcopy (b->data, b->new_data, b->size); + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } @@ -733,8 +683,7 @@ resize_bloc (bloc, size) This may return space to the system. */ static void -free_bloc (bloc) - bloc_ptr bloc; +free_bloc (bloc_ptr bloc) { heap_ptr heap = bloc->heap; @@ -800,8 +749,7 @@ free_bloc (bloc) GNU malloc package. */ POINTER -r_alloc_sbrk (size) - long size; +r_alloc_sbrk (long int size) { register bloc_ptr b; POINTER address; @@ -871,7 +819,7 @@ r_alloc_sbrk (size) header. */ for (b = last_bloc; b != NIL_BLOC; b = b->prev) { - safe_bcopy (b->data, b->new_data, b->size); + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } @@ -898,7 +846,7 @@ r_alloc_sbrk (size) last_heap = first_heap; } - bzero (address, size); + memset (address, 0, size); } else /* size < 0 */ { @@ -917,7 +865,7 @@ r_alloc_sbrk (size) for (b = first_bloc; b != NIL_BLOC; b = b->next) { - safe_bcopy (b->data, b->new_data, b->size); + memmove (b->new_data, b->data, b->size); *b->variable = b->data = b->new_data; } } @@ -952,9 +900,7 @@ r_alloc_sbrk (size) return zero. */ POINTER -r_alloc (ptr, size) - POINTER *ptr; - SIZE size; +r_alloc (POINTER *ptr, SIZE size) { register bloc_ptr new_bloc; @@ -977,8 +923,7 @@ r_alloc (ptr, size) Store 0 in *PTR to show there's no block allocated. */ void -r_alloc_free (ptr) - register POINTER *ptr; +r_alloc_free (register POINTER *ptr) { register bloc_ptr dead_bloc; @@ -1012,9 +957,7 @@ r_alloc_free (ptr) return zero. */ POINTER -r_re_alloc (ptr, size) - POINTER *ptr; - SIZE size; +r_re_alloc (POINTER *ptr, SIZE size) { register bloc_ptr bloc; @@ -1075,8 +1018,7 @@ r_re_alloc (ptr, size) malloc must return a null pointer. */ void -r_alloc_freeze (size) - long size; +r_alloc_freeze (long int size) { if (! r_alloc_initialized) r_alloc_init (); @@ -1093,7 +1035,7 @@ r_alloc_freeze (size) } void -r_alloc_thaw () +r_alloc_thaw (void) { if (! r_alloc_initialized) @@ -1103,7 +1045,7 @@ r_alloc_thaw () abort (); /* This frees all unused blocs. It is not too inefficient, as the resize - and bcopy is done only once. Afterwards, all unreferenced blocs are + and memcpy is done only once. Afterwards, all unreferenced blocs are already shrunk to zero size. */ if (!r_alloc_freeze_level) { @@ -1122,7 +1064,7 @@ r_alloc_thaw () /* Reinitialize the morecore hook variables after restarting a dumped Emacs. This is needed when using Doug Lea's malloc from GNU libc. */ void -r_alloc_reinit () +r_alloc_reinit (void) { /* Only do this if the hook has been reset, so that we don't get an infinite loop, in case Emacs was linked statically. */ @@ -1235,8 +1177,7 @@ r_alloc_check () is checked to ensure that memory corruption does not occur due to misuse. */ void -r_alloc_reset_variable (old, new) - POINTER *old, *new; +r_alloc_reset_variable (POINTER *old, POINTER *new) { bloc_ptr bloc = first_bloc; @@ -1266,7 +1207,7 @@ r_alloc_reset_variable (old, new) /* Initialize various things for memory allocation. */ static void -r_alloc_init () +r_alloc_init (void) { if (r_alloc_initialized) return; @@ -1314,8 +1255,8 @@ r_alloc_init () even though it is after the sbrk value. */ /* Doubly true, with the additional call that explicitly adds the rest of that page to the address space. */ - bzero (first_heap->start, - (char *) first_heap->end - (char *) first_heap->start); + memset (first_heap->start, 0, + (char *) first_heap->end - (char *) first_heap->start); virtual_break_value = break_value = first_heap->bloc_start = first_heap->end; #endif diff --git a/src/regex.c b/src/regex.c index 7d12089fea2..17158552a95 100644 --- a/src/regex.c +++ b/src/regex.c @@ -248,37 +248,16 @@ xrealloc (block, size) # endif # define realloc xrealloc -/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. - If nothing else has been done, use the method below. */ -# ifdef INHIBIT_STRING_HEADER -# if !(defined HAVE_BZERO && defined HAVE_BCOPY) -# if !defined bzero && !defined bcopy -# undef INHIBIT_STRING_HEADER -# endif +/* This is the normal way of making sure we have memcpy, memcmp and memset. */ +# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC +# include <string.h> +# else +# include <strings.h> +# ifndef memcmp +# define memcmp(s1, s2, n) bcmp (s1, s2, n) # endif -# endif - -/* This is the normal way of making sure we have memcpy, memcmp and bzero. - This is used in most programs--a few other programs avoid this - by defining INHIBIT_STRING_HEADER. */ -# ifndef INHIBIT_STRING_HEADER -# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC -# include <string.h> -# ifndef bzero -# ifndef _LIBC -# define bzero(s, n) (memset (s, '\0', n), (s)) -# else -# define bzero(s, n) __bzero (s, n) -# endif -# endif -# else -# include <strings.h> -# ifndef memcmp -# define memcmp(s1, s2, n) bcmp (s1, s2, n) -# endif -# ifndef memcpy -# define memcpy(d, s, n) (bcopy (s, d, n), (d)) -# endif +# ifndef memcpy +# define memcpy(d, s, n) (bcopy (s, d, n), (d)) # endif # endif @@ -290,7 +269,6 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 }; # define SWITCH_ENUM_CAST(x) (x) /* Dummy macros for non-Emacs environments. */ -# define BASE_LEADING_CODE_P(c) (0) # define CHAR_CHARSET(c) 0 # define CHARSET_LEADING_CODE_BASE(c) 0 # define MAX_MULTIBYTE_LENGTH 1 @@ -300,7 +278,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 }; # define CHAR_HEAD_P(p) (1) # define SINGLE_BYTE_CHAR_P(c) (1) # define SAME_CHARSET_P(c1, c2) (1) -# define MULTIBYTE_FORM_LENGTH(p, s) (1) +# define BYTES_BY_CHAR_HEAD(p) (1) # define PREV_CHAR_BOUNDARY(p, limit) ((p)--) # define STRING_CHAR(p) (*(p)) # define RE_STRING_CHAR(p, multibyte) STRING_CHAR (p) @@ -465,7 +443,7 @@ init_syntax_once () if (done) return; - bzero (re_syntax_table, sizeof re_syntax_table); + memset (re_syntax_table, 0, sizeof re_syntax_table); for (c = 0; c < CHAR_SET_SIZE; ++c) if (ISALNUM (c)) @@ -1322,8 +1300,7 @@ reg_syntax_t re_syntax_options; defined in regex.h. We return the old syntax. */ reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; +re_set_syntax (reg_syntax_t syntax) { reg_syntax_t ret = re_syntax_options; @@ -1336,8 +1313,7 @@ WEAK_ALIAS (__re_set_syntax, re_set_syntax) static re_char *whitespace_regexp; void -re_set_whitespace_regexp (regexp) - const char *regexp; +re_set_whitespace_regexp (const char *regexp) { whitespace_regexp = (re_char *) regexp; } @@ -2150,8 +2126,7 @@ struct range_table_work_area /* Map a string to the char class it names (if any). */ re_wctype_t -re_wctype (str) - re_char *str; +re_wctype (const re_char *str) { const char *string = str; if (STREQ (string, "alnum")) return RECC_ALNUM; @@ -2176,9 +2151,7 @@ re_wctype (str) /* True if CH is in the char class CC. */ boolean -re_iswctype (ch, cc) - int ch; - re_wctype_t cc; +re_iswctype (int ch, re_wctype_t cc) { switch (cc) { @@ -2208,8 +2181,7 @@ re_iswctype (ch, cc) /* Return a bit-pattern to use in the range-table bits to match multibyte chars of class CC. */ static int -re_wctype_to_bit (cc) - re_wctype_t cc; +re_wctype_to_bit (re_wctype_t cc) { switch (cc) { @@ -2233,8 +2205,7 @@ re_wctype_to_bit (cc) /* Actually extend the space in WORK_AREA. */ static void -extend_range_table_work_area (work_area) - struct range_table_work_area *work_area; +extend_range_table_work_area (struct range_table_work_area *work_area) { work_area->allocated += 16 * sizeof (int); if (work_area->table) @@ -2558,11 +2529,7 @@ do { \ } while (0) static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - re_char *pattern; - size_t size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; +regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) { /* We fetch characters from PATTERN here. */ register re_wchar_t c, c1; @@ -2960,7 +2927,7 @@ regex_compile (pattern, size, syntax, bufp) BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); + memset (b, 0, (1 << BYTEWIDTH) / BYTEWIDTH); /* charset_not matches newline according to a syntax bit. */ if ((re_opcode_t) b[-2] == charset_not @@ -3070,7 +3037,7 @@ regex_compile (pattern, size, syntax, bufp) syntax-table for ASCII chars, while the other chars will obey syntax-table properties. It's not ideal, but it's the way it's been done until now. */ - SETUP_SYNTAX_TABLE (BEGV, 0); + SETUP_BUFFER_SYNTAX_TABLE (); for (ch = 0; ch < 256; ++ch) { @@ -3876,10 +3843,7 @@ regex_compile (pattern, size, syntax, bufp) /* Store OP at LOC followed by two-byte integer parameter ARG. */ static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; +store_op1 (re_opcode_t op, unsigned char *loc, int arg) { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg); @@ -3889,10 +3853,7 @@ store_op1 (op, loc, arg) /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; +store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg1); @@ -3904,11 +3865,7 @@ store_op2 (op, loc, arg1, arg2) for OP followed by two-byte integer parameter ARG. */ static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; +insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) { register unsigned char *pfrom = end; register unsigned char *pto = end + 3; @@ -3923,11 +3880,7 @@ insert_op1 (op, loc, arg, end) /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; +insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end) { register unsigned char *pfrom = end; register unsigned char *pto = end + 5; @@ -3944,9 +3897,7 @@ insert_op2 (op, loc, arg1, arg2, end) least one character before the ^. */ static boolean -at_begline_loc_p (pattern, p, syntax) - re_char *pattern, *p; - reg_syntax_t syntax; +at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) { re_char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; @@ -3968,9 +3919,7 @@ at_begline_loc_p (pattern, p, syntax) at least one character after the $, i.e., `P < PEND'. */ static boolean -at_endline_loc_p (p, pend, syntax) - re_char *p, *pend; - reg_syntax_t syntax; +at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) { re_char *next = p; boolean next_backslash = *next == '\\'; @@ -3990,9 +3939,7 @@ at_endline_loc_p (p, pend, syntax) false if it's not. */ static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; +group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) { int this_element; @@ -4016,10 +3963,7 @@ group_in_compile_stack (compile_stack, regnum) Return -1 if fastmap was not updated accurately. */ static int -analyse_first (p, pend, fastmap, multibyte) - re_char *p, *pend; - char *fastmap; - const int multibyte; +analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) { int j, k; boolean not; @@ -4331,15 +4275,14 @@ analyse_first (p, pend, fastmap, multibyte) Returns 0 if we succeed, -2 if an internal error. */ int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; +re_compile_fastmap (struct re_pattern_buffer *bufp) { char *fastmap = bufp->fastmap; int analysis; assert (fastmap && bufp->buffer); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ + memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ analysis = analyse_first (bufp->buffer, bufp->buffer + bufp->used, @@ -4362,11 +4305,7 @@ re_compile_fastmap (bufp) freeing the old data. */ void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; +re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, unsigned int num_regs, regoff_t *starts, regoff_t *ends) { if (num_regs) { @@ -4390,11 +4329,7 @@ WEAK_ALIAS (__re_set_registers, re_set_registers) doesn't let you say where to stop matching. */ int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; +re_search (struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range, struct re_registers *regs) { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, regs, size); @@ -4435,14 +4370,7 @@ WEAK_ALIAS (__re_search, re_search) stack overflow). */ int -re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *str1, *str2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; +re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const char *str2, int size2, int startpos, int range, struct re_registers *regs, int stop) { int val; re_char *string1 = (re_char*) str1; @@ -4496,7 +4424,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) anchored_start = (bufp->buffer[0] == begline); #ifdef emacs - gl_state.object = re_match_object; + gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ { int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (startpos)); @@ -4643,7 +4571,7 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) { re_char *p = POS_ADDR_VSTRING (startpos); re_char *pend = STOP_ADDR_VSTRING (startpos); - int len = MULTIBYTE_FORM_LENGTH (p, pend - p); + int len = BYTES_BY_CHAR_HEAD (*p); range -= len; if (range < 0) @@ -4776,8 +4704,7 @@ static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, /* If the operation is a match against one or more chars, return a pointer to the next operation, else return NULL. */ static re_char * -skip_one_char (p) - re_char *p; +skip_one_char (const re_char *p) { switch (SWITCH_ENUM_CAST (*p++)) { @@ -4819,8 +4746,7 @@ skip_one_char (p) /* Jump over non-matching operations. */ static re_char * -skip_noops (p, pend) - re_char *p, *pend; +skip_noops (const re_char *p, const re_char *pend) { int mcnt; while (p < pend) @@ -4847,9 +4773,7 @@ skip_noops (p, pend) /* Non-zero if "p1 matches something" implies "p2 fails". */ static int -mutually_exclusive_p (bufp, p1, p2) - struct re_pattern_buffer *bufp; - re_char *p1, *p2; +mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) { re_opcode_t op2; const boolean multibyte = RE_MULTIBYTE_P (bufp); @@ -5087,19 +5011,13 @@ Lisp_Object re_match_object; matched substring. */ int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; +re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1, const char *string2, int size2, int pos, struct re_registers *regs, int stop) { int result; #ifdef emacs int charpos; - gl_state.object = re_match_object; + gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */ charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos)); SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); #endif @@ -5115,13 +5033,7 @@ WEAK_ALIAS (__re_match_2, re_match_2) /* This is a separate function so that we can force an alloca cleanup afterwards. */ static int -re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - re_char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; +re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int size1, const re_char *string2, int size2, int pos, struct re_registers *regs, int stop) { /* General temporaries. */ int mcnt; @@ -6452,11 +6364,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) bytes; nonzero otherwise. */ static int -bcmp_translate (s1, s2, len, translate, target_multibyte) - re_char *s1, *s2; - register int len; - RE_TRANSLATE_TYPE translate; - const int target_multibyte; +bcmp_translate (const re_char *s1, const re_char *s2, register int len, + RE_TRANSLATE_TYPE translate, const int target_multibyte) { register re_char *p1 = s1, *p2 = s2; re_char *p1_end = s1 + len; @@ -6497,17 +6406,10 @@ bcmp_translate (s1, s2, len, translate, target_multibyte) We call regex_compile to do the actual compilation. */ const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - size_t length; - struct re_pattern_buffer *bufp; +re_compile_pattern (const char *pattern, size_t length, struct re_pattern_buffer *bufp) { reg_errcode_t ret; -#ifdef emacs - gl_state.current_syntax_table = current_buffer->syntax_table; -#endif - /* GNU code is written to assume at least RE_NREGS registers will be set (and at least one extra will be -1). */ bufp->regs_allocated = REGS_UNALLOCATED; diff --git a/src/region-cache.c b/src/region-cache.c index d03d7df0bda..9037b5df4b4 100644 --- a/src/region-cache.c +++ b/src/region-cache.c @@ -62,7 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ revalidate_region_cache to see how this helps. */ struct boundary { - int pos; + EMACS_INT pos; int value; }; @@ -72,16 +72,16 @@ struct region_cache { struct boundary *boundaries; /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap. */ - int gap_start, gap_len; + EMACS_INT gap_start, gap_len; /* The number of elements allocated to boundaries, not including the gap. */ - int cache_len; + EMACS_INT cache_len; /* The areas that haven't changed since the last time we cleaned out invalid entries from the cache. These overlap when the buffer is entirely unchanged. */ - int beg_unchanged, end_unchanged; + EMACS_INT beg_unchanged, end_unchanged; /* The first and last positions in the buffer. Because boundaries store their positions relative to the start (BEG) and end (Z) of @@ -91,7 +91,7 @@ struct region_cache { Yes, buffer_beg is always 1. It's there for symmetry with buffer_end and the BEG and BUF_BEG macros. */ - int buffer_beg, buffer_end; + EMACS_INT buffer_beg, buffer_end; }; /* Return the position of boundary i in cache c. */ @@ -122,13 +122,13 @@ struct region_cache { preserve that information, instead of throwing it away. */ #define PRESERVE_THRESHOLD (500) -static void revalidate_region_cache (); +static void revalidate_region_cache (struct buffer *buf, struct region_cache *c); /* Interface: Allocating, initializing, and disposing of region caches. */ struct region_cache * -new_region_cache () +new_region_cache (void) { struct region_cache *c = (struct region_cache *) xmalloc (sizeof (struct region_cache)); @@ -156,8 +156,7 @@ new_region_cache () } void -free_region_cache (c) - struct region_cache *c; +free_region_cache (struct region_cache *c) { xfree (c->boundaries); xfree (c); @@ -173,19 +172,17 @@ free_region_cache (c) This operation should be logarithmic in the number of cache entries. It would be nice if it took advantage of locality of reference, too, by searching entries near the last entry found. */ -static int -find_cache_boundary (c, pos) - struct region_cache *c; - int pos; +static EMACS_INT +find_cache_boundary (struct region_cache *c, EMACS_INT pos) { - int low = 0, high = c->cache_len; + EMACS_INT low = 0, high = c->cache_len; while (low + 1 < high) { /* mid is always a valid index, because low < high and ">> 1" rounds down. */ - int mid = (low + high) >> 1; - int boundary = BOUNDARY_POS (c, mid); + EMACS_INT mid = (low + high) >> 1; + EMACS_INT boundary = BOUNDARY_POS (c, mid); if (pos < boundary) high = mid; @@ -210,16 +207,13 @@ find_cache_boundary (c, pos) /* Move the gap of cache C to index POS, and make sure it has space for at least MIN_SIZE boundaries. */ static void -move_cache_gap (c, pos, min_size) - struct region_cache *c; - int pos; - int min_size; +move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size) { /* Copy these out of the cache and into registers. */ - int gap_start = c->gap_start; - int gap_len = c->gap_len; - int buffer_beg = c->buffer_beg; - int buffer_end = c->buffer_end; + EMACS_INT gap_start = c->gap_start; + EMACS_INT gap_len = c->gap_len; + EMACS_INT buffer_beg = c->buffer_beg; + EMACS_INT buffer_end = c->buffer_end; if (pos < 0 || pos > c->cache_len) @@ -251,7 +245,7 @@ move_cache_gap (c, pos, min_size) when the portion after the gap is smallest. */ if (gap_len < min_size) { - int i; + EMACS_INT i; /* Always make at least NEW_CACHE_GAP elements, as long as we're expanding anyway. */ @@ -298,10 +292,8 @@ move_cache_gap (c, pos, min_size) /* Insert a new boundary in cache C; it will have cache index INDEX, and have the specified POS and VALUE. */ static void -insert_cache_boundary (c, index, pos, value) - struct region_cache *c; - int index; - int pos, value; +insert_cache_boundary (struct region_cache *c, EMACS_INT index, EMACS_INT pos, + int value) { /* index must be a valid cache index. */ if (index < 0 || index > c->cache_len) @@ -337,11 +329,10 @@ insert_cache_boundary (c, index, pos, value) /* Delete the i'th entry from cache C if START <= i < END. */ static void -delete_cache_boundaries (c, start, end) - struct region_cache *c; - int start, end; +delete_cache_boundaries (struct region_cache *c, + EMACS_INT start, EMACS_INT end) { - int len = end - start; + EMACS_INT len = end - start; /* Gotta be in range. */ if (start < 0 @@ -391,10 +382,8 @@ delete_cache_boundaries (c, start, end) /* Set the value in cache C for the region START..END to VALUE. */ static void -set_cache_region (c, start, end, value) - struct region_cache *c; - int start, end; - int value; +set_cache_region (struct region_cache *c, + EMACS_INT start, EMACS_INT end, int value) { if (start > end) abort (); @@ -417,8 +406,8 @@ set_cache_region (c, start, end, value) index of the earliest boundary after the last character in start..end. (This tortured terminology is intended to answer all the "< or <=?" sort of questions.) */ - int start_ix = find_cache_boundary (c, start); - int end_ix = find_cache_boundary (c, end - 1) + 1; + EMACS_INT start_ix = find_cache_boundary (c, start); + EMACS_INT end_ix = find_cache_boundary (c, end - 1) + 1; /* We must remember the value established by the last boundary before end; if that boundary's domain stretches beyond end, @@ -495,10 +484,8 @@ set_cache_region (c, start, end, value) buffer positions in the presence of insertions and deletions; the args to pass are the same before and after such an operation.) */ void -invalidate_region_cache (buf, c, head, tail) - struct buffer *buf; - struct region_cache *c; - int head, tail; +invalidate_region_cache (struct buffer *buf, struct region_cache *c, + EMACS_INT head, EMACS_INT tail) { /* Let chead = c->beg_unchanged, and ctail = c->end_unchanged. @@ -576,9 +563,7 @@ invalidate_region_cache (buf, c, head, tail) the cache, and causes cache gap motion. */ static void -revalidate_region_cache (buf, c) - struct buffer *buf; - struct region_cache *c; +revalidate_region_cache (struct buffer *buf, struct region_cache *c) { /* The boundaries now in the cache are expressed relative to the buffer_beg and buffer_end values stored in the cache. Now, @@ -638,7 +623,7 @@ revalidate_region_cache (buf, c) corresponds to the modified region of the buffer. */ else { - int modified_ix; + EMACS_INT modified_ix; /* These positions are correct, relative to both the cache basis and the buffer basis. */ @@ -706,10 +691,8 @@ revalidate_region_cache (buf, c) buffer positions) is "known," for the purposes of CACHE (e.g. "has no newlines", in the case of the line cache). */ void -know_region_cache (buf, c, start, end) - struct buffer *buf; - struct region_cache *c; - int start, end; +know_region_cache (struct buffer *buf, struct region_cache *c, + EMACS_INT start, EMACS_INT end) { revalidate_region_cache (buf, c); @@ -723,18 +706,15 @@ know_region_cache (buf, c, start, end) the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position after POS where the knownness changes. */ int -region_cache_forward (buf, c, pos, next) - struct buffer *buf; - struct region_cache *c; - int pos; - int *next; +region_cache_forward (struct buffer *buf, struct region_cache *c, + EMACS_INT pos, EMACS_INT *next) { revalidate_region_cache (buf, c); { - int i = find_cache_boundary (c, pos); + EMACS_INT i = find_cache_boundary (c, pos); int i_value = BOUNDARY_VALUE (c, i); - int j; + EMACS_INT j; /* Beyond the end of the buffer is unknown, by definition. */ if (pos >= BUF_Z (buf)) @@ -762,11 +742,8 @@ region_cache_forward (buf, c, pos, next) /* Return true if the text immediately before POS in BUF is known, for the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position before POS where the knownness changes. */ -int region_cache_backward (buf, c, pos, next) - struct buffer *buf; - struct region_cache *c; - int pos; - int *next; +int region_cache_backward (struct buffer *buf, struct region_cache *c, + EMACS_INT pos, EMACS_INT *next) { revalidate_region_cache (buf, c); @@ -779,9 +756,9 @@ int region_cache_backward (buf, c, pos, next) } { - int i = find_cache_boundary (c, pos - 1); + EMACS_INT i = find_cache_boundary (c, pos - 1); int i_value = BOUNDARY_VALUE (c, i); - int j; + EMACS_INT j; if (next) { @@ -804,21 +781,20 @@ int region_cache_backward (buf, c, pos, next) /* Debugging: pretty-print a cache to the standard error output. */ void -pp_cache (c) - struct region_cache *c; +pp_cache (struct region_cache *c) { int i; - int beg_u = c->buffer_beg + c->beg_unchanged; - int end_u = c->buffer_end - c->end_unchanged; + EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged; + EMACS_INT end_u = c->buffer_end - c->end_unchanged; fprintf (stderr, - "basis: %d..%d modified: %d..%d\n", - c->buffer_beg, c->buffer_end, - beg_u, end_u); + "basis: %ld..%ld modified: %ld..%ld\n", + (long)c->buffer_beg, (long)c->buffer_end, + (long)beg_u, (long)end_u); for (i = 0; i < c->cache_len; i++) { - int pos = BOUNDARY_POS (c, i); + EMACS_INT pos = BOUNDARY_POS (c, i); putc (((pos < beg_u) ? 'v' : (pos == beg_u) ? '-' @@ -828,7 +804,7 @@ pp_cache (c) : (pos == end_u) ? '-' : ' '), stderr); - fprintf (stderr, "%d : %d\n", pos, BOUNDARY_VALUE (c, i)); + fprintf (stderr, "%ld : %d\n", (long)pos, BOUNDARY_VALUE (c, i)); } } diff --git a/src/region-cache.h b/src/region-cache.h index 4a717d66081..e99eac90c85 100644 --- a/src/region-cache.h +++ b/src/region-cache.h @@ -61,17 +61,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Allocate, initialize and return a new, empty region cache. */ -struct region_cache *new_region_cache P_ ((void)); +struct region_cache *new_region_cache (void); /* Free a region cache. */ -void free_region_cache P_ ((struct region_cache *)); +void free_region_cache (struct region_cache *); /* Assert that the region of BUF between START and END (absolute buffer positions) is "known," for the purposes of CACHE (e.g. "has no newlines", in the case of the line cache). */ -extern void know_region_cache P_ ((struct buffer *BUF, - struct region_cache *CACHE, - int START, int END)); +extern void know_region_cache (struct buffer *BUF, + struct region_cache *CACHE, + EMACS_INT START, EMACS_INT END); /* Indicate that a section of BUF has changed, to invalidate CACHE. HEAD is the number of chars unchanged at the beginning of the buffer. @@ -81,9 +81,9 @@ extern void know_region_cache P_ ((struct buffer *BUF, (This way of specifying regions makes more sense than absolute buffer positions in the presence of insertions and deletions; the args to pass are the same before and after such an operation.) */ -extern void invalidate_region_cache P_ ((struct buffer *BUF, - struct region_cache *CACHE, - int HEAD, int TAIL)); +extern void invalidate_region_cache (struct buffer *BUF, + struct region_cache *CACHE, + EMACS_INT HEAD, EMACS_INT TAIL); /* The scanning functions. @@ -97,18 +97,18 @@ extern void invalidate_region_cache P_ ((struct buffer *BUF, /* Return true if the text immediately after POS in BUF is known, for the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position after POS where the knownness changes. */ -extern int region_cache_forward P_ ((struct buffer *BUF, - struct region_cache *CACHE, - int POS, - int *NEXT)); +extern int region_cache_forward (struct buffer *BUF, + struct region_cache *CACHE, + EMACS_INT POS, + EMACS_INT *NEXT); /* Return true if the text immediately before POS in BUF is known, for the purposes of CACHE. If NEXT is non-zero, set *NEXT to the nearest position before POS where the knownness changes. */ -extern int region_cache_backward P_ ((struct buffer *BUF, - struct region_cache *CACHE, - int POS, - int *NEXT)); +extern int region_cache_backward (struct buffer *BUF, + struct region_cache *CACHE, + EMACS_INT POS, + EMACS_INT *NEXT); /* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435 (do not change this comment) */ diff --git a/src/s/aix4-2.h b/src/s/aix4-2.h index 29a68dbf6e3..29702028649 100644 --- a/src/s/aix4-2.h +++ b/src/s/aix4-2.h @@ -1,6 +1,6 @@ /* -Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. +Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,135 +17,56 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ - +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #define USG /* System III, System V, etc */ #define USG5 -/* This symbol should be defined on AIX Version 3 ??????? */ +/* This symbol should be defined on AIX Version 3 ??????? */ #ifndef _AIX #define _AIX #endif /* SYSTEM_TYPE should indicate the kind of system you are using. It sets the Lisp variable system-type. */ - #define SYSTEM_TYPE "aix" /* In AIX, you allocate a pty by opening /dev/ptc to get the master side. To get the name of the slave side, you just ttyname() the master side. */ - #define PTY_ITERATION for (c = 0; !c ; c++) #define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptc"); #define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd)); -/* - * Define HAVE_TERMIO if the system provides sysV-style ioctls - * for terminal control. - */ - -#define HAVE_TERMIOS - -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ - #define HAVE_SOCKETS - -/* - * Define SYSV_SYSTEM_DIR to use the V.3 getdents/readir - * library functions. Almost, but not quite the same as - * the 4.2 functions - */ - -#define SYSV_SYSTEM_DIR - -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - /* The file containing the kernel's symbol table is called /unix. */ - #define KERNEL_FILE "/unix" -/* The symbol in the kernel where the load average is found - is named avenrun. */ - +/* The kernel symbol where the load average is found is named avenrun. */ #define LDAV_SYMBOL "avenrun" -/* Special itemss needed to make Emacs run on this system. */ - -#ifndef __GNUC__ -#define LINKER cc -#endif - -/* Prevent -lg from being used for debugging. Not needed. */ - -#define LIBS_DEBUG - -/* No need to specify -lc when linking. */ - -#define LIB_STANDARD - -/* Use terminfo instead of termcap. */ - -#define TERMINFO - -/* The following definition seems to be needed in AIX version 3.1.6.8. - It may not have been needed in certain earlier versions. */ -#define HAVE_TCATTR - -/* Include unistd.h, even though we don't define POSIX. */ -#define NEED_UNISTD_H +/* Special items needed to make Emacs run on this system. */ /* AIX doesn't define this. */ #define unix 1 -#ifndef __GNUC__ -/* Some programs in src produce warnings saying certain subprograms - are to comples and need a MAXMEM value greater than 2000 for - additional optimization. --nils@exp-math.uni-essen.de */ -#define C_SWITCH_SYSTEM -ma -qmaxmem=4000 -#endif - /* string.h defines rindex as a macro, at least with native cc, so we lose declaring char * rindex without this. It is just a guess which versions of AIX need this definition. */ #undef HAVE_STRING_H -/* For AIX, it turns out compiling emacs under AIX 3.2.4 REQUIRES "cc -g" - because "cc -O" crashes. Under AIX 3.2.5, "cc -O" is required because - "cc -g" crashes. Go figure. --floppy@merlin.mit.edu */ -/* The above isn't generally true. If it occurs with some compiler - release, seek a fixed version, be it XLC or GCC. The XLC version - isn't tied to the OS version on AIX any more than elsewhere. XLC - (the IBM compiler) can use -g with -O. (-O3 is also a possibility - for the optimization level.) -- fx, after David Edelsohn. */ -#define C_DEBUG_SWITCH -g -O - /* Perry Smith <pedz@ddivt1.austin.ibm.com> says these are correct. */ #define SIGNALS_VIA_CHARACTERS -#define MAIL_USE_LOCKF #define CLASH_DETECTION /* Perry Smith <pedz@ddivt1.austin.ibm.com> says these are correct. */ -#define POSIX_SIGNALS #undef sigmask -/* olson@mcs.anl.gov says -li18n is needed by -lXm. */ -#define LIB_MOTIF -lXm -li18n - #ifndef HAVE_LIBXMU -#define LIBXMU - /* Unfortunately without libXmu we cannot support EditRes. */ #define NO_EDITRES #endif @@ -153,19 +74,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* On AIX Emacs uses the gmalloc.c malloc implementation. But given the way this system works, libc functions that return malloced memory use the libc malloc implementation. Calling xfree or - xrealloc on the results of such functions results in a crash. + xrealloc on the results of such functions results in a crash. - One solution for this could be to define SYSTEM_MALLOC here, but - that does not currently work on this system. + One solution for this could be to define SYSTEM_MALLOC in configure, + but that does not currently work on this system. It is possible to completely override the malloc implementation on AIX, but that involves putting the malloc functions in a shared library and setting the MALLOCTYPE environment variable to point to - tha shared library. - + that shared library. + Emacs currently calls xrealloc on the results of get_current_dir name, - to avoid a crash just use the Emacs implementation for that function. -*/ + to avoid a crash just use the Emacs implementation for that function. */ #define BROKEN_GET_CURRENT_DIR_NAME 1 /* arch-tag: 38fe75ea-6aef-42bd-8449-bc34d921a562 diff --git a/src/s/bsd-common.h b/src/s/bsd-common.h index 8094f50d317..b17ca7a012f 100644 --- a/src/s/bsd-common.h +++ b/src/s/bsd-common.h @@ -1,6 +1,7 @@ /* Definitions file for GNU Emacs running on bsd 4.3 - Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,10 +19,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ /* We give these symbols the numeric values found in <sys/param.h> to avoid warnings about redefined macros. */ @@ -33,58 +32,54 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define BSD_SYSTEM 43 #endif /* BSD_SYSTEM */ +/* For mem-limits.h. */ +#define BSD4_2 + +#define TABDLY OXTABS +#define TAB3 OXTABS + +/* These aren't needed, since we have getloadavg. */ +#undef KERNEL_FILE +#undef LDAV_SYMBOL + +#define NO_TERMIO + +/* If the system's imake configuration file defines `NeedWidePrototypes' + as `NO', we must define NARROWPROTO manually. Such a define is + generated in the Makefile generated by `xmkmf'. If we don't + define NARROWPROTO, we will see the wrong function prototypes + for X functions taking float or double parameters. */ +#define NARROWPROTO 1 + /* SYSTEM_TYPE should indicate the kind of system you are using. It sets the Lisp variable system-type. */ - #define SYSTEM_TYPE "berkeley-unix" /* Do not use interrupt_input = 1 by default, because in 4.3 we can make noninterrupt input work properly. */ - #undef INTERRUPT_INPUT /* First pty name is /dev/ptyp0. */ - #define FIRST_PTY_LETTER 'p' -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ - #define HAVE_SOCKETS -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -#define MAIL_USE_FLOCK - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* The file containing the kernel's symbol table is called /vmunix. */ - #define KERNEL_FILE "/vmunix" -/* The symbol in the kernel where the load average is found - is named _avenrun. */ - +/* The kernel symbol where the load average is found is named _avenrun. */ #define LDAV_SYMBOL "_avenrun" /* Send signals to subprocesses by "typing" special chars at them. */ - #define SIGNALS_VIA_CHARACTERS /* arch-tag: 0c367245-bde3-492e-9029-3ff6898beb95 diff --git a/src/s/cygwin.h b/src/s/cygwin.h index 9ca5c67ce37..4d58542e660 100644 --- a/src/s/cygwin.h +++ b/src/s/cygwin.h @@ -1,6 +1,7 @@ /* System description header file for Cygwin. - Copyright (C) 1985, 1986, 1992, 1999, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 1992, 1999, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,8 +19,7 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "cygwin" /* Emacs can read input using SIGIO and buffering characters itself, @@ -43,26 +43,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ It would have Emacs fork off a separate process to read the input and send it to the true Emacs process through a pipe. */ - #undef INTERRUPT_INPUT -/* - * Define HAVE_TERMIOS if the system provides POSIX-style - * functions and macros for terminal control. - * - * Define HAVE_TERMIO if the system provides sysV-style ioctls - * for terminal control. - * - * Do not define both. HAVE_TERMIOS is preferred, if it is - * supported on your system. - */ - -#define HAVE_TERMIOS - -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS #define PTY_ITERATION for (i = 0; i < 1; i++) /* ick */ #define PTY_NAME_SPRINTF /* none */ @@ -80,14 +63,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ } \ while (0) -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* If the system's imake configuration file defines `NeedWidePrototypes' @@ -95,21 +73,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ generated in the Makefile generated by `xmkmf'. If we don't define NARROWPROTO, we will see the wrong function prototypes for X functions taking float or double parameters. */ - #define NARROWPROTO 1 -/* used in various places to enable cygwin-specific code changes */ +/* Used in various places to enable cygwin-specific code changes. */ #define CYGWIN 1 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) -#define SYSV_SYSTEM_DIR 1 -#define UNEXEC unexcw.o -#define POSIX_SIGNALS 1 -#define LINKER $(CC) - -/* Use terminfo instead of termcap. Fewer environment variables to - go wrong, more terminal types. */ -#define TERMINFO #define HAVE_SOCKETS @@ -132,7 +101,5 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ returns ENOSYS. A workaround is to set G_SLICE=always-malloc. */ #define G_SLICE_ALWAYS_MALLOC -/* the end */ - /* arch-tag: 5ae7ba00-83b0-4ab3-806a-3e845779191b (do not change this comment) */ diff --git a/src/s/darwin.h b/src/s/darwin.h index ab7c0717287..73e19602275 100644 --- a/src/s/darwin.h +++ b/src/s/darwin.h @@ -1,6 +1,7 @@ /* System description header file for Darwin (Mac OS X). - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,11 +19,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ - +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #define BSD4_2 /* BSD4_3 and BSD4_4 are already defined in sys/param.h */ #define BSD_SYSTEM @@ -30,14 +28,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* More specific than the above two. We cannot use __APPLE__ as this may not be defined on non-OSX Darwin, and we cannot define DARWIN here because Panther and lower CoreFoundation.h uses DARWIN to - distinguish OS X from pure Darwin. */ - + distinguish OS X from pure Darwin. */ #define DARWIN_OS /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "darwin" /* Emacs can read input using SIGIO and buffering characters itself, @@ -61,37 +57,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ It would have Emacs fork off a separate process to read the input and send it to the true Emacs process through a pipe. */ - #define INTERRUPT_INPUT /* Letter to use in finding device name of first pty, if system supports pty's. 'a' means it is /dev/ptya0 */ - #define FIRST_PTY_LETTER 'p' -/* - * Define HAVE_TERMIOS if the system provides POSIX-style - * functions and macros for terminal control. - * - * Define HAVE_TERMIO if the system provides sysV-style ioctls - * for terminal control. - * - * Do not define both. HAVE_TERMIOS is preferred, if it is - * supported on your system. - */ - -#define HAVE_TERMIOS - #define NO_TERMIO -/* - * Define HAVE_PTYS if the system supports pty devices. - * Note: PTYs are broken on darwin <6. Use at your own risk. - */ - +/* Define HAVE_PTYS if the system supports pty devices. + Note: PTYs are broken on darwin <6. Use at your own risk. */ #define HAVE_PTYS -/* Run only once. We need a `for'-loop because the code uses - `continue'. */ +/* Run only once. We need a `for'-loop because the code uses `continue'. */ #define PTY_ITERATION for (i = 0; i < 1; i++) #define PTY_NAME_SPRINTF /* none */ #define PTY_TTY_NAME_SPRINTF /* none */ @@ -109,28 +86,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ } \ while (0) -/** - * PTYs only work correctly on Darwin 7 or higher. So make the - * default for process-connection-type dependent on the kernel - * version. - */ +/* PTYs only work correctly on Darwin 7 or higher. So make the default + for process-connection-type dependent on the kernel version. */ #define MIN_PTY_KERNEL_VERSION '7' -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -#define MAIL_USE_FLOCK - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* Avoid the use of the name init_process (process.c) because it is @@ -140,79 +102,30 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Used in dispnew.c. Copied from freebsd.h. */ #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) -/* System uses OXTABS instead of the expected TAB3. (Copied from - bsd386.h.) */ +/* System uses OXTABS instead of the expected TAB3. (Copied from bsd386.h.) */ #define TAB3 OXTABS -/* Darwin ld insists on the use of malloc routines in the System - framework. */ -#define SYSTEM_MALLOC - /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ #define HAVE_SOCKETS -/* Definitions for how to dump. Copied from nextstep.h. */ - -#define UNEXEC unexmacosx.o - -#define START_FILES pre-crt0.o - -/* start_of_text isn't actually used, so make it compile without error. */ -#define TEXT_START (0) - /* Definitions for how to compile & link. */ - #ifdef HAVE_NS -#define LIBS_NSGUI -framework AppKit #define SYSTEM_PURESIZE_EXTRA 200000 -#define HEADERPAD_EXTRA 6C8 -#else /* !HAVE_NS */ -#define LIBS_NSGUI -#define HEADERPAD_EXTRA 690 -#endif /* !HAVE_NS */ +#endif /* On Darwin, res_init appears not to be useful: see bug#562 and http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html */ - #undef HAVE_RES_INIT #undef HAVE_LIBRESOLV -/* The -headerpad option tells ld (see man page) to leave room at the - end of the header for adding load commands. Needed for dumping. - 0x690 is the total size of 30 segment load commands (at 56 - each); under Cocoa 31 commands are required. */ -#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA - -#define C_SWITCH_SYSTEM_TEMACS -Dtemacs - -#ifdef temacs +#ifdef emacs #define malloc unexec_malloc #define realloc unexec_realloc #define free unexec_free -/* Don't use posix_memalign because it is not compatible with - unexmacosx.c. */ +/* Don't use posix_memalign because it is not compatible with unexmacosx.c. */ #undef HAVE_POSIX_MEMALIGN #endif -/* The ncurses library has been moved out of the System framework in - Mac OS X 10.2. So if ./configure detects it, set the command-line - option to use it. */ -#ifdef HAVE_LIBNCURSES -#define LIBS_TERMCAP -lncurses -/* This prevents crashes when running Emacs in Terminal.app under - 10.2. */ -#define TERMINFO -#endif - -/* Link this program just by running cc. */ -#define ORDINARY_LINK - -/* We don't have a g library, so override the -lg LIBS_DEBUG switch. */ -#define LIBS_DEBUG - -/* Adding -lm confuses the dynamic linker, so omit it. */ -#define LIB_MATH - /* Define the following so emacs symbols will not conflict with those in the System framework. Otherwise -prebind will not work. */ @@ -234,12 +147,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ioctl TIOCSCTTY. */ #define DONT_REOPEN_PTY -/* This makes create_process in process.c save and restore signal - handlers correctly. Suggested by Nozomu Ando.*/ -#define POSIX_SIGNALS - -/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the - stack. */ +/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the stack. */ #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS /* arch-tag: 481d443d-4f89-43ea-b5fb-49706d95fa41 diff --git a/src/s/freebsd.h b/src/s/freebsd.h index e13941d2dcc..cfed343d6c5 100644 --- a/src/s/freebsd.h +++ b/src/s/freebsd.h @@ -1,9 +1,8 @@ /* System description header for FreeBSD systems. - This file describes the parameters that system description files - should define or not. - Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + +Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. Author: Shawn M. Carey (according to authors.el) @@ -23,86 +22,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* Get the correct __FreeBSD_version, even if this is before that was - defined. */ -#ifndef __FreeBSD_version -#ifndef __FreeBSD__ -#define __FreeBSD_version 199401 -#elif __FreeBSD__ == 1 -#define __FreeBSD_version 199405 -#else -#include <osreldate.h> -#endif -#endif /* !defined __FreeBSD_version */ - -/* '__FreeBSD__' is defined by the preprocessor on FreeBSD-1.1 and up. - Earlier versions do not have shared libraries, so inhibit them. - You can inhibit them on newer systems if you wish - by defining NO_SHARED_LIBS. */ -#ifndef __FreeBSD__ -#define NO_SHARED_LIBS -#endif - /* Get most of the stuff from bsd-common */ #include "bsd-common.h" -/* For mem-limits.h. */ -#define BSD4_2 - -/* These aren't needed, since we have getloadavg. */ -#undef KERNEL_FILE -#undef LDAV_SYMBOL - #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) -#define LIBS_DEBUG -#define LIBS_SYSTEM -lutil -#if __FreeBSD_version < 400000 -#define LIBS_TERMCAP -ltermcap -#else -#define TERMINFO -#define LIBS_TERMCAP -lncurses -#endif - -#define SYSV_SYSTEM_DIR - -/* freebsd has POSIX-style pgrp behavior. */ -#undef BSD_PGRPS - -#ifdef __ELF__ - -/* Let `ld' find image libs and similar things in /usr/local/lib. The - system compiler, GCC, has apparently been modified to not look - there, contrary to what a stock GCC would do. */ - -#define LD_SWITCH_SYSTEM -L/usr/local/lib -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -#define UNEXEC unexelf.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o -#undef LIB_GCC -#define LIB_GCC - -#else /* not __ELF__ */ - -#ifdef NO_SHARED_LIBS -#ifdef __FreeBSD__ /* shared libs are available, but the user prefers - not to use them. */ -#define LD_SWITCH_SYSTEM -Bstatic -L/usr/local/lib -#endif /* __FreeBSD__ */ -#endif /* NO_SHARED_LIBS */ - -#endif /* not __ELF__ */ - #define HAVE_GETLOADAVG 1 -#define HAVE_TERMIOS -#define NO_TERMIO -#define DECLARE_GETPWUID_WITH_UID_T -/* freebsd uses OXTABS instead of the expected TAB3. */ -#define TABDLY OXTABS -#define TAB3 OXTABS - -/* this silences a few compilation warnings */ +/* This silences a few compilation warnings. */ #undef BSD_SYSTEM #if __FreeBSD__ == 1 #define BSD_SYSTEM 199103 @@ -117,21 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ioctl TIOCSCTTY. */ #define DONT_REOPEN_PTY -/* If the system's imake configuration file defines `NeedWidePrototypes' - as `NO', we must define NARROWPROTO manually. Such a define is - generated in the Makefile generated by `xmkmf'. If we don't - define NARROWPROTO, we will see the wrong function prototypes - for X functions taking float or double parameters. */ - -#define NARROWPROTO 1 - -/* The following is needed to make `configure' find Xpm, Xaw3d and - image include and library files if using /usr/bin/gcc. That - compiler seems to be modified to not find headers in - /usr/local/include or libs in /usr/local/lib by default. */ - -#define C_SWITCH_SYSTEM -I/usr/X11R6/include -I/usr/local/include -L/usr/local/lib - /* Circumvent a bug in FreeBSD. In the following sequence of writes/reads on a PTY, read(2) returns bogus data: @@ -145,37 +57,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ successfully after processing (for example with CRs added if the terminal is set up that way which it is here). The same bytes will be seen again in a later read(2), without the CRs. */ - #define BROKEN_PTY_READ_AFTER_EAGAIN 1 /* Tell that garbage collector that setjmp is known to save all - registers relevant for conservative garbage collection in the - jmp_buf. */ - + registers relevant for conservative garbage collection in the jmp_buf. */ #define GC_SETJMP_WORKS 1 -/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the - stack. */ - +/* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method for marking the stack. */ #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS -/* Define USE_MMAP_FOR_BUFFERS to let Emacs use mmap(2) to allocate - buffer text. This overrides REL_ALLOC. */ - -#define USE_MMAP_FOR_BUFFERS 1 - -/* Use sigprocmask(2) and friends instead of sigblock(2); the man page - of sigblock says it is obsolete. */ - -#define POSIX_SIGNALS 1 - -/* The `combreloc' setting became the default, and it seems to be - incompatible with unexec. Symptom is an immediate SEGV in - XtInitializeWidget when starting Emacs under X11. */ - -#if defined __FreeBSD_version && __FreeBSD_version >= 500042 -#define LD_SWITCH_SYSTEM_TEMACS -znocombreloc -#endif - /* arch-tag: 426529ca-b7c4-448f-b10a-d4dcdc9c78eb (do not change this comment) */ diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h index ae2eaa43c06..9327423b42f 100644 --- a/src/s/gnu-linux.h +++ b/src/s/gnu-linux.h @@ -1,6 +1,9 @@ /* This file is the configuration file for Linux-based GNU systems - Copyright (C) 1985, 1986, 1992, 1994, 1996, 1999, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 1992, 1994, 1996, 1999, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +This file was put together by Michael K. Johnson and Rik Faith. This file is part of GNU Emacs. @@ -17,23 +20,15 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* This file was put together by Michael K. Johnson and Rik Faith. */ - - -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ - +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #define USG #define GNU_LINUX /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "gnu/linux" /* All the best software is free. */ -#ifndef NOT_C_CODE #ifdef emacs #ifdef HAVE_LINUX_VERSION_H #include <linux/version.h> @@ -44,14 +39,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* LINUX_VERSION_CODE >= 0x20400 */ #endif /* HAVE_LINUX_VERSION_H */ #endif /* emacs */ -#endif /* NOT_C_CODE */ #if defined HAVE_GRANTPT #define UNIX98_PTYS -/* Run only once. We need a `for'-loop because the code uses - `continue'. */ - +/* Run only once. We need a `for'-loop because the code uses `continue'. */ #define PTY_ITERATION for (i = 0; i < 1; i++) #ifdef HAVE_GETPT @@ -63,7 +55,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Note that grantpt and unlockpt may fork. We must block SIGCHLD to prevent sigchld_handler from intercepting the child's death. */ - #define PTY_TTY_NAME_SPRINTF \ { \ char *ptyname; \ @@ -85,58 +76,21 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Letter to use in finding device name of first pty, if system supports pty's. 'p' means it is /dev/ptyp0 */ - #define FIRST_PTY_LETTER 'p' #endif /* not HAVE_GRANTPT */ -/* Define HAVE_TERMIOS if the system provides POSIX-style - functions and macros for terminal control. */ - -#define HAVE_TERMIOS - -/* Define HAVE_PTYS if the system supports pty devices. */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS #define HAVE_SOCKETS -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - /* This is used in list_system_processes. */ #define HAVE_PROCFS 1 -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -/* On GNU/Linux systems, both methods are used by various mail - programs. I assume that most people are using newer mailers that - have heard of flock. Change this if you need to. */ -/* Debian contains a patch which says: ``On Debian/GNU/Linux systems, - configure gets the right answers, and that means *NOT* using flock. - Using flock is guaranteed to be the wrong thing. See Debian Policy - for details.'' and then uses `#ifdef DEBIAN'. Unfortunately the - Debian maintainer hasn't provided a clean fix for Emacs. - movemail.c will use `maillock' when MAILDIR, HAVE_LIBMAIL and - HAVE_MAILLOCK_H are defined, so the following appears to be the - correct logic. -- fx */ -/* We must check for HAVE_LIBLOCKFILE too, as movemail does. - liblockfile is a Free Software replacement for libmail, used on - Debian systems and elsewhere. -rfr */ - -#if !((defined (HAVE_LIBMAIL) || defined (HAVE_LIBLOCKFILE)) && \ - defined (HAVE_MAILLOCK_H)) -#define MAIL_USE_FLOCK -#endif - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* Here, on a separate page, add any special hacks needed @@ -146,84 +100,27 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ your system and must be used only through an encapsulation (Which you should place, by convention, in sysdep.c). */ -/* This is needed for dispnew.c:update_frame */ - +/* This is needed for dispnew.c:update_frame. */ #ifdef emacs #include <stdio.h> /* Get the definition of _IO_STDIO_H. */ #if defined(_IO_STDIO_H) || defined(_STDIO_USES_IOSTREAM) -/* new C libio names */ +/* New C libio names. */ #define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \ ((FILE)->_IO_write_ptr - (FILE)->_IO_write_base) #elif defined (__UCLIBC__) -/* using the uClibc library */ +/* Using the uClibc library. */ #define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \ ((FILE)->__bufpos - (FILE)->__bufstart) #else /* !_IO_STDIO_H && ! __UCLIBC__ */ -/* old C++ iostream names */ +/* Old C++ iostream names. */ #define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \ ((FILE)->_pptr - (FILE)->_pbase) #endif /* !_IO_STDIO_H && ! __UCLIBC__ */ -#endif /* emacs */ -/* Ask GCC where to find libgcc.a. */ -#define LIB_GCC `$(CC) $(C_SWITCH_X_SITE) -print-libgcc-file-name` - -#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o - -/* Here is how to find X Windows. LD_SWITCH_X_SITE_AUX gives an -R option - says where to find X windows at run time. */ - -#ifdef __mips__ -#define LD_SWITCH_SYSTEM -G 0 LD_SWITCH_X_SITE_AUX -#else -#define LD_SWITCH_SYSTEM LD_SWITCH_X_SITE_AUX -#endif /* __mips__ */ - -/* Link temacs with -z nocombreloc so that unexec works right, whether or - not -z combreloc is the default. GNU ld ignores unknown -z KEYWORD - switches, so this also works with older versions that don't implement - -z combreloc. */ -#define LD_SWITCH_SYSTEM_TEMACS -z nocombreloc - -#ifdef emacs #define INTERRUPT_INPUT -#endif - -#define SYSV_SYSTEM_DIR /* use dirent.h */ +#endif /* emacs */ #define POSIX /* affects getpagesize.h and systty.h */ -#define POSIX_SIGNALS - -/* Best not to include -lg, unless it is last on the command line */ -#define LIBS_DEBUG -#undef LIB_GCC -#define LIB_GCC -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtn.o - -/* Don't use -g in test compiles in configure. - This is so we will use the same shared libs for that linking - that are used when linking temacs. */ -#ifdef THIS_IS_CONFIGURE -#define C_DEBUG_SWITCH -#endif - -/* alane@wozzle.linet.org says that -lipc is not a separate library, - since libc-4.4.1. So -lipc was deleted. */ -#define LIBS_SYSTEM -/* _BSD_SOURCE is redundant, at least in glibc2, since we define - _GNU_SOURCE. Left in in case it's relevant to libc5 systems and - anyone's still using Emacs on those. --fx 2002-12-14 */ -#define C_SWITCH_SYSTEM -D_BSD_SOURCE - -/* Paul Abrahams <abrahams@equinox.shaysnet.com> says this is needed. */ -#define LIB_MOTIF -lXm -lXpm - -#ifdef HAVE_LIBNCURSES -#define TERMINFO -#define LIBS_TERMCAP -lncurses -#endif - -#define UNEXEC unexelf.o /* This is to work around mysterious gcc failures in some system versions. It is unlikely that Emacs changes will work around this problem; @@ -232,21 +129,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define HAVE_XRMSETDATABASE #endif -/* Use BSD process groups, but use setpgid() instead of setpgrp() to - actually set a process group. */ -/* Interesting: only GNU/Linux defines this, but the BSDs do not... */ -#define BSD_PGRPS - #define NARROWPROTO 1 -/* Use mmap directly for allocating larger buffers. */ -#ifdef DOUG_LEA_MALLOC -#undef REL_ALLOC -#endif - /* Tell that garbage collector that setjmp is known to save all - registers relevant for conservative garbage collection in the - jmp_buf. */ + registers relevant for conservative garbage collection in the jmp_buf. */ /* Not all the architectures are tested, but there are Debian packages for SCM and/or Guile on them, so the technique must work. See also comments in alloc.c concerning setjmp and gcc. Fixme: it's @@ -254,7 +140,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ register window-flushing. */ /* Don't use #cpu here since in newest development versions of GCC, we must call cpp with -traditional, and that disables #cpu. */ - #if defined __i386__ || defined __sparc__ || defined __mc68000__ \ || defined __alpha__ || defined __mips__ || defined __s390__ \ || defined __arm__ || defined __powerpc__ || defined __amd64__ \ diff --git a/src/s/gnu.h b/src/s/gnu.h index b43cd65c40a..95b8017ddc1 100644 --- a/src/s/gnu.h +++ b/src/s/gnu.h @@ -1,6 +1,7 @@ /* Definitions file for GNU Emacs running on the GNU Hurd. - Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -21,58 +22,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Get most of the stuff from bsd-common */ #include "bsd-common.h" -/* For mem-limits.h. */ -#define BSD4_2 - #undef SYSTEM_TYPE #define SYSTEM_TYPE "gnu" #undef NLIST_STRUCT -#undef KERNEL_FILE -#undef LDAV_SYMBOL #define SIGNALS_VIA_CHARACTERS -#define HAVE_TERMIOS -#define NO_TERMIO - -#define LIBS_DEBUG - -/* XXX emacs should not expect TAB3 to be defined. */ -#define TABDLY OXTABS -#define TAB3 OXTABS - -/* Tell Emacs that we are a terminfo based system; disable the use - of local termcap. (GNU uses ncurses.) */ -#ifdef HAVE_LIBNCURSES -#define TERMINFO -#define LIBS_TERMCAP -lncurses -#endif - -#define SYSV_SYSTEM_DIR - -/* GNU has POSIX-style pgrp behavior. */ -#undef BSD_PGRPS - -/* Use mmap directly for allocating larger buffers. */ -#ifdef DOUG_LEA_MALLOC -#undef REL_ALLOC -#endif - -/* GNU needs its own crt0, and libc defines data_start. */ -#define ORDINARY_LINK +/* libc defines data_start. */ #define DATA_START ({ extern int data_start; (char *) &data_start; }) -/* GNU now always uses the ELF format. */ -#define UNEXEC unexelf.o - /* Some losing code fails to include this and then assumes that because it is braindead that O_RDONLY==0. */ -#ifndef NOT_C_CODE #include <fcntl.h> -#endif - -#define NARROWPROTO 1 #ifdef emacs #include <stdio.h> /* Get the definition of _IO_STDIO_H. */ diff --git a/src/s/hpux10-20.h b/src/s/hpux10-20.h index 5d231986010..0932e6f7112 100644 --- a/src/s/hpux10-20.h +++ b/src/s/hpux10-20.h @@ -1,6 +1,7 @@ /* System description file for hpux version 10.20. - Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,54 +21,31 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define RUN_TIME_REMAP -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ - +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #define USG /* System III, System V, etc */ - #define USG5 - #define HPUX /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "hpux" /* Letter to use in finding device name of first pty, - if system supports pty's. 'p' means it is /dev/ptym/ptyp0 */ - + if system supports pty's. 'p' means it is /dev/ptym/ptyp0 */ #define FIRST_PTY_LETTER 'p' -#define HAVE_TERMIOS #define NO_TERMIO -#define ORDINARY_LINK - -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ - #define HAVE_SOCKETS -/* Define this symbol if your system has the functions bcopy, etc. - * s800 and later versions of s300 (s200) kernels have equivalents - * of the BSTRING functions of BSD. If your s200 kernel doesn't have - * em comment out this section. - */ - -#define BSTRING - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* The symbol in the kernel where the load average is found @@ -75,16 +53,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Special hacks needed to make Emacs run on this system. */ -/* Use the system provided termcap(3) library */ -#define TERMINFO - /* In hpux, the symbol SIGIO is defined, but the feature doesn't work in the way Emacs needs it to. */ - #define BROKEN_SIGIO /* Some additional system facilities exist. */ - #define HAVE_PERROR /* Delete this line for version 6. */ /* This is how to get the device name of the tty end of a pty. */ @@ -98,30 +71,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* This triggers a conditional in xfaces.c. */ #define XOS_NEEDS_TIME_H -/* Don't use shared libraries. unexec doesn't handle them. - Note GCC automatically passes -a archive to ld, and it has its own - conflicting -a. */ -#define LD_SWITCH_SYSTEM_TEMACS - -#ifndef HAVE_LIBXMU -/* HP-UX doesn't supply Xmu. */ -#define LIBXMU - -#endif - /* Assar Westerlund <assar@sics.se> says this is necessary for HP-UX 10.20, and that it works for HP-UX 0 as well. */ #define NO_EDITRES -/* Tested in getloadavg.c. */ -#define HAVE_PSTAT_GETDYNAMIC - /* Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines has a broken `rint' in some library versions including math library version number A.09.05. You can fix the math library by installing patch number PHSS_4630. - But we can fix it more reliably for Emacs like this. */ + But we can fix it more reliably for Emacs like this. */ #undef HAVE_RINT /* We have to go this route, rather than hpux9's approach of renaming the @@ -136,35 +95,45 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* AlainF 20-Jul-1996 says this is right. */ #define KERNEL_FILE "/stand/vmunix" -#define LIBS_SYSTEM -l:libdld.sl /* Rainer Malzbender <rainer@displaytech.com> says definining - HAVE_XRMSETDATABASE allows Emacs to compile on HP-UX 10.20 - using GCC. */ - + HAVE_XRMSETDATABASE allows Emacs to compile on HP-UX 10.20 using GCC. */ #ifndef HAVE_XRMSETDATABASE #define HAVE_XRMSETDATABASE #endif -/* Make sure we get select from libc rather than from libcurses - because libcurses on HPUX 10.10 has a broken version of select. - We used to use -lc -lcurses, but this may be cleaner. */ -#define LIBS_TERMCAP -ltermcap - -/* However, HPUX 10 puts Xaw and Xmu in a strange place - (if you install them at all). So search that place. */ -#define C_SWITCH_X_SYSTEM -I/usr/include/X11R6 -I/usr/include/X11R5 -I/usr/include/Motif1.2 -I/usr/contrib/X11R6/include -I/usr/contrib/X11R5/include -#define LD_SWITCH_X_DEFAULT -L/usr/lib/X11R6 -L/usr/lib/X11R5 -L/usr/lib/Motif1.2 -L/usr/contrib/X11R5/lib - /* 2000-11-21: Temporarily disable Unix 98 large file support found by configure. It fails on HPUX 11, at least, because it enables header sections which lose when `static' is defined away, as it is on HP-UX. (You get duplicate symbol errors on linking). */ - #undef _FILE_OFFSET_BITS -/* otherwise sigunblock wont be defined */ -#define POSIX_SIGNALS +/* Define VIRT_ADDR_VARIES if the virtual addresses of + pure and impure space as loaded can vary, and even their + relative order cannot be relied on. + + Otherwise Emacs assumes that text space precedes data space, + numerically. */ +#define VIRT_ADDR_VARIES + +/* The data segment on this machine always starts at address 0x40000000. */ +#define DATA_SEG_BITS 0x40000000 + +#define DATA_START 0x40000000 + +/* Data type of load average, as read out of kmem. */ +#define LOAD_AVE_TYPE double + +/* Convert that into an integer that is 100 for a load average of 1.0 */ +#define LOAD_AVE_CVT(x) ((int) (x * 100.0)) + +/* The kernel symbol where the load average is found is named _avenrun. + At this time there are two major flavors of hp-ux (there is the s800 + and s300 (s200) flavors). The differences are thusly moved to the + corresponding machine description file. */ + +/* No underscore please. */ +#define LDAV_SYMBOL "avenrun" /* arch-tag: 8d8dcbf1-ca9b-48a1-94be-b750de18a5c6 (do not change this comment) */ diff --git a/src/s/hpux11.h b/src/s/hpux11.h index 3382395a90f..48f60841047 100644 --- a/src/s/hpux11.h +++ b/src/s/hpux11.h @@ -1,10 +1,5 @@ #include "hpux10-20.h" -#ifdef POSIX_SIGNALS -#undef POSIX_SIGNALS -#endif -#define POSIX_SIGNALS 1 - /* SA_RESTART resets the timeout of `select', so don't use it. */ #define BROKEN_SA_RESTART diff --git a/src/s/irix6-5.h b/src/s/irix6-5.h index 57429e41663..10481f609c3 100644 --- a/src/s/irix6-5.h +++ b/src/s/irix6-5.h @@ -20,18 +20,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define IRIX6_5 /* used in m/iris4d */ -#include "usg5-4.h" +#include "usg5-4-common.h" -#undef sigsetmask /* use sys_sigsetmask */ #undef _longjmp /* use system versions, not conservative aliases */ #undef _setjmp #define SETPGRP_RELEASES_CTTY -#ifdef LIB_STANDARD -#undef LIB_STANDARD -#endif - #ifdef SYSTEM_TYPE #undef SYSTEM_TYPE #endif @@ -45,10 +40,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Make process_send_signal work by "typing" a signal character on the pty. */ #define SIGNALS_VIA_CHARACTERS +/* Letter to use in finding device name of first pty, + if system supports pty's. 'a' means it is /dev/ptya0 */ +#undef FIRST_PTY_LETTER +#define FIRST_PTY_LETTER 'q' + /* No need to use sprintf to get the tty name--we get that from _getpty. */ -#ifdef PTY_TTY_NAME_SPRINTF -#undef PTY_TTY_NAME_SPRINTF -#endif #define PTY_TTY_NAME_SPRINTF /* No need to get the pty name at all. */ #ifdef PTY_NAME_SPRINTF @@ -80,55 +77,28 @@ char *_getpty(); strcpy (pty_name, name); \ } -/* Since we use POSIX constructs in PTY_OPEN, we must force POSIX - throughout. */ -#define POSIX_SIGNALS - /* Ulimit(UL_GMEMLIM) is busted... */ #define ULIMIT_BREAK_VALUE 0x14000000 /* Tell process_send_signal to use VSUSP instead of VSWTCH. */ #define PREFER_VSUSP -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -#define MAIL_USE_FLOCK - #define NARROWPROTO 1 -#define USE_MMAP_FOR_BUFFERS 1 - -/* arch-tag: ad0660e0-acf8-46ae-b866-4f3df5b1101b - (do not change this comment) */ - - #if _MIPS_SZLONG == 64 /* -mabi=64 (gcc) or -64 (MIPSpro) */ #define _LP64 /* lisp.h takes care of the rest */ #endif /* _MIPS_SZLONG */ -/* The only supported 32-bit configuration of GCC under IRIX6.x produces - n32 MIPS ABI binaries and also supports -g. */ -#ifdef __GNUC__ -#define C_DEBUG_SWITCH -g -#else -/* Optimize, inaccurate debugging, increase limit on size of what's - optimized. - - This should also be applicable other than on Irix 6.5, but I don't - know for which compiler versions. -- fx */ -#define C_DEBUG_SWITCH -g3 -O -OPT:Olimit=3500 -#endif - #undef SA_RESTART -#undef TIOCSIGSEND /* defined in usg5-4.h */ +#undef TIOCSIGSEND /* defined in usg5-4-common.h */ /* Tested on Irix 6.5. SCM worked on earlier versions. */ #define GC_SETJMP_WORKS 1 #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS +/* arch-tag: ad0660e0-acf8-46ae-b866-4f3df5b1101b + (do not change this comment) */ + /* arch-tag: d7ad9ec2-54ad-4b2f-adf2-0070c5c63e83 (do not change this comment) */ diff --git a/src/s/lynxos.h b/src/s/lynxos.h deleted file mode 100644 index 180b6005692..00000000000 --- a/src/s/lynxos.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Definitions file for GNU Emacs running on LynxOS-3.0.1 - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* LynxOS is almost a bsd 4.2 system */ -#include "s/bsd4-2.h" - -/* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - -/* override the bsd definition */ -#undef SYSTEM_TYPE -#define SYSTEM_TYPE "lynxos 3.0.1" - -/* System stuff redefined from bsd4-2.h */ -#undef KERNEL_FILE -#define KERNEL_FILE "/lynx.os" -#undef LDAV_SYMBOL -#define LDAV_SYMBOL "load_average" - -/* misc defines */ -#define LNOFLSH 0 - -/* COFF related */ -#define COFF -#define NO_REMAP -#define SECTION_ALIGNMENT 0x1 -#define COFF_BSD_SYMBOLS -#define etext __etext -#define edata __edata -#define _start __text - -/* Compilation options */ -#define LIBS_DEBUG -#define ORDINARY_LINK -/* we define following to prevent all the lynxos's stupid compilation */ -/* warning messages */ -#define C_SWITCH_SYSTEM -D__NO_INCLUDE_WARN__ -#define LIBS_SYSTEM -lbsd - -/* arch-tag: fbc81ec9-1c45-416b-a368-799ae7c094a1 - (do not change this comment) */ diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h index 3e5c65eaab5..4ae5f32e873 100644 --- a/src/s/ms-w32.h +++ b/src/s/ms-w32.h @@ -1,6 +1,7 @@ /* System description file for Windows NT. - Copyright (C) 1993, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1993, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -17,10 +18,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #ifndef WINDOWSNT #define WINDOWSNT @@ -30,71 +29,39 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* If you are compiling with a non-C calling convention but need to - declare vararg routines differently, put it here */ + declare vararg routines differently, put it here. */ #define _VARARGS_ __cdecl /* If you are providing a function to something that will call the function back (like a signal handler and signal, or main) its calling - convention must be whatever standard the libraries expect */ + convention must be whatever standard the libraries expect. */ #define _CALLBACK_ __cdecl /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "windows-nt" -#define SYMS_SYSTEM syms_of_ntterm () #define NO_MATHERR 1 /* Letter to use in finding device name of first pty, - if system supports pty's. 'a' means it is /dev/ptya0 */ - + if system supports pty's. 'a' means it is /dev/ptya0 */ #define FIRST_PTY_LETTER 'a' -/* - * Define HAVE_TIMEVAL if the system supports the BSD style clock values. - * Look in <sys/time.h> for a timeval structure. - */ - +/* Define HAVE_TIMEVAL if the system supports the BSD style clock values. + Look in <sys/time.h> for a timeval structure. */ #define HAVE_TIMEVAL 1 -/* NT supports Winsock which is close enough (with some hacks) */ - +/* NT supports Winsock which is close enough (with some hacks). */ #define HAVE_SOCKETS 1 /* But our select implementation doesn't allow us to make non-blocking connects. So until that is fixed, this is necessary: */ - #define BROKEN_NON_BLOCKING_CONNECT 1 /* And the select implementation does 1-byte read-ahead waiting for received packets, so datagrams are broken too. */ - #define BROKEN_DATAGRAM_SOCKETS 1 -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING -#define bzero(b, l) memset(b, 0, l) -#define bcopy(s, d, l) memmove(d, s, l) -#define bcmp(a, b, l) memcmp(a, b, l) - -/* bcopy (aka memmove aka memcpy at least on x86) under MSVC is quite safe */ -#define GAP_USE_BCOPY 1 -#define BCOPY_UPWARD_SAFE 1 -#define BCOPY_DOWNWARD_SAFE 1 - -/* If your system uses COFF (Common Object File Format) then define the - preprocessor symbol "COFF". */ - -#define COFF 1 - -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -/* #define MAIL_USE_FLOCK */ #define MAIL_USE_POP 1 #define MAIL_USE_SYSTEM_LOCK 1 @@ -106,24 +73,30 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* ============================================================ */ -/* Here, add any special hacks needed - to make Emacs work on this system. For example, - you might define certain system call names that don't - exist on your system, or that do different things on - your system and must be used only through an encapsulation - (Which you should place, by convention, in sysdep.c). */ - -/* Define this to be the separator between path elements */ -#define DIRECTORY_SEP XINT (Vdirectory_sep_char) +/* Here, add any special hacks needed to make Emacs work on this + system. For example, you might define certain system call names + that don't exist on your system, or that do different things on + your system and must be used only through an encapsulation (which + you should place, by convention, in sysdep.c). */ -/* Define this to be the separator between devices and paths */ +/* Define this to be the separator between devices and paths. */ #define DEVICE_SEP ':' /* We'll support either convention on NT. */ #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\') #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_)) -/* The null device on Windows NT. */ +#include <sys/types.h> +struct sigaction { + int sa_flags; + void (*sa_handler)(int); + sigset_t sa_mask; +}; +#define SIG_BLOCK 1 +#define SIG_SETMASK 2 +#define SIG_UNBLOCK 3 + +/* The null device on Windows NT. */ #define NULL_DEVICE "NUL:" #ifndef MAXPATHLEN @@ -133,7 +106,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define HAVE_SOUND 1 #define LISP_FLOAT_TYPE 1 -#undef HAVE_SYS_SELECT_H #define HAVE_SYS_TIMEB_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_UNISTD_H 1 @@ -166,8 +138,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define HAVE_RANDOM 1 #undef HAVE_SYSINFO #undef HAVE_LRAND48 -#define HAVE_BCOPY 1 -#define HAVE_BCMP 1 +#define HAVE_MEMCMP 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMSET 1 #define HAVE_LOGB 1 #define HAVE_FREXP 1 #define HAVE_FMOD 1 @@ -213,11 +187,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define MODE_LINE_BINARY_TEXT(_b_) (NILP ((_b_)->buffer_file_type) ? "T" : "B") -/* get some redefinitions in place */ +/* Get some redefinitions in place. */ #ifdef emacs -/* calls that are emulated or shadowed */ +/* Calls that are emulated or shadowed. */ #undef access #define access sys_access #undef chdir @@ -254,15 +228,26 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef write #define write sys_write -/* subprocess calls that are emulated */ +/* Subprocess calls that are emulated. */ #define spawnve sys_spawnve #define wait sys_wait #define kill sys_kill #define signal sys_signal +/* termcap.c calls that are emulated. */ +#define tputs sys_tputs +#define tgetstr sys_tgetstr + +/* cm.c calls that are emulated. */ +#define chcheckmagic sys_chcheckmagic +#define cmcostinit sys_cmcostinit +#define cmgoto sys_cmgoto +#define cmputc sys_cmputc +#define Wcm_clear sys_Wcm_clear + #endif /* emacs */ -/* map to MSVC names */ +/* Map to MSVC names. */ #define execlp _execlp #define execvp _execvp #define fdopen _fdopen @@ -283,8 +268,6 @@ typedef int pid_t; #define pclose _pclose #define umask _umask #define utimbuf _utimbuf -#define index strchr -#define rindex strrchr #define strdup _strdup #define strupr _strupr #define strnicmp _strnicmp @@ -296,8 +279,8 @@ typedef int pid_t; #define utime _utime #endif -/* this is hacky, but is necessary to avoid warnings about macro - redefinitions using the SDK compilers */ +/* This is hacky, but is necessary to avoid warnings about macro + redefinitions using the SDK compilers. */ #ifndef __STDC__ #define __STDC__ 1 #define MUST_UNDEF__STDC__ @@ -310,7 +293,7 @@ typedef int pid_t; #undef MUST_UNDEF__STDC__ #endif -/* Defines that we need that aren't in the standard signal.h */ +/* Defines that we need that aren't in the standard signal.h. */ #define SIGHUP 1 /* Hang up */ #define SIGQUIT 3 /* Quit process */ #define SIGTRAP 5 /* Trace trap */ @@ -353,8 +336,7 @@ extern char *get_emacs_configuration_options (void); #include <sys/stat.h> -/* Define for those source files that do not include enough NT - system files. */ +/* Define for those source files that do not include enough NT system files. */ #ifndef NULL #ifdef __cplusplus #define NULL 0 @@ -389,7 +371,7 @@ extern char *get_emacs_configuration_options (void); removed. Also, obviously, all files that define initialized data must include config.h to pick up this pragma. */ -/* Names must be < 8 bytes */ +/* Names must be < 8 bytes. */ #ifdef _MSC_VER #pragma data_seg("EMDATA") #pragma bss_seg("EMBSS") diff --git a/src/s/msdos.h b/src/s/msdos.h index 88771b9f15f..8dd8e3cf490 100644 --- a/src/s/msdos.h +++ b/src/s/msdos.h @@ -1,7 +1,7 @@ /* System description file for MS-DOS - Copyright (C) 1993, 1996, 1997, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright (C) 1993, 1996, 1997, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -21,20 +21,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Note: lots of stuff here was taken from s-msdos.h in demacs. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ - +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ #ifndef MSDOS #define MSDOS #endif -#ifdef __GO32__ #ifndef __DJGPP__ -#define __DJGPP__ 1 /* V2 defines __DJGPP__ == 2 */ -#endif -#else You lose; /* Emacs for DOS must be compiled with DJGPP */ #endif @@ -42,46 +35,19 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ #undef BSD_SYSTEM /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "ms-dos" -#define SYMS_SYSTEM syms_of_dosfns();syms_of_msdos();syms_of_win16select() - -/* NOMULTIPLEJOBS should be defined if your system's shell - does not have "job control" (the ability to stop a program, - run some other program, then continue the first one). */ - -#define NOMULTIPLEJOBS - -#define SYSV_SYSTEM_DIR - -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - -/* Define this is the compiler understands `volatile'. */ -#define HAVE_VOLATILE - - -/* subprocesses should be defined if you want to - have code for asynchronous subprocesses - (as used in M-x compile and M-x shell). +/* subprocesses should be defined if you want to have code for + asynchronous subprocesses (as used in M-x compile and M-x shell). This is the only system that needs this. */ - #undef subprocesses -/* If your system uses COFF (Common Object File Format) then define the - preprocessor symbol "COFF". */ - -#define COFF - -/* Here, on a separate page, add any special hacks needed - to make Emacs work on this system. For example, - you might define certain system call names that don't - exist on your system, or that do different things on - your system and must be used only through an encapsulation - (Which you should place, by convention, in sysdep.c). */ +/* Here, on a separate page, add any special hacks needed to make + Emacs work on this system. For example, you might define certain + system call names that don't exist on your system, or that do + different things on your system and must be used only through an + encapsulation (which you should place, by convention, in sysdep.c). */ /* Avoid incompatibilities between gmalloc.c and system header files in how to declare valloc. */ @@ -93,59 +59,18 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ /* setjmp and longjmp can safely replace _setjmp and _longjmp, but they will run slower. */ - #define _setjmp setjmp #define _longjmp longjmp -#if __DJGPP__ < 2 - -/* New chdir () routine. - DJGPP v2.0 and later doesn't need it because its chdir() does - set the drive itself. */ -#ifdef chdir -#undef chdir -#endif -#define chdir sys_chdir - -#define LIBS_SYSTEM -lpc /* isn't required in DJGPP v2.0, either */ - -#endif /* __DJGPP__ < 2 */ - -#if __DJGPP__ > 1 - #define DATA_START (&etext + 1) -#define TEXT_START &start #define _NAIVE_DOS_REGS -#else /* not __DJGPP__ > 1 */ - -/* This somehow needs to be defined even though we use COFF. */ -#define TEXT_START -1 - -#endif /* not __DJGPP__ > 1 */ - -#define ORDINARY_LINK - /* command.com does not understand `...` so we define this. */ -#define LIB_GCC -Lgcc #define SEPCHAR ';' #define NULL_DEVICE "nul" -#if __DJGPP__ < 2 -#define O_RDONLY 0x0001 -#define O_WRONLY 0x0002 -#define O_RDWR 0x0004 -#define O_CREAT 0x0100 -#define O_TRUNC 0x0200 -#define O_EXCL 0x0400 -#define O_APPEND 0x0800 -#define O_TEXT 0x4000 -#define O_BINARY 0x8000 -#define NO_MATHERR -#endif - #define HAVE_INVERSE_HYPERBOLIC #define FLOAT_CHECK_DOMAIN @@ -156,39 +81,24 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ :AB=<BG %d>:AF=<FG %d>:op=<DefC>:" /* Define this to a function (Fdowncase, Fupcase) if your file system - likes that */ + likes that. */ #define FILE_SYSTEM_CASE Fmsdos_downcase_filename -/* Define this to be the separator between devices and paths */ +/* Define this to be the separator between devices and paths. */ #define DEVICE_SEP ':' /* We'll support either convention on MSDOG. */ #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\') #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_)) -/* Call init_gettimeofday when TZ changes. */ -#if __DJGPP__ < 2 -#define LOCALTIME_CACHE -#define tzset init_gettimeofday -#endif - -/* bcopy under djgpp is quite safe */ -#define GAP_USE_BCOPY -#define BCOPY_UPWARD_SAFE 1 -#define BCOPY_DOWNWARD_SAFE 1 /* Mode line description of a buffer's type. */ #define MODE_LINE_BINARY_TEXT(buf) (NILP(buf->buffer_file_type) ? "T" : "B") -/* Do we have POSIX signals? */ -#if __DJGPP__ > 1 -#define POSIX_SIGNALS -#endif - /* We have (the code to control) a mouse. */ #define HAVE_MOUSE -/* We canuse mouse menus. */ +/* We can use mouse menus. */ #define HAVE_MENUS /* Define one of these for easier conditionals. */ @@ -197,7 +107,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ commentary below, in the non-X branch. The 140KB number was measured on GNU/Linux and on MS-WIndows. */ #define SYSTEM_PURESIZE_EXTRA (-170000+140000) -#define LIBX11_SYSTEM -lxext -lsys #else /* We need a little extra space, see ../../lisp/loadup.el. As of 20091024, DOS-specific files use up 62KB of pure space. But @@ -212,9 +121,7 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ #endif /* Tell the garbage collector that setjmp is known to save all - registers relevant for conservative garbage collection in the - jmp_buf. */ - + registers relevant for conservative garbage collection in the jmp_buf. */ #define GC_SETJMP_WORKS 1 #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS diff --git a/src/s/netbsd.h b/src/s/netbsd.h index 132fc137e50..6f5b24bcfa6 100644 --- a/src/s/netbsd.h +++ b/src/s/netbsd.h @@ -1,7 +1,7 @@ /* s/ file for netbsd system. - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. +Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -19,125 +19,31 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* Get most of the stuff from bsd-common */ +/* Get most of the stuff from bsd-common. */ #include "bsd-common.h" -#if defined (__alpha__) && !defined (__ELF__) -#define NO_SHARED_LIBS -#endif - -/* For mem-limits.h. */ -#define BSD4_2 - -#undef KERNEL_FILE -#undef LDAV_SYMBOL #define HAVE_GETLOADAVG 1 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base) -/* netbsd uses OXTABS instead of the expected TAB3. */ -#define TABDLY OXTABS -#define TAB3 OXTABS - -#define HAVE_TERMIOS -#define NO_TERMIO - -#define LIBS_DEBUG -/* -lutil is not needed for NetBSD >0.9. */ -/* #define LIBS_SYSTEM -lutil */ -#ifdef HAVE_TERM_H -#define TERMINFO -#define LIBS_TERMCAP -lterminfo -#else -#define LIBS_TERMCAP -ltermcap -#endif - -#define NEED_ERRNO -#define SYSV_SYSTEM_DIR - -/* Netbsd has POSIX-style pgrp behavior. */ -#undef BSD_PGRPS - -#if !defined (NO_SHARED_LIBS) && defined (__ELF__) -#define START_FILES pre-crt0.o /usr/lib/crt0.o START_FILES_1 /usr/lib/crtbegin.o -#define UNEXEC unexelf.o -#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtend.o END_FILES_1 -#undef LIB_GCC -#define LIB_GCC -#endif - -#ifdef HAVE_CRTIN -#define START_FILES_1 /usr/lib/crti.o -#define END_FILES_1 /usr/lib/crtn.o -#else -#define START_FILES_1 -#define END_FILES_1 -#endif - -#define AMPERSAND_FULL_NAME - -#ifdef __ELF__ -/* Here is how to find X Windows. LD_SWITCH_X_SITE_AUX gives an -R option - says where to find X windows at run time. We convert it to a -rpath option - which is what OSF1 uses. */ -#define LD_SWITCH_SYSTEM_tmp `echo LD_SWITCH_X_SITE_AUX | sed -e 's/-R/-Wl,-rpath,/'` -#define LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_tmp -Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib - -/* The following is needed to make `configure' find Xpm, Xaw3d and - image include and library files if using /usr/bin/gcc. That - compiler seems to be modified to not find headers in - /usr/local/include or libs in /usr/local/lib by default. */ - -#define C_SWITCH_SYSTEM -I/usr/X11R6/include -I/usr/pkg/include -I/usr/local/include -L/usr/pkg/lib -L/usr/local/lib - -/* Link temacs with -z nocombreloc so that unexec works right, whether or - not -z combreloc is the default. GNU ld ignores unknown -z KEYWORD - switches, so this also works with older versions that don't implement - -z combreloc. */ - -#define LD_SWITCH_SYSTEM_TEMACS -Wl,-z,nocombreloc - -#endif /* __ELF__ */ - -/* On post 1.3 releases of NetBSD, gcc -nostdlib also clears - the library search parth, i.e. it won't search /usr/lib - for libc and friends. Using -nostartfiles instead avoids - this problem, and will also work on earlier NetBSD releases */ - -#define LINKER $(CC) -nostartfiles - -#define NARROWPROTO 1 - #define DEFAULT_SOUND_DEVICE "/dev/audio" /* Greg A. Woods <woods@weird.com> says we must include signal.h before syssignal.h is included, to work around interface conflicts that are handled with CPP __RENAME() macro in signal.h. */ - -#ifndef NOT_C_CODE #include <signal.h> -#endif /* Don't close pty in process.c to make it as controlling terminal. It is already a controlling terminal of subprocess, because we did ioctl TIOCSCTTY. */ - #define DONT_REOPEN_PTY /* Tell that garbage collector that setjmp is known to save all - registers relevant for conservative garbage collection in the - jmp_buf. */ - + registers relevant for conservative garbage collection in the jmp_buf. */ #define GC_SETJMP_WORKS 1 /* Use the GC_MAKE_GCPROS_NOOPS (see lisp.h) method. */ - #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS -/* Use sigprocmask and friends instead of sigblock; - sigblock is considered obsolete on NetBSD. */ - -#define POSIX_SIGNALS 1 - /* arch-tag: e80f364a-04e9-4faf-93cb-f36a0fe95c81 (do not change this comment) */ diff --git a/src/s/openbsd.h b/src/s/openbsd.h index 3b996de7059..d9d60e3b868 100644 --- a/src/s/openbsd.h +++ b/src/s/openbsd.h @@ -1,40 +1,7 @@ -/* s/ file for openbsd systems. */ +/* System file for openbsd. */ -/* Mostly the same as NetBSD. */ +/* The same as NetBSD. Note there are differences in configure. */ #include "netbsd.h" -/* This very-badly named symbol is conditionally defined in netbsd.h. - Better would be either to not need it in the first place, or to choose - a more descriptive name. */ -#ifndef LD_SWITCH_SYSTEM_tmp -#define LD_SWITCH_SYSTEM_tmp /* empty */ -#endif - -/* David Mazieres <dm@reeducation-labor.lcs.mit.edu> says this - is necessary. Otherwise Emacs dumps core when run -nw. */ -#undef LIBS_TERMCAP - -#define TERMINFO -#define LIBS_TERMCAP -lncurses - -#undef LD_SWITCH_SYSTEM_TEMACS -#undef LD_SWITCH_SYSTEM -#ifdef __ELF__ - - /* Han Boetes <han@mijncomputer.nl> says this - is necessary, otherwise Emacs dumps core on elf systems. */ -#define LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_tmp -Z - -/* The version of gcc on OpenBSD doesn't search /usr/local/lib by - default. */ -#define LD_SWITCH_X_DEFAULT -L/usr/local/lib - -#else - -#define LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_tmp -#define LD_SWITCH_X_DEFAULT -L/usr/local/lib - -#endif - /* arch-tag: 7e3f65ca-3f48-4237-933f-2b208b21e8e2 (do not change this comment) */ diff --git a/src/s/sol2-10.h b/src/s/sol2-10.h index 865e17525c4..fd7f30021ea 100644 --- a/src/s/sol2-10.h +++ b/src/s/sol2-10.h @@ -2,25 +2,6 @@ #include "sol2-6.h" -#define SYSTEM_MALLOC - -/* - * Use the Solaris dldump() function, called from unexsol.c, to dump - * emacs, instead of the generic ELF dump code found in unexelf.c. - * The resulting binary has a complete symbol table, and is better - * for debugging and other observabilty tools (debuggers, pstack, etc). - * - * If you encounter a problem using dldump(), please consider sending - * a message to the OpenSolaris tools-linking mailing list: - * http://mail.opensolaris.org/mailman/listinfo/tools-linking - * - * It is likely that dldump() works with older Solaris too, - * but this has not been tested, and so, this change is for - * Solaris 10 and newer only at this time. - */ -#undef UNEXEC -#define UNEXEC unexsol.o - /* This is used in list_system_processes. */ #define HAVE_PROCFS 1 diff --git a/src/s/sol2-3.h b/src/s/sol2-3.h deleted file mode 100644 index fa05aa45b67..00000000000 --- a/src/s/sol2-3.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Definitions file for GNU Emacs running on Solaris 2.3. - - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -#include "usg5-4.h" - -#define SOLARIS2 - -/* This triggers a conditional in xfaces.c. */ -#define XOS_NEEDS_TIME_H - -#define POSIX - -#define LIBS_SYSTEM -lsocket -lnsl -lkstat - -/* Prefer kstat over kvm in getloadavg.c, kstat doesn't require root. - ghazi@caip.rutgers.edu, 7/21/97. Don't redefine if already defined - (e.g., by config.h). */ -#ifndef HAVE_LIBKSTAT -#define HAVE_LIBKSTAT -#endif - -/* inoue@ainet.or.jp says Solaris has a bug related to X11R6-style - XIM support. */ - -#define INHIBIT_X11R6_XIM - -/* Must use the system's termcap, if we use any termcap. - It does special things. */ - -#ifndef TERMINFO -#define LIBS_TERMCAP -ltermcap -#endif - -#define USE_MMAP_FOR_BUFFERS 1 - -#ifndef __GNUC__ -#define LD_SWITCH_SYSTEM -L /usr/ccs/lib LD_SWITCH_X_SITE_AUX -/* eggert thinks all versions of SunPro C allowed this. */ -#define C_DEBUG_SWITCH -g -O -#else /* GCC */ -/* We use ./prefix-args because we don't know whether LD_SWITCH_X_SITE_AUX - has anything in it. It can be empty. - This works ok in src. Luckily lib-src does not use LD_SWITCH_SYSTEM. */ -#define LD_SWITCH_SYSTEM -L /usr/ccs/lib \ - `./prefix-args -Xlinker LD_SWITCH_X_SITE_AUX` -#endif /* GCC */ - -/* Info from fnf@cygnus.com suggests this is appropriate. */ -#define POSIX_SIGNALS - -/* We don't need the definition from usg5-4.h with POSIX_SIGNALS. */ -#undef sigsetmask - -/* This is the same definition as in usg5-4.h, but with sigblock/sigunblock - rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't - work if POSIX_SIGNALS is defined. It may also be appropriate for SVR4.x - (x<2) but I'm not sure. fnf@cygnus.com */ -/* This sets the name of the slave side of the PTY. On SysVr4, - grantpt(3) forks a subprocess, so keep sigchld_handler() from - intercepting that death. If any child but grantpt's should die - within, it should be caught after sigrelse(2). */ - -#undef PTY_TTY_NAME_SPRINTF -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptsname (), *ptyname; \ - \ - sigblock (sigmask (SIGCLD)); \ - if (grantpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - sigunblock (sigmask (SIGCLD)); \ - if (unlockpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - if (!(ptyname = ptsname (fd))) \ - { emacs_close (fd); return -1; } \ - strncpy (pty_name, ptyname, sizeof (pty_name)); \ - pty_name[sizeof (pty_name) - 1] = 0; \ - } - -/* arch-tag: a8fe2e15-e517-49cb-a863-f346b80885fe - (do not change this comment) */ diff --git a/src/s/sol2-4.h b/src/s/sol2-4.h deleted file mode 100644 index df8552e9562..00000000000 --- a/src/s/sol2-4.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Handle Solaris 2.4. */ - -#include "sol2-3.h" - -#undef LD_SWITCH_SYSTEM - -/* `#ifdef USE_MOTIF' won't work here, since USE_MOTIF isn't defined yet. - Instead, dynamically check whether USE_MOTIF expands to something. */ -#define NOT_USING_MOTIF { set x USE_MOTIF; test "$$2" = "USE_MOTIF"; } - -#ifndef __GNUC__ -#define LD_SWITCH_SYSTEM_TEMACS -L/usr/ccs/lib LD_SWITCH_X_SITE_AUX \ - `NOT_USING_MOTIF || echo ' -R/usr/dt/lib'` -#else /* GCC */ -/* We use ./prefix-args because we don't know whether LD_SWITCH_X_SITE_AUX - has anything in it. It can be empty. - This works ok in temacs. */ -#define LD_SWITCH_SYSTEM_TEMACS -L/usr/ccs/lib \ - `./prefix-args -Xlinker LD_SWITCH_X_SITE_AUX` \ - `NOT_USING_MOTIF || echo ' -R/usr/dt/lib -L/usr/dt/lib'` - -/* Get rid of -traditional and let const really do its thing. */ -#undef C_SWITCH_SYSTEM -#undef const -#endif /* GCC */ - -/* Gregory Neil Shapiro <gshapiro@hhmi.org> reports the Motif header files - are in this directory on Solaris 2.4. */ -#define C_SWITCH_X_SYSTEM -I/usr/dt/include - -/* arch-tag: 6f0de37b-cfda-427a-a5ae-b83ed54aaae7 - (do not change this comment) */ diff --git a/src/s/sol2-5.h b/src/s/sol2-5.h deleted file mode 100644 index 90163987e69..00000000000 --- a/src/s/sol2-5.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Handle Solaris 2.5. */ - -#include "sol2-4.h" - -/* -lgen is needed for the regex and regcmp functions - which are used by Motif. In the future we can try changing - regex.c to provide them in Emacs, but this is safer for now. */ -#define LIB_MOTIF -lXm -lgen - -/* This is the only known way to avoid some crashes - that seem to relate to screwed up malloc data - after deleting a frame. */ -/* rms: I think the problems using ralloc had to do with system - libraries that called the system malloc even if we linked in the - GNU malloc. I could not see any way to fix the problem except to - have just one malloc and that had to be the system one. */ -/* This is not always necessary. Turned off at present for testers to - identify any problems with gmalloc more accurately. */ -/* #define SYSTEM_MALLOC */ - -/* There have problems reported with mmap at least on Solaris 2.6 - and 2.7. For simplicity, let's not use mmap for anything >= 2.5. - We can optimize this later. */ - -#undef USE_MMAP_FOR_BUFFERS - -/* Probably OK also on earlier versions. */ -#define GC_SETJMP_WORKS 1 -#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS - -/* arch-tag: 96d65526-21c9-4547-a797-2bd575c05be7 - (do not change this comment) */ diff --git a/src/s/sol2-6.h b/src/s/sol2-6.h index a43443e48c2..3b707aa5c3c 100644 --- a/src/s/sol2-6.h +++ b/src/s/sol2-6.h @@ -1,11 +1,66 @@ -/* Handle Solaris 2.6. */ +/* Definitions file for GNU Emacs running on Solaris 2.6. -#include "sol2-5.h" +Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. -#if 0 /* dldump does not handle all the extensions used by GNU ld. */ -#undef UNEXEC -#define UNEXEC unexsol.o +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +#include "usg5-4-common.h" + +#define SOLARIS2 + +/* This triggers a conditional in xfaces.c. */ +#define XOS_NEEDS_TIME_H + +#define POSIX + +/* Prefer kstat over kvm in getloadavg.c, kstat doesn't require root. + ghazi@caip.rutgers.edu, 7/21/97. Don't redefine if already defined + (e.g., by config.h). */ +#ifndef HAVE_LIBKSTAT +#define HAVE_LIBKSTAT #endif +/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock + rather than sighold/sigrelse, which appear to be BSD4.1 specific. + It may also be appropriate for SVR4.x + (x<2) but I'm not sure. fnf@cygnus.com */ +/* This sets the name of the slave side of the PTY. On SysVr4, + grantpt(3) forks a subprocess, so keep sigchld_handler() from + intercepting that death. If any child but grantpt's should die + within, it should be caught after sigrelse(2). */ + +#define PTY_TTY_NAME_SPRINTF \ + { \ + char *ptsname (), *ptyname; \ + \ + sigblock (sigmask (SIGCLD)); \ + if (grantpt (fd) == -1) \ + { emacs_close (fd); return -1; } \ + sigunblock (sigmask (SIGCLD)); \ + if (unlockpt (fd) == -1) \ + { emacs_close (fd); return -1; } \ + if (!(ptyname = ptsname (fd))) \ + { emacs_close (fd); return -1; } \ + strncpy (pty_name, ptyname, sizeof (pty_name)); \ + pty_name[sizeof (pty_name) - 1] = 0; \ + } + +#define GC_SETJMP_WORKS 1 +#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS + /* arch-tag: 71ea3857-89dc-4395-9623-77964e6ed3ca (do not change this comment) */ diff --git a/src/s/template.h b/src/s/template.h index e5fd2541c7b..eb7ca85c5e5 100644 --- a/src/s/template.h +++ b/src/s/template.h @@ -1,8 +1,9 @@ /* Template for system description header files. This file describes the parameters that system description files should define or not. - Copyright (C) 1985, 1986, 1992, 1999, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Copyright (C) 1985, 1986, 1992, 1999, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -20,10 +21,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -/* - * Define symbols to identify the version of Unix this is. - * Define all the symbols that apply correctly. - */ +/* Define symbols to identify the version of Unix this is. + Define all the symbols that apply correctly. */ /* #define USG5 */ /* #define USG */ @@ -33,16 +32,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* #define BSD_SYSTEM */ /* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ + It sets the Lisp variable system-type. */ #define SYSTEM_TYPE "berkeley-unix" -/* NOMULTIPLEJOBS should be defined if your system's shell - does not have "job control" (the ability to stop a program, - run some other program, then continue the first one). */ - -/* #define NOMULTIPLEJOBS */ - /* Emacs can read input using SIGIO and buffering characters itself, or using CBREAK mode and making C-g cause SIGINT. The choice is controlled by the variable interrupt_input. @@ -63,62 +56,26 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ Another method of doing input is planned but not implemented. It would have Emacs fork off a separate process to read the input and send it to the true Emacs process - through a pipe. */ - + through a pipe. */ #define INTERRUPT_INPUT /* Letter to use in finding device name of first pty, - if system supports pty's. 'a' means it is /dev/ptya0 */ - + if system supports pty's. 'a' means it is /dev/ptya0. */ #define FIRST_PTY_LETTER 'a' -/* - * Define HAVE_TERMIOS if the system provides POSIX-style - * functions and macros for terminal control. - * - * Define HAVE_TERMIO if the system provides sysV-style ioctls - * for terminal control. - * - * Do not define both. HAVE_TERMIOS is preferred, if it is - * supported on your system. - */ - -#define HAVE_TERMIOS -/* #define HAVE_TERMIO */ - -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - +/* Define HAVE_PTYS if the system supports pty devices. */ #define HAVE_PTYS -/* Define this symbol if your system has the functions bcopy, etc. */ - -#define BSTRING - /* subprocesses should be undefined if you do NOT want to have code for asynchronous subprocesses (as used in M-x compile and M-x shell). - Currently only MSDOS does not support this. */ + Currently only MSDOS does not support this. */ /* #undef subprocesses */ -/* If your system uses COFF (Common Object File Format) then define the - preprocessor symbol "COFF". */ - -/* #define COFF */ - -/* define MAIL_USE_FLOCK if the mailer uses flock - to interlock access to /usr/spool/mail/$USER. - The alternative is that a lock file named - /usr/spool/mail/$USER.lock. */ - -#define MAIL_USE_FLOCK - /* Define CLASH_DETECTION if you want lock files to be written so that Emacs can tell instantly when you try to modify a file that someone else has modified in his Emacs. */ - #define CLASH_DETECTION /* Define this if your operating system declares signal handlers to @@ -134,17 +91,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ is not ':', #define this to be the appropriate character constant. */ /* #define SEPCHAR ':' */ -/* Define this if the system can use mmap for buffer text allocation. */ -/* #define USE_MMAP_FOR_BUFFERS 1 */ - /* ============================================================ */ -/* Here, add any special hacks needed - to make Emacs work on this system. For example, - you might define certain system call names that don't - exist on your system, or that do different things on - your system and must be used only through an encapsulation - (Which you should place, by convention, in sysdep.c). */ +/* Here, add any special hacks needed to make Emacs work on this + system. For example, you might define certain system call names + that don't exist on your system, or that do different things on + your system and must be used only through an encapsulation (which + you should place, by convention, in sysdep.c). */ /* If the system's imake configuration file defines `NeedWidePrototypes' as `NO', we must define NARROWPROTO manually. Such a define is @@ -157,10 +110,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* ============================================================ */ /* After adding support for a new system, modify the large case - statement in the `configure' script to recognize reasonable + statement in configure.in to recognize reasonable configuration names, and add a description of the system to `etc/MACHINES'. + Check for any tests of $opsys in configure.in, and add an entry + for the new system if needed. + If you've just fixed a problem in an existing configuration file, you should also check `etc/MACHINES' to make sure its descriptions of known problems in that configuration should be updated. */ diff --git a/src/s/unixware.h b/src/s/unixware.h index 934821dd166..81b1b3d97fa 100644 --- a/src/s/unixware.h +++ b/src/s/unixware.h @@ -1,4 +1,63 @@ -#include "usg5-4-2.h" +/* s/ file for Unixware. + +Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + + +#include "usg5-4-common.h" + +/* #define HAVE_GETWD (appears to be buggy on SVR4.2) */ +#undef HAVE_GETWD + +#undef HAVE_SYSV_SIGPAUSE + +/* This is the same definition as in usg5-4-common.h, but with sigblock/sigunblock + rather than sighold/sigrelse, which appear to be BSD4.1 specific. + It may also be appropriate for SVR4.x + (x<2) but I'm not sure. fnf@cygnus.com */ +/* This sets the name of the slave side of the PTY. On SysVr4, + grantpt(3) forks a subprocess, so keep sigchld_handler() from + intercepting that death. If any child but grantpt's should die + within, it should be caught after sigrelse(2). */ +#define PTY_TTY_NAME_SPRINTF \ + { \ + char *ptsname(), *ptyname; \ + \ + sigblock(sigmask(SIGCLD)); \ + if (grantpt(fd) == -1) \ + fatal("could not grant slave pty"); \ + sigunblock(sigmask(SIGCLD)); \ + if (unlockpt(fd) == -1) \ + fatal("could not unlock slave pty"); \ + if (!(ptyname = ptsname(fd))) \ + fatal ("could not enable slave pty"); \ + strncpy(pty_name, ptyname, sizeof(pty_name)); \ + pty_name[sizeof(pty_name) - 1] = 0; \ + } + +/* Data type of load average, as read out of kmem. */ +#define LOAD_AVE_TYPE long + +/* Convert that into an integer that is 100 for a load average of 1.0 */ +/* This is totally uncalibrated. */ +#define LOAD_AVE_CVT(x) ((int) (((double) (x)) * 100.0 / FSCALE)) +#define FSCALE 256.0 + #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->__ptr - (FILE)->__base) diff --git a/src/s/usg5-4-2.h b/src/s/usg5-4-2.h deleted file mode 100644 index d7f2c60ffc1..00000000000 --- a/src/s/usg5-4-2.h +++ /dev/null @@ -1,73 +0,0 @@ -/* s/ file for System V release 4.2. - - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - - -#include "usg5-4.h" - -/* fnf@cygnus.com says these exist. */ -#define HAVE_TCATTR -/* #define HAVE_GETWD (appears to be buggy on SVR4.2) */ -#undef HAVE_GETWD - -/* Info from fnf@cygnus.com suggests this is appropriate. */ -#define POSIX_SIGNALS - -/* We don't need the definition from usg5-3.h with POSIX_SIGNALS. */ -#undef sigsetmask -#undef HAVE_SYSV_SIGPAUSE - -/* Motif needs -lgen. */ -#define LIBS_SYSTEM -lsocket -lnsl -lelf -lgen - -/* This is the same definition as in usg5-4.h, but with sigblock/sigunblock - rather than sighold/sigrelse, which appear to be BSD4.1 specific and won't - work if POSIX_SIGNALS is defined. It may also be appropriate for SVR4.x - (x<2) but I'm not sure. fnf@cygnus.com */ -/* This sets the name of the slave side of the PTY. On SysVr4, - grantpt(3) forks a subprocess, so keep sigchld_handler() from - intercepting that death. If any child but grantpt's should die - within, it should be caught after sigrelse(2). */ - -#undef PTY_TTY_NAME_SPRINTF -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptsname(), *ptyname; \ - \ - sigblock(sigmask(SIGCLD)); \ - if (grantpt(fd) == -1) \ - fatal("could not grant slave pty"); \ - sigunblock(sigmask(SIGCLD)); \ - if (unlockpt(fd) == -1) \ - fatal("could not unlock slave pty"); \ - if (!(ptyname = ptsname(fd))) \ - fatal ("could not enable slave pty"); \ - strncpy(pty_name, ptyname, sizeof(pty_name)); \ - pty_name[sizeof(pty_name) - 1] = 0; \ - } - -/* Use libw.a along with X11R6 Xt. */ -#define NEED_LIBW - -/* ryanr@ellingtn.ftc.nrcs.usda.gov (Richard Anthony Ryan) says -lXimp - is needed in UNIX_SV ... 4.2 1.1.2. */ -#define LIB_MOTIF -lXm -lXimp - -/* arch-tag: 9bbfcfc1-19be-45a1-9699-af57b87da2c6 - (do not change this comment) */ diff --git a/src/s/usg5-4-common.h b/src/s/usg5-4-common.h new file mode 100644 index 00000000000..4dcb8e50200 --- /dev/null +++ b/src/s/usg5-4-common.h @@ -0,0 +1,111 @@ +/* Definitions file for GNU Emacs running on AT&T's System V Release 4 + +Copyright (C) 1987, 1990, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +Written by James Van Artsdalen of Dell Computer Corp. james@bigtex.cactus.org. +Subsequently improved for Dell 2.2 by Eric S. Raymond <esr@snark.thyrsus.com>. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +/* Use the SysVr3 file for at least base configuration. */ +#define USG /* System III, System V, etc */ + +#define USG5 +#define USG5_4 + +/* SYSTEM_TYPE should indicate the kind of system you are using. + It sets the Lisp variable system-type. */ +#define SYSTEM_TYPE "usg-unix-v" + +/* The file containing the kernel's symbol table is called /unix. */ +#define KERNEL_FILE "/unix" + +/* The kernel symbol where the load average is found is named avenrun. */ +#define LDAV_SYMBOL "avenrun" + +/* setjmp and longjmp can safely replace _setjmp and _longjmp, + but they will run slower. */ +#define _setjmp setjmp +#define _longjmp longjmp + +/* The docs for system V/386 suggest v.3 has sigpause, so let's try it. */ +#define HAVE_SYSV_SIGPAUSE + +/* On USG systems signal handlers return void. */ +#define SIGTYPE void + +/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars. + But get <termio.h> first to make sure ttold.h doesn't interfere. + And don't try to use SIGIO yet. */ +#include <sys/wait.h> + +#ifdef emacs +#include <sys/filio.h> +#include <termio.h> +#include <sys/ttold.h> +#include <signal.h> +#include <sys/stream.h> +#include <sys/stropts.h> +#include <sys/termios.h> +#define BROKEN_SIGIO +#endif + +/* Some SVr4s don't define NSIG in sys/signal.h for ANSI environments; + instead, there's a system variable _sys_nsig. Unfortunately, we need the + constant to dimension an array. So wire in the appropriate value here. */ +#define NSIG_MINIMUM 32 + +/* We can support this. */ +#define CLASH_DETECTION + +/* Define HAVE_PTYS if the system supports pty devices. */ +#define HAVE_PTYS + +/* It is possible to receive SIGCHLD when there are no children + waiting, because a previous waitsys(2) cleaned up the carcass of child + without clearing the SIGCHLD pending info. So, use a non-blocking + wait3 instead, which maps to waitpid(2) in SysVr4. */ +#define wait3(status, options, rusage) \ + waitpid ((pid_t) -1, (status), (options)) +#define WRETCODE(w) (w >> 8) + +/* TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY + subprocesses the usual way. But TIOCSIGNAL does work for PTYs, and + this is all we need. */ +#define TIOCSIGSEND TIOCSIGNAL + +/* This change means that we don't loop through allocate_pty too many + times in the (rare) event of a failure. */ +#define FIRST_PTY_LETTER 'z' + +/* This sets the name of the master side of the PTY. */ +#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx"); + +/* Push various streams modules onto a PTY channel. */ +#define SETUP_SLAVE_PTY \ + if (ioctl (xforkin, I_PUSH, "ptem") == -1) \ + fatal ("ioctl I_PUSH ptem", errno); \ + if (ioctl (xforkin, I_PUSH, "ldterm") == -1) \ + fatal ("ioctl I_PUSH ldterm", errno); \ + if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) \ + fatal ("ioctl I_PUSH ttcompat", errno); + +/* This definition was suggested for next release. So give it a try. */ +#define HAVE_SOCKETS + +/* arch-tag: 1a0ed909-5faa-434b-b7c3-9d86c63d53a6 + (do not change this comment) */ diff --git a/src/s/usg5-4.h b/src/s/usg5-4.h deleted file mode 100644 index c611911b0e8..00000000000 --- a/src/s/usg5-4.h +++ /dev/null @@ -1,215 +0,0 @@ -/* Definitions file for GNU Emacs running on AT&T's System V Release 4 - Copyright (C) 1987, 1990, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - -/* This file written by James Van Artsdalen of Dell Computer Corporation. - * james@bigtex.cactus.org. Subsequently improved for Dell 2.2 by Eric - * S. Raymond <esr@snark.thyrsus.com>. - */ - -/* Use the SysVr3 file for at least base configuration. */ - -#define USG /* System III, System V, etc */ - -#define USG5 -#define USG5_4 - -/* SYSTEM_TYPE should indicate the kind of system you are using. - It sets the Lisp variable system-type. */ - -#define SYSTEM_TYPE "usg-unix-v" - -/* - * Define HAVE_TERMIO if the system provides sysV-style ioctls - * for terminal control. - */ - -#define HAVE_TERMIO - -/* - * Define HAVE_PTYS if the system supports pty devices. - */ - -/* - * Define SYSV_SYSTEM_DIR to use the V.3 getdents/readir - * library functions. Almost, but not quite the same as - * the 4.2 functions - */ -#define SYSV_SYSTEM_DIR - -/* The file containing the kernel's symbol table is called /unix. */ - -#define KERNEL_FILE "/unix" - -/* The symbol in the kernel where the load average is found - is named avenrun. */ - -#define LDAV_SYMBOL "avenrun" - -/* Special hacks needed to make Emacs run on this system. */ - -/* - * Make the sigsetmask function go away. Don't know what the - * ramifications of this are, but doesn't seem possible to - * emulate it properly anyway at this point. - */ - -#define sigsetmask(mask) /* Null expansion */ - -/* setjmp and longjmp can safely replace _setjmp and _longjmp, - but they will run slower. */ - -#define _setjmp setjmp -#define _longjmp longjmp - -/* On USG systems these have different names */ -#ifndef HAVE_INDEX -#define index strchr -#endif /* ! defined (HAVE_INDEX) */ -#ifndef HAVE_RINDEX -#define rindex strrchr -#endif /* ! defined (HAVE_RINDEX) */ - -/* Use terminfo instead of termcap. */ - -#define TERMINFO - - -/* The docs for system V/386 suggest v.3 has sigpause, - so let's give it a try. */ -#define HAVE_SYSV_SIGPAUSE - - -/* If we're using the System V X port, BSD bstring functions will be handy */ - -#ifdef HAVE_X_WINDOWS -#define BSTRING -#endif /* HAVE_X_WINDOWS */ - -/* On USG systems signal handlers return void */ - -#define SIGTYPE void - -#define ORDINARY_LINK - -#define LIB_STANDARD - -/* there are no -lg libraries on this system, and no libPW */ - -#define LIBS_DEBUG - -/* Undump with ELF */ - -#undef COFF - -#define UNEXEC unexelf.o - -/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct - * tchars. But get <termio.h> first to make sure ttold.h doesn't - * interfere. And don't try to use SIGIO yet. - */ - -#ifndef NOT_C_CODE -#include <sys/wait.h> -#endif - -#ifdef emacs -#include <sys/filio.h> -#include <termio.h> -#include <sys/ttold.h> -#include <signal.h> -#include <sys/stream.h> -#include <sys/stropts.h> -#include <sys/termios.h> -#define BROKEN_SIGIO -#endif - -/* Some SVr4s don't define NSIG in sys/signal.h for ANSI environments; - * instead, there's a system variable _sys_nsig. Unfortunately, we need the - * constant to dimension an array. So wire in the appropriate value here. - */ -#define NSIG_MINIMUM 32 - -/* We can support this */ - -#define CLASH_DETECTION - -#define HAVE_PTYS -#define HAVE_TERMIOS - -/* It is possible to receive SIGCHLD when there are no children - waiting, because a previous waitsys(2) cleaned up the carcass of child - without clearing the SIGCHLD pending info. So, use a non-blocking - wait3 instead, which maps to waitpid(2) in SysVr4. */ - -#define wait3(status, options, rusage) \ - waitpid ((pid_t) -1, (status), (options)) -#define WRETCODE(w) (w >> 8) - -/* TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY - subprocesses the usual way. But TIOCSIGNAL does work for PTYs, and - this is all we need. */ - -#define TIOCSIGSEND TIOCSIGNAL - -/* This change means that we don't loop through allocate_pty too many - times in the (rare) event of a failure. */ - -#define FIRST_PTY_LETTER 'z' - -/* This sets the name of the master side of the PTY. */ - -#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx"); - -/* This sets the name of the slave side of the PTY. On SysVr4, - grantpt(3) forks a subprocess, so keep sigchld_handler() from - intercepting that death. If any child but grantpt's should die - within, it should be caught after sigrelse(2). */ - -#define PTY_TTY_NAME_SPRINTF \ - { \ - char *ptsname (), *ptyname; \ - \ - sighold (SIGCLD); \ - if (grantpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - sigrelse (SIGCLD); \ - if (unlockpt (fd) == -1) \ - { emacs_close (fd); return -1; } \ - if (!(ptyname = ptsname (fd))) \ - { emacs_close (fd); return -1; } \ - strncpy (pty_name, ptyname, sizeof (pty_name)); \ - pty_name[sizeof (pty_name) - 1] = 0; \ - } - -/* Push various streams modules onto a PTY channel. */ - -#define SETUP_SLAVE_PTY \ - if (ioctl (xforkin, I_PUSH, "ptem") == -1) \ - fatal ("ioctl I_PUSH ptem", errno); \ - if (ioctl (xforkin, I_PUSH, "ldterm") == -1) \ - fatal ("ioctl I_PUSH ldterm", errno); \ - if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) \ - fatal ("ioctl I_PUSH ttcompat", errno); - -/* This definition was suggested for next release. - So give it a try. */ -#define HAVE_SOCKETS - -/* arch-tag: 1a0ed909-5faa-434b-b7c3-9d86c63d53a6 - (do not change this comment) */ diff --git a/src/scroll.c b/src/scroll.c index e2d3656dc43..4d1c4045bd4 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <string.h> #include <setjmp.h> #include "lisp.h" #include "termchar.h" @@ -58,14 +57,14 @@ struct matrix_elt unsigned char writecount; }; -static void do_direct_scrolling P_ ((struct frame *, - struct glyph_matrix *, - struct matrix_elt *, - int, int)); -static void do_scrolling P_ ((struct frame *, - struct glyph_matrix *, - struct matrix_elt *, - int, int)); +static void do_direct_scrolling (struct frame *, + struct glyph_matrix *, + struct matrix_elt *, + int, int); +static void do_scrolling (struct frame *, + struct glyph_matrix *, + struct matrix_elt *, + int, int); /* Determine, in matrix[i,j], the cost of updating the first j old @@ -86,20 +85,15 @@ static void do_scrolling P_ ((struct frame *, new contents appears. */ static void -calculate_scrolling (frame, matrix, window_size, lines_below, - draw_cost, old_hash, new_hash, - free_at_end) - FRAME_PTR frame; - /* matrix is of size window_size + 1 on each side. */ - struct matrix_elt *matrix; - int window_size, lines_below; - int *draw_cost; - int *old_hash; - int *new_hash; - int free_at_end; +calculate_scrolling (FRAME_PTR frame, + /* matrix is of size window_size + 1 on each side. */ + struct matrix_elt *matrix, + int window_size, int lines_below, + int *draw_cost, int *old_hash, int *new_hash, + int free_at_end) { register int i, j; - int frame_lines = FRAME_LINES (frame); + EMACS_INT frame_lines = FRAME_LINES (frame); register struct matrix_elt *p, *p1; register int cost, cost1; @@ -120,7 +114,7 @@ calculate_scrolling (frame, matrix, window_size, lines_below, /* Discourage long scrolls on fast lines. Don't scroll nearly a full frame height unless it saves at least 1/4 second. */ - int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame)); + int extra_cost = (int) (baud_rate / (10 * 4 * FRAME_LINES (frame))); if (baud_rate <= 0) extra_cost = 1; @@ -244,12 +238,7 @@ calculate_scrolling (frame, matrix, window_size, lines_below, of lines. */ static void -do_scrolling (frame, current_matrix, matrix, window_size, unchanged_at_top) - struct frame *frame; - struct glyph_matrix *current_matrix; - struct matrix_elt *matrix; - int window_size; - int unchanged_at_top; +do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct matrix_elt *matrix, int window_size, int unchanged_at_top) { struct matrix_elt *p; int i, j, k; @@ -268,7 +257,7 @@ do_scrolling (frame, current_matrix, matrix, window_size, unchanged_at_top) int *copy_from = (int *) alloca (window_size * sizeof (int)); /* Zero means line is empty. */ - bzero (retained_p, window_size * sizeof (char)); + memset (retained_p, 0, window_size * sizeof (char)); for (k = 0; k < window_size; ++k) copy_from[k] = -1; @@ -429,21 +418,16 @@ do_scrolling (frame, current_matrix, matrix, window_size, unchanged_at_top) is the equivalent of draw_cost for the old line contents */ static void -calculate_direct_scrolling (frame, matrix, window_size, lines_below, - draw_cost, old_draw_cost, old_hash, new_hash, - free_at_end) - FRAME_PTR frame; - /* matrix is of size window_size + 1 on each side. */ - struct matrix_elt *matrix; - int window_size, lines_below; - int *draw_cost; - int *old_draw_cost; - int *old_hash; - int *new_hash; - int free_at_end; +calculate_direct_scrolling (FRAME_PTR frame, + /* matrix is of size window_size + 1 on each side. */ + struct matrix_elt *matrix, + int window_size, int lines_below, + int *draw_cost, int *old_draw_cost, + int *old_hash, int *new_hash, + int free_at_end) { register int i, j; - int frame_lines = FRAME_LINES (frame); + EMACS_INT frame_lines = FRAME_LINES (frame); register struct matrix_elt *p, *p1; register int cost, cost1, delta; @@ -463,7 +447,7 @@ calculate_direct_scrolling (frame, matrix, window_size, lines_below, /* Discourage long scrolls on fast lines. Don't scroll nearly a full frame height unless it saves at least 1/4 second. */ - int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame)); + int extra_cost = (int) (baud_rate / (10 * 4 * FRAME_LINES (frame))); if (baud_rate <= 0) extra_cost = 1; @@ -655,13 +639,9 @@ calculate_direct_scrolling (frame, matrix, window_size, lines_below, the cost matrix for this approach is constructed. */ static void -do_direct_scrolling (frame, current_matrix, cost_matrix, - window_size, unchanged_at_top) - struct frame *frame; - struct glyph_matrix *current_matrix; - struct matrix_elt *cost_matrix; - int window_size; - int unchanged_at_top; +do_direct_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, + struct matrix_elt *cost_matrix, int window_size, + int unchanged_at_top) { struct matrix_elt *p; int i, j; @@ -692,7 +672,7 @@ do_direct_scrolling (frame, current_matrix, cost_matrix, old matrix. Lines not retained are empty. */ char *retained_p = (char *) alloca (window_size * sizeof (char)); - bzero (retained_p, window_size * sizeof (char)); + memset (retained_p, 0, window_size * sizeof (char)); /* Perform some sanity checks when GLYPH_DEBUG is on. */ CHECK_MATRIX (current_matrix); @@ -811,15 +791,9 @@ do_direct_scrolling (frame, current_matrix, cost_matrix, void -scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, - draw_cost, old_draw_cost, old_hash, new_hash, free_at_end) - FRAME_PTR frame; - int window_size, unchanged_at_top, unchanged_at_bottom; - int *draw_cost; - int *old_draw_cost; - int *old_hash; - int *new_hash; - int free_at_end; +scrolling_1 (FRAME_PTR frame, int window_size, int unchanged_at_top, + int unchanged_at_bottom, int *draw_cost, int *old_draw_cost, + int *old_hash, int *new_hash, int free_at_end) { struct matrix_elt *matrix; matrix = ((struct matrix_elt *) @@ -854,9 +828,7 @@ scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, such a line will have little weight. */ int -scrolling_max_lines_saved (start, end, oldhash, newhash, cost) - int start, end; - int *oldhash, *newhash, *cost; +scrolling_max_lines_saved (int start, int end, int *oldhash, int *newhash, int *cost) { struct { int hash; int count; } lines[01000]; register int i, h; @@ -872,7 +844,7 @@ scrolling_max_lines_saved (start, end, oldhash, newhash, cost) avg_length /= end - start; threshold = avg_length / 4; - bzero (lines, sizeof lines); + memset (lines, 0, sizeof lines); /* Put new lines' hash codes in hash table. Ignore lines shorter than the threshold. Thus, if the lines that are in common are @@ -909,15 +881,13 @@ scrolling_max_lines_saved (start, end, oldhash, newhash, cost) to scroll_frame_lines to perform this scrolling. */ int -scroll_cost (frame, from, to, amount) - FRAME_PTR frame; - int from, to, amount; +scroll_cost (FRAME_PTR frame, int from, int to, int amount) { /* Compute how many lines, at bottom of frame, will not be involved in actual motion. */ - int limit = to; - int offset; - int height = FRAME_LINES (frame); + EMACS_INT limit = to; + EMACS_INT offset; + EMACS_INT height = FRAME_LINES (frame); if (amount == 0) return 0; @@ -948,14 +918,10 @@ scroll_cost (frame, from, to, amount) overhead and multiply factor values */ static void -line_ins_del (frame, ov1, pf1, ovn, pfn, ov, mf) - FRAME_PTR frame; - int ov1, ovn; - int pf1, pfn; - register int *ov, *mf; +line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int *ov, register int *mf) { - register int i; - register int frame_lines = FRAME_LINES (frame); + register EMACS_INT i; + register EMACS_INT frame_lines = FRAME_LINES (frame); register int insert_overhead = ov1 * 10; register int next_insert_cost = ovn * 10; @@ -969,15 +935,11 @@ line_ins_del (frame, ov1, pf1, ovn, pfn, ov, mf) } static void -ins_del_costs (frame, - one_line_string, multi_string, - setup_string, cleanup_string, - costvec, ncostvec, coefficient) - FRAME_PTR frame; - char *one_line_string, *multi_string; - char *setup_string, *cleanup_string; - int *costvec, *ncostvec; - int coefficient; +ins_del_costs (FRAME_PTR frame, + char *one_line_string, char *multi_string, + char *setup_string, char *cleanup_string, + int *costvec, int *ncostvec, + int coefficient) { if (multi_string) line_ins_del (frame, @@ -1029,15 +991,11 @@ ins_del_costs (frame, */ void -do_line_insertion_deletion_costs (frame, - ins_line_string, multi_ins_string, - del_line_string, multi_del_string, - setup_string, cleanup_string, coefficient) - FRAME_PTR frame; - char *ins_line_string, *multi_ins_string; - char *del_line_string, *multi_del_string; - char *setup_string, *cleanup_string; - int coefficient; +do_line_insertion_deletion_costs (FRAME_PTR frame, + char *ins_line_string, char *multi_ins_string, + char *del_line_string, char *multi_del_string, + char *setup_string, char *cleanup_string, + int coefficient) { if (FRAME_INSERT_COST (frame) != 0) { diff --git a/src/search.c b/src/search.c index 736a89258f5..f2957c335a2 100644 --- a/src/search.c +++ b/src/search.c @@ -98,22 +98,22 @@ Lisp_Object Vsearch_spaces_regexp; only. */ Lisp_Object Vinhibit_changing_match_data; -static void set_search_regs P_ ((EMACS_INT, EMACS_INT)); -static void save_search_regs P_ ((void)); -static EMACS_INT simple_search P_ ((int, unsigned char *, int, int, - Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT)); -static EMACS_INT boyer_moore P_ ((int, unsigned char *, int, int, - Lisp_Object, Lisp_Object, - EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, int)); -static EMACS_INT search_buffer P_ ((Lisp_Object, EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT, int, int, - Lisp_Object, Lisp_Object, int)); -static void matcher_overflow () NO_RETURN; +static void set_search_regs (EMACS_INT, EMACS_INT); +static void save_search_regs (void); +static EMACS_INT simple_search (EMACS_INT, unsigned char *, EMACS_INT, + EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT); +static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, EMACS_INT, EMACS_INT, + Lisp_Object, Lisp_Object, + EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, int); +static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT, EMACS_INT, int, + Lisp_Object, Lisp_Object, int); +static void matcher_overflow (void) NO_RETURN; static void -matcher_overflow () +matcher_overflow (void) { error ("Stack overflow in regexp matcher"); } @@ -132,12 +132,7 @@ matcher_overflow () The behavior also depends on Vsearch_spaces_regexp. */ static void -compile_pattern_1 (cp, pattern, translate, regp, posix) - struct regexp_cache *cp; - Lisp_Object pattern; - Lisp_Object translate; - struct re_registers *regp; - int posix; +compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, struct re_registers *regp, int posix) { char *val; reg_syntax_t old; @@ -187,7 +182,7 @@ compile_pattern_1 (cp, pattern, translate, regp, posix) This is called from garbage collection. */ void -shrink_regexp_cache () +shrink_regexp_cache (void) { struct regexp_cache *cp; @@ -205,7 +200,7 @@ shrink_regexp_cache () automagically manages the memory in each re_pattern_buffer struct, based on its `allocated' and `buffer' values. */ void -clear_regexp_cache () +clear_regexp_cache (void) { int i; @@ -229,11 +224,7 @@ clear_regexp_cache () for this pattern. 0 means backtrack only enough to get a valid match. */ struct re_pattern_buffer * -compile_pattern (pattern, regp, translate, posix, multibyte) - Lisp_Object pattern; - struct re_registers *regp; - Lisp_Object translate; - int posix, multibyte; +compile_pattern (Lisp_Object pattern, struct re_registers *regp, Lisp_Object translate, int posix, int multibyte) { struct regexp_cache *cp, **cpp; @@ -290,14 +281,12 @@ compile_pattern (pattern, regp, translate, posix, multibyte) static Lisp_Object -looking_at_1 (string, posix) - Lisp_Object string; - int posix; +looking_at_1 (Lisp_Object string, int posix) { Lisp_Object val; unsigned char *p1, *p2; EMACS_INT s1, s2; - register int i; + register EMACS_INT i; struct re_pattern_buffer *bufp; if (running_asynch_code) @@ -373,8 +362,7 @@ DEFUN ("looking-at", Flooking_at, Slooking_at, 1, 1, 0, This function modifies the match data that `match-beginning', `match-end' and `match-data' access; save and restore the match data if you want to preserve them. */) - (regexp) - Lisp_Object regexp; + (Lisp_Object regexp) { return looking_at_1 (regexp, 0); } @@ -385,16 +373,13 @@ Find the longest match, in accord with Posix regular expression rules. This function modifies the match data that `match-beginning', `match-end' and `match-data' access; save and restore the match data if you want to preserve them. */) - (regexp) - Lisp_Object regexp; + (Lisp_Object regexp) { return looking_at_1 (regexp, 1); } static Lisp_Object -string_match_1 (regexp, string, start, posix) - Lisp_Object regexp, string, start; - int posix; +string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix) { int val; struct re_pattern_buffer *bufp; @@ -411,7 +396,7 @@ string_match_1 (regexp, string, start, posix) pos = 0, pos_byte = 0; else { - int len = SCHARS (string); + EMACS_INT len = SCHARS (string); CHECK_NUMBER (start); pos = XINT (start); @@ -474,8 +459,7 @@ matched by parenthesis constructs in the pattern. You can use the function `match-string' to extract the substrings matched by the parenthesis constructions in REGEXP. */) - (regexp, string, start) - Lisp_Object regexp, string, start; + (Lisp_Object regexp, Lisp_Object string, Lisp_Object start) { return string_match_1 (regexp, string, start, 0); } @@ -488,8 +472,7 @@ If third arg START is non-nil, start search at that index in STRING. For index of first char beyond the match, do (match-end 0). `match-end' and `match-beginning' also give indices of substrings matched by parenthesis constructs in the pattern. */) - (regexp, string, start) - Lisp_Object regexp, string, start; + (Lisp_Object regexp, Lisp_Object string, Lisp_Object start) { return string_match_1 (regexp, string, start, 1); } @@ -499,8 +482,7 @@ matched by parenthesis constructs in the pattern. */) This does not clobber the match data. */ int -fast_string_match (regexp, string) - Lisp_Object regexp, string; +fast_string_match (Lisp_Object regexp, Lisp_Object string) { int val; struct re_pattern_buffer *bufp; @@ -522,16 +504,12 @@ fast_string_match (regexp, string) This does not clobber the match data. We assume that STRING contains single-byte characters. */ -extern Lisp_Object Vascii_downcase_table; - int -fast_c_string_match_ignore_case (regexp, string) - Lisp_Object regexp; - const char *string; +fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string) { int val; struct re_pattern_buffer *bufp; - int len = strlen (string); + size_t len = strlen (string); regexp = string_make_unibyte (regexp); re_match_object = Qt; @@ -547,8 +525,7 @@ fast_c_string_match_ignore_case (regexp, string) /* Like fast_string_match but ignore case. */ int -fast_string_match_ignore_case (regexp, string) - Lisp_Object regexp, string; +fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string) { int val; struct re_pattern_buffer *bufp; @@ -572,10 +549,7 @@ fast_string_match_ignore_case (regexp, string) data. */ EMACS_INT -fast_looking_at (regexp, pos, pos_byte, limit, limit_byte, string) - Lisp_Object regexp; - EMACS_INT pos, pos_byte, limit, limit_byte; - Lisp_Object string; +fast_looking_at (Lisp_Object regexp, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT limit, EMACS_INT limit_byte, Lisp_Object string) { int multibyte; struct re_pattern_buffer *buf; @@ -640,8 +614,7 @@ fast_looking_at (regexp, pos, pos_byte, limit, limit_byte, string) This is our cheezy way of associating an action with the change of state of a buffer-local variable. */ static void -newline_cache_on_off (buf) - struct buffer *buf; +newline_cache_on_off (struct buffer *buf) { if (NILP (buf->cache_long_line_scans)) { @@ -681,13 +654,9 @@ newline_cache_on_off (buf) If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do except when inside redisplay. */ -int -scan_buffer (target, start, end, count, shortage, allow_quit) - register int target; - EMACS_INT start, end; - int count; - int *shortage; - int allow_quit; +EMACS_INT +scan_buffer (register int target, EMACS_INT start, EMACS_INT end, + EMACS_INT count, int *shortage, int allow_quit) { struct region_cache *newline_cache; int direction; @@ -727,7 +696,7 @@ scan_buffer (target, start, end, count, shortage, allow_quit) to see where we can avoid some scanning. */ if (target == '\n' && newline_cache) { - int next_change; + EMACS_INT next_change; immediate_quit = 0; while (region_cache_forward (current_buffer, newline_cache, start_byte, &next_change)) @@ -799,7 +768,7 @@ scan_buffer (target, start, end, count, shortage, allow_quit) /* Consult the newline cache, if appropriate. */ if (target == '\n' && newline_cache) { - int next_change; + EMACS_INT next_change; immediate_quit = 0; while (region_cache_backward (current_buffer, newline_cache, start_byte, &next_change)) @@ -878,12 +847,10 @@ scan_buffer (target, start, end, count, shortage, allow_quit) If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do except in special cases. */ -int -scan_newline (start, start_byte, limit, limit_byte, count, allow_quit) - EMACS_INT start, start_byte; - EMACS_INT limit, limit_byte; - register int count; - int allow_quit; +EMACS_INT +scan_newline (EMACS_INT start, EMACS_INT start_byte, + EMACS_INT limit, EMACS_INT limit_byte, + register EMACS_INT count, int allow_quit) { int direction = ((count > 0) ? 1 : -1); @@ -976,10 +943,8 @@ scan_newline (start, start_byte, limit, limit_byte, count, allow_quit) return count * direction; } -int -find_next_newline_no_quit (from, cnt) - EMACS_INT from; - int cnt; +EMACS_INT +find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt) { return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); } @@ -988,13 +953,11 @@ find_next_newline_no_quit (from, cnt) not after, and only search up to TO. This isn't just find_next_newline (...)-1, because you might hit TO. */ -int -find_before_next_newline (from, to, cnt) - EMACS_INT from, to; - int cnt; +EMACS_INT +find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt) { int shortage; - int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); + EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); if (shortage == 0) pos--; @@ -1005,14 +968,11 @@ find_before_next_newline (from, to, cnt) /* Subroutines of Lisp buffer search functions. */ static Lisp_Object -search_command (string, bound, noerror, count, direction, RE, posix) - Lisp_Object string, bound, noerror, count; - int direction; - int RE; - int posix; +search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, + Lisp_Object count, int direction, int RE, int posix) { register int np; - int lim, lim_byte; + EMACS_INT lim, lim_byte; int n = direction; if (!NILP (count)) @@ -1086,10 +1046,9 @@ search_command (string, bound, noerror, count, direction, RE, posix) /* Return 1 if REGEXP it matches just one constant string. */ static int -trivial_regexp_p (regexp) - Lisp_Object regexp; +trivial_regexp_p (Lisp_Object regexp) { - int len = SBYTES (regexp); + EMACS_INT len = SBYTES (regexp); unsigned char *s = SDATA (regexp); while (--len >= 0) { @@ -1153,21 +1112,12 @@ while (0) static struct re_registers search_regs_1; static EMACS_INT -search_buffer (string, pos, pos_byte, lim, lim_byte, n, - RE, trt, inverse_trt, posix) - Lisp_Object string; - EMACS_INT pos; - EMACS_INT pos_byte; - EMACS_INT lim; - EMACS_INT lim_byte; - int n; - int RE; - Lisp_Object trt; - Lisp_Object inverse_trt; - int posix; +search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte, + EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n, + int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) { - int len = SCHARS (string); - int len_byte = SBYTES (string); + EMACS_INT len = SCHARS (string); + EMACS_INT len_byte = SBYTES (string); register int i; if (running_asynch_code) @@ -1184,7 +1134,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp))) { unsigned char *p1, *p2; - int s1, s2; + EMACS_INT s1, s2; struct re_pattern_buffer *bufp; bufp = compile_pattern (string, @@ -1220,7 +1170,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, while (n < 0) { - int val; + EMACS_INT val; val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) @@ -1264,7 +1214,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, } while (n > 0) { - int val; + EMACS_INT val; val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, pos_byte - BEGV_BYTE, lim_byte - pos_byte, (NILP (Vinhibit_changing_match_data) @@ -1309,8 +1259,8 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, else /* non-RE case */ { unsigned char *raw_pattern, *pat; - int raw_pattern_size; - int raw_pattern_size_byte; + EMACS_INT raw_pattern_size; + EMACS_INT raw_pattern_size_byte; unsigned char *patbuf; int multibyte = !NILP (current_buffer->enable_multibyte_characters); unsigned char *base_pat; @@ -1443,7 +1393,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, } /* Store this character into the translated pattern. */ - bcopy (str, pat, charlen); + memcpy (pat, str, charlen); pat += charlen; base_pat += in_charlen; len_byte -= in_charlen; @@ -1504,19 +1454,16 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, boyer_moore cannot work. */ static EMACS_INT -simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) - int n; - unsigned char *pat; - int len, len_byte; - Lisp_Object trt; - EMACS_INT pos, pos_byte; - EMACS_INT lim, lim_byte; +simple_search (EMACS_INT n, unsigned char *pat, + EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt, + EMACS_INT pos, EMACS_INT pos_byte, + EMACS_INT lim, EMACS_INT lim_byte) { int multibyte = ! NILP (current_buffer->enable_multibyte_characters); int forward = n > 0; /* Number of buffer bytes matched. Note that this may be different from len_byte in a multibyte buffer. */ - int match_byte; + EMACS_INT match_byte; if (lim > pos && multibyte) while (n > 0) @@ -1526,7 +1473,7 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) /* Try matching at position POS. */ EMACS_INT this_pos = pos; EMACS_INT this_pos_byte = pos_byte; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (pos + len > lim || pos_byte + len_byte > lim_byte) goto stop; @@ -1571,7 +1518,7 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) { /* Try matching at position POS. */ EMACS_INT this_pos = pos; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (pos + len > lim) @@ -1611,7 +1558,7 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) /* Try matching at position POS. */ EMACS_INT this_pos = pos; EMACS_INT this_pos_byte = pos_byte; - int this_len = len; + EMACS_INT this_len = len; const unsigned char *p = pat + len_byte; if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte) @@ -1654,7 +1601,7 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) { /* Try matching at position POS. */ EMACS_INT this_pos = pos - len; - int this_len = len; + EMACS_INT this_len = len; unsigned char *p = pat; if (this_pos < lim) @@ -1717,24 +1664,20 @@ simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) If that criterion is not satisfied, do not call this function. */ static EMACS_INT -boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt, - pos, pos_byte, lim, lim_byte, char_base) - int n; - unsigned char *base_pat; - int len, len_byte; - Lisp_Object trt; - Lisp_Object inverse_trt; - EMACS_INT pos, pos_byte; - EMACS_INT lim, lim_byte; - int char_base; +boyer_moore (EMACS_INT n, unsigned char *base_pat, + EMACS_INT len, EMACS_INT len_byte, + Lisp_Object trt, Lisp_Object inverse_trt, + EMACS_INT pos, EMACS_INT pos_byte, + EMACS_INT lim, EMACS_INT lim_byte, int char_base) { int direction = ((n > 0) ? 1 : -1); - register int dirlen; + register EMACS_INT dirlen; EMACS_INT limit; int stride_for_teases = 0; int BM_tab[0400]; register unsigned char *cursor, *p_limit; - register int i, j; + register EMACS_INT i; + register int j; unsigned char *pat, *pat_end; int multibyte = ! NILP (current_buffer->enable_multibyte_characters); @@ -2127,8 +2070,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt, Also clear out the match data for registers 1 and up. */ static void -set_search_regs (beg_byte, nbytes) - EMACS_INT beg_byte, nbytes; +set_search_regs (EMACS_INT beg_byte, EMACS_INT nbytes) { int i; @@ -2162,15 +2104,14 @@ set_search_regs (beg_byte, nbytes) need not match a word boundary unless it ends in whitespace. */ static Lisp_Object -wordify (string, lax) - Lisp_Object string; - int lax; +wordify (Lisp_Object string, int lax) { register unsigned char *p, *o; - register int i, i_byte, len, punct_count = 0, word_count = 0; + register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0; Lisp_Object val; int prev_c = 0; - int adjust, whitespace_at_end; + EMACS_INT adjust; + int whitespace_at_end; CHECK_STRING (string); p = SDATA (string); @@ -2220,14 +2161,13 @@ wordify (string, lax) for (i = 0, i_byte = 0; i < len; ) { int c; - int i_byte_orig = i_byte; + EMACS_INT i_byte_orig = i_byte; FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); if (SYNTAX (c) == Sword) { - bcopy (SDATA (string) + i_byte_orig, o, - i_byte - i_byte_orig); + memcpy (o, SDATA (string) + i_byte_orig, i_byte - i_byte_orig); o += i_byte - i_byte_orig; } else if (i > 0 && SYNTAX (prev_c) == Sword && --word_count) @@ -2265,8 +2205,7 @@ Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. See also the functions `match-beginning', `match-end' and `replace-match'. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (string, bound, noerror, count, -1, 0, 0); } @@ -2285,8 +2224,7 @@ Search case-sensitivity is determined by the value of the variable `case-fold-search', which see. See also the functions `match-beginning', `match-end' and `replace-match'. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (string, bound, noerror, count, 1, 0, 0); } @@ -2300,8 +2238,7 @@ The match found must not extend before that position. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (wordify (string, 0), bound, noerror, count, -1, 1, 0); } @@ -2315,8 +2252,7 @@ The match found must not extend after that position. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (wordify (string, 0), bound, noerror, count, 1, 1, 0); } @@ -2334,8 +2270,7 @@ The match found must not extend before that position. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (wordify (string, 1), bound, noerror, count, -1, 1, 0); } @@ -2353,8 +2288,7 @@ The match found must not extend after that position. Optional third argument, if t, means if fail just return nil (no error). If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. */) - (string, bound, noerror, count) - Lisp_Object string, bound, noerror, count; + (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (wordify (string, 1), bound, noerror, count, 1, 1, 0); } @@ -2372,8 +2306,7 @@ Optional third argument, if t, means if fail just return nil (no error). Optional fourth argument is repeat count--search for successive occurrences. See also the functions `match-beginning', `match-end', `match-string', and `replace-match'. */) - (regexp, bound, noerror, count) - Lisp_Object regexp, bound, noerror, count; + (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (regexp, bound, noerror, count, -1, 1, 0); } @@ -2389,8 +2322,7 @@ Optional third argument, if t, means if fail just return nil (no error). Optional fourth argument is repeat count--search for successive occurrences. See also the functions `match-beginning', `match-end', `match-string', and `replace-match'. */) - (regexp, bound, noerror, count) - Lisp_Object regexp, bound, noerror, count; + (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (regexp, bound, noerror, count, 1, 1, 0); } @@ -2409,8 +2341,7 @@ Optional third argument, if t, means if fail just return nil (no error). Optional fourth argument is repeat count--search for successive occurrences. See also the functions `match-beginning', `match-end', `match-string', and `replace-match'. */) - (regexp, bound, noerror, count) - Lisp_Object regexp, bound, noerror, count; + (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (regexp, bound, noerror, count, -1, 1, 1); } @@ -2427,8 +2358,7 @@ Optional third argument, if t, means if fail just return nil (no error). Optional fourth argument is repeat count--search for successive occurrences. See also the functions `match-beginning', `match-end', `match-string', and `replace-match'. */) - (regexp, bound, noerror, count) - Lisp_Object regexp, bound, noerror, count; + (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { return search_command (regexp, bound, noerror, count, 1, 1, 1); } @@ -2469,11 +2399,10 @@ This is, in a vague sense, the inverse of using `\\N' in NEWTEXT; NEWTEXT in place of subexp N. This is useful only after a regular expression search or match, since only regular expressions have distinguished subexpressions. */) - (newtext, fixedcase, literal, string, subexp) - Lisp_Object newtext, fixedcase, literal, string, subexp; + (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) { enum { nochange, all_caps, cap_initial } case_action; - register int pos, pos_byte; + register EMACS_INT pos, pos_byte; int some_multiletter_word; int some_lowercase; int some_uppercase; @@ -2621,8 +2550,8 @@ since only regular expressions have distinguished subexpressions. */) for (pos_byte = 0, pos = 0; pos_byte < length;) { - int substart = -1; - int subend = 0; + EMACS_INT substart = -1; + EMACS_INT subend = 0; int delbackslash = 0; FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); @@ -2715,9 +2644,9 @@ since only regular expressions have distinguished subexpressions. */) perform substitution on the replacement string. */ if (NILP (literal)) { - int length = SBYTES (newtext); + EMACS_INT length = SBYTES (newtext); unsigned char *substed; - int substed_alloc_size, substed_len; + EMACS_INT substed_alloc_size, substed_len; int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); int str_multibyte = STRING_MULTIBYTE (newtext); Lisp_Object rev_tbl; @@ -2736,8 +2665,8 @@ since only regular expressions have distinguished subexpressions. */) for (pos_byte = 0, pos = 0; pos_byte < length;) { unsigned char str[MAX_MULTIBYTE_LENGTH]; - unsigned char *add_stuff = NULL; - int add_len = 0; + const unsigned char *add_stuff = NULL; + EMACS_INT add_len = 0; int idx = -1; if (str_multibyte) @@ -2822,7 +2751,7 @@ since only regular expressions have distinguished subexpressions. */) /* Now add to the end of SUBSTED. */ if (add_stuff) { - bcopy (add_stuff, substed + substed_len, add_len); + memcpy (substed + substed_len, add_stuff, add_len); substed_len += add_len; } } @@ -2831,7 +2760,8 @@ since only regular expressions have distinguished subexpressions. */) { if (buf_multibyte) { - int nchars = multibyte_chars_in_text (substed, substed_len); + EMACS_INT nchars = + multibyte_chars_in_text (substed, substed_len); newtext = make_multibyte_string (substed, nchars, substed_len); } @@ -2886,9 +2816,7 @@ since only regular expressions have distinguished subexpressions. */) } static Lisp_Object -match_limit (num, beginningp) - Lisp_Object num; - int beginningp; +match_limit (Lisp_Object num, int beginningp) { register int n; @@ -2912,8 +2840,7 @@ SUBEXP, a number, specifies which parenthesized expression in the last Value is nil if SUBEXPth pair didn't match, or there were less than SUBEXP pairs. Zero means the entire text matched by the whole regexp or whole string. */) - (subexp) - Lisp_Object subexp; + (Lisp_Object subexp) { return match_limit (subexp, 1); } @@ -2925,8 +2852,7 @@ SUBEXP, a number, specifies which parenthesized expression in the last Value is nil if SUBEXPth pair didn't match, or there were less than SUBEXP pairs. Zero means the entire text matched by the whole regexp or whole string. */) - (subexp) - Lisp_Object subexp; + (Lisp_Object subexp) { return match_limit (subexp, 0); } @@ -2951,8 +2877,7 @@ If optional third arg RESEAT is non-nil, any previous markers on the REUSE list will be modified to point to nowhere. Return value is undefined if the last search failed. */) - (integers, reuse, reseat) - Lisp_Object integers, reuse, reseat; + (Lisp_Object integers, Lisp_Object reuse, Lisp_Object reseat) { Lisp_Object tail, prev; Lisp_Object *data; @@ -3052,8 +2977,7 @@ DEFUN ("set-match-data", Fset_match_data, Sset_match_data, 1, 2, 0, LIST should have been created by calling `match-data' previously. If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) - (list, reseat) - register Lisp_Object list, reseat; + (register Lisp_Object list, Lisp_Object reseat) { register int i; register Lisp_Object marker; @@ -3171,7 +3095,7 @@ static Lisp_Object saved_last_thing_searched; /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data if asynchronous code (filter or sentinel) is running. */ static void -save_search_regs () +save_search_regs (void) { if (!search_regs_saved) { @@ -3190,7 +3114,7 @@ save_search_regs () /* Called upon exit from filters and sentinels. */ void -restore_search_regs () +restore_search_regs (void) { if (search_regs_saved) { @@ -3209,8 +3133,7 @@ restore_search_regs () } static Lisp_Object -unwind_set_match_data (list) - Lisp_Object list; +unwind_set_match_data (Lisp_Object list) { /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */ return Fset_match_data (list, Qt); @@ -3218,7 +3141,7 @@ unwind_set_match_data (list) /* Called to unwind protect the match data. */ void -record_unwind_save_match_data () +record_unwind_save_match_data (void) { record_unwind_protect (unwind_set_match_data, Fmatch_data (Qnil, Qnil, Qnil)); @@ -3228,8 +3151,7 @@ record_unwind_save_match_data () DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, doc: /* Return a regexp string which matches exactly STRING and nothing else. */) - (string) - Lisp_Object string; + (Lisp_Object string) { register unsigned char *in, *out, *end; register unsigned char *temp; @@ -3262,7 +3184,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, } void -syms_of_search () +syms_of_search (void) { register int i; diff --git a/src/sound.c b/src/sound.c index af6daf2e268..3869f3a57ff 100644 --- a/src/sound.c +++ b/src/sound.c @@ -86,8 +86,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* BEGIN: Windows Specific Includes */ #include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <limits.h> #include <windows.h> #include <mmsystem.h> @@ -99,7 +97,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Symbols. */ -extern Lisp_Object QCfile, QCdata; Lisp_Object QCvolume, QCdevice; Lisp_Object Qsound; Lisp_Object Qplay_sound_functions; @@ -115,10 +112,12 @@ enum sound_attr SOUND_ATTR_SENTINEL }; -static void alsa_sound_perror P_ ((char *, int)) NO_RETURN; -static void sound_perror P_ ((char *)) NO_RETURN; -static void sound_warning P_ ((char *)); -static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); +#ifdef HAVE_ALSA +static void alsa_sound_perror (const char *, int) NO_RETURN; +#endif +static void sound_perror (const char *) NO_RETURN; +static void sound_warning (const char *); +static int parse_sound (Lisp_Object, Lisp_Object *); /* END: Common Definitions */ @@ -225,25 +224,25 @@ struct sound_device int channels; /* Open device SD. */ - void (* open) P_ ((struct sound_device *sd)); + void (* open) (struct sound_device *sd); /* Close device SD. */ - void (* close) P_ ((struct sound_device *sd)); + void (* close) (struct sound_device *sd); /* Configure SD accoring to device-dependent parameters. */ - void (* configure) P_ ((struct sound_device *device)); + void (* configure) (struct sound_device *device); /* Choose a device-dependent format for outputting sound S. */ - void (* choose_format) P_ ((struct sound_device *sd, - struct sound *s)); + void (* choose_format) (struct sound_device *sd, + struct sound *s); /* Return a preferred data size in bytes to be sent to write (below) each time. 2048 is used if this is NULL. */ - int (* period_size) P_ ((struct sound_device *sd)); + int (* period_size) (struct sound_device *sd); /* Write NYBTES bytes from BUFFER to device SD. */ - void (* write) P_ ((struct sound_device *sd, const char *buffer, - int nbytes)); + void (* write) (struct sound_device *sd, const char *buffer, + int nbytes); /* A place for devices to store additional data. */ void *data; @@ -279,7 +278,7 @@ struct sound Lisp_Object data; /* Play sound file S on device SD. */ - void (* play) P_ ((struct sound *s, struct sound_device *sd)); + void (* play) (struct sound *s, struct sound_device *sd); }; /* These are set during `play-sound-internal' so that sound_cleanup has @@ -290,30 +289,30 @@ struct sound *current_sound; /* Function prototypes. */ -static void vox_open P_ ((struct sound_device *)); -static void vox_configure P_ ((struct sound_device *)); -static void vox_close P_ ((struct sound_device *sd)); -static void vox_choose_format P_ ((struct sound_device *, struct sound *)); -static int vox_init P_ ((struct sound_device *)); -static void vox_write P_ ((struct sound_device *, const char *, int)); -static void find_sound_type P_ ((struct sound *)); -static u_int32_t le2hl P_ ((u_int32_t)); -static u_int16_t le2hs P_ ((u_int16_t)); -static u_int32_t be2hl P_ ((u_int32_t)); -static int wav_init P_ ((struct sound *)); -static void wav_play P_ ((struct sound *, struct sound_device *)); -static int au_init P_ ((struct sound *)); -static void au_play P_ ((struct sound *, struct sound_device *)); +static void vox_open (struct sound_device *); +static void vox_configure (struct sound_device *); +static void vox_close (struct sound_device *sd); +static void vox_choose_format (struct sound_device *, struct sound *); +static int vox_init (struct sound_device *); +static void vox_write (struct sound_device *, const char *, int); +static void find_sound_type (struct sound *); +static u_int32_t le2hl (u_int32_t); +static u_int16_t le2hs (u_int16_t); +static u_int32_t be2hl (u_int32_t); +static int wav_init (struct sound *); +static void wav_play (struct sound *, struct sound_device *); +static int au_init (struct sound *); +static void au_play (struct sound *, struct sound_device *); #if 0 /* Currently not used. */ -static u_int16_t be2hs P_ ((u_int16_t)); +static u_int16_t be2hs (u_int16_t); #endif /* END: Non Windows Definitions */ #else /* WINDOWSNT */ /* BEGIN: Windows Specific Definitions */ -static int do_play_sound P_ ((const char *, unsigned long)); +static int do_play_sound (const char *, unsigned long); /* END: Windows Specific Definitions */ #endif /* WINDOWSNT */ @@ -328,8 +327,7 @@ static int do_play_sound P_ ((const char *, unsigned long)); /* Like perror, but signals an error. */ static void -sound_perror (msg) - char *msg; +sound_perror (const char *msg) { int saved_errno = errno; @@ -347,8 +345,7 @@ sound_perror (msg) /* Display a warning message. */ static void -sound_warning (msg) - char *msg; +sound_warning (const char *msg) { message (msg); } @@ -381,9 +378,7 @@ sound_warning (msg) range [0, 1]. */ static int -parse_sound (sound, attrs) - Lisp_Object sound; - Lisp_Object *attrs; +parse_sound (Lisp_Object sound, Lisp_Object *attrs) { /* SOUND must be a list starting with the symbol `sound'. */ if (!CONSP (sound) || !EQ (XCAR (sound), Qsound)) @@ -452,8 +447,7 @@ parse_sound (sound, attrs) S is the sound file structure to fill in. */ static void -find_sound_type (s) - struct sound *s; +find_sound_type (struct sound *s) { if (!wav_init (s) && !au_init (s)) error ("Unknown sound format"); @@ -463,8 +457,7 @@ find_sound_type (s) /* Function installed by play-sound-internal with record_unwind_protect. */ static Lisp_Object -sound_cleanup (arg) - Lisp_Object arg; +sound_cleanup (Lisp_Object arg) { if (current_sound_device->close) current_sound_device->close (current_sound_device); @@ -484,10 +477,9 @@ sound_cleanup (arg) to host byte-order. */ static u_int32_t -le2hl (value) - u_int32_t value; +le2hl (u_int32_t value) { -#ifdef WORDS_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned char *p = (unsigned char *) &value; value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); #endif @@ -499,10 +491,9 @@ le2hl (value) to host byte-order. */ static u_int16_t -le2hs (value) - u_int16_t value; +le2hs (u_int16_t value) { -#ifdef WORDS_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned char *p = (unsigned char *) &value; value = p[0] + (p[1] << 8); #endif @@ -514,10 +505,9 @@ le2hs (value) to host byte-order. */ static u_int32_t -be2hl (value) - u_int32_t value; +be2hl (u_int32_t value) { -#ifndef WORDS_BIG_ENDIAN +#ifndef WORDS_BIGENDIAN unsigned char *p = (unsigned char *) &value; value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24); #endif @@ -531,10 +521,9 @@ be2hl (value) to host byte-order. */ static u_int16_t -be2hs (value) - u_int16_t value; +be2hs (u_int16_t value) { -#ifndef WORDS_BIG_ENDIAN +#ifndef WORDS_BIGENDIAN unsigned char *p = (unsigned char *) &value; value = p[1] + (p[0] << 8); #endif @@ -554,13 +543,12 @@ be2hs (value) Value is non-zero if the file is a WAV file. */ static int -wav_init (s) - struct sound *s; +wav_init (struct sound *s) { struct wav_header *header = (struct wav_header *) s->header; if (s->header_size < sizeof *header - || bcmp (s->header, "RIFF", 4) != 0) + || memcmp (s->header, "RIFF", 4) != 0) return 0; /* WAV files are in little-endian order. Convert the header @@ -590,9 +578,7 @@ wav_init (s) /* Play RIFF-WAVE audio file S on sound device SD. */ static void -wav_play (s, sd) - struct sound *s; - struct sound_device *sd; +wav_play (struct sound *s, struct sound_device *sd) { struct wav_header *header = (struct wav_header *) s->header; @@ -665,13 +651,12 @@ enum au_encoding Value is non-zero if the file is an AU file. */ static int -au_init (s) - struct sound *s; +au_init (struct sound *s) { struct au_header *header = (struct au_header *) s->header; if (s->header_size < sizeof *header - || bcmp (s->header, ".snd", 4) != 0) + || memcmp (s->header, ".snd", 4) != 0) return 0; header->magic_number = be2hl (header->magic_number); @@ -692,9 +677,7 @@ au_init (s) /* Play Sun audio file S on sound device SD. */ static void -au_play (s, sd) - struct sound *s; - struct sound_device *sd; +au_play (struct sound *s, struct sound_device *sd) { struct au_header *header = (struct au_header *) s->header; @@ -740,10 +723,9 @@ au_play (s, sd) otherwise use a default device name. */ static void -vox_open (sd) - struct sound_device *sd; +vox_open (struct sound_device *sd) { - char *file; + const char *file; /* Open the sound device. Default is /dev/dsp. */ if (sd->file) @@ -760,8 +742,7 @@ vox_open (sd) /* Configure device SD from parameters in it. */ static void -vox_configure (sd) - struct sound_device *sd; +vox_configure (struct sound_device *sd) { int val; @@ -814,8 +795,7 @@ vox_configure (sd) /* Close device SD if it is open. */ static void -vox_close (sd) - struct sound_device *sd; +vox_close (struct sound_device *sd) { if (sd->fd >= 0) { @@ -845,9 +825,7 @@ vox_close (sd) /* Choose device-dependent format for device SD from sound file S. */ static void -vox_choose_format (sd, s) - struct sound_device *sd; - struct sound *s; +vox_choose_format (struct sound_device *sd, struct sound *s) { if (s->type == RIFF) { @@ -890,10 +868,9 @@ vox_choose_format (sd, s) structure. */ static int -vox_init (sd) - struct sound_device *sd; +vox_init (struct sound_device *sd) { - char *file; + const char *file; int fd; /* Open the sound device. Default is /dev/dsp. */ @@ -921,10 +898,7 @@ vox_init (sd) /* Write NBYTES bytes from BUFFER to device SD. */ static void -vox_write (sd, buffer, nbytes) - struct sound_device *sd; - const char *buffer; - int nbytes; +vox_write (struct sound_device *sd, const char *buffer, int nbytes) { int nwritten = emacs_write (sd->fd, buffer, nbytes); if (nwritten < 0) @@ -939,9 +913,7 @@ vox_write (sd, buffer, nbytes) /* This driver is available on GNU/Linux. */ static void -alsa_sound_perror (msg, err) - char *msg; - int err; +alsa_sound_perror (const char *msg, int err) { error ("%s: %s", msg, snd_strerror (err)); } @@ -958,10 +930,9 @@ struct alsa_params otherwise use a default device name. */ static void -alsa_open (sd) - struct sound_device *sd; +alsa_open (struct sound_device *sd) { - char *file; + const char *file; struct alsa_params *p; int err; @@ -986,8 +957,7 @@ alsa_open (sd) } static int -alsa_period_size (sd) - struct sound_device *sd; +alsa_period_size (struct sound_device *sd) { struct alsa_params *p = (struct alsa_params *) sd->data; int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; @@ -995,8 +965,7 @@ alsa_period_size (sd) } static void -alsa_configure (sd) - struct sound_device *sd; +alsa_configure (struct sound_device *sd) { int val, err, dir; unsigned uval; @@ -1085,7 +1054,7 @@ alsa_configure (sd) int chn; snd_mixer_t *handle; snd_mixer_elem_t *e; - char *file = sd->file ? sd->file : DEFAULT_ALSA_SOUND_DEVICE; + const char *file = sd->file ? sd->file : DEFAULT_ALSA_SOUND_DEVICE; if (snd_mixer_open (&handle, 0) >= 0) { @@ -1115,8 +1084,7 @@ alsa_configure (sd) /* Close device SD if it is open. */ static void -alsa_close (sd) - struct sound_device *sd; +alsa_close (struct sound_device *sd) { struct alsa_params *p = (struct alsa_params *) sd->data; if (p) @@ -1137,9 +1105,7 @@ alsa_close (sd) /* Choose device-dependent format for device SD from sound file S. */ static void -alsa_choose_format (sd, s) - struct sound_device *sd; - struct sound *s; +alsa_choose_format (struct sound_device *sd, struct sound *s) { struct alsa_params *p = (struct alsa_params *) sd->data; if (s->type == RIFF) @@ -1194,10 +1160,7 @@ alsa_choose_format (sd, s) /* Write NBYTES bytes from BUFFER to device SD. */ static void -alsa_write (sd, buffer, nbytes) - struct sound_device *sd; - const char *buffer; - int nbytes; +alsa_write (struct sound_device *sd, const char *buffer, int nbytes) { struct alsa_params *p = (struct alsa_params *) sd->data; @@ -1244,12 +1207,8 @@ alsa_write (sd, buffer, nbytes) } static void -snd_error_quiet (file, line, function, err, fmt) - const char *file; - int line; - const char *function; - int err; - const char *fmt; +snd_error_quiet (const char *file, int line, const char *function, int err, + const char *fmt) { } @@ -1257,10 +1216,9 @@ snd_error_quiet (file, line, function, err, fmt) structure. */ static int -alsa_init (sd) - struct sound_device *sd; +alsa_init (struct sound_device *sd) { - char *file; + const char *file; snd_pcm_t *handle; int err; @@ -1307,9 +1265,7 @@ alsa_init (sd) } static int -do_play_sound (psz_file, ui_volume) - const char *psz_file; - unsigned long ui_volume; +do_play_sound (const char *psz_file, unsigned long ui_volume) { int i_result = 0; MCIERROR mci_error = 0; @@ -1394,8 +1350,7 @@ DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, doc: /* Play sound SOUND. Internal use only, use `play-sound' instead. */) - (sound) - Lisp_Object sound; + (Lisp_Object sound) { Lisp_Object attrs[SOUND_ATTR_SENTINEL]; int count = SPECPDL_INDEX (); @@ -1421,9 +1376,9 @@ Internal use only, use `play-sound' instead. */) file = Qnil; GCPRO2 (sound, file); current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); - bzero (current_sound_device, sizeof (struct sound_device)); + memset (current_sound_device, 0, sizeof (struct sound_device)); current_sound = (struct sound *) xmalloc (sizeof (struct sound)); - bzero (current_sound, sizeof (struct sound)); + memset (current_sound, 0, sizeof (struct sound)); record_unwind_protect (sound_cleanup, Qnil); current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); @@ -1446,7 +1401,8 @@ Internal use only, use `play-sound' instead. */) { current_sound->data = attrs[SOUND_DATA]; current_sound->header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (current_sound->data)); - bcopy (SDATA (current_sound->data), current_sound->header, current_sound->header_size); + memcpy (current_sound->header, SDATA (current_sound->data), + current_sound->header_size); } /* Find out the type of sound. Give up if we can't tell. */ @@ -1524,7 +1480,7 @@ Internal use only, use `play-sound' instead. */) ***********************************************************************/ void -syms_of_sound () +syms_of_sound (void) { QCdevice = intern_c_string(":device"); staticpro (&QCdevice); @@ -1540,7 +1496,7 @@ syms_of_sound () void -init_sound () +init_sound (void) { } diff --git a/src/strftime.c b/src/strftime.c index 7a9506e55d3..a7617427793 100644 --- a/src/strftime.c +++ b/src/strftime.c @@ -131,14 +131,6 @@ extern char *tzname[]; # endif #endif -#ifndef __P -# if defined __GNUC__ || (defined __STDC__ && __STDC__) || defined (PROTOTYPES) -# define __P(args) args -# else -# define __P(args) () -# endif /* GCC. */ -#endif /* Not __P. */ - #ifndef PTR # ifdef __STDC__ # define PTR void * @@ -187,7 +179,7 @@ extern char *tzname[]; Similarly for localtime_r. */ # if ! HAVE_TM_GMTOFF -static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *)); +static struct tm *my_strftime_gmtime_r (const time_t *, struct tm *); static struct tm * my_strftime_gmtime_r (t, tp) const time_t *t; @@ -200,7 +192,7 @@ my_strftime_gmtime_r (t, tp) return tp; } -static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *)); +static struct tm *my_strftime_localtime_r (const time_t *, struct tm *); static struct tm * my_strftime_localtime_r (t, tp) const time_t *t; @@ -371,8 +363,8 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ more reliable way to accept other sets of digits. */ #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) -static CHAR_T *memcpy_lowcase __P ((CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO)); +static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO); static CHAR_T * memcpy_lowcase (dest, src, len LOCALE_PARAM) @@ -386,8 +378,8 @@ memcpy_lowcase (dest, src, len LOCALE_PARAM) return dest; } -static CHAR_T *memcpy_uppcase __P ((CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO)); +static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO); static CHAR_T * memcpy_uppcase (dest, src, len LOCALE_PARAM) @@ -406,7 +398,7 @@ memcpy_uppcase (dest, src, len LOCALE_PARAM) /* Yield the difference between *A and *B, measured in seconds, ignoring leap seconds. */ # define tm_diff ftime_tm_diff -static int tm_diff __P ((const struct tm *, const struct tm *)); +static int tm_diff (const struct tm *, const struct tm *); static int tm_diff (a, b) const struct tm *a; @@ -440,7 +432,7 @@ tm_diff (a, b) #define ISO_WEEK_START_WDAY 1 /* Monday */ #define ISO_WEEK1_WDAY 4 /* Thursday */ #define YDAY_MINIMUM (-366) -static int iso_week_days __P ((int, int)); +static int iso_week_days (int, int); #ifdef __GNUC__ __inline__ #endif @@ -499,8 +491,8 @@ static CHAR_T const month_name[][10] = #if !defined _LIBC && !defined(WINDOWSNT) && HAVE_TZNAME && HAVE_TZSET /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. Work around this bug by copying *tp before it might be munged. */ - size_t _strftime_copytm __P ((char *, size_t, const char *, - const struct tm * extra_args_spec_iso)); + size_t _strftime_copytm (char *, size_t, const char *, + const struct tm * extra_args_spec_iso); size_t my_strftime (s, maxsize, format, tp extra_args) CHAR_T *s; diff --git a/src/syntax.c b/src/syntax.c index 4d7dd2ba7a3..2f4f5236a40 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -34,6 +34,60 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "syntax.h" #include "intervals.h" +#include "category.h" + +/* Then there are seven single-bit flags that have the following meanings: + 1. This character is the first of a two-character comment-start sequence. + 2. This character is the second of a two-character comment-start sequence. + 3. This character is the first of a two-character comment-end sequence. + 4. This character is the second of a two-character comment-end sequence. + 5. This character is a prefix, for backward-prefix-chars. + 6. The char is part of a delimiter for comments of style "b". + 7. This character is part of a nestable comment sequence. + 8. The char is part of a delimiter for comments of style "c". + Note that any two-character sequence whose first character has flag 1 + and whose second character has flag 2 will be interpreted as a comment start. + + bit 6 and 8 are used to discriminate between different comment styles. + Languages such as C++ allow two orthogonal syntax start/end pairs + and bit 6 is used to determine whether a comment-end or Scommentend + ends style a or b. Comment markers can start style a, b, c, or bc. + Style a is always the default. + For 2-char comment markers, the style b flag is only looked up on the second + char of the comment marker and on the first char of the comment ender. + For style c (like to for the nested flag), the flag can be placed on any + one of the chars. + */ + +/* These macros extract specific flags from an integer + that holds the syntax code and the flags. */ + +#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) + +#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) + +#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) + +#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) + +#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) + +#define SYNTAX_FLAGS_COMMENT_STYLEB(flags) (((flags) >> 21) & 1) +#define SYNTAX_FLAGS_COMMENT_STYLEC(flags) (((flags) >> 22) & 2) +/* FLAGS should be the flags of the main char of the comment marker, e.g. + the second for comstart and the first for comend. */ +#define SYNTAX_FLAGS_COMMENT_STYLE(flags, other_flags) \ + (SYNTAX_FLAGS_COMMENT_STYLEB (flags) \ + | SYNTAX_FLAGS_COMMENT_STYLEC (flags) \ + | SYNTAX_FLAGS_COMMENT_STYLEC (other_flags)) + +#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) + +/* These macros extract a particular flag for a given character. */ + +#define SYNTAX_COMEND_FIRST(c) \ + (SYNTAX_FLAGS_COMEND_FIRST (SYNTAX_WITH_FLAGS (c))) +#define SYNTAX_PREFIX(c) (SYNTAX_FLAGS_PREFIX (SYNTAX_WITH_FLAGS (c))) /* We use these constants in place for comment-style and string-ender-char to distinguish comments/strings started by @@ -41,7 +95,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define ST_COMMENT_STYLE (256 + 1) #define ST_STRING_STYLE (256 + 2) -#include "category.h" Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; @@ -98,18 +151,23 @@ static EMACS_INT find_start_begv; static int find_start_modiff; -static Lisp_Object skip_chars P_ ((int, Lisp_Object, Lisp_Object, int)); -static Lisp_Object skip_syntaxes P_ ((int, Lisp_Object, Lisp_Object)); -static Lisp_Object scan_lists P_ ((EMACS_INT, EMACS_INT, EMACS_INT, int)); -static void scan_sexps_forward P_ ((struct lisp_parse_state *, - EMACS_INT, EMACS_INT, EMACS_INT, int, - int, Lisp_Object, int)); -static int in_classes P_ ((int, Lisp_Object)); +static Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); +static Lisp_Object skip_syntaxes (int, Lisp_Object, Lisp_Object); +static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, int); +static void scan_sexps_forward (struct lisp_parse_state *, + EMACS_INT, EMACS_INT, EMACS_INT, int, + int, Lisp_Object, int); +static int in_classes (int, Lisp_Object); +/* Whether the syntax of the character C has the prefix flag set. */ +int syntax_prefix_flag_p (int c) +{ + return SYNTAX_PREFIX (c); +} struct gl_state_s gl_state; /* Global state of syntax parser. */ -INTERVAL interval_of (); +INTERVAL interval_of (int, Lisp_Object); #define INTERVALS_AT_ONCE 10 /* 1 + max-number of intervals to scan to property-change. */ @@ -127,9 +185,8 @@ INTERVAL interval_of (); start/end of OBJECT. */ void -update_syntax_table (charpos, count, init, object) - int charpos, count, init; - Lisp_Object object; +update_syntax_table (EMACS_INT charpos, int count, int init, + Lisp_Object object) { Lisp_Object tmp_table; int cnt = 0, invalidate = 1; @@ -318,8 +375,7 @@ char_quoted (EMACS_INT charpos, EMACS_INT bytepos) We assume that BYTEPOS is not at the end of the buffer. */ INLINE EMACS_INT -inc_bytepos (bytepos) - EMACS_INT bytepos; +inc_bytepos (EMACS_INT bytepos) { if (NILP (current_buffer->enable_multibyte_characters)) return bytepos + 1; @@ -332,8 +388,7 @@ inc_bytepos (bytepos) We assume that BYTEPOS is not at the start of the buffer. */ INLINE EMACS_INT -dec_bytepos (bytepos) - EMACS_INT bytepos; +dec_bytepos (EMACS_INT bytepos) { if (NILP (current_buffer->enable_multibyte_characters)) return bytepos - 1; @@ -357,8 +412,7 @@ dec_bytepos (bytepos) update the global data. */ static EMACS_INT -find_defun_start (pos, pos_byte) - EMACS_INT pos, pos_byte; +find_defun_start (EMACS_INT pos, EMACS_INT pos_byte) { EMACS_INT opoint = PT, opoint_byte = PT_BYTE; @@ -385,8 +439,7 @@ find_defun_start (pos, pos_byte) /* We optimize syntax-table lookup for rare updates. Thus we accept only those `^\s(' which are good in global _and_ text-property syntax-tables. */ - gl_state.current_syntax_table = current_buffer->syntax_table; - gl_state.use_global = 0; + SETUP_BUFFER_SYNTAX_TABLE (); while (PT > BEGV) { int c; @@ -401,8 +454,7 @@ find_defun_start (pos, pos_byte) if (SYNTAX (c) == Sopen) break; /* Now fallback to the default value. */ - gl_state.current_syntax_table = current_buffer->syntax_table; - gl_state.use_global = 0; + SETUP_BUFFER_SYNTAX_TABLE (); } /* Move to beg of previous line. */ scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -2, 1); @@ -424,8 +476,7 @@ find_defun_start (pos, pos_byte) /* Return the SYNTAX_COMEND_FIRST of the character before POS, POS_BYTE. */ static int -prev_char_comend_first (pos, pos_byte) - int pos, pos_byte; +prev_char_comend_first (EMACS_INT pos, EMACS_INT pos_byte) { int c, val; @@ -467,10 +518,7 @@ prev_char_comend_first (pos, pos_byte) the returned value (or at FROM, if the search was not successful). */ static int -back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_ptr) - EMACS_INT from, from_byte, stop; - int comnested, comstyle; - EMACS_INT *charpos_ptr, *bytepos_ptr; +back_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, int comnested, int comstyle, EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr) { /* Look back, counting the parity of string-quotes, and recording the comment-starters seen. @@ -510,8 +558,8 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p that determines quote parity to the comment-end. */ while (from != stop) { - int temp_byte, prev_syntax; - int com2start, com2end; + EMACS_INT temp_byte; + int prev_syntax, com2start, com2end; int comstart; /* Move back and examine a character. */ @@ -526,7 +574,8 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p /* Check for 2-char comment markers. */ com2start = (SYNTAX_FLAGS_COMSTART_FIRST (syntax) && SYNTAX_FLAGS_COMSTART_SECOND (prev_syntax) - && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax) + && (comstyle + == SYNTAX_FLAGS_COMMENT_STYLE (prev_syntax, syntax)) && (SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax) || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested); com2end = (SYNTAX_FLAGS_COMEND_FIRST (syntax) @@ -547,7 +596,8 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p have %..\n and %{..}%. */ if (from > stop && (com2end || comstart)) { - int next = from, next_byte = from_byte, next_c, next_syntax; + EMACS_INT next = from, next_byte = from_byte; + int next_c, next_syntax; DEC_BOTH (next, next_byte); UPDATE_SYNTAX_TABLE_BACKWARD (next); next_c = FETCH_CHAR_AS_MULTIBYTE (next_byte); @@ -557,7 +607,8 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p && SYNTAX_FLAGS_COMEND_FIRST (next_syntax)) || ((com2end || comnested) && SYNTAX_FLAGS_COMSTART_SECOND (syntax) - && comstyle == SYNTAX_FLAGS_COMMENT_STYLE (syntax) + && (comstyle + == SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_syntax)) && SYNTAX_FLAGS_COMSTART_FIRST (next_syntax))) goto lossage; /* UPDATE_SYNTAX_TABLE_FORWARD (next + 1); */ @@ -577,7 +628,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p code = Scomment; /* Ignore comment starters of a different style. */ else if (code == Scomment - && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax) + && (comstyle != SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) || SYNTAX_FLAGS_COMMENT_NESTED (syntax) != comnested)) continue; @@ -627,7 +678,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p break; case Sendcomment: - if (SYNTAX_FLAGS_COMMENT_STYLE (syntax) == comstyle + if (SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == comstyle && ((com2end && SYNTAX_FLAGS_COMMENT_NESTED (prev_syntax)) || SYNTAX_FLAGS_COMMENT_NESTED (syntax)) == comnested) /* This is the same style of comment ender as ours. */ @@ -735,8 +786,7 @@ back_comment (from, from_byte, stop, comnested, comstyle, charpos_ptr, bytepos_p DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0, doc: /* Return t if OBJECT is a syntax table. Currently, any char-table counts as a syntax table. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (CHAR_TABLE_P (object) && EQ (XCHAR_TABLE (object)->purpose, Qsyntax_table)) @@ -745,8 +795,7 @@ Currently, any char-table counts as a syntax table. */) } static void -check_syntax_table (obj) - Lisp_Object obj; +check_syntax_table (Lisp_Object obj) { CHECK_TYPE (CHAR_TABLE_P (obj) && EQ (XCHAR_TABLE (obj)->purpose, Qsyntax_table), Qsyntax_table_p, obj); @@ -755,7 +804,7 @@ check_syntax_table (obj) DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0, doc: /* Return the current syntax table. This is the one specified by the current buffer. */) - () + (void) { return current_buffer->syntax_table; } @@ -764,7 +813,7 @@ DEFUN ("standard-syntax-table", Fstandard_syntax_table, Sstandard_syntax_table, 0, 0, 0, doc: /* Return the standard syntax table. This is the one used for new buffers. */) - () + (void) { return Vstandard_syntax_table; } @@ -772,8 +821,7 @@ This is the one used for new buffers. */) DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0, doc: /* Construct a new syntax table and return it. It is a copy of the TABLE, which defaults to the standard syntax table. */) - (table) - Lisp_Object table; + (Lisp_Object table) { Lisp_Object copy; @@ -799,8 +847,7 @@ It is a copy of the TABLE, which defaults to the standard syntax table. */) DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0, doc: /* Select a new syntax table for the current buffer. One argument, a syntax table. */) - (table) - Lisp_Object table; + (Lisp_Object table) { int idx; check_syntax_table (table); @@ -859,28 +906,23 @@ For example, if CHARACTER is a word constituent, the character `w' (119) is returned. The characters that correspond to various syntax codes are listed in the documentation of `modify-syntax-entry'. */) - (character) - Lisp_Object character; + (Lisp_Object character) { int char_int; - gl_state.current_syntax_table = current_buffer->syntax_table; - - gl_state.use_global = 0; - CHECK_NUMBER (character); + CHECK_CHARACTER (character); char_int = XINT (character); + SETUP_BUFFER_SYNTAX_TABLE (); return make_number (syntax_code_spec[(int) SYNTAX (char_int)]); } DEFUN ("matching-paren", Fmatching_paren, Smatching_paren, 1, 1, 0, doc: /* Return the matching parenthesis of CHARACTER, or nil if none. */) - (character) - Lisp_Object character; + (Lisp_Object character) { int char_int, code; - gl_state.current_syntax_table = current_buffer->syntax_table; - gl_state.use_global = 0; CHECK_NUMBER (character); char_int = XINT (character); + SETUP_BUFFER_SYNTAX_TABLE (); code = SYNTAX (char_int); if (code == Sopen || code == Sclose) return SYNTAX_MATCH (char_int); @@ -893,8 +935,7 @@ STRING should be a string as it is allowed as argument of `modify-syntax-entry'. Value is the equivalent cons cell \(CODE . MATCHING-CHAR) that can be used as value of a `syntax-table' text property. */) - (string) - Lisp_Object string; + (Lisp_Object string) { register const unsigned char *p; register enum syntaxcode code; @@ -954,6 +995,10 @@ text property. */) case 'n': val |= 1 << 22; break; + + case 'c': + val |= 1 << 23; + break; } if (val < XVECTOR (Vsyntax_code_object)->size && NILP (match)) @@ -993,20 +1038,20 @@ Defined flags are the characters 1, 2, 3, 4, b, p, and n. 3 means CHAR is the start of a two-char comment end sequence. 4 means CHAR is the second character of such a sequence. -There can be up to two orthogonal comment sequences. This is to support +There can be several orthogonal comment sequences. This is to support language modes such as C++. By default, all comment sequences are of style a, but you can set the comment sequence style to b (on the second character -of a comment-start, or the first character of a comment-end sequence) using -this flag: +of a comment-start, and the first character of a comment-end sequence) and/or +c (on any of its chars) using this flag: b means CHAR is part of comment sequence b. + c means CHAR is part of comment sequence c. n means CHAR is part of a nestable comment sequence. p means CHAR is a prefix character for `backward-prefix-chars'; such characters are treated as whitespace when they occur between expressions. usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */) - (c, newentry, syntax_table) - Lisp_Object c, newentry, syntax_table; + (Lisp_Object c, Lisp_Object newentry, Lisp_Object syntax_table) { if (CONSP (c)) { @@ -1039,11 +1084,12 @@ usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) */) DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, Sinternal_describe_syntax_value, 1, 1, 0, doc: /* Insert a description of the internal syntax description SYNTAX at point. */) - (syntax) - Lisp_Object syntax; + (Lisp_Object syntax) { register enum syntaxcode code; - char desc, start1, start2, end1, end2, prefix, comstyle, comnested; + int syntax_code; + char desc, start1, start2, end1, end2, prefix, + comstyleb, comstylec, comnested; char str[2]; Lisp_Object first, match_lisp, value = syntax; @@ -1074,14 +1120,16 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, return syntax; } - code = (enum syntaxcode) (XINT (first) & 0377); - start1 = (XINT (first) >> 16) & 1; - start2 = (XINT (first) >> 17) & 1; - end1 = (XINT (first) >> 18) & 1; - end2 = (XINT (first) >> 19) & 1; - prefix = (XINT (first) >> 20) & 1; - comstyle = (XINT (first) >> 21) & 1; - comnested = (XINT (first) >> 22) & 1; + syntax_code = XINT (first); + code = (enum syntaxcode) (syntax_code & 0377); + start1 = SYNTAX_FLAGS_COMSTART_FIRST (syntax_code); + start2 = SYNTAX_FLAGS_COMSTART_SECOND (syntax_code);; + end1 = SYNTAX_FLAGS_COMEND_FIRST (syntax_code); + end2 = SYNTAX_FLAGS_COMEND_SECOND (syntax_code); + prefix = SYNTAX_FLAGS_PREFIX (syntax_code); + comstyleb = SYNTAX_FLAGS_COMMENT_STYLEB (syntax_code); + comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); if ((int) code < 0 || (int) code >= (int) Smax) { @@ -1110,8 +1158,10 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, if (prefix) insert ("p", 1); - if (comstyle) + if (comstyleb) insert ("b", 1); + if (comstylec) + insert ("c", 1); if (comnested) insert ("n", 1); @@ -1171,8 +1221,10 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, insert_string (",\n\t is the first character of a comment-end sequence"); if (end2) insert_string (",\n\t is the second character of a comment-end sequence"); - if (comstyle) + if (comstyleb) insert_string (" (comment style b)"); + if (comstylec) + insert_string (" (comment style c)"); if (comnested) insert_string (" (nestable)"); @@ -1192,13 +1244,12 @@ Lisp_Object Vfind_word_boundary_function_table; If that many words cannot be found before the end of the buffer, return 0. COUNT negative means scan backward and stop at word beginning. */ -int -scan_words (from, count) - register int from, count; +EMACS_INT +scan_words (register EMACS_INT from, register EMACS_INT count) { - register int beg = BEGV; - register int end = ZV; - register int from_byte = CHAR_TO_BYTE (from); + register EMACS_INT beg = BEGV; + register EMACS_INT end = ZV; + register EMACS_INT from_byte = CHAR_TO_BYTE (from); register enum syntaxcode code; int ch0, ch1; Lisp_Object func, script, pos; @@ -1326,8 +1377,7 @@ Normally returns t. If an edge of the buffer or a field boundary is reached, point is left there and the function returns nil. Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object tmp; int orig_val, val; @@ -1350,7 +1400,7 @@ and the function returns nil. Field boundaries are not noticed if return val == orig_val ? Qt : Qnil; } -Lisp_Object skip_chars (); +Lisp_Object skip_chars (int, Lisp_Object, Lisp_Object, int); DEFUN ("skip-chars-forward", Fskip_chars_forward, Sskip_chars_forward, 1, 2, 0, doc: /* Move point forward, stopping before a char not in STRING, or at pos LIM. @@ -1362,8 +1412,7 @@ With arg "^a-zA-Z", skips nonletters stopping before first letter. Char classes, e.g. `[:alpha:]', are supported. Returns the distance traveled, either zero or positive. */) - (string, lim) - Lisp_Object string, lim; + (Lisp_Object string, Lisp_Object lim) { return skip_chars (1, string, lim, 1); } @@ -1372,8 +1421,7 @@ DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 2, doc: /* Move point backward, stopping after a char not in STRING, or at pos LIM. See `skip-chars-forward' for details. Returns the distance traveled, either zero or negative. */) - (string, lim) - Lisp_Object string, lim; + (Lisp_Object string, Lisp_Object lim) { return skip_chars (0, string, lim, 1); } @@ -1384,8 +1432,7 @@ SYNTAX is a string of syntax code characters. Stop before a char whose syntax is not in SYNTAX, or at position LIM. If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. This function returns the distance traveled, either zero or positive. */) - (syntax, lim) - Lisp_Object syntax, lim; + (Lisp_Object syntax, Lisp_Object lim) { return skip_syntaxes (1, syntax, lim); } @@ -1396,17 +1443,13 @@ SYNTAX is a string of syntax code characters. Stop on reaching a char whose syntax is not in SYNTAX, or at position LIM. If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. This function returns the distance traveled, either zero or negative. */) - (syntax, lim) - Lisp_Object syntax, lim; + (Lisp_Object syntax, Lisp_Object lim) { return skip_syntaxes (0, syntax, lim); } static Lisp_Object -skip_chars (forwardp, string, lim, handle_iso_classes) - int forwardp; - Lisp_Object string, lim; - int handle_iso_classes; +skip_chars (int forwardp, Lisp_Object string, Lisp_Object lim, int handle_iso_classes) { register unsigned int c; unsigned char fastmap[0400]; @@ -1414,14 +1457,14 @@ skip_chars (forwardp, string, lim, handle_iso_classes) int *char_ranges; int n_char_ranges = 0; int negate = 0; - register int i, i_byte; + register EMACS_INT i, i_byte; /* Set to 1 if the current buffer is multibyte and the region contains non-ASCII chars. */ int multibyte; /* Set to 1 if STRING is multibyte and it contains non-ASCII chars. */ int string_multibyte; - int size_byte; + EMACS_INT size_byte; const unsigned char *str; int len; Lisp_Object iso_classes; @@ -1444,7 +1487,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes) && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE)); string_multibyte = SBYTES (string) > SCHARS (string); - bzero (fastmap, sizeof fastmap); + memset (fastmap, 0, sizeof fastmap); str = SDATA (string); size_byte = SBYTES (string); @@ -1493,7 +1536,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes) || *class_end != ':' || class_end[1] != ']') goto not_a_class_name; - bcopy (class_beg, class_name, class_end - class_beg); + memcpy (class_name, class_beg, class_end - class_beg); class_name[class_end - class_beg] = 0; cc = re_wctype (class_name); @@ -1554,8 +1597,8 @@ skip_chars (forwardp, string, lim, handle_iso_classes) unsigned char fastmap2[0400]; int range_start_byte, range_start_char; - bcopy (fastmap2 + 0200, fastmap + 0200, 0200); - bzero (fastmap + 0200, 0200); + memcpy (fastmap + 0200, fastmap2 + 0200, 0200); + memset (fastmap + 0200, 0, 0200); /* We are sure that this loop stops. */ for (i = 0200; ! fastmap2[i]; i++); c = BYTE8_TO_CHAR (i); @@ -1615,7 +1658,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes) || *class_end != ':' || class_end[1] != ']') goto not_a_class_name_multibyte; - bcopy (class_beg, class_name, class_end - class_beg); + memcpy (class_name, class_beg, class_end - class_beg); class_name[class_end - class_beg] = 0; cc = re_wctype (class_name); @@ -1700,7 +1743,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes) if (! multibyte && n_char_ranges > 0) { - bzero (fastmap + 0200, 0200); + memset (fastmap + 0200, 0, 0200); for (i = 0; i < n_char_ranges; i += 2) { int c1 = char_ranges[i]; @@ -1733,9 +1776,9 @@ skip_chars (forwardp, string, lim, handle_iso_classes) } { - int start_point = PT; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT start_point = PT; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; unsigned char *p = PT_ADDR, *endp, *stop; if (forwardp) @@ -1755,7 +1798,7 @@ skip_chars (forwardp, string, lim, handle_iso_classes) let's initialize it manually. We ignore syntax-table text-properties for now, since that's what we've done in the past. */ - SETUP_SYNTAX_TABLE (BEGV, 0); + SETUP_BUFFER_SYNTAX_TABLE (); if (forwardp) { if (multibyte) @@ -1900,16 +1943,14 @@ skip_chars (forwardp, string, lim, handle_iso_classes) static Lisp_Object -skip_syntaxes (forwardp, string, lim) - int forwardp; - Lisp_Object string, lim; +skip_syntaxes (int forwardp, Lisp_Object string, Lisp_Object lim) { register unsigned int c; unsigned char fastmap[0400]; int negate = 0; - register int i, i_byte; + register EMACS_INT i, i_byte; int multibyte; - int size_byte; + EMACS_INT size_byte; unsigned char *str; CHECK_STRING (string); @@ -1931,7 +1972,7 @@ skip_syntaxes (forwardp, string, lim) multibyte = (!NILP (current_buffer->enable_multibyte_characters) && (XINT (lim) - PT != CHAR_TO_BYTE (XINT (lim)) - PT_BYTE)); - bzero (fastmap, sizeof fastmap); + memset (fastmap, 0, sizeof fastmap); if (SBYTES (string) > SCHARS (string)) /* As this is very rare case (syntax spec is ASCII only), don't @@ -1962,9 +2003,9 @@ skip_syntaxes (forwardp, string, lim) fastmap[i] ^= 1; { - int start_point = PT; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT start_point = PT; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; unsigned char *p = PT_ADDR, *endp, *stop; if (forwardp) @@ -2075,9 +2116,7 @@ skip_syntaxes (forwardp, string, lim) integer which is its type according to re_wctype. */ static int -in_classes (c, iso_classes) - int c; - Lisp_Object iso_classes; +in_classes (int c, Lisp_Object iso_classes) { int fits_class = 0; @@ -2099,7 +2138,7 @@ in_classes (c, iso_classes) FROM_BYTE is the bytepos corresponding to FROM. Do not move past STOP (a charpos). The comment over which we have to jump is of style STYLE - (either SYNTAX_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). + (either SYNTAX_FLAGS_COMMENT_STYLE(foo) or ST_COMMENT_STYLE). NESTING should be positive to indicate the nesting at the beginning for nested comments and should be zero or negative else. ST_COMMENT_STYLE cannot be nested. @@ -2119,16 +2158,14 @@ in_classes (c, iso_classes) remains valid for forward search starting at the returned position. */ static int -forw_comment (from, from_byte, stop, nesting, style, prev_syntax, - charpos_ptr, bytepos_ptr, incomment_ptr) - EMACS_INT from, from_byte, stop; - int nesting, style, prev_syntax; - EMACS_INT *charpos_ptr, *bytepos_ptr; - int *incomment_ptr; +forw_comment (EMACS_INT from, EMACS_INT from_byte, EMACS_INT stop, + int nesting, int style, int prev_syntax, + EMACS_INT *charpos_ptr, EMACS_INT *bytepos_ptr, + int *incomment_ptr) { register int c, c1; register enum syntaxcode code; - register int syntax; + register int syntax, other_syntax; if (nesting <= 0) nesting = -1; @@ -2150,7 +2187,7 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, syntax = SYNTAX_WITH_FLAGS (c); code = syntax & 0xff; if (code == Sendcomment - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? (nesting > 0 && --nesting == 0) : nesting < 0)) /* we have encountered a comment end of the same style @@ -2166,7 +2203,7 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, if (nesting > 0 && code == Scomment && SYNTAX_FLAGS_COMMENT_NESTED (syntax) - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style) + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style) /* we have encountered a nested comment of the same style as the comment sequence which began this comment section */ nesting++; @@ -2175,11 +2212,13 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, forw_incomment: if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax) - && SYNTAX_FLAGS_COMMENT_STYLE (syntax) == style && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMEND_SECOND (c1)) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMEND_SECOND (other_syntax)) + && SYNTAX_FLAGS_COMMENT_STYLE (syntax, other_syntax) == style && ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) || - SYNTAX_COMMENT_NESTED (c1)) ? nesting > 0 : nesting < 0)) + SYNTAX_FLAGS_COMMENT_NESTED (other_syntax)) + ? nesting > 0 : nesting < 0)) { if (--nesting <= 0) /* we have encountered a comment end of the same style @@ -2196,10 +2235,11 @@ forw_comment (from, from_byte, stop, nesting, style, prev_syntax, && from < stop && SYNTAX_FLAGS_COMSTART_FIRST (syntax) && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMMENT_STYLE (c1) == style - && SYNTAX_COMSTART_SECOND (c1)) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax) == style + && SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) || - SYNTAX_COMMENT_NESTED (c1))) + SYNTAX_FLAGS_COMMENT_NESTED (other_syntax))) /* we have encountered a nested comment of the same style as the comment sequence which began this comment section */ @@ -2221,8 +2261,7 @@ Stop scanning if we find something other than a comment or whitespace. Set point to where scanning stops. If COUNT comments are found as expected, with nothing except whitespace between them, return t; otherwise return nil. */) - (count) - Lisp_Object count; + (Lisp_Object count) { register EMACS_INT from; EMACS_INT from_byte; @@ -2251,7 +2290,7 @@ between them, return t; otherwise return nil. */) { do { - int comstart_first; + int comstart_first, syntax, other_syntax; if (from == stop) { @@ -2260,15 +2299,17 @@ between them, return t; otherwise return nil. */) return Qnil; } c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX (c); - comstart_first = SYNTAX_COMSTART_FIRST (c); - comnested = SYNTAX_COMMENT_NESTED (c); - comstyle = SYNTAX_COMMENT_STYLE (c); + comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); if (from < stop && comstart_first && (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMSTART_SECOND (c1))) + other_syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMSTART_SECOND (other_syntax))) { /* We have encountered a comment start sequence and we are ignoring all text inside comments. We must record @@ -2276,8 +2317,9 @@ between them, return t; otherwise return nil. */) only a comment end of the same style actually ends the comment section. */ code = Scomment; - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); } @@ -2313,7 +2355,7 @@ between them, return t; otherwise return nil. */) { while (1) { - int quoted; + int quoted, syntax; if (from <= stop) { @@ -2326,15 +2368,17 @@ between them, return t; otherwise return nil. */) /* char_quoted does UPDATE_SYNTAX_TABLE_BACKWARD (from). */ quoted = char_quoted (from, from_byte); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX (c); comstyle = 0; - comnested = SYNTAX_COMMENT_NESTED (c); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); if (code == Sendcomment) - comstyle = SYNTAX_COMMENT_STYLE (c); - if (from > stop && SYNTAX_COMEND_SECOND (c) + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) && prev_char_comend_first (from, from_byte) && !char_quoted (from - 1, dec_bytepos (from_byte))) { + int other_syntax; /* We must record the comment style encountered so that later, we can match only the proper comment begin sequence of the same style. */ @@ -2343,14 +2387,17 @@ between them, return t; otherwise return nil. */) /* Calling char_quoted, above, set up global syntax position at the new value of FROM. */ c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + other_syntax = SYNTAX_WITH_FLAGS (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); } if (code == Scomment_fence) { /* Skip until first preceding unquoted comment_fence. */ - int found = 0, ini = from, ini_byte = from_byte; + int found = 0; + EMACS_INT ini = from, ini_byte = from_byte; while (1) { @@ -2391,7 +2438,7 @@ between them, return t; otherwise return nil. */) { /* Failure: we should go back to the end of this not-quite-endcomment. */ - if (SYNTAX(c) != code) + if (SYNTAX (c) != code) /* It was a two-char Sendcomment. */ INC_BOTH (from, from_byte); goto leave; @@ -2430,10 +2477,7 @@ between them, return t; otherwise return nil. */) ? SYNTAX (c) : Ssymbol) static Lisp_Object -scan_lists (from, count, depth, sexpflag) - register EMACS_INT from; - EMACS_INT count, depth; - int sexpflag; +scan_lists (register EMACS_INT from, EMACS_INT count, EMACS_INT depth, int sexpflag) { Lisp_Object val; register EMACS_INT stop = count > 0 ? ZV : BEGV; @@ -2468,21 +2512,23 @@ scan_lists (from, count, depth, sexpflag) { while (from < stop) { - int comstart_first, prefix; + int comstart_first, prefix, syntax, other_syntax; UPDATE_SYNTAX_TABLE_FORWARD (from); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax = SYNTAX_WITH_FLAGS (c); code = SYNTAX_WITH_MULTIBYTE_CHECK (c); - comstart_first = SYNTAX_COMSTART_FIRST (c); - comnested = SYNTAX_COMMENT_NESTED (c); - comstyle = SYNTAX_COMMENT_STYLE (c); - prefix = SYNTAX_PREFIX (c); + comstart_first = SYNTAX_FLAGS_COMSTART_FIRST (syntax); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + prefix = SYNTAX_FLAGS_PREFIX (syntax); if (depth == min_depth) last_good = from; INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); if (from < stop && comstart_first && (c = FETCH_CHAR_AS_MULTIBYTE (from_byte), - SYNTAX_COMSTART_SECOND (c)) + other_syntax = SYNTAX_WITH_FLAGS (c), + SYNTAX_FLAGS_COMSTART_SECOND (other_syntax)) && parse_sexp_ignore_comments) { /* we have encountered a comment start sequence and we @@ -2491,9 +2537,9 @@ scan_lists (from, count, depth, sexpflag) only a comment end of the same style actually ends the comment section */ code = Scomment; - c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); } @@ -2637,29 +2683,34 @@ scan_lists (from, count, depth, sexpflag) { while (from > stop) { + int syntax; DEC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_BACKWARD (from); c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + syntax= SYNTAX_WITH_FLAGS (c); code = SYNTAX_WITH_MULTIBYTE_CHECK (c); if (depth == min_depth) last_good = from; comstyle = 0; - comnested = SYNTAX_COMMENT_NESTED (c); + comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax); if (code == Sendcomment) - comstyle = SYNTAX_COMMENT_STYLE (c); - if (from > stop && SYNTAX_COMEND_SECOND (c) + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); + if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) && prev_char_comend_first (from, from_byte) && parse_sexp_ignore_comments) { /* We must record the comment style encountered so that later, we can match only the proper comment begin sequence of the same style. */ + int c1, other_syntax; DEC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_BACKWARD (from); code = Sendcomment; c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); - comstyle = SYNTAX_COMMENT_STYLE (c1); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + other_syntax = SYNTAX_WITH_FLAGS (c1); + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested + = comnested || SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); } /* Quoting turns anything except a comment-ender @@ -2670,7 +2721,7 @@ scan_lists (from, count, depth, sexpflag) DEC_BOTH (from, from_byte); code = Sword; } - else if (SYNTAX_PREFIX (c)) + else if (SYNTAX_FLAGS_PREFIX (syntax)) continue; switch (SWITCH_ENUM_CAST (code)) @@ -2828,8 +2879,7 @@ Comments are ignored if `parse-sexp-ignore-comments' is non-nil. If the beginning or end of (the accessible part of) the buffer is reached and the depth is wrong, an error is signaled. If the depth is right but the count is not used up, nil is returned. */) - (from, count, depth) - Lisp_Object from, count, depth; + (Lisp_Object from, Lisp_Object count, Lisp_Object depth) { CHECK_NUMBER (from); CHECK_NUMBER (count); @@ -2849,8 +2899,7 @@ If the beginning or end of (the accessible part of) the buffer is reached in the middle of a parenthetical grouping, an error is signaled. If the beginning or end is reached between groupings but before count is used up, nil is returned. */) - (from, count) - Lisp_Object from, count; + (Lisp_Object from, Lisp_Object count) { CHECK_NUMBER (from); CHECK_NUMBER (count); @@ -2862,13 +2911,13 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, 0, 0, 0, doc: /* Move point backward over any number of chars with prefix syntax. This includes chars with "quote" or "prefix" syntax (' or p). */) - () + (void) { - int beg = BEGV; - int opoint = PT; - int opoint_byte = PT_BYTE; - int pos = PT; - int pos_byte = PT_BYTE; + EMACS_INT beg = BEGV; + EMACS_INT opoint = PT; + EMACS_INT opoint_byte = PT_BYTE; + EMACS_INT pos = PT; + EMACS_INT pos_byte = PT_BYTE; int c; if (pos <= beg) @@ -2908,14 +2957,10 @@ This includes chars with "quote" or "prefix" syntax (' or p). */) after the beginning of a string, or after the end of a string. */ static void -scan_sexps_forward (stateptr, from, from_byte, end, targetdepth, - stopbefore, oldstate, commentstop) - struct lisp_parse_state *stateptr; - register EMACS_INT from; - EMACS_INT from_byte, end; - int targetdepth, stopbefore; - Lisp_Object oldstate; - int commentstop; +scan_sexps_forward (struct lisp_parse_state *stateptr, + EMACS_INT from, EMACS_INT from_byte, EMACS_INT end, + int targetdepth, int stopbefore, + Lisp_Object oldstate, int commentstop) { struct lisp_parse_state state; @@ -3000,8 +3045,11 @@ do { prev_from = from; \ oldstate = Fcdr (oldstate); oldstate = Fcdr (oldstate); tem = Fcar (oldstate); - state.comstyle = NILP (tem) ? 0 : (EQ (tem, Qsyntax_table) - ? ST_COMMENT_STYLE : 1); + state.comstyle = (NILP (tem) + ? 0 + : (EQ (tem, Qsyntax_table) + ? ST_COMMENT_STYLE + : INTEGERP (tem) ? XINT (tem) : 1)); oldstate = Fcdr (oldstate); tem = Fcar (oldstate); @@ -3046,22 +3094,25 @@ do { prev_from = from; \ while (from < end) { + int syntax; INC_FROM; code = prev_from_syntax & 0xff; if (from < end && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) && (c1 = FETCH_CHAR (from_byte), - SYNTAX_COMSTART_SECOND (c1))) + syntax = SYNTAX_WITH_FLAGS (c1), + SYNTAX_FLAGS_COMSTART_SECOND (syntax))) /* Duplicate code to avoid a complex if-expression which causes trouble for the SGI compiler. */ { /* Record the comment style we have entered so that only the comment-end sequence of the same style actually terminates the comment section. */ - state.comstyle = SYNTAX_COMMENT_STYLE (c1); + state.comstyle + = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); comnested = SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax); - comnested = comnested || SYNTAX_COMMENT_NESTED (c1); + comnested = comnested || SYNTAX_FLAGS_COMMENT_NESTED (syntax); state.incomment = comnested ? 1 : -1; state.comstr_start = prev_from; INC_FROM; @@ -3079,7 +3130,7 @@ do { prev_from = from; \ } else if (code == Scomment) { - state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax); + state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? 1 : -1); state.comstr_start = prev_from; @@ -3272,8 +3323,7 @@ Value is a list of elements describing final state of parsing: else an integer (the current comment nesting). 5. t if following a quote character. 6. the minimum paren-depth encountered during this scan. - 7. t if in a comment of style b; symbol `syntax-table' if the comment - should be terminated by a generic comment delimiter. + 7. style of comment, if any. 8. character address of start of comment or string; nil if not in one. 9. Intermediate data for continuation of parsing (subject to change). If third arg TARGETDEPTH is non-nil, parsing stops if the depth @@ -3286,8 +3336,7 @@ Fifth arg OLDSTATE is a list like what this function returns. Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. If it is symbol `syntax-table', stop after the start of a comment or a string, or after end of a comment or a string. */) - (from, to, targetdepth, stopbefore, oldstate, commentstop) - Lisp_Object from, to, targetdepth, stopbefore, oldstate, commentstop; + (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) { struct lisp_parse_state state; int target; @@ -3310,8 +3359,10 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. SET_PT (state.location); return Fcons (make_number (state.depth), - Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), - Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart), + Fcons (state.prevlevelstart < 0 + ? Qnil : make_number (state.prevlevelstart), + Fcons (state.thislevelstart < 0 + ? Qnil : make_number (state.thislevelstart), Fcons (state.instring >= 0 ? (state.instring == ST_STRING_STYLE ? Qt : make_number (state.instring)) : Qnil, @@ -3322,8 +3373,9 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. Fcons (make_number (state.mindepth), Fcons ((state.comstyle ? (state.comstyle == ST_COMMENT_STYLE - ? Qsyntax_table : Qt) : - Qnil), + ? Qsyntax_table + : make_number (state.comstyle)) + : Qnil), Fcons (((state.incomment || (state.instring >= 0)) ? make_number (state.comstr_start) @@ -3332,7 +3384,7 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. } void -init_syntax_once () +init_syntax_once (void) { register int i, c; Lisp_Object temp; @@ -3422,7 +3474,7 @@ init_syntax_once () } void -syms_of_syntax () +syms_of_syntax (void) { Qsyntax_table_p = intern_c_string ("syntax-table-p"); staticpro (&Qsyntax_table_p); diff --git a/src/syntax.h b/src/syntax.h index c36b1eb28f6..15e6c729308 100644 --- a/src/syntax.h +++ b/src/syntax.h @@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ extern Lisp_Object Qsyntax_table_p; -extern void update_syntax_table P_ ((int, int, int, Lisp_Object)); +extern void update_syntax_table (EMACS_INT, int, int, Lisp_Object); /* The standard syntax table is stored where it will automatically be used in all new buffers. */ @@ -128,56 +128,9 @@ extern Lisp_Object syntax_temp; : Qnil)) #endif -/* Then there are seven single-bit flags that have the following meanings: - 1. This character is the first of a two-character comment-start sequence. - 2. This character is the second of a two-character comment-start sequence. - 3. This character is the first of a two-character comment-end sequence. - 4. This character is the second of a two-character comment-end sequence. - 5. This character is a prefix, for backward-prefix-chars. - 6. see below - 7. This character is part of a nestable comment sequence. - Note that any two-character sequence whose first character has flag 1 - and whose second character has flag 2 will be interpreted as a comment start. - bit 6 is used to discriminate between two different comment styles. - Languages such as C++ allow two orthogonal syntax start/end pairs - and bit 6 is used to determine whether a comment-end or Scommentend - ends style a or b. Comment start sequences can start style a or b. - Style a is always the default. - */ - -/* These macros extract a particular flag for a given character. */ - -#define SYNTAX_COMSTART_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 16) & 1) - -#define SYNTAX_COMSTART_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 17) & 1) - -#define SYNTAX_COMEND_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 18) & 1) - -#define SYNTAX_COMEND_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 19) & 1) - -#define SYNTAX_PREFIX(c) ((SYNTAX_WITH_FLAGS (c) >> 20) & 1) - -#define SYNTAX_COMMENT_STYLE(c) ((SYNTAX_WITH_FLAGS (c) >> 21) & 1) - -#define SYNTAX_COMMENT_NESTED(c) ((SYNTAX_WITH_FLAGS (c) >> 22) & 1) - -/* These macros extract specific flags from an integer - that holds the syntax code and the flags. */ - -#define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) - -#define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) - -#define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) - -#define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) - -#define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) - -#define SYNTAX_FLAGS_COMMENT_STYLE(flags) (((flags) >> 21) & 1) - -#define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) +/* Whether the syntax of the character C has the prefix flag set. */ +extern int syntax_prefix_flag_p (int c); /* This array, indexed by a character, contains the syntax code which that character signifies (as a char). For example, @@ -245,6 +198,14 @@ extern char syntax_code_spec[16]; 1) \ : 0)) +/* This macro sets up the buffer-global syntax table. */ +#define SETUP_BUFFER_SYNTAX_TABLE() \ +do \ + { \ + gl_state.use_global = 0; \ + gl_state.current_syntax_table = current_buffer->syntax_table; \ + } while (0) + /* This macro should be called with FROM at the start of forward search, or after the last position of the backward search. It makes sure that the first char is picked up with correct table, so @@ -256,12 +217,11 @@ extern char syntax_code_spec[16]; #define SETUP_SYNTAX_TABLE(FROM, COUNT) \ do \ { \ + SETUP_BUFFER_SYNTAX_TABLE (); \ gl_state.b_property = BEGV; \ gl_state.e_property = ZV + 1; \ gl_state.object = Qnil; \ - gl_state.use_global = 0; \ gl_state.offset = 0; \ - gl_state.current_syntax_table = current_buffer->syntax_table; \ if (parse_sexp_lookup_properties) \ if ((COUNT) > 0 || (FROM) > BEGV) \ update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\ @@ -279,6 +239,7 @@ while (0) #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \ do \ { \ + SETUP_BUFFER_SYNTAX_TABLE (); \ gl_state.object = (OBJECT); \ if (BUFFERP (gl_state.object)) \ { \ @@ -305,8 +266,6 @@ do \ gl_state.e_property = 1 + SCHARS (gl_state.object); \ gl_state.offset = 0; \ } \ - gl_state.use_global = 0; \ - gl_state.current_syntax_table = current_buffer->syntax_table; \ if (parse_sexp_lookup_properties) \ update_syntax_table (((FROM) + gl_state.offset \ + (COUNT > 0 ? 0 : -1)), \ @@ -340,9 +299,9 @@ struct gl_state_s extern struct gl_state_s gl_state; extern int parse_sexp_lookup_properties; -extern INTERVAL interval_of P_ ((int, Lisp_Object)); +extern INTERVAL interval_of (int, Lisp_Object); -extern int scan_words P_ ((int, int)); +extern EMACS_INT scan_words (EMACS_INT, EMACS_INT); /* arch-tag: 28833cca-cd73-4741-8c85-a3111166a0e0 (do not change this comment) */ diff --git a/src/sysdep.c b/src/sysdep.c index 2f79a711cfd..f68d475d22c 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -18,10 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - #include <ctype.h> #include <signal.h> #include <stdio.h> @@ -36,20 +33,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif /* HAVE_ALLOCA_H */ #include "lisp.h" -/* Including stdlib.h isn't necessarily enough to get srandom - declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */ - -/* The w32 build defines select stuff in w32.h, which is included by - sys/select.h (included below). */ -#ifndef WINDOWSNT #include "sysselect.h" -#endif - #include "blockinput.h" #ifdef WINDOWSNT @@ -61,19 +47,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #endif /* not WINDOWSNT */ -/* Does anyone other than VMS need this? */ -#ifndef fwrite -#define sys_fwrite fwrite -#else -#undef fwrite -#endif - #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #ifdef HAVE_SETPGID -#if !defined (USG) || defined (BSD_PGRPS) +#if !defined (USG) #undef setpgrp #define setpgrp setpgid #endif @@ -89,38 +68,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "dosfns.h" #include "msdos.h" #include <sys/param.h> - -#if __DJGPP__ > 1 -extern int etext; -extern unsigned start __asm__ ("start"); -#endif -#endif - -#ifndef USE_CRT_DLL -#ifndef errno -extern int errno; -#endif #endif #include <sys/file.h> - -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif - -#ifndef MSDOS -#include <sys/ioctl.h> -#endif #include "systty.h" #include "syswait.h" -#if defined (USG) +#ifdef HAVE_SYS_UTSNAME_H #include <sys/utsname.h> #include <memory.h> -#endif /* USG */ - -extern int quit_char; +#endif /* HAVE_SYS_UTSNAME_H */ #include "keyboard.h" #include "frame.h" @@ -131,11 +90,12 @@ extern int quit_char; #include "dispextern.h" #include "process.h" #include "cm.h" /* for reset_sys_modes */ - -/* For serial_configure and serial_open. */ -extern Lisp_Object QCport, QCspeed, QCprocess; -extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; -extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; +#ifdef HAVE_TERM_H +/* Include this last. If it is ncurses header file, it adds a lot of + defines that interfere with stuff in other headers. Someone responsible + for ncurses messed up bigtime. See bug#6812. */ +#include <term.h> +#endif #ifdef WINDOWSNT #include <direct.h> @@ -163,31 +123,13 @@ struct utimbuf { #endif #endif -/* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ -#ifndef LPASS8 -#define LPASS8 0 -#endif - static const int baud_convert[] = { 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400 }; -#ifdef HAVE_SPEED_T -#include <termios.h> -#else -#if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T) -#else -#if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX) -#include <termios.h> -#endif -#endif -#endif - -int emacs_ospeed; - -void croak P_ ((char *)) NO_RETURN; +void croak (char *) NO_RETURN; /* Temporary used by `sigblock' when defined in terms of signprocmask. */ @@ -200,7 +142,7 @@ SIGMASKTYPE sigprocmask_set; Any other returned value must be freed with free. This is used only when get_current_dir_name is not defined on the system. */ char* -get_current_dir_name () +get_current_dir_name (void) { char *buf; char *pwd; @@ -272,7 +214,7 @@ get_current_dir_name () /* Discard pending input on all input descriptors. */ void -discard_tty_input () +discard_tty_input (void) { #ifndef WINDOWSNT struct emacs_tty buf; @@ -326,6 +268,8 @@ stuff_char (char c) void init_baud_rate (int fd) { + int emacs_ospeed; + if (noninteractive) emacs_ospeed = 0; else @@ -333,32 +277,11 @@ init_baud_rate (int fd) #ifdef DOS_NT emacs_ospeed = 15; #else /* not DOS_NT */ -#ifdef HAVE_TERMIOS struct termios sg; sg.c_cflag = B9600; tcgetattr (fd, &sg); emacs_ospeed = cfgetospeed (&sg); -#else /* not TERMIOS */ -#ifdef HAVE_TERMIO - struct termio sg; - - sg.c_cflag = B9600; -#ifdef HAVE_TCATTR - tcgetattr (fd, &sg); -#else - ioctl (fd, TCGETA, &sg); -#endif - emacs_ospeed = sg.c_cflag & CBAUD; -#else /* neither TERMIOS nor TERMIO */ - struct sgttyb sg; - - sg.sg_ospeed = B9600; - if (ioctl (fd, TIOCGETP, &sg) < 0) - abort (); - emacs_ospeed = sg.sg_ospeed; -#endif /* not HAVE_TERMIO */ -#endif /* not HAVE_TERMIOS */ #endif /* not DOS_NT */ } @@ -369,48 +292,23 @@ init_baud_rate (int fd) } -/*ARGSUSED*/ -void -set_exclusive_use (fd) - int fd; -{ -#ifdef FIOCLEX - ioctl (fd, FIOCLEX, 0); -#endif - /* Ok to do nothing if this feature does not exist */ -} - -#ifndef subprocesses - -wait_without_blocking () -{ -#ifdef BSD_SYSTEM - wait3 (0, WNOHANG | WUNTRACED, 0); -#else - croak ("wait_without_blocking"); -#endif - synch_process_alive = 0; -} - -#endif /* not subprocesses */ int wait_debugging; /* Set nonzero to make following function work under dbx (at least for bsd). */ SIGTYPE -wait_for_termination_signal () +wait_for_termination_signal (void) {} +#ifndef MSDOS /* Wait for subprocess with process id `pid' to terminate and make sure it will get eliminated (not remain forever as a zombie) */ void -wait_for_termination (pid) - int pid; +wait_for_termination (int pid) { while (1) { -#ifdef subprocesses #if defined (BSD_SYSTEM) || defined (HPUX) /* Note that kill returns -1 even if the process is just a zombie now. But inevitably a SIGCHLD interrupt should be generated @@ -431,7 +329,10 @@ wait_for_termination (pid) else sigpause (SIGEMPTYMASK); #else /* not BSD_SYSTEM, and not HPUX version >= 6 */ -#ifdef POSIX_SIGNALS /* would this work for GNU/Linux as well? */ +#ifdef WINDOWSNT + wait (0); + break; +#else /* not WINDOWSNT */ sigblock (sigmask (SIGCHLD)); errno = 0; if (kill (pid, 0) == -1 && errno == ESRCH) @@ -441,69 +342,20 @@ wait_for_termination (pid) } sigsuspend (&empty_mask); -#else /* not POSIX_SIGNALS */ -#ifdef HAVE_SYSV_SIGPAUSE - sighold (SIGCHLD); - if (0 > kill (pid, 0)) - { - sigrelse (SIGCHLD); - break; - } - sigpause (SIGCHLD); -#else /* not HAVE_SYSV_SIGPAUSE */ -#ifdef WINDOWSNT - wait (0); - break; -#else /* not WINDOWSNT */ - if (0 > kill (pid, 0)) - break; - /* Using sleep instead of pause avoids timing error. - If the inferior dies just before the sleep, - we lose just one second. */ - sleep (1); #endif /* not WINDOWSNT */ -#endif /* not HAVE_SYSV_SIGPAUSE */ -#endif /* not POSIX_SIGNALS */ #endif /* not BSD_SYSTEM, and not HPUX version >= 6 */ -#else /* not subprocesses */ -#if __DJGPP__ > 1 - break; -#else /* not __DJGPP__ > 1 */ - if (kill (pid, 0) < 0) - break; - wait (0); -#endif /* not __DJGPP__ > 1*/ -#endif /* not subprocesses */ } } -#ifdef subprocesses - /* * flush any pending output * (may flush input as well; it does not matter the way we use it) */ void -flush_pending_output (channel) - int channel; +flush_pending_output (int channel) { -#ifdef HAVE_TERMIOS - /* If we try this, we get hit with SIGTTIN, because - the child's tty belongs to the child's pgrp. */ -#else -#ifdef TCFLSH - ioctl (channel, TCFLSH, 1); -#else -#ifdef TIOCFLUSH - int zero = 0; - /* 3rd arg should be ignored - but some 4.2 kernels actually want the address of an int - and nonzero means something different. */ - ioctl (channel, TIOCFLUSH, &zero); -#endif -#endif -#endif + /* FIXME: maybe this function should be removed */ } /* Set up the terminal at the other end of a pseudo-terminal that @@ -512,15 +364,12 @@ flush_pending_output (channel) in Emacs. No padding needed for insertion into an Emacs buffer. */ void -child_setup_tty (out) - int out; +child_setup_tty (int out) { -#ifndef DOS_NT +#ifndef WINDOWSNT struct emacs_tty s; EMACS_GET_TTY (out, &s); - -#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) s.main.c_oflag |= OPOST; /* Enable output postprocessing */ s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ #ifdef NLDLY @@ -547,8 +396,6 @@ child_setup_tty (out) #endif s.main.c_oflag &= ~TAB3; /* Disable tab expansion */ s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ - s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ - s.main.c_cc[VEOF] = 04; /* insure that EOF is Control-D */ s.main.c_cc[VERASE] = CDISABLE; /* disable erase processing */ s.main.c_cc[VKILL] = CDISABLE; /* disable kill processing */ @@ -566,11 +413,6 @@ child_setup_tty (out) #endif /* not SIGNALS_VIA_CHARACTERS */ #ifdef AIX -/* AIX enhanced edit loses NULs, so disable it */ -#ifndef IBMR2AIX - s.main.c_line = 0; - s.main.c_iflag &= ~ASCEDIT; -#endif /* Also, PTY overloads NUL and BREAK. don't ignore break, but don't signal either, so it looks like NUL. */ s.main.c_iflag &= ~IGNBRK; @@ -578,42 +420,53 @@ child_setup_tty (out) /* rms: Formerly it set s.main.c_cc[VINTR] to 0377 here unconditionally. Then a SIGNALS_VIA_CHARACTERS conditional would force it to 0377. That looks like duplicated code. */ - s.main.c_cc[VEOL] = CDISABLE; s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ #endif /* AIX */ -#else /* not HAVE_TERMIO */ - - s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE - | CBREAK | TANDEM); - s.main.sg_flags |= LPASS8; - s.main.sg_erase = 0377; - s.main.sg_kill = 0377; - s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ - -#endif /* not HAVE_TERMIO */ + /* We originally enabled ICANON (and set VEOF to 04), and then had + proces.c send additional EOF chars to flush the output when faced + with long lines, but this leads to weird effects when the + subprocess has disabled ICANON and ends up seeing those spurious + extra EOFs. So we don't send EOFs any more in + process.c:send_process. First we tried to disable ICANON by + default, so if a subsprocess sets up ICANON, it's his problem (or + the Elisp package that talks to it) to deal with lines that are + too long. But this disables some features, such as the ability + to send EOF signals. So we re-enabled ICANON but there is no + more "send eof to flush" going on (which is wrong and unportable + in itself). The correct way to handle too much output is to + buffer what could not be written and then write it again when + select returns ok for writing. This has it own set of + problems. Write is now asynchronous, is that a problem? How much + do we buffer, and what do we do when that limit is reached? */ + + s.main.c_lflag |= ICANON; /* Enable line editing and eof processing */ + s.main.c_cc[VEOF] = 'D'&037; /* Control-D */ +#if 0 /* These settings only apply to non-ICANON mode. */ + s.main.c_cc[VMIN] = 1; + s.main.c_cc[VTIME] = 0; +#endif EMACS_SET_TTY (out, &s, 0); - -#endif /* not DOS_NT */ +#endif /* not WINDOWSNT */ } +#endif /* not MSDOS */ -#endif /* subprocesses */ /* Record a signal code and the handler for it. */ struct save_signal { int code; - SIGTYPE (*handler) P_ ((int)); + SIGTYPE (*handler) (int); }; -static void save_signal_handlers P_ ((struct save_signal *)); -static void restore_signal_handlers P_ ((struct save_signal *)); +static void save_signal_handlers (struct save_signal *); +static void restore_signal_handlers (struct save_signal *); /* Suspend the Emacs process; give terminal to its superior. */ void -sys_suspend () +sys_suspend (void) { #if defined (SIGTSTP) && !defined (MSDOS) @@ -634,7 +487,7 @@ sys_suspend () /* Fork a subshell. */ void -sys_subshell () +sys_subshell (void) { #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ int st; @@ -669,17 +522,15 @@ sys_subshell () dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); str = (unsigned char *) alloca (SCHARS (dir) + 2); len = SCHARS (dir); - bcopy (SDATA (dir), str, len); + memcpy (str, SDATA (dir), len); if (str[len - 1] != '/') str[len++] = '/'; str[len] = 0; xyzzy: #ifdef DOS_NT pid = 0; -#if __DJGPP__ > 1 save_signal_handlers (saved_handlers); synch_process_alive = 1; -#endif /* __DJGPP__ > 1 */ #else pid = vfork (); if (pid == -1) @@ -688,7 +539,7 @@ sys_subshell () if (pid == 0) { - char *sh = 0; + const char *sh = 0; #ifdef DOS_NT /* MW, Aug 1993 */ getwd (oldwd); @@ -704,9 +555,7 @@ sys_subshell () if (str) chdir ((char *) str); -#ifdef subprocesses close_process_descs (); /* Close Emacs's pipes/ptys */ -#endif #ifdef SET_EMACS_PRIORITY { @@ -751,7 +600,7 @@ sys_subshell () } /* Do this now if we did not do it before. */ -#if !defined (MSDOS) || __DJGPP__ == 1 +#ifndef MSDOS save_signal_handlers (saved_handlers); synch_process_alive = 1; #endif @@ -764,20 +613,18 @@ sys_subshell () } static void -save_signal_handlers (saved_handlers) - struct save_signal *saved_handlers; +save_signal_handlers (struct save_signal *saved_handlers) { while (saved_handlers->code) { saved_handlers->handler - = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN); + = (SIGTYPE (*) (int)) signal (saved_handlers->code, SIG_IGN); saved_handlers++; } } static void -restore_signal_handlers (saved_handlers) - struct save_signal *saved_handlers; +restore_signal_handlers (struct save_signal *saved_handlers) { while (saved_handlers->code) { @@ -814,8 +661,7 @@ unrequest_sigio (void) int old_fcntl_flags[MAXDESC]; void -init_sigio (fd) - int fd; +init_sigio (int fd) { #ifdef FASYNC old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; @@ -825,8 +671,7 @@ init_sigio (fd) } void -reset_sigio (fd) - int fd; +reset_sigio (int fd) { #ifdef FASYNC fcntl (fd, F_SETFL, old_fcntl_flags[fd]); @@ -838,7 +683,7 @@ reset_sigio (fd) /* XXX Yeah, but you need it for SIGIO, don't you? */ void -request_sigio () +request_sigio (void) { if (noninteractive) return; @@ -853,7 +698,7 @@ request_sigio () void unrequest_sigio (void) -{ +{ if (noninteractive) return; @@ -873,7 +718,7 @@ unrequest_sigio (void) #ifndef MSDOS void -request_sigio () +request_sigio (void) { if (noninteractive || read_socket_hook) return; @@ -882,7 +727,7 @@ request_sigio () } void -unrequest_sigio () +unrequest_sigio (void) { if (noninteractive || read_socket_hook) return; @@ -894,65 +739,7 @@ unrequest_sigio () #endif /* FASYNC */ #endif /* F_SETFL */ #endif /* SIGIO */ - -/* Saving and restoring the process group of Emacs's terminal. */ - -#ifdef BSD_PGRPS - -/* The process group of which Emacs was a member when it initially - started. - - If Emacs was in its own process group (i.e. inherited_pgroup == - getpid ()), then we know we're running under a shell with job - control (Emacs would never be run as part of a pipeline). - Everything is fine. - - If Emacs was not in its own process group, then we know we're - running under a shell (or a caller) that doesn't know how to - separate itself from Emacs (like sh). Emacs must be in its own - process group in order to receive SIGIO correctly. In this - situation, we put ourselves in our own pgroup, forcibly set the - tty's pgroup to our pgroup, and make sure to restore and reinstate - the tty's pgroup just like any other terminal setting. If - inherited_group was not the tty's pgroup, then we'll get a - SIGTTmumble when we try to change the tty's pgroup, and a CONT if - it goes foreground in the future, which is what should happen. - - This variable is initialized in emacs.c. */ -int inherited_pgroup; - -/* Split off the foreground process group to Emacs alone. When we are - in the foreground, but not started in our own process group, - redirect the tty device handle FD to point to our own process - group. We need to be in our own process group to receive SIGIO - properly. */ -static void -narrow_foreground_group (int fd) -{ - int me = getpid (); - - setpgrp (0, inherited_pgroup); -#if 0 - /* XXX inherited_pgroup should not be zero here, but GTK seems to - mess this up. */ - if (! inherited_pgroup) - abort (); /* Should not happen. */ -#endif - if (inherited_pgroup != me) - EMACS_SET_TTY_PGRP (fd, &me); /* XXX This only works on the controlling tty. */ - setpgrp (0, me); -} -/* Set the tty to our original foreground group. */ -static void -widen_foreground_group (int fd) -{ - if (inherited_pgroup != getpid ()) - EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); - setpgrp (0, inherited_pgroup); -} - -#endif /* BSD_PGRPS */ /* Getting and setting emacs_tty structures. */ @@ -960,43 +747,14 @@ widen_foreground_group (int fd) Return zero if all's well, or -1 if we ran into an error we couldn't deal with. */ int -emacs_get_tty (fd, settings) - int fd; - struct emacs_tty *settings; +emacs_get_tty (int fd, struct emacs_tty *settings) { /* Retrieve the primary parameters - baud rate, character size, etcetera. */ -#ifdef HAVE_TCATTR +#ifndef DOS_NT /* We have those nifty POSIX tcmumbleattr functions. */ - bzero (&settings->main, sizeof (settings->main)); + memset (&settings->main, 0, sizeof (settings->main)); if (tcgetattr (fd, &settings->main) < 0) return -1; - -#else -#ifdef HAVE_TERMIO - /* The SYSV-style interface? */ - if (ioctl (fd, TCGETA, &settings->main) < 0) - return -1; - -#else -#ifndef DOS_NT - /* I give up - I hope you have the BSD ioctls. */ - if (ioctl (fd, TIOCGETP, &settings->main) < 0) - return -1; -#endif /* not DOS_NT */ -#endif -#endif - - /* Suivant - Do we have to get struct ltchars data? */ -#ifdef HAVE_LTCHARS - if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0) - return -1; -#endif - - /* How about a struct tchars and a wordful of lmode bits? */ -#ifdef HAVE_TCHARS - if (ioctl (fd, TIOCGETC, &settings->tchars) < 0 - || ioctl (fd, TIOCLGET, &settings->lmode) < 0) - return -1; #endif /* We have survived the tempest. */ @@ -1009,13 +767,10 @@ emacs_get_tty (fd, settings) Return 0 if all went well, and -1 if anything failed. */ int -emacs_set_tty (fd, settings, flushp) - int fd; - struct emacs_tty *settings; - int flushp; +emacs_set_tty (int fd, struct emacs_tty *settings, int flushp) { /* Set the primary parameters - baud rate, character size, etcetera. */ -#ifdef HAVE_TCATTR +#ifndef DOS_NT int i; /* We have those nifty POSIX tcmumbleattr functions. William J. Smith <wjs@wiis.wang.com> writes: @@ -1037,7 +792,7 @@ emacs_set_tty (fd, settings, flushp) { struct termios new; - bzero (&new, sizeof (new)); + memset (&new, 0, sizeof (new)); /* Get the current settings, and see if they're what we asked for. */ tcgetattr (fd, &new); /* We cannot use memcmp on the whole structure here because under @@ -1053,34 +808,6 @@ emacs_set_tty (fd, settings, flushp) else continue; } - -#else -#ifdef HAVE_TERMIO - /* The SYSV-style interface? */ - if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0) - return -1; - -#else -#ifndef DOS_NT - /* I give up - I hope you have the BSD ioctls. */ - if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) - return -1; -#endif /* not DOS_NT */ - -#endif -#endif - - /* Suivant - Do we have to get struct ltchars data? */ -#ifdef HAVE_LTCHARS - if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0) - return -1; -#endif - - /* How about a struct tchars and a wordful of lmode bits? */ -#ifdef HAVE_TCHARS - if (ioctl (fd, TIOCSETC, &settings->tchars) < 0 - || ioctl (fd, TIOCLSET, &settings->lmode) < 0) - return -1; #endif /* We have survived the tempest. */ @@ -1103,13 +830,6 @@ unsigned char _sobuf[BUFSIZ+8]; char _sobuf[BUFSIZ]; #endif -#ifdef HAVE_LTCHARS -static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; -#endif -#ifdef HAVE_TCHARS -static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; -#endif - /* Initialize the terminal mode on all tty devices that are currently open. */ @@ -1124,8 +844,7 @@ init_all_sys_modes (void) /* Initialize the terminal mode on the given tty device. */ void -init_sys_modes (tty_out) - struct tty_display_info *tty_out; +init_sys_modes (struct tty_display_info *tty_out) { struct emacs_tty tty; @@ -1136,24 +855,15 @@ init_sys_modes (tty_out) if (!tty_out->output) return; /* The tty is suspended. */ - -#ifdef BSD_PGRPS -#if 0 - /* read_socket_hook is not global anymore. I think doing this - unconditionally will not cause any problems. */ - if (! read_socket_hook && EQ (Vinitial_window_system, Qnil)) -#endif - narrow_foreground_group (fileno (tty_out->input)); -#endif if (! tty_out->old_tty) tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty)); - + EMACS_GET_TTY (fileno (tty_out->input), tty_out->old_tty); tty = *tty_out->old_tty; -#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) +#if !defined (DOS_NT) XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]); tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ @@ -1206,7 +916,7 @@ init_sys_modes (tty_out) means that the interrupt and quit feature must be disabled on secondary ttys, or we would not even see the keypress. - + Note that even though emacsclient could have special code to pass SIGINT to Emacs, we should _not_ enable interrupt/quit keys for emacsclient frames. This means @@ -1224,13 +934,12 @@ init_sys_modes (tty_out) tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use of C-z */ #endif /* VSWTCH */ - -#if defined (__mips__) || defined (HAVE_TCATTR) + #ifdef VSUSP - tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ + tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off handling of C-z. */ #endif /* VSUSP */ #ifdef V_DSUSP - tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ + tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off handling of C-y. */ #endif /* V_DSUSP */ #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */ tty.main.c_cc[VDSUSP] = CDISABLE; @@ -1266,19 +975,12 @@ init_sys_modes (tty_out) tty.main.c_cc[VSTOP] = CDISABLE; #endif /* VSTOP */ } -#endif /* mips or HAVE_TCATTR */ #ifdef AIX -#ifndef IBMR2AIX - /* AIX enhanced edit loses NULs, so disable it. */ - tty.main.c_line = 0; - tty.main.c_iflag &= ~ASCEDIT; -#else tty.main.c_cc[VSTRT] = CDISABLE; tty.main.c_cc[VSTOP] = CDISABLE; tty.main.c_cc[VSUSP] = CDISABLE; tty.main.c_cc[VDSUSP] = CDISABLE; -#endif /* IBMR2AIX */ if (tty_out->flow_control) { #ifdef VSTART @@ -1295,41 +997,8 @@ init_sys_modes (tty_out) tty.main.c_iflag &= ~IGNBRK; tty.main.c_iflag &= ~BRKINT; #endif -#else /* if not HAVE_TERMIO */ -#ifndef DOS_NT - XSETINT (Vtty_erase_char, tty.main.sg_erase); - tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); - if (meta_key) - tty.main.sg_flags |= ANYP; - tty.main.sg_flags |= interrupt_input ? RAW : CBREAK; #endif /* not DOS_NT */ -#endif /* not HAVE_TERMIO */ - - /* If going to use CBREAK mode, we must request C-g to interrupt - and turn off start and stop chars, etc. If not going to use - CBREAK mode, do this anyway so as to turn off local flow - control for user coming over network on 4.2; in this case, - only t_stopc and t_startc really matter. */ -#ifndef HAVE_TERMIO -#ifdef HAVE_TCHARS - /* Note: if not using CBREAK mode, it makes no difference how we - set this */ - tty.tchars = new_tchars; - tty.tchars.t_intrc = quit_char; - if (tty_out->flow_control) - { - tty.tchars.t_startc = '\021'; - tty.tchars.t_stopc = '\023'; - } - - tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode; - -#endif /* HAVE_TCHARS */ -#endif /* not HAVE_TERMIO */ - -#ifdef HAVE_LTCHARS - tty.ltchars = new_ltchars; -#endif /* HAVE_LTCHARS */ + #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ if (!tty_out->term_initted) internal_terminal_init (); @@ -1348,7 +1017,7 @@ init_sys_modes (tty_out) if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0); #endif -#if defined (HAVE_TERMIOS) || defined (HPUX) +#if !defined (DOS_NT) #ifdef TCOON if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON); #endif @@ -1401,9 +1070,8 @@ init_sys_modes (tty_out) if (tty_out->term_initted && no_redraw_on_reenter) { - /* XXX This seems wrong on multi-tty. */ - if (display_completed) - direct_output_forward_char (0); + /* We used to call "direct_output_forward_char(0)" here, + but it's not clear why, since it may not do anything anyway. */ } else { @@ -1484,8 +1152,7 @@ get_tty_size (int fd, int *widthp, int *heightp) to HEIGHT and WIDTH. This is used mainly with ptys. */ int -set_window_size (fd, height, width) - int fd, height, width; +set_window_size (int fd, int height, int width) { #ifdef TIOCSWINSZ @@ -1533,8 +1200,7 @@ reset_all_sys_modes (void) bottom of the frame, turn off interrupt-driven I/O, etc. */ void -reset_sys_modes (tty_out) - struct tty_display_info *tty_out; +reset_sys_modes (struct tty_display_info *tty_out) { if (noninteractive) { @@ -1546,11 +1212,11 @@ reset_sys_modes (tty_out) if (!tty_out->output) return; /* The tty is suspended. */ - + /* Go to and clear the last line of the terminal. */ cmgoto (tty_out, FrameRows (tty_out) - 1, 0); - + /* Code adapted from tty_clear_end_of_line. */ if (tty_out->TS_clr_line) { @@ -1560,16 +1226,16 @@ reset_sys_modes (tty_out) { /* have to do it the hard way */ int i; tty_turn_off_insert (tty_out); - + for (i = curX (tty_out); i < FrameCols (tty_out) - 1; i++) { fputc (' ', tty_out->output); } } - + cmgoto (tty_out, FrameRows (tty_out) - 1, 0); fflush (tty_out->output); - + if (tty_out->terminal->reset_terminal_modes_hook) tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal); @@ -1602,9 +1268,6 @@ reset_sys_modes (tty_out) dos_ttcooked (); #endif -#ifdef BSD_PGRPS - widen_foreground_group (fileno (tty_out->input)); -#endif } #ifdef HAVE_PTYS @@ -1612,8 +1275,7 @@ reset_sys_modes (tty_out) /* Set up the proper status flags for use of a pty. */ void -setup_pty (fd) - int fd; +setup_pty (int fd) { /* I'm told that TOICREMOTE does not mean control chars "can't be sent" but rather that they don't have @@ -1649,83 +1311,6 @@ setup_pty (fd) } #endif /* HAVE_PTYS */ -#if !defined(CANNOT_DUMP) || !defined(SYSTEM_MALLOC) -/* Some systems that cannot dump also cannot implement these. */ - -/* - * Return the address of the start of the text segment prior to - * doing an unexec. After unexec the return value is undefined. - * See crt0.c for further explanation and _start. - * - */ - -#if !(defined (__NetBSD__) && defined (__ELF__)) -#ifndef HAVE_TEXT_START -char * -start_of_text () -{ -#ifdef TEXT_START - return ((char *) TEXT_START); -#else - extern int _start (); - return ((char *) _start); -#endif /* TEXT_START */ -} -#endif /* not HAVE_TEXT_START */ -#endif - -/* - * Return the address of the start of the data segment prior to - * doing an unexec. After unexec the return value is undefined. - * See crt0.c for further information and definition of data_start. - * - * Apparently, on BSD systems this is etext at startup. On - * USG systems (swapping) this is highly mmu dependent and - * is also dependent on whether or not the program is running - * with shared text. Generally there is a (possibly large) - * gap between end of text and start of data with shared text. - * - * On Uniplus+ systems with shared text, data starts at a - * fixed address. Each port (from a given oem) is generally - * different, and the specific value of the start of data can - * be obtained via the UniPlus+ specific "uvar" system call, - * however the method outlined in crt0.c seems to be more portable. - * - * Probably what will have to happen when a USG unexec is available, - * at least on UniPlus, is temacs will have to be made unshared so - * that text and data are contiguous. Then once loadup is complete, - * unexec will produce a shared executable where the data can be - * at the normal shared text boundary and the startofdata variable - * will be patched by unexec to the correct value. - * - */ - -#ifndef start_of_data -char * -start_of_data () -{ -#ifdef DATA_START - return ((char *) DATA_START); -#else -#ifdef ORDINARY_LINK - /* - * This is a hack. Since we're not linking crt0.c or pre_crt0.c, - * data_start isn't defined. We take the address of environ, which - * is known to live at or near the start of the system crt0.c, and - * we don't sweat the handful of bytes that might lose. - */ - extern char **environ; - - return ((char *) &environ); -#else - extern int data_start; - return ((char *) &data_start); -#endif /* ORDINARY_LINK */ -#endif /* DATA_START */ -} -#endif /* start_of_data */ -#endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ - /* init_system_name sets up the string for the Lisp function system-name to return. */ @@ -1743,7 +1328,7 @@ extern int h_errno; #endif /* TRY_AGAIN */ void -init_system_name () +init_system_name (void) { #ifndef HAVE_GETHOSTNAME struct utsname uts; @@ -1776,7 +1361,7 @@ init_system_name () #ifndef CANNOT_DUMP if (initialized) #endif /* not CANNOT_DUMP */ - if (! index (hostname, '.')) + if (! strchr (hostname, '.')) { int count; #ifdef HAVE_GETADDRINFO @@ -1784,7 +1369,7 @@ init_system_name () struct addrinfo hints; int ret; - memset (&hints, 0, sizeof(hints)); + memset (&hints, 0, sizeof (hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; @@ -1805,7 +1390,7 @@ init_system_name () while (it) { char *fqdn = it->ai_canonname; - if (fqdn && index (fqdn, '.') + if (fqdn && strchr (fqdn, '.') && strcmp (fqdn, "localhost.localdomain") != 0) break; it = it->ai_next; @@ -1841,13 +1426,13 @@ init_system_name () { char *fqdn = (char *) hp->h_name; - if (!index (fqdn, '.')) + if (!strchr (fqdn, '.')) { /* We still don't have a fully qualified domain name. Try to find one in the list of alternate names */ char **alias = hp->h_aliases; while (*alias - && (!index (*alias, '.') + && (!strchr (*alias, '.') || !strcmp (*alias, "localhost.localdomain"))) alias++; if (*alias) @@ -1868,255 +1453,13 @@ init_system_name () } } -#ifndef MSDOS -#if !defined (HAVE_SELECT) - -#include "sysselect.h" -#undef select - -#if defined (HAVE_X_WINDOWS) && !defined (HAVE_SELECT) -/* Cause explanatory error message at compile time, - since the select emulation is not good enough for X. */ -int *x = &x_windows_lose_if_no_select_system_call; -#endif - -/* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs - * Only checks read descriptors. - */ -/* How long to wait between checking fds in select */ -#define SELECT_PAUSE 1 -int select_alarmed; - -/* For longjmp'ing back to read_input_waiting. */ - -jmp_buf read_alarm_throw; - -/* Nonzero if the alarm signal should throw back to read_input_waiting. - The read_socket_hook function sets this to 1 while it is waiting. */ - -int read_alarm_should_throw; - -SIGTYPE -select_alarm () -{ - select_alarmed = 1; - signal (SIGALRM, SIG_IGN); - SIGNAL_THREAD_CHECK (SIGALRM); - if (read_alarm_should_throw) - longjmp (read_alarm_throw, 1); -} - -#ifndef WINDOWSNT -/* Only rfds are checked. */ -int -sys_select (nfds, rfds, wfds, efds, timeout) - int nfds; - SELECT_TYPE *rfds, *wfds, *efds; - EMACS_TIME *timeout; -{ - /* XXX This needs to be updated for multi-tty support. Is there - anybody who needs to emulate select these days? */ - int ravail = 0; - SELECT_TYPE orfds; - int timeoutval; - int *local_timeout; - extern int proc_buffered_char[]; -#ifndef subprocesses - int process_tick = 0, update_tick = 0; -#else - extern int process_tick, update_tick; -#endif - unsigned char buf; - -#if defined (HAVE_SELECT) && defined (HAVE_X_WINDOWS) - /* If we're using X, then the native select will work; we only need the - emulation for non-X usage. */ - if (!NILP (Vinitial_window_system)) - return select (nfds, rfds, wfds, efds, timeout); -#endif - timeoutval = timeout ? EMACS_SECS (*timeout) : 100000; - local_timeout = &timeoutval; - FD_ZERO (&orfds); - if (rfds) - { - orfds = *rfds; - FD_ZERO (rfds); - } - if (wfds) - FD_ZERO (wfds); - if (efds) - FD_ZERO (efds); - - /* If we are looking only for the terminal, with no timeout, - just read it and wait -- that's more efficient. */ - if (*local_timeout == 100000 && process_tick == update_tick - && FD_ISSET (0, &orfds)) - { - int fd; - for (fd = 1; fd < nfds; ++fd) - if (FD_ISSET (fd, &orfds)) - goto hardway; - if (! detect_input_pending ()) - read_input_waiting (); - FD_SET (0, rfds); - return 1; - } - - hardway: - /* Once a second, till the timer expires, check all the flagged read - * descriptors to see if any input is available. If there is some then - * set the corresponding bit in the return copy of rfds. - */ - while (1) - { - register int to_check, fd; - - if (rfds) - { - for (to_check = nfds, fd = 0; --to_check >= 0; fd++) - { - if (FD_ISSET (fd, &orfds)) - { - int avail = 0, status = 0; - - if (fd == 0) - avail = detect_input_pending (); /* Special keyboard handler */ - else - { -#ifdef FIONREAD - status = ioctl (fd, FIONREAD, &avail); -#else /* no FIONREAD */ - /* Hoping it will return -1 if nothing available - or 0 if all 0 chars requested are read. */ - if (proc_buffered_char[fd] >= 0) - avail = 1; - else - { - avail = read (fd, &buf, 1); - if (avail > 0) - proc_buffered_char[fd] = buf; - } -#endif /* no FIONREAD */ - } - if (status >= 0 && avail > 0) - { - FD_SET (fd, rfds); - ravail++; - } - } - } - } - if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) - break; - - turn_on_atimers (0); - signal (SIGALRM, select_alarm); - select_alarmed = 0; - alarm (SELECT_PAUSE); - - /* Wait for a SIGALRM (or maybe a SIGTINT) */ - while (select_alarmed == 0 && *local_timeout != 0 - && process_tick == update_tick) - { - /* If we are interested in terminal input, - wait by reading the terminal. - That makes instant wakeup for terminal input at least. */ - if (FD_ISSET (0, &orfds)) - { - read_input_waiting (); - if (detect_input_pending ()) - select_alarmed = 1; - } - else - pause (); - } - (*local_timeout) -= SELECT_PAUSE; - - /* Reset the old alarm if there was one. */ - turn_on_atimers (1); - - if (*local_timeout == 0) /* Stop on timer being cleared */ - break; - } - return ravail; -} -#endif /* not WINDOWSNT */ - -/* Read keyboard input into the standard buffer, - waiting for at least one character. */ - -void -read_input_waiting () -{ - /* XXX This needs to be updated for multi-tty support. Is there - anybody who needs to emulate select these days? */ - int nread, i; - extern int quit_char; - - if (read_socket_hook) - { - struct input_event hold_quit; - - EVENT_INIT (hold_quit); - hold_quit.kind = NO_EVENT; - - read_alarm_should_throw = 0; - if (! setjmp (read_alarm_throw)) - nread = (*read_socket_hook) (0, 1, &hold_quit); - else - nread = -1; - - if (hold_quit.kind != NO_EVENT) - kbd_buffer_store_event (&hold_quit); - } - else - { - struct input_event e; - char buf[3]; - nread = read (fileno (stdin), buf, 1); - EVENT_INIT (e); - - /* Scan the chars for C-g and store them in kbd_buffer. */ - e.kind = ASCII_KEYSTROKE_EVENT; - e.frame_or_window = selected_frame; - e.modifiers = 0; - for (i = 0; i < nread; i++) - { - /* Convert chars > 0177 to meta events if desired. - We do this under the same conditions that read_avail_input does. */ - if (read_socket_hook == 0) - { - /* If the user says she has a meta key, then believe her. */ - if (meta_key == 1 && (buf[i] & 0x80)) - e.modifiers = meta_modifier; - if (meta_key != 2) - buf[i] &= ~0x80; - } - - XSETINT (e.code, buf[i]); - kbd_buffer_store_event (&e); - /* Don't look at input that follows a C-g too closely. - This reduces lossage due to autorepeat on C-g. */ - if (buf[i] == quit_char) - break; - } - } -} - -#if !defined (HAVE_SELECT) -#define select sys_select -#endif - -#endif /* not HAVE_SELECT */ -#endif /* not MSDOS */ - /* POSIX signals support - DJB */ /* Anyone with POSIX signals should have ANSI C declarations */ -#ifdef POSIX_SIGNALS - sigset_t empty_mask, full_mask; +#ifndef WINDOWSNT + signal_handler_t sys_signal (int signal_number, signal_handler_t action) { @@ -2145,6 +1488,8 @@ sys_signal (int signal_number, signal_handler_t action) return (old_action.sa_handler); } +#endif /* WINDOWSNT */ + #ifndef __GNUC__ /* If we're compiling with GCC, we don't need this function, since it can be written as a macro. */ @@ -2187,7 +1532,6 @@ sys_sigsetmask (sigset_t new_mask) return (old_mask); } -#endif /* POSIX_SIGNALS */ #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST static char *my_sys_siglist[NSIG]; @@ -2198,12 +1542,10 @@ static char *my_sys_siglist[NSIG]; #endif void -init_signals () +init_signals (void) { -#ifdef POSIX_SIGNALS sigemptyset (&empty_mask); sigfillset (&full_mask); -#endif #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST if (! initialized) @@ -2406,8 +1748,7 @@ init_signals () #endif /* !RAND_BITS */ void -seed_random (arg) - long arg; +seed_random (long int arg) { #ifdef HAVE_RANDOM srandom ((unsigned int)arg); @@ -2425,7 +1766,7 @@ seed_random (arg) * This suffices even for a 64-bit architecture with a 15-bit rand. */ long -get_random () +get_random (void) { long val = random (); #if VALBITS > RAND_BITS @@ -2460,9 +1801,7 @@ strerror (errnum) #endif /* ! HAVE_STRERROR */ int -emacs_open (path, oflag, mode) - const char *path; - int oflag, mode; +emacs_open (const char *path, int oflag, int mode) { register int rtnval; @@ -2473,8 +1812,7 @@ emacs_open (path, oflag, mode) } int -emacs_close (fd) - int fd; +emacs_close (int fd) { int did_retry = 0; register int rtnval; @@ -2493,10 +1831,7 @@ emacs_close (fd) } int -emacs_read (fildes, buf, nbyte) - int fildes; - char *buf; - unsigned int nbyte; +emacs_read (int fildes, char *buf, unsigned int nbyte) { register int rtnval; @@ -2507,10 +1842,7 @@ emacs_read (fildes, buf, nbyte) } int -emacs_write (fildes, buf, nbyte) - int fildes; - const char *buf; - unsigned int nbyte; +emacs_write (int fildes, const char *buf, unsigned int nbyte) { register int rtnval, bytes_written; @@ -2571,11 +1903,10 @@ emacs_write (fildes, buf, nbyte) #ifndef HAVE_GETWD char * -getwd (pathname) - char *pathname; +getwd (char *pathname) { char *npath, *spath; - extern char *getcwd (); + extern char *getcwd (char *, size_t); BLOCK_INPUT; /* getcwd uses malloc */ spath = npath = getcwd ((char *) 0, MAXPATHLEN); @@ -2604,9 +1935,8 @@ getwd (pathname) #ifndef HAVE_RENAME -rename (from, to) - const char *from; - const char *to; +int +rename (const char *from, const char *to) { if (access (from, 0) == 0) { @@ -2626,7 +1956,8 @@ rename (from, to) /* HPUX curses library references perror, but as far as we know it won't be called. Anyway this definition will do for now. */ -perror () +void +perror (void) { } #endif /* HPUX and not HAVE_PERROR */ @@ -2639,9 +1970,8 @@ perror () * until we are, then close the unsuccessful ones. */ -dup2 (oldd, newd) - int oldd; - int newd; +int +dup2 (int oldd, int newd) { register int fd, ret; @@ -2669,17 +1999,13 @@ dup2 (oldd, newd) * Only needed when subprocesses are defined. */ -#ifdef subprocesses #ifndef HAVE_GETTIMEOFDAY #ifdef HAVE_TIMEVAL -/* ARGSUSED */ int -gettimeofday (tp, tzp) - struct timeval *tp; - struct timezone *tzp; +gettimeofday (struct timeval *tp, struct timezone *tzp) { - extern long time (); + extern long time (long); tp->tv_sec = time ((long *)0); tp->tv_usec = 0; @@ -2689,16 +2015,14 @@ gettimeofday (tp, tzp) } #endif -#endif -#endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL */ +#endif /* !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL */ /* * This function will go away as soon as all the stubs fixed. (fnf) */ void -croak (badfunc) - char *badfunc; +croak (char *badfunc) { printf ("%s not yet implemented\r\n", badfunc); reset_all_sys_modes (); @@ -2709,7 +2033,7 @@ croak (badfunc) /* Directory routines for systems that don't have them. */ -#ifdef SYSV_SYSTEM_DIR +#ifdef HAVE_DIRENT_H #include <dirent.h> @@ -2721,25 +2045,16 @@ closedir (DIR *dirp /* stream from opendir */) int rtnval; rtnval = emacs_close (dirp->dd_fd); - - /* Some systems (like Solaris) allocate the buffer and the DIR all - in one block. Why in the world are we freeing this ourselves - anyway? */ -#if ! defined (SOLARIS2) - xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ -#endif xfree ((char *) dirp); return rtnval; } #endif /* not HAVE_CLOSEDIR */ -#endif /* SYSV_SYSTEM_DIR */ +#endif /* HAVE_DIRENT_H */ int -set_file_times (filename, atime, mtime) - const char *filename; - EMACS_TIME atime, mtime; +set_file_times (const char *filename, EMACS_TIME atime, EMACS_TIME mtime) { #ifdef HAVE_UTIMES struct timeval tv[2]; @@ -2776,9 +2091,7 @@ set_file_times (filename, atime, mtime) * Make a directory. */ int -mkdir (dpath, dmode) - char *dpath; - int dmode; +mkdir (char *dpath, int dmode) { int cpid, status, fd; struct stat statbuf; @@ -2836,8 +2149,7 @@ mkdir (dpath, dmode) #ifndef HAVE_RMDIR int -rmdir (dpath) - char *dpath; +rmdir (char *dpath) { int cpid, status, fd; struct stat statbuf; @@ -2882,58 +2194,62 @@ rmdir (dpath) #endif /* !HAVE_RMDIR */ -#ifndef BSTRING - -#ifndef bzero - -void -bzero (b, length) - register char *b; - register int length; +#ifndef HAVE_MEMSET +void * +memset (void *b, int n, size_t length) { + unsigned char *p = b; while (length-- > 0) - *b++ = 0; + *p++ = n; + return b; } +#endif /* !HAVE_MEMSET */ -#endif /* no bzero */ -#endif /* BSTRING */ - -#if (!defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) -#undef bcopy - -/* Saying `void' requires a declaration, above, where bcopy is used - and that declaration causes pain for systems where bcopy is a macro. */ -bcopy (b1, b2, length) - register char *b1; - register char *b2; - register int length; +#ifndef HAVE_MEMCPY +void * +memcpy (void *b1, void *b2, size_t length) { + unsigned char *p1 = b1, *p2 = b2; while (length-- > 0) - *b2++ = *b1++; + *p1++ = *p2++; + return b1; } -#endif /* (!defined (BSTRING) && !defined (bcopy)) || defined (NEED_BCOPY) */ +#endif /* !HAVE_MEMCPY */ -#ifndef BSTRING -#ifndef bcmp +#ifndef HAVE_MEMMOVE +void * +memmove (void *b1, void *b2, size_t length) +{ + unsigned char *p1 = b1, *p2 = b2; + if (p1 < p2 || p1 >= p2 + length) + while (length-- > 0) + *p1++ = *p2++; + else + { + p1 += length; + p2 += length; + while (length-- > 0) + *--p1 = *--p2; + } + return b1; +} +#endif /* !HAVE_MEMCPY */ + +#ifndef HAVE_MEMCMP int -bcmp (b1, b2, length) /* This could be a macro! */ - register char *b1; - register char *b2; - register int length; +memcmp (void *b1, void *b2, size_t length) { + unsigned char *p1 = b1, *p2 = b2; while (length-- > 0) - if (*b1++ != *b2++) - return 1; - + if (*p1++ != *p2++) + return p1[-1] < p2[-1] ? -1 : 1; return 0; } -#endif /* no bcmp */ -#endif /* not BSTRING */ +#endif /* !HAVE_MEMCMP */ #ifndef HAVE_STRSIGNAL char * -strsignal (code) - int code; +strsignal (int code) { char *signame = 0; @@ -2947,9 +2263,10 @@ strsignal (code) } #endif /* HAVE_STRSIGNAL */ -#ifdef HAVE_TERMIOS +#ifndef DOS_NT /* For make-serial-process */ -int serial_open (char *port) +int +serial_open (char *port) { int fd = -1; @@ -2975,14 +2292,12 @@ int serial_open (char *port) return fd; } -#endif /* TERMIOS */ - -#ifdef HAVE_TERMIOS #if !defined (HAVE_CFMAKERAW) /* Workaround for targets which are missing cfmakeraw. */ /* Pasted from man page. */ -static void cfmakeraw (struct termios *termios_p) +static void +cfmakeraw (struct termios *termios_p) { termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); termios_p->c_oflag &= ~OPOST; @@ -2994,7 +2309,8 @@ static void cfmakeraw (struct termios *termios_p) #if !defined (HAVE_CFSETSPEED) /* Workaround for targets which are missing cfsetspeed. */ -static int cfsetspeed (struct termios *termios_p, speed_t vitesse) +static int +cfsetspeed (struct termios *termios_p, speed_t vitesse) { return (cfsetispeed (termios_p, vitesse) + cfsetospeed (termios_p, vitesse)); @@ -3004,7 +2320,7 @@ static int cfsetspeed (struct termios *termios_p, speed_t vitesse) /* For serial-process-configure */ void serial_configure (struct Lisp_Process *p, - Lisp_Object contact) + Lisp_Object contact) { Lisp_Object childp2 = Qnil; Lisp_Object tem = Qnil; @@ -3047,7 +2363,7 @@ serial_configure (struct Lisp_Process *p, CHECK_NUMBER (tem); if (XINT (tem) != 7 && XINT (tem) != 8) error (":bytesize must be nil (8), 7, or 8"); - summary[0] = XINT(tem) + '0'; + summary[0] = XINT (tem) + '0'; #if defined (CSIZE) && defined (CS7) && defined (CS8) attr.c_cflag &= ~CSIZE; attr.c_cflag |= ((XINT (tem) == 7) ? CS7 : CS8); @@ -3162,7 +2478,7 @@ serial_configure (struct Lisp_Process *p, p->childp = childp2; } -#endif /* TERMIOS */ +#endif /* not DOS_NT */ /* System depended enumeration of and access to system processes a-la ps(1). */ @@ -3171,7 +2487,7 @@ serial_configure (struct Lisp_Process *p, /* Process enumeration and access via /proc. */ Lisp_Object -list_system_processes () +list_system_processes (void) { Lisp_Object procdir, match, proclist, next; struct gcpro gcpro1, gcpro2; @@ -3205,7 +2521,7 @@ list_system_processes () #elif !defined (WINDOWSNT) && !defined (MSDOS) Lisp_Object -list_system_processes () +list_system_processes (void) { return Qnil; } @@ -3365,7 +2681,7 @@ system_process_attributes (Lisp_Object pid) unsigned long minflt, majflt, cminflt, cmajflt, vsize; time_t sec; unsigned usec; - EMACS_TIME tnow, tstart, tboot, telapsed,ttotal; + EMACS_TIME tnow, tstart, tboot, telapsed; double pcpu, pmem; Lisp_Object attrs = Qnil; Lisp_Object cmd_str, decoded_cmd, tem; @@ -3404,7 +2720,7 @@ system_process_attributes (Lisp_Object pid) procfn_end = fn + strlen (fn); strcpy (procfn_end, "/stat"); fd = emacs_open (fn, O_RDONLY, 0); - if (fd >= 0 && (nread = emacs_read (fd, procbuf, sizeof(procbuf) - 1)) > 0) + if (fd >= 0 && (nread = emacs_read (fd, procbuf, sizeof (procbuf) - 1)) > 0) { procbuf[nread] = '\0'; p = procbuf; @@ -3665,7 +2981,7 @@ system_process_attributes (Lisp_Object pid) strcpy (procfn_end, "/psinfo"); fd = emacs_open (fn, O_RDONLY, 0); if (fd >= 0 - && (nread = read (fd, (char*)&pinfo, sizeof(struct psinfo)) > 0)) + && (nread = read (fd, (char*)&pinfo, sizeof (struct psinfo)) > 0)) { attrs = Fcons (Fcons (Qppid, make_fixnum_or_float (pinfo.pr_ppid)), attrs); attrs = Fcons (Fcons (Qpgrp, make_fixnum_or_float (pinfo.pr_pgid)), attrs); diff --git a/src/sysselect.h b/src/sysselect.h index ddb3e91f2e3..0c90814390c 100644 --- a/src/sysselect.h +++ b/src/sysselect.h @@ -27,6 +27,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #endif +/* The w32 build defines select stuff in w32.h, which is included + where w32 needs it, but not where sysselect.h is included. The w32 + definitions in w32.h are incompatible with the below. */ +#ifndef WINDOWSNT #ifdef FD_SET #ifdef FD_SETSIZE #define MAXDESC FD_SETSIZE @@ -44,6 +48,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define FD_ISSET(n, p) (*(p) & (1 << (n))) #define FD_ZERO(p) (*(p) = 0) #endif /* no FD_SET */ +#endif /* not WINDOWSNT */ #if !defined (HAVE_SELECT) #define select sys_select diff --git a/src/syssignal.h b/src/syssignal.h index 64dacc671ce..48eb7229353 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -extern void init_signals P_ ((void)); +extern void init_signals (void); #if defined (HAVE_GTK_AND_PTHREAD) || defined (HAVE_NS) #include <pthread.h> @@ -26,12 +26,6 @@ extern void init_signals P_ ((void)); #define FORWARD_SIGNAL_TO_MAIN_THREAD #endif -#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD -extern pthread_t main_thread; -#endif - -#ifdef POSIX_SIGNALS - /* Don't #include <signal.h>. That header should always be #included before "config.h", because some configuration files (like s/hpux.h) indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file @@ -71,78 +65,20 @@ extern sigset_t sys_sigmask (); #ifndef sigsetmask #define sigsetmask(SIG) sys_sigsetmask (SIG) #endif -#define sighold(SIG) ONLY_USED_IN_BSD_4_1 -#define sigrelse(SIG) ONLY_USED_IN_BSD_4_1 #undef signal #define signal(SIG,ACT) sys_signal(SIG,ACT) /* Whether this is what all systems want or not, this is what appears to be assumed in the source, for example data.c:arith_error. */ -typedef RETSIGTYPE (*signal_handler_t) (/*int*/); +typedef RETSIGTYPE (*signal_handler_t) (int); -signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action)); -sigset_t sys_sigblock P_ ((sigset_t new_mask)); -sigset_t sys_sigunblock P_ ((sigset_t new_mask)); -sigset_t sys_sigsetmask P_ ((sigset_t new_mask)); +signal_handler_t sys_signal (int signal_number, signal_handler_t action); +sigset_t sys_sigblock (sigset_t new_mask); +sigset_t sys_sigunblock (sigset_t new_mask); +sigset_t sys_sigsetmask (sigset_t new_mask); #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG) -#else /* ! defined (POSIX_SIGNALS) */ -#ifdef USG5_4 - -extern SIGMASKTYPE sigprocmask_set; - -#ifndef sigblock -#define sigblock(sig) \ - (sigprocmask_set = SIGEMPTYMASK | (sig), \ - sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL)) -#endif - -#ifndef sigunblock -#define sigunblock(sig) \ - (sigprocmask_set = SIGFULLMASK & ~(sig), \ - sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL)) -#endif - -#else -#ifdef USG - -#ifndef sigunblock -#define sigunblock(sig) -#endif - -#else - -#ifndef sigunblock -#define sigunblock(SIG) \ -{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); } -#endif - -#endif /* ! defined (USG) */ -#endif /* ! defined (USG5_4) */ -#endif /* ! defined (POSIX_SIGNALS) */ - -#ifndef SIGMASKTYPE -#define SIGMASKTYPE int -#endif - -#ifndef SIGEMPTYMASK -#define SIGEMPTYMASK (0) -#endif - -#ifndef SIGFULLMASK -#define SIGFULLMASK (0xffffffff) -#endif - -#ifndef sigmask -#define sigmask(no) (1L << ((no) - 1)) -#endif - -#ifndef sigunblock -#define sigunblock(SIG) \ -{ SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); } -#endif - #define sigfree() sigsetmask (SIGEMPTYMASK) #if defined (SIGINFO) && defined (BROKEN_SIGINFO) @@ -150,9 +86,6 @@ extern SIGMASKTYPE sigprocmask_set; #endif #if defined (SIGIO) && defined (BROKEN_SIGIO) # undef SIGIO -# if defined (__Lynx__) -# undef SIGPOLL /* Defined as SIGIO on LynxOS */ -# endif #endif #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) #undef SIGPOLL @@ -200,10 +133,11 @@ extern SIGMASKTYPE sigprocmask_set; #ifndef HAVE_STRSIGNAL /* strsignal is in sysdep.c */ -char *strsignal (); +char *strsignal (int); #endif #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD +extern pthread_t main_thread; #define SIGNAL_THREAD_CHECK(signo) \ do { \ if (!pthread_equal (pthread_self (), main_thread)) \ diff --git a/src/systime.h b/src/systime.h index 2f8d35805a4..9f6a907a9c2 100644 --- a/src/systime.h +++ b/src/systime.h @@ -136,17 +136,20 @@ extern time_t timezone; #define EMACS_SET_SECS_USECS(time, secs, usecs) \ (EMACS_SET_SECS (time, secs), EMACS_SET_USECS (time, usecs)) -extern int set_file_times __P ((const char *, EMACS_TIME, EMACS_TIME)); +extern int set_file_times (const char *, EMACS_TIME, EMACS_TIME); /* defined in keyboard.c */ -extern void set_waiting_for_input __P ((EMACS_TIME *)); +extern void set_waiting_for_input (EMACS_TIME *); /* When lisp.h is not included Lisp_Object is not defined (this can happen when this files is used outside the src directory). Use GCPRO1 to determine if lisp.h was included. */ #ifdef GCPRO1 /* defined in dired.c */ -extern Lisp_Object make_time __P ((time_t)); +extern Lisp_Object make_time (time_t); + +/* defined in editfns.c*/ +extern int lisp_time_argument (Lisp_Object, time_t *, int *); #endif /* Compare times T1 and T2. Value is 0 if T1 and T2 are the same. diff --git a/src/systty.h b/src/systty.h index 057f58f6064..8c46411cedb 100644 --- a/src/systty.h +++ b/src/systty.h @@ -17,45 +17,21 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef HAVE_TERMIOS -#define HAVE_TCATTR -#endif - - /* Include the proper files. */ -#ifdef HAVE_TERMIO +#ifndef DOS_NT #ifndef NO_TERMIO #include <termio.h> #endif /* not NO_TERMIO */ -#ifndef INCLUDED_FCNTL -#define INCLUDED_FCNTL -#include <fcntl.h> -#endif -#else /* not HAVE_TERMIO */ -#ifdef HAVE_TERMIOS -#ifndef NO_TERMIO -#include <termio.h> -#endif #include <termios.h> -#define INCLUDED_FCNTL #include <fcntl.h> -#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ -#ifndef DOS_NT -#include <sgtty.h> #endif /* not DOS_NT */ -#endif /* not HAVE_TERMIOS */ -#endif /* not HAVE_TERMIO */ -#ifdef __GNU_LIBRARY__ +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> -#include <termios.h> #endif -#ifdef NEED_BSDTTY +#ifdef HPUX #include <sys/bsdtty.h> -#endif - -#if defined (HPUX) && defined (HAVE_PTYS) #include <sys/ptyio.h> #endif @@ -63,7 +39,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/pty.h> #endif /* AIX */ -#if (defined (POSIX) || defined (NEED_UNISTD_H)) && defined (HAVE_UNISTD_H) +#ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -81,17 +57,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef SIGIO #endif -/* On TERMIOS systems, the tcmumbleattr calls take care of these - parameters, and it's a bad idea to use them (on AIX, it makes the - tty hang for a long time). */ -#if defined (TIOCGLTC) && !defined (HAVE_TERMIOS) -#define HAVE_LTCHARS -#endif - -#if defined (TIOCGETC) && !defined (HAVE_TERMIOS) -#define HAVE_TCHARS -#endif - /* Try to establish the correct character to disable terminal functions in a system-independent manner. Note that USG (at least) define @@ -118,60 +83,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size))) #endif -#ifdef HAVE_TERMIO -#ifdef TCOUTQ -#undef EMACS_OUTQSIZE -#define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size))) -#endif -#endif - /* Manipulate a terminal's current process group. */ -/* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current - controlling process group. - - EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's +/* EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's current process group. Return -1 if there is an error. EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's current process group to *PGID. Return -1 if there is an error. */ -/* HPUX tty process group stuff doesn't work, says the anonymous voice - from the past. */ -#ifndef HPUX -#ifdef TIOCGPGRP -#define EMACS_HAVE_TTY_PGRP -#else -#ifdef HAVE_TERMIOS -#define EMACS_HAVE_TTY_PGRP -#endif /* HAVE_TERMIOS */ -#endif /* TIOCGPGRP */ -#endif /* not HPUX */ - -#ifdef EMACS_HAVE_TTY_PGRP - -#if defined (HAVE_TERMIOS) - +#ifndef DOS_NT #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd))) #define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid))) - -#else /* not HAVE_TERMIOS */ -#ifdef TIOCSPGRP - -#define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid))) -#define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid))) - -#endif /* TIOCSPGRP */ -#endif /* HAVE_TERMIOS */ - -#else /* not EMACS_SET_TTY_PGRP */ - -/* Just ignore this for now and hope for the best */ -#define EMACS_GET_TTY_PGRP(fd, pgid) 0 -#define EMACS_SET_TTY_PGRP(fd, pgif) 0 - -#endif /* not EMACS_SET_TTY_PGRP */ +#endif /* not DOS_NT */ /* EMACS_GETPGRP (arg) returns the process group of the process. */ @@ -214,32 +138,11 @@ struct emacs_tty { /* There is always one of the following elements, so there is no need for dummy get and set definitions. */ -#ifdef HAVE_TCATTR +#ifndef DOS_NT struct termios main; -#else /* not HAVE_TCATTR */ -#ifdef HAVE_TERMIO - struct termio main; -#else /* not HAVE_TERMIO */ -#ifdef DOS_NT +#else /* DOS_NT */ int main; -#else /* not DOS_NT */ - struct sgttyb main; -#endif /* not DOS_NT */ -#endif /* not HAVE_TERMIO */ -#endif /* not HAVE_TCATTR */ - -/* If we have TERMIOS, we don't need to do this - they're taken care of - by the tc*attr calls. */ -#ifndef HAVE_TERMIOS -#ifdef HAVE_LTCHARS - struct ltchars ltchars; -#endif /* HAVE_LTCHARS */ - -#ifdef HAVE_TCHARS - struct tchars tchars; - int lmode; -#endif /* HAVE_TCHARS */ -#endif /* not defined HAVE_TERMIOS */ +#endif /* DOS_NT */ }; /* Define EMACS_GET_TTY and EMACS_SET_TTY, @@ -250,15 +153,13 @@ struct emacs_tty { expression, so we moved them out to their own functions in sysdep.c. */ #define EMACS_GET_TTY(fd, p) (emacs_get_tty ((fd), (p))) #define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp))) -#ifdef P_ /* Unfortunately this file is sometimes included before lisp.h */ -extern int emacs_get_tty P_ ((int, struct emacs_tty *)); -extern int emacs_set_tty P_ ((int, struct emacs_tty *, int)); -#endif +extern int emacs_get_tty (int, struct emacs_tty *); +extern int emacs_set_tty (int, struct emacs_tty *, int); /* Define EMACS_TTY_TABS_OK. */ -#ifdef HAVE_TERMIOS +#ifndef DOS_NT #ifdef TABDLY #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) @@ -266,21 +167,9 @@ extern int emacs_set_tty P_ ((int, struct emacs_tty *, int)); #define EMACS_TTY_TABS_OK(p) 1 #endif /* not TABDLY */ -#else /* not def HAVE_TERMIOS */ -#ifdef HAVE_TERMIO - -#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) - -#else /* neither HAVE_TERMIO nor HAVE_TERMIOS */ - -#ifdef DOS_NT +#else /* DOS_NT */ #define EMACS_TTY_TABS_OK(p) 0 -#else /* not DOS_NT */ -#define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS) -#endif /* not DOS_NT */ - -#endif /* not def HAVE_TERMIO */ -#endif /* not def HAVE_TERMIOS */ +#endif /* DOS_NT */ /* arch-tag: cf4b90bc-be41-401c-be98-40619178a712 (do not change this comment) */ diff --git a/src/term.c b/src/term.c index 78bf77d9d71..4baea231de3 100644 --- a/src/term.c +++ b/src/term.c @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> #include <ctype.h> -#include <string.h> #include <errno.h> #include <sys/file.h> @@ -31,10 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #endif -#if HAVE_TERMIOS_H -#include <termios.h> /* For TIOCNOTTY. */ -#endif - #include <signal.h> #include <stdarg.h> #include <setjmp.h> @@ -66,15 +61,10 @@ static int been_here = -1; /* For now, don't try to include termcap.h. On some systems, configure finds a non-standard termcap.h that the main build won't find. */ - -#if defined HAVE_TERMCAP_H && 0 -#include <termcap.h> -#else -extern void tputs P_ ((const char *, int, int (*)(int))); -extern int tgetent P_ ((char *, const char *)); -extern int tgetflag P_ ((char *id)); -extern int tgetnum P_ ((char *id)); -#endif +extern void tputs (const char *, int, int (*)(int)); +extern int tgetent (char *, const char *); +extern int tgetflag (char *id); +extern int tgetnum (char *id); #include "cm.h" #ifdef HAVE_X_WINDOWS @@ -96,16 +86,20 @@ extern int tgetnum P_ ((char *id)); #define DEV_TTY "/dev/tty" #endif -static void tty_set_scroll_region P_ ((struct frame *f, int start, int stop)); -static void turn_on_face P_ ((struct frame *, int face_id)); -static void turn_off_face P_ ((struct frame *, int face_id)); -static void tty_show_cursor P_ ((struct tty_display_info *)); -static void tty_hide_cursor P_ ((struct tty_display_info *)); -static void tty_background_highlight P_ ((struct tty_display_info *tty)); -static void clear_tty_hooks P_ ((struct terminal *terminal)); -static void set_tty_hooks P_ ((struct terminal *terminal)); -static void dissociate_if_controlling_tty P_ ((int fd)); -static void delete_tty P_ ((struct terminal *)); +static void tty_set_scroll_region (struct frame *f, int start, int stop); +static void turn_on_face (struct frame *, int face_id); +static void turn_off_face (struct frame *, int face_id); +static void tty_show_cursor (struct tty_display_info *); +static void tty_hide_cursor (struct tty_display_info *); +static void tty_background_highlight (struct tty_display_info *tty); +static void clear_tty_hooks (struct terminal *terminal); +static void set_tty_hooks (struct terminal *terminal); +static void dissociate_if_controlling_tty (int fd); +static void delete_tty (struct terminal *); +static void maybe_fatal (int must_succeed, struct terminal *terminal, + const char *str1, const char *str2, ...) NO_RETURN; +static void vfatal (const char *str, va_list ap) NO_RETURN; + #define OUTPUT(tty, a) \ emacs_tputs ((tty), a, \ @@ -133,8 +127,6 @@ static int visible_cursor; /* Display space properties */ -extern Lisp_Object Qspace, QCalign_to, QCwidth; - /* Functions to call after suspending a tty. */ Lisp_Object Vsuspend_tty_functions; @@ -184,15 +176,15 @@ static int no_controlling_tty; static int system_uses_terminfo; -char *tparam (); +char *tparam (char *, char *, int, int, ...); -extern char *tgetstr (); +extern char *tgetstr (char *, char **); #ifdef HAVE_GPM #include <sys/fcntl.h> -static void term_clear_mouse_face (); +static void term_clear_mouse_face (void); static void term_mouse_highlight (struct frame *f, int x, int y); /* The device for which we have enabled gpm support (or NULL). */ @@ -562,10 +554,7 @@ static int encode_terminal_dst_size; sequence, and return a pointer to that byte sequence. */ unsigned char * -encode_terminal_code (src, src_len, coding) - struct glyph *src; - int src_len; - struct coding_system *coding; +encode_terminal_code (struct glyph *src, int src_len, struct coding_system *coding) { struct glyph *src_end = src + src_len; unsigned char *buf; @@ -604,7 +593,7 @@ encode_terminal_code (src, src_len, coding) if (src->u.cmp.automatic) { gstring = composition_gstring_from_id (src->u.cmp.id); - required = src->u.cmp.to + 1 - src->u.cmp.from; + required = src->slice.cmp.to + 1 - src->slice.cmp.from; } else { @@ -621,7 +610,7 @@ encode_terminal_code (src, src_len, coding) } if (src->u.cmp.automatic) - for (i = src->u.cmp.from; i <= src->u.cmp.to; i++) + for (i = src->slice.cmp.from; i <= src->slice.cmp.to; i++) { Lisp_Object g = LGSTRING_GLYPH (gstring, i); int c = LGLYPH_CHAR (g); @@ -716,7 +705,7 @@ encode_terminal_code (src, src_len, coding) } else { - unsigned char *p = SDATA (string), *pend = p + SBYTES (string); + unsigned char *p = SDATA (string); if (! STRING_MULTIBYTE (string)) string = string_to_multibyte (string); @@ -728,7 +717,7 @@ encode_terminal_code (src, src_len, coding) encode_terminal_src_size); buf = encode_terminal_src + nbytes; } - bcopy (SDATA (string), buf, SBYTES (string)); + memcpy (buf, SDATA (string), SBYTES (string)); buf += SBYTES (string); nchars += SCHARS (string); } @@ -841,10 +830,8 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) #ifdef HAVE_GPM /* Only used by GPM code. */ static void -tty_write_glyphs_with_face (f, string, len, face_id) - register struct frame *f; - register struct glyph *string; - register int len, face_id; +tty_write_glyphs_with_face (register struct frame *f, register struct glyph *string, + register int len, register int face_id) { unsigned char *conversion_buffer; struct coding_system *coding; @@ -1092,7 +1079,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n) not counting any line-dependent padding. */ int -string_cost (char *str) +string_cost (const char *str) { cost = 0; if (str) @@ -1104,7 +1091,7 @@ string_cost (char *str) counting any line-dependent padding at one line. */ static int -string_cost_one_line (char *str) +string_cost_one_line (const char *str) { cost = 0; if (str) @@ -1116,7 +1103,7 @@ string_cost_one_line (char *str) in tenths of characters. */ int -per_line_cost (char *str) +per_line_cost (const char *str) { cost = 0; if (str) @@ -1127,7 +1114,6 @@ per_line_cost (char *str) return cost; } -#ifndef old /* char_ins_del_cost[n] is cost of inserting N characters. char_ins_del_cost[-n] is cost of deleting N characters. The length of this vector is based on max_frame_cols. */ @@ -1135,7 +1121,6 @@ per_line_cost (char *str) int *char_ins_del_vector; #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_COLS ((f))]) -#endif /* ARGSUSED */ static void @@ -1235,8 +1220,8 @@ calculate_costs (struct frame *frame) = (int *) xmalloc (sizeof (int) + 2 * max_frame_cols * sizeof (int)); - bzero (char_ins_del_vector, (sizeof (int) - + 2 * max_frame_cols * sizeof (int))); + memset (char_ins_del_vector, 0, + (sizeof (int) + 2 * max_frame_cols * sizeof (int))); if (f && (!tty->TS_ins_line && !tty->TS_del_line)) @@ -1273,7 +1258,7 @@ struct fkey_table { other keys (as on the IBM PC keyboard) they get overridden. */ -static struct fkey_table keys[] = +static const struct fkey_table keys[] = { {"kh", "home"}, /* termcap */ {"kl", "left"}, /* termcap */ @@ -1369,18 +1354,17 @@ static struct fkey_table keys[] = {"!3", "S-undo"} /*shifted undo key*/ }; +#ifndef DOS_NT static char **term_get_fkeys_address; static KBOARD *term_get_fkeys_kboard; -static Lisp_Object term_get_fkeys_1 (); +static Lisp_Object term_get_fkeys_1 (void); /* Find the escape codes sent by the function keys for Vinput_decode_map. This function scans the termcap function key sequence entries, and adds entries to Vinput_decode_map for each function key it finds. */ static void -term_get_fkeys (address, kboard) - char **address; - KBOARD *kboard; +term_get_fkeys (char **address, KBOARD *kboard) { /* We run the body of the function (term_get_fkeys_1) and ignore all Lisp errors during the call. The only errors should be from Fdefine_key @@ -1390,14 +1374,13 @@ term_get_fkeys (address, kboard) function key specification, rather than giving the user an error and refusing to run at all on such a terminal. */ - extern Lisp_Object Fidentity (); term_get_fkeys_address = address; term_get_fkeys_kboard = kboard; internal_condition_case (term_get_fkeys_1, Qerror, Fidentity); } static Lisp_Object -term_get_fkeys_1 () +term_get_fkeys_1 (void) { int i; @@ -1508,24 +1491,16 @@ term_get_fkeys_1 () return Qnil; } +#endif /* not DOS_NT */ /*********************************************************************** Character Display Information ***********************************************************************/ - -/* Avoid name clash with functions defined in xterm.c */ -#ifdef static -#define append_glyph append_glyph_term -#define produce_stretch_glyph produce_stretch_glyph_term -#define append_composite_glyph append_composite_glyph_term -#define produce_composite_glyph produce_composite_glyph_term -#endif - -static void append_glyph P_ ((struct it *)); -static void produce_stretch_glyph P_ ((struct it *)); -static void append_composite_glyph P_ ((struct it *)); -static void produce_composite_glyph P_ ((struct it *)); +static void append_glyph (struct it *); +static void produce_stretch_glyph (struct it *); +static void append_composite_glyph (struct it *); +static void produce_composite_glyph (struct it *); /* Append glyphs to IT's glyph_row. Called from produce_glyphs for terminal frames if IT->glyph_row != NULL. IT->char_to_display is @@ -1534,8 +1509,7 @@ static void produce_composite_glyph P_ ((struct it *)); IT->pixel_width > 1. */ static void -append_glyph (it) - struct it *it; +append_glyph (struct it *it) { struct glyph *glyph, *end; int i; @@ -1545,6 +1519,26 @@ append_glyph (it) + it->glyph_row->used[it->area]); end = it->glyph_row->glyphs[1 + it->area]; + /* If the glyph row is reversed, we need to prepend the glyph rather + than append it. */ + if (it->glyph_row->reversed_p && it->area == TEXT_AREA) + { + struct glyph *g; + int move_by = it->pixel_width; + + /* Make room for the new glyphs. */ + if (move_by > end - glyph) /* don't overstep end of this area */ + move_by = end - glyph; + for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--) + g[move_by] = *g; + glyph = it->glyph_row->glyphs[it->area]; + end = glyph + move_by; + } + + /* BIDI Note: we put the glyphs of a "multi-pixel" character left to + right, even in the REVERSED_P case, since (a) all of its u.ch are + identical, and (b) the PADDING_P flag needs to be set for the + leftmost one, because we write to the terminal left-to-right. */ for (i = 0; i < it->pixel_width && glyph < end; ++i) @@ -1556,13 +1550,24 @@ append_glyph (it) glyph->padding_p = i > 0; glyph->charpos = CHARPOS (it->position); glyph->object = it->object; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[it->area]; ++glyph; } } - /* Produce glyphs for the display element described by IT. *IT specifies what we want to produce a glyph for (character, image, ...), and where in the glyph matrix we currently are (glyph row and hpos). @@ -1583,8 +1588,7 @@ append_glyph (it) instead they use the macro PRODUCE_GLYPHS. */ void -produce_glyphs (it) - struct it *it; +produce_glyphs (struct it *it) { /* If a hook is installed, let it do the work. */ @@ -1686,8 +1690,7 @@ produce_glyphs (it) to reach HPOS, a value in canonical character units. */ static void -produce_stretch_glyph (it) - struct it *it; +produce_stretch_glyph (struct it *it) { /* (space :width WIDTH ...) */ Lisp_Object prop, plist; @@ -1756,8 +1759,7 @@ produce_stretch_glyph (it) face. */ static void -append_composite_glyph (it) - struct it *it; +append_composite_glyph (struct it *it) { struct glyph *glyph; @@ -1765,6 +1767,17 @@ append_composite_glyph (it) glyph = it->glyph_row->glyphs[it->area] + it->glyph_row->used[it->area]; if (glyph < it->glyph_row->glyphs[1 + it->area]) { + /* If the glyph row is reversed, we need to prepend the glyph + rather than append it. */ + if (it->glyph_row->reversed_p && it->area == TEXT_AREA) + { + struct glyph *g; + + /* Make room for the new glyph. */ + for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--) + g[1] = *g; + glyph = it->glyph_row->glyphs[it->area]; + } glyph->type = COMPOSITE_GLYPH; glyph->pixel_width = it->pixel_width; glyph->u.cmp.id = it->cmp_it.id; @@ -1777,14 +1790,26 @@ append_composite_glyph (it) { glyph->u.cmp.automatic = 1; glyph->u.cmp.id = it->cmp_it.id; - glyph->u.cmp.from = it->cmp_it.from; - glyph->u.cmp.to = it->cmp_it.to - 1; + glyph->slice.cmp.from = it->cmp_it.from; + glyph->slice.cmp.to = it->cmp_it.to - 1; } glyph->face_id = it->face_id; glyph->padding_p = 0; glyph->charpos = CHARPOS (it->position); glyph->object = it->object; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[it->area]; ++glyph; @@ -1798,11 +1823,8 @@ append_composite_glyph (it) correctly. */ static void -produce_composite_glyph (it) - struct it *it; +produce_composite_glyph (struct it *it) { - int c; - if (it->cmp_it.ch < 0) { struct composition *cmp = composition_table[it->cmp_it.id]; @@ -1829,9 +1851,7 @@ produce_composite_glyph (it) face_id, c, len of IT are left untouched. */ void -produce_special_glyphs (it, what) - struct it *it; - enum display_element_type what; +produce_special_glyphs (struct it *it, enum display_element_type what) { struct it temp_it; Lisp_Object gc; @@ -1842,16 +1862,20 @@ produce_special_glyphs (it, what) temp_it.what = IT_CHARACTER; temp_it.len = 1; temp_it.object = make_number (0); - bzero (&temp_it.current, sizeof temp_it.current); + memset (&temp_it.current, 0, sizeof temp_it.current); if (what == IT_CONTINUATION) { - /* Continuation glyph. */ - SET_GLYPH_FROM_CHAR (glyph, '\\'); + /* Continuation glyph. For R2L lines, we mirror it by hand. */ + if (it->bidi_it.paragraph_dir == R2L) + SET_GLYPH_FROM_CHAR (glyph, '/'); + else + SET_GLYPH_FROM_CHAR (glyph, '\\'); if (it->dp && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc)) && GLYPH_CODE_CHAR_VALID_P (gc)) { + /* FIXME: Should we mirror GC for R2L lines? */ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc); spec_glyph_lookup_face (XWINDOW (it->window), &glyph); } @@ -1864,6 +1888,7 @@ produce_special_glyphs (it, what) && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc)) && GLYPH_CODE_CHAR_VALID_P (gc)) { + /* FIXME: Should we mirror GC for R2L lines? */ SET_GLYPH_FROM_GLYPH_CODE (glyph, gc); spec_glyph_lookup_face (XWINDOW (it->window), &glyph); } @@ -1900,9 +1925,7 @@ produce_special_glyphs (it, what) FACE_ID is a realized face ID number, in the face cache. */ static void -turn_on_face (f, face_id) - struct frame *f; - int face_id; +turn_on_face (struct frame *f, int face_id) { struct face *face = FACE_FROM_ID (f, face_id); long fg = face->foreground; @@ -1999,9 +2022,7 @@ turn_on_face (f, face_id) /* Turn off appearances of face FACE_ID on tty frame F. */ static void -turn_off_face (f, face_id) - struct frame *f; - int face_id; +turn_off_face (struct frame *f, int face_id) { struct face *face = FACE_FROM_ID (f, face_id); struct tty_display_info *tty = FRAME_TTY (f); @@ -2054,10 +2075,8 @@ turn_off_face (f, face_id) colors FG and BG. */ int -tty_capable_p (tty, caps, fg, bg) - struct tty_display_info *tty; - unsigned caps; - unsigned long fg, bg; +tty_capable_p (struct tty_display_info *tty, unsigned int caps, + unsigned long fg, unsigned long bg) { #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \ if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \ @@ -2083,8 +2102,7 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p, TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). This function always returns nil if TERMINAL does not refer to a text-only terminal. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = get_tty_terminal (terminal, 0); if (!t) @@ -2101,8 +2119,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells, TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). This function always returns 0 if TERMINAL does not refer to a text-only terminal. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = get_tty_terminal (terminal, 0); if (!t) @@ -2197,14 +2214,11 @@ tty_setup_colors (struct tty_display_info *tty, int mode) } void -set_tty_color_mode (tty, f) - struct tty_display_info *tty; - struct frame *f; +set_tty_color_mode (struct tty_display_info *tty, struct frame *f) { - Lisp_Object tem, val, color_mode_spec; + Lisp_Object tem, val; Lisp_Object color_mode; int mode; - extern Lisp_Object Qtty_color_mode; Lisp_Object tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil); @@ -2213,12 +2227,13 @@ set_tty_color_mode (tty, f) if (INTEGERP (val)) color_mode = val; - else + else if (SYMBOLP (tty_color_mode_alist)) { - tem = (NILP (tty_color_mode_alist) ? Qnil - : Fassq (val, XSYMBOL (tty_color_mode_alist)->value)); + tem = Fassq (val, Fsymbol_value (tty_color_mode_alist)); color_mode = CONSP (tem) ? XCDR (tem) : Qnil; } + else + color_mode = Qnil; mode = INTEGERP (color_mode) ? XINT (color_mode) : 0; @@ -2262,8 +2277,7 @@ get_tty_terminal (Lisp_Object terminal, int throw) Returns NULL if the named terminal device is not opened. */ struct terminal * -get_named_tty (name) - char *name; +get_named_tty (const char *name) { struct terminal *t; @@ -2288,8 +2302,7 @@ Returns nil if TERMINAL is not on a tty device. TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); @@ -2308,8 +2321,7 @@ DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0, TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). This function always returns nil if TERMINAL is not on a tty device. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); @@ -2329,8 +2341,7 @@ no effect if used on a non-tty terminal. TERMINAL can be a terminal object, a frame or nil (meaning the selected frame's terminal). This function always returns nil if TERMINAL does not refer to a text-only terminal. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = get_terminal (terminal, 1); @@ -2360,8 +2371,7 @@ terminal device. suspended. A suspended tty may be resumed by calling `resume-tty' on it. */) - (tty) - Lisp_Object tty; + (Lisp_Object tty) { struct terminal *t = get_tty_terminal (tty, 1); FILE *f; @@ -2385,10 +2395,7 @@ A suspended tty may be resumed by calling `resume-tty' on it. */) } reset_sys_modes (t->display_info.tty); - -#ifdef subprocesses delete_keyboard_wait_descriptor (fileno (f)); -#endif #ifndef MSDOS fclose (f); @@ -2427,8 +2434,7 @@ suspended. TTY may be a terminal object, a frame, or nil (meaning the selected frame's terminal). */) - (tty) - Lisp_Object tty; + (Lisp_Object tty) { struct terminal *t = get_tty_terminal (tty, 1); int fd; @@ -2457,9 +2463,7 @@ frame's terminal). */) t->display_info.tty->input = t->display_info.tty->output; #endif -#ifdef subprocesses add_keyboard_wait_descriptor (fd); -#endif if (FRAMEP (t->display_info.tty->top_frame)) { @@ -2593,7 +2597,7 @@ term_show_mouse_face (enum draw_glyphs_face draw) } static void -term_clear_mouse_face () +term_clear_mouse_face (void) { if (!NILP (mouse_face_window)) term_show_mouse_face (DRAW_NORMAL_TEXT); @@ -2609,9 +2613,10 @@ term_clear_mouse_face () If POS is after end of W, return end of last line in W. - taken from msdos.c */ static int -fast_find_position (struct window *w, int pos, int *hpos, int *vpos) +fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos) { - int i, lastcol, line_start_position, maybe_next_line_p = 0; + int i, lastcol, maybe_next_line_p = 0; + EMACS_INT line_start_position; int yb = window_text_bottom_y (w); struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row; @@ -2649,7 +2654,7 @@ fast_find_position (struct window *w, int pos, int *hpos, int *vpos) for (i = 0; i < row->used[TEXT_AREA]; i++) { struct glyph *glyph = row->glyphs[TEXT_AREA] + i; - int charpos; + EMACS_INT charpos; charpos = glyph->charpos; if (charpos == pos) @@ -2710,7 +2715,8 @@ term_mouse_highlight (struct frame *f, int x, int y) && XFASTINT (w->last_modified) == BUF_MODIFF (b) && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) { - int pos, i, nrows = w->current_matrix->nrows; + int i, nrows = w->current_matrix->nrows; + EMACS_INT pos; struct glyph_row *row; struct glyph *glyph; @@ -2753,9 +2759,9 @@ term_mouse_highlight (struct frame *f, int x, int y) /* Check for mouse-face. */ { - extern Lisp_Object Qmouse_face; Lisp_Object mouse_face, overlay, position, *overlay_vec; - int noverlays, obegv, ozv; + int noverlays; + EMACS_INT obegv, ozv; struct buffer *obuf; /* If we get an out-of-range value, return now; avoid an error. */ @@ -2879,7 +2885,6 @@ term_mouse_highlight (struct frame *f, int x, int y) /* Look for a `help-echo' property. */ { Lisp_Object help; - extern Lisp_Object Qhelp_echo; /* Check overlays first. */ help = Qnil; @@ -3100,7 +3105,7 @@ DEFUN ("gpm-mouse-start", Fgpm_mouse_start, Sgpm_mouse_start, 0, 0, 0, doc: /* Open a connection to Gpm. Gpm-mouse can only be activated for one tty at a time. */) - () + (void) { struct frame *f = SELECTED_FRAME (); struct tty_display_info *tty @@ -3148,7 +3153,7 @@ close_gpm (int fd) DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop, 0, 0, 0, doc: /* Close a connection to Gpm. */) - () + (void) { struct frame *f = SELECTED_FRAME (); struct tty_display_info *tty @@ -3181,7 +3186,7 @@ create_tty_output (struct frame *f) abort (); t = xmalloc (sizeof (struct tty_output)); - bzero (t, sizeof (struct tty_output)); + memset (t, 0, sizeof (struct tty_output)); t->display_info = FRAME_TERMINAL (f)->display_info.tty; @@ -3308,7 +3313,7 @@ dissociate_if_controlling_tty (int fd) EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */ if (pgid != -1) { -#if defined (USG) && !defined (BSD_PGRPS) +#if defined (USG5) setpgrp (); no_controlling_tty = 1; #elif defined (CYGWIN) @@ -3334,8 +3339,6 @@ dissociate_if_controlling_tty (int fd) #endif /* !DOS_NT */ } -static void maybe_fatal(); - /* Create a termcap display on the tty device with the given name and type. @@ -3348,7 +3351,7 @@ static void maybe_fatal(); If MUST_SUCCEED is true, then all errors are fatal. */ struct terminal * -init_tty (char *name, char *terminal_type, int must_succeed) +init_tty (const char *name, const char *terminal_type, int must_succeed) { char *area = NULL; char **address = &area; @@ -3388,7 +3391,7 @@ init_tty (char *name, char *terminal_type, int must_succeed) #else tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); #endif - bzero (tty, sizeof (struct tty_display_info)); + memset (tty, 0, sizeof (struct tty_display_info)); tty->next = tty_list; tty_list = tty; @@ -3399,6 +3402,15 @@ init_tty (char *name, char *terminal_type, int must_succeed) tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); Wcm_clear (tty); + encode_terminal_src_size = 0; + encode_terminal_dst_size = 0; + +#ifdef HAVE_GPM + terminal->mouse_position_hook = term_mouse_position; + mouse_face_window = Qnil; +#endif + + #ifndef DOS_NT set_tty_hooks (terminal); @@ -3452,80 +3464,6 @@ init_tty (char *name, char *terminal_type, int must_succeed) add_keyboard_wait_descriptor (fileno (tty->input)); -#endif /* !DOS_NT */ - - encode_terminal_src_size = 0; - encode_terminal_dst_size = 0; - -#ifdef HAVE_GPM - terminal->mouse_position_hook = term_mouse_position; - mouse_face_window = Qnil; -#endif - -#ifdef DOS_NT -#ifdef WINDOWSNT - initialize_w32_display (terminal); -#else /* MSDOS */ - if (strcmp (terminal_type, "internal") == 0) - terminal->type = output_msdos_raw; - initialize_msdos_display (terminal); -#endif /* MSDOS */ - tty->output = stdout; - tty->input = stdin; - /* The following two are inaccessible from w32console.c. */ - terminal->delete_frame_hook = &tty_free_frame_resources; - terminal->delete_terminal_hook = &delete_tty; - - tty->name = xstrdup (name); - terminal->name = xstrdup (name); - tty->type = xstrdup (terminal_type); - -#ifdef subprocesses - add_keyboard_wait_descriptor (0); -#endif - - Wcm_clear (tty); - -#ifdef WINDOWSNT - { - struct frame *f = XFRAME (selected_frame); - - FrameRows (tty) = FRAME_LINES (f); - FrameCols (tty) = FRAME_COLS (f); - tty->specified_window = FRAME_LINES (f); - - FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; - FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; - } -#else /* MSDOS */ - { - int height, width; - get_tty_size (fileno (tty->input), &width, &height); - FrameCols (tty) = width; - FrameRows (tty) = height; - } -#endif /* MSDOS */ - tty->delete_in_insert_mode = 1; - - UseTabs (tty) = 0; - terminal->scroll_region_ok = 0; - - /* Seems to insert lines when it's not supposed to, messing up the - display. In doing a trace, it didn't seem to be called much, so I - don't think we're losing anything by turning it off. */ - terminal->line_ins_del_ok = 0; -#ifdef WINDOWSNT - terminal->char_ins_del_ok = 1; - baud_rate = 19200; -#else /* MSDOS */ - terminal->char_ins_del_ok = 0; - init_baud_rate (fileno (tty->input)); -#endif /* MSDOS */ - - tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ - -#else /* not DOS_NT */ - Wcm_clear (tty); tty->termcap_term_buffer = (char *) xmalloc (buffer_size); @@ -3550,25 +3488,18 @@ init_tty (char *name, char *terminal_type, int must_succeed) } if (status == 0) { -#ifdef TERMINFO maybe_fatal (must_succeed, terminal, "Terminal type %s is not defined", "Terminal type %s is not defined.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n\ -to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", - terminal_type); +`setenv TERM ...') to specify the correct type. It may be necessary\n" +#ifdef TERMINFO +"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", #else - maybe_fatal (must_succeed, terminal, - "Terminal type %s is not defined", - "Terminal type %s is not defined.\n\ -If that is not the actual type of terminal you have,\n\ -use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n\ -to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", - terminal_type); +"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", #endif + terminal_type); } #ifndef TERMINFO @@ -3684,7 +3615,61 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", tty->TF_underscore = tgetflag ("ul"); tty->TF_teleray = tgetflag ("xt"); -#endif /* !DOS_NT */ +#else /* DOS_NT */ +#ifdef WINDOWSNT + { + struct frame *f = XFRAME (selected_frame); + + initialize_w32_display (terminal); + + FrameRows (tty) = FRAME_LINES (f); + FrameCols (tty) = FRAME_COLS (f); + tty->specified_window = FRAME_LINES (f); + + FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; + FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; + terminal->char_ins_del_ok = 1; + baud_rate = 19200; + } +#else /* MSDOS */ + { + int height, width; + if (strcmp (terminal_type, "internal") == 0) + terminal->type = output_msdos_raw; + initialize_msdos_display (terminal); + + get_tty_size (fileno (tty->input), &width, &height); + FrameCols (tty) = width; + FrameRows (tty) = height; + terminal->char_ins_del_ok = 0; + init_baud_rate (fileno (tty->input)); + } +#endif /* MSDOS */ + tty->output = stdout; + tty->input = stdin; + /* The following two are inaccessible from w32console.c. */ + terminal->delete_frame_hook = &tty_free_frame_resources; + terminal->delete_terminal_hook = &delete_tty; + + tty->name = xstrdup (name); + terminal->name = xstrdup (name); + tty->type = xstrdup (terminal_type); + + add_keyboard_wait_descriptor (0); + + tty->delete_in_insert_mode = 1; + + UseTabs (tty) = 0; + terminal->scroll_region_ok = 0; + + /* Seems to insert lines when it's not supposed to, messing up the + display. In doing a trace, it didn't seem to be called much, so I + don't think we're losing anything by turning it off. */ + terminal->line_ins_del_ok = 0; + + tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ +#endif /* DOS_NT */ + terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (terminal->kboard); terminal->kboard->Vwindow_system = Qnil; @@ -3714,7 +3699,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", if (FrameRows (tty) < 3 || FrameCols (tty) < 3) maybe_fatal (must_succeed, terminal, - "Screen size %dx%d is too small" + "Screen size %dx%d is too small", "Screen size %dx%d is too small", FrameCols (tty), FrameRows (tty)); @@ -3835,20 +3820,15 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", { maybe_fatal (must_succeed, terminal, "Terminal type \"%s\" is not powerful enough to run Emacs", -# ifdef TERMINFO "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ It lacks the ability to position the cursor.\n\ If that is not the actual type of terminal you have,\n\ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n\ -to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", +`setenv TERM ...') to specify the correct type. It may be necessary\n" +# ifdef TERMINFO +"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", # else /* TERMCAP */ - "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ -It lacks the ability to position the cursor.\n\ -If that is not the actual type of terminal you have,\n\ -use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n\ -to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", +"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", # endif /* TERMINFO */ terminal_type); } @@ -3895,24 +3875,39 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", return terminal; } + +static void +vfatal (const char *str, va_list ap) +{ + fprintf (stderr, "emacs: "); + vfprintf (stderr, str, ap); + if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) + fprintf (stderr, "\n"); + va_end (ap); + fflush (stderr); + exit (1); +} + + /* Auxiliary error-handling function for init_tty. Delete TERMINAL, then call error or fatal with str1 or str2, respectively, according to MUST_SUCCEED. */ static void -maybe_fatal (must_succeed, terminal, str1, str2, arg1, arg2) - int must_succeed; - struct terminal *terminal; - char *str1, *str2, *arg1, *arg2; +maybe_fatal (int must_succeed, struct terminal *terminal, + const char *str1, const char *str2, ...) { + va_list ap; + va_start (ap, str2); if (terminal) delete_tty (terminal); if (must_succeed) - fatal (str2, arg1, arg2); + vfatal (str2, ap); else - error (str1, arg1, arg2); + verror (str1, ap); + va_end (ap); abort (); } @@ -3921,13 +3916,8 @@ fatal (const char *str, ...) { va_list ap; va_start (ap, str); - fprintf (stderr, "emacs: "); - vfprintf (stderr, str, ap); - if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) - fprintf (stderr, "\n"); + vfatal (str, ap); va_end (ap); - fflush (stderr); - exit (1); } @@ -3976,9 +3966,7 @@ delete_tty (struct terminal *terminal) if (tty->input) { -#ifdef subprocesses delete_keyboard_wait_descriptor (fileno (tty->input)); -#endif if (tty->input != stdin) fclose (tty->input); } @@ -3992,7 +3980,7 @@ delete_tty (struct terminal *terminal) xfree (tty->termcap_strings_buffer); xfree (tty->termcap_term_buffer); - bzero (tty, sizeof (struct tty_display_info)); + memset (tty, 0, sizeof (struct tty_display_info)); xfree (tty); } @@ -4013,7 +4001,7 @@ mark_ttys (void) void -syms_of_term () +syms_of_term (void) { DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo, doc: /* Non-nil means the system uses terminfo rather than termcap. diff --git a/src/termcap.c b/src/termcap.c index 9b4a7f657f6..4ad0cee6264 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -18,56 +18,20 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - -#ifdef emacs - #include <setjmp.h> -#include <lisp.h> /* xmalloc is here */ -/* Get the O_* definitions for open et al. */ #include <sys/file.h> -#ifdef HAVE_FCNTL_H #include <fcntl.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#else /* not emacs */ - -#ifdef STDC_HEADERS -#include <stdlib.h> -#include <string.h> -#else -char *getenv (); -char *malloc (); -char *realloc (); -#endif - -/* Do this after the include, in case string.h prototypes bcopy. */ -#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy) -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif - #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#endif /* not emacs */ +#include "lisp.h" #ifndef NULL #define NULL (char *) 0 #endif -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - /* BUFSIZE is the initial size allocated for the buffer for reading the termcap file. It is not a limit. @@ -89,37 +53,6 @@ int bufsize = 128; #define TERMCAP_FILE "/etc/termcap" #endif -#ifndef emacs -static void -memory_out () -{ - write (2, "virtual memory exhausted\n", 25); - exit (1); -} - -static char * -xmalloc (size) - unsigned size; -{ - register char *tem = malloc (size); - - if (!tem) - memory_out (); - return tem; -} - -static char * -xrealloc (ptr, size) - char *ptr; - unsigned size; -{ - register char *tem = realloc (ptr, size); - - if (!tem) - memory_out (); - return tem; -} -#endif /* not emacs */ /* Looking up capabilities in the entry already found. */ @@ -127,15 +60,14 @@ xrealloc (ptr, size) for tgetnum, tgetflag and tgetstr to find. */ static char *term_entry; -static char *tgetst1 (); +static char *tgetst1 (char *ptr, char **area); /* Search entry BP for capability CAP. Return a pointer to the capability (in BP) if found, 0 if not found. */ static char * -find_capability (bp, cap) - register char *bp, *cap; +find_capability (register char *bp, register char *cap) { for (; *bp; bp++) if (bp[0] == ':' @@ -146,8 +78,7 @@ find_capability (bp, cap) } int -tgetnum (cap) - char *cap; +tgetnum (char *cap) { register char *ptr = find_capability (term_entry, cap); if (!ptr || ptr[-1] != '#') @@ -156,8 +87,7 @@ tgetnum (cap) } int -tgetflag (cap) - char *cap; +tgetflag (char *cap) { register char *ptr = find_capability (term_entry, cap); return ptr && ptr[-1] == ':'; @@ -169,9 +99,7 @@ tgetflag (cap) If AREA is null, space is allocated with `malloc'. */ char * -tgetstr (cap, area) - char *cap; - char **area; +tgetstr (char *cap, char **area) { register char *ptr = find_capability (term_entry, cap); if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) @@ -209,9 +137,7 @@ static const char esctab[] or NULL if PTR is NULL. */ static char * -tgetst1 (ptr, area) - char *ptr; - char **area; +tgetst1 (char *ptr, char **area) { register char *p, *r; register int c; @@ -322,7 +248,7 @@ tgetst1 (ptr, area) cut[last_p_param].len = r - cut[last_p_param].beg; for (i = 0, wp = ret; i <= last_p_param; wp += cut[i++].len) - bcopy (cut[i].beg, wp, cut[i].len); + memcpy (wp, cut[i].beg, cut[i].len); r = wp; } } @@ -336,48 +262,20 @@ tgetst1 (ptr, area) /* Outputting a string with padding. */ -#ifndef emacs -short ospeed; -/* If OSPEED is 0, we use this as the actual baud rate. */ -int tputs_baud_rate; -#endif - char PC; -#ifndef emacs -/* Actual baud rate if positive; - - baud rate / 100 if negative. */ - -static const int speeds[] = - { - 0, 50, 75, 110, 135, 150, -2, -3, -6, -12, - -18, -24, -48, -96, -192, -288, -384, -576, -1152 - }; - -#endif /* not emacs */ - void -tputs (str, nlines, outfun) - register char *str; - int nlines; - register int (*outfun) (); +tputs (register char *str, int nlines, register int (*outfun) (/* ??? */)) { register int padcount = 0; register int speed; -#ifdef emacs extern EMACS_INT baud_rate; speed = baud_rate; /* For quite high speeds, convert to the smaller units to avoid overflow. */ if (speed > 10000) speed = - speed / 100; -#else - if (ospeed == 0) - speed = tputs_baud_rate; - else - speed = speeds[ospeed]; -#endif if (!str) return; @@ -432,10 +330,10 @@ struct termcap_buffer /* Forward declarations of static functions. */ -static int scan_file (); -static char *gobble_line (); -static int compare_contin (); -static int name_match (); +static int scan_file (char *str, int fd, register struct termcap_buffer *bufp); +static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end); +static int compare_contin (register char *str1, register char *str2); +static int name_match (char *line, char *name); #ifdef MSDOS /* MW, May 1993 */ static int @@ -460,8 +358,7 @@ valid_filename_p (fn) in it, and some other value otherwise. */ int -tgetent (bp, name) - char *bp, *name; +tgetent (char *bp, char *name) { register char *termcap_name; register int fd; @@ -625,10 +522,7 @@ tgetent (bp, name) or 0 if no entry is found in the file. */ static int -scan_file (str, fd, bufp) - char *str; - int fd; - register struct termcap_buffer *bufp; +scan_file (char *str, int fd, register struct termcap_buffer *bufp) { register char *end; @@ -665,8 +559,7 @@ scan_file (str, fd, bufp) by termcap entry LINE. */ static int -name_match (line, name) - char *line, *name; +name_match (char *line, char *name) { register char *tem; @@ -681,8 +574,7 @@ name_match (line, name) } static int -compare_contin (str1, str2) - register char *str1, *str2; +compare_contin (register char *str1, register char *str2) { register int c1, c2; while (1) @@ -722,10 +614,7 @@ compare_contin (str1, str2) thing as one line. The caller decides when a line is continued. */ static char * -gobble_line (fd, bufp, append_end) - int fd; - register struct termcap_buffer *bufp; - char *append_end; +gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) { register char *end; register int nread; @@ -758,7 +647,7 @@ gobble_line (fd, bufp, append_end) else { append_end -= bufp->ptr - buf; - bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf); + memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf); bufp->ptr = buf; } if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full))) diff --git a/src/termhooks.h b/src/termhooks.h index 2b4011627c8..b9358896bae 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -39,16 +39,11 @@ enum scroll_bar_part { /* If the value of the frame parameter changed, whis hook is called. For example, if going from fullscreen to not fullscreen this hook may do something OS dependent, like extended window manager hints on X11. */ -extern void (*fullscreen_hook) P_ ((struct frame *f)); +extern void (*fullscreen_hook) (struct frame *f); /* Input queue declarations and hooks. */ -/* Expedient hack: only provide the below definitions to files that - are prepared to handle lispy things. CONSP is defined if lisp.h - has been included before this file. */ -#ifdef CONSP - enum event_kind { NO_EVENT, /* nothing happened. This should never @@ -228,9 +223,11 @@ struct input_event /* For an ASCII_KEYSTROKE_EVENT and MULTIBYTE_CHAR_KEYSTROKE_EVENT, this is the character. For a NON_ASCII_KEYSTROKE_EVENT, this is the keysym code. - For a mouse event, this is the button number. */ + For a mouse event, this is the button number. + For a HELP_EVENT, this is the position within the object + (stored in ARG below) where the help was found. */ /* In WindowsNT, for a mouse wheel event, this is the delta. */ - int code; + EMACS_INT code; enum scroll_bar_part part; int modifiers; /* See enum below for interpretation. */ @@ -255,7 +252,7 @@ struct input_event Lisp_Object arg; }; -#define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event)) +#define EVENT_INIT(event) memset (&(event), 0, sizeof (struct input_event)) /* Bits in the modifiers member of the input_event structure. Note that reorder_modifiers assumes that the bits are in canonical @@ -315,8 +312,6 @@ extern void term_mouse_moveto (int, int); extern struct tty_display_info *gpm_tty; #endif -#endif /* CONSP */ - struct ns_display_info; struct x_display_info; @@ -415,28 +410,28 @@ struct terminal /* Text display hooks. */ - void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos)); - void (*raw_cursor_to_hook) P_ ((struct frame *, int, int)); + void (*cursor_to_hook) (struct frame *f, int vpos, int hpos); + void (*raw_cursor_to_hook) (struct frame *, int, int); - void (*clear_to_end_hook) P_ ((struct frame *)); - void (*clear_frame_hook) P_ ((struct frame *)); - void (*clear_end_of_line_hook) P_ ((struct frame *, int)); + void (*clear_to_end_hook) (struct frame *); + void (*clear_frame_hook) (struct frame *); + void (*clear_end_of_line_hook) (struct frame *, int); - void (*ins_del_lines_hook) P_ ((struct frame *f, int, int)); + void (*ins_del_lines_hook) (struct frame *f, int, int); - void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); - void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n)); - void (*delete_glyphs_hook) P_ ((struct frame *, int)); + void (*insert_glyphs_hook) (struct frame *f, struct glyph *s, int n); + void (*write_glyphs_hook) (struct frame *f, struct glyph *s, int n); + void (*delete_glyphs_hook) (struct frame *, int); - void (*ring_bell_hook) P_ ((struct frame *f)); - void (*toggle_invisible_pointer_hook) P_ ((struct frame *f, int invisible)); + void (*ring_bell_hook) (struct frame *f); + void (*toggle_invisible_pointer_hook) (struct frame *f, int invisible); - void (*reset_terminal_modes_hook) P_ ((struct terminal *)); - void (*set_terminal_modes_hook) P_ ((struct terminal *)); + void (*reset_terminal_modes_hook) (struct terminal *); + void (*set_terminal_modes_hook) (struct terminal *); - void (*update_begin_hook) P_ ((struct frame *)); - void (*update_end_hook) P_ ((struct frame *)); - void (*set_terminal_window_hook) P_ ((struct frame *, int)); + void (*update_begin_hook) (struct frame *); + void (*update_end_hook) (struct frame *); + void (*set_terminal_window_hook) (struct frame *, int); /* Multi-frame and mouse support hooks. */ @@ -458,12 +453,12 @@ struct terminal This should clear mouse_moved until the next motion event arrives. */ - void (*mouse_position_hook) P_ ((struct frame **f, int, - Lisp_Object *bar_window, - enum scroll_bar_part *part, - Lisp_Object *x, - Lisp_Object *y, - unsigned long *time)); + void (*mouse_position_hook) (struct frame **f, int, + Lisp_Object *bar_window, + enum scroll_bar_part *part, + Lisp_Object *x, + Lisp_Object *y, + unsigned long *time); /* The window system handling code should set this if the mouse has moved since the last call to the mouse_position_hook. Calling that @@ -473,7 +468,7 @@ struct terminal /* When a frame's focus redirection is changed, this hook tells the window system code to re-decide where to put the highlight. Under X, this means that Emacs lies about where the focus is. */ - void (*frame_rehighlight_hook) P_ ((struct frame *)); + void (*frame_rehighlight_hook) (struct frame *); /* If we're displaying frames using a window system that can stack frames on top of each other, this hook allows you to bring a frame @@ -485,12 +480,12 @@ struct terminal If RAISE is non-zero, F is brought to the front, before all other windows. If RAISE is zero, F is sent to the back, behind all other windows. */ - void (*frame_raise_lower_hook) P_ ((struct frame *f, int raise)); + void (*frame_raise_lower_hook) (struct frame *f, int raise); /* If the value of the frame parameter changed, whis hook is called. For example, if going from fullscreen to not fullscreen this hook may do something OS dependent, like extended window manager hints on X11. */ - void (*fullscreen_hook) P_ ((struct frame *f)); + void (*fullscreen_hook) (struct frame *f); /* Scroll bar hooks. */ @@ -520,9 +515,9 @@ struct terminal indicate that we are displaying PORTION characters out of a total of WHOLE characters, starting at POSITION. If WINDOW doesn't yet have a scroll bar, create one for it. */ - void (*set_vertical_scroll_bar_hook) P_ ((struct window *window, - int portion, int whole, - int position)); + void (*set_vertical_scroll_bar_hook) (struct window *window, + int portion, int whole, + int position); /* The following three hooks are used when we're doing a thorough @@ -545,11 +540,11 @@ struct terminal If non-zero, this hook should be safe to apply to any frame, whether or not it can support scroll bars, and whether or not it is currently displaying them. */ - void (*condemn_scroll_bars_hook) P_ ((struct frame *frame)); + void (*condemn_scroll_bars_hook) (struct frame *frame); /* Unmark WINDOW's scroll bar for deletion in this judgement cycle. Note that it's okay to redeem a scroll bar that is not condemned. */ - void (*redeem_scroll_bar_hook) P_ ((struct window *window)); + void (*redeem_scroll_bar_hook) (struct window *window); /* Remove all scroll bars on FRAME that haven't been saved since the last call to `*condemn_scroll_bars_hook'. @@ -562,7 +557,7 @@ struct terminal If non-zero, this hook should be safe to apply to any frame, whether or not it can support scroll bars, and whether or not it is currently displaying them. */ - void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME)); + void (*judge_scroll_bars_hook) (struct frame *FRAME); /* Called to read input events. @@ -584,17 +579,17 @@ struct terminal Therefore, in most cases EXPECTED should be simply ignored. XXX This documentation needs to be updated. */ - int (*read_socket_hook) P_ ((struct terminal *terminal, - int expected, - struct input_event *hold_quit)); + int (*read_socket_hook) (struct terminal *terminal, + int expected, + struct input_event *hold_quit); /* Called when a frame's display becomes entirely up to date. */ - void (*frame_up_to_date_hook) P_ ((struct frame *)); + void (*frame_up_to_date_hook) (struct frame *); /* Called to delete the device-specific portions of a frame that is on this terminal device. */ - void (*delete_frame_hook) P_ ((struct frame *)); + void (*delete_frame_hook) (struct frame *); /* Called after the last frame on this terminal is deleted, or when the display device was closed (hangup). @@ -606,7 +601,7 @@ struct terminal on the terminal. delete_frame ensures that there are no live frames on the terminal when it calls this hook, so infinite recursion is prevented. */ - void (*delete_terminal_hook) P_ ((struct terminal *)); + void (*delete_terminal_hook) (struct terminal *); }; @@ -647,10 +642,10 @@ extern struct terminal *terminal_list; /* Return true if the terminal device is not suspended. */ #define TERMINAL_ACTIVE_P(d) (((d)->type != output_termcap && (d)->type !=output_msdos_raw) || (d)->display_info.tty->input) -extern Lisp_Object get_terminal_param P_ ((struct terminal *, Lisp_Object)); -extern struct terminal *get_terminal P_ ((Lisp_Object terminal, int)); -extern struct terminal *create_terminal P_ ((void)); -extern void delete_terminal P_ ((struct terminal *)); +extern Lisp_Object get_terminal_param (struct terminal *, Lisp_Object); +extern struct terminal *get_terminal (Lisp_Object terminal, int); +extern struct terminal *create_terminal (void); +extern void delete_terminal (struct terminal *); /* The initial terminal device, created by initial_term_init. */ extern struct terminal *initial_terminal; diff --git a/src/terminal.c b/src/terminal.c index 45d918a2bd4..bda6c307a10 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -40,7 +40,7 @@ struct terminal *initial_terminal; /* Function to use to ring the bell. */ Lisp_Object Vring_bell_function; -static void delete_initial_terminal P_ ((struct terminal *)); +static void delete_initial_terminal (struct terminal *); @@ -300,8 +300,7 @@ selected frame's terminal). Normally, you may not delete a display if all other displays are suspended, but if the second argument FORCE is non-nil, you may do so. */) - (terminal, force) - Lisp_Object terminal, force; + (Lisp_Object terminal, Lisp_Object force) { struct terminal *t = get_terminal (terminal, 0); @@ -342,8 +341,7 @@ DEFUN ("frame-terminal", Fframe_terminal, Sframe_terminal, 0, 1, 0, If FRAME is nil, the selected frame is used. The terminal device is represented by its integer identifier. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct terminal *t; @@ -370,8 +368,7 @@ Value is nil if OBJECT is not a live display terminal. If object is a live display terminal, the return value indicates what sort of output terminal it uses. See the documentation of `framep' for possible return values. */) - (object) - Lisp_Object object; + (Lisp_Object object) { struct terminal *t; @@ -402,7 +399,7 @@ possible return values. */) DEFUN ("terminal-list", Fterminal_list, Sterminal_list, 0, 0, 0, doc: /* Return a list of all terminal devices. */) - () + (void) { Lisp_Object terminal, terminals = Qnil; struct terminal *t; @@ -422,8 +419,7 @@ It is not guaranteed that the returned value is unique among opened devices. TERMINAL may be a terminal object, a frame, or nil (meaning the selected frame's terminal). */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); @@ -435,9 +431,7 @@ selected frame's terminal). */) /* Return the value of terminal parameter PARAM in terminal T. */ Lisp_Object -get_terminal_param (t, param) - struct terminal *t; - Lisp_Object param; +get_terminal_param (struct terminal *t, Lisp_Object param) { Lisp_Object tem = Fassq (param, t->param_alist); if (EQ (tem, Qnil)) @@ -449,10 +443,7 @@ get_terminal_param (t, param) Return the previous value. */ Lisp_Object -store_terminal_param (t, parameter, value) - struct terminal *t; - Lisp_Object parameter; - Lisp_Object value; +store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object value) { Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist); if (EQ (old_alist_elt, Qnil)) @@ -476,8 +467,7 @@ is a symbol. TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct terminal *t = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); @@ -488,9 +478,7 @@ DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0, doc: /* Return TERMINAL's value for parameter PARAMETER. TERMINAL can be a terminal object, a frame, or nil (meaning the selected frame's terminal). */) - (terminal, parameter) - Lisp_Object terminal; - Lisp_Object parameter; + (Lisp_Object terminal, Lisp_Object parameter) { Lisp_Object value; struct terminal *t @@ -507,10 +495,7 @@ Return the previous value of PARAMETER. TERMINAL can be a terminal object, a frame or nil (meaning the selected frame's terminal). */) - (terminal, parameter, value) - Lisp_Object terminal; - Lisp_Object parameter; - Lisp_Object value; + (Lisp_Object terminal, Lisp_Object parameter, Lisp_Object value) { struct terminal *t = TERMINALP (terminal) ? XTERMINAL (terminal) : get_terminal (terminal, 1); @@ -552,7 +537,7 @@ delete_initial_terminal (struct terminal *terminal) } void -syms_of_terminal () +syms_of_terminal (void) { DEFVAR_LISP ("ring-bell-function", &Vring_bell_function, diff --git a/src/terminfo.c b/src/terminfo.c index 55508196fae..50749492cfe 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -35,13 +35,12 @@ char *UP, *BC, PC; */ char * -tparam (string, outstring, len, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - char *string; - char *outstring; - int len, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9; +tparam (char *string, char *outstring, + int len, int arg1, int arg2, int arg3, int arg4, + int arg5, int arg6, int arg7, int arg8, int arg9) { char *temp; - extern char *tparm(); + extern char *tparm (char *str, ...); temp = tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); if (outstring == 0) diff --git a/src/textprop.c b/src/textprop.c index 83d09cce558..88e869b13e9 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -78,15 +78,14 @@ Lisp_Object Vtext_property_default_nonsticky; Lisp_Object interval_insert_behind_hooks; Lisp_Object interval_insert_in_front_hooks; -static void text_read_only P_ ((Lisp_Object)) NO_RETURN; +static void text_read_only (Lisp_Object) NO_RETURN; /* Signal a `text-read-only' error. This function makes it easier to capture that error in GDB by putting a breakpoint on it. */ static void -text_read_only (propval) - Lisp_Object propval; +text_read_only (Lisp_Object propval) { if (STRINGP (propval)) xsignal1 (Qtext_read_only, propval); @@ -123,12 +122,10 @@ text_read_only (propval) #define hard 1 INTERVAL -validate_interval_range (object, begin, end, force) - Lisp_Object object, *begin, *end; - int force; +validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *end, int force) { register INTERVAL i; - int searchpos; + EMACS_INT searchpos; CHECK_STRING_OR_BUFFER (object); CHECK_NUMBER_COERCE_MARKER (*begin); @@ -164,7 +161,7 @@ validate_interval_range (object, begin, end, force) } else { - int len = SCHARS (object); + EMACS_INT len = SCHARS (object); if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end) && XINT (*end) <= len)) @@ -191,8 +188,7 @@ validate_interval_range (object, begin, end, force) is even numbered and thus suitable as a plist. */ static Lisp_Object -validate_plist (list) - Lisp_Object list; +validate_plist (Lisp_Object list) { if (NILP (list)) return Qnil; @@ -218,9 +214,7 @@ validate_plist (list) with the same values, of list PLIST. */ static int -interval_has_all_properties (plist, i) - Lisp_Object plist; - INTERVAL i; +interval_has_all_properties (Lisp_Object plist, INTERVAL i) { register Lisp_Object tail1, tail2, sym1; register int found; @@ -256,9 +250,7 @@ interval_has_all_properties (plist, i) properties of PLIST, regardless of their values. */ static INLINE int -interval_has_some_properties (plist, i) - Lisp_Object plist; - INTERVAL i; +interval_has_some_properties (Lisp_Object plist, INTERVAL i) { register Lisp_Object tail1, tail2, sym; @@ -280,9 +272,7 @@ interval_has_some_properties (plist, i) property names in LIST, regardless of their values. */ static INLINE int -interval_has_some_properties_list (list, i) - Lisp_Object list; - INTERVAL i; +interval_has_some_properties_list (Lisp_Object list, INTERVAL i) { register Lisp_Object tail1, tail2, sym; @@ -305,8 +295,7 @@ interval_has_some_properties_list (list, i) /* Return the value of PROP in property-list PLIST, or Qunbound if it has none. */ static Lisp_Object -property_value (plist, prop) - Lisp_Object plist, prop; +property_value (Lisp_Object plist, Lisp_Object prop) { Lisp_Object value; @@ -324,9 +313,7 @@ property_value (plist, prop) OBJECT is the string or buffer that INTERVAL belongs to. */ static void -set_properties (properties, interval, object) - Lisp_Object properties, object; - INTERVAL interval; +set_properties (Lisp_Object properties, INTERVAL interval, Lisp_Object object) { Lisp_Object sym, value; @@ -372,10 +359,7 @@ set_properties (properties, interval, object) are actually added to I's plist) */ static int -add_properties (plist, i, object) - Lisp_Object plist; - INTERVAL i; - Lisp_Object object; +add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object) { Lisp_Object tail1, tail2, sym1, val1; register int changed = 0; @@ -451,10 +435,7 @@ add_properties (plist, i, object) OBJECT is the string or buffer containing I. */ static int -remove_properties (plist, list, i, object) - Lisp_Object plist, list; - INTERVAL i; - Lisp_Object object; +remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object object) { register Lisp_Object tail1, tail2, sym, current_plist; register int changed = 0; @@ -535,12 +516,10 @@ erase_properties (i) POSITION is BEG-based. */ INTERVAL -interval_of (position, object) - int position; - Lisp_Object object; +interval_of (int position, Lisp_Object object) { register INTERVAL i; - int beg, end; + EMACS_INT beg, end; if (NILP (object)) XSETBUFFER (object, current_buffer); @@ -579,8 +558,7 @@ If the optional second argument OBJECT is a buffer (or nil, which means the current buffer), POSITION is a buffer position (integer or marker). If OBJECT is a string, POSITION is a 0-based index into it. If POSITION is at the end of OBJECT, the value is nil. */) - (position, object) - Lisp_Object position, object; + (Lisp_Object position, Lisp_Object object) { register INTERVAL i; @@ -604,9 +582,7 @@ DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0, doc: /* Return the value of POSITION's property PROP, in OBJECT. OBJECT is optional and defaults to the current buffer. If POSITION is at the end of OBJECT, the value is nil. */) - (position, prop, object) - Lisp_Object position, object; - Lisp_Object prop; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object) { return textget (Ftext_properties_at (position, object), prop); } @@ -623,10 +599,7 @@ If POSITION is at the end of OBJECT, the value is nil. */) window-specific overlays are considered only if they are associated with OBJECT. */ Lisp_Object -get_char_property_and_overlay (position, prop, object, overlay) - Lisp_Object position, object; - register Lisp_Object prop; - Lisp_Object *overlay; +get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop, Lisp_Object object, Lisp_Object *overlay) { struct window *w = 0; @@ -689,9 +662,7 @@ If OBJECT is a buffer, then overlay properties are considered as well as text properties. If OBJECT is a window, then that window's buffer is used, but window-specific overlays are considered only if they are associated with OBJECT. */) - (position, prop, object) - Lisp_Object position, object; - register Lisp_Object prop; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object) { return get_char_property_and_overlay (position, prop, object, 0); } @@ -710,9 +681,7 @@ value is always nil, since strings do not have overlays. If OBJECT is a window, then that window's buffer is used, but window-specific overlays are considered only if they are associated with OBJECT. If POSITION is at the end of OBJECT, both car and cdr are nil. */) - (position, prop, object) - Lisp_Object position, object; - register Lisp_Object prop; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object) { Lisp_Object overlay; Lisp_Object val @@ -732,8 +701,7 @@ If none is found up to (point-max), the function returns (point-max). If the optional second argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. LIMIT is a no-op if it is greater than (point-max). */) - (position, limit) - Lisp_Object position, limit; + (Lisp_Object position, Lisp_Object limit) { Lisp_Object temp; @@ -758,8 +726,7 @@ If none is found since (point-min), the function returns (point-min). If the optional second argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. LIMIT is a no-op if it is less than (point-min). */) - (position, limit) - Lisp_Object position, limit; + (Lisp_Object position, Lisp_Object limit) { Lisp_Object temp; @@ -791,8 +758,7 @@ If the property is constant all the way to the end of OBJECT, return the last valid position in OBJECT. If the optional fourth argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. */) - (position, prop, object, limit) - Lisp_Object prop, position, object, limit; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) { if (STRINGP (object)) { @@ -876,8 +842,7 @@ If the property is constant all the way to the start of OBJECT, return the first valid position in OBJECT. If the optional fourth argument LIMIT is non-nil, don't search back past position LIMIT; return LIMIT if nothing is found before LIMIT. */) - (position, prop, object, limit) - Lisp_Object prop, position, object, limit; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) { if (STRINGP (object)) { @@ -965,8 +930,7 @@ If the value is non-nil, it is a position greater than POSITION, never equal. If the optional third argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. */) - (position, object, limit) - Lisp_Object position, object, limit; + (Lisp_Object position, Lisp_Object object, Lisp_Object limit) { register INTERVAL i, next; @@ -1020,8 +984,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) /* Return 1 if there's a change in some property between BEG and END. */ int -property_change_between_p (beg, end) - int beg, end; +property_change_between_p (EMACS_INT beg, EMACS_INT end) { register INTERVAL i, next; Lisp_Object object, pos; @@ -1063,8 +1026,7 @@ If the value is non-nil, it is a position greater than POSITION, never equal. If the optional fourth argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT. */) - (position, prop, object, limit) - Lisp_Object position, prop, object, limit; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) { register INTERVAL i, next; register Lisp_Object here_val; @@ -1111,8 +1073,7 @@ If the value is non-nil, it is a position less than POSITION, never equal. If the optional third argument LIMIT is non-nil, don't search back past position LIMIT; return LIMIT if nothing is found until LIMIT. */) - (position, object, limit) - Lisp_Object position, object, limit; + (Lisp_Object position, Lisp_Object object, Lisp_Object limit) { register INTERVAL i, previous; @@ -1160,8 +1121,7 @@ If the value is non-nil, it is a position less than POSITION, never equal. If the optional fourth argument LIMIT is non-nil, don't search back past position LIMIT; return LIMIT if nothing is found until LIMIT. */) - (position, prop, object, limit) - Lisp_Object position, prop, object, limit; + (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) { register INTERVAL i, previous; register Lisp_Object here_val; @@ -1210,11 +1170,11 @@ OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. Return t if any property value actually changed, nil otherwise. */) - (start, end, properties, object) - Lisp_Object start, end, properties, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) { register INTERVAL i, unchanged; - register int s, len, modified = 0; + register EMACS_INT s, len; + register int modified = 0; struct gcpro gcpro1; properties = validate_plist (properties); @@ -1243,7 +1203,7 @@ Return t if any property value actually changed, nil otherwise. */) skip it. */ if (interval_has_all_properties (properties, i)) { - int got = (LENGTH (i) - (s - i->position)); + EMACS_INT got = (LENGTH (i) - (s - i->position)); if (got >= len) RETURN_UNGCPRO (Qnil); len -= got; @@ -1318,8 +1278,7 @@ specify the property to add. If the optional fifth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. */) - (start, end, property, value, object) - Lisp_Object start, end, property, value, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object) { Fadd_text_properties (start, end, Fcons (property, Fcons (value, Qnil)), @@ -1336,8 +1295,7 @@ the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. If PROPERTIES is nil, the effect is to remove all properties from the designated part of OBJECT. */) - (start, end, properties, object) - Lisp_Object start, end, properties, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) { return set_text_properties (start, end, properties, object, Qt); } @@ -1353,8 +1311,7 @@ the designated part of OBJECT. */) otherwise. */ Lisp_Object -set_text_properties (start, end, properties, object, coherent_change_p) - Lisp_Object start, end, properties, object, coherent_change_p; +set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, Lisp_Object coherent_change_p) { register INTERVAL i; Lisp_Object ostart, oend; @@ -1418,12 +1375,10 @@ set_text_properties (start, end, properties, object, coherent_change_p) START and END can be in any order. */ void -set_text_properties_1 (start, end, properties, buffer, i) - Lisp_Object start, end, properties, buffer; - INTERVAL i; +set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i) { register INTERVAL prev_changed = NULL_INTERVAL; - register int s, len; + register EMACS_INT s, len; INTERVAL unchanged; s = XINT (start); @@ -1509,11 +1464,11 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. Return t if any property was actually removed, nil otherwise. Use `set-text-properties' if you want to remove all text properties. */) - (start, end, properties, object) - Lisp_Object start, end, properties, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) { register INTERVAL i, unchanged; - register int s, len, modified = 0; + register EMACS_INT s, len; + register int modified = 0; if (NILP (object)) XSETBUFFER (object, current_buffer); @@ -1531,7 +1486,7 @@ Use `set-text-properties' if you want to remove all text properties. */) it covers the entire region. */ if (! interval_has_some_properties (properties, i)) { - int got = (LENGTH (i) - (s - i->position)); + EMACS_INT got = (LENGTH (i) - (s - i->position)); if (got >= len) return Qnil; len -= got; @@ -1595,11 +1550,11 @@ If the optional fourth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. Return t if any property was actually removed, nil otherwise. */) - (start, end, list_of_properties, object) - Lisp_Object start, end, list_of_properties, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object) { register INTERVAL i, unchanged; - register int s, len, modified = 0; + register EMACS_INT s, len; + register int modified = 0; Lisp_Object properties; properties = list_of_properties; @@ -1619,7 +1574,7 @@ Return t if any property was actually removed, nil otherwise. */) it covers the entire region. */ if (! interval_has_some_properties_list (properties, i)) { - int got = (LENGTH (i) - (s - i->position)); + EMACS_INT got = (LENGTH (i) - (s - i->position)); if (got >= len) return Qnil; len -= got; @@ -1703,11 +1658,10 @@ is `eq' to VALUE. Otherwise return nil. If the optional fifth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. */) - (start, end, property, value, object) - Lisp_Object start, end, property, value, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object) { register INTERVAL i; - register int e, pos; + register EMACS_INT e, pos; if (NILP (object)) XSETBUFFER (object, current_buffer); @@ -1740,11 +1694,10 @@ is not `eq' to VALUE. Otherwise, return nil. If the optional fifth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. */) - (start, end, property, value, object) - Lisp_Object start, end, property, value, object; + (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object) { register INTERVAL i; - register int s, e; + register EMACS_INT s, e; if (NILP (object)) XSETBUFFER (object, current_buffer); @@ -1777,8 +1730,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */ BUFFER can be either a buffer or nil (meaning current buffer). */ int -text_property_stickiness (prop, pos, buffer) - Lisp_Object prop, pos, buffer; +text_property_stickiness (Lisp_Object prop, Lisp_Object pos, Lisp_Object buffer) { Lisp_Object prev_pos, front_sticky; int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */ @@ -1851,14 +1803,14 @@ text_property_stickiness (prop, pos, buffer) /* Note this can GC when DEST is a buffer. */ Lisp_Object -copy_text_properties (start, end, src, pos, dest, prop) - Lisp_Object start, end, src, pos, dest, prop; +copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_Object pos, Lisp_Object dest, Lisp_Object prop) { INTERVAL i; Lisp_Object res; Lisp_Object stuff; Lisp_Object plist; - int s, e, e2, p, len, modified = 0; + EMACS_INT s, e, e2, p, len; + int modified = 0; struct gcpro gcpro1, gcpro2; i = validate_interval_range (src, &start, &end, soft); @@ -1944,8 +1896,7 @@ copy_text_properties (start, end, src, pos, dest, prop) doesn't contain text properties between START and END. */ Lisp_Object -text_property_list (object, start, end, prop) - Lisp_Object object, start, end, prop; +text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object prop) { struct interval *i; Lisp_Object result; @@ -1955,12 +1906,12 @@ text_property_list (object, start, end, prop) i = validate_interval_range (object, &start, &end, soft); if (!NULL_INTERVAL_P (i)) { - int s = XINT (start); - int e = XINT (end); + EMACS_INT s = XINT (start); + EMACS_INT e = XINT (end); while (s < e) { - int interval_end, len; + EMACS_INT interval_end, len; Lisp_Object plist; interval_end = i->position + LENGTH (i); @@ -2002,8 +1953,7 @@ text_property_list (object, start, end, prop) non-zero if OBJECT was modified. */ int -add_text_properties_from_list (object, list, delta) - Lisp_Object object, list, delta; +add_text_properties_from_list (Lisp_Object object, Lisp_Object list, Lisp_Object delta) { struct gcpro gcpro1, gcpro2; int modified_p = 0; @@ -2036,11 +1986,10 @@ add_text_properties_from_list (object, list, delta) end-points to NEW_END. */ Lisp_Object -extend_property_ranges (list, new_end) - Lisp_Object list, new_end; +extend_property_ranges (Lisp_Object list, Lisp_Object new_end) { Lisp_Object prev = Qnil, head = list; - int max = XINT (new_end); + EMACS_INT max = XINT (new_end); for (; CONSP (list); prev = list, list = XCDR (list)) { @@ -2072,8 +2021,7 @@ extend_property_ranges (list, new_end) /* Call the modification hook functions in LIST, each with START and END. */ static void -call_mod_hooks (list, start, end) - Lisp_Object list, start, end; +call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end) { struct gcpro gcpro1; GCPRO1 (list); @@ -2094,9 +2042,7 @@ call_mod_hooks (list, start, end) those hooks in order, with START and END - 1 as arguments. */ void -verify_interval_modification (buf, start, end) - struct buffer *buf; - int start, end; +verify_interval_modification (struct buffer *buf, int start, int end) { register INTERVAL intervals = BUF_INTERVALS (buf); register INTERVAL i; @@ -2117,7 +2063,7 @@ verify_interval_modification (buf, start, end) if (start > end) { - int temp = start; + EMACS_INT temp = start; start = end; end = temp; } @@ -2274,8 +2220,7 @@ verify_interval_modification (buf, start, end) so it can indicate the range of inserted text. */ void -report_interval_modification (start, end) - Lisp_Object start, end; +report_interval_modification (Lisp_Object start, Lisp_Object end) { if (! NILP (interval_insert_behind_hooks)) call_mod_hooks (interval_insert_behind_hooks, start, end); @@ -2286,7 +2231,7 @@ report_interval_modification (start, end) } void -syms_of_textprop () +syms_of_textprop (void) { DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties, doc: /* Property-list used as default values. diff --git a/src/tparam.c b/src/tparam.c index dcf79a3b617..d8a8f0260f0 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -18,66 +18,14 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - -#ifdef emacs #include <setjmp.h> #include "lisp.h" /* for xmalloc */ -#else - -#ifdef STDC_HEADERS -#include <stdlib.h> -#include <string.h> -#else -char *malloc (); -char *realloc (); -#endif - -/* Do this after the include, in case string.h prototypes bcopy. */ -#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy) -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif - -#endif /* not emacs */ #ifndef NULL #define NULL (char *) 0 #endif -#ifndef emacs -static void -memory_out () -{ - write (2, "virtual memory exhausted\n", 25); - exit (1); -} - -static char * -xmalloc (size) - unsigned size; -{ - register char *tem = malloc (size); - - if (!tem) - memory_out (); - return tem; -} - -static char * -xrealloc (ptr, size) - char *ptr; - unsigned size; -{ - register char *tem = realloc (ptr, size); - - if (!tem) - memory_out (); - return tem; -} -#endif /* not emacs */ - /* Assuming STRING is the value of a termcap string entry containing `%' constructs to expand parameters, merge in parameter values and store result in block OUTSTRING points to. @@ -90,15 +38,11 @@ xrealloc (ptr, size) The fourth and following args to tparam serve as the parameter values. */ -static char *tparam1 (); +static char *tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp); /* VARARGS 2 */ char * -tparam (string, outstring, len, arg0, arg1, arg2, arg3) - char *string; - char *outstring; - int len; - int arg0, arg1, arg2, arg3; +tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3) { int arg[4]; @@ -115,9 +59,7 @@ char *UP; static char tgoto_buf[50]; char * -tgoto (cm, hpos, vpos) - char *cm; - int hpos, vpos; +tgoto (char *cm, int hpos, int vpos) { int args[2]; if (!cm) @@ -128,12 +70,7 @@ tgoto (cm, hpos, vpos) } static char * -tparam1 (string, outstring, len, up, left, argp) - char *string; - char *outstring; - int len; - char *up, *left; - register int *argp; +tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp) { register int c; register char *p = string; @@ -162,7 +99,7 @@ tparam1 (string, outstring, len, up, left, argp) { outlen = len + 40; new = (char *) xmalloc (outlen); - bcopy (outstring, new, offset); + memcpy (new, outstring, offset); } else { diff --git a/src/undo.c b/src/undo.c index b678c5c58ba..cd3ad97349b 100644 --- a/src/undo.c +++ b/src/undo.c @@ -67,8 +67,7 @@ int undo_inhibit_record_point; undo record that will be added just after this command terminates. */ static void -record_point (pt) - int pt; +record_point (EMACS_INT pt) { int at_boundary; @@ -130,8 +129,7 @@ record_point (pt) because we don't need to record the contents.) */ void -record_insert (beg, length) - int beg, length; +record_insert (EMACS_INT beg, EMACS_INT length) { Lisp_Object lbeg, lend; @@ -166,9 +164,7 @@ record_insert (beg, length) of the characters in STRING, at location BEG. */ void -record_delete (beg, string) - int beg; - Lisp_Object string; +record_delete (EMACS_INT beg, Lisp_Object string) { Lisp_Object sbeg; @@ -196,9 +192,7 @@ record_delete (beg, string) won't be inverted automatically by undoing the buffer modification. */ void -record_marker_adjustment (marker, adjustment) - Lisp_Object marker; - int adjustment; +record_marker_adjustment (Lisp_Object marker, EMACS_INT adjustment) { if (EQ (current_buffer->undo_list, Qt)) return; @@ -221,8 +215,7 @@ record_marker_adjustment (marker, adjustment) The replacement must not change the number of characters. */ void -record_change (beg, length) - int beg, length; +record_change (EMACS_INT beg, EMACS_INT length) { record_delete (beg, make_buffer_string (beg, beg + length, 1)); record_insert (beg, length); @@ -233,7 +226,7 @@ record_change (beg, length) we can tell whether it is obsolete because the file was saved again. */ void -record_first_change () +record_first_change (void) { Lisp_Object high, low; struct buffer *base_buffer = current_buffer; @@ -257,9 +250,9 @@ record_first_change () for LENGTH characters starting at position BEG in BUFFER. */ void -record_property_change (beg, length, prop, value, buffer) - int beg, length; - Lisp_Object prop, value, buffer; +record_property_change (EMACS_INT beg, EMACS_INT length, + Lisp_Object prop, Lisp_Object value, + Lisp_Object buffer) { Lisp_Object lbeg, lend, entry; struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer); @@ -297,7 +290,7 @@ DEFUN ("undo-boundary", Fundo_boundary, Sundo_boundary, 0, 0, 0, doc: /* Mark a boundary between units of undo. An undo command will stop at this point, but another undo command will undo to the previous boundary. */) - () + (void) { Lisp_Object tem; if (EQ (current_buffer->undo_list, Qt)) @@ -328,8 +321,7 @@ but another undo command will undo to the previous boundary. */) In some cases this works by calling undo-outer-limit-function. */ void -truncate_undo_list (b) - struct buffer *b; +truncate_undo_list (struct buffer *b) { Lisp_Object list; Lisp_Object prev, next, last_boundary; @@ -465,8 +457,7 @@ truncate_undo_list (b) DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, doc: /* Undo N records from the front of the list LIST. Return what remains of the list. */) - (n, list) - Lisp_Object n, list; + (Lisp_Object n, Lisp_Object list) { struct gcpro gcpro1, gcpro2; Lisp_Object next; @@ -612,7 +603,7 @@ Return what remains of the list. */) { /* Element (STRING . POS) means STRING was deleted. */ Lisp_Object membuf; - int pos = XINT (cdr); + EMACS_INT pos = XINT (cdr); membuf = car; if (pos < 0) @@ -665,7 +656,7 @@ Return what remains of the list. */) } void -syms_of_undo () +syms_of_undo (void) { Qinhibit_read_only = intern_c_string ("inhibit-read-only"); staticpro (&Qinhibit_read_only); diff --git a/src/unexaix.c b/src/unexaix.c index 97b69d7e5c7..2d128bc6806 100644 --- a/src/unexaix.c +++ b/src/unexaix.c @@ -31,33 +31,17 @@ what you give them. Help stamp out software-hoarding! */ * Mike Sperber <sperber@informatik.uni-tuebingen.de> * * Synopsis: - * unexec (new_name, a_name, data_start, bss_start, entry_address) - * char *new_name, *a_name; - * unsigned data_start, bss_start, entry_address; + * unexec (const char *new_name, const *old_name); * * Takes a snapshot of the program and makes an a.out format file in the * file named by the string argument new_name. * If a_name is non-NULL, the symbol table will be taken from the given file. * On some machines, an existing a_name file is required. * - * data_start and entry_address are ignored. - * - * bss_start indicates how much of the data segment is to be saved in the - * a.out file and restored when the program is executed. It gives the lowest - * unsaved address, and is rounded up to a page boundary. The default when 0 - * is given assumes that the entire data segment is to be stored, including - * the previous data and bss as well as any additional storage allocated with - * sbrk(2). - * */ -#ifndef emacs -#define PERROR(arg) perror (arg); return -1 -#else #include <config.h> #define PERROR(file) report_error (file, new) -#endif - #include <a.out.h> /* Define getpagesize () if the system does not. Note that this may depend on symbols defined in a.out.h @@ -71,7 +55,7 @@ what you give them. Help stamp out software-hoarding! */ #include <unistd.h> #include <fcntl.h> -extern char *start_of_text (void); /* Start of text */ +char *start_of_text (void); /* Start of text */ extern char *start_of_data (void); /* Start of initialized data */ extern int _data; @@ -103,7 +87,6 @@ static int adjust_lnnoptrs (int, int, char *); static int pagemask; -#ifdef emacs #include <setjmp.h> #include "lisp.h" @@ -114,7 +97,6 @@ report_error (char *file, int fd) close (fd); report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); } -#endif /* emacs */ #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 @@ -124,12 +106,7 @@ static void report_error_1 (int fd, char *msg, int a1, int a2) { close (fd); -#ifdef emacs error (msg, a1, a2); -#else - fprintf (stderr, msg, a1, a2); - fprintf (stderr, "\n"); -#endif } static int make_hdr (int, int, unsigned, unsigned, unsigned, char *, char *); @@ -143,10 +120,7 @@ static void write_segment (int, char *, char *); * * driving logic. */ -int unexec (char *new_name, char *a_name, - unsigned data_start, - unsigned bss_start, - unsigned entry_address) +int unexec (const char *new_name, const char *a_name) { int new = -1, a_out = -1; @@ -159,8 +133,6 @@ int unexec (char *new_name, char *a_name, PERROR (new_name); } if (make_hdr (new, a_out, - data_start, bss_start, - entry_address, a_name, new_name) < 0 || copy_text_and_data (new) < 0 || copy_sym (new, a_out, a_name, new_name) < 0 @@ -186,12 +158,11 @@ int unexec (char *new_name, char *a_name, */ static int make_hdr (int new, int a_out, - unsigned data_start, unsigned bss_start, - unsigned entry_address, char *a_name, char *new_name) { int scns; - unsigned int bss_end; + unsigned int bss_start; + unsigned int data_start; struct scnhdr section[MAX_SECTIONS]; struct scnhdr * f_thdr; /* Text section header */ @@ -211,22 +182,8 @@ make_hdr (int new, int a_out, data_start = data_start & ~pagemask; /* (Down) to page boundary. */ - bss_end = ADDR_CORRECT (sbrk (0)) + pagemask; - bss_end &= ~ pagemask; - /* Adjust data/bss boundary. */ - if (bss_start != 0) - { - bss_start = (ADDR_CORRECT (bss_start) + pagemask); - /* (Up) to page bdry. */ - bss_start &= ~ pagemask; - if (bss_start > bss_end) - { - ERROR1 ("unexec: Specified bss_start (%u) is past end of program", - bss_start); - } - } - else - bss_start = bss_end; + bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; + bss_start &= ~ pagemask; if (data_start > bss_start) /* Can't have negative data size. */ { @@ -311,7 +268,7 @@ make_hdr (int new, int a_out, f_hdr.f_flags |= (F_RELFLG | F_EXEC); f_ohdr.dsize = bss_start - f_ohdr.data_start; - f_ohdr.bsize = bss_end - bss_start; + f_ohdr.bsize = 0; f_dhdr->s_size = f_ohdr.dsize; f_bhdr->s_size = f_ohdr.bsize; @@ -435,7 +392,6 @@ write_segment (int new, char *ptr, char *end) { int i, nwrite, ret; char buf[80]; - extern int errno; char zeros[UnexBlockSz]; for (i = 0; ptr < end;) @@ -670,5 +626,18 @@ unrelocate_symbols (int new, int a_out, char *a_name, char *new_name) return 0; } +/* + * Return the address of the start of the text segment prior to + * doing an unexec. After unexec the return value is undefined. + * See crt0.c for further explanation and _start. + * + */ + +char * +start_of_text (void) +{ + return ((char *) 0x10000000); +} + /* arch-tag: 0783857a-7c2d-456f-a426-58b722d69fd0 (do not change this comment) */ diff --git a/src/unexalpha.c b/src/unexalpha.c deleted file mode 100644 index 13c1def5714..00000000000 --- a/src/unexalpha.c +++ /dev/null @@ -1,539 +0,0 @@ -/* Unexec for DEC alpha. - - Copyright (C) 1994, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. - -Author: Rainer Schoepf <schoepf@sc.ZIB-Berlin.DE> - -This file is part of GNU Emacs. - -GNU Emacs is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -GNU Emacs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ - - -#include <config.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <stdio.h> -#include <errno.h> -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#if !defined (__NetBSD__) && !defined (__OpenBSD__) -#include <filehdr.h> -#include <aouthdr.h> -#include <scnhdr.h> -#include <syms.h> -#ifndef __linux__ -# include <reloc.h> -# include <elf_abi.h> -#endif -#else /* __NetBSD__ or __OpenBSD__ */ -/* - * NetBSD/Alpha does not have 'normal' user-land ECOFF support because - * there's no desire to support ECOFF as the executable format in the - * long term. - */ -#include <sys/exec_ecoff.h> - -/* Structures, constants, etc., that NetBSD defines strangely. */ -#define filehdr ecoff_filehdr -#define aouthdr ecoff_aouthdr -#define scnhdr ecoff_scnhdr -#define HDRR struct ecoff_symhdr -#define pHDRR HDRR * -#define cbHDRR sizeof(HDRR) -#ifdef __OpenBSD__ -#define ALPHAMAGIC ECOFF_MAGIC_NATIVE_ALPHA -#else -#define ALPHAMAGIC ECOFF_MAGIC_NETBSD_ALPHA -#endif -#define ZMAGIC ECOFF_ZMAGIC - -/* Misc. constants that NetBSD doesn't define at all. */ -#define ALPHAUMAGIC 0617 -#define _MIPS_NSCNS_MAX 35 -#define STYP_TEXT 0x00000020 -#define STYP_DATA 0x00000040 -#define STYP_BSS 0x00000080 -#define STYP_RDATA 0x00000100 -#define STYP_SDATA 0x00000200 -#define STYP_SBSS 0x00000400 -#define STYP_INIT 0x80000000 -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" -#define _INIT ".init" -#define _RDATA ".rdata" -#define _SDATA ".sdata" -#define _SBSS ".sbss" -#endif /* __NetBSD__ || __OpenBSD__ */ - -static void fatal_unexec __P ((char *, char *)); -static void mark_x __P ((char *)); - -static void update_dynamic_symbols __P ((char *, char *, int, struct aouthdr)); - -#define READ(_fd, _buffer, _size, _error_message, _error_arg) \ - errno = EEOF; \ - if (read (_fd, _buffer, _size) != _size) \ - fatal_unexec (_error_message, _error_arg); - -#define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \ - if (write (_fd, _buffer, _size) != _size) \ - fatal_unexec (_error_message, _error_arg); - -#define SEEK(_fd, _position, _error_message, _error_arg) \ - errno = EEOF; \ - if (lseek (_fd, _position, L_SET) != _position) \ - fatal_unexec (_error_message, _error_arg); - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#else -void *sbrk (); -#endif - -#define EEOF -1 - -static struct scnhdr *text_section; -static struct scnhdr *rel_dyn_section; -static struct scnhdr *dynstr_section; -static struct scnhdr *dynsym_section; -static struct scnhdr *init_section; -static struct scnhdr *finit_section; -static struct scnhdr *rdata_section; -static struct scnhdr *rconst_section; -static struct scnhdr *data_section; -static struct scnhdr *pdata_section; -static struct scnhdr *xdata_section; -static struct scnhdr *got_section; -static struct scnhdr *lit8_section; -static struct scnhdr *lit4_section; -static struct scnhdr *sdata_section; -static struct scnhdr *sbss_section; -static struct scnhdr *bss_section; - -static struct scnhdr old_data_scnhdr; - -static unsigned long Brk; - -struct headers { - struct filehdr fhdr; - struct aouthdr aout; - struct scnhdr section[_MIPS_NSCNS_MAX]; -}; - - -void -unexec (new_name, a_name, data_start, bss_start, entry_address) - char *new_name, *a_name; - unsigned long data_start, bss_start, entry_address; -{ - int new, old; - char * oldptr; - struct headers ohdr, nhdr; - struct stat stat; - long pagesize, brk; - long newsyms, symrel; - int nread; - int i; - long vaddr, scnptr; -#define BUFSIZE 8192 - char buffer[BUFSIZE]; - - if ((old = open (a_name, O_RDONLY)) < 0) - fatal_unexec ("opening %s", a_name); - - new = creat (new_name, 0666); - if (new < 0) fatal_unexec ("creating %s", new_name); - - if ((fstat (old, &stat) == -1)) - fatal_unexec ("fstat %s", a_name); - - oldptr = (char *)mmap (0, stat.st_size, PROT_READ, MAP_FILE|MAP_SHARED, old, 0); - - if (oldptr == (char *)-1) - fatal_unexec ("mmap %s", a_name); - - close (old); - - /* This is a copy of the a.out header of the original executable */ - - ohdr = (*(struct headers *)oldptr); - - /* This is where we build the new header from the in-memory copy */ - - nhdr = *((struct headers *)TEXT_START); - - /* First do some consistency checks */ - - if (nhdr.fhdr.f_magic != ALPHAMAGIC - && nhdr.fhdr.f_magic != ALPHAUMAGIC) - { - fprintf (stderr, "unexec: input file magic number is %x, not %x or %x.\n", - nhdr.fhdr.f_magic, ALPHAMAGIC, ALPHAUMAGIC); - exit (1); - } - - if (nhdr.fhdr.f_opthdr != sizeof (nhdr.aout)) - { - fprintf (stderr, "unexec: input a.out header is %d bytes, not %d.\n", - nhdr.fhdr.f_opthdr, (int)sizeof (nhdr.aout)); - exit (1); - } - if (nhdr.aout.magic != ZMAGIC) - { - fprintf (stderr, "unexec: input file a.out magic number is %o, not %o.\n", - nhdr.aout.magic, ZMAGIC); - exit (1); - } - - - /* Now check the existence of certain header section and grab - their addresses. */ - -#define CHECK_SCNHDR(ptr, name, flags) \ - ptr = NULL; \ - for (i = 0; i < nhdr.fhdr.f_nscns && !ptr; i++) \ - if (strncmp (nhdr.section[i].s_name, name, 8) == 0) \ - { \ - if (nhdr.section[i].s_flags != flags) \ - fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \ - nhdr.section[i].s_flags, flags, name); \ - ptr = nhdr.section + i; \ - } \ - - CHECK_SCNHDR (text_section, _TEXT, STYP_TEXT); - CHECK_SCNHDR (init_section, _INIT, STYP_INIT); -#ifdef _REL_DYN - CHECK_SCNHDR (rel_dyn_section, _REL_DYN, STYP_REL_DYN); -#endif /* _REL_DYN */ -#ifdef _DYNSYM - CHECK_SCNHDR (dynsym_section, _DYNSYM, STYP_DYNSYM); -#endif /* _REL_DYN */ -#ifdef _DYNSTR - CHECK_SCNHDR (dynstr_section, _DYNSTR, STYP_DYNSTR); -#endif /* _REL_DYN */ -#ifdef _FINI - CHECK_SCNHDR (finit_section, _FINI, STYP_FINI); -#endif /* _FINI */ - CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA); -#ifdef _RCONST - CHECK_SCNHDR (rconst_section, _RCONST, STYP_RCONST); -#endif -#ifdef _PDATA - CHECK_SCNHDR (pdata_section, _PDATA, STYP_PDATA); -#endif /* _PDATA */ -#ifdef _GOT - CHECK_SCNHDR (got_section, _GOT, STYP_GOT); -#endif /* _GOT */ - CHECK_SCNHDR (data_section, _DATA, STYP_DATA); -#ifdef _XDATA - CHECK_SCNHDR (xdata_section, _XDATA, STYP_XDATA); -#endif /* _XDATA */ -#ifdef _LIT8 - CHECK_SCNHDR (lit8_section, _LIT8, STYP_LIT8); - CHECK_SCNHDR (lit4_section, _LIT4, STYP_LIT4); -#endif /* _LIT8 */ - CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA); - CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS); - CHECK_SCNHDR (bss_section, _BSS, STYP_BSS); - - - pagesize = getpagesize (); - brk = (((long) (sbrk (0))) + pagesize - 1) & (-pagesize); - - /* Remember the current break */ - - Brk = brk; - - bcopy (data_section, &old_data_scnhdr, sizeof (old_data_scnhdr)); - - nhdr.aout.dsize = brk - DATA_START; - nhdr.aout.bsize = 0; - if (entry_address == 0) - { - extern __start (); - nhdr.aout.entry = (unsigned long)__start; - } - else - nhdr.aout.entry = entry_address; - - nhdr.aout.bss_start = nhdr.aout.data_start + nhdr.aout.dsize; - - if (rdata_section != NULL) - { - rdata_section->s_size = data_start - DATA_START; - - /* Adjust start and virtual addresses of rdata_section, too. */ - rdata_section->s_vaddr = DATA_START; - rdata_section->s_paddr = DATA_START; - rdata_section->s_scnptr = text_section->s_scnptr + nhdr.aout.tsize; - } - - data_section->s_vaddr = data_start; - data_section->s_paddr = data_start; - data_section->s_size = brk - data_start; - - if (rdata_section != NULL) - { - data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size; - } - - vaddr = data_section->s_vaddr + data_section->s_size; - scnptr = data_section->s_scnptr + data_section->s_size; - if (lit8_section != NULL) - { - lit8_section->s_vaddr = vaddr; - lit8_section->s_paddr = vaddr; - lit8_section->s_size = 0; - lit8_section->s_scnptr = scnptr; - } - if (lit4_section != NULL) - { - lit4_section->s_vaddr = vaddr; - lit4_section->s_paddr = vaddr; - lit4_section->s_size = 0; - lit4_section->s_scnptr = scnptr; - } - if (sdata_section != NULL) - { - sdata_section->s_vaddr = vaddr; - sdata_section->s_paddr = vaddr; - sdata_section->s_size = 0; - sdata_section->s_scnptr = scnptr; - } -#ifdef _XDATA - if (xdata_section != NULL) - { - xdata_section->s_vaddr = vaddr; - xdata_section->s_paddr = vaddr; - xdata_section->s_size = 0; - xdata_section->s_scnptr = scnptr; - } -#endif -#ifdef _GOT - if (got_section != NULL) - { - bcopy (got_section, buffer, sizeof (struct scnhdr)); - - got_section->s_vaddr = vaddr; - got_section->s_paddr = vaddr; - got_section->s_size = 0; - got_section->s_scnptr = scnptr; - } -#endif /*_GOT */ - if (sbss_section != NULL) - { - sbss_section->s_vaddr = vaddr; - sbss_section->s_paddr = vaddr; - sbss_section->s_size = 0; - sbss_section->s_scnptr = scnptr; - } - if (bss_section != NULL) - { - bss_section->s_vaddr = vaddr; - bss_section->s_paddr = vaddr; - bss_section->s_size = 0; - bss_section->s_scnptr = scnptr; - } - - WRITE (new, (char *)TEXT_START, nhdr.aout.tsize, - "writing text section to %s", new_name); - WRITE (new, (char *)DATA_START, nhdr.aout.dsize, - "writing data section to %s", new_name); - -#ifdef _GOT -#define old_got_section ((struct scnhdr *)buffer) - - if (got_section != NULL) - { - SEEK (new, old_got_section->s_scnptr, - "seeking to start of got_section in %s", new_name); - WRITE (new, oldptr + old_got_section->s_scnptr, old_got_section->s_size, - "writing new got_section of %s", new_name); - SEEK (new, nhdr.aout.tsize + nhdr.aout.dsize, - "seeking to end of data section of %s", new_name); - } - -#undef old_got_section -#endif - - /* - * Construct new symbol table header - */ - - bcopy (oldptr + nhdr.fhdr.f_symptr, buffer, cbHDRR); - -#define symhdr ((pHDRR)buffer) - newsyms = nhdr.aout.tsize + nhdr.aout.dsize; - symrel = newsyms - nhdr.fhdr.f_symptr; - nhdr.fhdr.f_symptr = newsyms; - symhdr->cbLineOffset += symrel; - symhdr->cbDnOffset += symrel; - symhdr->cbPdOffset += symrel; - symhdr->cbSymOffset += symrel; - symhdr->cbOptOffset += symrel; - symhdr->cbAuxOffset += symrel; - symhdr->cbSsOffset += symrel; - symhdr->cbSsExtOffset += symrel; - symhdr->cbFdOffset += symrel; - symhdr->cbRfdOffset += symrel; - symhdr->cbExtOffset += symrel; - - WRITE (new, buffer, cbHDRR, "writing symbol table header of %s", new_name); - - /* - * Copy the symbol table and line numbers - */ - WRITE (new, oldptr + ohdr.fhdr.f_symptr + cbHDRR, - stat.st_size - ohdr.fhdr.f_symptr - cbHDRR, - "writing symbol table of %s", new_name); - -#ifdef _REL_DYN - if (rel_dyn_section) - update_dynamic_symbols (oldptr, new_name, new, nhdr.aout); -#endif - -#undef symhdr - - SEEK (new, 0, "seeking to start of header in %s", new_name); - WRITE (new, &nhdr, sizeof (nhdr), - "writing header of %s", new_name); - - close (old); - close (new); - mark_x (new_name); -} - - -static void -update_dynamic_symbols (old, new_name, new, aout) - char *old; /* Pointer to old executable */ - char *new_name; /* Name of new executable */ - int new; /* File descriptor for new executable */ - struct aouthdr aout; /* a.out info from the file header */ -{ -#if !defined (__linux__) && !defined (__NetBSD__) && !defined (__OpenBSD__) - - typedef struct dynrel_info { - char * addr; - unsigned type:8; - unsigned index:24; - unsigned info:8; - unsigned pad:8; - } dr_info; - - int nsyms = rel_dyn_section->s_size / sizeof (struct dynrel_info); - int i; - dr_info * rd_base = (dr_info *) (old + rel_dyn_section->s_scnptr); - Elf32_Sym * ds_base = (Elf32_Sym *) (old + dynsym_section->s_scnptr); - - for (i = 0; i < nsyms; i++) { - register Elf32_Sym x; - - if (rd_base[i].index == 0) - continue; - - x = ds_base[rd_base[i].index]; - -#if 0 - fprintf (stderr, "Object inspected: %s, addr = %lx, shndx = %x", - old + dynstr_section->s_scnptr + x.st_name, rd_base[i].addr, x.st_shndx); -#endif - - - if ((ELF32_ST_BIND (x.st_info) == STB_GLOBAL) - && (x.st_shndx == 0) - /* && (x.st_value == NULL) */ - ) { - /* OK, this is probably a reference to an object in a shared - library, so copy the old value. This is done in several steps: - 1. reladdr is the address of the location in question relative to - the start of the data section, - 2. oldref is the addr is the mapped in temacs executable, - 3. newref is the address of the location in question in the - undumped executable, - 4. len is the size of the object reference in bytes -- - currently only 4 (long) and 8 (quad) are supported. - */ - register unsigned long reladdr = (long)rd_base[i].addr - old_data_scnhdr.s_vaddr; - char * oldref = old + old_data_scnhdr.s_scnptr + reladdr; - unsigned long newref = aout.tsize + reladdr; - int len; - -#if 0 - fprintf (stderr, "...relocated\n"); -#endif - - if (rd_base[i].type == R_REFLONG) - len = 4; - else if (rd_base[i].type == R_REFQUAD) - len = 8; - else - fatal_unexec ("unrecognized relocation type in .dyn.rel section (symbol #%d)", (char *) i); - - SEEK (new, newref, "seeking to dynamic symbol in %s", new_name); - WRITE (new, oldref, len, "writing old dynrel info in %s", new_name); - } - -#if 0 - else - fprintf (stderr, "...not relocated\n"); -#endif - - } - -#endif /* not __linux__ and not __NetBSD__ and not __OpenBSD__ */ -} - - -/* - * mark_x - * - * After successfully building the new a.out, mark it executable - */ - -static void -mark_x (name) - char *name; -{ - struct stat sbuf; - int um = umask (777); - umask (um); - if (stat (name, &sbuf) < 0) - fatal_unexec ("getting protection on %s", name); - sbuf.st_mode |= 0111 & ~um; - if (chmod (name, sbuf.st_mode) < 0) - fatal_unexec ("setting protection on %s", name); -} - -static void -fatal_unexec (s, arg) - char *s; - char *arg; -{ - if (errno == EEOF) - fputs ("unexec: unexpected end of file, ", stderr); - else - fprintf (stderr, "unexec: %s, ", strerror (errno)); - fprintf (stderr, s, arg); - fputs (".\n", stderr); - exit (1); -} - -/* arch-tag: 46316c49-ee08-4aa3-942b-00798902f5bd - (do not change this comment) */ diff --git a/src/unexec.c b/src/unexcoff.c index d1921069af7..0c6af414d82 100644 --- a/src/unexec.c +++ b/src/unexcoff.c @@ -18,48 +18,29 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* - * unexec.c - Convert a running program into an a.out file. + * unexcoff.c - Convert a running program into an a.out or COFF file. + * + * ================================================================== + * Note: This file is currently used only by the MSDOS (a.k.a. DJGPP) + * build of Emacs. If you are not interested in the MSDOS build, you + * are looking at the wrong version of unexec! + * ================================================================== * * Author: Spencer W. Thomas * Computer Science Dept. * University of Utah * Date: Tue Mar 2 1982 + * Originally under the name unexec.c. * Modified heavily since then. * * Synopsis: - * unexec (new_name, a_name, data_start, bss_start, entry_address) - * char *new_name, *a_name; - * unsigned data_start, bss_start, entry_address; + * unexec (const char *new_name, const char *old_name); * * Takes a snapshot of the program and makes an a.out format file in the * file named by the string argument new_name. * If a_name is non-NULL, the symbol table will be taken from the given file. * On some machines, an existing a_name file is required. * - * The boundaries within the a.out file may be adjusted with the data_start - * and bss_start arguments. Either or both may be given as 0 for defaults. - * - * Data_start gives the boundary between the text segment and the data - * segment of the program. The text segment can contain shared, read-only - * program code and literal data, while the data segment is always unshared - * and unprotected. Data_start gives the lowest unprotected address. - * The value you specify may be rounded down to a suitable boundary - * as required by the machine you are using. - * - * Specifying zero for data_start means the boundary between text and data - * should not be the same as when the program was loaded. - * If NO_REMAP is defined, the argument data_start is ignored and the - * segment boundaries are never changed. - * - * Bss_start indicates how much of the data segment is to be saved in the - * a.out file and restored when the program is executed. It gives the lowest - * unsaved address, and is rounded up to a page boundary. The default when 0 - * is given assumes that the entire data segment is to be stored, including - * the previous data and bss as well as any additional storage allocated with - * break (2). - * - * The new file is set up to start at entry_address. - * * If you make improvements I'd like to get them too. * harpo!utah-cs!thomas, thomas@Utah-20 * @@ -69,73 +50,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ * of Dell Computer Corporation. james@bigtex.cactus.org. */ -/* There are several compilation parameters affecting unexec: - -* COFF - -Define this if your system uses COFF for executables. - -* NO_REMAP - -Define this if you do not want to try to save Emacs's pure data areas -as part of the text segment. - -Saving them as text is good because it allows users to share more. - -However, on machines that locate the text area far from the data area, -the boundary cannot feasibly be moved. Such machines require -NO_REMAP. - -Also, remapping can cause trouble with the built-in startup routine -/lib/crt0.o, which defines `environ' as an initialized variable. -Dumping `environ' as pure does not work! So, to use remapping, -you must write a startup routine for your machine in Emacs's crt0.c. -If NO_REMAP is defined, Emacs uses the system's crt0.o. - -* SECTION_ALIGNMENT - -Some machines that use COFF executables require that each section -start on a certain boundary *in the COFF file*. Such machines should -define SECTION_ALIGNMENT to a mask of the low-order bits that must be -zero on such a boundary. This mask is used to control padding between -segments in the COFF file. - -If SECTION_ALIGNMENT is not defined, the segments are written -consecutively with no attempt at alignment. This is right for -unmodified system V. - -* SEGMENT_MASK - -Some machines require that the beginnings and ends of segments -*in core* be on certain boundaries. For most machines, a page -boundary is sufficient. That is the default. When a larger -boundary is needed, define SEGMENT_MASK to a mask of -the bits that must be zero on such a boundary. - -* ADJUST_EXEC_HEADER - -This macro can be used to generate statements to adjust or -initialize nonstandard fields in the file header - -*/ - -#ifndef emacs -#define PERROR(arg) perror (arg); return -1 -#else #include <config.h> #define PERROR(file) report_error (file, new) -#endif #ifndef CANNOT_DUMP /* all rest of file! */ #ifdef HAVE_COFF_H #include <coff.h> #ifdef MSDOS -#if __DJGPP__ > 1 #include <fcntl.h> /* for O_RDONLY, O_RDWR */ #include <crt0.h> /* for _crt0_startup_flags and its bits */ +#include <sys/exceptn.h> static int save_djgpp_startup_flags; -#endif /* __DJGPP__ > 1 */ #define filehdr external_filehdr #define scnhdr external_scnhdr #define syment external_syment @@ -171,16 +97,7 @@ struct aouthdr #include <sys/file.h> -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif -#ifndef O_RDWR -#define O_RDWR 2 -#endif - - -extern char *start_of_text (); /* Start of text */ -extern char *start_of_data (); /* Start of initialized data */ +extern char *start_of_data (void); /* Start of initialized data */ static long block_copy_start; /* Old executable start point */ static struct filehdr f_hdr; /* File header */ @@ -202,45 +119,33 @@ static int pagemask; #define ADDR_CORRECT(x) ((char *)(x) - (char*)0) -#ifdef emacs - #include <setjmp.h> #include "lisp.h" -static -report_error (file, fd) - char *file; - int fd; +static void +report_error (const char *file, int fd) { if (fd) close (fd); report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); } -#endif /* emacs */ #define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 #define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 -static -report_error_1 (fd, msg, a1, a2) - int fd; - char *msg; - int a1, a2; +static void +report_error_1 (int fd, const char *msg, int a1, int a2) { close (fd); -#ifdef emacs error (msg, a1, a2); -#else - fprintf (stderr, msg, a1, a2); - fprintf (stderr, "\n"); -#endif } -static int make_hdr (); -static int copy_text_and_data (); -static int copy_sym (); -static void mark_x (); +static int make_hdr (int, int, unsigned, unsigned, unsigned, + const char *, const char *); +static int copy_text_and_data (int, int); +static int copy_sym (int, int, const char *, const char *); +static void mark_x (const char *); /* **************************************************************** * make_hdr @@ -249,54 +154,26 @@ static void mark_x (); * Modify the text and data sizes. */ static int -make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) - int new, a_out; - unsigned data_start, bss_start, entry_address; - char *a_name; - char *new_name; +make_hdr (int new, int a_out, + const char *a_name, const char *new_name) { - int tem; auto struct scnhdr f_thdr; /* Text section header */ auto struct scnhdr f_dhdr; /* Data section header */ auto struct scnhdr f_bhdr; /* Bss section header */ auto struct scnhdr scntemp; /* Temporary section header */ register int scns; - unsigned int bss_end; + unsigned int bss_start; + unsigned int data_start; pagemask = getpagesize () - 1; /* Adjust text/data boundary. */ -#ifdef NO_REMAP data_start = (int) start_of_data (); -#else /* not NO_REMAP */ - if (!data_start) - data_start = (int) start_of_data (); -#endif /* not NO_REMAP */ data_start = ADDR_CORRECT (data_start); - -#ifdef SEGMENT_MASK - data_start = data_start & ~SEGMENT_MASK; /* (Down) to segment boundary. */ -#else data_start = data_start & ~pagemask; /* (Down) to page boundary. */ -#endif - bss_end = ADDR_CORRECT (sbrk (0)) + pagemask; - bss_end &= ~ pagemask; - - /* Adjust data/bss boundary. */ - if (bss_start != 0) - { - bss_start = (ADDR_CORRECT (bss_start) + pagemask); - /* (Up) to page bdry. */ - bss_start &= ~ pagemask; - if (bss_start > bss_end) - { - ERROR1 ("unexec: Specified bss_start (%u) is past end of program", - bss_start); - } - } - else - bss_start = bss_end; + bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; + bss_start &= ~ pagemask; if (data_start > bss_start) /* Can't have negative data size. */ { @@ -310,7 +187,6 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) if (a_out >= 0) { #ifdef MSDOS -#if __DJGPP__ > 1 /* Support the coff-go32-exe format with a prepended stub, since this is what GCC 2.8.0 and later generates by default in DJGPP. */ unsigned short mz_header[3]; @@ -328,7 +204,6 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) } else lseek (a_out, 0L, 0); -#endif /* __DJGPP__ > 1 */ #endif /* MSDOS */ if (read (a_out, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr)) { @@ -378,42 +253,17 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) to correspond to what we want to dump. */ f_hdr.f_flags |= (F_RELFLG | F_EXEC); -#ifndef NO_REMAP - f_ohdr.text_start = (long) start_of_text (); - f_ohdr.tsize = data_start - f_ohdr.text_start; - f_ohdr.data_start = data_start; -#endif /* NO_REMAP */ f_ohdr.dsize = bss_start - f_ohdr.data_start; - f_ohdr.bsize = bss_end - bss_start; - /* On some machines, the old values are right. - ??? Maybe on all machines with NO_REMAP. */ + f_ohdr.bsize = 0; f_thdr.s_size = f_ohdr.tsize; f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr); f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr)); lnnoptr = f_thdr.s_lnnoptr; -#ifdef SECTION_ALIGNMENT - /* Some systems require special alignment - of the sections in the file itself. */ - f_thdr.s_scnptr - = (f_thdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT; -#endif /* SECTION_ALIGNMENT */ text_scnptr = f_thdr.s_scnptr; f_dhdr.s_paddr = f_ohdr.data_start; f_dhdr.s_vaddr = f_ohdr.data_start; f_dhdr.s_size = f_ohdr.dsize; f_dhdr.s_scnptr = f_thdr.s_scnptr + f_thdr.s_size; -#ifdef SECTION_ALIGNMENT - /* Some systems require special alignment - of the sections in the file itself. */ - f_dhdr.s_scnptr - = (f_dhdr.s_scnptr + SECTION_ALIGNMENT) & ~SECTION_ALIGNMENT; -#endif /* SECTION_ALIGNMENT */ -#ifdef DATA_SECTION_ALIGNMENT - /* Some systems require special alignment - of the data section only. */ - f_dhdr.s_scnptr - = (f_dhdr.s_scnptr + DATA_SECTION_ALIGNMENT) & ~DATA_SECTION_ALIGNMENT; -#endif /* DATA_SECTION_ALIGNMENT */ data_scnptr = f_dhdr.s_scnptr; f_bhdr.s_paddr = f_ohdr.data_start + f_ohdr.dsize; f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize; @@ -431,10 +281,6 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) f_thdr.s_lnnoptr += bias; } -#ifdef ADJUST_EXEC_HEADER - ADJUST_EXEC_HEADER; -#endif /* ADJUST_EXEC_HEADER */ - if (write (new, &f_hdr, sizeof (f_hdr)) != sizeof (f_hdr)) { PERROR (new_name); @@ -464,22 +310,17 @@ make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) } -write_segment (new, ptr, end) - int new; - register char *ptr, *end; +void +write_segment (int new, const char *ptr, const char *end) { register int i, nwrite, ret; - char buf[80]; -#ifndef USE_CRT_DLL - extern int errno; -#endif /* This is the normal amount to write at once. It is the size of block that NFS uses. */ int writesize = 1 << 13; int pagesize = getpagesize (); char zeros[1 << 13]; - bzero (zeros, sizeof (zeros)); + memset (zeros, 0, sizeof (zeros)); for (i = 0; ptr < end;) { @@ -505,16 +346,6 @@ write_segment (new, ptr, end) nwrite = pagesize; write (new, zeros, nwrite); } -#if 0 /* Now that we have can ask `write' to write more than a page, - it is legit for write do less than the whole amount specified. */ - else if (nwrite != ret) - { - sprintf (buf, - "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d", - ptr, new, nwrite, ret, errno); - PERROR (buf); - } -#endif i += nwrite; ptr += nwrite; } @@ -525,14 +356,12 @@ write_segment (new, ptr, end) * Copy the text and data segments from memory to the new a.out */ static int -copy_text_and_data (new, a_out) - int new, a_out; +copy_text_and_data (int new, int a_out) { register char *end; register char *ptr; #ifdef MSDOS -#if __DJGPP__ >= 2 /* Dump the original table of exception handlers, not the one where our exception hooks are registered. */ __djgpp_exception_toggle (); @@ -542,7 +371,6 @@ copy_text_and_data (new, a_out) save_djgpp_startup_flags = _crt0_startup_flags; _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR); #endif -#endif lseek (new, (long) text_scnptr, 0); ptr = (char *) f_ohdr.text_start; @@ -555,14 +383,12 @@ copy_text_and_data (new, a_out) write_segment (new, ptr, end); #ifdef MSDOS -#if __DJGPP__ >= 2 /* Restore our exception hooks. */ __djgpp_exception_toggle (); /* Restore the startup flags. */ _crt0_startup_flags = save_djgpp_startup_flags; #endif -#endif return 0; @@ -574,9 +400,7 @@ copy_text_and_data (new, a_out) * Copy the relocation information and symbol table from the a.out to the new */ static int -copy_sym (new, a_out, a_name, new_name) - int new, a_out; - char *a_name, *new_name; +copy_sym (int new, int a_out, const char *a_name, const char *new_name) { char page[1024]; int n; @@ -612,8 +436,7 @@ copy_sym (new, a_out, a_name, new_name) * After successfully building the new a.out, mark it executable */ static void -mark_x (name) - char *name; +mark_x (const char *name) { struct stat sbuf; int um; @@ -630,7 +453,6 @@ mark_x (name) PERROR (name); } -#ifndef COFF_BSD_SYMBOLS /* * If the COFF file contains a symbol table and a line number section, @@ -654,10 +476,8 @@ mark_x (name) a reasonable size buffer. But I don't have time to work on such things, so I am installing it as submitted to me. -- RMS. */ -adjust_lnnoptrs (writedesc, readdesc, new_name) - int writedesc; - int readdesc; - char *new_name; +int +adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name) { register int nsyms; register int new; @@ -699,18 +519,15 @@ adjust_lnnoptrs (writedesc, readdesc, new_name) return 0; } -#endif /* COFF_BSD_SYMBOLS */ - /* **************************************************************** * unexec * * driving logic. */ -unexec (new_name, a_name, data_start, bss_start, entry_address) - char *new_name, *a_name; - unsigned data_start, bss_start, entry_address; +int +unexec (const char *new_name, const char *a_name) { - int new, a_out = -1; + int new = -1, a_out = -1; if (a_name && (a_out = open (a_name, O_RDONLY)) < 0) { @@ -721,16 +538,13 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) PERROR (new_name); } - if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0 + if (make_hdr (new, a_out, a_name, new_name) < 0 || copy_text_and_data (new, a_out) < 0 || copy_sym (new, a_out, a_name, new_name) < 0 -#ifndef COFF_BSD_SYMBOLS || adjust_lnnoptrs (new, a_out, new_name) < 0 -#endif ) { close (new); - /* unlink (new_name); /* Failed, unlink new a.out */ return -1; } diff --git a/src/unexcw.c b/src/unexcw.c index 4930eb46315..c33d9d90215 100644 --- a/src/unexcw.c +++ b/src/unexcw.c @@ -248,8 +248,7 @@ add_exe_suffix_if_necessary (const char *name, char *modified) } int -unexec (char *outfile, char *infile, unsigned start_data, unsigned d1, - unsigned d2) +unexec (const char *outfile, const char *infile) { char infile_buffer[FILENAME_MAX]; char outfile_buffer[FILENAME_MAX]; diff --git a/src/unexelf.c b/src/unexelf.c index a91af9458eb..605b9f75ac0 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -33,34 +33,13 @@ what you give them. Help stamp out software-hoarding! */ * Modified heavily since then. * * Synopsis: - * unexec (new_name, old_name, data_start, bss_start, entry_address) - * char *new_name, *old_name; - * unsigned data_start, bss_start, entry_address; + * unexec (const char *new_name, const char *old_name); * * Takes a snapshot of the program and makes an a.out format file in the * file named by the string argument new_name. * If old_name is non-NULL, the symbol table will be taken from the given file. * On some machines, an existing old_name file is required. * - * The boundaries within the a.out file may be adjusted with the data_start - * and bss_start arguments. Either or both may be given as 0 for defaults. - * - * Data_start gives the boundary between the text segment and the data - * segment of the program. The text segment can contain shared, read-only - * program code and literal data, while the data segment is always unshared - * and unprotected. Data_start gives the lowest unprotected address. - * The value you specify may be rounded down to a suitable boundary - * as required by the machine you are using. - * - * Bss_start indicates how much of the data segment is to be saved in the - * a.out file and restored when the program is executed. It gives the lowest - * unsaved address, and is rounded up to a page boundary. The default when 0 - * is given assumes that the entire data segment is to be stored, including - * the previous data and bss as well as any additional storage allocated with - * break (2). - * - * The new file is set up to start at entry_address. - * */ /* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co. @@ -407,13 +386,8 @@ temacs: /* We do not use mmap because that fails with NFS. Instead we read the whole file, modify it, and write it out. */ -#ifndef emacs -#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) -#include <string.h> -#else #include <config.h> extern void fatal (const char *msgid, ...); -#endif #include <sys/types.h> #include <stdio.h> @@ -424,7 +398,7 @@ extern void fatal (const char *msgid, ...); #include <fcntl.h> #if !defined (__NetBSD__) && !defined (__OpenBSD__) #include <elf.h> -#endif +#endif /* not __NetBSD__ and not __OpenBSD__ */ #include <sys/mman.h> #if defined (_SYSTYPE_SYSV) #include <sys/elf_mips.h> @@ -594,8 +568,7 @@ typedef unsigned char byte; /* Round X up to a multiple of Y. */ static ElfW(Addr) -round_up (x, y) - ElfW(Addr) x, y; +round_up (ElfW(Addr) x, ElfW(Addr) y) { int rem = x % y; if (rem == 0) @@ -611,13 +584,8 @@ round_up (x, y) if NOERROR is 0; we return -1 if NOERROR is nonzero. */ static int -find_section (name, section_names, file_name, old_file_h, old_section_h, noerror) - char *name; - char *section_names; - char *file_name; - ElfW(Ehdr) *old_file_h; - ElfW(Shdr) *old_section_h; - int noerror; +find_section (const char *name, const char *section_names, const char *file_name, + ElfW(Ehdr) *old_file_h, ElfW(Shdr) *old_section_h, int noerror) { int idx; @@ -652,9 +620,7 @@ find_section (name, section_names, file_name, old_file_h, old_section_h, noerror * */ void -unexec (new_name, old_name, data_start, bss_start, entry_address) - char *new_name, *old_name; - unsigned data_start, bss_start, entry_address; +unexec (const char *new_name, const char *old_name) { int new_file, old_file, new_file_size; @@ -1316,13 +1282,8 @@ temacs: /* Write out new_file, and free the buffers. */ if (write (new_file, new_base, new_file_size) != new_file_size) -#ifndef emacs - fatal ("Didn't write %d bytes: errno %d\n", - new_file_size, errno); -#else fatal ("Didn't write %d bytes to %s: errno %d\n", new_file_size, new_name, errno); -#endif munmap (old_base, old_file_size); munmap (new_base, new_file_size); diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c index cad2a5025ab..b9edd4f3a84 100644 --- a/src/unexhp9k800.c +++ b/src/unexhp9k800.c @@ -49,16 +49,11 @@ sigsetreturn (_sigreturn); */ -#ifdef emacs #include <config.h> -#endif - #include <stdio.h> #include <fcntl.h> #include <errno.h> - #include <a.out.h> - #include <dl.h> /* brk value to restore, stored as a global. @@ -79,12 +74,9 @@ run_time_remap (ignored) /* Create a new a.out file, same as old but with current data space */ - -unexec (new_name, old_name, new_end_of_text, dummy1, dummy2) - char new_name[]; /* name of the new a.out file to be created */ - char old_name[]; /* name of the old a.out file */ - char *new_end_of_text; /* ptr to new edata/etext; NOT USED YET */ - int dummy1, dummy2; /* not used by emacs */ +int +unexec (const char *new_name, /* name of the new a.out file to be created */ + const char *old_name) /* name of the old a.out file */ { int old, new; int old_size, new_size; diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 3949e5f6e00..f48c8d7dfa6 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -190,6 +190,8 @@ static off_t data_segment_old_fileoff = 0; static struct segment_command *data_segment_scp; +static void unexec_error (const char *format, ...) NO_RETURN; + /* Read N bytes from infd into memory starting at address DEST. Return true if successful, false otherwise. */ static int @@ -218,7 +220,7 @@ unexec_write_zero (off_t dest, size_t count) char buf[UNEXEC_COPY_BUFSZ]; ssize_t bytes; - bzero (buf, UNEXEC_COPY_BUFSZ); + memset (buf, 0, UNEXEC_COPY_BUFSZ); if (lseek (outfd, dest, SEEK_SET) != dest) return 0; @@ -267,7 +269,7 @@ unexec_copy (off_t dest, off_t src, ssize_t count) /* Debugging and informational messages routines. */ static void -unexec_error (char *format, ...) +unexec_error (const char *format, ...) { va_list ap; @@ -305,7 +307,7 @@ print_region (vm_address_t address, vm_size_t size, vm_prot_t prot, } static void -print_region_list () +print_region_list (void) { struct region_t *r; @@ -316,7 +318,7 @@ print_region_list () } static void -print_regions () +print_regions (void) { task_t target_task = mach_task_self (); vm_address_t address = (vm_address_t) 0; @@ -346,7 +348,7 @@ print_regions () cannot be omitted because they some regions created at run time are read-only. */ static void -build_region_list () +build_region_list (void) { task_t target_task = mach_task_self (); vm_address_t address = (vm_address_t) 0; @@ -465,7 +467,7 @@ unexec_reader (task_t task, vm_address_t address, vm_size_t size, void **ptr) } static void -find_emacs_zone_regions () +find_emacs_zone_regions (void) { num_unexec_regions = 0; @@ -495,7 +497,7 @@ unexec_regions_sort_compare (const void *a, const void *b) } static void -unexec_regions_merge () +unexec_regions_merge (void) { int i, n; unexec_region_info r; @@ -627,7 +629,7 @@ print_load_command (struct load_command *lc) the global array lca. Store the total number of load commands in global variable nlc. */ static void -read_load_commands () +read_load_commands (void) { int i; @@ -684,8 +686,8 @@ read_load_commands () } } - printf ("Highest address of load commands in input file: %#8x\n", - infile_lc_highest_addr); + printf ("Highest address of load commands in input file: %#8lx\n", + (unsigned long)infile_lc_highest_addr); printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n", text_seg_lowest_offset); @@ -1143,7 +1145,7 @@ copy_other (struct load_command *lc) /* Loop through all load commands and dump them. Then write the Mach header. */ static void -dump_it () +dump_it (void) { int i; long linkedit_delta = 0; @@ -1217,9 +1219,8 @@ dump_it () from it. The file names of the output and input files are outfile and infile, respectively. The three other parameters are ignored. */ -void -unexec (char *outfile, char *infile, void *start_data, void *start_bss, - void *entry_address) +int +unexec (const char *outfile, const char *infile) { if (in_dumped_exec) unexec_error ("Unexec from a dumped executable is not supported."); @@ -1249,11 +1250,12 @@ unexec (char *outfile, char *infile, void *start_data, void *start_bss, dump_it (); close (outfd); + return 0; } void -unexec_init_emacs_zone () +unexec_init_emacs_zone (void) { emacs_zone = malloc_create_zone (0, 0); malloc_set_zone_name (emacs_zone, "EmacsZone"); diff --git a/src/unexsol.c b/src/unexsol.c index 04e3f40799c..1d58ed46d4b 100644 --- a/src/unexsol.c +++ b/src/unexsol.c @@ -1,7 +1,6 @@ /* Trivial unexec for Solaris. */ #include <config.h> -#include <stdlib.h> #include <dlfcn.h> #include <setjmp.h> @@ -11,8 +10,7 @@ #include "coding.h" int -unexec (char *new_name, char *old_name, unsigned int data_start, - unsigned int bss_start, unsigned int entry_address) +unexec (const char *new_name, const char *old_name) { Lisp_Object data; Lisp_Object errstring; diff --git a/src/unexw32.c b/src/unexw32.c index d3e4e812480..a4dba647f53 100644 --- a/src/unexw32.c +++ b/src/unexw32.c @@ -724,9 +724,8 @@ copy_executable_and_dump_data (file_data *p_infile, /* Dump out .data and .bss sections into a new executable. */ -void -unexec (char *new_name, char *old_name, void *start_data, void *start_bss, - void *entry_address) +int +unexec (const char *new_name, const char *old_name) { file_data in_file, out_file; char out_filename[MAX_PATH], in_filename[MAX_PATH]; @@ -821,6 +820,8 @@ unexec (char *new_name, char *old_name, void *start_data, void *start_bss, close_file_data (&in_file); close_file_data (&out_file); + + return 0; } /* eof */ diff --git a/src/vm-limit.c b/src/vm-limit.c index a5b07eb50da..813ee6163c9 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -17,25 +17,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef emacs #include <config.h> #include <setjmp.h> #include "lisp.h" -#endif - -#ifndef emacs -#include <stddef.h> -typedef size_t SIZE; -typedef void *POINTER; -#define EXCEEDS_LISP_PTR(x) 0 -#endif - #include "mem-limits.h" -#ifdef HAVE_GETRLIMIT -#include <sys/resource.h> -#endif - /* Level number of warnings already issued. 0 -- no warnings issued. @@ -44,12 +30,13 @@ typedef void *POINTER; 3 -- 95% warning issued; keep warning frequently. */ enum warnlevel { not_warned, warned_75, warned_85, warned_95 }; - static enum warnlevel warnlevel; +typedef POINTER_TYPE *POINTER; + /* Function to call to issue a warning; 0 means don't issue them. */ -static void (*warn_function) (); +static void (*warn_function) (const char *); /* Start of data space; can be changed by calling malloc_init. */ static POINTER data_space_start; @@ -58,17 +45,9 @@ static POINTER data_space_start; static unsigned long lim_data; -#ifdef NO_LIM_DATA -static void -get_lim_data () -{ - lim_data = -1; -} -#else /* not NO_LIM_DATA */ - #if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) static void -get_lim_data () +get_lim_data (void) { struct rlimit rlimit; @@ -84,7 +63,7 @@ get_lim_data () #ifdef USG static void -get_lim_data () +get_lim_data (void) { extern long ulimit (); @@ -108,18 +87,18 @@ get_lim_data () #ifdef WINDOWSNT static void -get_lim_data () +get_lim_data (void) { extern unsigned long reserved_heap_size; lim_data = reserved_heap_size; } #else -#if !defined (BSD4_2) && !defined (__osf__) +#if !defined (BSD4_2) && !defined (CYGWIN) #ifdef MSDOS void -get_lim_data () +get_lim_data (void) { _go32_dpmi_meminfo info; unsigned long lim1, lim2; @@ -150,23 +129,23 @@ get_lim_data () } unsigned long -ret_lim_data () +ret_lim_data (void) { get_lim_data (); return lim_data; } #else /* not MSDOS */ static void -get_lim_data () +get_lim_data (void) { lim_data = vlimit (LIM_DATA, -1); } #endif /* not MSDOS */ -#else /* BSD4_2 */ +#else /* BSD4_2 || CYGWIN */ static void -get_lim_data () +get_lim_data (void) { struct rlimit XXrlimit; @@ -181,17 +160,16 @@ get_lim_data () #endif /* not WINDOWSNT */ #endif /* not USG */ #endif /* not HAVE_GETRLIMIT */ -#endif /* not NO_LIM_DATA */ /* Verify amount of memory available, complaining if we're near the end. */ static void -check_memory_limits () +check_memory_limits (void) { #ifdef REL_ALLOC - extern POINTER (*real_morecore) (); + extern POINTER (*real_morecore) (SIZE); #endif - extern POINTER (*__morecore) (); + extern POINTER (*__morecore) (SIZE); register POINTER cp; unsigned long five_percent; @@ -260,16 +238,54 @@ check_memory_limits () (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); } +#if !defined(CANNOT_DUMP) || !defined(SYSTEM_MALLOC) +/* Some systems that cannot dump also cannot implement these. */ + +/* + * Return the address of the start of the data segment prior to + * doing an unexec. After unexec the return value is undefined. + * See crt0.c for further information and definition of data_start. + * + * Apparently, on BSD systems this is etext at startup. On + * USG systems (swapping) this is highly mmu dependent and + * is also dependent on whether or not the program is running + * with shared text. Generally there is a (possibly large) + * gap between end of text and start of data with shared text. + * + */ + +char * +start_of_data (void) +{ +#ifdef BSD_SYSTEM + extern char etext; + return (POINTER)(&etext); +#elif defined DATA_START + return ((POINTER) DATA_START); +#elif defined ORDINARY_LINK + /* + * This is a hack. Since we're not linking crt0.c or pre_crt0.c, + * data_start isn't defined. We take the address of environ, which + * is known to live at or near the start of the system crt0.c, and + * we don't sweat the handful of bytes that might lose. + */ + extern char **environ; + return ((POINTER) &environ); +#else + extern int data_start; + return ((POINTER) &data_start); +#endif +} +#endif /* (not CANNOT_DUMP or not SYSTEM_MALLOC) */ + /* Enable memory usage warnings. START says where the end of pure storage is. WARNFUN specifies the function to call to issue a warning. */ void -memory_warnings (start, warnfun) - POINTER start; - void (*warnfun) (); +memory_warnings (POINTER start, void (*warnfun) (const char *)) { - extern void (* __after_morecore_hook) (); /* From gmalloc.c */ + extern void (* __after_morecore_hook) (void); /* From gmalloc.c */ if (start) data_space_start = start; diff --git a/src/w16select.c b/src/w16select.c index d6951be4d82..4d471e97911 100644 --- a/src/w16select.c +++ b/src/w16select.c @@ -23,12 +23,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ menus, and the Windows clipboard. */ /* Written by Dale P. Smith <dpsm@en.com> */ -/* Adapted to DJGPP v1 by Eli Zaretskii <eliz@is.elta.co.il> */ +/* Adapted to DJGPP by Eli Zaretskii <eliz@gnu.org> */ #ifdef MSDOS #include <config.h> -#include <string.h> #include <dpmi.h> #include <go32.h> #include <sys/farptr.h> @@ -94,25 +93,6 @@ static unsigned char *last_clipboard_text; /* The size of allocated storage for storing the clipboard data. */ static size_t clipboard_storage_size; -/* Emulation of `__dpmi_int' and friends for DJGPP v1.x */ - -#if __DJGPP__ < 2 - -typedef _go32_dpmi_registers __dpmi_regs; -#define __tb _go32_info_block.linear_address_of_transfer_buffer -#define _dos_ds _go32_info_block.selector_for_linear_memory - -static int -__dpmi_int (intno, regs) - int intno; - __dpmi_regs *regs; -{ - regs->x.ss = regs->x.sp = regs->x.flags = 0; - return _go32_dpmi_simulate_int (intno, regs); -} - -#endif /* __DJGPP__ < 2 */ - /* C functions to access the Windows 3.1x clipboard from DOS apps. The information was obtained from the Microsoft Knowledge Base, @@ -128,7 +108,7 @@ __dpmi_int (intno, regs) /* Return the WinOldAp support version, or 0x1700 if not supported. */ unsigned -identify_winoldap_version () +identify_winoldap_version (void) { __dpmi_regs regs; @@ -143,7 +123,7 @@ identify_winoldap_version () /* Open the clipboard, return non-zero if successfull. */ unsigned -open_clipboard () +open_clipboard (void) { __dpmi_regs regs; @@ -166,7 +146,7 @@ open_clipboard () /* Empty clipboard, return non-zero if successfull. */ unsigned -empty_clipboard () +empty_clipboard (void) { __dpmi_regs regs; @@ -181,8 +161,7 @@ empty_clipboard () /* Ensure we have a buffer in low memory with enough memory for data of size WANT_SIZE. Return the linear address of the buffer. */ static unsigned long -alloc_xfer_buf (want_size) - unsigned want_size; +alloc_xfer_buf (unsigned want_size) { __dpmi_regs regs; @@ -219,7 +198,7 @@ alloc_xfer_buf (want_size) The clipboard buffer tends to be large in size, because for small clipboard data sizes we use the DJGPP transfer buffer. */ static void -free_xfer_buf () +free_xfer_buf (void) { /* If the size is 0, we used DJGPP transfer buffer, so don't free. */ if (clipboard_xfer_buf_info.size) @@ -237,11 +216,7 @@ free_xfer_buf () /* Copy data into the clipboard, return zero if successfull. */ unsigned -set_clipboard_data (Format, Data, Size, Raw) - unsigned Format; - void *Data; - unsigned Size; - int Raw; +set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) { __dpmi_regs regs; unsigned truelen; @@ -340,8 +315,7 @@ set_clipboard_data (Format, Data, Size, Raw) /* Return the size of the clipboard data of format FORMAT. */ unsigned -get_clipboard_data_size (Format) - unsigned Format; +get_clipboard_data_size (unsigned Format) { __dpmi_regs regs; @@ -361,11 +335,7 @@ get_clipboard_data_size (Format) Warning: this doesn't check whether DATA has enough space to hold SIZE bytes. */ unsigned -get_clipboard_data (Format, Data, Size, Raw) - unsigned Format; - void *Data; - unsigned Size; - int Raw; +get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw) { __dpmi_regs regs; unsigned long xbuf_addr; @@ -444,7 +414,7 @@ get_clipboard_data (Format, Data, Size, Raw) /* Close clipboard, return non-zero if successfull. */ unsigned -close_clipboard () +close_clipboard (void) { __dpmi_regs regs; @@ -458,8 +428,7 @@ close_clipboard () /* Compact clipboard data so that at least SIZE bytes is available. */ unsigned -clipboard_compact (Size) - unsigned Size; +clipboard_compact (unsigned Size) { __dpmi_regs regs; @@ -483,11 +452,10 @@ static char system_error_msg[] = DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_data, 1, 2, 0, doc: /* This sets the clipboard data to the given text. */) - (string, frame) - Lisp_Object string, frame; + (Lisp_Object string, Lisp_Object frame) { unsigned ok = 1, put_status = 0; - int nbytes, charset_info, no_crlf_conversion; + int nbytes, no_crlf_conversion; unsigned char *src, *dst = NULL; CHECK_STRING (string); @@ -525,9 +493,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat { /* We must encode contents of STRING according to what clipboard-coding-system specifies. */ - int bufsize; struct coding_system coding; - unsigned char *htext2; Lisp_Object coding_system = NILP (Vnext_selection_coding_system) ? Vselection_coding_system : Vnext_selection_coding_system; @@ -593,13 +559,12 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_data, 0, 1, 0, doc: /* This gets the clipboard data in text format. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { unsigned data_size, truelen; unsigned char *htext = NULL; Lisp_Object ret = Qnil; - int no_crlf_conversion, require_decoding = 0; + int require_decoding = 0; if (NILP (frame)) frame = Fselected_frame (); @@ -640,8 +605,6 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat } if (require_decoding) { - int bufsize; - unsigned char *buf; struct coding_system coding; Lisp_Object coding_system = Vnext_selection_coding_system; @@ -688,8 +651,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'. */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { CHECK_SYMBOL (selection); @@ -704,8 +666,8 @@ and t is the same as `SECONDARY'. */) into the clipboard if we run under Windows, so we cannot check the clipboard alone.) */ if ((EQ (selection, Qnil) || EQ (selection, QPRIMARY)) - && ! NILP (SYMBOL_VALUE (Fintern_soft (build_string ("kill-ring"), - Qnil)))) + && ! NILP (Fsymbol_value (Fintern_soft (build_string ("kill-ring"), + Qnil)))) return Qt; if (EQ (selection, QCLIPBOARD)) @@ -724,7 +686,7 @@ and t is the same as `SECONDARY'. */) } void -syms_of_win16select () +syms_of_win16select (void) { defsubr (&Sw16_set_clipboard_data); defsubr (&Sw16_get_clipboard_data); diff --git a/src/w32.c b/src/w32.c index d96abd346f5..ae34ac6aadb 100644 --- a/src/w32.c +++ b/src/w32.c @@ -78,15 +78,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Some versions of compiler define MEMORYSTATUSEX, some don't, so we use a different name to avoid compilation problems. */ typedef struct _MEMORY_STATUS_EX { - DWORD dwLength; - DWORD dwMemoryLoad; - DWORDLONG ullTotalPhys; - DWORDLONG ullAvailPhys; - DWORDLONG ullTotalPageFile; - DWORDLONG ullAvailPageFile; - DWORDLONG ullTotalVirtual; - DWORDLONG ullAvailVirtual; - DWORDLONG ullAvailExtendedVirtual; + DWORD dwLength; + DWORD dwMemoryLoad; + DWORDLONG ullTotalPhys; + DWORDLONG ullAvailPhys; + DWORDLONG ullTotalPageFile; + DWORDLONG ullAvailPageFile; + DWORDLONG ullTotalVirtual; + DWORDLONG ullAvailVirtual; + DWORDLONG ullAvailExtendedVirtual; } MEMORY_STATUS_EX,*LPMEMORY_STATUS_EX; #include <lmcons.h> @@ -94,23 +94,27 @@ typedef struct _MEMORY_STATUS_EX { #include <tlhelp32.h> #include <psapi.h> +#include <w32api.h> +#if !defined(__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15) /* This either is not in psapi.h or guarded by higher value of - _WIN32_WINNT than what we use. */ + _WIN32_WINNT than what we use. w32api suplied with MinGW 3.15 + defines it in psapi.h */ typedef struct _PROCESS_MEMORY_COUNTERS_EX { - DWORD cb; - DWORD PageFaultCount; - DWORD PeakWorkingSetSize; - DWORD WorkingSetSize; - DWORD QuotaPeakPagedPoolUsage; - DWORD QuotaPagedPoolUsage; - DWORD QuotaPeakNonPagedPoolUsage; - DWORD QuotaNonPagedPoolUsage; - DWORD PagefileUsage; - DWORD PeakPagefileUsage; - DWORD PrivateUsage; + DWORD cb; + DWORD PageFaultCount; + DWORD PeakWorkingSetSize; + DWORD WorkingSetSize; + DWORD QuotaPeakPagedPoolUsage; + DWORD QuotaPagedPoolUsage; + DWORD QuotaPeakNonPagedPoolUsage; + DWORD QuotaNonPagedPoolUsage; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; + DWORD PrivateUsage; } PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; +#endif -#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ +/* TCP connection support. */ #include <sys/socket.h> #undef socket #undef bind @@ -129,7 +133,6 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { #undef accept #undef recvfrom #undef sendto -#endif #include "w32.h" #include "ndir.h" @@ -140,15 +143,11 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { /* For serial_configure and serial_open. */ #include "process.h" -/* From process.c */ -extern Lisp_Object QCport, QCspeed, QCprocess; -extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; -extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; typedef HRESULT (WINAPI * ShGetFolderPath_fn) (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *); -void globals_of_w32 (); +void globals_of_w32 (void); static DWORD get_rid (PSID); extern Lisp_Object Vw32_downcase_file_names; @@ -173,7 +172,6 @@ static BOOL g_b_init_is_windows_9x; static BOOL g_b_init_open_process_token; static BOOL g_b_init_get_token_information; static BOOL g_b_init_lookup_account_sid; -static BOOL g_b_init_get_sid_identifier_authority; static BOOL g_b_init_get_sid_sub_authority; static BOOL g_b_init_get_sid_sub_authority_count; static BOOL g_b_init_get_file_security; @@ -236,8 +234,6 @@ typedef BOOL (WINAPI * LookupAccountSid_Proc) ( LPTSTR DomainName, LPDWORD cbDomainName, PSID_NAME_USE peUse); -typedef PSID_IDENTIFIER_AUTHORITY (WINAPI * GetSidIdentifierAuthority_Proc) ( - PSID pSid); typedef PDWORD (WINAPI * GetSidSubAuthority_Proc) ( PSID pSid, DWORD n); @@ -304,13 +300,11 @@ typedef BOOL (WINAPI * GetSystemTimes_Proc) ( LPFILETIME lpKernelTime, LPFILETIME lpUserTime); - - /* ** A utility function ** */ static BOOL -is_windows_9x () +is_windows_9x (void) { - static BOOL s_b_ret=0; + static BOOL s_b_ret = 0; OSVERSIONINFO os_ver; if (g_b_init_is_windows_9x == 0) { @@ -329,7 +323,7 @@ is_windows_9x () Returns a list of three integers if the times are provided by the OS (NT derivatives), otherwise it returns the result of current-time. */ Lisp_Object -w32_get_internal_run_time () +w32_get_internal_run_time (void) { if (get_process_times_fn) { @@ -367,7 +361,7 @@ w32_get_internal_run_time () /* ** The wrapper functions ** */ -BOOL WINAPI +static BOOL WINAPI open_process_token (HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle) @@ -397,7 +391,7 @@ open_process_token (HANDLE ProcessHandle, ); } -BOOL WINAPI +static BOOL WINAPI get_token_information (HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, @@ -431,7 +425,7 @@ get_token_information (HANDLE TokenHandle, ); } -BOOL WINAPI +static BOOL WINAPI lookup_account_sid (LPCTSTR lpSystemName, PSID Sid, LPTSTR Name, @@ -469,31 +463,7 @@ lookup_account_sid (LPCTSTR lpSystemName, ); } -PSID_IDENTIFIER_AUTHORITY WINAPI -get_sid_identifier_authority (PSID pSid) -{ - static GetSidIdentifierAuthority_Proc s_pfn_Get_Sid_Identifier_Authority = NULL; - HMODULE hm_advapi32 = NULL; - if (is_windows_9x () == TRUE) - { - return NULL; - } - if (g_b_init_get_sid_identifier_authority == 0) - { - g_b_init_get_sid_identifier_authority = 1; - hm_advapi32 = LoadLibrary ("Advapi32.dll"); - s_pfn_Get_Sid_Identifier_Authority = - (GetSidIdentifierAuthority_Proc) GetProcAddress ( - hm_advapi32, "GetSidIdentifierAuthority"); - } - if (s_pfn_Get_Sid_Identifier_Authority == NULL) - { - return NULL; - } - return (s_pfn_Get_Sid_Identifier_Authority (pSid)); -} - -PDWORD WINAPI +static PDWORD WINAPI get_sid_sub_authority (PSID pSid, DWORD n) { static GetSidSubAuthority_Proc s_pfn_Get_Sid_Sub_Authority = NULL; @@ -518,7 +488,7 @@ get_sid_sub_authority (PSID pSid, DWORD n) return (s_pfn_Get_Sid_Sub_Authority (pSid, n)); } -PUCHAR WINAPI +static PUCHAR WINAPI get_sid_sub_authority_count (PSID pSid) { static GetSidSubAuthorityCount_Proc s_pfn_Get_Sid_Sub_Authority_Count = NULL; @@ -543,7 +513,7 @@ get_sid_sub_authority_count (PSID pSid) return (s_pfn_Get_Sid_Sub_Authority_Count (pSid)); } -BOOL WINAPI +static BOOL WINAPI get_file_security (LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, @@ -573,7 +543,7 @@ get_file_security (LPCTSTR lpFileName, lpnLengthNeeded)); } -BOOL WINAPI +static BOOL WINAPI get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner, LPBOOL lpbOwnerDefaulted) @@ -600,7 +570,7 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor, lpbOwnerDefaulted)); } -BOOL WINAPI +static BOOL WINAPI get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pGroup, LPBOOL lpbGroupDefaulted) @@ -627,7 +597,7 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor, lpbGroupDefaulted)); } -BOOL WINAPI +static BOOL WINAPI is_valid_sid (PSID sid) { static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL; @@ -651,7 +621,7 @@ is_valid_sid (PSID sid) return (s_pfn_Is_Valid_Sid (sid)); } -BOOL WINAPI +static BOOL WINAPI equal_sid (PSID sid1, PSID sid2) { static EqualSid_Proc s_pfn_Equal_Sid = NULL; @@ -675,7 +645,7 @@ equal_sid (PSID sid1, PSID sid2) return (s_pfn_Equal_Sid (sid1, sid2)); } -DWORD WINAPI +static DWORD WINAPI get_length_sid (PSID sid) { static GetLengthSid_Proc s_pfn_Get_Length_Sid = NULL; @@ -699,7 +669,7 @@ get_length_sid (PSID sid) return (s_pfn_Get_Length_Sid (sid)); } -BOOL WINAPI +static BOOL WINAPI copy_sid (DWORD destlen, PSID dest, PSID src) { static CopySid_Proc s_pfn_Copy_Sid = NULL; @@ -729,7 +699,7 @@ copy_sid (DWORD destlen, PSID dest, PSID src) supported in Windows NT / 2k / XP */ -void WINAPI +static void WINAPI get_native_system_info (LPSYSTEM_INFO lpSystemInfo) { static GetNativeSystemInfo_Proc s_pfn_Get_Native_System_Info = NULL; @@ -749,7 +719,7 @@ get_native_system_info (LPSYSTEM_INFO lpSystemInfo) lpSystemInfo->dwNumberOfProcessors = -1; } -BOOL WINAPI +static BOOL WINAPI get_system_times (LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime) @@ -830,17 +800,6 @@ getwd (char *dir) #endif } -#ifndef HAVE_SOCKETS -/* Emulate gethostname. */ -int -gethostname (char *buffer, int size) -{ - /* NT only allows small host names, so the buffer is - certainly large enough. */ - return !GetComputerName (buffer, &size); -} -#endif /* HAVE_SOCKETS */ - /* Emulate getloadavg. */ struct load_sample { @@ -1031,13 +990,13 @@ static struct group dflt_group = }; unsigned -getuid () +getuid (void) { return dflt_passwd.pw_uid; } unsigned -geteuid () +geteuid (void) { /* I could imagine arguing for checking to see whether the user is in the Administrators group and returning a UID of 0 for that @@ -1046,13 +1005,13 @@ geteuid () } unsigned -getgid () +getgid (void) { return dflt_passwd.pw_gid; } unsigned -getegid () +getegid (void) { return getgid (); } @@ -1086,8 +1045,8 @@ getpwnam (char *name) return pw; } -void -init_user_info () +static void +init_user_info (void) { /* Find the user's real name by opening the process token and looking up the name associated with the user-sid in that token. @@ -1203,7 +1162,7 @@ init_user_info () } int -random () +random (void) { /* rand () on NT gives us 15 random bits...hack together 30 bits. */ return ((rand () << 15) | rand ()); @@ -1221,9 +1180,7 @@ srandom (int seed) case path name components to lower case. */ static void -normalize_filename (fp, path_sep) - register char *fp; - char path_sep; +normalize_filename (register char *fp, char path_sep) { char sep; char *elem; @@ -1279,16 +1236,14 @@ normalize_filename (fp, path_sep) /* Destructively turn backslashes into slashes. */ void -dostounix_filename (p) - register char *p; +dostounix_filename (register char *p) { normalize_filename (p, '/'); } /* Destructively turn slashes into backslashes. */ void -unixtodos_filename (p) - register char *p; +unixtodos_filename (register char *p) { normalize_filename (p, '\\'); } @@ -1296,10 +1251,8 @@ unixtodos_filename (p) /* Remove all CR's that are followed by a LF. (From msdos.c...probably should figure out a way to share it, although this code isn't going to ever change.) */ -int -crlf_to_lf (n, buf) - register int n; - register unsigned char *buf; +static int +crlf_to_lf (register int n, register unsigned char *buf) { unsigned char *np = buf; unsigned char *startp = buf; @@ -1437,7 +1390,7 @@ w32_get_long_filename (char * name, char * buf, int size) return TRUE; } -int +static int is_unc_volume (const char *filename) { const char *ptr = filename; @@ -1478,6 +1431,30 @@ sigunblock (int sig) } int +sigemptyset (sigset_t *set) +{ + return 0; +} + +int +sigaddset (sigset_t *set, int signo) +{ + return 0; +} + +int +sigfillset (sigset_t *set) +{ + return 0; +} + +int +sigprocmask (int how, const sigset_t *set, sigset_t *oset) +{ + return 0; +} + +int setpgrp (int pid, int gid) { return 0; @@ -1492,9 +1469,7 @@ alarm (int seconds) #define REG_ROOT "SOFTWARE\\GNU\\Emacs" LPBYTE -w32_get_resource (key, lpdwtype) - char *key; - LPDWORD lpdwtype; +w32_get_resource (char *key, LPDWORD lpdwtype) { LPBYTE lpvalue; HKEY hrootkey = NULL; @@ -1614,7 +1589,7 @@ init_environment (char ** argv) {"LANG", NULL}, }; -#define N_ENV_VARS sizeof(dflt_envvars)/sizeof(dflt_envvars[0]) +#define N_ENV_VARS sizeof (dflt_envvars)/sizeof (dflt_envvars[0]) /* We need to copy dflt_envvars[] and work on the copy because we don't want the dumped Emacs to inherit the values of @@ -1917,7 +1892,25 @@ get_emacs_configuration (void) char * get_emacs_configuration_options (void) { - static char options_buffer[256]; + static char *options_buffer; + char cv[32]; /* Enough for COMPILER_VERSION. */ + char *options[] = { + cv, /* To be filled later. */ +#ifdef EMACSDEBUG + " --no-opt", +#endif + /* configure.bat already sets USER_CFLAGS and USER_LDFLAGS + with a starting space to save work here. */ +#ifdef USER_CFLAGS + " --cflags", USER_CFLAGS, +#endif +#ifdef USER_LDFLAGS + " --ldflags", USER_LDFLAGS, +#endif + NULL + }; + size_t size = 0; + int i; /* Work out the effective configure options for this build. */ #ifdef _MSC_VER @@ -1930,18 +1923,19 @@ get_emacs_configuration_options (void) #endif #endif - sprintf (options_buffer, COMPILER_VERSION); -#ifdef EMACSDEBUG - strcat (options_buffer, " --no-opt"); -#endif -#ifdef USER_CFLAGS - strcat (options_buffer, " --cflags"); - strcat (options_buffer, USER_CFLAGS); -#endif -#ifdef USER_LDFLAGS - strcat (options_buffer, " --ldflags"); - strcat (options_buffer, USER_LDFLAGS); -#endif + if (_snprintf (cv, sizeof (cv) - 1, COMPILER_VERSION) < 0) + return "Error: not enough space for compiler version"; + cv[sizeof (cv) - 1] = '\0'; + + for (i = 0; options[i]; i++) + size += strlen (options[i]); + + options_buffer = xmalloc (size + 1); + options_buffer[0] = '\0'; + + for (i = 0; options[i]; i++) + strcat (options_buffer, options[i]); + return options_buffer; } @@ -2052,7 +2046,7 @@ add_volume_info (char * root_dir, volume_info_data * info) /* Wrapper for GetVolumeInformation, which uses caching to avoid performance penalty (~2ms on 486 for local drives, 7.5ms for local cdrom drive, ~5-10ms or more for remote drives on LAN). */ -volume_info_data * +static volume_info_data * GetCachedVolumeInformation (char * root_dir) { volume_info_data * info; @@ -2087,7 +2081,7 @@ GetCachedVolumeInformation (char * root_dir) involve network access, and so is extremely quick). */ /* Map drive letter to UNC if remote. */ - if ( isalpha (root_dir[0]) && !fixed[ DRIVE_INDEX (root_dir[0]) ] ) + if (isalpha (root_dir[0]) && !fixed[DRIVE_INDEX (root_dir[0])]) { char remote_name[ 256 ]; char drive[3] = { root_dir[0], ':' }; @@ -2143,7 +2137,7 @@ GetCachedVolumeInformation (char * root_dir) /* Get information on the volume where name is held; set path pointer to start of pathname in name (past UNC header\volume header if present). */ -int +static int get_volume_info (const char * name, const char ** pPath) { char temp[MAX_PATH]; @@ -2194,7 +2188,7 @@ get_volume_info (const char * name, const char ** pPath) /* Determine if volume is FAT format (ie. only supports short 8.3 names); also set path pointer to start of pathname in name. */ -int +static int is_fat_volume (const char * name, const char ** pPath) { if (get_volume_info (name, pPath)) @@ -2332,9 +2326,9 @@ static WIN32_FIND_DATA dir_find_data; /* Support shares on a network resource as subdirectories of a read-only root directory. */ static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE; -HANDLE open_unc_volume (const char *); -char *read_unc_volume (HANDLE, char *, int); -void close_unc_volume (HANDLE); +static HANDLE open_unc_volume (const char *); +static char *read_unc_volume (HANDLE, char *, int); +static void close_unc_volume (HANDLE); DIR * opendir (char *filename) @@ -2470,7 +2464,7 @@ readdir (DIR *dirp) return &dir_static; } -HANDLE +static HANDLE open_unc_volume (const char *path) { NETRESOURCE nr; @@ -2495,7 +2489,7 @@ open_unc_volume (const char *path) return INVALID_HANDLE_VALUE; } -char * +static char * read_unc_volume (HANDLE henum, char *readbuf, int size) { DWORD count; @@ -2520,14 +2514,14 @@ read_unc_volume (HANDLE henum, char *readbuf, int size) return readbuf; } -void +static void close_unc_volume (HANDLE henum) { if (henum != INVALID_HANDLE_VALUE) WNetCloseEnum (henum); } -DWORD +static DWORD unc_volume_file_attributes (const char *path) { HANDLE henum; @@ -2952,7 +2946,7 @@ static int init = 0; } while (0) static void -initialize_utc_base () +initialize_utc_base (void) { /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */ SYSTEMTIME st; @@ -2987,8 +2981,7 @@ convert_time (FILETIME ft) return (time_t) ((tmp - utc_base) / 10000000L); } - -void +static void convert_from_time_t (time_t time, FILETIME * pft) { ULARGE_INTEGER tmp; @@ -3464,7 +3457,6 @@ stat (const char * path, struct stat * buf) buf->st_dev = volume_info.serialnum; buf->st_rdev = volume_info.serialnum; - buf->st_size = wfd.nFileSizeHigh; buf->st_size <<= 32; buf->st_size += wfd.nFileSizeLow; @@ -3637,7 +3629,7 @@ utime (const char *name, struct utimbuf *times) /* Helper wrapper functions. */ -HANDLE WINAPI +static HANDLE WINAPI create_toolhelp32_snapshot (DWORD Flags, DWORD Ignored) { static CreateToolhelp32Snapshot_Proc s_pfn_Create_Toolhelp32_Snapshot = NULL; @@ -3656,7 +3648,7 @@ create_toolhelp32_snapshot (DWORD Flags, DWORD Ignored) return (s_pfn_Create_Toolhelp32_Snapshot (Flags, Ignored)); } -BOOL WINAPI +static BOOL WINAPI process32_first (HANDLE hSnapshot, LPPROCESSENTRY32 lppe) { static Process32First_Proc s_pfn_Process32_First = NULL; @@ -3675,7 +3667,7 @@ process32_first (HANDLE hSnapshot, LPPROCESSENTRY32 lppe) return (s_pfn_Process32_First (hSnapshot, lppe)); } -BOOL WINAPI +static BOOL WINAPI process32_next (HANDLE hSnapshot, LPPROCESSENTRY32 lppe) { static Process32Next_Proc s_pfn_Process32_Next = NULL; @@ -3694,7 +3686,7 @@ process32_next (HANDLE hSnapshot, LPPROCESSENTRY32 lppe) return (s_pfn_Process32_Next (hSnapshot, lppe)); } -BOOL WINAPI +static BOOL WINAPI open_thread_token (HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, @@ -3728,7 +3720,7 @@ open_thread_token (HANDLE ThreadHandle, ); } -BOOL WINAPI +static BOOL WINAPI impersonate_self (SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) { static ImpersonateSelf_Proc s_pfn_Impersonate_Self = NULL; @@ -3751,7 +3743,7 @@ impersonate_self (SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) return s_pfn_Impersonate_Self (ImpersonationLevel); } -BOOL WINAPI +static BOOL WINAPI revert_to_self (void) { static RevertToSelf_Proc s_pfn_Revert_To_Self = NULL; @@ -3774,7 +3766,7 @@ revert_to_self (void) return s_pfn_Revert_To_Self (); } -BOOL WINAPI +static BOOL WINAPI get_process_memory_info (HANDLE h_proc, PPROCESS_MEMORY_COUNTERS mem_counters, DWORD bufsize) @@ -3800,8 +3792,10 @@ get_process_memory_info (HANDLE h_proc, return s_pfn_Get_Process_Memory_Info (h_proc, mem_counters, bufsize); } -BOOL WINAPI -get_process_working_set_size (HANDLE h_proc, DWORD *minrss, DWORD *maxrss) +static BOOL WINAPI +get_process_working_set_size (HANDLE h_proc, + DWORD *minrss, + DWORD *maxrss) { static GetProcessWorkingSetSize_Proc s_pfn_Get_Process_Working_Set_Size = NULL; @@ -3824,7 +3818,7 @@ get_process_working_set_size (HANDLE h_proc, DWORD *minrss, DWORD *maxrss) return s_pfn_Get_Process_Working_Set_Size (h_proc, minrss, maxrss); } -BOOL WINAPI +static BOOL WINAPI global_memory_status (MEMORYSTATUS *buf) { static GlobalMemoryStatus_Proc s_pfn_Global_Memory_Status = NULL; @@ -3847,7 +3841,7 @@ global_memory_status (MEMORYSTATUS *buf) return s_pfn_Global_Memory_Status (buf); } -BOOL WINAPI +static BOOL WINAPI global_memory_status_ex (MEMORY_STATUS_EX *buf) { static GlobalMemoryStatusEx_Proc s_pfn_Global_Memory_Status_Ex = NULL; @@ -3871,7 +3865,7 @@ global_memory_status_ex (MEMORY_STATUS_EX *buf) } Lisp_Object -list_system_processes () +list_system_processes (void) { struct gcpro gcpro1; Lisp_Object proclist = Qnil; @@ -3962,8 +3956,7 @@ restore_privilege (TOKEN_PRIVILEGES *priv) } static Lisp_Object -ltime (time_sec, time_usec) - long time_sec, time_usec; +ltime (long time_sec, long time_usec) { return list3 (make_number ((time_sec >> 16) & 0xffff), make_number (time_sec & 0xffff), @@ -3973,10 +3966,9 @@ ltime (time_sec, time_usec) #define U64_TO_LISP_TIME(time) ltime ((time) / 1000000L, (time) % 1000000L) static int -process_times (h_proc, ctime, etime, stime, utime, ttime, pcpu) - HANDLE h_proc; - Lisp_Object *ctime, *etime, *stime, *utime, *ttime; - double *pcpu; +process_times (HANDLE h_proc, Lisp_Object *ctime, Lisp_Object *etime, + Lisp_Object *stime, Lisp_Object *utime, Lisp_Object *ttime, + double *pcpu) { FILETIME ft_creation, ft_exit, ft_kernel, ft_user, ft_current; ULONGLONG tem1, tem2, tem3, tem; @@ -4026,8 +4018,7 @@ process_times (h_proc, ctime, etime, stime, utime, ttime, pcpu) } Lisp_Object -system_process_attributes (pid) - Lisp_Object pid; +system_process_attributes (Lisp_Object pid) { struct gcpro gcpro1, gcpro2, gcpro3; Lisp_Object attrs = Qnil; @@ -4330,8 +4321,6 @@ system_process_attributes (pid) } -#ifdef HAVE_SOCKETS - /* Wrappers for winsock functions to map between our file descriptors and winsock's handles; also set h_errno for convenience. @@ -4411,7 +4400,6 @@ init_winsock (int load_now) if (winsock_lib != NULL) return TRUE; - pfn_SetHandleInformation = NULL; pfn_SetHandleInformation = (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetHandleInformation"); @@ -4493,7 +4481,7 @@ int h_errno = 0; normal system codes where they overlap (non-overlapping definitions are already in <sys/socket.h> */ static void -set_errno () +set_errno (void) { if (winsock_lib == NULL) h_errno = EINVAL; @@ -4515,7 +4503,7 @@ set_errno () } static void -check_errno () +check_errno (void) { if (h_errno == 0 && winsock_lib != NULL) pfn_WSASetLastError (0); @@ -4618,15 +4606,9 @@ sys_strerror (int error_no) but I believe the method of keeping the socket handle separate (and insuring it is not inheritable) is the correct one. */ -//#define SOCK_REPLACE_HANDLE - -#ifdef SOCK_REPLACE_HANDLE -#define SOCK_HANDLE(fd) ((SOCKET) _get_osfhandle (fd)) -#else #define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) -#endif -int socket_to_fd (SOCKET s); +static int socket_to_fd (SOCKET s); int sys_socket (int af, int type, int protocol) @@ -4652,7 +4634,7 @@ sys_socket (int af, int type, int protocol) } /* Convert a SOCKET to a file descriptor. */ -int +static int socket_to_fd (SOCKET s) { int fd; @@ -4668,13 +4650,6 @@ socket_to_fd (SOCKET s) fd = _open ("NUL:", _O_RDWR); if (fd >= 0) { -#ifdef SOCK_REPLACE_HANDLE - /* now replace handle to NUL with our socket handle */ - CloseHandle ((HANDLE) _get_osfhandle (fd)); - _free_osfhnd (fd); - _set_osfhnd (fd, s); - /* setmode (fd, _O_BINARY); */ -#else /* Make a non-inheritable copy of the socket handle. Note that it is possible that sockets aren't actually kernel handles, which appears to be the case on Windows 9x when @@ -4720,7 +4695,6 @@ socket_to_fd (SOCKET s) } } fd_info[fd].hnd = (HANDLE) s; -#endif /* set our own internal flags */ fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; @@ -4753,7 +4727,6 @@ socket_to_fd (SOCKET s) return -1; } - int sys_bind (int s, const struct sockaddr * addr, int namelen) { @@ -4775,7 +4748,6 @@ sys_bind (int s, const struct sockaddr * addr, int namelen) return SOCKET_ERROR; } - int sys_connect (int s, const struct sockaddr * name, int namelen) { @@ -4888,7 +4860,6 @@ sys_getpeername (int s, struct sockaddr *addr, int * namelen) return SOCKET_ERROR; } - int sys_shutdown (int s, int how) { @@ -5081,8 +5052,6 @@ fcntl (int s, int cmd, int options) return SOCKET_ERROR; } -#endif /* HAVE_SOCKETS */ - /* Shadow main io functions: we need to handle pipes and sockets more intelligently, and implement non-blocking mode as well. */ @@ -5117,18 +5086,15 @@ sys_close (int fd) } if (i == MAXDESC) { -#ifdef HAVE_SOCKETS if (fd_info[fd].flags & FILE_SOCKET) { -#ifndef SOCK_REPLACE_HANDLE if (winsock_lib == NULL) abort (); pfn_shutdown (SOCK_HANDLE (fd), 2); rc = pfn_closesocket (SOCK_HANDLE (fd)); -#endif + winsock_inuse--; /* count open sockets */ } -#endif delete_child (cp); } } @@ -5160,7 +5126,6 @@ sys_dup (int fd) return new_fd; } - int sys_dup2 (int src, int dst) { @@ -5296,7 +5261,6 @@ _sys_read_ahead (int fd) return STATUS_READ_ERROR; } } -#ifdef HAVE_SOCKETS else if (fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock = 0; @@ -5312,7 +5276,6 @@ _sys_read_ahead (int fd) pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); } } -#endif if (rc == sizeof (char)) cp->status = STATUS_READ_SUCCEEDED; @@ -5484,7 +5447,6 @@ sys_read (int fd, char * buffer, unsigned int count) nchars += rc; } } -#ifdef HAVE_SOCKETS else /* FILE_SOCKET */ { if (winsock_lib == NULL) abort (); @@ -5511,7 +5473,6 @@ sys_read (int fd, char * buffer, unsigned int count) nchars += res; } } -#endif } else { @@ -5636,9 +5597,7 @@ sys_write (int fd, const void * buffer, unsigned int count) } } } - else -#ifdef HAVE_SOCKETS - if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) + else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock = 0; if (winsock_lib == NULL) abort (); @@ -5666,14 +5625,40 @@ sys_write (int fd, const void * buffer, unsigned int count) } } else -#endif - nchars = _write (fd, buffer, count); + { + /* Some networked filesystems don't like too large writes, so + break them into smaller chunks. See the Comments section of + the MSDN documentation of WriteFile for details behind the + choice of the value of CHUNK below. See also the thread + http://thread.gmane.org/gmane.comp.version-control.git/145294 + in the git mailing list. */ + const unsigned char *p = buffer; + const unsigned chunk = 30 * 1024 * 1024; + + nchars = 0; + while (count > 0) + { + unsigned this_chunk = count < chunk ? count : chunk; + int n = _write (fd, p, this_chunk); + + nchars += n; + if (n < 0) + { + nchars = n; + break; + } + else if (n < this_chunk) + break; + count -= n; + p += n; + } + } return nchars; } static void -check_windows_init_file () +check_windows_init_file (void) { extern int noninteractive, inhibit_window_system; @@ -5729,20 +5714,17 @@ check_windows_init_file () } void -term_ntproc () +term_ntproc (void) { -#ifdef HAVE_SOCKETS /* shutdown the socket interface if necessary */ term_winsock (); -#endif term_w32select (); } void -init_ntproc () +init_ntproc (void) { -#ifdef HAVE_SOCKETS /* Initialise the socket interface now if available and requested by the user by defining PRELOAD_WINSOCK; otherwise loading will be delayed until open-network-stream is called (w32-has-winsock can @@ -5756,7 +5738,6 @@ init_ntproc () if (getenv ("PRELOAD_WINSOCK") != NULL) init_winsock (TRUE); -#endif /* Initial preparation for subprocess support: replace our standard handles with non-inheritable versions. */ @@ -5848,7 +5829,7 @@ init_ntproc () shutdown_handler ensures that buffers' autosave files are up to date when the user logs off, or the system shuts down. */ -BOOL WINAPI +static BOOL WINAPI shutdown_handler (DWORD type) { /* Ctrl-C and Ctrl-Break are already suppressed, so don't handle them. */ @@ -5870,7 +5851,7 @@ shutdown_handler (DWORD type) initialized is non zero (see the function main in emacs.c). */ void -globals_of_w32 () +globals_of_w32 (void) { HMODULE kernel32 = GetModuleHandle ("kernel32.dll"); @@ -5881,7 +5862,6 @@ globals_of_w32 () g_b_init_open_process_token = 0; g_b_init_get_token_information = 0; g_b_init_lookup_account_sid = 0; - g_b_init_get_sid_identifier_authority = 0; g_b_init_get_sid_sub_authority = 0; g_b_init_get_sid_sub_authority_count = 0; g_b_init_get_file_security = 0; diff --git a/src/w32console.c b/src/w32console.c index 303299898d9..35f0fc195f7 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -25,10 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include <stdlib.h> #include <stdio.h> #include <windows.h> -#include <string.h> #include <setjmp.h> #include "lisp.h" @@ -42,13 +40,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "w32inevt.h" /* from window.c */ -extern Lisp_Object Frecenter (); +extern Lisp_Object Frecenter (Lisp_Object); /* from keyboard.c */ -extern int detect_input_pending (); +extern int detect_input_pending (void); /* from sysdep.c */ -extern int read_input_pending (); +extern int read_input_pending (void); static void w32con_move_cursor (struct frame *f, int row, int col); static void w32con_clear_to_end (struct frame *f); @@ -68,7 +66,7 @@ static WORD w32_face_attributes (struct frame *f, int face_id); static COORD cursor_coords; static HANDLE prev_screen, cur_screen; static WORD char_attr_normal; -static DWORD prev_console_mode; +static DWORD prev_console_mode; #ifndef USE_SEPARATE_SCREEN static CONSOLE_CURSOR_INFO prev_console_cursor; @@ -268,7 +266,8 @@ scroll_line (struct frame *f, int dist, int direction) /* If start is zero insert blanks instead of a string at start ?. */ static void -w32con_insert_glyphs (struct frame *f, register struct glyph *start, register int len) +w32con_insert_glyphs (struct frame *f, register struct glyph *start, + register int len) { scroll_line (f, len, RIGHT); @@ -286,8 +285,8 @@ w32con_insert_glyphs (struct frame *f, register struct glyph *start, register in } } -extern unsigned char *encode_terminal_code P_ ((struct glyph *, int, - struct coding_system *)); +extern unsigned char *encode_terminal_code (struct glyph *, int, + struct coding_system *); static void w32con_write_glyphs (struct frame *f, register struct glyph *string, @@ -392,8 +391,7 @@ SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent to use the corresponding system sound for the bell. The 'silent sound prevents Emacs from making any sound at all. SOUND is nil to use the normal beep. */) - (sound) - Lisp_Object sound; + (Lisp_Object sound) { CHECK_SYMBOL (sound); @@ -488,6 +486,62 @@ w32con_set_terminal_window (struct frame *f, int size) } /*********************************************************************** + stubs from termcap.c + ***********************************************************************/ + +void +sys_tputs (char *str, int nlines, int (*outfun) (int)) +{ +} + +char * +sys_tgetstr (char *cap, char **area) +{ + return NULL; +} + + +/*********************************************************************** + stubs from cm.c + ***********************************************************************/ + +struct tty_display_info *current_tty = NULL; +int cost = 0; + +int +evalcost (int c) +{ + return c; +} + +int +cmputc (int c) +{ + return c; +} + +void +cmcheckmagic (struct tty_display_info *tty) +{ +} + +void +cmcostinit (struct tty_display_info *tty) +{ +} + +void +cmgoto (struct tty_display_info *tty, int row, int col) +{ +} + +void +Wcm_clear (struct tty_display_info *tty) +{ +} + + +/*********************************************************************** Faces ***********************************************************************/ @@ -495,9 +549,7 @@ w32con_set_terminal_window (struct frame *f, int size) /* Turn appearances of face FACE_ID on tty frame F on. */ static WORD -w32_face_attributes (f, face_id) - struct frame *f; - int face_id; +w32_face_attributes (struct frame *f, int face_id) { WORD char_attr; struct face *face = FACE_FROM_ID (f, face_id); @@ -531,30 +583,6 @@ w32_face_attributes (f, face_id) return char_attr; } - - -/* Given a color index, return its standard name. */ -Lisp_Object -vga_stdcolor_name (int idx) -{ - /* Standard VGA colors, in the order of their standard numbering - in the default VGA palette. */ - static char *vga_colors[16] = { - "black", "blue", "green", "cyan", "red", "magenta", "brown", - "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan", - "lightred", "lightmagenta", "yellow", "white" - }; - - extern Lisp_Object Qunspecified; - - if (idx >= 0 && idx < sizeof (vga_colors) / sizeof (vga_colors[0])) - return build_string (vga_colors[idx]); - else - return Qunspecified; /* meaning the default */ -} - -typedef int (*term_hook) (); - void initialize_w32_display (struct terminal *term) { @@ -695,9 +723,7 @@ initialize_w32_display (struct terminal *term) DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, doc: /* Set screen colors. */) - (foreground, background) - Lisp_Object foreground; - Lisp_Object background; + (Lisp_Object foreground, Lisp_Object background) { char_attr_normal = XFASTINT (foreground) + (XFASTINT (background) << 4); @@ -707,8 +733,7 @@ DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0, doc: /* Set cursor size. */) - (size) - Lisp_Object size; + (Lisp_Object size) { CONSOLE_CURSOR_INFO cci; cci.dwSize = XFASTINT (size); @@ -719,7 +744,7 @@ DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0, } void -syms_of_ntterm () +syms_of_ntterm (void) { DEFVAR_BOOL ("w32-use-full-screen-buffer", &w32_use_full_screen_buffer, diff --git a/src/w32fns.c b/src/w32fns.c index 61dd8b9ee1f..808503547f1 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -69,15 +69,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define FOF_NO_CONNECTED_ELEMENTS 0x2000 #endif -void syms_of_w32fns (); -void globals_of_w32fns (); +void syms_of_w32fns (void); +void globals_of_w32fns (void); -extern void free_frame_menubar (); -extern double atof (); -extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object)); -extern void w32_menu_display_help P_ ((HWND, HMENU, UINT, UINT)); -extern void w32_free_menu_strings P_ ((HWND)); -extern const char *map_w32_filename P_ ((const char *, const char **)); +extern void free_frame_menubar (struct frame *); +extern double atof (const char *); +extern int w32_console_toggle_lock_key (int, Lisp_Object); +extern void w32_menu_display_help (HWND, HMENU, UINT, UINT); +extern void w32_free_menu_strings (HWND); +extern const char *map_w32_filename (const char *, const char **); extern int quit_char; @@ -262,7 +262,6 @@ typedef BOOL (WINAPI * GetMonitorInfo_Proc) (IN HMONITOR monitor, OUT struct MONITOR_INFO* info); TrackMouseEvent_Proc track_mouse_event_fn = NULL; -ClipboardSequence_Proc clipboard_sequence_fn = NULL; ImmGetCompositionString_Proc get_composition_string_fn = NULL; ImmGetContext_Proc get_ime_context_fn = NULL; ImmReleaseContext_Proc release_ime_context_fn = NULL; @@ -294,6 +293,8 @@ extern Lisp_Object Vwindow_system_version; /* The below are defined in frame.c. */ +extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode; +extern Lisp_Object Vwindow_system_version; extern Lisp_Object Qtooltip; #ifdef GLYPH_DEBUG @@ -319,18 +320,18 @@ extern HMENU current_popup_menu; static int menubar_in_use = 0; /* From w32uniscribe.c */ -extern void syms_of_w32uniscribe (); +extern void syms_of_w32uniscribe (void); extern int uniscribe_available; /* Function prototypes for hourglass support. */ -static void w32_show_hourglass P_ ((struct frame *)); -static void w32_hide_hourglass P_ ((void)); +static void w32_show_hourglass (struct frame *); +static void w32_hide_hourglass (void); /* Error if we are not connected to MS-Windows. */ void -check_w32 () +check_w32 (void) { if (! w32_in_use) error ("MS-Windows not in use or not initialized"); @@ -340,7 +341,7 @@ check_w32 () You should not call this unless HAVE_MENUS is defined. */ int -have_menus_p () +have_menus_p (void) { return w32_in_use; } @@ -349,8 +350,7 @@ have_menus_p () and checking validity for W32. */ FRAME_PTR -check_x_frame (frame) - Lisp_Object frame; +check_x_frame (Lisp_Object frame) { FRAME_PTR f; @@ -368,8 +368,7 @@ check_x_frame (frame) the first display on the list. */ struct w32_display_info * -check_x_display_info (frame) - Lisp_Object frame; +check_x_display_info (Lisp_Object frame) { if (NILP (frame)) { @@ -400,9 +399,7 @@ check_x_display_info (frame) /* This function can be called during GC, so use GC_xxx type test macros. */ struct frame * -x_window_to_frame (dpyinfo, wdesc) - struct w32_display_info *dpyinfo; - HWND wdesc; +x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc) { Lisp_Object tail, frame; struct frame *f; @@ -423,26 +420,24 @@ x_window_to_frame (dpyinfo, wdesc) } -static Lisp_Object unwind_create_frame P_ ((Lisp_Object)); -static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object)); -static void my_create_window P_ ((struct frame *)); -static void my_create_tip_window P_ ((struct frame *)); +static Lisp_Object unwind_create_frame (Lisp_Object); +static Lisp_Object unwind_create_tip_frame (Lisp_Object); +static void my_create_window (struct frame *); +static void my_create_tip_window (struct frame *); /* TODO: Native Input Method support; see x_create_im. */ -void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object, - Lisp_Object)); +void x_set_foreground_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_background_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_mouse_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_cursor_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_border_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object); +void x_set_icon_type (struct frame *, Lisp_Object, Lisp_Object); +void x_set_icon_name (struct frame *, Lisp_Object, Lisp_Object); +void x_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); +void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +void x_set_title (struct frame *, Lisp_Object, Lisp_Object); +void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object); @@ -452,9 +447,7 @@ static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object, not Emacs's own window. */ void -x_real_positions (f, xptr, yptr) - FRAME_PTR f; - int *xptr, *yptr; +x_real_positions (FRAME_PTR f, int *xptr, int *yptr) { POINT pt; RECT rect; @@ -484,8 +477,7 @@ DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color, This adds or updates a named color to `w32-color-map', making it available for use. The original entry's RGB ref is returned, or nil if the entry is new. */) - (red, green, blue, name) - Lisp_Object red, green, blue, name; + (Lisp_Object red, Lisp_Object green, Lisp_Object blue, Lisp_Object name) { Lisp_Object rgb; Lisp_Object oldrgb = Qnil; @@ -771,7 +763,7 @@ colormap_t w32_color_map[] = DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, 0, 0, 0, doc: /* Return the default color map. */) - () + (void) { int i; colormap_t *pc = w32_color_map; @@ -793,28 +785,7 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map, } static Lisp_Object -w32_to_x_color (rgb) - Lisp_Object rgb; -{ - Lisp_Object color; - - CHECK_NUMBER (rgb); - - BLOCK_INPUT; - - color = Frassq (rgb, Vw32_color_map); - - UNBLOCK_INPUT; - - if (!NILP (color)) - return (Fcar (color)); - else - return Qnil; -} - -static Lisp_Object -w32_color_map_lookup (colorname) - char *colorname; +w32_color_map_lookup (char *colorname) { Lisp_Object tail, ret = Qnil; @@ -846,8 +817,7 @@ w32_color_map_lookup (colorname) static void -add_system_logical_colors_to_map (system_colors) - Lisp_Object *system_colors; +add_system_logical_colors_to_map (Lisp_Object *system_colors) { HKEY colors_key; @@ -895,8 +865,7 @@ add_system_logical_colors_to_map (system_colors) static Lisp_Object -x_to_w32_color (colorname) - char * colorname; +x_to_w32_color (char * colorname) { register Lisp_Object ret = Qnil; @@ -1207,9 +1176,7 @@ w32_unmap_color (FRAME_PTR f, COLORREF color) /* Gamma-correct COLOR on frame F. */ void -gamma_correct (f, color) - struct frame *f; - COLORREF *color; +gamma_correct (struct frame *f, COLORREF *color) { if (f->gamma) { @@ -1226,11 +1193,7 @@ gamma_correct (f, color) If ALLOC is nonzero, allocate a new colormap cell. */ int -w32_defined_color (f, color, color_def, alloc) - FRAME_PTR f; - char *color; - XColor *color_def; - int alloc; +w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc) { register Lisp_Object tem; COLORREF w32_color_ref; @@ -1302,10 +1265,7 @@ w32_defined_color (f, color, color_def, alloc) ARG says. */ int -x_decode_color (f, arg, def) - FRAME_PTR f; - Lisp_Object arg; - int def; +x_decode_color (FRAME_PTR f, Lisp_Object arg, int def) { XColor cdef; @@ -1339,9 +1299,7 @@ x_decode_color (f, arg, def) in the standard place; do not attempt to change the window. */ void -x_set_foreground_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { struct w32_output *x = f->output_data.w32; PIX_TYPE fg, old_fg; @@ -1365,9 +1323,7 @@ x_set_foreground_color (f, arg, oldval) } void -x_set_background_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { FRAME_BACKGROUND_PIXEL (f) = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); @@ -1385,9 +1341,7 @@ x_set_background_color (f, arg, oldval) } void -x_set_mouse_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { Cursor cursor, nontext_cursor, mode_cursor, hand_cursor; int count; @@ -1534,9 +1488,7 @@ x_set_mouse_color (f, arg, oldval) } void -x_set_cursor_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { unsigned long fore_pixel, pixel; @@ -1583,9 +1535,7 @@ x_set_cursor_color (f, arg, oldval) F has a window. */ void -x_set_border_pixel (f, pix) - struct frame *f; - int pix; +x_set_border_pixel (struct frame *f, int pix) { f->output_data.w32->border_pixel = pix; @@ -1604,9 +1554,7 @@ x_set_border_pixel (f, pix) F has a window; it must be redone when the window is created. */ void -x_set_border_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int pix; @@ -1618,9 +1566,7 @@ x_set_border_color (f, arg, oldval) void -x_set_cursor_type (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { set_frame_cursor_types (f, arg); @@ -1629,9 +1575,7 @@ x_set_cursor_type (f, arg, oldval) } void -x_set_icon_type (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int result; @@ -1658,9 +1602,7 @@ x_set_icon_type (f, arg, oldval) } void -x_set_icon_name (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { if (STRINGP (arg)) { @@ -1708,9 +1650,7 @@ x_set_icon_name (f, arg, oldval) void -x_set_menu_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int nlines; int olines = FRAME_MENU_BAR_LINES (f); @@ -1753,9 +1693,7 @@ x_set_menu_bar_lines (f, value, oldval) The frame's height doesn't change. */ void -x_set_tool_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int delta, nlines, root_height; Lisp_Object root_window; @@ -1835,10 +1773,7 @@ x_set_tool_bar_lines (f, value, oldval) F->explicit_name is set, ignore the new name; otherwise, set it. */ void -x_set_name (f, name, explicit) - struct frame *f; - Lisp_Object name; - int explicit; +x_set_name (struct frame *f, Lisp_Object name, int explicit) { /* Make sure that requests from lisp code override requests from Emacs redisplay code. */ @@ -1893,9 +1828,7 @@ x_set_name (f, name, explicit) specified a name for the frame; the name will override any set by the redisplay code. */ void -x_explicitly_set_name (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { x_set_name (f, arg, 1); } @@ -1904,9 +1837,7 @@ x_explicitly_set_name (f, arg, oldval) name; names set this way will never override names set by the user's lisp code. */ void -x_implicitly_set_name (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { x_set_name (f, arg, 0); } @@ -1915,9 +1846,7 @@ x_implicitly_set_name (f, arg, oldval) If NAME is nil, use the frame name as the title. */ void -x_set_title (f, name, old_name) - struct frame *f; - Lisp_Object name, old_name; +x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) { /* Don't change the title if it's already NAME. */ if (EQ (name, f->title)) @@ -1941,8 +1870,8 @@ x_set_title (f, name, old_name) } } -void x_set_scroll_bar_default_width (f) - struct frame *f; +void +x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); @@ -1970,11 +1899,10 @@ w32_load_cursor (LPCTSTR name) return cursor; } -extern LRESULT CALLBACK w32_wnd_proc (); +static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM); static BOOL -w32_init_class (hinst) - HINSTANCE hinst; +w32_init_class (HINSTANCE hinst) { WNDCLASS wc; @@ -1993,9 +1921,7 @@ w32_init_class (hinst) } static HWND -w32_createscrollbar (f, bar) - struct frame *f; - struct scroll_bar * bar; +w32_createscrollbar (struct frame *f, struct scroll_bar * bar) { return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, /* Position and size of scroll bar. */ @@ -2010,8 +1936,7 @@ w32_createscrollbar (f, bar) } static void -w32_createwindow (f) - struct frame *f; +w32_createwindow (struct frame *f) { HWND hwnd; RECT rect; @@ -2081,12 +2006,7 @@ w32_createwindow (f) } static void -my_post_msg (wmsg, hwnd, msg, wParam, lParam) - W32Msg * wmsg; - HWND hwnd; - UINT msg; - WPARAM wParam; - LPARAM lParam; +my_post_msg (W32Msg * wmsg, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { wmsg->msg.hwnd = hwnd; wmsg->msg.message = msg; @@ -2180,7 +2100,7 @@ record_keyup (unsigned int wparam, unsigned int lparam) it regains focus, be conservative and clear all modifiers since we cannot reconstruct the left and right modifier state. */ static void -reset_modifiers () +reset_modifiers (void) { SHORT ctrl, alt; @@ -2227,7 +2147,7 @@ reset_modifiers () modifier keys, we know that, if no modifiers are set, then neither the left or right modifier should be set. */ static void -sync_modifiers () +sync_modifiers (void) { if (!modifiers_recorded) return; @@ -2313,7 +2233,7 @@ w32_key_to_modifier (int key) } static unsigned int -w32_get_modifiers () +w32_get_modifiers (void) { return ((modifier_set (VK_SHIFT) ? shift_modifier : 0) | (modifier_set (VK_CONTROL) ? ctrl_modifier : 0) | @@ -2330,7 +2250,7 @@ w32_get_modifiers () and window input. */ static int -construct_console_modifiers () +construct_console_modifiers (void) { int mods; @@ -2402,8 +2322,7 @@ static Lisp_Object w32_grabbed_keys; combinations like Alt-Tab which are used by the system. */ static void -register_hot_keys (hwnd) - HWND hwnd; +register_hot_keys (HWND hwnd) { Lisp_Object keylist; @@ -2422,8 +2341,7 @@ register_hot_keys (hwnd) } static void -unregister_hot_keys (hwnd) - HWND hwnd; +unregister_hot_keys (HWND hwnd) { Lisp_Object keylist; @@ -2629,7 +2547,7 @@ complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result) } static void -cancel_all_deferred_msgs () +cancel_all_deferred_msgs (void) { deferred_msg * item; @@ -2674,7 +2592,7 @@ w32_msg_worker (void *arg) } static void -signal_user_input () +signal_user_input (void) { /* Interrupt any lisp that wants to be interrupted by input. */ if (!NILP (Vthrow_on_input)) @@ -2692,13 +2610,9 @@ signal_user_input () static void -post_character_message (hwnd, msg, wParam, lParam, modifiers) - HWND hwnd; - UINT msg; - WPARAM wParam; - LPARAM lParam; - DWORD modifiers; - +post_character_message (HWND hwnd, UINT msg, + WPARAM wParam, LPARAM lParam, + DWORD modifiers) { W32Msg wmsg; @@ -2757,12 +2671,8 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers) /* Main window procedure */ -LRESULT CALLBACK -w32_wnd_proc (hwnd, msg, wParam, lParam) - HWND hwnd; - UINT msg; - WPARAM wParam; - LPARAM lParam; +static LRESULT CALLBACK +w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct frame *f; struct w32_display_info *dpyinfo = &one_w32_display_info; @@ -2820,7 +2730,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) { PAINTSTRUCT paintStruct; RECT update_rect; - bzero (&update_rect, sizeof (update_rect)); + memset (&update_rect, 0, sizeof (update_rect)); f = x_window_to_frame (dpyinfo, hwnd); if (f == 0) @@ -3197,9 +3107,6 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) HIMC context; struct window *w; - if (!context) - break; - f = x_window_to_frame (dpyinfo, hwnd); w = XWINDOW (FRAME_SELECTED_WINDOW (f)); @@ -3217,6 +3124,10 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) - WINDOW_MODE_LINE_HEIGHT (w)); context = get_ime_context_fn (hwnd); + + if (!context) + break; + set_ime_composition_window_fn (context, &form); release_ime_context_fn (hwnd, context); } @@ -4011,8 +3922,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) } static void -my_create_window (f) - struct frame * f; +my_create_window (struct frame * f) { MSG msg; @@ -4027,8 +3937,7 @@ my_create_window (f) messages for the tooltip. Creating tooltips indirectly also creates deadlocks when tooltips are created for menu items. */ static void -my_create_tip_window (f) - struct frame *f; +my_create_tip_window (struct frame *f) { RECT rect; @@ -4071,10 +3980,7 @@ my_create_tip_window (f) /* Create and set up the w32 window for frame F. */ static void -w32_window (f, window_prompting, minibuffer_only) - struct frame *f; - long window_prompting; - int minibuffer_only; +w32_window (struct frame *f, long window_prompting, int minibuffer_only) { BLOCK_INPUT; @@ -4122,9 +4028,7 @@ w32_window (f, window_prompting, minibuffer_only) well. */ static void -x_icon (f, parms) - struct frame *f; - Lisp_Object parms; +x_icon (struct frame *f, Lisp_Object parms) { Lisp_Object icon_x, icon_y; struct w32_display_info *dpyinfo = &one_w32_display_info; @@ -4163,8 +4067,7 @@ x_icon (f, parms) static void -x_make_gc (f) - struct frame *f; +x_make_gc (struct frame *f) { XGCValues gc_values; @@ -4197,8 +4100,7 @@ x_make_gc (f) constructed. */ static Lisp_Object -unwind_create_frame (frame) - Lisp_Object frame; +unwind_create_frame (Lisp_Object frame) { struct frame *f = XFRAME (frame); @@ -4223,9 +4125,7 @@ unwind_create_frame (frame) } static void -x_default_font_parameter (f, parms) - struct frame *f; - Lisp_Object parms; +x_default_font_parameter (struct frame *f, Lisp_Object parms) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL, @@ -4275,8 +4175,7 @@ then `default-minibuffer-frame' must be a frame whose minibuffer can be shared by the new frame. This function is an internal primitive--use `make-frame' instead. */) - (parameters) - Lisp_Object parameters; + (Lisp_Object parameters) { struct frame *f; Lisp_Object frame, tem; @@ -4359,7 +4258,7 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_method = output_w32; f->output_data.w32 = (struct w32_output *) xmalloc (sizeof (struct w32_output)); - bzero (f->output_data.w32, sizeof (struct w32_output)); + memset (f->output_data.w32, 0, sizeof (struct w32_output)); FRAME_FONTSET (f) = -1; f->icon_name @@ -4466,10 +4365,17 @@ This function is an internal primitive--use `make-frame' instead. */) happen. */ init_frame_faces (f); - x_default_parameter (f, parameters, Qmenu_bar_lines, make_number (1), - "menuBar", "MenuBar", RES_TYPE_NUMBER); - x_default_parameter (f, parameters, Qtool_bar_lines, make_number (1), - "toolBar", "ToolBar", RES_TYPE_NUMBER); + /* The X resources controlling the menu-bar and tool-bar are + processed specially at startup, and reflected in the mode + variables; ignore them here. */ + x_default_parameter (f, parameters, Qmenu_bar_lines, + NILP (Vmenu_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parameters, Qtool_bar_lines, + NILP (Vtool_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); x_default_parameter (f, parameters, Qbuffer_predicate, Qnil, "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); @@ -4583,8 +4489,7 @@ This function is an internal primitive--use `make-frame' instead. */) display info directly because we're called from frame.c, which doesn't know about that structure. */ Lisp_Object -x_get_focus_frame (frame) - struct frame *frame; +x_get_focus_frame (struct frame *frame) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (frame); Lisp_Object xfocus; @@ -4597,8 +4502,7 @@ x_get_focus_frame (frame) DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, doc: /* Give FRAME input focus, raising to foreground if necessary. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { x_focus_on_frame (check_x_frame (frame)); return Qnil; @@ -4607,8 +4511,7 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, doc: /* Internal function called by `color-defined-p', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { XColor foo; FRAME_PTR f = check_x_frame (frame); @@ -4623,8 +4526,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, doc: /* Internal function called by `color-values', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { XColor foo; FRAME_PTR f = check_x_frame (frame); @@ -4644,8 +4546,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, doc: /* Internal function called by `display-color-p', which see. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4662,8 +4563,7 @@ Note that color displays do support shades of gray. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4679,8 +4579,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4693,8 +4592,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4707,8 +4605,7 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4721,8 +4618,7 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); HDC hdc; @@ -4751,8 +4647,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4764,8 +4659,7 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { return build_string ("Microsoft Corp."); } @@ -4779,8 +4673,7 @@ release number. See also the function `x-server-vendor'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { return Fcons (make_number (w32_major_version), Fcons (make_number (w32_minor_version), @@ -4792,8 +4685,7 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { return make_number (1); } @@ -4804,8 +4696,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); HDC hdc; @@ -4825,8 +4716,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); @@ -4849,8 +4739,7 @@ The value may be `always', `when-mapped', or `not-useful'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { return intern ("not-useful"); } @@ -4864,8 +4753,7 @@ The value is one of the symbols `static-gray', `gray-scale', The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); Lisp_Object result = Qnil; @@ -4888,43 +4776,37 @@ DEFUN ("x-display-save-under", Fx_display_save_under, The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { return Qnil; } int -x_pixel_width (f) - register struct frame *f; +x_pixel_width (register struct frame *f) { return FRAME_PIXEL_WIDTH (f); } int -x_pixel_height (f) - register struct frame *f; +x_pixel_height (register struct frame *f) { return FRAME_PIXEL_HEIGHT (f); } int -x_char_width (f) - register struct frame *f; +x_char_width (register struct frame *f) { return FRAME_COLUMN_WIDTH (f); } int -x_char_height (f) - register struct frame *f; +x_char_height (register struct frame *f) { return FRAME_LINE_HEIGHT (f); } int -x_screen_planes (f) - register struct frame *f; +x_screen_planes (register struct frame *f) { return FRAME_W32_DISPLAY_INFO (f)->n_planes; } @@ -4933,8 +4815,7 @@ x_screen_planes (f) Open a new connection if necessary. */ struct w32_display_info * -x_display_info_for_name (name) - Lisp_Object name; +x_display_info_for_name (Lisp_Object name) { Lisp_Object names; struct w32_display_info *dpyinfo; @@ -4974,8 +4855,7 @@ DISPLAY is the name of the display to connect to. Optional second arg XRM-STRING is a string of resources in xrdb format. If the optional third arg MUST-SUCCEED is non-nil, terminate Emacs if we can't open the connection. */) - (display, xrm_string, must_succeed) - Lisp_Object display, xrm_string, must_succeed; + (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed) { unsigned char *xrm_option; struct w32_display_info *dpyinfo; @@ -5063,8 +4943,7 @@ DEFUN ("x-close-connection", Fx_close_connection, doc: /* Close the connection to DISPLAY's server. For DISPLAY, specify either a frame or a display name (a string). If DISPLAY is nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); int i; @@ -5083,7 +4962,7 @@ If DISPLAY is nil, that stands for the selected frame's display. */) DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, doc: /* Return the list of display names that Emacs has connections to. */) - () + (void) { Lisp_Object tail, result; @@ -5096,8 +4975,7 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, doc: /* This is a noop on W32 systems. */) - (on, display) - Lisp_Object display, on; + (Lisp_Object on, Lisp_Object display) { return Qnil; } @@ -5126,8 +5004,7 @@ If OUTER_P is non-nil, the property is changed for the outer X window of FRAME. Default is to change on the edit X window. Value is VALUE. */) - (prop, value, frame, type, format, outer_p) - Lisp_Object prop, value, frame, type, format, outer_p; + (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) { #if 0 /* TODO : port window properties to W32 */ struct frame *f = check_x_frame (frame); @@ -5156,8 +5033,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property, Sx_delete_window_property, 1, 2, 0, doc: /* Remove window property PROP from X window of FRAME. FRAME nil or omitted means use the selected frame. Value is PROP. */) - (prop, frame) - Lisp_Object prop, frame; + (Lisp_Object prop, Lisp_Object frame) { #if 0 /* TODO : port window properties to W32 */ @@ -5184,8 +5060,7 @@ DEFUN ("x-window-property", Fx_window_property, Sx_window_property, If FRAME is nil or omitted, use the selected frame. Value is nil if FRAME hasn't a property with name PROP or if PROP has no string value. */) - (prop, frame) - Lisp_Object prop, frame; + (Lisp_Object prop, Lisp_Object frame) { #if 0 /* TODO : port window properties to W32 */ @@ -5249,7 +5124,7 @@ extern Lisp_Object Vhourglass_delay; xdisp.c could be used. */ int -hourglass_started () +hourglass_started (void) { return hourglass_shown_p || hourglass_timer; } @@ -5257,7 +5132,7 @@ hourglass_started () /* Cancel a currently active hourglass timer, and start a new one. */ void -start_hourglass () +start_hourglass (void) { DWORD delay; int secs, msecs = 0; @@ -5293,7 +5168,7 @@ start_hourglass () cursor if shown. */ void -cancel_hourglass () +cancel_hourglass (void) { if (hourglass_timer) { @@ -5312,8 +5187,7 @@ cancel_hourglass () to indicate that an hourglass cursor is shown. */ static void -w32_show_hourglass (f) - struct frame *f; +w32_show_hourglass (struct frame *f) { if (!hourglass_shown_p) { @@ -5328,7 +5202,7 @@ w32_show_hourglass (f) /* Hide the hourglass cursor on all frames, if it is currently shown. */ static void -w32_hide_hourglass () +w32_hide_hourglass (void) { if (hourglass_shown_p) { @@ -5356,10 +5230,10 @@ w32_hide_hourglass () Tool tips ***********************************************************************/ -static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *, - Lisp_Object, Lisp_Object)); -static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object, - Lisp_Object, int, int, int *, int *)); +static Lisp_Object x_create_tip_frame (struct w32_display_info *, + Lisp_Object, Lisp_Object); +static void compute_tip_xy (struct frame *, Lisp_Object, Lisp_Object, + Lisp_Object, int, int, int *, int *); /* The frame of a currently visible tooltip. */ @@ -5382,8 +5256,7 @@ Lisp_Object Vx_max_tooltip_size; static Lisp_Object -unwind_create_tip_frame (frame) - Lisp_Object frame; +unwind_create_tip_frame (Lisp_Object frame) { Lisp_Object deleted; @@ -5408,9 +5281,8 @@ unwind_create_tip_frame (frame) when this happens. */ static Lisp_Object -x_create_tip_frame (dpyinfo, parms, text) - struct w32_display_info *dpyinfo; - Lisp_Object parms, text; +x_create_tip_frame (struct w32_display_info *dpyinfo, + Lisp_Object parms, Lisp_Object text) { struct frame *f; Lisp_Object frame, tem; @@ -5474,7 +5346,7 @@ x_create_tip_frame (dpyinfo, parms, text) f->output_method = output_w32; f->output_data.w32 = (struct w32_output *) xmalloc (sizeof (struct w32_output)); - bzero (f->output_data.w32, sizeof (struct w32_output)); + memset (f->output_data.w32, 0, sizeof (struct w32_output)); FRAME_FONTSET (f) = -1; f->icon_name = Qnil; @@ -5649,11 +5521,9 @@ x_create_tip_frame (dpyinfo, parms, text) the display in *ROOT_X, and *ROOT_Y. */ static void -compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) - struct frame *f; - Lisp_Object parms, dx, dy; - int width, height; - int *root_x, *root_y; +compute_tip_xy (struct frame *f, + Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, + int width, int height, int *root_x, int *root_y) { Lisp_Object left, top; int min_x, min_y, max_x, max_y; @@ -5757,8 +5627,7 @@ DY added (default is -10). A tooltip's maximum size is specified by `x-max-tooltip-size'. Text larger than the specified size is clipped. */) - (string, frame, parms, timeout, dx, dy) - Lisp_Object string, frame, parms, timeout, dx, dy; + (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy) { struct frame *f; struct window *w; @@ -5987,7 +5856,7 @@ Text larger than the specified size is clipped. */) DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, doc: /* Hide the current tooltip window, if there is any. Value is t if tooltip was open, nil otherwise. */) - () + (void) { int count; Lisp_Object deleted, frame, timer; @@ -6031,12 +5900,8 @@ extern Lisp_Object Qfile_name_history; read-only when "Directories" is selected in the filter. This allows us to work around the fact that the standard Open File dialog does not support directories. */ -UINT CALLBACK -file_dialog_callback (hwnd, msg, wParam, lParam) - HWND hwnd; - UINT msg; - WPARAM wParam; - LPARAM lParam; +static UINT CALLBACK +file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_NOTIFY) { @@ -6087,8 +5952,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file selection box, if specified. Ensure that file exists if MUSTMATCH is non-nil. If ONLY-DIR-P is non-nil, the user can only select directories. */) - (prompt, dir, default_filename, mustmatch, only_dir_p) - Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; + (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { struct frame *f = SELECTED_FRAME (); Lisp_Object file = Qnil; @@ -6137,7 +6001,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) specbind (Qinhibit_redisplay, Qt); BLOCK_INPUT; - bzero (&new_file_details, sizeof (new_file_details)); + memset (&new_file_details, 0, sizeof (new_file_details)); /* Apparently NT4 crashes if you give it an unexpected size. I'm not sure about Windows 9x, so play it safe. */ if (w32_major_version > 4 && w32_major_version < 95) @@ -6216,8 +6080,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash, Ssystem_move_file_to_trash, 1, 1, 0, doc: /* Move file or directory named FILENAME to the recycle bin. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object handler; Lisp_Object encoded_file; @@ -6248,10 +6111,10 @@ DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash, /* On Windows, write permission is required to delete/move files. */ _chmod (path, 0666); - bzero (tmp_path, sizeof (tmp_path)); + memset (tmp_path, 0, sizeof (tmp_path)); strcpy (tmp_path, path); - bzero (&file_op, sizeof (file_op)); + memset (&file_op, 0, sizeof (file_op)); file_op.hwnd = HWND_DESKTOP; file_op.wFunc = FO_DELETE; file_op.pFrom = tmp_path; @@ -6279,8 +6142,7 @@ to activate the menubar for keyboard access. #xf140 activates the screen saver if defined. If optional parameter FRAME is not specified, use selected frame. */) - (command, frame) - Lisp_Object command, frame; + (Lisp_Object command, Lisp_Object frame) { FRAME_PTR f = check_x_frame (frame); @@ -6333,8 +6195,7 @@ an integer representing a ShowWindow flag: 1 - start normally 3 - start maximized 6 - start minimized */) - (operation, document, parameters, show_flag) - Lisp_Object operation, document, parameters, show_flag; + (Lisp_Object operation, Lisp_Object document, Lisp_Object parameters, Lisp_Object show_flag) { Lisp_Object current_dir; char *errstr; @@ -6390,8 +6251,7 @@ lookup_vk_code (char *key) /* Convert a one-element vector style key sequence to a hot key definition. */ static Lisp_Object -w32_parse_hot_key (key) - Lisp_Object key; +w32_parse_hot_key (Lisp_Object key) { /* Copied from Fdefine_key and store_in_keymap. */ register Lisp_Object c; @@ -6472,8 +6332,7 @@ modifier is interpreted as Alt if `w32-alt-is-meta' is t, and hyper is always interpreted as the Windows modifier keys. The return value is the hotkey-id if registered, otherwise nil. */) - (key) - Lisp_Object key; + (Lisp_Object key) { key = w32_parse_hot_key (key); @@ -6505,8 +6364,7 @@ The return value is the hotkey-id if registered, otherwise nil. */) DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key, Sw32_unregister_hot_key, 1, 1, 0, doc: /* Unregister KEY as a hot-key combination. */) - (key) - Lisp_Object key; + (Lisp_Object key) { Lisp_Object item; @@ -6538,7 +6396,7 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key, DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys, Sw32_registered_hot_keys, 0, 0, 0, doc: /* Return list of registered hot-key IDs. */) - () + (void) { return Fdelq (Qnil, Fcopy_sequence (w32_grabbed_keys)); } @@ -6547,8 +6405,7 @@ DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key, Sw32_reconstruct_hot_key, 1, 1, 0, doc: /* Convert hot-key ID to a lisp key combination. usage: (w32-reconstruct-hot-key ID) */) - (hotkeyid) - Lisp_Object hotkeyid; + (Lisp_Object hotkeyid) { int vk_code, w32_modifiers; Lisp_Object key; @@ -6582,8 +6439,7 @@ DEFUN ("w32-toggle-lock-key", Fw32_toggle_lock_key, KEY can be `capslock', `kp-numlock', or `scroll'. If the optional parameter NEW-STATE is a number, then the state of KEY is set to off if the low bit of NEW-STATE is zero, otherwise on. */) - (key, new_state) - Lisp_Object key, new_state; + (Lisp_Object key, Lisp_Object new_state) { int vk_code; @@ -6619,8 +6475,7 @@ DEFUN ("w32-window-exists-p", Fw32_window_exists_p, Sw32_window_exists_p, doc: /* Return non-nil if a window exists with the specified CLASS and NAME. This is a direct interface to the Windows API FindWindow function. */) - (class, name) -Lisp_Object class, name; + (Lisp_Object class, Lisp_Object name) { HWND hnd; @@ -6649,7 +6504,7 @@ The following %-sequences are provided: %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min' */) - () + (void) { Lisp_Object status = Qnil; @@ -6753,8 +6608,7 @@ Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total storage of the file system, FREE is the free storage, and AVAIL is the storage available to a non-superuser. All 3 numbers are in bytes. If the underlying system call fails, value is nil. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { Lisp_Object encoded, value; @@ -6846,7 +6700,7 @@ If the underlying system call fails, value is nil. */) DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, 0, 0, 0, doc: /* Return the name of Windows default printer device. */) - () + (void) { static char pname_buf[256]; int err; @@ -6955,10 +6809,11 @@ frame_parm_handler w32_frame_parm_handlers[] = x_set_font_backend, x_set_alpha, 0, /* x_set_sticky */ + 0, /* x_set_tool_bar_position */ }; void -syms_of_w32fns () +syms_of_w32fns (void) { globals_of_w32fns (); /* This is zero if not using MS-Windows. */ @@ -7315,7 +7170,7 @@ only be necessary if the default setting causes problems. */); is non zero. */ void -globals_of_w32fns () +globals_of_w32fns (void) { HMODULE user32_lib = GetModuleHandle ("user32.dll"); /* @@ -7324,9 +7179,6 @@ globals_of_w32fns () */ track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent"); - /* ditto for GetClipboardSequenceNumber. */ - clipboard_sequence_fn = (ClipboardSequence_Proc) - GetProcAddress (user32_lib, "GetClipboardSequenceNumber"); monitor_from_point_fn = (MonitorFromPoint_Proc) GetProcAddress (user32_lib, "MonitorFromPoint"); @@ -7358,7 +7210,7 @@ globals_of_w32fns () #undef abort void -w32_abort () +w32_abort (void) { int button; button = MessageBox (NULL, @@ -7386,7 +7238,7 @@ w32_abort () /* For convenience when debugging. */ int -w32_last_error () +w32_last_error (void) { return GetLastError (); } diff --git a/src/w32font.c b/src/w32font.c index 679f17329ab..f489fe2d763 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -72,7 +72,7 @@ static Lisp_Object Qstandard, Qsubpixel, Qnatural; static Lisp_Object Qzh; /* scripts */ -static Lisp_Object Qlatin, Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; +static Lisp_Object Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew; static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali; static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu; static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao; @@ -106,28 +106,28 @@ static Lisp_Object Vw32_charset_info_alist; /* Font spacing symbols - defined in font.c. */ extern Lisp_Object Qc, Qp, Qm; -static void fill_in_logfont P_ ((FRAME_PTR, LOGFONT *, Lisp_Object)); +static void fill_in_logfont (FRAME_PTR, LOGFONT *, Lisp_Object); -static BYTE w32_antialias_type P_ ((Lisp_Object)); -static Lisp_Object lispy_antialias_type P_ ((BYTE)); +static BYTE w32_antialias_type (Lisp_Object); +static Lisp_Object lispy_antialias_type (BYTE); -static Lisp_Object font_supported_scripts P_ ((FONTSIGNATURE *)); -static int w32font_full_name P_ ((LOGFONT *, Lisp_Object, int, char *, int)); -static void compute_metrics P_ ((HDC, struct w32font_info *, unsigned int, - struct w32_metric_cache *)); +static Lisp_Object font_supported_scripts (FONTSIGNATURE *); +static int w32font_full_name (LOGFONT *, Lisp_Object, int, char *, int); +static void compute_metrics (HDC, struct w32font_info *, unsigned int, + struct w32_metric_cache *); -static Lisp_Object w32_registry P_ ((LONG, DWORD)); +static Lisp_Object w32_registry (LONG, DWORD); /* EnumFontFamiliesEx callbacks. */ -static int CALLBACK add_font_entity_to_list P_ ((ENUMLOGFONTEX *, +static int CALLBACK add_font_entity_to_list (ENUMLOGFONTEX *, + NEWTEXTMETRICEX *, + DWORD, LPARAM); +static int CALLBACK add_one_font_entity_to_list (ENUMLOGFONTEX *, NEWTEXTMETRICEX *, - DWORD, LPARAM)); -static int CALLBACK add_one_font_entity_to_list P_ ((ENUMLOGFONTEX *, - NEWTEXTMETRICEX *, - DWORD, LPARAM)); -static int CALLBACK add_font_name_to_list P_ ((ENUMLOGFONTEX *, - NEWTEXTMETRICEX *, - DWORD, LPARAM)); + DWORD, LPARAM); +static int CALLBACK add_font_name_to_list (ENUMLOGFONTEX *, + NEWTEXTMETRICEX *, + DWORD, LPARAM); /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track of what we really want. */ @@ -149,12 +149,11 @@ struct font_callback_data /* Handles the problem that EnumFontFamiliesEx will not return all style variations if the font name is not specified. */ -static void list_all_matching_fonts P_ ((struct font_callback_data *)); +static void list_all_matching_fonts (struct font_callback_data *); static int -memq_no_quit (elt, list) - Lisp_Object elt, list; +memq_no_quit (Lisp_Object elt, Lisp_Object list) { while (CONSP (list) && ! EQ (XCAR (list), elt)) list = XCDR (list); @@ -162,8 +161,7 @@ memq_no_quit (elt, list) } Lisp_Object -intern_font_name (string) - char * string; +intern_font_name (char * string) { Lisp_Object obarray, tem, str; int len; @@ -185,8 +183,7 @@ intern_font_name (string) Return a cache of font-entities on FRAME. The cache must be a cons whose cdr part is the actual cache area. */ Lisp_Object -w32font_get_cache (f) - FRAME_PTR f; +w32font_get_cache (FRAME_PTR f) { struct w32_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -198,8 +195,7 @@ w32font_get_cache (f) is a vector of font-entities. This is the sole API that allocates font-entities. */ static Lisp_Object -w32font_list (frame, font_spec) - Lisp_Object frame, font_spec; +w32font_list (Lisp_Object frame, Lisp_Object font_spec) { Lisp_Object fonts = w32font_list_internal (frame, font_spec, 0); FONT_ADD_LOG ("w32font-list", font_spec, fonts); @@ -211,8 +207,7 @@ w32font_list (frame, font_spec) FRAME. The closeness is detemined by the font backend, thus `face-font-selection-order' is ignored here. */ static Lisp_Object -w32font_match (frame, font_spec) - Lisp_Object frame, font_spec; +w32font_match (Lisp_Object frame, Lisp_Object font_spec) { Lisp_Object entity = w32font_match_internal (frame, font_spec, 0); FONT_ADD_LOG ("w32font-match", font_spec, entity); @@ -223,15 +218,14 @@ w32font_match (frame, font_spec) List available families. The value is a list of family names (symbols). */ static Lisp_Object -w32font_list_family (frame) - Lisp_Object frame; +w32font_list_family (Lisp_Object frame) { Lisp_Object list = Qnil; LOGFONT font_match_pattern; HDC dc; FRAME_PTR f = XFRAME (frame); - bzero (&font_match_pattern, sizeof (font_match_pattern)); + memset (&font_match_pattern, 0, sizeof (font_match_pattern)); font_match_pattern.lfCharSet = DEFAULT_CHARSET; dc = get_frame_dc (f); @@ -248,10 +242,7 @@ w32font_list_family (frame) Open a font specified by FONT_ENTITY on frame F. If the font is scalable, open it with PIXEL_SIZE. */ static Lisp_Object -w32font_open (f, font_entity, pixel_size) - FRAME_PTR f; - Lisp_Object font_entity; - int pixel_size; +w32font_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) { Lisp_Object font_object = font_make_object (VECSIZE (struct w32font_info), @@ -275,9 +266,7 @@ w32font_open (f, font_entity, pixel_size) /* w32 implementation of close for font_backend. Close FONT on frame F. */ void -w32font_close (f, font) - FRAME_PTR f; - struct font *font; +w32font_close (FRAME_PTR f, struct font *font) { int i; struct w32font_info *w32_font = (struct w32font_info *) font; @@ -303,9 +292,7 @@ w32font_close (f, font) return 1. If not, return 0. If a font must be opened to check it, return -1. */ int -w32font_has_char (entity, c) - Lisp_Object entity; - int c; +w32font_has_char (Lisp_Object entity, int c) { /* We can't be certain about which characters a font will support until we open it. Checking the scripts that the font supports turns out @@ -354,9 +341,7 @@ w32font_has_char (entity, c) which characters are not supported by the font. */ static unsigned -w32font_encode_char (font, c) - struct font *font; - int c; +w32font_encode_char (struct font *font, int c) { struct w32font_info * w32_font = (struct w32font_info *)font; @@ -373,11 +358,8 @@ w32font_encode_char (font, c) CODE (length NGLYPHS). Apparently metrics can be NULL, in this case just return the overall width. */ int -w32font_text_extents (font, code, nglyphs, metrics) - struct font *font; - unsigned *code; - int nglyphs; - struct font_metrics *metrics; +w32font_text_extents (struct font *font, unsigned *code, + int nglyphs, struct font_metrics *metrics) { int i; HFONT old_font = NULL; @@ -391,7 +373,7 @@ w32font_text_extents (font, code, nglyphs, metrics) if (metrics) { - bzero (metrics, sizeof (struct font_metrics)); + memset (metrics, 0, sizeof (struct font_metrics)); metrics->ascent = font->ascent; metrics->descent = font->descent; @@ -412,9 +394,9 @@ w32font_text_extents (font, code, nglyphs, metrics) = xrealloc (w32_font->cached_metrics, (block + 1) * sizeof (struct w32_metric_cache *)); - bzero (w32_font->cached_metrics + w32_font->n_cache_blocks, - ((block + 1 - w32_font->n_cache_blocks) - * sizeof (struct w32_metric_cache *))); + memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0, + ((block + 1 - w32_font->n_cache_blocks) + * sizeof (struct w32_metric_cache *))); w32_font->n_cache_blocks = block + 1; } @@ -422,8 +404,8 @@ w32font_text_extents (font, code, nglyphs, metrics) { w32_font->cached_metrics[block] = xmalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); - bzero (w32_font->cached_metrics[block], - CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); + memset (w32_font->cached_metrics[block], 0, + CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache)); } char_metric = w32_font->cached_metrics[block] + pos_in_block; @@ -552,9 +534,8 @@ w32font_text_extents (font, code, nglyphs, metrics) */ int -w32font_draw (s, from, to, x, y, with_background) - struct glyph_string *s; - int from, to, x, y, with_background; +w32font_draw (struct glyph_string *s, int from, int to, + int x, int y, int with_background) { UINT options; HRGN orig_clip = NULL; @@ -715,9 +696,7 @@ w32font_otf_drive (struct font *font, Lisp_Object features, Additional parameter opentype_only restricts the returned fonts to opentype fonts, which can be used with the Uniscribe backend. */ Lisp_Object -w32font_list_internal (frame, font_spec, opentype_only) - Lisp_Object frame, font_spec; - int opentype_only; +w32font_list_internal (Lisp_Object frame, Lisp_Object font_spec, int opentype_only) { struct font_callback_data match_data; HDC dc; @@ -727,7 +706,7 @@ w32font_list_internal (frame, font_spec, opentype_only) match_data.list = Qnil; match_data.frame = frame; - bzero (&match_data.pattern, sizeof (LOGFONT)); + memset (&match_data.pattern, 0, sizeof (LOGFONT)); fill_in_logfont (f, &match_data.pattern, font_spec); /* If the charset is unrecognized, then we won't find a font, so don't @@ -770,9 +749,7 @@ w32font_list_internal (frame, font_spec, opentype_only) Additional parameter opentype_only restricts the returned fonts to opentype fonts, which can be used with the Uniscribe backend. */ Lisp_Object -w32font_match_internal (frame, font_spec, opentype_only) - Lisp_Object frame, font_spec; - int opentype_only; +w32font_match_internal (Lisp_Object frame, Lisp_Object font_spec, int opentype_only) { struct font_callback_data match_data; HDC dc; @@ -782,7 +759,7 @@ w32font_match_internal (frame, font_spec, opentype_only) match_data.frame = frame; match_data.list = Qnil; - bzero (&match_data.pattern, sizeof (LOGFONT)); + memset (&match_data.pattern, 0, sizeof (LOGFONT)); fill_in_logfont (f, &match_data.pattern, font_spec); match_data.opentype_only = opentype_only; @@ -800,11 +777,8 @@ w32font_match_internal (frame, font_spec, opentype_only) } int -w32font_open_internal (f, font_entity, pixel_size, font_object) - FRAME_PTR f; - Lisp_Object font_entity; - int pixel_size; - Lisp_Object font_object; +w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, + int pixel_size, Lisp_Object font_object) { int len, size, i; LOGFONT logfont; @@ -821,7 +795,7 @@ w32font_open_internal (f, font_entity, pixel_size, font_object) if (!font) return 0; - bzero (&logfont, sizeof (logfont)); + memset (&logfont, 0, sizeof (logfont)); fill_in_logfont (f, &logfont, font_entity); /* Prefer truetype fonts, to avoid known problems with type1 fonts, and @@ -850,8 +824,8 @@ w32font_open_internal (f, font_entity, pixel_size, font_object) { metrics = (OUTLINETEXTMETRICW *) alloca (len); if (GetOutlineTextMetricsW (dc, len, metrics)) - bcopy (&metrics->otmTextMetrics, &w32_font->metrics, - sizeof (TEXTMETRICW)); + memcpy (&w32_font->metrics, &metrics->otmTextMetrics, + sizeof (TEXTMETRICW)); else metrics = NULL; } @@ -951,11 +925,9 @@ w32font_open_internal (f, font_entity, pixel_size, font_object) /* Callback function for EnumFontFamiliesEx. * Adds the name of a font to a Lisp list (passed in as the lParam arg). */ static int CALLBACK -add_font_name_to_list (logical_font, physical_font, font_type, list_object) - ENUMLOGFONTEX *logical_font; - NEWTEXTMETRICEX *physical_font; - DWORD font_type; - LPARAM list_object; +add_font_name_to_list (ENUMLOGFONTEX *logical_font, + NEWTEXTMETRICEX *physical_font, + DWORD font_type, LPARAM list_object) { Lisp_Object* list = (Lisp_Object *) list_object; Lisp_Object family; @@ -971,19 +943,17 @@ add_font_name_to_list (logical_font, physical_font, font_type, list_object) return 1; } -static int w32_decode_weight P_ ((int)); -static int w32_encode_weight P_ ((int)); +static int w32_decode_weight (int); +static int w32_encode_weight (int); /* Convert an enumerated Windows font to an Emacs font entity. */ static Lisp_Object -w32_enumfont_pattern_entity (frame, logical_font, physical_font, - font_type, requested_font, backend) - Lisp_Object frame; - ENUMLOGFONTEX *logical_font; - NEWTEXTMETRICEX *physical_font; - DWORD font_type; - LOGFONT *requested_font; - Lisp_Object backend; +w32_enumfont_pattern_entity (Lisp_Object frame, + ENUMLOGFONTEX *logical_font, + NEWTEXTMETRICEX *physical_font, + DWORD font_type, + LOGFONT *requested_font, + Lisp_Object backend) { Lisp_Object entity, tem; LOGFONT *lf = (LOGFONT*) logical_font; @@ -1088,7 +1058,7 @@ w32_enumfont_pattern_entity (frame, logical_font, physical_font, /* Convert generic families to the family portion of lfPitchAndFamily. */ -BYTE +static BYTE w32_generic_family (Lisp_Object name) { /* Generic families. */ @@ -1107,8 +1077,7 @@ w32_generic_family (Lisp_Object name) } static int -logfonts_match (font, pattern) - LOGFONT *font, *pattern; +logfonts_match (LOGFONT *font, LOGFONT *pattern) { /* Only check height for raster fonts. */ if (pattern->lfHeight && font->lfOutPrecision == OUT_STRING_PRECIS @@ -1132,12 +1101,9 @@ logfonts_match (font, pattern) #define CSB_CHINESE ((1 << 18) | (1 << 20)) static int -font_matches_spec (type, font, spec, backend, logfont) - DWORD type; - NEWTEXTMETRICEX *font; - Lisp_Object spec; - Lisp_Object backend; - LOGFONT *logfont; +font_matches_spec (DWORD type, NEWTEXTMETRICEX *font, + Lisp_Object spec, Lisp_Object backend, + LOGFONT *logfont) { Lisp_Object extra, val; @@ -1322,9 +1288,7 @@ font_matches_spec (type, font, spec, backend, logfont) } static int -w32font_coverage_ok (coverage, charset) - FONTSIGNATURE * coverage; - BYTE charset; +w32font_coverage_ok (FONTSIGNATURE * coverage, BYTE charset) { DWORD subrange1 = coverage->fsUsb[1]; @@ -1350,9 +1314,7 @@ w32font_coverage_ok (coverage, charset) static int -check_face_name (font, full_name) - LOGFONT *font; - char *full_name; +check_face_name (LOGFONT *font, char *full_name) { char full_iname[LF_FULLFACESIZE+1]; @@ -1397,11 +1359,9 @@ check_face_name (font, full_name) * and the list to which the fonts are added are passed in via the * lparam argument, in the form of a font_callback_data struct. */ static int CALLBACK -add_font_entity_to_list (logical_font, physical_font, font_type, lParam) - ENUMLOGFONTEX *logical_font; - NEWTEXTMETRICEX *physical_font; - DWORD font_type; - LPARAM lParam; +add_font_entity_to_list (ENUMLOGFONTEX *logical_font, + NEWTEXTMETRICEX *physical_font, + DWORD font_type, LPARAM lParam) { struct font_callback_data *match_data = (struct font_callback_data *) lParam; @@ -1510,11 +1470,9 @@ add_font_entity_to_list (logical_font, physical_font, font_type, lParam) /* Callback function for EnumFontFamiliesEx. * Terminates the search once we have a match. */ static int CALLBACK -add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam) - ENUMLOGFONTEX *logical_font; - NEWTEXTMETRICEX *physical_font; - DWORD font_type; - LPARAM lParam; +add_one_font_entity_to_list (ENUMLOGFONTEX *logical_font, + NEWTEXTMETRICEX *physical_font, + DWORD font_type, LPARAM lParam) { struct font_callback_data *match_data = (struct font_callback_data *) lParam; @@ -1526,8 +1484,7 @@ add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam) /* Old function to convert from x to w32 charset, from w32fns.c. */ static LONG -x_to_w32_charset (lpcs) - char * lpcs; +x_to_w32_charset (char * lpcs) { Lisp_Object this_entry, w32_charset; char *charset; @@ -1609,8 +1566,7 @@ x_to_w32_charset (lpcs) /* Convert a Lisp font registry (symbol) to a windows charset. */ static LONG -registry_to_w32_charset (charset) - Lisp_Object charset; +registry_to_w32_charset (Lisp_Object charset) { if (EQ (charset, Qiso10646_1) || EQ (charset, Qunicode_bmp) || EQ (charset, Qunicode_sip)) @@ -1625,9 +1581,7 @@ registry_to_w32_charset (charset) /* Old function to convert from w32 to x charset, from w32fns.c. */ static char * -w32_to_x_charset (fncharset, matching) - int fncharset; - char *matching; +w32_to_x_charset (int fncharset, char *matching) { static char buf[32]; Lisp_Object charset_type; @@ -1821,9 +1775,7 @@ w32_to_x_charset (fncharset, matching) } static Lisp_Object -w32_registry (w32_charset, font_type) - LONG w32_charset; - DWORD font_type; +w32_registry (LONG w32_charset, DWORD font_type) { char *charset; @@ -1837,8 +1789,7 @@ w32_registry (w32_charset, font_type) } static int -w32_decode_weight (fnweight) - int fnweight; +w32_decode_weight (int fnweight) { if (fnweight >= FW_HEAVY) return 210; if (fnweight >= FW_EXTRABOLD) return 205; @@ -1852,8 +1803,7 @@ w32_decode_weight (fnweight) } static int -w32_encode_weight (n) - int n; +w32_encode_weight (int n) { if (n >= 210) return FW_HEAVY; if (n >= 205) return FW_EXTRABOLD; @@ -1869,8 +1819,7 @@ w32_encode_weight (n) /* Convert a Windows font weight into one of the weights supported by fontconfig (see font.c:font_parse_fcname). */ static Lisp_Object -w32_to_fc_weight (n) - int n; +w32_to_fc_weight (int n) { if (n >= FW_EXTRABOLD) return intern ("black"); if (n >= FW_BOLD) return intern ("bold"); @@ -1881,10 +1830,7 @@ w32_to_fc_weight (n) /* Fill in all the available details of LOGFONT from FONT_SPEC. */ static void -fill_in_logfont (f, logfont, font_spec) - FRAME_PTR f; - LOGFONT *logfont; - Lisp_Object font_spec; +fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec) { Lisp_Object tmp, extra; int dpi = FRAME_W32_DISPLAY_INFO (f)->resy; @@ -2028,8 +1974,7 @@ fill_in_logfont (f, logfont, font_spec) } static void -list_all_matching_fonts (match_data) - struct font_callback_data *match_data; +list_all_matching_fonts (struct font_callback_data *match_data) { HDC dc; Lisp_Object families = w32font_list_family (match_data->frame); @@ -2065,8 +2010,7 @@ list_all_matching_fonts (match_data) } static Lisp_Object -lispy_antialias_type (type) - BYTE type; +lispy_antialias_type (BYTE type) { Lisp_Object lispy; @@ -2093,8 +2037,7 @@ lispy_antialias_type (type) /* Convert antialiasing symbols to lfQuality */ static BYTE -w32_antialias_type (type) - Lisp_Object type; +w32_antialias_type (Lisp_Object type) { if (EQ (type, Qnone)) return NONANTIALIASED_QUALITY; @@ -2240,12 +2183,8 @@ font_supported_scripts (FONTSIGNATURE * sig) The full name is in fcname format, with weight, slant and antialiasing specified if they are not "normal". */ static int -w32font_full_name (font, font_obj, pixel_size, name, nbytes) - LOGFONT * font; - Lisp_Object font_obj; - int pixel_size; - char *name; - int nbytes; +w32font_full_name (LOGFONT * font, Lisp_Object font_obj, + int pixel_size, char *name, int nbytes) { int len, height, outline; char *p; @@ -2317,11 +2256,7 @@ w32font_full_name (font, font_obj, pixel_size, name, nbytes) the function returns -1, otherwise it returns the number of bytes written to FCNAME. */ static int -logfont_to_fcname (font, pointsize, fcname, size) - LOGFONT* font; - int pointsize; - char *fcname; - int size; +logfont_to_fcname (LOGFONT* font, int pointsize, char *fcname, int size) { int len, height; char *p = fcname; @@ -2360,11 +2295,8 @@ logfont_to_fcname (font, pointsize, fcname, size) } static void -compute_metrics (dc, w32_font, code, metrics) - HDC dc; - struct w32font_info *w32_font; - unsigned int code; - struct w32_metric_cache *metrics; +compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code, + struct w32_metric_cache *metrics) { GLYPHMETRICS gm; MAT2 transform; @@ -2373,7 +2305,7 @@ compute_metrics (dc, w32_font, code, metrics) if (w32_font->glyph_idx) options |= GGO_GLYPH_INDEX; - bzero (&transform, sizeof (transform)); + memset (&transform, 0, sizeof (transform)); transform.eM11.value = 1; transform.eM22.value = 1; @@ -2396,8 +2328,7 @@ Return fontconfig style font string corresponding to the selection. If FRAME is omitted or nil, it defaults to the selected frame. If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts in the font selection dialog. */) - (frame, exclude_proportional) - Lisp_Object frame, exclude_proportional; + (Lisp_Object frame, Lisp_Object exclude_proportional) { FRAME_PTR f = check_x_frame (frame); CHOOSEFONT cf; @@ -2407,8 +2338,8 @@ in the font selection dialog. */) HANDLE oldobj; char buf[100]; - bzero (&cf, sizeof (cf)); - bzero (&lf, sizeof (lf)); + memset (&cf, 0, sizeof (cf)); + memset (&lf, 0, sizeof (lf)); cf.lStructSize = sizeof (cf); cf.hwndOwner = FRAME_W32_WINDOW (f); @@ -2458,9 +2389,7 @@ static const char *w32font_non_booleans [] = { }; static void -w32font_filter_properties (font, alist) - Lisp_Object font; - Lisp_Object alist; +w32font_filter_properties (Lisp_Object font, Lisp_Object alist) { font_filter_properties (font, alist, w32font_booleans, w32font_non_booleans); } @@ -2501,7 +2430,7 @@ struct font_driver w32font_driver = /* Initialize state that does not change between invocations. This is only called when Emacs is dumped. */ void -syms_of_w32font () +syms_of_w32font (void) { DEFSYM (Qgdi, "gdi"); DEFSYM (Quniscribe, "uniscribe"); diff --git a/src/w32font.h b/src/w32font.h index 3e2345589b5..6479f95faf5 100644 --- a/src/w32font.h +++ b/src/w32font.h @@ -62,26 +62,26 @@ struct w32font_info #define CACHE_BLOCKSIZE 128 -Lisp_Object w32font_get_cache P_ ((FRAME_PTR fe)); -Lisp_Object w32font_list_internal P_ ((Lisp_Object frame, - Lisp_Object font_spec, - int opentype_only)); -Lisp_Object w32font_match_internal P_ ((Lisp_Object frame, - Lisp_Object font_spec, - int opentype_only)); -int w32font_open_internal P_ ((FRAME_PTR f, Lisp_Object font_entity, - int pixel_size, Lisp_Object font_object)); -void w32font_close P_ ((FRAME_PTR f, struct font *font)); -int w32font_has_char P_ ((Lisp_Object entity, int c)); -int w32font_text_extents P_ ((struct font *font, unsigned *code, int nglyphs, - struct font_metrics *metrics)); -int w32font_draw P_ ((struct glyph_string *s, int from, int to, - int x, int y, int with_background)); - - -int uniscribe_check_otf P_ ((LOGFONT *font, Lisp_Object otf_spec)); - -Lisp_Object intern_font_name P_ ((char *)); +Lisp_Object w32font_get_cache (FRAME_PTR fe); +Lisp_Object w32font_list_internal (Lisp_Object frame, + Lisp_Object font_spec, + int opentype_only); +Lisp_Object w32font_match_internal (Lisp_Object frame, + Lisp_Object font_spec, + int opentype_only); +int w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, + int pixel_size, Lisp_Object font_object); +void w32font_close (FRAME_PTR f, struct font *font); +int w32font_has_char (Lisp_Object entity, int c); +int w32font_text_extents (struct font *font, unsigned *code, int nglyphs, + struct font_metrics *metrics); +int w32font_draw (struct glyph_string *s, int from, int to, + int x, int y, int with_background); + + +int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec); + +Lisp_Object intern_font_name (char *); #endif diff --git a/src/w32gui.h b/src/w32gui.h index 07a6fed0b47..9cad4f21f21 100644 --- a/src/w32gui.h +++ b/src/w32gui.h @@ -118,7 +118,7 @@ extern int nCmdShow; #define PBaseSize (1L << 8) /* program specified base for incrementing */ #define PWinGravity (1L << 9) /* program specified window gravity */ -extern int XParseGeometry (); +extern int XParseGeometry (char *, int *, int *, unsigned *, unsigned *); typedef struct { diff --git a/src/w32heap.c b/src/w32heap.c index f3e3d3b9b90..285325e3f8b 100644 --- a/src/w32heap.c +++ b/src/w32heap.c @@ -25,7 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #endif -#include <stdlib.h> #include <stdio.h> #include <setjmp.h> @@ -222,7 +221,7 @@ sbrk (unsigned long increment) was allocated by something else; GNU malloc detects when there is a jump in the sbrk values, and starts a new heap block. */ void -init_heap () +init_heap (void) { PIMAGE_DOS_HEADER dos_header; PIMAGE_NT_HEADERS nt_header; diff --git a/src/w32heap.h b/src/w32heap.h index cbd7f7ae96d..20a49a4e0ac 100644 --- a/src/w32heap.h +++ b/src/w32heap.h @@ -41,8 +41,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. #define get_w32_major_version() w32_major_version #define get_w32_minor_version() w32_minor_version -extern unsigned char *get_data_start(); -extern unsigned char *get_data_end(); +extern unsigned char *get_data_start (void); +extern unsigned char *get_data_end (void); extern unsigned long reserved_heap_size; extern SYSTEM_INFO sysinfo_cache; extern OSVERSIONINFO osinfo_cache; @@ -62,7 +62,7 @@ extern int os_subtype; extern void *sbrk (unsigned long size); /* Initialize heap structures for sbrk on startup. */ -extern void init_heap (); +extern void init_heap (void); /* Round the heap to this size. */ extern void round_heap (unsigned long size); diff --git a/src/w32inevt.c b/src/w32inevt.c index 3aaad6b016a..1111f8dfa44 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #endif -#include <stdlib.h> #include <stdio.h> #include <windows.h> #include <setjmp.h> @@ -289,7 +288,7 @@ static int faked_key = 0; /* return code -1 means that event_queue_ptr won't be incremented. In other word, this event makes two key codes. (by himi) */ -int +static int key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) { static int mod_key_state = 0; @@ -684,7 +683,7 @@ resize_event (WINDOW_BUFFER_SIZE_RECORD *event) } static void -maybe_generate_resize_event () +maybe_generate_resize_event (void) { CONSOLE_SCREEN_BUFFER_INFO info; FRAME_PTR f = get_frame (); diff --git a/src/w32menu.c b/src/w32menu.c index 82536c984b4..ff6bd977bea 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -59,8 +59,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ HMENU current_popup_menu; -void syms_of_w32menu (); -void globals_of_w32menu (); +void syms_of_w32menu (void); +void globals_of_w32menu (void); typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) ( IN HMENU, @@ -72,10 +72,16 @@ typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) ( IN UINT, IN BOOL, IN LPCMENUITEMINFOA); +typedef int (WINAPI * MessageBoxW_Proc) ( + IN HWND window, + IN WCHAR *text, + IN WCHAR *caption, + IN UINT type); GetMenuItemInfoA_Proc get_menu_item_info = NULL; SetMenuItemInfoA_Proc set_menu_item_info = NULL; AppendMenuW_Proc unicode_append_menu = NULL; +MessageBoxW_Proc unicode_message_box = NULL; Lisp_Object Qdebug_on_next_call; @@ -90,16 +96,19 @@ extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; extern Lisp_Object Qmenu_bar_update_hook; -void set_frame_menubar P_ ((FRAME_PTR, int, int)); +void set_frame_menubar (FRAME_PTR, int, int); #ifdef HAVE_DIALOGS -static Lisp_Object w32_dialog_show P_ ((FRAME_PTR, int, Lisp_Object, char**)); +static Lisp_Object w32_dialog_show (FRAME_PTR, int, Lisp_Object, char**); #else -static int is_simple_dialog P_ ((Lisp_Object)); -static Lisp_Object simple_dialog_show P_ ((FRAME_PTR, Lisp_Object, Lisp_Object)); +static int is_simple_dialog (Lisp_Object); +static Lisp_Object simple_dialog_show (FRAME_PTR, Lisp_Object, Lisp_Object); #endif -void w32_free_menu_strings P_ ((HWND)); +static void utf8to16 (unsigned char *, int, WCHAR *); +static int fill_in_menu (HMENU, widget_value *); + +void w32_free_menu_strings (HWND); /* This is set nonzero after the user activates the menu bar, and set @@ -111,31 +120,6 @@ void w32_free_menu_strings P_ ((HWND)); int pending_menu_activation; - -/* Return the frame whose ->output_data.w32->menubar_widget equals - ID, or 0 if none. */ - -static struct frame * -menubar_id_to_frame (id) - HMENU id; -{ - Lisp_Object tail, frame; - FRAME_PTR f; - - for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) - { - frame = XCAR (tail); - if (!FRAMEP (frame)) - continue; - f = XFRAME (frame); - if (!FRAME_WINDOW_P (f)) - continue; - if (f->output_data.w32->menubar_widget == id) - return f; - } - return 0; -} - #ifdef HAVE_MENUS DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0, @@ -157,8 +141,7 @@ on the left of the dialog box and all following items on the right. If HEADER is non-nil, the frame title for the box is "Information", otherwise it is "Question". */) - (position, contents, header) - Lisp_Object position, contents, header; + (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { FRAME_PTR f = NULL; Lisp_Object window; @@ -276,8 +259,7 @@ otherwise it is "Question". */) This way we can safely execute Lisp code. */ void -x_activate_menubar (f) - FRAME_PTR f; +x_activate_menubar (FRAME_PTR f) { set_frame_menubar (f, 0, 1); @@ -386,10 +368,7 @@ menubar_selection_callback (FRAME_PTR f, void * client_data) it is set the first time this is called, from initialize_frame_menubar. */ void -set_frame_menubar (f, first_time, deep_p) - FRAME_PTR f; - int first_time; - int deep_p; +set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) { HMENU menubar_widget = f->output_data.w32->menubar_widget; Lisp_Object items; @@ -442,12 +421,8 @@ set_frame_menubar (f, first_time, deep_p) set_buffer_internal_1 (XBUFFER (buffer)); - /* Run the Lucid hook. */ + /* Run the hooks. */ safe_run_hooks (Qactivate_menubar_hook); - /* If it has changed current-menubar from previous value, - really recompute the menubar from the value. */ - if (! NILP (Vlucid_menu_bar_dirty_flag)) - call0 (Qrecompute_lucid_menubar); safe_run_hooks (Qmenu_bar_update_hook); FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); @@ -455,8 +430,8 @@ set_frame_menubar (f, first_time, deep_p) /* Save the frame's previous menu bar contents data. */ if (previous_menu_items_used) - bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, - previous_menu_items_used * sizeof (Lisp_Object)); + memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, + previous_menu_items_used * sizeof (Lisp_Object)); /* Fill in menu_items with the current menu bar contents. This can evaluate Lisp code. */ @@ -648,8 +623,7 @@ set_frame_menubar (f, first_time, deep_p) is visible. */ void -initialize_frame_menubar (f) - FRAME_PTR f; +initialize_frame_menubar (FRAME_PTR f) { /* This function is called before the first chance to redisplay the frame. It has to be, so the frame will have the right size. */ @@ -661,8 +635,7 @@ initialize_frame_menubar (f) This is used when deleting a frame, and when turning off the menu bar. */ void -free_frame_menubar (f) - FRAME_PTR f; +free_frame_menubar (FRAME_PTR f) { BLOCK_INPUT; @@ -694,7 +667,7 @@ free_frame_menubar (f) Lisp_Object w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, char **error) + Lisp_Object title, const char **error) { int i; int menu_item_selection; @@ -1020,11 +993,9 @@ static char * button_names [] = { "button6", "button7", "button8", "button9", "button10" }; static Lisp_Object -w32_dialog_show (f, keymaps, title, header, error) - FRAME_PTR f; - int keymaps; - Lisp_Object title, header; - char **error; +w32_dialog_show (FRAME_PTR f, int keymaps, + Lisp_Object title, Lisp_Object header, + char **error) { int i, nb_buttons = 0; char dialog_name[6]; @@ -1214,8 +1185,7 @@ w32_dialog_show (f, keymaps, title, header, error) MessageBox provides. */ static int -is_simple_dialog (contents) - Lisp_Object contents; +is_simple_dialog (Lisp_Object contents) { Lisp_Object options = XCDR (contents); Lisp_Object name, yes, no, other; @@ -1251,36 +1221,77 @@ is_simple_dialog (contents) } static Lisp_Object -simple_dialog_show (f, contents, header) - FRAME_PTR f; - Lisp_Object contents, header; +simple_dialog_show (FRAME_PTR f, Lisp_Object contents, Lisp_Object header) { int answer; UINT type; - char *text, *title; Lisp_Object lispy_answer = Qnil, temp = XCAR (contents); - if (STRINGP (temp)) - text = SDATA (temp); - else - text = ""; + type = MB_YESNO; - if (NILP (header)) + /* Since we only handle Yes/No dialogs, and we already checked + is_simple_dialog, we don't need to worry about checking contents + to see what type of dialog to use. */ + + /* Use unicode if possible, so any language can be displayed. */ + if (unicode_message_box) { - title = "Question"; - type = MB_ICONQUESTION; + WCHAR *text, *title; + + if (STRINGP (temp)) + { + char *utf8_text = SDATA (ENCODE_UTF_8 (temp)); + /* Be pessimistic about the number of characters needed. + Remember characters outside the BMP will take more than + one utf16 word, so we cannot simply use the character + length of temp. */ + int utf8_len = strlen (utf8_text); + text = alloca ((utf8_len + 1) * sizeof (WCHAR)); + utf8to16 (utf8_text, utf8_len, text); + } + else + { + text = L""; + } + + if (NILP (header)) + { + title = L"Question"; + type |= MB_ICONQUESTION; + } + else + { + title = L"Information"; + type |= MB_ICONINFORMATION; + } + + answer = unicode_message_box (FRAME_W32_WINDOW (f), text, title, type); } else { - title = "Information"; - type = MB_ICONINFORMATION; - } - type |= MB_YESNO; + char *text, *title; - /* Since we only handle Yes/No dialogs, and we already checked - is_simple_dialog, we don't need to worry about checking contents - to see what type of dialog to use. */ - answer = MessageBox (FRAME_W32_WINDOW (f), text, title, type); + /* Fall back on ANSI message box, but at least use system + encoding so questions representable by the system codepage + are encoded properly. */ + if (STRINGP (temp)) + text = SDATA (ENCODE_SYSTEM (temp)); + else + text = ""; + + if (NILP (header)) + { + title = "Question"; + type |= MB_ICONQUESTION; + } + else + { + title = "Information"; + type |= MB_ICONINFORMATION; + } + + answer = MessageBox (FRAME_W32_WINDOW (f), text, title, type); + } if (answer == IDYES) lispy_answer = build_string ("Yes"); @@ -1317,10 +1328,9 @@ simple_dialog_show (f, contents, header) /* Is this item a separator? */ static int -name_is_separator (name) - char *name; +name_is_separator (const char *name) { - char *start = name; + const char *start = name; /* Check if name string consists of only dashes ('-'). */ while (*name == '-') name++; @@ -1330,13 +1340,6 @@ name_is_separator (name) return (*name == '\0' || start + 2 == name); } -/* Indicate boundary between left and right. */ -static int -add_left_right_boundary (HMENU menu) -{ - return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL); -} - /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */ static void utf8to16 (unsigned char * src, int len, WCHAR * dest) @@ -1405,7 +1408,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) strcat (out_string, wv->key); } else - out_string = wv->name; + out_string = (char *)wv->name; /* Quote any special characters within the menu item's text and key binding. */ @@ -1534,7 +1537,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) if (set_menu_item_info) { MENUITEMINFO info; - bzero (&info, sizeof (info)); + memset (&info, 0, sizeof (info)); info.cbSize = sizeof (info); info.fMask = MIIM_DATA; @@ -1566,7 +1569,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) } /* Construct native Windows menu(bar) based on widget_value tree. */ -int +static int fill_in_menu (HMENU menu, widget_value *wv) { int items_added = 0; @@ -1617,7 +1620,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags) { MENUITEMINFO info; - bzero (&info, sizeof (info)); + memset (&info, 0, sizeof (info)); info.cbSize = sizeof (info); info.fMask = MIIM_DATA; get_menu_item_info (menu, item, FALSE, &info); @@ -1648,14 +1651,13 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags) /* Free memory used by owner-drawn strings. */ static void -w32_free_submenu_strings (menu) - HMENU menu; +w32_free_submenu_strings (HMENU menu) { int i, num = GetMenuItemCount (menu); for (i = 0; i < num; i++) { MENUITEMINFO info; - bzero (&info, sizeof (info)); + memset (&info, 0, sizeof (info)); info.cbSize = sizeof (info); info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_SUBMENU; @@ -1677,8 +1679,7 @@ w32_free_submenu_strings (menu) } void -w32_free_menu_strings (hwnd) - HWND hwnd; +w32_free_menu_strings (HWND hwnd) { HMENU menu = current_popup_menu; @@ -1702,7 +1703,7 @@ w32_free_menu_strings (hwnd) DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0, doc: /* Return t if a menu or popup dialog is active on selected frame. */) - () + (void) { #ifdef HAVE_MENUS FRAME_PTR f; @@ -1714,7 +1715,7 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_ } void -syms_of_w32menu () +syms_of_w32menu (void) { globals_of_w32menu (); @@ -1737,13 +1738,14 @@ syms_of_w32menu () is non zero. */ void -globals_of_w32menu () +globals_of_w32menu (void) { /* See if Get/SetMenuItemInfo functions are available. */ HMODULE user32 = GetModuleHandle ("user32.dll"); get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW"); + unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW"); } /* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0 diff --git a/src/w32proc.c b/src/w32proc.c index 07ee0300cfb..49687574472 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -117,7 +117,8 @@ extern Lisp_Object Qlocal; Lisp_Object Qhigh, Qlow; #ifdef EMACSDEBUG -void _DebPrint (const char *fmt, ...) +void +_DebPrint (const char *fmt, ...) { char buf[1024]; va_list args; @@ -129,7 +130,7 @@ void _DebPrint (const char *fmt, ...) } #endif -typedef void (_CALLBACK_ *signal_handler)(int); +typedef void (_CALLBACK_ *signal_handler) (int); /* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ static signal_handler sig_handlers[NSIG]; @@ -158,7 +159,7 @@ int child_proc_count = 0; child_process child_procs[ MAX_CHILDREN ]; child_process *dead_child = NULL; -DWORD WINAPI reader_thread (void *arg); +static DWORD WINAPI reader_thread (void *arg); /* Find an unused process slot. */ child_process * @@ -278,7 +279,7 @@ find_child_pid (DWORD pid) is normally blocked until woken by select() to check for input by reading one char. When the read completes, char_avail is signaled to wake up the select emulator and the thread blocks itself again. */ -DWORD WINAPI +static DWORD WINAPI reader_thread (void *arg) { child_process *cp; @@ -607,8 +608,11 @@ get_result: # define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER #endif -void -w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app) +static void +w32_executable_type (char * filename, + int * is_dos_app, + int * is_cygnus_app, + int * is_gui_app) { file_data executable; char * p; @@ -722,7 +726,7 @@ unwind: close_file_data (&executable); } -int +static int compare_env (const void *strp1, const void *strp2) { const char *str1 = *(const char **)strp1, *str2 = *(const char **)strp2; @@ -746,7 +750,7 @@ compare_env (const void *strp1, const void *strp2) return 1; } -void +static void merge_and_sort_env (char **envp1, char **envp2, char **new_envp) { char **optr, **nptr; @@ -1690,8 +1694,6 @@ set_process_dir (char * dir) process_dir = dir; } -#ifdef HAVE_SOCKETS - /* To avoid problems with winsock implementations that work over dial-up connections causing or requiring a connection to exist while Emacs is running, Emacs no longer automatically loads winsock on startup if it @@ -1719,8 +1721,7 @@ also loaded immediately if not already loaded. If winsock is loaded, the winsock local hostname is returned (since this may be different from the value of `system-name' and should supplant it), otherwise t is returned to indicate winsock support is present. */) - (load_now) - Lisp_Object load_now; + (Lisp_Object load_now) { int have_winsock; @@ -1751,29 +1752,20 @@ DEFUN ("w32-unload-winsock", Fw32_unload_winsock, Sw32_unload_winsock, This is provided to allow dial-up socket connections to be disconnected when no longer needed. Returns nil without unloading winsock if any socket connections still exist. */) - () + (void) { return term_winsock () ? Qt : Qnil; } -#endif /* HAVE_SOCKETS */ - /* Some miscellaneous functions that are Windows specific, but not GUI specific (ie. are applicable in terminal or batch mode as well). */ -/* lifted from fileio.c */ -#define CORRECT_DIR_SEPS(s) \ - do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ - else unixtodos_filename (s); \ - } while (0) - DEFUN ("w32-short-file-name", Fw32_short_file_name, Sw32_short_file_name, 1, 1, 0, doc: /* Return the short file name version (8.3) of the full path of FILENAME. If FILENAME does not exist, return nil. All path elements in FILENAME are converted to their short names. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { char shortname[MAX_PATH]; @@ -1786,7 +1778,7 @@ All path elements in FILENAME are converted to their short names. */) if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0) return Qnil; - CORRECT_DIR_SEPS (shortname); + dostounix_filename (shortname); return build_string (shortname); } @@ -1797,8 +1789,7 @@ DEFUN ("w32-long-file-name", Fw32_long_file_name, Sw32_long_file_name, doc: /* Return the long file name version of the full path of FILENAME. If FILENAME does not exist, return nil. All path elements in FILENAME are converted to their long names. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { char longname[ MAX_PATH ]; int drive_only = 0; @@ -1815,7 +1806,7 @@ All path elements in FILENAME are converted to their long names. */) if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH)) return Qnil; - CORRECT_DIR_SEPS (longname); + dostounix_filename (longname); /* If we were passed only a drive, make sure that a slash is not appended for consistency with directories. Allow for drive mapping via SUBST @@ -1835,8 +1826,7 @@ PRIORITY should be one of the symbols high, normal, or low; any other symbol will be interpreted as normal. If successful, the return value is t, otherwise nil. */) - (process, priority) - Lisp_Object process, priority; + (Lisp_Object process, Lisp_Object priority) { HANDLE proc_handle = GetCurrentProcess (); DWORD priority_class = NORMAL_PRIORITY_CLASS; @@ -1958,8 +1948,7 @@ is a number, it is interpreted as an LCTYPE constant and the corresponding locale information is returned. If LCID (a 16-bit number) is not a valid locale, the result is nil. */) - (lcid, longform) - Lisp_Object lcid, longform; + (Lisp_Object lcid, Lisp_Object longform) { int got_abbrev; int got_full; @@ -2005,12 +1994,12 @@ DEFUN ("w32-get-current-locale-id", Fw32_get_current_locale_id, doc: /* Return Windows locale id for current locale setting. This is a numerical value; use `w32-get-locale-info' to convert to a human-readable form. */) - () + (void) { return make_number (GetThreadLocale ()); } -DWORD +static DWORD int_from_hex (char * s) { DWORD val = 0; @@ -2032,7 +2021,7 @@ int_from_hex (char * s) function isn't given a context pointer. */ Lisp_Object Vw32_valid_locale_ids; -BOOL CALLBACK +static BOOL CALLBACK enum_locale_fn (LPTSTR localeNum) { DWORD id = int_from_hex (localeNum); @@ -2045,7 +2034,7 @@ DEFUN ("w32-get-valid-locale-ids", Fw32_get_valid_locale_ids, doc: /* Return list of all valid Windows locale ids. Each id is a numerical value; use `w32-get-locale-info' to convert to a human-readable form. */) - () + (void) { Vw32_valid_locale_ids = Qnil; @@ -2062,8 +2051,7 @@ By default, the system default locale setting is returned; if the optional parameter USERP is non-nil, the user default locale setting is returned. This is a numerical value; use `w32-get-locale-info' to convert to a human-readable form. */) - (userp) - Lisp_Object userp; + (Lisp_Object userp) { if (NILP (userp)) return make_number (GetSystemDefaultLCID ()); @@ -2074,8 +2062,7 @@ human-readable form. */) DEFUN ("w32-set-current-locale", Fw32_set_current_locale, Sw32_set_current_locale, 1, 1, 0, doc: /* Make Windows locale LCID be the current locale setting for Emacs. If successful, the new locale id is returned, otherwise nil. */) - (lcid) - Lisp_Object lcid; + (Lisp_Object lcid) { CHECK_NUMBER (lcid); @@ -2098,7 +2085,7 @@ If successful, the new locale id is returned, otherwise nil. */) function isn't given a context pointer. */ Lisp_Object Vw32_valid_codepages; -BOOL CALLBACK +static BOOL CALLBACK enum_codepage_fn (LPTSTR codepageNum) { DWORD id = atoi (codepageNum); @@ -2109,7 +2096,7 @@ enum_codepage_fn (LPTSTR codepageNum) DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages, Sw32_get_valid_codepages, 0, 0, 0, doc: /* Return list of all valid Windows codepages. */) - () + (void) { Vw32_valid_codepages = Qnil; @@ -2123,7 +2110,7 @@ DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages, DEFUN ("w32-get-console-codepage", Fw32_get_console_codepage, Sw32_get_console_codepage, 0, 0, 0, doc: /* Return current Windows codepage for console input. */) - () + (void) { return make_number (GetConsoleCP ()); } @@ -2134,8 +2121,7 @@ DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage, doc: /* Make Windows codepage CP be the current codepage setting for Emacs. The codepage setting affects keyboard input and display in tty mode. If successful, the new CP is returned, otherwise nil. */) - (cp) - Lisp_Object cp; + (Lisp_Object cp) { CHECK_NUMBER (cp); @@ -2152,7 +2138,7 @@ If successful, the new CP is returned, otherwise nil. */) DEFUN ("w32-get-console-output-codepage", Fw32_get_console_output_codepage, Sw32_get_console_output_codepage, 0, 0, 0, doc: /* Return current Windows codepage for console output. */) - () + (void) { return make_number (GetConsoleOutputCP ()); } @@ -2163,8 +2149,7 @@ DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage, doc: /* Make Windows codepage CP be the current codepage setting for Emacs. The codepage setting affects keyboard input and display in tty mode. If successful, the new CP is returned, otherwise nil. */) - (cp) - Lisp_Object cp; + (Lisp_Object cp) { CHECK_NUMBER (cp); @@ -2182,8 +2167,7 @@ DEFUN ("w32-get-codepage-charset", Fw32_get_codepage_charset, Sw32_get_codepage_charset, 1, 1, 0, doc: /* Return charset of codepage CP. Returns nil if the codepage is not valid. */) - (cp) - Lisp_Object cp; + (Lisp_Object cp) { CHARSETINFO info; @@ -2203,7 +2187,7 @@ DEFUN ("w32-get-valid-keyboard-layouts", Fw32_get_valid_keyboard_layouts, Sw32_get_valid_keyboard_layouts, 0, 0, 0, doc: /* Return list of Windows keyboard languages and layouts. The return value is a list of pairs of language id and layout id. */) - () + (void) { int num_layouts = GetKeyboardLayoutList (0, NULL); HKL * layouts = (HKL *) alloca (num_layouts * sizeof (HKL)); @@ -2229,7 +2213,7 @@ DEFUN ("w32-get-keyboard-layout", Fw32_get_keyboard_layout, Sw32_get_keyboard_layout, 0, 0, 0, doc: /* Return current Windows keyboard language and layout. The return value is the cons of the language id and the layout id. */) - () + (void) { DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId); @@ -2243,8 +2227,7 @@ DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout, doc: /* Make LAYOUT be the current keyboard layout for Emacs. The keyboard layout setting affects interpretation of keyboard input. If successful, the new layout id is returned, otherwise nil. */) - (layout) - Lisp_Object layout; + (Lisp_Object layout) { DWORD kl; @@ -2276,15 +2259,14 @@ If successful, the new layout id is returned, otherwise nil. */) void -syms_of_ntproc () +syms_of_ntproc (void) { DEFSYM (Qhigh, "high"); DEFSYM (Qlow, "low"); -#ifdef HAVE_SOCKETS defsubr (&Sw32_has_winsock); defsubr (&Sw32_unload_winsock); -#endif + defsubr (&Sw32_short_file_name); defsubr (&Sw32_long_file_name); defsubr (&Sw32_set_process_priority); diff --git a/src/w32reg.c b/src/w32reg.c index f9687d1effe..5c02dd376c7 100644 --- a/src/w32reg.c +++ b/src/w32reg.c @@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "blockinput.h" #include <stdio.h> -#include <string.h> #define REG_ROOT "SOFTWARE\\GNU\\Emacs" @@ -58,9 +57,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ */ static char * -w32_get_rdb_resource (rdb, resource) - char *rdb; - char *resource; +w32_get_rdb_resource (char *rdb, char *resource) { char *value = rdb; int len = strlen (resource); @@ -78,9 +75,7 @@ w32_get_rdb_resource (rdb, resource) } static LPBYTE -w32_get_string_resource (name, class, dwexptype) - char *name, *class; - DWORD dwexptype; +w32_get_string_resource (char *name, char *class, DWORD dwexptype) { LPBYTE lpvalue = NULL; HKEY hrootkey = NULL; @@ -147,9 +142,7 @@ w32_get_string_resource (name, class, dwexptype) database RDB. */ char * -x_get_string_resource (rdb, name, class) - XrmDatabase rdb; - char *name, *class; +x_get_string_resource (XrmDatabase rdb, char *name, char *class) { if (rdb) { diff --git a/src/w32select.c b/src/w32select.c index 25abacbc75d..f9bab384062 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -89,8 +89,8 @@ static HGLOBAL convert_to_handle_as_ascii (void); static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system); static Lisp_Object render (Lisp_Object oformat); static Lisp_Object render_locale (void); -static Lisp_Object render_all (void); -static void run_protected (Lisp_Object (*code) (), Lisp_Object arg); +static Lisp_Object render_all (Lisp_Object ignore); +static void run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg); static Lisp_Object lisp_error_handler (Lisp_Object error); static LRESULT CALLBACK owner_callback (HWND win, UINT msg, WPARAM wp, LPARAM lp); @@ -334,7 +334,7 @@ render_locale (void) data survives us. This code will do that. */ static Lisp_Object -render_all (void) +render_all (Lisp_Object ignore) { ONTRACE (fprintf (stderr, "render_all\n")); @@ -392,13 +392,12 @@ render_all (void) } static void -run_protected (Lisp_Object (*code) (), Lisp_Object arg) +run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg) { /* FIXME: This works but it doesn't feel right. Too much fiddling with global variables and calling strange looking functions. Is this really the right way to run Lisp callbacks? */ - extern int waiting_for_input; int owfi; BLOCK_INPUT; @@ -681,8 +680,7 @@ setup_windows_coding_system (Lisp_Object coding_system, DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_data, 1, 2, 0, doc: /* This sets the clipboard data to the given text. */) - (string, ignored) - Lisp_Object string, ignored; + (Lisp_Object string, Lisp_Object ignored) { BOOL ok = TRUE; int nbytes; @@ -802,8 +800,7 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, Sw32_get_clipboard_data, 0, 1, 0, doc: /* This gets the clipboard data in text format. */) - (ignored) - Lisp_Object ignored; + (Lisp_Object ignored) { HGLOBAL htext; Lisp_Object ret = Qnil; @@ -1027,8 +1024,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'. */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { CHECK_SYMBOL (selection); @@ -1065,7 +1061,7 @@ and t is the same as `SECONDARY'. */) dumped version. */ void -syms_of_w32select () +syms_of_w32select (void) { defsubr (&Sw32_set_clipboard_data); defsubr (&Sw32_get_clipboard_data); @@ -1104,7 +1100,7 @@ set to nil. */); un-dumped version. */ void -globals_of_w32select () +globals_of_w32select (void) { DEFAULT_LCID = GetUserDefaultLCID (); /* Drop the sort order from the LCID, so we can compare this with diff --git a/src/w32term.c b/src/w32term.c index bda7438f78a..1f53860de2e 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <signal.h> #include <stdio.h> -#include <stdlib.h> #include <setjmp.h> #include "lisp.h" #include "blockinput.h" @@ -96,7 +95,7 @@ int x_underline_at_descent_line; extern unsigned int msh_mousewheel; -extern void free_frame_menubar (); +extern void free_frame_menubar (struct frame *); extern int w32_codepage_for_font (char *fontname); extern Cursor w32_load_cursor (LPCTSTR name); @@ -228,53 +227,51 @@ static int input_signal_count; extern Lisp_Object Vcommand_line_args, Vsystem_name; -#ifndef USE_CRT_DLL -extern int errno; -#endif - /* A mask of extra modifier bits to put into every keyboard char. */ extern EMACS_INT extra_keyboard_modifiers; /* Keyboard code page - may be changed by language-change events. */ static int keyboard_codepage; -static void x_update_window_end P_ ((struct window *, int, int)); -static void w32_handle_tool_bar_click P_ ((struct frame *, - struct input_event *)); -static void w32_define_cursor P_ ((Window, Cursor)); - -void x_lower_frame P_ ((struct frame *)); -void x_scroll_bar_clear P_ ((struct frame *)); -void x_wm_set_size_hint P_ ((struct frame *, long, int)); -void x_raise_frame P_ ((struct frame *)); -void x_set_window_size P_ ((struct frame *, int, int, int)); -void x_wm_set_window_state P_ ((struct frame *, int)); -void x_wm_set_icon_pixmap P_ ((struct frame *, int)); -static void w32_initialize P_ ((void)); -static void x_update_end P_ ((struct frame *)); -static void w32_frame_up_to_date P_ ((struct frame *)); -static void w32_set_terminal_modes P_ ((struct terminal *)); -static void w32_reset_terminal_modes P_ ((struct terminal *)); -static void x_clear_frame P_ ((struct frame *)); -static void frame_highlight P_ ((struct frame *)); -static void frame_unhighlight P_ ((struct frame *)); -static void x_new_focus_frame P_ ((struct w32_display_info *, - struct frame *)); -static void x_focus_changed P_ ((int, int, struct w32_display_info *, - struct frame *, struct input_event *)); -static void w32_detect_focus_change P_ ((struct w32_display_info *, - W32Msg *, struct input_event *)); -static void w32_frame_rehighlight P_ ((struct frame *)); -static void x_frame_rehighlight P_ ((struct w32_display_info *)); -static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); -static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, - enum text_cursor_kinds)); -static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, int, HDC)); -static BOOL my_show_window P_ ((struct frame *, HWND, int)); -static void my_set_window_pos P_ ((HWND, HWND, int, int, int, int, UINT)); -static void my_set_focus P_ ((struct frame *, HWND)); -static void my_set_foreground_window P_ ((HWND)); -static void my_destroy_window P_ ((struct frame *, HWND)); +static void x_update_window_end (struct window *, int, int); +static void w32_handle_tool_bar_click (struct frame *, + struct input_event *); +static void w32_define_cursor (Window, Cursor); + +void x_lower_frame (struct frame *); +void x_scroll_bar_clear (struct frame *); +void x_wm_set_size_hint (struct frame *, long, int); +void x_raise_frame (struct frame *); +void x_set_window_size (struct frame *, int, int, int); +void x_wm_set_window_state (struct frame *, int); +void x_wm_set_icon_pixmap (struct frame *, int); +static void w32_initialize (void); +static void x_update_end (struct frame *); +static void w32_frame_up_to_date (struct frame *); +static void w32_set_terminal_modes (struct terminal *); +static void w32_reset_terminal_modes (struct terminal *); +static void x_clear_frame (struct frame *); +static void frame_highlight (struct frame *); +static void frame_unhighlight (struct frame *); +static void x_new_focus_frame (struct w32_display_info *, + struct frame *); +static void x_focus_changed (int, int, struct w32_display_info *, + struct frame *, struct input_event *); +static void w32_detect_focus_change (struct w32_display_info *, + W32Msg *, struct input_event *); +static void w32_frame_rehighlight (struct frame *); +static void x_frame_rehighlight (struct w32_display_info *); +static void x_draw_hollow_cursor (struct window *, struct glyph_row *); +static void x_draw_bar_cursor (struct window *, struct glyph_row *, int, + enum text_cursor_kinds); +static void w32_clip_to_row (struct window *, struct glyph_row *, int, HDC); +static BOOL my_show_window (struct frame *, HWND, int); +static void my_set_window_pos (HWND, HWND, int, int, int, int, UINT); +#if 0 +static void my_set_focus (struct frame *, HWND); +#endif +static void my_set_foreground_window (HWND); +static void my_destroy_window (struct frame *, HWND); static Lisp_Object Qvendor_specific_keysyms; @@ -298,9 +295,7 @@ struct record event_record[100]; int event_record_index; -record_event (locus, type) - char *locus; - int type; +record_event (char *locus, int type) { if (event_record_index == sizeof (event_record) / sizeof (struct record)) event_record_index = 0; @@ -314,7 +309,7 @@ record_event (locus, type) void -XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, +XChangeGC (void *ignore, XGCValues *gc, unsigned long mask, XGCValues *xgcv) { if (mask & GCForeground) @@ -326,11 +321,10 @@ XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, } XGCValues * -XCreateGC (void * ignore, Window window, unsigned long mask, - XGCValues *xgcv) +XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv) { XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); - bzero (gc, sizeof (XGCValues)); + memset (gc, 0, sizeof (XGCValues)); XChangeGC (ignore, gc, mask, xgcv); @@ -338,7 +332,7 @@ XCreateGC (void * ignore, Window window, unsigned long mask, } void -XGetGCValues (void* ignore, XGCValues *gc, +XGetGCValues (void *ignore, XGCValues *gc, unsigned long mask, XGCValues *xgcv) { XChangeGC (ignore, xgcv, mask, gc); @@ -381,11 +375,7 @@ w32_draw_rectangle (HDC hdc, XGCValues *gc, int x, int y, /* Draw a filled rectangle at the specified position. */ void -w32_fill_rect (f, hdc, pix, lprect) - FRAME_PTR f; - HDC hdc; - COLORREF pix; - RECT * lprect; +w32_fill_rect (FRAME_PTR f, HDC hdc, COLORREF pix, RECT *lprect) { HBRUSH hb; @@ -395,8 +385,7 @@ w32_fill_rect (f, hdc, pix, lprect) } void -w32_clear_window (f) - FRAME_PTR f; +w32_clear_window (FRAME_PTR f) { RECT rect; HDC hdc = get_frame_dc (f); @@ -416,8 +405,7 @@ w32_clear_window (f) #define OPAQUE_FRAME 255 void -x_set_frame_alpha (f) - struct frame *f; +x_set_frame_alpha (struct frame *f) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); double alpha = 1.0; @@ -463,8 +451,7 @@ x_set_frame_alpha (f) } int -x_display_pixel_height (dpyinfo) - struct w32_display_info *dpyinfo; +x_display_pixel_height (struct w32_display_info *dpyinfo) { HDC dc = GetDC (NULL); int pixels = GetDeviceCaps (dc, VERTRES); @@ -473,8 +460,7 @@ x_display_pixel_height (dpyinfo) } int -x_display_pixel_width (dpyinfo) - struct w32_display_info *dpyinfo; +x_display_pixel_width (struct w32_display_info *dpyinfo) { HDC dc = GetDC (NULL); int pixels = GetDeviceCaps (dc, HORZRES); @@ -493,8 +479,7 @@ x_display_pixel_width (dpyinfo) each window being updated. */ static void -x_update_begin (f) - struct frame *f; +x_update_begin (struct frame *f) { struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f); @@ -516,8 +501,7 @@ x_update_begin (f) position of W. */ static void -x_update_window_begin (w) - struct window *w; +x_update_window_begin (struct window *w) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f); @@ -576,9 +560,7 @@ x_update_window_begin (w) /* Draw a vertical window border from (x,y0) to (x,y1) */ static void -w32_draw_vertical_window_border (w, x, y0, y1) - struct window *w; - int x, y0, y1; +w32_draw_vertical_window_border (struct window *w, int x, int y0, int y1) { struct frame *f = XFRAME (WINDOW_FRAME (w)); RECT r; @@ -615,9 +597,8 @@ w32_draw_vertical_window_border (w, x, y0, y1) here. */ static void -x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) - struct window *w; - int cursor_on_p, mouse_face_overwritten_p; +x_update_window_end (struct window *w, int cursor_on_p, + int mouse_face_overwritten_p) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame)); @@ -661,8 +642,7 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) update_end. */ static void -x_update_end (f) - struct frame *f; +x_update_end (struct frame *f) { if (! FRAME_W32_P (f)) return; @@ -677,8 +657,7 @@ x_update_end (f) updated_window is not available here. */ static void -w32_frame_up_to_date (f) - struct frame *f; +w32_frame_up_to_date (struct frame *f) { if (FRAME_W32_P (f)) { @@ -707,8 +686,7 @@ w32_frame_up_to_date (f) between bitmaps to be drawn between current row and DESIRED_ROW. */ static void -x_after_update_window_line (desired_row) - struct glyph_row *desired_row; +x_after_update_window_line (struct glyph_row *desired_row) { struct window *w = updated_window; struct frame *f; @@ -754,10 +732,8 @@ x_after_update_window_line (desired_row) drawn. */ static void -w32_draw_fringe_bitmap (w, row, p) - struct window *w; - struct glyph_row *row; - struct draw_fringe_bitmap_params *p; +w32_draw_fringe_bitmap (struct window *w, struct glyph_row *row, + struct draw_fringe_bitmap_params *p) { struct frame *f = XFRAME (WINDOW_FRAME (w)); HDC hdc; @@ -880,10 +856,7 @@ w32_draw_fringe_bitmap (w, row, p) } static void -w32_define_fringe_bitmap (which, bits, h, wd) - int which; - unsigned short *bits; - int h, wd; +w32_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd) { if (which >= max_fringe_bmp) { @@ -898,8 +871,7 @@ w32_define_fringe_bitmap (which, bits, h, wd) } static void -w32_destroy_fringe_bitmap (which) - int which; +w32_destroy_fringe_bitmap (int which) { if (which >= max_fringe_bmp) return; @@ -937,40 +909,39 @@ w32_reset_terminal_modes (struct terminal *term) /* Function prototypes of this page. */ -static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); -static void x_set_glyph_string_gc P_ ((struct glyph_string *)); -static void x_draw_glyph_string_background P_ ((struct glyph_string *, - int)); -static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); -static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); -static void x_draw_glyph_string_box P_ ((struct glyph_string *)); -static void x_draw_glyph_string P_ ((struct glyph_string *)); -static void x_set_cursor_gc P_ ((struct glyph_string *)); -static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); -static void x_set_mouse_face_gc P_ ((struct glyph_string *)); +static void x_set_glyph_string_clipping (struct glyph_string *); +static void x_set_glyph_string_gc (struct glyph_string *); +static void x_draw_glyph_string_background (struct glyph_string *, + int); +static void x_draw_glyph_string_foreground (struct glyph_string *); +static void x_draw_composite_glyph_string_foreground (struct glyph_string *); +static void x_draw_glyph_string_box (struct glyph_string *); +static void x_draw_glyph_string (struct glyph_string *); +static void x_set_cursor_gc (struct glyph_string *); +static void x_set_mode_line_face_gc (struct glyph_string *); +static void x_set_mouse_face_gc (struct glyph_string *); static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int); -static void w32_setup_relief_color P_ ((struct frame *, struct relief *, - double, int, COLORREF)); -static void x_setup_relief_colors P_ ((struct glyph_string *)); -static void x_draw_image_glyph_string P_ ((struct glyph_string *)); -static void x_draw_image_relief P_ ((struct glyph_string *)); -static void x_draw_image_foreground P_ ((struct glyph_string *)); -static void w32_draw_image_foreground_1 P_ ((struct glyph_string *, HBITMAP)); -static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, - int, int, int)); -static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int, - int, int, int, int, int, int, - RECT *)); -static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, - int, int, int, RECT *)); +static void w32_setup_relief_color (struct frame *, struct relief *, + double, int, COLORREF); +static void x_setup_relief_colors (struct glyph_string *); +static void x_draw_image_glyph_string (struct glyph_string *); +static void x_draw_image_relief (struct glyph_string *); +static void x_draw_image_foreground (struct glyph_string *); +static void w32_draw_image_foreground_1 (struct glyph_string *, HBITMAP); +static void x_clear_glyph_string_rect (struct glyph_string *, int, + int, int, int); +static void w32_draw_relief_rect (struct frame *, int, int, int, int, + int, int, int, int, int, int, + RECT *); +static void w32_draw_box_rect (struct glyph_string *, int, int, int, int, + int, int, int, RECT *); /* Set S->gc to a suitable GC for drawing glyph string S in cursor face. */ static void -x_set_cursor_gc (s) - struct glyph_string *s; +x_set_cursor_gc (struct glyph_string *s) { if (s->font == FRAME_FONT (s->f) && s->face->background == FRAME_BACKGROUND_PIXEL (s->f) @@ -1021,8 +992,7 @@ x_set_cursor_gc (s) /* Set up S->gc of glyph string S for drawing text in mouse face. */ static void -x_set_mouse_face_gc (s) - struct glyph_string *s; +x_set_mouse_face_gc (struct glyph_string *s) { int face_id; struct face *face; @@ -1075,8 +1045,7 @@ x_set_mouse_face_gc (s) matrix was built, so there isn't much to do, here. */ static INLINE void -x_set_mode_line_face_gc (s) - struct glyph_string *s; +x_set_mode_line_face_gc (struct glyph_string *s) { s->gc = s->face->gc; } @@ -1087,8 +1056,7 @@ x_set_mode_line_face_gc (s) pattern. */ static INLINE void -x_set_glyph_string_gc (s) - struct glyph_string *s; +x_set_glyph_string_gc (struct glyph_string *s) { PREPARE_FACE_FOR_DISPLAY (s->f, s->face); @@ -1133,8 +1101,7 @@ x_set_glyph_string_gc (s) line or menu if we don't have X toolkit support. */ static INLINE void -x_set_glyph_string_clipping (s) - struct glyph_string *s; +x_set_glyph_string_clipping (struct glyph_string *s) { RECT *r = s->clip; int n = get_glyph_string_clip_rects (s, r, 2); @@ -1162,8 +1129,8 @@ x_set_glyph_string_clipping (s) the area of SRC. */ static void -x_set_glyph_string_clipping_exactly (src, dst) - struct glyph_string *src, *dst; +x_set_glyph_string_clipping_exactly (struct glyph_string *src, + struct glyph_string *dst) { RECT r; @@ -1180,8 +1147,7 @@ x_set_glyph_string_clipping_exactly (src, dst) Compute left and right overhang of glyph string S. */ static void -w32_compute_glyph_string_overhangs (s) - struct glyph_string *s; +w32_compute_glyph_string_overhangs (struct glyph_string *s) { if (s->cmp == NULL && s->first_glyph->type == CHAR_GLYPH @@ -1209,9 +1175,8 @@ w32_compute_glyph_string_overhangs (s) /* Fill rectangle X, Y, W, H with background color of glyph string S. */ static INLINE void -x_clear_glyph_string_rect (s, x, y, w, h) - struct glyph_string *s; - int x, y, w, h; +x_clear_glyph_string_rect (struct glyph_string *s, + int x, int y, int w, int h) { int real_x = x; int real_y = y; @@ -1241,9 +1206,7 @@ x_clear_glyph_string_rect (s, x, y, w, h) contains the first component of a composition. */ static void -x_draw_glyph_string_background (s, force_p) - struct glyph_string *s; - int force_p; +x_draw_glyph_string_background (struct glyph_string *s, int force_p) { /* Nothing to do if background has already been drawn or if it shouldn't be drawn in the first place. */ @@ -1282,8 +1245,7 @@ x_draw_glyph_string_background (s, force_p) /* Draw the foreground of glyph string S. */ static void -x_draw_glyph_string_foreground (s) - struct glyph_string *s; +x_draw_glyph_string_foreground (struct glyph_string *s) { int i, x; @@ -1340,8 +1302,7 @@ x_draw_glyph_string_foreground (s) /* Draw the foreground of composite glyph string S. */ static void -x_draw_composite_glyph_string_foreground (s) - struct glyph_string *s; +x_draw_composite_glyph_string_foreground (struct glyph_string *s) { int i, j, x; struct font *font = s->font; @@ -1454,11 +1415,8 @@ x_draw_composite_glyph_string_foreground (s) Value is non-zero if successful. */ static int -w32_alloc_lighter_color (f, color, factor, delta) - struct frame *f; - COLORREF *color; - double factor; - int delta; +w32_alloc_lighter_color (struct frame *f, COLORREF *color, + double factor, int delta) { COLORREF new; long bright; @@ -1517,10 +1475,7 @@ w32_alloc_lighter_color (f, color, factor, delta) colors in COLORS. On W32, we no longer try to map colors to a palette. */ void -x_query_colors (f, colors, ncolors) - struct frame *f; - XColor *colors; - int ncolors; +x_query_colors (struct frame *f, XColor *colors, int ncolors) { int i; @@ -1535,9 +1490,7 @@ x_query_colors (f, colors, ncolors) } void -x_query_color (f, color) - struct frame *f; - XColor *color; +x_query_color (struct frame *f, XColor *color) { x_query_colors (f, color, 1); } @@ -1551,12 +1504,8 @@ x_query_color (f, color) be allocated, use DEFAULT_PIXEL, instead. */ static void -w32_setup_relief_color (f, relief, factor, delta, default_pixel) - struct frame *f; - struct relief *relief; - double factor; - int delta; - COLORREF default_pixel; +w32_setup_relief_color (struct frame *f, struct relief *relief, double factor, + int delta, COLORREF default_pixel) { XGCValues xgcv; struct w32_output *di = f->output_data.w32; @@ -1592,8 +1541,7 @@ w32_setup_relief_color (f, relief, factor, delta, default_pixel) /* Set up colors for the relief lines around glyph string S. */ static void -x_setup_relief_colors (s) - struct glyph_string *s; +x_setup_relief_colors (struct glyph_string *s) { struct w32_output *di = s->f->output_data.w32; COLORREF color; @@ -1628,12 +1576,10 @@ x_setup_relief_colors (s) when drawing. */ static void -w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, - raised_p, top_p, bot_p, left_p, right_p, clip_rect) - struct frame *f; - int left_x, top_y, right_x, bottom_y, width; - int top_p, bot_p, left_p, right_p, raised_p; - RECT *clip_rect; +w32_draw_relief_rect (struct frame *f, + int left_x, int top_y, int right_x, int bottom_y, int width, + int raised_p, int top_p, int bot_p, int left_p, int right_p, + RECT *clip_rect) { int i; XGCValues gc; @@ -1693,11 +1639,9 @@ w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, rectangle to use when drawing. */ static void -w32_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, - left_p, right_p, clip_rect) - struct glyph_string *s; - int left_x, top_y, right_x, bottom_y, width, left_p, right_p; - RECT *clip_rect; +w32_draw_box_rect (struct glyph_string *s, + int left_x, int top_y, int right_x, int bottom_y, int width, + int left_p, int right_p, RECT *clip_rect) { w32_set_clip_rectangle (s->hdc, clip_rect); @@ -1730,8 +1674,7 @@ w32_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, /* Draw a box around glyph string S. */ static void -x_draw_glyph_string_box (s) - struct glyph_string *s; +x_draw_glyph_string_box (struct glyph_string *s) { int width, left_x, right_x, top_y, bottom_y, last_x, raised_p; int left_p, right_p; @@ -1782,8 +1725,7 @@ x_draw_glyph_string_box (s) /* Draw foreground of image glyph string S. */ static void -x_draw_image_foreground (s) - struct glyph_string *s; +x_draw_image_foreground (struct glyph_string *s) { int x = s->x; int y = s->ybase - image_ascent (s->img, s->face, &s->slice); @@ -1873,8 +1815,7 @@ x_draw_image_foreground (s) /* Draw a relief around the image glyph string S. */ static void -x_draw_image_relief (s) - struct glyph_string *s; +x_draw_image_relief (struct glyph_string *s) { int x0, y0, x1, y1, thick, raised_p; RECT r; @@ -1926,9 +1867,7 @@ x_draw_image_relief (s) /* Draw the foreground of image glyph string S to PIXMAP. */ static void -w32_draw_image_foreground_1 (s, pixmap) - struct glyph_string *s; - HBITMAP pixmap; +w32_draw_image_foreground_1 (struct glyph_string *s, HBITMAP pixmap) { HDC hdc = CreateCompatibleDC (s->hdc); HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap); @@ -2015,9 +1954,7 @@ w32_draw_image_foreground_1 (s, pixmap) give the rectangle to draw. */ static void -x_draw_glyph_string_bg_rect (s, x, y, w, h) - struct glyph_string *s; - int x, y, w, h; +x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h) { #if 0 /* TODO: stipple */ if (s->stippled_p) @@ -2048,8 +1985,7 @@ x_draw_glyph_string_bg_rect (s, x, y, w, h) */ static void -x_draw_image_glyph_string (s) - struct glyph_string *s; +x_draw_image_glyph_string (struct glyph_string *s) { int x, y; int box_line_hwidth = eabs (s->face->box_line_width); @@ -2162,25 +2098,41 @@ x_draw_image_glyph_string (s) /* Draw stretch glyph string S. */ static void -x_draw_stretch_glyph_string (s) - struct glyph_string *s; +x_draw_stretch_glyph_string (struct glyph_string *s) { xassert (s->first_glyph->type == STRETCH_GLYPH); if (s->hl == DRAW_CURSOR && !x_stretch_cursor_p) { - /* If `x-stretch-block-cursor' is nil, don't draw a block cursor - as wide as the stretch glyph. */ + /* If `x-stretch-cursor' is nil, don't draw a block cursor as + wide as the stretch glyph. */ int width, background_width = s->background_width; - int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); + int x = s->x; - if (x < left_x) + if (!s->row->reversed_p) { - background_width -= left_x - x; - x = left_x; + int left_x = window_box_left_offset (s->w, TEXT_AREA); + + if (x < left_x) + { + background_width -= left_x - x; + x = left_x; + } + } + else + { + /* In R2L rows, draw the cursor on the right edge of the + stretch glyph. */ + int right_x = window_box_right_offset (s->w, TEXT_AREA); + + if (x + background_width > right_x) + background_width -= x - right_x; + x += background_width; } width = min (FRAME_COLUMN_WIDTH (s->f), background_width); + if (s->row->reversed_p) + x -= width; /* Draw cursor. */ x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height); @@ -2194,7 +2146,10 @@ x_draw_stretch_glyph_string (s) RECT r; HDC hdc = s->hdc; - x += width; + if (!s->row->reversed_p) + x += width; + else + x = s->x; if (s->row->mouse_face_p && cursor_in_mouse_face_p (s->w)) { @@ -2245,8 +2200,7 @@ x_draw_stretch_glyph_string (s) /* Draw glyph string S. */ static void -x_draw_glyph_string (s) - struct glyph_string *s; +x_draw_glyph_string (struct glyph_string *s) { int relief_drawn_p = 0; @@ -2492,9 +2446,8 @@ x_draw_glyph_string (s) /* Shift display to make room for inserted glyphs. */ void -w32_shift_glyphs_for_insert (f, x, y, width, height, shift_by) - struct frame *f; - int x, y, width, height, shift_by; +w32_shift_glyphs_for_insert (struct frame *f, int x, int y, + int width, int height, int shift_by) { HDC hdc; @@ -2510,9 +2463,7 @@ w32_shift_glyphs_for_insert (f, x, y, width, height, shift_by) for X frames. */ static void -x_delete_glyphs (f, n) - struct frame *f; - register int n; +x_delete_glyphs (struct frame *f, register int n) { if (! FRAME_W32_P (f)) return; @@ -2582,8 +2533,7 @@ w32_ring_bell (struct frame *f) that is bounded by calls to x_update_begin and x_update_end. */ static void -w32_set_terminal_window (n) - register int n; +w32_set_terminal_window (struct frame *f, int n) { /* This function intentionally left blank. */ } @@ -2597,9 +2547,7 @@ w32_set_terminal_window (n) lines or deleting -N lines at vertical position VPOS. */ static void -x_ins_del_lines (f, vpos, n) - struct frame *f; - int vpos, n; +x_ins_del_lines (struct frame *f, int vpos, int n) { if (! FRAME_W32_P (f)) return; @@ -2611,9 +2559,7 @@ x_ins_del_lines (f, vpos, n) /* Scroll part of the display as described by RUN. */ static void -x_scroll_run (w, run) - struct window *w; - struct run *run; +x_scroll_run (struct window *w, struct run *run) { struct frame *f = XFRAME (w->frame); int x, y, width, height, from_y, to_y, bottom_y; @@ -2695,16 +2641,14 @@ x_scroll_run (w, run) ***********************************************************************/ static void -frame_highlight (f) - struct frame *f; +frame_highlight (struct frame *f) { x_update_cursor (f, 1); x_set_frame_alpha (f); } static void -frame_unhighlight (f) - struct frame *f; +frame_unhighlight (struct frame *f) { x_update_cursor (f, 1); x_set_frame_alpha (f); @@ -2717,9 +2661,7 @@ frame_unhighlight (f) Lisp code can tell when the switch took place by examining the events. */ static void -x_new_focus_frame (dpyinfo, frame) - struct w32_display_info *dpyinfo; - struct frame *frame; +x_new_focus_frame (struct w32_display_info *dpyinfo, struct frame *frame) { struct frame *old_focus = dpyinfo->w32_focus_frame; @@ -2747,12 +2689,8 @@ x_new_focus_frame (dpyinfo, frame) a FOCUS_IN_EVENT into *BUFP. */ static void -x_focus_changed (type, state, dpyinfo, frame, bufp) - int type; - int state; - struct w32_display_info *dpyinfo; - struct frame *frame; - struct input_event *bufp; +x_focus_changed (int type, int state, struct w32_display_info *dpyinfo, + struct frame *frame, struct input_event *bufp) { if (type == WM_SETFOCUS) { @@ -2797,10 +2735,8 @@ x_focus_changed (type, state, dpyinfo, frame, bufp) Returns FOCUS_IN_EVENT event in *BUFP. */ static void -w32_detect_focus_change (dpyinfo, event, bufp) - struct w32_display_info *dpyinfo; - W32Msg *event; - struct input_event *bufp; +w32_detect_focus_change (struct w32_display_info *dpyinfo, W32Msg *event, + struct input_event *bufp) { struct frame *frame; @@ -2819,8 +2755,7 @@ w32_detect_focus_change (dpyinfo, event, bufp) /* Handle an event saying the mouse has moved out of an Emacs frame. */ void -x_mouse_leave (dpyinfo) - struct w32_display_info *dpyinfo; +x_mouse_leave (struct w32_display_info *dpyinfo) { x_new_focus_frame (dpyinfo, dpyinfo->w32_focus_event_frame); } @@ -2834,8 +2769,7 @@ x_mouse_leave (dpyinfo) the appropriate X display info. */ static void -w32_frame_rehighlight (frame) - struct frame *frame; +w32_frame_rehighlight (struct frame *frame) { if (! FRAME_W32_P (frame)) return; @@ -2843,8 +2777,7 @@ w32_frame_rehighlight (frame) } static void -x_frame_rehighlight (dpyinfo) - struct w32_display_info *dpyinfo; +x_frame_rehighlight (struct w32_display_info *dpyinfo) { struct frame *old_highlight = dpyinfo->x_highlight_frame; @@ -2877,8 +2810,7 @@ x_frame_rehighlight (dpyinfo) /* Convert a keysym to its name. */ char * -x_get_keysym_name (keysym) - int keysym; +x_get_keysym_name (int keysym) { /* Make static so we can always return it */ static char value[100]; @@ -2908,11 +2840,7 @@ codepage_for_locale (LCID locale) the state in PUP. XBUTTON provides extra information for extended mouse button messages. Returns FALSE if unable to parse the message. */ BOOL -parse_button (message, xbutton, pbutton, pup) - int message; - int xbutton; - int * pbutton; - int * pup; +parse_button (int message, int xbutton, int * pbutton, int * pup) { int button = 0; int up = 0; @@ -2980,10 +2908,7 @@ parse_button (message, xbutton, pbutton, pup) the mouse. */ static Lisp_Object -construct_mouse_click (result, msg, f) - struct input_event *result; - W32Msg *msg; - struct frame *f; +construct_mouse_click (struct input_event *result, W32Msg *msg, struct frame *f) { int button; int up; @@ -3009,10 +2934,7 @@ construct_mouse_click (result, msg, f) } static Lisp_Object -construct_mouse_wheel (result, msg, f) - struct input_event *result; - W32Msg *msg; - struct frame *f; +construct_mouse_wheel (struct input_event *result, W32Msg *msg, struct frame *f) { POINT p; int delta; @@ -3045,10 +2967,7 @@ construct_mouse_wheel (result, msg, f) } static Lisp_Object -construct_drag_n_drop (result, msg, f) - struct input_event *result; - W32Msg *msg; - struct frame *f; +construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f) { Lisp_Object files; Lisp_Object frame; @@ -3109,9 +3028,7 @@ static MSG last_mouse_motion_event; static Lisp_Object last_mouse_motion_frame; static int -note_mouse_movement (frame, msg) - FRAME_PTR frame; - MSG *msg; +note_mouse_movement (FRAME_PTR frame, MSG *msg) { int mouse_x = LOWORD (msg->lParam); int mouse_y = HIWORD (msg->lParam); @@ -3159,12 +3076,15 @@ note_mouse_movement (frame, msg) Mouse Face ************************************************************************/ -static struct scroll_bar *x_window_to_scroll_bar (); -static void x_scroll_bar_report_motion (); -static void x_check_fullscreen P_ ((struct frame *)); +static struct scroll_bar *x_window_to_scroll_bar (Window); +static void x_scroll_bar_report_motion (FRAME_PTR *, Lisp_Object *, + enum scroll_bar_part *, + Lisp_Object *, Lisp_Object *, + unsigned long *); +static void x_check_fullscreen (struct frame *); static void -redo_mouse_highlight () +redo_mouse_highlight (void) { if (!NILP (last_mouse_motion_frame) && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame))) @@ -3174,9 +3094,7 @@ redo_mouse_highlight () } static void -w32_define_cursor (window, cursor) - Window window; - Cursor cursor; +w32_define_cursor (Window window, Cursor cursor) { PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0); } @@ -3201,13 +3119,9 @@ w32_define_cursor (window, cursor) movement. */ static void -w32_mouse_position (fp, insist, bar_window, part, x, y, time) - FRAME_PTR *fp; - int insist; - Lisp_Object *bar_window; - enum scroll_bar_part *part; - Lisp_Object *x, *y; - unsigned long *time; +w32_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, + enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, + unsigned long *time) { FRAME_PTR f1; @@ -3298,9 +3212,7 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time) or ButtonRelase. */ static void -w32_handle_tool_bar_click (f, button_event) - struct frame *f; - struct input_event *button_event; +w32_handle_tool_bar_click (struct frame *f, struct input_event *button_event) { int x = XFASTINT (button_event->x); int y = XFASTINT (button_event->y); @@ -3325,8 +3237,7 @@ w32_handle_tool_bar_click (f, button_event) bits. */ static struct scroll_bar * -x_window_to_scroll_bar (window_id) - Window window_id; +x_window_to_scroll_bar (Window window_id) { Lisp_Object tail; @@ -3362,9 +3273,8 @@ x_window_to_scroll_bar (window_id) displaying PORTION out of a whole WHOLE, and our position POSITION. */ static void -w32_set_scroll_bar_thumb (bar, portion, position, whole) - struct scroll_bar *bar; - int portion, position, whole; +w32_set_scroll_bar_thumb (struct scroll_bar *bar, + int portion, int position, int whole) { Window w = SCROLL_BAR_W32_WINDOW (bar); /* We use the whole scroll-bar height in the calculations below, to @@ -3439,9 +3349,7 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole) ************************************************************************/ static HWND -my_create_scrollbar (f, bar) - struct frame * f; - struct scroll_bar * bar; +my_create_scrollbar (struct frame * f, struct scroll_bar * bar) { return (HWND) SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_CREATESCROLLBAR, (WPARAM) f, @@ -3479,27 +3387,24 @@ my_set_window_pos (HWND hwnd, HWND hwndAfter, #endif } +#if 0 static void -my_set_focus (f, hwnd) - struct frame * f; - HWND hwnd; +my_set_focus (struct frame * f, HWND hwnd) { SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_SETFOCUS, (WPARAM) hwnd, 0); } +#endif static void -my_set_foreground_window (hwnd) - HWND hwnd; +my_set_foreground_window (HWND hwnd) { SendMessage (hwnd, WM_EMACS_SETFOREGROUND, (WPARAM) hwnd, 0); } static void -my_destroy_window (f, hwnd) - struct frame * f; - HWND hwnd; +my_destroy_window (struct frame * f, HWND hwnd) { SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_DESTROYWINDOW, (WPARAM) hwnd, 0); @@ -3511,9 +3416,7 @@ my_destroy_window (f, hwnd) scroll bar. */ static struct scroll_bar * -x_scroll_bar_create (w, top, left, width, height) - struct window *w; - int top, left, width, height; +x_scroll_bar_create (struct window *w, int top, int left, int width, int height) { struct frame *f = XFRAME (WINDOW_FRAME (w)); HWND hwnd; @@ -3566,8 +3469,7 @@ x_scroll_bar_create (w, top, left, width, height) nil. */ static void -x_scroll_bar_remove (bar) - struct scroll_bar *bar; +x_scroll_bar_remove (struct scroll_bar *bar) { FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); @@ -3587,9 +3489,8 @@ x_scroll_bar_remove (bar) characters, starting at POSITION. If WINDOW has no scroll bar, create one. */ static void -w32_set_vertical_scroll_bar (w, portion, whole, position) - struct window *w; - int portion, whole, position; +w32_set_vertical_scroll_bar (struct window *w, + int portion, int whole, int position) { struct frame *f = XFRAME (w->frame); struct scroll_bar *bar; @@ -3732,8 +3633,7 @@ w32_set_vertical_scroll_bar (w, portion, whole, position) `*redeem_scroll_bar_hook' is applied to its window before the judgment. */ static void -w32_condemn_scroll_bars (frame) - FRAME_PTR frame; +w32_condemn_scroll_bars (FRAME_PTR frame) { /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */ while (! NILP (FRAME_SCROLL_BARS (frame))) @@ -3754,8 +3654,7 @@ w32_condemn_scroll_bars (frame) Note that WINDOW isn't necessarily condemned at all. */ static void -w32_redeem_scroll_bar (window) - struct window *window; +w32_redeem_scroll_bar (struct window *window) { struct scroll_bar *bar; struct frame *f; @@ -3800,8 +3699,7 @@ w32_redeem_scroll_bar (window) last call to `*condemn_scroll_bars_hook'. */ static void -w32_judge_scroll_bars (f) - FRAME_PTR f; +w32_judge_scroll_bars (FRAME_PTR f) { Lisp_Object bar, next; @@ -3832,10 +3730,8 @@ w32_judge_scroll_bars (f) mark bits. */ static int -w32_scroll_bar_handle_click (bar, msg, emacs_event) - struct scroll_bar *bar; - W32Msg *msg; - struct input_event *emacs_event; +w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg, + struct input_event *emacs_event) { if (! WINDOWP (bar->window)) abort (); @@ -3941,12 +3837,10 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event) on the scroll bar. */ static void -x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) - FRAME_PTR *fp; - Lisp_Object *bar_window; - enum scroll_bar_part *part; - Lisp_Object *x, *y; - unsigned long *time; +x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, + enum scroll_bar_part *part, + Lisp_Object *x, Lisp_Object *y, + unsigned long *time) { struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); Window w = SCROLL_BAR_W32_WINDOW (bar); @@ -4002,8 +3896,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) redraw them. */ void -x_scroll_bar_clear (f) - FRAME_PTR f; +x_scroll_bar_clear (FRAME_PTR f) { Lisp_Object bar; @@ -4061,11 +3954,9 @@ static char dbcs_lead = 0; recursively with different messages by the system. */ -int -w32_read_socket (sd, expected, hold_quit) - register int sd; - int expected; - struct input_event *hold_quit; +static int +w32_read_socket (struct terminal *terminal, int expected, + struct input_event *hold_quit) { int count = 0; int check_visibility = 0; @@ -4894,11 +4785,7 @@ w32_read_socket (sd, expected, hold_quit) mode lines must be clipped to the whole window. */ static void -w32_clip_to_row (w, row, area, hdc) - struct window *w; - struct glyph_row *row; - int area; - HDC hdc; +w32_clip_to_row (struct window *w, struct glyph_row *row, int area, HDC hdc) { struct frame *f = XFRAME (WINDOW_FRAME (w)); RECT clip_rect; @@ -4919,9 +4806,7 @@ w32_clip_to_row (w, row, area, hdc) /* Draw a hollow box cursor on window W in glyph row ROW. */ static void -x_draw_hollow_cursor (w, row) - struct window *w; - struct glyph_row *row; +x_draw_hollow_cursor (struct window *w, struct glyph_row *row) { struct frame *f = XFRAME (WINDOW_FRAME (w)); HDC hdc; @@ -4961,11 +4846,8 @@ x_draw_hollow_cursor (w, row) --gerd. */ static void -x_draw_bar_cursor (w, row, width, kind) - struct window *w; - struct glyph_row *row; - int width; - enum text_cursor_kinds kind; +x_draw_bar_cursor (struct window *w, struct glyph_row *row, + int width, enum text_cursor_kinds kind) { struct frame *f = XFRAME (w->frame); struct glyph *cursor_glyph; @@ -5014,6 +4896,11 @@ x_draw_bar_cursor (w, row, width, kind) w->phys_cursor_width = width; + /* If the character under cursor is R2L, draw the bar cursor + on the right of its glyph, rather than on the left. */ + if ((cursor_glyph->resolved_level & 1) != 0) + x += cursor_glyph->pixel_width - width; + w32_fill_area (f, hdc, cursor_color, x, WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), width, row->height); @@ -5044,9 +4931,7 @@ x_draw_bar_cursor (w, row, width, kind) /* RIF: Define cursor CURSOR on frame F. */ static void -w32_define_frame_cursor (f, cursor) - struct frame *f; - Cursor cursor; +w32_define_frame_cursor (struct frame *f, Cursor cursor) { w32_define_cursor (FRAME_W32_WINDOW (f), cursor); } @@ -5055,9 +4940,7 @@ w32_define_frame_cursor (f, cursor) /* RIF: Clear area on frame F. */ static void -w32_clear_frame_area (f, x, y, width, height) - struct frame *f; - int x, y, width, height; +w32_clear_frame_area (struct frame *f, int x, int y, int width, int height) { HDC hdc; @@ -5069,12 +4952,9 @@ w32_clear_frame_area (f, x, y, width, height) /* RIF: Draw or clear cursor on window W. */ static void -w32_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, active_p) - struct window *w; - struct glyph_row *glyph_row; - int x, y; - int cursor_type, cursor_width; - int on_p, active_p; +w32_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, + int x, int y, int cursor_type, int cursor_width, + int on_p, int active_p) { if (on_p) { @@ -5127,10 +5007,12 @@ w32_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, act } if (glyph_row->exact_window_width_line_p - && w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA]) + && (glyph_row->reversed_p + ? (w->phys_cursor.hpos < 0) + : (w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA]))) { glyph_row->cursor_in_fringe_p = 1; - draw_fringe_bitmap (w, glyph_row, 0); + draw_fringe_bitmap (w, glyph_row, glyph_row->reversed_p); return; } @@ -5167,9 +5049,7 @@ w32_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, act /* Icons. */ int -x_bitmap_icon (f, icon) - struct frame *f; - Lisp_Object icon; +x_bitmap_icon (struct frame *f, Lisp_Object icon) { HANDLE main_icon; HANDLE small_icon = NULL; @@ -5258,10 +5138,7 @@ x_io_error_quitter (display) /* Changing the font of the frame. */ Lisp_Object -x_new_font (f, font_object, fontset) - struct frame *f; - Lisp_Object font_object; - int fontset; +x_new_font (struct frame *f, Lisp_Object font_object, int fontset) { struct font *font = XFONT_OBJECT (font_object); @@ -5329,8 +5206,7 @@ xim_close_dpy (dpyinfo) from its current recorded position values and gravity. */ void -x_calc_absolute_position (f) - struct frame *f; +x_calc_absolute_position (struct frame *f) { int flags = f->size_hint_flags; @@ -5390,10 +5266,8 @@ x_calc_absolute_position (f) which means, do adjust for borders but don't change the gravity. */ void -x_set_offset (f, xoff, yoff, change_gravity) - struct frame *f; - register int xoff, yoff; - int change_gravity; +x_set_offset (struct frame *f, register int xoff, register int yoff, + int change_gravity) { int modified_top, modified_left; @@ -5428,8 +5302,7 @@ x_set_offset (f, xoff, yoff, change_gravity) /* Check if we need to resize the frame due to a fullscreen request. If so needed, resize the frame. */ static void -x_check_fullscreen (f) - struct frame *f; +x_check_fullscreen (struct frame *f) { if (f->want_fullscreen & FULLSCREEN_BOTH) { @@ -5459,10 +5332,7 @@ x_check_fullscreen (f) Otherwise we leave the window gravity unchanged. */ void -x_set_window_size (f, change_gravity, cols, rows) - struct frame *f; - int change_gravity; - int cols, rows; +x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) { int pixelwidth, pixelheight; @@ -5554,9 +5424,7 @@ x_set_window_size (f, change_gravity, cols, rows) void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); void -x_set_mouse_position (f, x, y) - struct frame *f; - int x, y; +x_set_mouse_position (struct frame *f, int x, int y) { int pix_x, pix_y; @@ -5573,9 +5441,7 @@ x_set_mouse_position (f, x, y) } void -x_set_mouse_pixel_position (f, pix_x, pix_y) - struct frame *f; - int pix_x, pix_y; +x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) { RECT rect; POINT pt; @@ -5596,8 +5462,7 @@ x_set_mouse_pixel_position (f, pix_x, pix_y) /* focus shifting, raising and lowering. */ void -x_focus_on_frame (f) - struct frame *f; +x_focus_on_frame (struct frame *f) { struct w32_display_info *dpyinfo = &one_w32_display_info; @@ -5614,15 +5479,13 @@ x_focus_on_frame (f) } void -x_unfocus_frame (f) - struct frame *f; +x_unfocus_frame (struct frame *f) { } /* Raise frame F. */ void -x_raise_frame (f) - struct frame *f; +x_raise_frame (struct frame *f) { BLOCK_INPUT; @@ -5681,8 +5544,7 @@ x_raise_frame (f) /* Lower frame F. */ void -x_lower_frame (f) - struct frame *f; +x_lower_frame (struct frame *f) { BLOCK_INPUT; my_set_window_pos (FRAME_W32_WINDOW (f), @@ -5693,9 +5555,7 @@ x_lower_frame (f) } static void -w32_frame_raise_lower (f, raise_flag) - FRAME_PTR f; - int raise_flag; +w32_frame_raise_lower (FRAME_PTR f, int raise_flag) { if (! FRAME_W32_P (f)) return; @@ -5716,8 +5576,7 @@ w32_frame_raise_lower (f, raise_flag) finishes with it. */ void -x_make_frame_visible (f) - struct frame *f; +x_make_frame_visible (struct frame *f) { Lisp_Object type; @@ -5809,8 +5668,8 @@ x_make_frame_visible (f) /* Make the frame visible (mapped and not iconified). */ -x_make_frame_invisible (f) - struct frame *f; +void +x_make_frame_invisible (struct frame *f) { /* Don't keep the highlight on an invisible frame. */ if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f) @@ -5836,8 +5695,7 @@ x_make_frame_invisible (f) /* Change window state from mapped to iconified. */ void -x_iconify_frame (f) - struct frame *f; +x_iconify_frame (struct frame *f) { Lisp_Object type; @@ -5864,8 +5722,7 @@ x_iconify_frame (f) /* Free X resources of frame F. */ void -x_free_frame_resources (f) - struct frame *f; +x_free_frame_resources (struct frame *f) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); @@ -5923,8 +5780,7 @@ x_free_frame_resources (f) /* Destroy the window of frame F. */ void -x_destroy_window (f) - struct frame *f; +x_destroy_window (struct frame *f) { struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); @@ -5941,10 +5797,7 @@ x_destroy_window (f) If USER_POSITION is nonzero, we set the USPosition flag (this is useful when FLAGS is 0). */ void -x_wm_set_size_hint (f, flags, user_position) - struct frame *f; - long flags; - int user_position; +x_wm_set_size_hint (struct frame *f, long flags, int user_position) { Window window = FRAME_W32_WINDOW (f); @@ -5960,9 +5813,7 @@ x_wm_set_size_hint (f, flags, user_position) /* Window manager things */ void -x_wm_set_icon_position (f, icon_x, icon_y) - struct frame *f; - int icon_x, icon_y; +x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) { #if 0 Window window = FRAME_W32_WINDOW (f); @@ -5983,12 +5834,11 @@ x_wm_set_icon_position (f, icon_x, icon_y) static int w32_initialized = 0; void -w32_initialize_display_info (display_name) - Lisp_Object display_name; +w32_initialize_display_info (Lisp_Object display_name) { struct w32_display_info *dpyinfo = &one_w32_display_info; - bzero (dpyinfo, sizeof (*dpyinfo)); + memset (dpyinfo, 0, sizeof (*dpyinfo)); /* Put it on w32_display_name_list. */ w32_display_name_list = Fcons (Fcons (display_name, Qnil), @@ -6037,8 +5887,7 @@ w32_initialize_display_info (display_name) but any whitespace following value is not removed. */ static char * -w32_make_rdb (xrm_option) - char *xrm_option; +w32_make_rdb (char *xrm_option) { char *buffer = xmalloc (strlen (xrm_option) + 2); char *current = buffer; @@ -6197,10 +6046,7 @@ x_delete_terminal (struct terminal *terminal) } struct w32_display_info * -w32_term_init (display_name, xrm_option, resource_name) - Lisp_Object display_name; - char *xrm_option; - char *resource_name; +w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) { struct w32_display_info *dpyinfo; struct terminal *terminal; @@ -6275,8 +6121,7 @@ w32_term_init (display_name, xrm_option, resource_name) /* Get rid of display DPYINFO, assuming all frames are already gone. */ void -x_delete_display (dpyinfo) - struct w32_display_info *dpyinfo; +x_delete_display (struct w32_display_info *dpyinfo) { /* Discard this display from w32_display_name_list and w32_display_list. We can't use Fdelq because that can quit. */ @@ -6324,7 +6169,7 @@ x_delete_display (dpyinfo) DWORD WINAPI w32_msg_worker (void * arg); static void -w32_initialize () +w32_initialize (void) { HANDLE shell; HRESULT (WINAPI * set_user_model) (wchar_t * id); @@ -6427,7 +6272,7 @@ w32_initialize () } void -syms_of_w32term () +syms_of_w32term (void) { staticpro (&w32_display_name_list); w32_display_name_list = Qnil; diff --git a/src/w32term.h b/src/w32term.h index ea5f420a7dc..ea245144ac3 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -48,8 +48,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ extern MSG CurMsg; extern BOOL bUseDflt; -extern struct frame *x_window_to_frame (); - /* Structure recording bitmaps and reference count. If REFCOUNT is 0 then this record is free to be reused. */ @@ -226,16 +224,19 @@ extern Lisp_Object w32_display_name_list; /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */ extern Lisp_Object Vx_pixel_size_width_font_regexp; -struct w32_display_info *x_display_info_for_name (); +extern struct frame *x_window_to_frame (struct w32_display_info *, HWND); + +struct w32_display_info *x_display_info_for_name (Lisp_Object); -Lisp_Object display_x_get_resource P_ ((struct w32_display_info *, - Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object)); +Lisp_Object display_x_get_resource (struct w32_display_info *, + Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object); -extern struct w32_display_info *w32_term_init (); +extern struct w32_display_info *w32_term_init (Lisp_Object, + char *, char *); -extern int x_display_pixel_height P_ ((struct w32_display_info *)); -extern int x_display_pixel_width P_ ((struct w32_display_info *)); +extern int x_display_pixel_height (struct w32_display_info *); +extern int x_display_pixel_width (struct w32_display_info *); #define PIX_TYPE COLORREF @@ -544,8 +545,10 @@ struct scroll_bar { #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0) -extern void w32_fill_rect (); -extern void w32_clear_window (); +struct frame; /* from frame.h */ + +extern void w32_fill_rect (struct frame *, HDC, COLORREF, RECT *); +extern void w32_clear_window (struct frame *); #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \ do { \ @@ -645,10 +648,10 @@ typedef struct deferred_msg extern CRITICAL_SECTION critsect; -extern void init_crit (); -extern void delete_crit (); +extern void init_crit (void); +extern void delete_crit (void); -extern void signal_quit (); +extern void signal_quit (void); #define enter_crit() EnterCriticalSection (&critsect) #define leave_crit() LeaveCriticalSection (&critsect) @@ -658,14 +661,13 @@ extern void deselect_palette (struct frame * f, HDC hdc); extern HDC get_frame_dc (struct frame * f); extern int release_frame_dc (struct frame * f, HDC hDC); -extern void drain_message_queue (); +extern void drain_message_queue (void); -extern BOOL get_next_msg (); -extern BOOL post_msg (); +extern BOOL get_next_msg (W32Msg *, BOOL); +extern BOOL post_msg (W32Msg *); extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result); -extern void wait_for_sync (); -extern BOOL parse_button (); +extern BOOL parse_button (int, int, int *, int *); extern void w32_sys_ring_bell (struct frame *f); extern void x_delete_display (struct w32_display_info *dpyinfo); @@ -725,7 +727,7 @@ struct frame * check_x_frame (Lisp_Object); EXFUN (Fx_display_color_p, 1); EXFUN (Fx_display_grayscale_p, 1); -typedef DWORD (WINAPI * ClipboardSequence_Proc) (); +typedef DWORD (WINAPI * ClipboardSequence_Proc) (void); typedef BOOL (WINAPI * AppendMenuW_Proc) ( IN HMENU, IN UINT, diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 6d75aa27f8a..6c29e6ee2d0 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c @@ -57,15 +57,14 @@ extern int initialized; extern struct font_driver uniscribe_font_driver; /* EnumFontFamiliesEx callback. */ -static int CALLBACK add_opentype_font_name_to_list P_ ((ENUMLOGFONTEX *, - NEWTEXTMETRICEX *, - DWORD, LPARAM)); +static int CALLBACK add_opentype_font_name_to_list (ENUMLOGFONTEX *, + NEWTEXTMETRICEX *, + DWORD, LPARAM); /* Used by uniscribe_otf_capability. */ static Lisp_Object otf_features (HDC context, char *table); static int -memq_no_quit (elt, list) - Lisp_Object elt, list; +memq_no_quit (Lisp_Object elt, Lisp_Object list) { while (CONSP (list) && ! EQ (XCAR (list), elt)) list = XCDR (list); @@ -75,8 +74,7 @@ memq_no_quit (elt, list) /* Font backend interface implementation. */ static Lisp_Object -uniscribe_list (frame, font_spec) - Lisp_Object frame, font_spec; +uniscribe_list (Lisp_Object frame, Lisp_Object font_spec) { Lisp_Object fonts = w32font_list_internal (frame, font_spec, 1); FONT_ADD_LOG ("uniscribe-list", font_spec, fonts); @@ -84,8 +82,7 @@ uniscribe_list (frame, font_spec) } static Lisp_Object -uniscribe_match (frame, font_spec) - Lisp_Object frame, font_spec; +uniscribe_match (Lisp_Object frame, Lisp_Object font_spec) { Lisp_Object entity = w32font_match_internal (frame, font_spec, 1); FONT_ADD_LOG ("uniscribe-match", font_spec, entity); @@ -93,15 +90,14 @@ uniscribe_match (frame, font_spec) } static Lisp_Object -uniscribe_list_family (frame) - Lisp_Object frame; +uniscribe_list_family (Lisp_Object frame) { Lisp_Object list = Qnil; LOGFONT font_match_pattern; HDC dc; FRAME_PTR f = XFRAME (frame); - bzero (&font_match_pattern, sizeof (font_match_pattern)); + memset (&font_match_pattern, 0, sizeof (font_match_pattern)); /* Limit enumerated fonts to outline fonts to save time. */ font_match_pattern.lfOutPrecision = OUT_OUTLINE_PRECIS; @@ -116,10 +112,7 @@ uniscribe_list_family (frame) } static Lisp_Object -uniscribe_open (f, font_entity, pixel_size) - FRAME_PTR f; - Lisp_Object font_entity; - int pixel_size; +uniscribe_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) { Lisp_Object font_object = font_make_object (VECSIZE (struct uniscribe_font_info), @@ -148,9 +141,7 @@ uniscribe_open (f, font_entity, pixel_size) } static void -uniscribe_close (f, font) - FRAME_PTR f; - struct font *font; +uniscribe_close (FRAME_PTR f, struct font *font) { struct uniscribe_font_info *uniscribe_font = (struct uniscribe_font_info *) font; @@ -164,8 +155,7 @@ uniscribe_close (f, font) /* Return a list describing which scripts/languages FONT supports by which GSUB/GPOS features of OpenType tables. */ static Lisp_Object -uniscribe_otf_capability (font) - struct font *font; +uniscribe_otf_capability (struct font *font) { HDC context; HFONT old_font; @@ -190,20 +180,20 @@ uniscribe_otf_capability (font) /* Uniscribe implementation of shape for font backend. - Shape text in LGSTRING. See the docstring of `font-make-gstring' - for the format of LGSTRING. If the (N+1)th element of LGSTRING - is nil, input of shaping is from the 1st to (N)th elements. In - each input glyph, FROM, TO, CHAR, and CODE are already set. + Shape text in LGSTRING. See the docstring of + `composition-get-gstring' for the format of LGSTRING. If the + (N+1)th element of LGSTRING is nil, input of shaping is from the + 1st to (N)th elements. In each input glyph, FROM, TO, CHAR, and + CODE are already set. This function updates all fields of the input glyphs. If the output glyphs (M) are more than the input glyphs (N), (N+1)th through (M)th elements of LGSTRING are updated possibly by making a new glyph object and storing it in LGSTRING. If (M) is greater - than the length of LGSTRING, nil should be return. In that case, - this function is called again with the larger LGSTRING. */ + than the length of LGSTRING, nil should be returned. In that case, + this function is called again with a larger LGSTRING. */ static Lisp_Object -uniscribe_shape (lgstring) - Lisp_Object lgstring; +uniscribe_shape (Lisp_Object lgstring) { struct font * font; struct uniscribe_font_info * uniscribe_font; @@ -228,6 +218,9 @@ uniscribe_shape (lgstring) max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring); done_glyphs = 0; chars = (wchar_t *) alloca (nchars * sizeof (wchar_t)); + /* FIXME: This loop assumes that characters in the input LGSTRING + are all inside the BMP. Need to encode characters beyond the BMP + as UTF-16. */ for (i = 0; i < nchars; i++) { /* lgstring can be bigger than the number of characters in it, in @@ -259,9 +252,6 @@ uniscribe_shape (lgstring) return Qnil; } - /* TODO: When we get BIDI support, we need to call ScriptLayout here. - Requires that we know the surrounding context. */ - glyphs = alloca (max_glyphs * sizeof (WORD)); clusters = alloca (nchars * sizeof (WORD)); attributes = alloca (max_glyphs * sizeof (SCRIPT_VISATTR)); @@ -270,8 +260,12 @@ uniscribe_shape (lgstring) for (i = 0; i < nitems; i++) { - int nglyphs, nchars_in_run, rtl = items[i].a.fRTL ? -1 : 1; + int nglyphs, nchars_in_run; nchars_in_run = items[i+1].iCharPos - items[i].iCharPos; + /* Force ScriptShape to generate glyphs in the same order as + they are in the input LGSTRING, which is in the logical + order. */ + items[i].a.fLogicalOrder = 1; /* Context may be NULL here, in which case the cache should be used without needing to select the font. */ @@ -332,7 +326,7 @@ uniscribe_shape (lgstring) { int j, nclusters, from, to; - from = rtl > 0 ? 0 : nchars_in_run - 1; + from = 0; to = from; for (j = 0; j < nglyphs; j++) @@ -353,22 +347,19 @@ uniscribe_shape (lgstring) gl = glyphs[j]; LGLYPH_SET_CODE (lglyph, gl); - /* Detect clusters, for linking codes back to characters. */ + /* Detect clusters, for linking codes back to + characters. */ if (attributes[j].fClusterStart) { - while (from >= 0 && from < nchars_in_run - && clusters[from] < j) - from += rtl; - if (from < 0) - from = to = 0; - else if (from >= nchars_in_run) + while (from < nchars_in_run && clusters[from] < j) + from++; + if (from >= nchars_in_run) from = to = nchars_in_run - 1; else { int k; - to = rtl > 0 ? nchars_in_run - 1 : 0; - for (k = from + rtl; k >= 0 && k < nchars_in_run; - k += rtl) + to = nchars_in_run - 1; + for (k = from + 1; k < nchars_in_run; k++) { if (clusters[k] > j) { @@ -451,9 +442,7 @@ uniscribe_shape (lgstring) Return a glyph code of FONT for character C (Unicode code point). If FONT doesn't have such a glyph, return FONT_INVALID_CODE. */ static unsigned -uniscribe_encode_char (font, c) - struct font *font; - int c; +uniscribe_encode_char (struct font *font, int c) { HDC context = NULL; struct frame *f = NULL; @@ -499,6 +488,10 @@ uniscribe_encode_char (font, c) SCRIPT_VISATTR attrs[2]; int nglyphs; + /* Force ScriptShape to generate glyphs in the logical + order. */ + items[0].a.fLogicalOrder = 1; + result = ScriptShape (context, &(uniscribe_font->cache), ch, len, 2, &(items[0].a), glyphs, clusters, attrs, &nglyphs); @@ -574,12 +567,9 @@ uniscribe_encode_char (font, c) Adds the name of opentype fonts to a Lisp list (passed in as the lParam arg). */ static int CALLBACK -add_opentype_font_name_to_list (logical_font, physical_font, font_type, - list_object) - ENUMLOGFONTEX *logical_font; - NEWTEXTMETRICEX *physical_font; - DWORD font_type; - LPARAM list_object; +add_opentype_font_name_to_list (ENUMLOGFONTEX *logical_font, + NEWTEXTMETRICEX *physical_font, + DWORD font_type, LPARAM list_object) { Lisp_Object* list = (Lisp_Object *) list_object; Lisp_Object family; @@ -651,9 +641,7 @@ static char* NOTHING = " "; OTF_SPEC is in the format (script lang [(gsub_feature ...)|nil] [(gpos_feature ...)]?) */ int -uniscribe_check_otf (font, otf_spec) - LOGFONT *font; - Lisp_Object otf_spec; +uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec) { Lisp_Object script, lang, rest; Lisp_Object features[2]; @@ -958,7 +946,7 @@ struct font_driver uniscribe_font_driver = /* Note that this should be called at every startup, not just when dumping, as it needs to test for the existence of the Uniscribe library. */ void -syms_of_w32uniscribe () +syms_of_w32uniscribe (void) { HMODULE uniscribe; diff --git a/src/w32xfns.c b/src/w32xfns.c index 7e2a3704dff..4cbd812ec0f 100644 --- a/src/w32xfns.c +++ b/src/w32xfns.c @@ -39,7 +39,7 @@ HANDLE input_available = NULL; HANDLE interrupt_handle = NULL; void -init_crit () +init_crit (void) { InitializeCriticalSection (&critsect); @@ -57,7 +57,7 @@ init_crit () } void -delete_crit () +delete_crit (void) { DeleteCriticalSection (&critsect); @@ -74,7 +74,7 @@ delete_crit () } void -signal_quit () +signal_quit (void) { /* Make sure this event never remains signaled; if the main thread isn't in a blocking call, then this should do nothing. */ @@ -161,9 +161,7 @@ int_msg *lpTail = NULL; int nQueue = 0; BOOL -get_next_msg (lpmsg, bWait) - W32Msg * lpmsg; - BOOL bWait; +get_next_msg (W32Msg * lpmsg, BOOL bWait) { BOOL bRet = FALSE; @@ -180,7 +178,7 @@ get_next_msg (lpmsg, bWait) if (nQueue) { - bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); + memcpy (lpmsg, &lpHead->w32msg, sizeof (W32Msg)); { int_msg * lpCur = lpHead; @@ -245,15 +243,14 @@ get_next_msg (lpmsg, bWait) } BOOL -post_msg (lpmsg) - W32Msg * lpmsg; +post_msg (W32Msg * lpmsg) { int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); if (!lpNew) return (FALSE); - bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); + memcpy (&lpNew->w32msg, lpmsg, sizeof (W32Msg)); lpNew->lpNext = NULL; enter_crit (); @@ -283,7 +280,7 @@ prepend_msg (W32Msg *lpmsg) if (!lpNew) return (FALSE); - bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); + memcpy (&lpNew->w32msg, lpmsg, sizeof (W32Msg)); enter_crit (); @@ -298,7 +295,7 @@ prepend_msg (W32Msg *lpmsg) /* Process all messages in the current thread's queue. */ void -drain_message_queue () +drain_message_queue (void) { MSG msg; while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) @@ -322,9 +319,7 @@ drain_message_queue () */ static int -read_integer (string, NextString) - register char *string; - char **NextString; +read_integer (register char *string, char **NextString) { register int Result = 0; int Sign = 1; @@ -348,10 +343,9 @@ read_integer (string, NextString) } int -XParseGeometry (string, x, y, width, height) - char *string; - int *x, *y; - unsigned int *width, *height; /* RETURN */ +XParseGeometry (char *string, + int *x, int *y, + unsigned int *width, unsigned int *height) { int mask = NoValue; register char *strind; @@ -445,8 +439,7 @@ XParseGeometry (string, x, y, width, height) /* x_sync is a no-op on W32. */ void -x_sync (f) - void *f; +x_sync (void *f) { } diff --git a/src/widget.c b/src/widget.c index 0c3aa64a74e..2301f76c7c9 100644 --- a/src/widget.c +++ b/src/widget.c @@ -76,14 +76,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define DEFAULT_FACE_FONT "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*" -static void EmacsFrameInitialize (/*Widget, Widget, ArgList, Cardinal * */); -static void EmacsFrameDestroy (/* Widget */); -static void EmacsFrameRealize (/* Widget, XtValueMask*, XSetWindowAttributes* */); -void EmacsFrameResize (/* Widget widget */); -static Boolean EmacsFrameSetValues (/* Widget, Widget, Widget, - ArgList, Cardinal * */); -static XtGeometryResult EmacsFrameQueryGeometry (/* Widget, XtWidgetGeometry*, - XtWidgetGeometry* */); +static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2); +static void EmacsFrameDestroy (Widget widget); +static void EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs); +void EmacsFrameResize (Widget widget); +static Boolean EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2); +static XtGeometryResult EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result); #undef XtOffset @@ -180,10 +178,7 @@ EmacsFrameClassRec emacsFrameClassRec = { WidgetClass emacsFrameClass = (WidgetClass) &emacsFrameClassRec; static void -get_default_char_pixel_size (ew, pixel_width, pixel_height) - EmacsFrame ew; - int* pixel_width; - int* pixel_height; +get_default_char_pixel_size (EmacsFrame ew, int *pixel_width, int *pixel_height) { struct frame* f = ew->emacs_frame.frame; *pixel_width = FRAME_COLUMN_WIDTH (f); @@ -191,12 +186,7 @@ get_default_char_pixel_size (ew, pixel_width, pixel_height) } static void -pixel_to_char_size (ew, pixel_width, pixel_height, char_width, char_height) - EmacsFrame ew; - Dimension pixel_width; - Dimension pixel_height; - int* char_width; - int* char_height; +pixel_to_char_size (EmacsFrame ew, Dimension pixel_width, Dimension pixel_height, int *char_width, int *char_height) { struct frame* f = ew->emacs_frame.frame; *char_width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, (int) pixel_width); @@ -204,12 +194,7 @@ pixel_to_char_size (ew, pixel_width, pixel_height, char_width, char_height) } static void -char_to_pixel_size (ew, char_width, char_height, pixel_width, pixel_height) - EmacsFrame ew; - int char_width; - int char_height; - Dimension* pixel_width; - Dimension* pixel_height; +char_to_pixel_size (EmacsFrame ew, int char_width, int char_height, Dimension *pixel_width, Dimension *pixel_height) { struct frame* f = ew->emacs_frame.frame; *pixel_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, char_width); @@ -217,12 +202,7 @@ char_to_pixel_size (ew, char_width, char_height, pixel_width, pixel_height) } static void -round_size_to_char (ew, in_width, in_height, out_width, out_height) - EmacsFrame ew; - Dimension in_width; - Dimension in_height; - Dimension* out_width; - Dimension* out_height; +round_size_to_char (EmacsFrame ew, Dimension in_width, Dimension in_height, Dimension *out_width, Dimension *out_height) { int char_width; int char_height; @@ -231,8 +211,7 @@ round_size_to_char (ew, in_width, in_height, out_width, out_height) } static Widget -get_wm_shell (w) - Widget w; +get_wm_shell (Widget w) { Widget wmshell; @@ -269,8 +248,7 @@ static Boolean first_frame_p = True; #endif static void -set_frame_size (ew) - EmacsFrame ew; +set_frame_size (EmacsFrame ew) { /* The widget hierarchy is @@ -491,8 +469,7 @@ set_frame_size (ew) int update_hints_inhibit; static void -update_wm_hints (ew) - EmacsFrame ew; +update_wm_hints (EmacsFrame ew) { Widget wmshell = get_wm_shell ((Widget)ew); int cw; @@ -570,8 +547,7 @@ static char setup_frame_cursor_bits[] = }; static void -setup_frame_gcs (ew) - EmacsFrame ew; +setup_frame_gcs (EmacsFrame ew) { XGCValues gc_values; struct frame* s = ew->emacs_frame.frame; @@ -649,8 +625,7 @@ setup_frame_gcs (ew) } static void -update_various_frame_slots (ew) - EmacsFrame ew; +update_various_frame_slots (EmacsFrame ew) { struct frame *f = ew->emacs_frame.frame; struct x_output *x = f->output_data.x; @@ -661,8 +636,7 @@ update_various_frame_slots (ew) } static void -update_from_various_frame_slots (ew) - EmacsFrame ew; +update_from_various_frame_slots (EmacsFrame ew) { struct frame *f = ew->emacs_frame.frame; struct x_output *x = f->output_data.x; @@ -677,11 +651,7 @@ update_from_various_frame_slots (ew) } static void -EmacsFrameInitialize (request, new, dum1, dum2) - Widget request; - Widget new; - ArgList dum1; - Cardinal *dum2; +EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, Cardinal *dum2) { EmacsFrame ew = (EmacsFrame)new; @@ -698,10 +668,7 @@ EmacsFrameInitialize (request, new, dum1, dum2) static void -EmacsFrameRealize (widget, mask, attrs) - Widget widget; - XtValueMask *mask; - XSetWindowAttributes *attrs; +EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs) { EmacsFrame ew = (EmacsFrame)widget; @@ -717,11 +684,10 @@ EmacsFrameRealize (widget, mask, attrs) update_wm_hints (ew); } -extern void free_frame_faces (/* struct frame * */); +extern void free_frame_faces (struct frame *); static void -EmacsFrameDestroy (widget) - Widget widget; +EmacsFrameDestroy (Widget widget) { EmacsFrame ew = (EmacsFrame) widget; struct frame* s = ew->emacs_frame.frame; @@ -739,8 +705,7 @@ EmacsFrameDestroy (widget) } void -EmacsFrameResize (widget) - Widget widget; +EmacsFrameResize (Widget widget) { EmacsFrame ew = (EmacsFrame)widget; struct frame *f = ew->emacs_frame.frame; @@ -756,12 +721,7 @@ EmacsFrameResize (widget) } static Boolean -EmacsFrameSetValues (cur_widget, req_widget, new_widget, dum1, dum2) - Widget cur_widget; - Widget req_widget; - Widget new_widget; - ArgList dum1; - Cardinal *dum2; +EmacsFrameSetValues (Widget cur_widget, Widget req_widget, Widget new_widget, ArgList dum1, Cardinal *dum2) { EmacsFrame cur = (EmacsFrame)cur_widget; EmacsFrame new = (EmacsFrame)new_widget; @@ -834,10 +794,7 @@ EmacsFrameSetValues (cur_widget, req_widget, new_widget, dum1, dum2) } static XtGeometryResult -EmacsFrameQueryGeometry (widget, request, result) - Widget widget; - XtWidgetGeometry* request; - XtWidgetGeometry* result; +EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *result) { EmacsFrame ew = (EmacsFrame)widget; @@ -867,10 +824,7 @@ EmacsFrameQueryGeometry (widget, request, result) /* Special entrypoints */ void -EmacsFrameSetCharSize (widget, columns, rows) - Widget widget; - int columns; - int rows; +EmacsFrameSetCharSize (Widget widget, int columns, int rows) { EmacsFrame ew = (EmacsFrame) widget; struct frame *f = ew->emacs_frame.frame; @@ -880,8 +834,7 @@ EmacsFrameSetCharSize (widget, columns, rows) void -widget_store_internal_border (widget) - Widget widget; +widget_store_internal_border (Widget widget) { EmacsFrame ew = (EmacsFrame) widget; FRAME_PTR f = ew->emacs_frame.frame; diff --git a/src/widget.h b/src/widget.h index 00c08914059..a1ddeb2e94f 100644 --- a/src/widget.h +++ b/src/widget.h @@ -94,8 +94,8 @@ extern WidgetClass emacsFrameClass; extern struct _DisplayContext* display_context; /* Special entrypoints */ -void EmacsFrameSetCharSize P_ ((Widget, int, int)); -void widget_store_internal_border P_ ((Widget widget)); +void EmacsFrameSetCharSize (Widget, int, int); +void widget_store_internal_border (Widget widget); #endif /* _EmacsFrame_h */ diff --git a/src/window.c b/src/window.c index f9a2d31b4fe..7591401ee42 100644 --- a/src/window.c +++ b/src/window.c @@ -51,40 +51,37 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "nsterm.h" #endif - Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; Lisp_Object Qdisplay_buffer; -Lisp_Object Qscroll_up, Qscroll_down; +Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; Lisp_Object Qwindow_size_fixed; -extern Lisp_Object Qleft_margin, Qright_margin; - -static int displayed_window_lines P_ ((struct window *)); -static struct window *decode_window P_ ((Lisp_Object)); -static int count_windows P_ ((struct window *)); -static int get_leaf_windows P_ ((struct window *, struct window **, int)); -static void window_scroll P_ ((Lisp_Object, int, int, int)); -static void window_scroll_pixel_based P_ ((Lisp_Object, int, int, int)); -static void window_scroll_line_based P_ ((Lisp_Object, int, int, int)); -static int window_min_size_1 P_ ((struct window *, int, int)); -static int window_min_size_2 P_ ((struct window *, int, int)); -static int window_min_size P_ ((struct window *, int, int, int, int *)); -static void size_window P_ ((Lisp_Object, int, int, int, int, int)); -static int freeze_window_start P_ ((struct window *, void *)); -static int window_fixed_size_p P_ ((struct window *, int, int)); -static void enlarge_window P_ ((Lisp_Object, int, int)); -static Lisp_Object window_list P_ ((void)); -static int add_window_to_list P_ ((struct window *, void *)); -static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object)); -static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object, - Lisp_Object, int)); -static void decode_next_window_args P_ ((Lisp_Object *, Lisp_Object *, - Lisp_Object *)); -static int foreach_window_1 P_ ((struct window *, - int (* fn) (struct window *, void *), - void *)); -static Lisp_Object window_list_1 P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); +static int displayed_window_lines (struct window *); +static struct window *decode_window (Lisp_Object); +static int count_windows (struct window *); +static int get_leaf_windows (struct window *, struct window **, int); +static void window_scroll (Lisp_Object, int, int, int); +static void window_scroll_pixel_based (Lisp_Object, int, int, int); +static void window_scroll_line_based (Lisp_Object, int, int, int); +static int window_min_size_1 (struct window *, int, int); +static int window_min_size_2 (struct window *, int, int); +static int window_min_size (struct window *, int, int, int, int *); +static void size_window (Lisp_Object, int, int, int, int, int); +static int freeze_window_start (struct window *, void *); +static int window_fixed_size_p (struct window *, int, int); +static void enlarge_window (Lisp_Object, int, int); +static Lisp_Object window_list (void); +static int add_window_to_list (struct window *, void *); +static int candidate_window_p (Lisp_Object, Lisp_Object, Lisp_Object, + Lisp_Object); +static Lisp_Object next_window (Lisp_Object, Lisp_Object, + Lisp_Object, int); +static void decode_next_window_args (Lisp_Object *, Lisp_Object *, + Lisp_Object *); +static int foreach_window_1 (struct window *, + int (* fn) (struct window *, void *), + void *); +static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); /* This is the window in which the terminal's cursor should be left when nothing is being done with it. This must @@ -191,36 +188,29 @@ static int window_scroll_preserve_vpos; static int inhibit_frame_unsplittable; #endif /* 0 */ -extern EMACS_INT scroll_margin; - -extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; - /* If non-nil, then the `recenter' command with a nil argument the entire frame to be redrawn; the special value `tty' causes the frame to be redrawn only if it is a tty frame. */ static Lisp_Object Vrecenter_redisplay; -extern Lisp_Object Qtty; DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, doc: /* Return t if OBJECT is a window. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return WINDOWP (object) ? Qt : Qnil; } DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, doc: /* Return t if OBJECT is a window which is currently visible. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return WINDOW_LIVE_P (object) ? Qt : Qnil; } Lisp_Object -make_window () +make_window (void) { Lisp_Object val; register struct window *p; @@ -243,9 +233,9 @@ make_window () p->dedicated = Qnil; p->window_parameters = Qnil; p->pseudo_window_p = 0; - bzero (&p->cursor, sizeof (p->cursor)); - bzero (&p->last_cursor, sizeof (p->last_cursor)); - bzero (&p->phys_cursor, sizeof (p->phys_cursor)); + memset (&p->cursor, 0, sizeof (p->cursor)); + memset (&p->last_cursor, 0, sizeof (p->last_cursor)); + memset (&p->phys_cursor, 0, sizeof (p->phys_cursor)); p->desired_matrix = p->current_matrix = 0; p->nrows_scale_factor = p->ncols_scale_factor = 1; p->phys_cursor_type = -1; @@ -274,7 +264,7 @@ make_window () DEFUN ("selected-window", Fselected_window, Sselected_window, 0, 0, 0, doc: /* Return the window that the cursor now appears in and commands apply to. */) - () + (void) { return selected_window; } @@ -283,8 +273,7 @@ DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, doc: /* Return the window used now for minibuffers. If the optional argument FRAME is specified, return the minibuffer window used by that frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { if (NILP (frame)) frame = selected_frame; @@ -295,8 +284,7 @@ used by that frame. */) DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1, 0, doc: /* Return non-nil if WINDOW is a minibuffer window. WINDOW defaults to the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w = decode_window (window); return MINI_WINDOW_P (w) ? Qt : Qnil; @@ -320,11 +308,10 @@ of the window. The remaining elements are omitted if the character after POS is fully visible; otherwise, RTOP and RBOT are the number of pixels off-window at the top and bottom of the row, ROWH is the height of the display row, and VPOS is the row number (0-based) containing POS. */) - (pos, window, partially) - Lisp_Object pos, window, partially; + (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) { register struct window *w; - register int posint; + register EMACS_INT posint; register struct buffer *buf; struct text_pos top; Lisp_Object in_window = Qnil; @@ -389,8 +376,7 @@ of the (first) text line, YPOS is negative. Return nil if window display is not up-to-date. In that case, use `pos-visible-in-window-p' to obtain the information. */) - (line, window) - Lisp_Object line, window; + (Lisp_Object line, Lisp_Object window) { register struct window *w; register struct buffer *b; @@ -483,8 +469,7 @@ Return nil if window display is not up-to-date. In that case, use static struct window * -decode_window (window) - register Lisp_Object window; +decode_window (register Lisp_Object window) { if (NILP (window)) return XWINDOW (selected_window); @@ -494,8 +479,7 @@ decode_window (window) } static struct window * -decode_any_window (window) - register Lisp_Object window; +decode_any_window (register Lisp_Object window) { if (NILP (window)) return XWINDOW (selected_window); @@ -507,8 +491,7 @@ decode_any_window (window) DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, doc: /* Return the buffer that WINDOW is displaying. WINDOW defaults to the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_window (window)->buffer; } @@ -521,8 +504,7 @@ The return value includes WINDOW's mode line and header line, if any. Note: The function does not take into account the value of `line-spacing' when calculating the number of lines in WINDOW. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_any_window (window)->total_lines; } @@ -534,8 +516,7 @@ WINDOW defaults to the selected window. Note: The return value is the number of columns available for text in WINDOW. If you want to find out how many columns WINDOW takes up, use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))). */) - (window) - Lisp_Object window; + (Lisp_Object window) { return make_number (window_box_text_cols (decode_any_window (window))); } @@ -543,8 +524,7 @@ WINDOW. If you want to find out how many columns WINDOW takes up, use DEFUN ("window-full-width-p", Fwindow_full_width_p, Swindow_full_width_p, 0, 1, 0, doc: /* Return t if WINDOW is as wide as its frame. WINDOW defaults to the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return WINDOW_FULL_WIDTH_P (decode_any_window (window)) ? Qt : Qnil; } @@ -552,8 +532,7 @@ WINDOW defaults to the selected window. */) DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, doc: /* Return the number of columns by which WINDOW is scrolled from left margin. WINDOW defaults to the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_window (window)->hscroll; } @@ -564,8 +543,7 @@ Return NCOL. NCOL should be zero or positive. Note that if `automatic-hscrolling' is non-nil, you cannot scroll the window so that the location of point moves off-window. */) - (window, ncol) - Lisp_Object window, ncol; + (Lisp_Object window, Lisp_Object ncol) { struct window *w = decode_window (window); int hscroll; @@ -586,8 +564,7 @@ DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger, doc: /* Return WINDOW's redisplay end trigger value. WINDOW defaults to the selected window. See `set-window-redisplay-end-trigger' for more information. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_window (window)->redisplay_end_trigger; } @@ -600,8 +577,7 @@ If it is a buffer position, then if redisplay in WINDOW reaches a position beyond VALUE, the functions in `redisplay-end-trigger-functions' are called with two arguments: WINDOW, and the end trigger value. Afterwards the end-trigger value is reset to nil. */) - (window, value) - register Lisp_Object window, value; + (register Lisp_Object window, Lisp_Object value) { register struct window *w; @@ -621,8 +597,7 @@ BOTTOM is one more than the bottommost row occupied by WINDOW. The edges include the space used by WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. For the edges of just the text area, use `window-inside-edges'. */) - (window) - Lisp_Object window; + (Lisp_Object window) { register struct window *w = decode_any_window (window); @@ -643,8 +618,7 @@ BOTTOM is one more than the bottommost y position occupied by WINDOW. The pixel edges include the space used by WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. For the pixel edges of just the text area, use `window-inside-pixel-edges'. */) - (window) - Lisp_Object window; + (Lisp_Object window) { register struct window *w = decode_any_window (window); @@ -655,6 +629,52 @@ of just the text area, use `window-inside-pixel-edges'. */) Qnil)))); } +static void +calc_absolute_offset(struct window *w, int *add_x, int *add_y) +{ + struct frame *f = XFRAME (w->frame); + *add_y = f->top_pos; +#ifdef FRAME_MENUBAR_HEIGHT + *add_y += FRAME_MENUBAR_HEIGHT (f); +#endif +#ifdef FRAME_TOOLBAR_TOP_HEIGHT + *add_y += FRAME_TOOLBAR_TOP_HEIGHT (f); +#elif FRAME_TOOLBAR_HEIGHT + *add_y += FRAME_TOOLBAR_HEIGHT (f); +#endif +#ifdef FRAME_NS_TITLEBAR_HEIGHT + *add_y += FRAME_NS_TITLEBAR_HEIGHT (f); +#endif + *add_x = f->left_pos; +#ifdef FRAME_TOOLBAR_LEFT_WIDTH + *add_x += FRAME_TOOLBAR_LEFT_WIDTH (f); +#endif +} + +DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges, + Swindow_absolute_pixel_edges, 0, 1, 0, + doc: /* Return a list of the edge pixel coordinates of WINDOW. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at +the top left corner of the display. + +RIGHT is one more than the rightmost x position occupied by WINDOW. +BOTTOM is one more than the bottommost y position occupied by WINDOW. +The pixel edges include the space used by WINDOW's scroll bar, display +margins, fringes, header line, and/or mode line. For the pixel edges +of just the text area, use `window-inside-absolute-pixel-edges'. */) + (Lisp_Object window) +{ + register struct window *w = decode_any_window (window); + int add_x, add_y; + calc_absolute_offset (w, &add_x, &add_y); + + return Fcons (make_number (WINDOW_LEFT_EDGE_X (w) + add_x), + Fcons (make_number (WINDOW_TOP_EDGE_Y (w) + add_y), + Fcons (make_number (WINDOW_RIGHT_EDGE_X (w) + add_x), + Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w) + add_y), + Qnil)))); +} + DEFUN ("window-inside-edges", Fwindow_inside_edges, Swindow_inside_edges, 0, 1, 0, doc: /* Return a list of the edge coordinates of WINDOW. The list has the form (LEFT TOP RIGHT BOTTOM). @@ -665,8 +685,7 @@ RIGHT is one more than the rightmost column of WINDOW's text area. BOTTOM is one more than the bottommost row of WINDOW's text area. The inside edges do not include the space used by the WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. */) - (window) - Lisp_Object window; + (Lisp_Object window) { register struct window *w = decode_any_window (window); @@ -691,8 +710,7 @@ RIGHT is one more than the rightmost x position of WINDOW's text area. BOTTOM is one more than the bottommost y position of WINDOW's text area. The inside edges do not include the space used by WINDOW's scroll bar, display margins, fringes, header line, and/or mode line. */) - (window) - Lisp_Object window; + (Lisp_Object window) { register struct window *w = decode_any_window (window); @@ -708,6 +726,35 @@ display margins, fringes, header line, and/or mode line. */) - WINDOW_MODE_LINE_HEIGHT (w))); } +DEFUN ("window-inside-absolute-pixel-edges", + Fwindow_inside_absolute_pixel_edges, + Swindow_inside_absolute_pixel_edges, 0, 1, 0, + doc: /* Return a list of the edge pixel coordinates of WINDOW. +The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at +the top left corner of the display. + +RIGHT is one more than the rightmost x position of WINDOW's text area. +BOTTOM is one more than the bottommost y position of WINDOW's text area. +The inside edges do not include the space used by WINDOW's scroll bar, +display margins, fringes, header line, and/or mode line. */) + (Lisp_Object window) +{ + register struct window *w = decode_any_window (window); + int add_x, add_y; + calc_absolute_offset (w, &add_x, &add_y); + + return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) + + WINDOW_LEFT_MARGIN_WIDTH (w) + + WINDOW_LEFT_FRINGE_WIDTH (w) + add_x), + make_number (WINDOW_TOP_EDGE_Y (w) + + WINDOW_HEADER_LINE_HEIGHT (w) + add_y), + make_number (WINDOW_BOX_RIGHT_EDGE_X (w) + - WINDOW_RIGHT_MARGIN_WIDTH (w) + - WINDOW_RIGHT_FRINGE_WIDTH (w) + add_x), + make_number (WINDOW_BOTTOM_EDGE_Y (w) + - WINDOW_MODE_LINE_HEIGHT (w) + add_y)); +} + /* Test if the character at column *X, row *Y is within window W. If it is not, return ON_NOTHING; if it is in the window's text area, @@ -730,9 +777,7 @@ display margins, fringes, header line, and/or mode line. */) X and Y are frame relative pixel coordinates. */ static enum window_part -coordinates_in_window (w, x, y) - register struct window *w; - register int *x, *y; +coordinates_in_window (register struct window *w, register int *x, register int *y) { struct frame *f = XFRAME (WINDOW_FRAME (w)); int left_x, right_x, top_y, bottom_y; @@ -937,8 +982,7 @@ If they are on the border between WINDOW and its right sibling, `vertical-line' is returned. If they are in the windows's left or right marginal areas, `left-margin'\n\ or `right-margin' is returned. */) - (coordinates, window) - register Lisp_Object coordinates, window; + (register Lisp_Object coordinates, Lisp_Object window) { struct window *w; struct frame *f; @@ -1015,9 +1059,7 @@ struct check_window_data }; static int -check_window_containing (w, user_data) - struct window *w; - void *user_data; +check_window_containing (struct window *w, void *user_data) { struct check_window_data *cw = (struct check_window_data *) user_data; enum window_part found; @@ -1055,12 +1097,7 @@ check_window_containing (w, user_data) case. */ Lisp_Object -window_from_coordinates (f, x, y, part, wx, wy, tool_bar_p) - struct frame *f; - int x, y; - enum window_part *part; - int *wx, *wy; - int tool_bar_p; +window_from_coordinates (struct frame *f, int x, int y, enum window_part *part, int *wx, int *wy, int tool_bar_p) { Lisp_Object window; struct check_window_data cw; @@ -1097,8 +1134,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, If omitted, FRAME defaults to the currently selected frame. The top left corner of the frame is considered to be row 0, column 0. */) - (x, y, frame) - Lisp_Object x, y, frame; + (Lisp_Object x, Lisp_Object y, Lisp_Object frame) { struct frame *f; @@ -1131,8 +1167,7 @@ is also currently selected, the value returned is the same as (point). It would be more strictly correct to return the `top-level' value of point, outside of any save-excursion forms. But that is hard to define. */) - (window) - Lisp_Object window; + (Lisp_Object window) { register struct window *w = decode_window (window); @@ -1146,8 +1181,7 @@ DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, doc: /* Return position at which display currently starts in WINDOW. WINDOW defaults to the selected window. This is updated by redisplay or by calling `set-window-start'. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return Fmarker_position (decode_window (window)->start); } @@ -1173,8 +1207,7 @@ Return nil if there is no recorded value. \(This can happen if the last redisplay of WINDOW was preempted, and did not finish.) If UPDATE is non-nil, compute the up-to-date position if it isn't already recorded. */) - (window, update) - Lisp_Object window, update; + (Lisp_Object window, Lisp_Object update) { Lisp_Object value; struct window *w = decode_window (window); @@ -1242,8 +1275,7 @@ if it isn't already recorded. */) DEFUN ("set-window-point", Fset_window_point, Sset_window_point, 2, 2, 0, doc: /* Make point value in WINDOW be at position POS in WINDOW's buffer. Return POS. */) - (window, pos) - Lisp_Object window, pos; + (Lisp_Object window, Lisp_Object pos) { register struct window *w = decode_window (window); @@ -1267,8 +1299,7 @@ DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, WINDOW defaults to the selected window. Return POS. Optional third arg NOFORCE non-nil inhibits next redisplay from overriding motion of point in order to display at this exact start. */) - (window, pos, noforce) - Lisp_Object window, pos, noforce; + (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) { register struct window *w = decode_window (window); @@ -1306,8 +1337,7 @@ from displaying another buffer in it. `get-lru-window' and Functions like `set-window-buffer' may change the buffer displayed by a window, unless that window is "strongly" dedicated to its buffer, that is the value returned by `window-dedicated-p' is t. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_window (window)->dedicated; } @@ -1331,8 +1361,7 @@ its buffer. Functions like `set-window-buffer' may change the buffer displayed by a window, unless that window is strongly dedicated to its buffer. If and when `set-window-buffer' displays another buffer in a window, it also makes sure that the window is not marked as dedicated. */) - (window, flag) - Lisp_Object window, flag; + (Lisp_Object window, Lisp_Object flag) { register struct window *w = decode_window (window); @@ -1346,8 +1375,7 @@ DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, doc: /* Return the parameters of WINDOW and their values. WINDOW defaults to the selected window. The return value is a list of elements of the form (PARAMETER . VALUE). */) - (window) - Lisp_Object window; + (Lisp_Object window) { return Fcopy_alist (decode_window (window)->window_parameters); } @@ -1356,8 +1384,7 @@ DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, 2, 2, 0, doc: /* Return WINDOW's value for PARAMETER. WINDOW defaults to the selected window. */) - (window, parameter) - Lisp_Object window, parameter; + (Lisp_Object window, Lisp_Object parameter) { Lisp_Object result; @@ -1369,8 +1396,7 @@ DEFUN ("set-window-parameter", Fset_window_parameter, Sset_window_parameter, 3, 3, 0, doc: /* Set WINDOW's value of PARAMETER to VALUE. WINDOW defaults to the selected window. Return VALUE. */) - (window, parameter, value) - Lisp_Object window, parameter, value; + (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) { register struct window *w = decode_window (window); Lisp_Object old_alist_elt; @@ -1388,8 +1414,7 @@ DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, 0, 1, 0, doc: /* Return the display-table that WINDOW is using. WINDOW defaults to the selected window. */) - (window) - Lisp_Object window; + (Lisp_Object window) { return decode_window (window)->display_table; } @@ -1400,8 +1425,7 @@ WINDOW defaults to the selected window. */) return 0. */ struct Lisp_Char_Table * -window_display_table (w) - struct window *w; +window_display_table (struct window *w) { struct Lisp_Char_Table *dp = NULL; @@ -1422,8 +1446,7 @@ window_display_table (w) DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_display_table, 2, 2, 0, doc: /* Set WINDOW's display-table to TABLE. */) - (window, table) - register Lisp_Object window, table; + (register Lisp_Object window, Lisp_Object table) { register struct window *w; @@ -1435,8 +1458,7 @@ DEFUN ("set-window-display-table", Fset_window_display_table, Sset_window_displa /* Record info on buffer window w is displaying when it is about to cease to display that buffer. */ static void -unshow_buffer (w) - register struct window *w; +unshow_buffer (register struct window *w) { Lisp_Object buf; struct buffer *b; @@ -1484,8 +1506,7 @@ unshow_buffer (w) /* Put replacement into the window structure in place of old. */ static void -replace_window (old, replacement) - Lisp_Object old, replacement; +replace_window (Lisp_Object old, Lisp_Object replacement) { register Lisp_Object tem; register struct window *o = XWINDOW (old), *p = XWINDOW (replacement); @@ -1502,9 +1523,9 @@ replace_window (old, replacement) p->total_lines = o->total_lines; p->desired_matrix = p->current_matrix = 0; p->vscroll = 0; - bzero (&p->cursor, sizeof (p->cursor)); - bzero (&p->last_cursor, sizeof (p->last_cursor)); - bzero (&p->phys_cursor, sizeof (p->phys_cursor)); + memset (&p->cursor, 0, sizeof (p->cursor)); + memset (&p->last_cursor, 0, sizeof (p->last_cursor)); + memset (&p->phys_cursor, 0, sizeof (p->phys_cursor)); p->phys_cursor_type = -1; p->phys_cursor_width = -1; p->must_be_updated_p = 0; @@ -1541,8 +1562,7 @@ DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "", doc: /* Remove WINDOW from its frame. WINDOW defaults to the selected window. Return nil. Signal an error when WINDOW is the only window on its frame. */) - (window) - register Lisp_Object window; + (register Lisp_Object window) { struct frame *f; if (NILP (window)) @@ -1559,8 +1579,7 @@ Signal an error when WINDOW is the only window on its frame. */) } void -delete_window (window) - register Lisp_Object window; +delete_window (register Lisp_Object window) { register Lisp_Object tem, parent, sib; register struct window *p; @@ -1774,9 +1793,7 @@ delete_window (window) function window_list. */ static int -add_window_to_list (w, user_data) - struct window *w; - void *user_data; +add_window_to_list (struct window *w, void *user_data) { Lisp_Object *list = (Lisp_Object *) user_data; Lisp_Object window; @@ -1791,7 +1808,7 @@ add_window_to_list (w, user_data) list, cache it in Vwindow_list, and return that. */ static Lisp_Object -window_list () +window_list (void) { if (!CONSP (Vwindow_list)) { @@ -1832,8 +1849,7 @@ window_list () a frame means consider windows on that frame, only. */ static int -candidate_window_p (window, owindow, minibuf, all_frames) - Lisp_Object window, owindow, minibuf, all_frames; +candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf, Lisp_Object all_frames) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); @@ -1898,8 +1914,7 @@ candidate_window_p (window, owindow, minibuf, all_frames) ALL_FRAMES. */ static void -decode_next_window_args (window, minibuf, all_frames) - Lisp_Object *window, *minibuf, *all_frames; +decode_next_window_args (Lisp_Object *window, Lisp_Object *minibuf, Lisp_Object *all_frames) { if (NILP (*window)) *window = selected_window; @@ -1945,9 +1960,7 @@ decode_next_window_args (window, minibuf, all_frames) ALL_FRAMES. */ static Lisp_Object -next_window (window, minibuf, all_frames, next_p) - Lisp_Object window, minibuf, all_frames; - int next_p; +next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, int next_p) { decode_next_window_args (&window, &minibuf, &all_frames); @@ -2046,8 +2059,7 @@ If you use consistent values for MINIBUF and ALL-FRAMES, you can use `next-window' to iterate through the entire cycle of acceptable windows, eventually ending up back at the window you started with. `previous-window' traverses the same cycle, in the reverse order. */) - (window, minibuf, all_frames) - Lisp_Object window, minibuf, all_frames; + (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) { return next_window (window, minibuf, all_frames, 1); } @@ -2064,8 +2076,7 @@ use `previous-window' to iterate through the entire cycle of acceptable windows, eventually ending up back at the window you started with. `next-window' traverses the same cycle, in the reverse order. */) - (window, minibuf, all_frames) - Lisp_Object window, minibuf, all_frames; + (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) { return next_window (window, minibuf, all_frames, 0); } @@ -2084,8 +2095,7 @@ This function uses `next-window' for finding the window to select. The argument ALL-FRAMES has the same meaning as in `next-window', but the MINIBUF argument of `next-window' is always effectively nil. */) - (count, all_frames) - Lisp_Object count, all_frames; + (Lisp_Object count, Lisp_Object all_frames) { Lisp_Object window; int i; @@ -2111,8 +2121,7 @@ MINIBUF t means include the minibuffer window, even if it isn't active. MINIBUF nil or omitted means include the minibuffer window only if it's active. MINIBUF neither nil nor t means never include the minibuffer window. */) - (frame, minibuf, window) - Lisp_Object frame, minibuf, window; + (Lisp_Object frame, Lisp_Object minibuf, Lisp_Object window) { if (NILP (window)) window = FRAMEP (frame) ? XFRAME (frame)->selected_window : selected_window; @@ -2131,8 +2140,7 @@ MINIBUF neither nil nor t means never include the minibuffer window. */) for `next-window'. */ static Lisp_Object -window_list_1 (window, minibuf, all_frames) - Lisp_Object window, minibuf, all_frames; +window_list_1 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) { Lisp_Object tail, list, rest; @@ -2180,10 +2188,7 @@ enum window_loop }; static Lisp_Object -window_loop (type, obj, mini, frames) - enum window_loop type; - Lisp_Object obj, frames; - int mini; +window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frames) { Lisp_Object window, windows, best_window, frame_arg; struct frame *f; @@ -2410,7 +2415,7 @@ window_loop (type, obj, mini, frames) /* Used for debugging. Abort if any window has a dead buffer. */ void -check_all_windows () +check_all_windows (void) { window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); } @@ -2428,8 +2433,7 @@ If FRAME is 0, search all visible and iconified frames. If FRAME is t, search all frames. If FRAME is nil, search only the selected frame. If FRAME is a frame, search only that frame. */) - (frame, dedicated) - Lisp_Object frame, dedicated; + (Lisp_Object frame, Lisp_Object dedicated) { register Lisp_Object w; /* First try for a window that is full-width */ @@ -2454,8 +2458,7 @@ If FRAME is 0, search all visible and iconified frames. If FRAME is t, search all frames. If FRAME is nil, search only the selected frame. If FRAME is a frame, search only that frame. */) - (frame, dedicated) - Lisp_Object frame, dedicated; + (Lisp_Object frame, Lisp_Object dedicated) { return window_loop (GET_LARGEST_WINDOW, dedicated, 0, frame); @@ -2470,8 +2473,7 @@ If optional argument FRAME is 0, search all visible and iconified frames. If FRAME is t, search all frames. If FRAME is nil, search only the selected frame. If FRAME is a frame, search only that frame. */) - (buffer_or_name, frame) - Lisp_Object buffer_or_name, frame; + (Lisp_Object buffer_or_name, Lisp_Object frame) { Lisp_Object buffer; @@ -2495,11 +2497,10 @@ previously visible in WINDOW in the same place on the frame. Doing this depends on the value of (window-start WINDOW), so if calling this function in a program gives strange scrolling, make sure the window-start value is reasonable when this function is called. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w; - int startpos; + EMACS_INT startpos; int top, new_top; if (NILP (window)) @@ -2563,8 +2564,7 @@ If FRAME is t, search only the selected frame. If FRAME is a frame, search only that frame. When a window showing BUFFER-OR-NAME is dedicated and the only window of its frame, that frame is deleted when there are other frames left. */) - (buffer_or_name, frame) - Lisp_Object buffer_or_name, frame; + (Lisp_Object buffer_or_name, Lisp_Object frame) { Lisp_Object buffer; @@ -2599,8 +2599,7 @@ When a window showing BUFFER-OR-NAME is dedicated that window is deleted. If that window is the only window on its frame, that frame is deleted too when there are other frames left. If there are no other frames left, some other buffer is displayed in that window. */) - (buffer_or_name) - Lisp_Object buffer_or_name; + (Lisp_Object buffer_or_name) { Lisp_Object buffer; @@ -2621,8 +2620,7 @@ frames left, some other buffer is displayed in that window. */) of all frames, even those on other keyboards. */ void -replace_buffer_in_all_windows (buffer) - Lisp_Object buffer; +replace_buffer_in_all_windows (Lisp_Object buffer) { Lisp_Object tail, frame; @@ -2651,9 +2649,7 @@ replace_buffer_in_all_windows (buffer) minimum allowable size. */ void -check_frame_size (frame, rows, cols) - FRAME_PTR frame; - int *rows, *cols; +check_frame_size (FRAME_PTR frame, int *rows, int *cols) { /* For height, we have to see: how many windows the frame has at minimum (one or two), @@ -2679,9 +2675,7 @@ check_frame_size (frame, rows, cols) either. */ static int -window_fixed_size_p (w, width_p, check_siblings_p) - struct window *w; - int width_p, check_siblings_p; +window_fixed_size_p (struct window *w, int width_p, int check_siblings_p) { int fixed_p; struct window *c; @@ -2781,9 +2775,7 @@ window_fixed_size_p (w, width_p, check_siblings_p) minibuffer window, always return 1. */ static int -window_min_size_2 (w, width_p, safe_p) - struct window *w; - int width_p, safe_p; +window_min_size_2 (struct window *w, int width_p, int safe_p) { /* We should consider buffer-local values of window_min_height and window_min_width here. */ @@ -2817,9 +2809,7 @@ window_min_size_2 (w, width_p, safe_p) sizes of W's children. */ static int -window_min_size_1 (w, width_p, safe_p) - struct window *w; - int width_p, safe_p; +window_min_size_1 (struct window *w, int width_p, int safe_p) { struct window *c; int size; @@ -2894,9 +2884,7 @@ window_min_size_1 (w, width_p, safe_p) to 1 if W is fixed-size unless FIXED is null. */ static int -window_min_size (w, width_p, safe_p, ignore_fixed_p, fixed) - struct window *w; - int width_p, safe_p, ignore_fixed_p, *fixed; +window_min_size (struct window *w, int width_p, int safe_p, int ignore_fixed_p, int *fixed) { int size, fixed_p; @@ -2922,8 +2910,7 @@ window_min_size (w, width_p, safe_p, ignore_fixed_p, fixed) is still too narrow. */ static int -adjust_window_margins (w) - struct window *w; +adjust_window_margins (struct window *w) { int box_cols = (WINDOW_TOTAL_COLS (w) - WINDOW_FRINGE_COLS (w) @@ -2977,11 +2964,8 @@ adjust_window_margins (w) a specific window, it will attempt to strictly resize that window proportionally, even at the expense of deleting smaller windows. */ static int * -shrink_windows (total, size, nchildren, shrinkable, resize_fixed_p, - forward, width_p, safe_p) - int total, size, nchildren, shrinkable; - int resize_fixed_p, width_p, safe_p; - Lisp_Object forward; +shrink_windows (int total, int size, int nchildren, int shrinkable, + int resize_fixed_p, Lisp_Object forward, int width_p, int safe_p) { int available_resize = 0; int *new_sizes, *min_sizes; @@ -3121,10 +3105,7 @@ shrink_windows (total, size, nchildren, shrinkable, resize_fixed_p, This should give better behavior when resizing frames. */ static void -size_window (window, size, width_p, nodelete_p, first_only, last_only) - Lisp_Object window; - int size, width_p, nodelete_p; - int first_only, last_only; +size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int first_only, int last_only) { struct window *w = XWINDOW (window); struct window *c; @@ -3315,10 +3296,7 @@ size_window (window, size, width_p, nodelete_p, first_only, last_only) displayed correctly. */ void -set_window_height (window, height, nodelete) - Lisp_Object window; - int height; - int nodelete; +set_window_height (Lisp_Object window, int height, int nodelete) { size_window (window, height, 0, nodelete, 0, 0); } @@ -3332,10 +3310,7 @@ set_window_height (window, height, nodelete) displayed correctly. */ void -set_window_width (window, width, nodelete) - Lisp_Object window; - int width; - int nodelete; +set_window_width (Lisp_Object window, int width, int nodelete) { size_window (window, width, 1, nodelete, 0, 0); } @@ -3343,9 +3318,7 @@ set_window_width (window, width, nodelete) /* Change window heights in windows rooted in WINDOW by N lines. */ void -change_window_heights (window, n) - Lisp_Object window; - int n; +change_window_heights (Lisp_Object window, int n) { struct window *w = XWINDOW (window); @@ -3441,9 +3414,7 @@ run_window_configuration_change_hook (struct frame *f) reset from the buffer's local settings. */ void -set_window_buffer (window, buffer, run_hooks_p, keep_margins_p) - Lisp_Object window, buffer; - int run_hooks_p, keep_margins_p; +set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int keep_margins_p) { struct window *w = XWINDOW (window); struct buffer *b = XBUFFER (buffer); @@ -3465,7 +3436,7 @@ set_window_buffer (window, buffer, run_hooks_p, keep_margins_p) XSETFASTINT (w->window_end_pos, 0); XSETFASTINT (w->window_end_vpos, 0); - bzero (&w->last_cursor, sizeof w->last_cursor); + memset (&w->last_cursor, 0, sizeof w->last_cursor); w->window_end_valid = Qnil; if (!(keep_margins_p && samebuf)) { /* If we're not actually changing the buffer, don't reset hscroll and @@ -3554,8 +3525,7 @@ already display BUFFER-OR-NAME. This function runs `window-scroll-functions' before running `window-configuration-change-hook'. */) - (window, buffer_or_name, keep_margins) - register Lisp_Object window, buffer_or_name, keep_margins; + (register Lisp_Object window, Lisp_Object buffer_or_name, Lisp_Object keep_margins) { register Lisp_Object tem, buffer; register struct window *w = decode_window (window); @@ -3598,8 +3568,7 @@ make this window the most recently selected one. Note that the main editor command loop selects the buffer of the selected window before each command. */) - (window, norecord) - register Lisp_Object window, norecord; + (register Lisp_Object window, Lisp_Object norecord) { register struct window *w; register struct window *ow; @@ -3614,6 +3583,7 @@ selected window before each command. */) { ++window_select_count; XSETFASTINT (w->use_time, window_select_count); + record_buffer (w->buffer); } if (EQ (window, selected_window)) @@ -3649,8 +3619,6 @@ selected window before each command. */) selected_window = window; - if (NILP (norecord)) - record_buffer (w->buffer); Fset_buffer (w->buffer); XBUFFER (w->buffer)->last_selected_window = window; @@ -3661,7 +3629,7 @@ selected window before each command. */) redisplay_window has altered point after scrolling, because it makes the change only in the window. */ { - register int new_point = marker_position (w->pointm); + register EMACS_INT new_point = marker_position (w->pointm); if (new_point < BEGV) SET_PT (BEGV); else if (new_point > ZV) @@ -3675,24 +3643,21 @@ selected window before each command. */) } static Lisp_Object -select_window_norecord (window) - Lisp_Object window; +select_window_norecord (Lisp_Object window) { return WINDOW_LIVE_P (window) ? Fselect_window (window, Qt) : selected_window; } static Lisp_Object -select_frame_norecord (frame) - Lisp_Object frame; +select_frame_norecord (Lisp_Object frame) { return FRAME_LIVE_P (XFRAME (frame)) ? Fselect_frame (frame, Qt) : selected_frame; } Lisp_Object -display_buffer (buffer, not_this_window_p, override_frame) - Lisp_Object buffer, not_this_window_p, override_frame; +display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p, Lisp_Object override_frame) { return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame); } @@ -3703,8 +3668,7 @@ DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update, If optional arg OBJECT is a window, force redisplay of that window only. If OBJECT is a buffer or buffer name, force redisplay of all windows displaying that buffer. */) - (object) - Lisp_Object object; + (Lisp_Object object) { if (NILP (object)) { @@ -3743,8 +3707,7 @@ displaying that buffer. */) void -temp_output_buffer_show (buf) - register Lisp_Object buf; +temp_output_buffer_show (register Lisp_Object buf) { register struct buffer *old = current_buffer; register Lisp_Object window; @@ -3804,8 +3767,7 @@ temp_output_buffer_show (buf) } static void -make_dummy_parent (window) - Lisp_Object window; +make_dummy_parent (Lisp_Object window) { Lisp_Object new; register struct window *o, *p; @@ -3847,8 +3809,7 @@ The upper or leftmost window is the original one, and remains selected if it was selected before. See Info node `(elisp)Splitting Windows' for more details and examples. */) - (window, size, horizontal) - Lisp_Object window, size, horizontal; + (Lisp_Object window, Lisp_Object size, Lisp_Object horizontal) { register Lisp_Object new; register struct window *o, *p; @@ -3938,7 +3899,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples. */) p->parent = o->parent; p->buffer = Qt; p->window_end_valid = Qnil; - bzero (&p->last_cursor, sizeof p->last_cursor); + memset (&p->last_cursor, 0, sizeof p->last_cursor); /* Duplicate special geometry settings. */ @@ -3987,8 +3948,7 @@ window wider by SIZE columns. If SIZE is negative, shrink the window by This function can delete windows if they get too small. The size of fixed size windows is not altered by this function. */) - (size, horizontal) - Lisp_Object size, horizontal; + (Lisp_Object size, Lisp_Object horizontal) { CHECK_NUMBER (size); enlarge_window (selected_window, XINT (size), !NILP (horizontal)); @@ -4007,8 +3967,7 @@ window by -SIZE lines or columns. Return nil. This function can delete windows if they get too small. The size of fixed size windows is not altered by this function. */) - (size, horizontal) - Lisp_Object size, horizontal; + (Lisp_Object size, Lisp_Object horizontal) { CHECK_NUMBER (size); enlarge_window (selected_window, -XINT (size), !NILP (horizontal)); @@ -4019,16 +3978,14 @@ fixed size windows is not altered by this function. */) } int -window_height (window) - Lisp_Object window; +window_height (Lisp_Object window) { register struct window *p = XWINDOW (window); return WINDOW_TOTAL_LINES (p); } int -window_width (window) - Lisp_Object window; +window_width (Lisp_Object window) { register struct window *p = XWINDOW (window); return WINDOW_TOTAL_COLS (p); @@ -4050,17 +4007,15 @@ window_width (window) deleted. */ static void -enlarge_window (window, delta, horiz_flag) - Lisp_Object window; - int delta, horiz_flag; +enlarge_window (Lisp_Object window, int delta, int horiz_flag) { Lisp_Object parent, next, prev; struct window *p; Lisp_Object *sizep; int maximum; - int (*sizefun) P_ ((Lisp_Object)) + int (*sizefun) (Lisp_Object) = horiz_flag ? window_width : window_height; - void (*setsizefun) P_ ((Lisp_Object, int, int)) + void (*setsizefun) (Lisp_Object, int, int) = (horiz_flag ? set_window_width : set_window_height); /* Give up if this window cannot be resized. */ @@ -4328,9 +4283,7 @@ enlarge_window (window, delta, horiz_flag) are not deleted; instead, we signal an error. */ static void -adjust_window_trailing_edge (window, delta, horiz_flag) - Lisp_Object window; - int delta, horiz_flag; +adjust_window_trailing_edge (Lisp_Object window, int delta, int horiz_flag) { Lisp_Object parent, child; struct window *p; @@ -4466,8 +4419,7 @@ Otherwise, adjust the height, moving the bottom edge. Following siblings of the selected window are resized to fulfill the size request. If they become too small in the process, they are not deleted; instead, we signal an error. */) - (window, delta, horizontal) - Lisp_Object window, delta, horizontal; + (Lisp_Object window, Lisp_Object delta, Lisp_Object horizontal) { CHECK_NUMBER (delta); if (NILP (window)) @@ -4486,7 +4438,7 @@ are not deleted; instead, we signal an error. */) Resizing Mini-Windows ***********************************************************************/ -static void shrink_window_lowest_first P_ ((struct window *, int)); +static void shrink_window_lowest_first (struct window *, int); enum save_restore_action { @@ -4495,16 +4447,14 @@ enum save_restore_action RESTORE_ORIG_SIZES }; -static int save_restore_orig_size P_ ((struct window *, - enum save_restore_action)); +static int save_restore_orig_size (struct window *, + enum save_restore_action); /* Shrink windows rooted in window W to HEIGHT. Take the space needed from lowest windows first. */ static void -shrink_window_lowest_first (w, height) - struct window *w; - int height; +shrink_window_lowest_first (struct window *w, int height) { struct window *c; Lisp_Object child; @@ -4586,9 +4536,7 @@ shrink_window_lowest_first (w, height) stored in orig_top_line and orig_total_lines for all windows. */ static int -save_restore_orig_size (w, action) - struct window *w; - enum save_restore_action action; +save_restore_orig_size (struct window *w, enum save_restore_action action) { int success_p = 1; @@ -4643,9 +4591,7 @@ save_restore_orig_size (w, action) without deleting other windows. */ void -grow_mini_window (w, delta) - struct window *w; - int delta; +grow_mini_window (struct window *w, int delta) { struct frame *f = XFRAME (w->frame); struct window *root; @@ -4694,8 +4640,7 @@ grow_mini_window (w, delta) line. */ void -shrink_mini_window (w) - struct window *w; +shrink_mini_window (struct window *w) { struct frame *f = XFRAME (w->frame); struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); @@ -4725,8 +4670,7 @@ shrink_mini_window (w) the frame are cleared. */ void -mark_window_cursors_off (w) - struct window *w; +mark_window_cursors_off (struct window *w) { while (w) { @@ -4745,8 +4689,7 @@ mark_window_cursors_off (w) /* Return number of lines of text (not counting mode lines) in W. */ int -window_internal_height (w) - struct window *w; +window_internal_height (struct window *w) { int ht = XFASTINT (w->total_lines); @@ -4773,8 +4716,7 @@ window_internal_height (w) separating W from the sibling to its right. */ int -window_box_text_cols (w) - struct window *w; +window_box_text_cols (struct window *w) { struct frame *f = XFRAME (WINDOW_FRAME (w)); int width = XINT (w->total_cols); @@ -4811,11 +4753,7 @@ window_box_text_cols (w) respectively. */ static void -window_scroll (window, n, whole, noerror) - Lisp_Object window; - int n; - int whole; - int noerror; +window_scroll (Lisp_Object window, int n, int whole, int noerror) { immediate_quit = 1; @@ -4835,11 +4773,7 @@ window_scroll (window, n, whole, noerror) descriptions. */ static void -window_scroll_pixel_based (window, n, whole, noerror) - Lisp_Object window; - int n; - int whole; - int noerror; +window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) { struct it it; struct window *w = XWINDOW (window); @@ -4914,7 +4848,7 @@ window_scroll_pixel_based (window, n, whole, noerror) /* Maybe modify window start instead of scrolling. */ if (rbot > 0 || w->vscroll < 0) { - int spos; + EMACS_INT spos; Fset_window_vscroll (window, make_number (0), Qt); /* If there are other text lines above the current row, @@ -4945,12 +4879,13 @@ window_scroll_pixel_based (window, n, whole, noerror) if (!NILP (Vscroll_preserve_screen_position)) { /* We preserve the goal pixel coordinate across consecutive - calls to scroll-up or scroll-down. This avoids the + calls to scroll-up, scroll-down and other commands that + have the `scroll-command' property. This avoids the possibility of point becoming "stuck" on a tall line when scrolling by one line. */ if (window_scroll_pixel_based_preserve_y < 0 - || (!EQ (current_kboard->Vlast_command, Qscroll_up) - && !EQ (current_kboard->Vlast_command, Qscroll_down))) + || !SYMBOLP (current_kboard->Vlast_command) + || NILP (Fget (current_kboard->Vlast_command, Qscroll_command))) { start_display (&it, w, start); move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); @@ -4967,7 +4902,7 @@ window_scroll_pixel_based (window, n, whole, noerror) start_display (&it, w, start); if (whole) { - int start_pos = IT_CHARPOS (it); + EMACS_INT start_pos = IT_CHARPOS (it); int dy = WINDOW_FRAME_LINE_HEIGHT (w); dy = max ((window_box_height (w) - next_screen_context_lines * dy), @@ -5046,8 +4981,8 @@ window_scroll_pixel_based (window, n, whole, noerror) if (! vscrolled) { - int pos = IT_CHARPOS (it); - int bytepos; + EMACS_INT pos = IT_CHARPOS (it); + EMACS_INT bytepos; /* If in the middle of a multi-glyph character move forward to the next character. */ @@ -5117,7 +5052,7 @@ window_scroll_pixel_based (window, n, whole, noerror) } else if (n < 0) { - int charpos, bytepos; + EMACS_INT charpos, bytepos; int partial_p; /* Save our position, for the @@ -5184,20 +5119,16 @@ window_scroll_pixel_based (window, n, whole, noerror) See the comment of window_scroll for parameter descriptions. */ static void -window_scroll_line_based (window, n, whole, noerror) - Lisp_Object window; - int n; - int whole; - int noerror; +window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) { register struct window *w = XWINDOW (window); - register int opoint = PT, opoint_byte = PT_BYTE; - register int pos, pos_byte; + register EMACS_INT opoint = PT, opoint_byte = PT_BYTE; + register EMACS_INT pos, pos_byte; register int ht = window_internal_height (w); register Lisp_Object tem; int lose; Lisp_Object bolp; - int startpos; + EMACS_INT startpos; Lisp_Object original_pos = Qnil; /* If scrolling screen-fulls, compute the number of lines to @@ -5210,8 +5141,8 @@ window_scroll_line_based (window, n, whole, noerror) if (!NILP (Vscroll_preserve_screen_position)) { if (window_scroll_preserve_vpos <= 0 - || (!EQ (current_kboard->Vlast_command, Qscroll_up) - && !EQ (current_kboard->Vlast_command, Qscroll_down))) + || !SYMBOLP (current_kboard->Vlast_command) + || NILP (Fget (current_kboard->Vlast_command, Qscroll_command))) { struct position posit = *compute_motion (startpos, 0, 0, 0, @@ -5346,9 +5277,7 @@ window_scroll_line_based (window, n, whole, noerror) up. This is the guts of Fscroll_up and Fscroll_down. */ static void -scroll_command (n, direction) - Lisp_Object n; - int direction; +scroll_command (Lisp_Object n, int direction) { int count = SPECPDL_INDEX (); @@ -5385,8 +5314,7 @@ A near full screen is `next-screen-context-lines' less than a full screen. Negative ARG means scroll downward. If ARG is the atom `-', scroll downward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { scroll_command (arg, 1); return Qnil; @@ -5399,8 +5327,7 @@ A near full screen is `next-screen-context-lines' less than a full screen. Negative ARG means scroll upward. If ARG is the atom `-', scroll upward by nearly full screen. When calling from a program, supply as argument a number, nil, or `-'. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { scroll_command (arg, -1); return Qnil; @@ -5413,7 +5340,7 @@ showing that buffer is used. If in the minibuffer, `minibuffer-scroll-window' if non-nil specifies the window. This takes precedence over `other-window-scroll-buffer'. */) - () + (void) { Lisp_Object window; @@ -5463,8 +5390,7 @@ showing that buffer, popping the buffer up if necessary. If in the minibuffer, `minibuffer-scroll-window' if non-nil specifies the window to scroll. This takes precedence over `other-window-scroll-buffer'. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { Lisp_Object window; struct window *w; @@ -5507,8 +5433,7 @@ If SET-MINIMUM is non-nil, the new scroll amount becomes the lower bound for automatic scrolling, i.e. automatic scrolling will not scroll a window to a column less than the value returned by this function. This happens in an interactive call. */) - (arg, set_minimum) - register Lisp_Object arg, set_minimum; + (register Lisp_Object arg, Lisp_Object set_minimum) { Lisp_Object result; int hscroll; @@ -5537,8 +5462,7 @@ If SET-MINIMUM is non-nil, the new scroll amount becomes the lower bound for automatic scrolling, i.e. automatic scrolling will not scroll a window to a column less than the value returned by this function. This happens in an interactive call. */) - (arg, set_minimum) - register Lisp_Object arg, set_minimum; + (register Lisp_Object arg, Lisp_Object set_minimum) { Lisp_Object result; int hscroll; @@ -5561,7 +5485,7 @@ by this function. This happens in an interactive call. */) DEFUN ("minibuffer-selected-window", Fminibuffer_selected_window, Sminibuffer_selected_window, 0, 0, 0, doc: /* Return the window which was selected when entering the minibuffer. Returns nil, if selected window is not a minibuffer window. */) - () + (void) { if (minibuf_level > 0 && MINI_WINDOW_P (XWINDOW (selected_window)) @@ -5575,8 +5499,7 @@ Returns nil, if selected window is not a minibuffer window. */) as opposed to its height. */ static int -displayed_window_lines (w) - struct window *w; +displayed_window_lines (struct window *w) { struct it it; struct text_pos start; @@ -5644,14 +5567,13 @@ then only tty frame are redrawn. Just C-u as prefix means put point in the center of the window and redisplay normally--don't erase and redraw the frame. */) - (arg) - register Lisp_Object arg; + (register Lisp_Object arg) { struct window *w = XWINDOW (selected_window); struct buffer *buf = XBUFFER (w->buffer); struct buffer *obuf = current_buffer; int center_p = 0; - int charpos, bytepos; + EMACS_INT charpos, bytepos; int iarg; int this_scroll_margin; @@ -5829,8 +5751,7 @@ WINDOW defaults to the selected window. The return value does not include the mode line, any header line, nor any partial-height lines in the text display area. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w = decode_window (window); int pixel_height = window_box_height (w); @@ -5846,8 +5767,7 @@ DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, With no argument, position point at center of window. An argument specifies vertical position within the window; zero means top of window, negative means relative to bottom of window. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { struct window *w = XWINDOW (selected_window); int lines, start; @@ -5960,16 +5880,14 @@ struct saved_window DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0, doc: /* Return t if OBJECT is a window-configuration object. */) - (object) - Lisp_Object object; + (Lisp_Object object) { return WINDOW_CONFIGURATIONP (object) ? Qt : Qnil; } DEFUN ("window-configuration-frame", Fwindow_configuration_frame, Swindow_configuration_frame, 1, 1, 0, doc: /* Return the frame that CONFIG, a window-configuration object, is about. */) - (config) - Lisp_Object config; + (Lisp_Object config) { register struct save_window_data *data; struct Lisp_Vector *saved_windows; @@ -5989,15 +5907,14 @@ by `current-window-configuration' (which see). If CONFIGURATION was made from a frame that is now deleted, only frame-independent values can be restored. In this case, the return value is nil. Otherwise the value is t. */) - (configuration) - Lisp_Object configuration; + (Lisp_Object configuration) { register struct save_window_data *data; struct Lisp_Vector *saved_windows; Lisp_Object new_current_buffer; Lisp_Object frame; FRAME_PTR f; - int old_point = -1; + EMACS_INT old_point = -1; CHECK_WINDOW_CONFIGURATION (configuration); @@ -6321,8 +6238,7 @@ the return value is nil. Otherwise the value is t. */) by setting their buffers to nil. */ void -delete_all_subwindows (w) - register struct window *w; +delete_all_subwindows (register struct window *w) { if (!NILP (w->next)) delete_all_subwindows (XWINDOW (w->next)); @@ -6348,8 +6264,7 @@ delete_all_subwindows (w) } static int -count_windows (window) - register struct window *window; +count_windows (register struct window *window) { register int count = 1; if (!NILP (window->next)) @@ -6366,10 +6281,7 @@ count_windows (window) Value is last index + 1. */ static int -get_leaf_windows (w, flat, i) - struct window *w; - struct window **flat; - int i; +get_leaf_windows (struct window *w, struct window **flat, int i) { while (w) { @@ -6392,8 +6304,7 @@ get_leaf_windows (w, flat, i) can be returned. */ struct glyph * -get_phys_cursor_glyph (w) - struct window *w; +get_phys_cursor_glyph (struct window *w) { struct glyph_row *row; struct glyph *glyph; @@ -6412,10 +6323,7 @@ get_phys_cursor_glyph (w) static int -save_window_save (window, vector, i) - Lisp_Object window; - struct Lisp_Vector *vector; - int i; +save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) { register struct saved_window *p; register struct window *w; @@ -6505,8 +6413,7 @@ point and mark. An exception is made for point in the current buffer: its value is -not- saved. This also records the currently selected frame, and FRAME's focus redirection (see `redirect-frame-focus'). */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { register Lisp_Object tem; register int n_windows; @@ -6554,8 +6461,7 @@ Also restore the choice of selected window. Also restore which buffer is current. Does not restore the value of point in current buffer. usage: (save-window-excursion BODY...) */) - (args) - Lisp_Object args; + (Lisp_Object args) { register Lisp_Object val; register int count = SPECPDL_INDEX (); @@ -6573,8 +6479,7 @@ usage: (save-window-excursion BODY...) */) ***********************************************************************/ static Lisp_Object -window_tree (w) - struct window *w; +window_tree (struct window *w) { Lisp_Object tail = Qnil; Lisp_Object result = Qnil; @@ -6627,8 +6532,7 @@ EDGES is a list \(LEFT TOP RIGHT BOTTOM) as returned by `window-edges'. If FRAME is nil or omitted, return information on the currently selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { FRAME_PTR f; @@ -6657,8 +6561,7 @@ Second arg LEFT-WIDTH specifies the number of character cells to reserve for the left marginal area. Optional third arg RIGHT-WIDTH does the same for the right marginal area. A nil width parameter means no margin. */) - (window, left_width, right_width) - Lisp_Object window, left_width, right_width; + (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) { struct window *w = decode_window (window); @@ -6702,8 +6605,7 @@ If WINDOW is omitted or nil, use the currently selected window. Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). If a marginal area does not exist, its width will be returned as nil. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w = decode_window (window); return Fcons (w->left_margin_cols, w->right_margin_cols); @@ -6728,8 +6630,7 @@ the command `set-fringe-style'. If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes outside of the display margins. By default, fringes are drawn between display marginal areas and the text area. */) - (window, left_width, right_width, outside_margins) - Lisp_Object window, left_width, right_width, outside_margins; + (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins) { struct window *w = decode_window (window); @@ -6766,8 +6667,7 @@ DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, doc: /* Get width of fringes of window WINDOW. If WINDOW is omitted or nil, use the currently selected window. Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w = decode_window (window); @@ -6794,8 +6694,7 @@ bar: left, right, or nil. If WIDTH is nil, use the frame's scroll-bar width. If VERTICAL-TYPE is t, use the frame's scroll-bar type. Fourth parameter HORIZONTAL-TYPE is currently unused. */) - (window, width, vertical_type, horizontal_type) - Lisp_Object window, width, vertical_type, horizontal_type; + (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) { struct window *w = decode_window (window); @@ -6839,8 +6738,7 @@ If WINDOW is omitted or nil, use the currently selected window. Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). If WIDTH is nil or TYPE is t, the window is using the frame's corresponding value. */) - (window) - Lisp_Object window; + (Lisp_Object window) { struct window *w = decode_window (window); return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) @@ -6862,8 +6760,7 @@ DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0, Use the selected window if WINDOW is nil or omitted. Normally, value is a multiple of the canonical character height of WINDOW; optional second arg PIXELS-P means value is measured in pixels. */) - (window, pixels_p) - Lisp_Object window, pixels_p; + (Lisp_Object window, Lisp_Object pixels_p) { Lisp_Object result; struct frame *f; @@ -6896,8 +6793,7 @@ If PIXELS-P is nil, VSCROLL may have to be rounded so that it corresponds to an integral number of pixels. The return value is the result of this rounding. If PIXELS-P is non-nil, the return value is VSCROLL. */) - (window, vscroll, pixels_p) - Lisp_Object window, vscroll, pixels_p; + (Lisp_Object window, Lisp_Object vscroll, Lisp_Object pixels_p) { struct window *w; struct frame *f; @@ -6941,10 +6837,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */) additional argument USER_DATA. Stops when FN returns 0. */ void -foreach_window (f, fn, user_data) - struct frame *f; - int (* fn) P_ ((struct window *, void *)); - void *user_data; +foreach_window (struct frame *f, int (*fn) (struct window *, void *), void *user_data) { /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ if (WINDOWP (FRAME_ROOT_WINDOW (f))) @@ -6958,10 +6851,7 @@ foreach_window (f, fn, user_data) Stop when FN returns 0. Value is 0 if stopped by FN. */ static int -foreach_window_1 (w, fn, user_data) - struct window *w; - int (* fn) P_ ((struct window *, void *)); - void *user_data; +foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *user_data) { int cont; @@ -6986,9 +6876,7 @@ foreach_window_1 (w, fn, user_data) the window start. */ static int -freeze_window_start (w, freeze_p) - struct window *w; - void *freeze_p; +freeze_window_start (struct window *w, void *freeze_p) { if (MINI_WINDOW_P (w) || (WINDOWP (selected_window) /* Can be nil in corner cases. */ @@ -7008,9 +6896,7 @@ freeze_window_start (w, freeze_p) means freeze the window start. */ void -freeze_window_starts (f, freeze_p) - struct frame *f; - int freeze_p; +freeze_window_starts (struct frame *f, int freeze_p) { foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); } @@ -7024,9 +6910,7 @@ freeze_window_starts (f, freeze_p) describe the same state of affairs. This is used by Fequal. */ int -compare_window_configurations (c1, c2, ignore_positions) - Lisp_Object c1, c2; - int ignore_positions; +compare_window_configurations (Lisp_Object c1, Lisp_Object c2, int ignore_positions) { register struct save_window_data *d1, *d2; struct Lisp_Vector *sw1, *sw2; @@ -7143,8 +7027,7 @@ DEFUN ("compare-window-configurations", Fcompare_window_configurations, doc: /* Compare two window configurations as regards the structure of windows. This function ignores details such as the values of point and mark and scrolling positions. */) - (x, y) - Lisp_Object x, y; + (Lisp_Object x, Lisp_Object y) { if (compare_window_configurations (x, y, 1)) return Qt; @@ -7152,7 +7035,7 @@ and scrolling positions. */) } void -init_window_once () +init_window_once (void) { struct frame *f = make_initial_frame (); XSETFRAME (selected_frame, f); @@ -7165,13 +7048,13 @@ init_window_once () } void -init_window () +init_window (void) { Vwindow_list = Qnil; } void -syms_of_window () +syms_of_window (void) { Qscroll_up = intern_c_string ("scroll-up"); staticpro (&Qscroll_up); @@ -7179,6 +7062,12 @@ syms_of_window () Qscroll_down = intern_c_string ("scroll-down"); staticpro (&Qscroll_down); + Qscroll_command = intern_c_string ("scroll-command"); + staticpro (&Qscroll_command); + + Fput (Qscroll_up, Qscroll_command, Qt); + Fput (Qscroll_down, Qscroll_command, Qt); + Qwindow_size_fixed = intern_c_string ("window-size-fixed"); staticpro (&Qwindow_size_fixed); Fset (Qwindow_size_fixed, Qnil); @@ -7268,7 +7157,9 @@ at the scroll margin or window boundary respectively. A value of t means point keeps its screen position if the scroll command moved it vertically out of the window, e.g. when scrolling by full screens. -Any other value means point always keeps its screen position. */); +Any other value means point always keeps its screen position. +Scroll commands should have the `scroll-command' property +on their symbols to be controlled by this variable. */); Vscroll_preserve_screen_position = Qnil; DEFVAR_LISP ("window-point-insertion-type", &Vwindow_point_insertion_type, @@ -7285,7 +7176,7 @@ with the relevant frame selected. */); DEFVAR_LISP ("recenter-redisplay", &Vrecenter_redisplay, doc: /* If non-nil, then the `recenter' command with a nil argument -the entire frame to be redrawn; the special value `tty' causes the +will redraw the entire frame; the special value `tty' causes the frame to be redrawn only if it is a tty frame. */); Vrecenter_redisplay = Qtty; @@ -7307,8 +7198,10 @@ frame to be redrawn only if it is a tty frame. */); defsubr (&Sset_window_redisplay_end_trigger); defsubr (&Swindow_edges); defsubr (&Swindow_pixel_edges); + defsubr (&Swindow_absolute_pixel_edges); defsubr (&Swindow_inside_edges); defsubr (&Swindow_inside_pixel_edges); + defsubr (&Swindow_inside_absolute_pixel_edges); defsubr (&Scoordinates_in_window_p); defsubr (&Swindow_at); defsubr (&Swindow_point); @@ -7370,7 +7263,7 @@ frame to be redrawn only if it is a tty frame. */); } void -keys_of_window () +keys_of_window (void) { initial_define_key (control_x_map, '1', "delete-other-windows"); initial_define_key (control_x_map, '2', "split-window"); @@ -7380,12 +7273,9 @@ keys_of_window () initial_define_key (control_x_map, '<', "scroll-left"); initial_define_key (control_x_map, '>', "scroll-right"); - initial_define_key (global_map, Ctl ('V'), "scroll-up"); + initial_define_key (global_map, Ctl ('V'), "scroll-up-command"); initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); - initial_define_key (meta_map, 'v', "scroll-down"); - - initial_define_key (global_map, Ctl('L'), "recenter"); - initial_define_key (meta_map, 'r', "move-to-window-line"); + initial_define_key (meta_map, 'v', "scroll-down-command"); } /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f diff --git a/src/window.h b/src/window.h index 05c1eb18c89..e9529487b14 100644 --- a/src/window.h +++ b/src/window.h @@ -117,7 +117,10 @@ struct window /* The buffer displayed in this window */ /* Of the fields vchild, hchild and buffer, only one is non-nil. */ Lisp_Object buffer; - /* A marker pointing to where in the text to start displaying */ + /* A marker pointing to where in the text to start displaying. + BIDI Note: This is the _logical-order_ start, i.e. the smallest + buffer position visible in the window, not necessarily the + character displayed in the top left corner of the window. */ Lisp_Object start; /* A marker pointing to where in the text point is in this window, used only when the window is not selected. @@ -782,25 +785,25 @@ EXFUN (Fwindow_vscroll, 2); EXFUN (Fset_window_margins, 3); EXFUN (Fwindow_live_p, 1); EXFUN (Fset_window_point, 2); -extern Lisp_Object make_window P_ ((void)); -extern void delete_window P_ ((Lisp_Object)); -extern Lisp_Object window_from_coordinates P_ ((struct frame *, int, int, - enum window_part *, - int *, int*, int)); +extern Lisp_Object make_window (void); +extern void delete_window (Lisp_Object); +extern Lisp_Object window_from_coordinates (struct frame *, int, int, + enum window_part *, + int *, int*, int); EXFUN (Fwindow_dedicated_p, 1); -extern int window_height P_ ((Lisp_Object)); -extern int window_width P_ ((Lisp_Object)); +extern int window_height (Lisp_Object); +extern int window_width (Lisp_Object); EXFUN (Fwindow_full_width_p, 1); -extern void set_window_height P_ ((Lisp_Object, int, int)); -extern void set_window_width P_ ((Lisp_Object, int, int)); -extern void change_window_heights P_ ((Lisp_Object, int)); -extern void delete_all_subwindows P_ ((struct window *)); -extern void freeze_window_starts P_ ((struct frame *, int)); -extern void foreach_window P_ ((struct frame *, - int (* fn) (struct window *, void *), - void *)); -extern void grow_mini_window P_ ((struct window *, int)); -extern void shrink_mini_window P_ ((struct window *)); +extern void set_window_height (Lisp_Object, int, int); +extern void set_window_width (Lisp_Object, int, int); +extern void change_window_heights (Lisp_Object, int); +extern void delete_all_subwindows (struct window *); +extern void freeze_window_starts (struct frame *, int); +extern void foreach_window (struct frame *, + int (* fn) (struct window *, void *), + void *); +extern void grow_mini_window (struct window *, int); +extern void shrink_mini_window (struct window *); void run_window_configuration_change_hook (struct frame *f); @@ -808,8 +811,8 @@ void run_window_configuration_change_hook (struct frame *f); means it's allowed to run hooks. See make_frame for a case where it's not allowed. */ -void set_window_buffer P_ ((Lisp_Object window, Lisp_Object buffer, - int run_hooks_p, int keep_margins_p)); +void set_window_buffer (Lisp_Object window, Lisp_Object buffer, + int run_hooks_p, int keep_margins_p); /* Prompt to display in front of the minibuffer contents. */ @@ -859,13 +862,13 @@ extern int buffer_shared; /* If *ROWS or *COLS are too small a size for FRAME, set them to the minimum allowable size. */ -extern void check_frame_size P_ ((struct frame *frame, int *rows, int *cols)); +extern void check_frame_size (struct frame *frame, int *rows, int *cols); /* Return a pointer to the glyph W's physical cursor is on. Value is null if W's current matrix is invalid, so that no meaningfull glyph can be returned. */ -struct glyph *get_phys_cursor_glyph P_ ((struct window *w)); +struct glyph *get_phys_cursor_glyph (struct window *w); /* Value is non-zero if WINDOW is a live window. */ @@ -888,24 +891,24 @@ EXFUN (Fsave_window_excursion, UNEVALLED); EXFUN (Fsplit_window, 3); EXFUN (Fset_window_configuration, 1); EXFUN (Fcurrent_window_configuration, 1); -extern int compare_window_configurations P_ ((Lisp_Object, Lisp_Object, int)); +extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); EXFUN (Fcoordinates_in_window_p, 2); EXFUN (Fwindow_at, 3); EXFUN (Fpos_visible_in_window_p, 3); -extern void mark_window_cursors_off P_ ((struct window *)); -extern int window_internal_height P_ ((struct window *)); -extern int window_internal_width P_ ((struct window *)); +extern void mark_window_cursors_off (struct window *); +extern int window_internal_height (struct window *); +extern int window_internal_width (struct window *); EXFUN (Frecenter, 1); EXFUN (Fscroll_other_window, 1); EXFUN (Fset_window_start, 3); -extern void temp_output_buffer_show P_ ((Lisp_Object)); -extern void replace_buffer_in_all_windows P_ ((Lisp_Object)); -extern void init_window_once P_ ((void)); -extern void init_window P_ ((void)); -extern void syms_of_window P_ ((void)); -extern void keys_of_window P_ ((void)); - -extern int window_box_text_cols P_ ((struct window *w)); +extern void temp_output_buffer_show (Lisp_Object); +extern void replace_buffer_in_all_windows (Lisp_Object); +extern void init_window_once (void); +extern void init_window (void); +extern void syms_of_window (void); +extern void keys_of_window (void); + +extern int window_box_text_cols (struct window *w); #endif /* not WINDOW_H_INCLUDED */ diff --git a/src/xdisp.c b/src/xdisp.c index 59e38e440e4..4c007e572ce 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -32,9 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ decides it's time to do it. This is done either automatically for you as part of the interpreter's command loop or as the result of calling Lisp functions like `sit-for'. The C function `redisplay' - in xdisp.c is the only entry into the inner redisplay code. (Or, - let's say almost---see the description of direct update - operations, below.) + in xdisp.c is the only entry into the inner redisplay code. The following diagram shows how redisplay code is invoked. As you can see, Lisp calls redisplay and vice versa. Under window systems @@ -46,12 +44,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ change the interpreter's state. If you don't follow these rules, you will encounter bugs which are very hard to explain. - (Direct functions, see below) - direct_output_for_insert, - direct_forward_char (dispnew.c) - +---------------------------------+ - | | - | V +--------------+ redisplay +----------------+ | Lisp machine |---------------->| Redisplay code |<--+ +--------------+ (xdisp.c) +----------------+ | @@ -85,27 +77,42 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ then compared to find a cheap way to update the display, e.g. by reusing part of the display by scrolling lines. - - Direct operations. - You will find a lot of redisplay optimizations when you start looking at the innards of redisplay. The overall goal of all these optimizations is to make redisplay fast because it is done - frequently. + frequently. Some of these optimizations are implemented by the + following functions: + + . try_cursor_movement + + This function tries to update the display if the text in the + window did not change and did not scroll, only point moved, and + it did not move off the displayed portion of the text. + + . try_window_reusing_current_matrix + + This function reuses the current matrix of a window when text + has not changed, but the window start changed (e.g., due to + scrolling). - Two optimizations are not found in xdisp.c. These are the direct - operations mentioned above. As the name suggests they follow a - different principle than the rest of redisplay. Instead of - building a desired matrix and then comparing it with the current - display, they perform their actions directly on the display and on - the current matrix. + . try_window_id - One direct operation updates the display after one character has - been entered. The other one moves the cursor by one position - forward or backward. You find these functions under the names - `direct_output_for_insert' and `direct_output_forward_char' in - dispnew.c. + This function attempts to redisplay a window by reusing parts of + its existing display. It finds and reuses the part that was not + changed, and redraws the rest. + . try_window + + This function performs the full redisplay of a single window + assuming that its fonts were not changed and that the cursor + will not end up in the scroll margins. (Loading fonts requires + re-adjustment of dimensions of glyph matrices, which makes this + method impossible to use.) + + These optimizations are tried in sequence (some can be skipped if + it is known that they are not applicable). If none of the + optimizations were successful, redisplay calls redisplay_windows, + which performs a full redisplay of all windows. Desired matrices. @@ -137,13 +144,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ see in dispextern.h. Glyphs in a desired matrix are normally constructed in a loop - calling get_next_display_element and then produce_glyphs. The call - to produce_glyphs will fill the iterator structure with pixel + calling get_next_display_element and then PRODUCE_GLYPHS. The call + to PRODUCE_GLYPHS will fill the iterator structure with pixel information about the element being displayed and at the same time produce glyphs for it. If the display element fits on the line being displayed, set_iterator_to_next is called next, otherwise the - glyphs produced are discarded. - + glyphs produced are discarded. The function display_line is the + workhorse of filling glyph rows in the desired matrix with glyphs. + In addition to producing glyphs, it also handles line truncation + and continuation, word wrap, and cursor positioning (for the + latter, see also set_cursor_from_row). Frame matrices. @@ -164,7 +174,69 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ wanted to have without having to move many bytes around. To be honest, there is a little bit more done, but not much more. If you plan to extend that code, take a look at dispnew.c. The function - build_frame_matrix is a good starting point. */ + build_frame_matrix is a good starting point. + + Bidirectional display. + + Bidirectional display adds quite some hair to this already complex + design. The good news are that a large portion of that hairy stuff + is hidden in bidi.c behind only 3 interfaces. bidi.c implements a + reordering engine which is called by set_iterator_to_next and + returns the next character to display in the visual order. See + commentary on bidi.c for more details. As far as redisplay is + concerned, the effect of calling bidi_move_to_visually_next, the + main interface of the reordering engine, is that the iterator gets + magically placed on the buffer or string position that is to be + displayed next. In other words, a linear iteration through the + buffer/string is replaced with a non-linear one. All the rest of + the redisplay is oblivious to the bidi reordering. + + Well, almost oblivious---there are still complications, most of + them due to the fact that buffer and string positions no longer + change monotonously with glyph indices in a glyph row. Moreover, + for continued lines, the buffer positions may not even be + monotonously changing with vertical positions. Also, accounting + for face changes, overlays, etc. becomes more complex because + non-linear iteration could potentially skip many positions with + changes, and then cross them again on the way back... + + One other prominent effect of bidirectional display is that some + paragraphs of text need to be displayed starting at the right + margin of the window---the so-called right-to-left, or R2L + paragraphs. R2L paragraphs are displayed with R2L glyph rows, + which have their reversed_p flag set. The bidi reordering engine + produces characters in such rows starting from the character which + should be the rightmost on display. PRODUCE_GLYPHS then reverses + the order, when it fills up the glyph row whose reversed_p flag is + set, by prepending each new glyph to what is already there, instead + of appending it. When the glyph row is complete, the function + extend_face_to_end_of_line fills the empty space to the left of the + leftmost character with special glyphs, which will display as, + well, empty. On text terminals, these special glyphs are simply + blank characters. On graphics terminals, there's a single stretch + glyph with suitably computed width. Both the blanks and the + stretch glyph are given the face of the background of the line. + This way, the terminal-specific back-end can still draw the glyphs + left to right, even for R2L lines. + + Note one important detail mentioned above: that the bidi reordering + engine, driven by the iterator, produces characters in R2L rows + starting at the character that will be the rightmost on display. + As far as the iterator is concerned, the geometry of such rows is + still left to right, i.e. the iterator "thinks" the first character + is at the leftmost pixel position. The iterator does not know that + PRODUCE_GLYPHS reverses the order of the glyphs that the iterator + delivers. This is important when functions from the the move_it_* + family are used to get to certain screen position or to match + screen coordinates with buffer coordinates: these functions use the + iterator geometry, which is left to right even in R2L paragraphs. + This works well with most callers of move_it_*, because they need + to get to a specific column, and columns are still numbered in the + reading order, i.e. the rightmost character in a R2L paragraph is + still column zero. But some callers do not get well with this; a + notable example is mouse clicks that need to find the character + that corresponds to certain pixel coordinates. See + buffer_posn_from_coords in dispnew.c for how this is handled. */ #include <config.h> #include <stdio.h> @@ -186,6 +258,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "macros.h" #include "disptab.h" #include "termhooks.h" +#include "termopts.h" #include "intervals.h" #include "coding.h" #include "process.h" @@ -215,30 +288,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define INFINITY 10000000 -#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ - || defined(HAVE_NS) || defined (USE_GTK) -extern void set_frame_menubar P_ ((struct frame *f, int, int)); -extern int pending_menu_activation; -#endif - -extern int interrupt_input; -extern int command_loop_level; - -extern Lisp_Object do_mouse_tracking; - -extern int minibuffer_auto_raise; -extern Lisp_Object Vminibuffer_list; - -extern Lisp_Object Qface; -extern Lisp_Object Qmode_line, Qmode_line_inactive, Qheader_line; - -extern Lisp_Object Voverriding_local_map; -extern Lisp_Object Voverriding_local_map_menu_flag; -extern Lisp_Object Qmenu_item; -extern Lisp_Object Qwhen; -extern Lisp_Object Qhelp_echo; -extern Lisp_Object Qbefore_string, Qafter_string; - Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; Lisp_Object Qwindow_text_change_functions, Vwindow_text_change_functions; @@ -249,6 +298,7 @@ Lisp_Object Qfontified; Lisp_Object Qgrow_only; Lisp_Object Qinhibit_eval_during_redisplay; Lisp_Object Qbuffer_position, Qposition, Qobject; +Lisp_Object Qright_to_left, Qleft_to_right; /* Cursor shapes */ Lisp_Object Qbar, Qhbar, Qbox, Qhollow; @@ -303,6 +353,14 @@ EMACS_INT tool_bar_button_relief; Lisp_Object Vauto_resize_tool_bars; +/* Type of tool bar. Can be symbols image, text, both or both-hroiz. */ + +Lisp_Object Vtool_bar_style; + +/* Maximum number of characters a label can have to be shown. */ + +EMACS_INT tool_bar_max_label_size; + /* Non-zero means draw block and hollow cursor as wide as the glyph under it. For example, if a block cursor is over a tab, it will be drawn as wide as that tab on the display. */ @@ -320,7 +378,6 @@ int inhibit_eval_during_redisplay; /* Names of text properties relevant for redisplay. */ Lisp_Object Qdisplay; -extern Lisp_Object Qface, Qinvisible, Qwidth; /* Symbols used in text property values. */ @@ -331,10 +388,6 @@ Lisp_Object Qslice; Lisp_Object Qcenter; Lisp_Object Qmargin, Qpointer; Lisp_Object Qline_height; -extern Lisp_Object Qheight; -extern Lisp_Object QCwidth, QCheight, QCascent; -extern Lisp_Object Qscroll_bar; -extern Lisp_Object Qcursor; /* Non-nil means highlight trailing whitespace. */ @@ -345,17 +398,18 @@ Lisp_Object Vshow_trailing_whitespace; Lisp_Object Vnobreak_char_display; #ifdef HAVE_WINDOW_SYSTEM -extern Lisp_Object Voverflow_newline_into_fringe; /* Test if overflow newline into fringe. Called with iterator IT at or past right window margin, and with IT->current_x set. */ -#define IT_OVERFLOW_NEWLINE_INTO_FRINGE(it) \ - (!NILP (Voverflow_newline_into_fringe) \ - && FRAME_WINDOW_P (it->f) \ - && WINDOW_RIGHT_FRINGE_WIDTH (it->w) > 0 \ - && it->current_x == it->last_visible_x \ - && it->line_wrap != WORD_WRAP) +#define IT_OVERFLOW_NEWLINE_INTO_FRINGE(IT) \ + (!NILP (Voverflow_newline_into_fringe) \ + && FRAME_WINDOW_P ((IT)->f) \ + && ((IT)->bidi_it.paragraph_dir == R2L \ + ? (WINDOW_LEFT_FRINGE_WIDTH ((IT)->w) > 0) \ + : (WINDOW_RIGHT_FRINGE_WIDTH ((IT)->w) > 0)) \ + && (IT)->current_x == (IT)->last_visible_x \ + && (IT)->line_wrap != WORD_WRAP) #else /* !HAVE_WINDOW_SYSTEM */ #define IT_OVERFLOW_NEWLINE_INTO_FRINGE(it) 0 @@ -386,7 +440,7 @@ Lisp_Object Qescape_glyph; Lisp_Object Qnobreak_space; /* The symbol `image' which is the car of the lists used to represent - images in Lisp. */ + images in Lisp. Also a tool bar style. */ Lisp_Object Qimage; @@ -394,6 +448,9 @@ Lisp_Object Qimage; Lisp_Object QCmap, QCpointer; Lisp_Object Qrect, Qcircle, Qpoly; +/* Tool bar styles */ +Lisp_Object Qboth, Qboth_horiz, Qtext_image_horiz; + /* Non-zero means print newline to stdout before next mini-buffer message. */ @@ -764,15 +821,15 @@ struct props /* A handler function called to set up iterator IT from the property at IT's current position. Value is used to steer handle_stop. */ - enum prop_handled (*handler) P_ ((struct it *it)); + enum prop_handled (*handler) (struct it *it); }; -static enum prop_handled handle_face_prop P_ ((struct it *)); -static enum prop_handled handle_invisible_prop P_ ((struct it *)); -static enum prop_handled handle_display_prop P_ ((struct it *)); -static enum prop_handled handle_composition_prop P_ ((struct it *)); -static enum prop_handled handle_overlay_change P_ ((struct it *)); -static enum prop_handled handle_fontified_prop P_ ((struct it *)); +static enum prop_handled handle_face_prop (struct it *); +static enum prop_handled handle_invisible_prop (struct it *); +static enum prop_handled handle_display_prop (struct it *); +static enum prop_handled handle_composition_prop (struct it *); +static enum prop_handled handle_overlay_change (struct it *); +static enum prop_handled handle_fontified_prop (struct it *); /* Properties handled by iterators. */ @@ -850,7 +907,7 @@ Lisp_Object Qinhibit_free_realized_faces; Lisp_Object help_echo_string; Lisp_Object help_echo_window; Lisp_Object help_echo_object; -int help_echo_pos; +EMACS_INT help_echo_pos; /* Temporary variable for XTread_socket. */ @@ -882,146 +939,152 @@ Lisp_Object Vhourglass_delay; /* Function prototypes. */ -static void setup_for_ellipsis P_ ((struct it *, int)); -static void mark_window_display_accurate_1 P_ ((struct window *, int)); -static int single_display_spec_string_p P_ ((Lisp_Object, Lisp_Object)); -static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object)); -static int cursor_row_p P_ ((struct window *, struct glyph_row *)); -static int redisplay_mode_lines P_ ((Lisp_Object, int)); -static char *decode_mode_spec_coding P_ ((Lisp_Object, char *, int)); - -static Lisp_Object get_it_property P_ ((struct it *it, Lisp_Object prop)); - -static void handle_line_prefix P_ ((struct it *)); - -static void pint2str P_ ((char *, int, int)); -static void pint2hrstr P_ ((char *, int, int)); -static struct text_pos run_window_scroll_functions P_ ((Lisp_Object, - struct text_pos)); -static void reconsider_clip_changes P_ ((struct window *, struct buffer *)); -static int text_outside_line_unchanged_p P_ ((struct window *, int, int)); -static void store_mode_line_noprop_char P_ ((char)); -static int store_mode_line_noprop P_ ((const unsigned char *, int, int)); -static void x_consider_frame_title P_ ((Lisp_Object)); -static void handle_stop P_ ((struct it *)); -static int tool_bar_lines_needed P_ ((struct frame *, int *)); -static int single_display_spec_intangible_p P_ ((Lisp_Object)); -static void ensure_echo_area_buffers P_ ((void)); -static Lisp_Object unwind_with_echo_area_buffer P_ ((Lisp_Object)); -static Lisp_Object with_echo_area_buffer_unwind_data P_ ((struct window *)); -static int with_echo_area_buffer P_ ((struct window *, int, - int (*) (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT), - EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static void clear_garbaged_frames P_ ((void)); -static int current_message_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static int truncate_message_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static int set_message_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static int display_echo_area P_ ((struct window *)); -static int display_echo_area_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static int resize_mini_window_1 P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); -static Lisp_Object unwind_redisplay P_ ((Lisp_Object)); -static int string_char_and_length P_ ((const unsigned char *, int *)); -static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object, - struct text_pos)); -static int compute_window_start_on_continuation_line P_ ((struct window *)); -static Lisp_Object safe_eval_handler P_ ((Lisp_Object)); -static void insert_left_trunc_glyphs P_ ((struct it *)); -static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *, - Lisp_Object)); -static void extend_face_to_end_of_line P_ ((struct it *)); -static int append_space_for_newline P_ ((struct it *, int)); -static int cursor_row_fully_visible_p P_ ((struct window *, int, int)); -static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); -static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); -static int trailing_whitespace_p P_ ((int)); -static int message_log_check_duplicate P_ ((int, int, int, int)); -static void push_it P_ ((struct it *)); -static void pop_it P_ ((struct it *)); -static void sync_frame_with_window_matrix_rows P_ ((struct window *)); -static void select_frame_for_redisplay P_ ((Lisp_Object)); -static void redisplay_internal P_ ((int)); -static int echo_area_display P_ ((int)); -static void redisplay_windows P_ ((Lisp_Object)); -static void redisplay_window P_ ((Lisp_Object, int)); -static Lisp_Object redisplay_window_error (); -static Lisp_Object redisplay_window_0 P_ ((Lisp_Object)); -static Lisp_Object redisplay_window_1 P_ ((Lisp_Object)); -static int update_menu_bar P_ ((struct frame *, int, int)); -static int try_window_reusing_current_matrix P_ ((struct window *)); -static int try_window_id P_ ((struct window *)); -static int display_line P_ ((struct it *)); -static int display_mode_lines P_ ((struct window *)); -static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); -static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int)); -static int store_mode_line_string P_ ((char *, Lisp_Object, int, int, int, Lisp_Object)); -static char *decode_mode_spec P_ ((struct window *, int, int, int, - Lisp_Object *)); -static void display_menu_bar P_ ((struct window *)); -static int display_count_lines P_ ((int, int, int, int, int *)); -static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, - EMACS_INT, EMACS_INT, struct it *, int, int, int, int)); -static void compute_line_metrics P_ ((struct it *)); -static void run_redisplay_end_trigger_hook P_ ((struct it *)); -static int get_overlay_strings P_ ((struct it *, int)); -static int get_overlay_strings_1 P_ ((struct it *, int, int)); -static void next_overlay_string P_ ((struct it *)); -static void reseat P_ ((struct it *, struct text_pos, int)); -static void reseat_1 P_ ((struct it *, struct text_pos, int)); -static void back_to_previous_visible_line_start P_ ((struct it *)); -void reseat_at_previous_visible_line_start P_ ((struct it *)); -static void reseat_at_next_visible_line_start P_ ((struct it *, int)); -static int next_element_from_ellipsis P_ ((struct it *)); -static int next_element_from_display_vector P_ ((struct it *)); -static int next_element_from_string P_ ((struct it *)); -static int next_element_from_c_string P_ ((struct it *)); -static int next_element_from_buffer P_ ((struct it *)); -static int next_element_from_composition P_ ((struct it *)); -static int next_element_from_image P_ ((struct it *)); -static int next_element_from_stretch P_ ((struct it *)); -static void load_overlay_strings P_ ((struct it *, int)); -static int init_from_display_pos P_ ((struct it *, struct window *, - struct display_pos *)); -static void reseat_to_string P_ ((struct it *, unsigned char *, - Lisp_Object, int, int, int, int)); +static void setup_for_ellipsis (struct it *, int); +static void mark_window_display_accurate_1 (struct window *, int); +static int single_display_spec_string_p (Lisp_Object, Lisp_Object); +static int display_prop_string_p (Lisp_Object, Lisp_Object); +static int cursor_row_p (struct window *, struct glyph_row *); +static int redisplay_mode_lines (Lisp_Object, int); +static char *decode_mode_spec_coding (Lisp_Object, char *, int); + +static Lisp_Object get_it_property (struct it *it, Lisp_Object prop); + +static void handle_line_prefix (struct it *); + +static void pint2str (char *, int, int); +static void pint2hrstr (char *, int, int); +static struct text_pos run_window_scroll_functions (Lisp_Object, + struct text_pos); +static void reconsider_clip_changes (struct window *, struct buffer *); +static int text_outside_line_unchanged_p (struct window *, + EMACS_INT, EMACS_INT); +static void store_mode_line_noprop_char (char); +static int store_mode_line_noprop (const unsigned char *, int, int); +static void x_consider_frame_title (Lisp_Object); +static void handle_stop (struct it *); +static void handle_stop_backwards (struct it *, EMACS_INT); +static int tool_bar_lines_needed (struct frame *, int *); +static int single_display_spec_intangible_p (Lisp_Object); +static void ensure_echo_area_buffers (void); +static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object); +static Lisp_Object with_echo_area_buffer_unwind_data (struct window *); +static int with_echo_area_buffer (struct window *, int, + int (*) (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT), + EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static void clear_garbaged_frames (void); +static int current_message_1 (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static int truncate_message_1 (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static int set_message_1 (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static int display_echo_area (struct window *); +static int display_echo_area_1 (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static int resize_mini_window_1 (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT); +static Lisp_Object unwind_redisplay (Lisp_Object); +static int string_char_and_length (const unsigned char *, int *); +static struct text_pos display_prop_end (struct it *, Lisp_Object, + struct text_pos); +static int compute_window_start_on_continuation_line (struct window *); +static Lisp_Object safe_eval_handler (Lisp_Object); +static void insert_left_trunc_glyphs (struct it *); +static struct glyph_row *get_overlay_arrow_glyph_row (struct window *, + Lisp_Object); +static void extend_face_to_end_of_line (struct it *); +static int append_space_for_newline (struct it *, int); +static int cursor_row_fully_visible_p (struct window *, int, int); +static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int); +static int try_cursor_movement (Lisp_Object, struct text_pos, int *); +static int trailing_whitespace_p (EMACS_INT); +static int message_log_check_duplicate (EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT); +static void push_it (struct it *); +static void pop_it (struct it *); +static void sync_frame_with_window_matrix_rows (struct window *); +static void select_frame_for_redisplay (Lisp_Object); +static void redisplay_internal (int); +static int echo_area_display (int); +static void redisplay_windows (Lisp_Object); +static void redisplay_window (Lisp_Object, int); +static Lisp_Object redisplay_window_error (Lisp_Object); +static Lisp_Object redisplay_window_0 (Lisp_Object); +static Lisp_Object redisplay_window_1 (Lisp_Object); +static int update_menu_bar (struct frame *, int, int); +static int try_window_reusing_current_matrix (struct window *); +static int try_window_id (struct window *); +static int display_line (struct it *); +static int display_mode_lines (struct window *); +static int display_mode_line (struct window *, enum face_id, Lisp_Object); +static int display_mode_element (struct it *, int, int, int, Lisp_Object, Lisp_Object, int); +static int store_mode_line_string (const char *, Lisp_Object, int, int, int, Lisp_Object); +static const char *decode_mode_spec (struct window *, int, int, int, + Lisp_Object *); +static void display_menu_bar (struct window *); +static int display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, int, + EMACS_INT *); +static int display_string (const unsigned char *, Lisp_Object, Lisp_Object, + EMACS_INT, EMACS_INT, struct it *, int, int, int, int); +static void compute_line_metrics (struct it *); +static void run_redisplay_end_trigger_hook (struct it *); +static int get_overlay_strings (struct it *, EMACS_INT); +static int get_overlay_strings_1 (struct it *, EMACS_INT, int); +static void next_overlay_string (struct it *); +static void reseat (struct it *, struct text_pos, int); +static void reseat_1 (struct it *, struct text_pos, int); +static void back_to_previous_visible_line_start (struct it *); +void reseat_at_previous_visible_line_start (struct it *); +static void reseat_at_next_visible_line_start (struct it *, int); +static int next_element_from_ellipsis (struct it *); +static int next_element_from_display_vector (struct it *); +static int next_element_from_string (struct it *); +static int next_element_from_c_string (struct it *); +static int next_element_from_buffer (struct it *); +static int next_element_from_composition (struct it *); +static int next_element_from_image (struct it *); +static int next_element_from_stretch (struct it *); +static void load_overlay_strings (struct it *, EMACS_INT); +static int init_from_display_pos (struct it *, struct window *, + struct display_pos *); +static void reseat_to_string (struct it *, const unsigned char *, + Lisp_Object, EMACS_INT, EMACS_INT, int, int); static enum move_it_result move_it_in_display_line_to (struct it *, EMACS_INT, int, enum move_operation_enum); -void move_it_vertically_backward P_ ((struct it *, int)); -static void init_to_row_start P_ ((struct it *, struct window *, - struct glyph_row *)); -static int init_to_row_end P_ ((struct it *, struct window *, - struct glyph_row *)); -static void back_to_previous_line_start P_ ((struct it *)); -static int forward_to_next_line_start P_ ((struct it *, int *)); -static struct text_pos string_pos_nchars_ahead P_ ((struct text_pos, - Lisp_Object, int)); -static struct text_pos string_pos P_ ((int, Lisp_Object)); -static struct text_pos c_string_pos P_ ((int, unsigned char *, int)); -static int number_of_chars P_ ((unsigned char *, int)); -static void compute_stop_pos P_ ((struct it *)); -static void compute_string_pos P_ ((struct text_pos *, struct text_pos, - Lisp_Object)); -static int face_before_or_after_it_pos P_ ((struct it *, int)); -static EMACS_INT next_overlay_change P_ ((EMACS_INT)); -static int handle_single_display_spec P_ ((struct it *, Lisp_Object, - Lisp_Object, Lisp_Object, - struct text_pos *, int)); -static int underlying_face_id P_ ((struct it *)); -static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *, - struct window *)); +void move_it_vertically_backward (struct it *, int); +static void init_to_row_start (struct it *, struct window *, + struct glyph_row *); +static int init_to_row_end (struct it *, struct window *, + struct glyph_row *); +static void back_to_previous_line_start (struct it *); +static int forward_to_next_line_start (struct it *, int *); +static struct text_pos string_pos_nchars_ahead (struct text_pos, + Lisp_Object, EMACS_INT); +static struct text_pos string_pos (EMACS_INT, Lisp_Object); +static struct text_pos c_string_pos (EMACS_INT, const unsigned char *, int); +static EMACS_INT number_of_chars (const unsigned char *, int); +static void compute_stop_pos (struct it *); +static void compute_string_pos (struct text_pos *, struct text_pos, + Lisp_Object); +static int face_before_or_after_it_pos (struct it *, int); +static EMACS_INT next_overlay_change (EMACS_INT); +static int handle_single_display_spec (struct it *, Lisp_Object, + Lisp_Object, Lisp_Object, + struct text_pos *, int); +static int underlying_face_id (struct it *); +static int in_ellipses_for_invisible_text_p (struct display_pos *, + struct window *); #define face_before_it_pos(IT) face_before_or_after_it_pos ((IT), 1) #define face_after_it_pos(IT) face_before_or_after_it_pos ((IT), 0) #ifdef HAVE_WINDOW_SYSTEM -static void update_tool_bar P_ ((struct frame *, int)); -static void build_desired_tool_bar_string P_ ((struct frame *f)); -static int redisplay_tool_bar P_ ((struct frame *)); -static void display_tool_bar_line P_ ((struct it *, int)); -static void notice_overwritten_cursor P_ ((struct window *, - enum glyph_row_area, - int, int, int, int)); +static void update_tool_bar (struct frame *, int); +static void build_desired_tool_bar_string (struct frame *f); +static int redisplay_tool_bar (struct frame *); +static void display_tool_bar_line (struct it *, int); +static void notice_overwritten_cursor (struct window *, + enum glyph_row_area, + int, int, int, int); +static void append_stretch_glyph (struct it *, Lisp_Object, + int, int, int); @@ -1039,8 +1102,7 @@ static void notice_overwritten_cursor P_ ((struct window *, This is the height of W minus the height of a mode line, if any. */ INLINE int -window_text_bottom_y (w) - struct window *w; +window_text_bottom_y (struct window *w) { int height = WINDOW_TOTAL_HEIGHT (w); @@ -1054,9 +1116,7 @@ window_text_bottom_y (w) the left and right of the window. */ INLINE int -window_box_width (w, area) - struct window *w; - int area; +window_box_width (struct window *w, int area) { int cols = XFASTINT (w->total_cols); int pixels = 0; @@ -1095,8 +1155,7 @@ window_box_width (w, area) including mode lines of W, if any. */ INLINE int -window_box_height (w) - struct window *w; +window_box_height (struct window *w) { struct frame *f = XFRAME (w->frame); int height = WINDOW_TOTAL_HEIGHT (w); @@ -1143,9 +1202,7 @@ window_box_height (w) whole window, to the right of the left fringe of W. */ INLINE int -window_box_left_offset (w, area) - struct window *w; - int area; +window_box_left_offset (struct window *w, int area) { int x; @@ -1173,13 +1230,11 @@ window_box_left_offset (w, area) /* Return the window-relative coordinate of the right edge of display - area AREA of window W. AREA < 0 means return the left edge of the + area AREA of window W. AREA < 0 means return the right edge of the whole window, to the left of the right fringe of W. */ INLINE int -window_box_right_offset (w, area) - struct window *w; - int area; +window_box_right_offset (struct window *w, int area) { return window_box_left_offset (w, area) + window_box_width (w, area); } @@ -1189,9 +1244,7 @@ window_box_right_offset (w, area) whole window, to the right of the left fringe of W. */ INLINE int -window_box_left (w, area) - struct window *w; - int area; +window_box_left (struct window *w, int area) { struct frame *f = XFRAME (w->frame); int x; @@ -1207,13 +1260,11 @@ window_box_left (w, area) /* Return the frame-relative coordinate of the right edge of display - area AREA of window W. AREA < 0 means return the left edge of the + area AREA of window W. AREA < 0 means return the right edge of the whole window, to the left of the right fringe of W. */ INLINE int -window_box_right (w, area) - struct window *w; - int area; +window_box_right (struct window *w, int area) { return window_box_left (w, area) + window_box_width (w, area); } @@ -1226,10 +1277,8 @@ window_box_right (w, area) *BOX_WIDTH, and *BOX_HEIGHT the pixel width and height of the box. */ INLINE void -window_box (w, area, box_x, box_y, box_width, box_height) - struct window *w; - int area; - int *box_x, *box_y, *box_width, *box_height; +window_box (struct window *w, int area, int *box_x, int *box_y, + int *box_width, int *box_height) { if (box_width) *box_width = window_box_width (w, area); @@ -1255,11 +1304,8 @@ window_box (w, area, box_x, box_y, box_width, box_height) box. */ INLINE void -window_box_edges (w, area, top_left_x, top_left_y, - bottom_right_x, bottom_right_y) - struct window *w; - int area; - int *top_left_x, *top_left_y, *bottom_right_x, *bottom_right_y; +window_box_edges (struct window *w, int area, int *top_left_x, int *top_left_y, + int *bottom_right_x, int *bottom_right_y) { window_box (w, area, top_left_x, top_left_y, bottom_right_x, bottom_right_y); @@ -1277,8 +1323,7 @@ window_box_edges (w, area, top_left_x, top_left_y, This can modify IT's settings. */ int -line_bottom_y (it) - struct it *it; +line_bottom_y (struct it *it) { int line_height = it->max_ascent + it->max_descent; int line_top_y = it->current_y; @@ -1320,9 +1365,8 @@ line_bottom_y (it) Set *ROWH and *VPOS to row's visible height and VPOS (row number). */ int -pos_visible_p (w, charpos, x, y, rtop, rbot, rowh, vpos) - struct window *w; - int charpos, *x, *y, *rtop, *rbot, *rowh, *vpos; +pos_visible_p (struct window *w, EMACS_INT charpos, int *x, int *y, + int *rtop, int *rbot, int *rowh, int *vpos) { struct it it; struct text_pos top; @@ -1461,9 +1505,7 @@ pos_visible_p (w, charpos, x, y, rtop, rbot, rowh, vpos) character. */ static INLINE int -string_char_and_length (str, len) - const unsigned char *str; - int *len; +string_char_and_length (const unsigned char *str, int *len) { int c; @@ -1483,16 +1525,13 @@ string_char_and_length (str, len) in STRING, return the position NCHARS ahead (NCHARS >= 0). */ static struct text_pos -string_pos_nchars_ahead (pos, string, nchars) - struct text_pos pos; - Lisp_Object string; - int nchars; +string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, EMACS_INT nchars) { xassert (STRINGP (string) && nchars >= 0); if (STRING_MULTIBYTE (string)) { - int rest = SBYTES (string) - BYTEPOS (pos); + EMACS_INT rest = SBYTES (string) - BYTEPOS (pos); const unsigned char *p = SDATA (string) + BYTEPOS (pos); int len; @@ -1516,9 +1555,7 @@ string_pos_nchars_ahead (pos, string, nchars) for character position CHARPOS in STRING. */ static INLINE struct text_pos -string_pos (charpos, string) - int charpos; - Lisp_Object string; +string_pos (EMACS_INT charpos, Lisp_Object string) { struct text_pos pos; xassert (STRINGP (string)); @@ -1533,10 +1570,7 @@ string_pos (charpos, string) means recognize multibyte characters. */ static struct text_pos -c_string_pos (charpos, s, multibyte_p) - int charpos; - unsigned char *s; - int multibyte_p; +c_string_pos (EMACS_INT charpos, const unsigned char *s, int multibyte_p) { struct text_pos pos; @@ -1545,7 +1579,8 @@ c_string_pos (charpos, s, multibyte_p) if (multibyte_p) { - int rest = strlen (s), len; + EMACS_INT rest = strlen (s); + int len; SET_TEXT_POS (pos, 0, 0); while (charpos--) @@ -1567,16 +1602,15 @@ c_string_pos (charpos, s, multibyte_p) /* Value is the number of characters in C string S. MULTIBYTE_P non-zero means recognize multibyte characters. */ -static int -number_of_chars (s, multibyte_p) - unsigned char *s; - int multibyte_p; +static EMACS_INT +number_of_chars (const unsigned char *s, int multibyte_p) { - int nchars; + EMACS_INT nchars; if (multibyte_p) { - int rest = strlen (s), len; + EMACS_INT rest = strlen (s); + int len; unsigned char *p = (unsigned char *) s; for (nchars = 0; rest > 0; ++nchars) @@ -1597,9 +1631,7 @@ number_of_chars (s, multibyte_p) NEWPOS->charpos must be >= POS.charpos. */ static void -compute_string_pos (newpos, pos, string) - struct text_pos *newpos, pos; - Lisp_Object string; +compute_string_pos (struct text_pos *newpos, struct text_pos pos, Lisp_Object string) { xassert (STRINGP (string)); xassert (CHARPOS (*newpos) >= CHARPOS (pos)); @@ -1616,9 +1648,7 @@ compute_string_pos (newpos, pos, string) frame F. FACE_ID specifies what line's height to estimate. */ int -estimate_mode_line_height (f, face_id) - struct frame *f; - enum face_id face_id; +estimate_mode_line_height (struct frame *f, enum face_id face_id) { #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) @@ -1652,12 +1682,8 @@ estimate_mode_line_height (f, face_id) not force the value into range. */ void -pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) - FRAME_PTR f; - register int pix_x, pix_y; - int *x, *y; - NativeRectangle *bounds; - int noclip; +pixel_to_glyph_coords (FRAME_PTR f, register int pix_x, register int pix_y, + int *x, int *y, NativeRectangle *bounds, int noclip) { #ifdef HAVE_WINDOW_SYSTEM @@ -1706,10 +1732,8 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) return 0. */ int -glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y) - struct window *w; - int hpos, vpos; - int *frame_x, *frame_y; +glyph_to_pixel_coords (struct window *w, int hpos, int vpos, + int *frame_x, int *frame_y) { #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w)))) @@ -1769,10 +1793,8 @@ glyph_to_pixel_coords (w, hpos, vpos, frame_x, frame_y) static struct glyph * -x_y_to_hpos_vpos (w, x, y, hpos, vpos, dx, dy, area) - struct window *w; - int x, y; - int *hpos, *vpos, *dx, *dy, *area; +x_y_to_hpos_vpos (struct window *w, int x, int y, int *hpos, int *vpos, + int *dx, int *dy, int *area) { struct glyph *glyph, *end; struct glyph_row *row = NULL; @@ -1849,9 +1871,7 @@ x_y_to_hpos_vpos (w, x, y, hpos, vpos, dx, dy, area) Takes pseudo-windows into account. */ void -frame_to_window_pixel_xy (w, x, y) - struct window *w; - int *x, *y; +frame_to_window_pixel_xy (struct window *w, int *x, int *y) { if (w->pseudo_window_p) { @@ -1873,10 +1893,7 @@ frame_to_window_pixel_xy (w, x, y) Return the number of stored rectangles. */ int -get_glyph_string_clip_rects (s, rects, n) - struct glyph_string *s; - NativeRectangle *rects; - int n; +get_glyph_string_clip_rects (struct glyph_string *s, NativeRectangle *rects, int n) { XRectangle r; @@ -2070,9 +2087,7 @@ get_glyph_string_clip_rects (s, rects, n) Return in *NR the clipping rectangle for glyph string S. */ void -get_glyph_string_clip_rect (s, nr) - struct glyph_string *s; - NativeRectangle *nr; +get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr) { get_glyph_string_clip_rects (s, nr, 1); } @@ -2084,11 +2099,8 @@ get_glyph_string_clip_rect (s, nr) */ void -get_phys_cursor_geometry (w, row, glyph, xp, yp, heightp) - struct window *w; - struct glyph_row *row; - struct glyph *glyph; - int *xp, *yp, *heightp; +get_phys_cursor_geometry (struct window *w, struct glyph_row *row, + struct glyph *glyph, int *xp, int *yp, int *heightp) { struct frame *f = XFRAME (WINDOW_FRAME (w)); int x, y, wd, h, h0, y0; @@ -2148,10 +2160,7 @@ get_phys_cursor_geometry (w, row, glyph, xp, yp, heightp) */ void -remember_mouse_glyph (f, gx, gy, rect) - struct frame *f; - int gx, gy; - NativeRectangle *rect; +remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) { Lisp_Object window; struct window *w; @@ -2347,8 +2356,7 @@ remember_mouse_glyph (f, gx, gy, rect) /* Error handler for safe_eval and safe_call. */ static Lisp_Object -safe_eval_handler (arg) - Lisp_Object arg; +safe_eval_handler (Lisp_Object arg) { add_to_log ("Error during redisplay: %s", arg, Qnil); return Qnil; @@ -2363,9 +2371,7 @@ safe_eval_handler (arg) redisplay during the evaluation. */ Lisp_Object -safe_call (nargs, args) - int nargs; - Lisp_Object *args; +safe_call (int nargs, Lisp_Object *args) { Lisp_Object val; @@ -2381,7 +2387,7 @@ safe_call (nargs, args) specbind (Qinhibit_redisplay, Qt); /* Use Qt to ensure debugger does not run, so there is no possibility of wanting to redisplay. */ - val = internal_condition_case_2 (Ffuncall, nargs, args, Qt, + val = internal_condition_case_n (Ffuncall, nargs, args, Qt, safe_eval_handler); UNGCPRO; val = unbind_to (count, val); @@ -2395,8 +2401,7 @@ safe_call (nargs, args) Return the result, or nil if something went wrong. */ Lisp_Object -safe_call1 (fn, arg) - Lisp_Object fn, arg; +safe_call1 (Lisp_Object fn, Lisp_Object arg) { Lisp_Object args[2]; args[0] = fn; @@ -2525,12 +2530,9 @@ check_window_end (w) the desired matrix of W. */ void -init_iterator (it, w, charpos, bytepos, row, base_face_id) - struct it *it; - struct window *w; - int charpos, bytepos; - struct glyph_row *row; - enum face_id base_face_id; +init_iterator (struct it *it, struct window *w, + EMACS_INT charpos, EMACS_INT bytepos, + struct glyph_row *row, enum face_id base_face_id) { int highlight_region_p; enum face_id remapped_base_face_id = base_face_id; @@ -2566,7 +2568,7 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) } /* Clear IT. */ - bzero (it, sizeof *it); + memset (it, 0, sizeof *it); it->current.overlay_string_index = -1; it->current.dpvec_index = -1; it->base_face_id = remapped_base_face_id; @@ -2628,6 +2630,13 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) /* Are multibyte characters enabled in current_buffer? */ it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters); + /* Do we need to reorder bidirectional text? Not if this is a + unibyte buffer: by definition, none of the single-byte characters + are strong R2L, so no reordering is needed. And bidi.c doesn't + support unibyte buffers anyway. */ + it->bidi_p + = !NILP (current_buffer->bidi_display_reordering) && it->multibyte_p; + /* Non-zero if we should highlight the region. */ highlight_region_p = (!NILP (Vtransient_mark_mode) @@ -2649,7 +2658,7 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) && WINDOWP (minibuf_selected_window) && w == XWINDOW (minibuf_selected_window)))) { - int charpos = marker_position (current_buffer->mark); + EMACS_INT charpos = marker_position (current_buffer->mark); it->region_beg_charpos = min (PT, charpos); it->region_end_charpos = max (PT, charpos); } @@ -2718,6 +2727,10 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) it->glyph_row = row; it->area = TEXT_AREA; + /* Forget any previous info about this row being reversed. */ + if (it->glyph_row) + it->glyph_row->reversed_p = 0; + /* Get the dimensions of the display area. The display area consists of the visible window area plus a horizontally scrolled part to the left of the window. All x-values are relative to the @@ -2773,6 +2786,21 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) it->start_of_box_run_p = 1; } + /* If we are to reorder bidirectional text, init the bidi + iterator. */ + if (it->bidi_p) + { + /* Note the paragraph direction that this buffer wants to + use. */ + if (EQ (current_buffer->bidi_paragraph_direction, Qleft_to_right)) + it->paragraph_embedding = L2R; + else if (EQ (current_buffer->bidi_paragraph_direction, Qright_to_left)) + it->paragraph_embedding = R2L; + else + it->paragraph_embedding = NEUTRAL_DIR; + bidi_init_it (charpos, bytepos, &it->bidi_it); + } + /* If a buffer position was specified, set the iterator there, getting overlays and face properties from that position. */ if (charpos >= BUF_BEG (current_buffer)) @@ -2800,10 +2828,7 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id) /* Initialize IT for the display of window W with window start POS. */ void -start_display (it, w, pos) - struct it *it; - struct window *w; - struct text_pos pos; +start_display (struct it *it, struct window *w, struct text_pos pos) { struct glyph_row *row; int first_vpos = WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; @@ -2875,13 +2900,11 @@ start_display (it, w, pos) text. W is the window we display, for text property lookup. */ static int -in_ellipses_for_invisible_text_p (pos, w) - struct display_pos *pos; - struct window *w; +in_ellipses_for_invisible_text_p (struct display_pos *pos, struct window *w) { Lisp_Object prop, window; int ellipses_p = 0; - int charpos = CHARPOS (pos->pos); + EMACS_INT charpos = CHARPOS (pos->pos); /* If POS specifies a position in a display vector, this might be for an ellipsis displayed for invisible text. We won't @@ -2911,12 +2934,9 @@ in_ellipses_for_invisible_text_p (pos, w) is zero if there are overlay strings with newlines at POS. */ static int -init_from_display_pos (it, w, pos) - struct it *it; - struct window *w; - struct display_pos *pos; +init_from_display_pos (struct it *it, struct window *w, struct display_pos *pos) { - int charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos); + EMACS_INT charpos = CHARPOS (pos->pos), bytepos = BYTEPOS (pos->pos); int i, overlay_strings_with_newlines = 0; /* If POS specifies a position in a display vector, this might @@ -3022,10 +3042,7 @@ init_from_display_pos (it, w, pos) starting at ROW->start. */ static void -init_to_row_start (it, w, row) - struct it *it; - struct window *w; - struct glyph_row *row; +init_to_row_start (struct it *it, struct window *w, struct glyph_row *row) { init_from_display_pos (it, w, &row->start); it->start = row->start; @@ -3040,10 +3057,7 @@ init_to_row_start (it, w, row) end position. */ static int -init_to_row_end (it, w, row) - struct it *it; - struct window *w; - struct glyph_row *row; +init_to_row_end (struct it *it, struct window *w, struct glyph_row *row) { int success = 0; @@ -3071,8 +3085,7 @@ init_to_row_end (it, w, row) to stop. */ static void -handle_stop (it) - struct it *it; +handle_stop (struct it *it) { enum prop_handled handled; int handle_overlay_change_p; @@ -3165,8 +3178,7 @@ handle_stop (it) information for IT's current position. */ static void -compute_stop_pos (it) - struct it *it; +compute_stop_pos (struct it *it) { register INTERVAL iv, next_iv; Lisp_Object object, limit, position; @@ -3260,8 +3272,15 @@ compute_stop_pos (it) } } - composition_compute_stop_pos (&it->cmp_it, charpos, bytepos, - it->stop_charpos, it->string); + if (it->cmp_it.id < 0) + { + EMACS_INT stoppos = it->end_charpos; + + if (it->bidi_p && it->bidi_it.scan_dir < 0) + stoppos = -1; + composition_compute_stop_pos (&it->cmp_it, charpos, bytepos, + stoppos, it->string); + } xassert (STRINGP (it->string) || (it->stop_charpos >= BEGV @@ -3275,8 +3294,7 @@ compute_stop_pos (it) xmalloc. */ static EMACS_INT -next_overlay_change (pos) - EMACS_INT pos; +next_overlay_change (EMACS_INT pos) { int noverlays; EMACS_INT endpos; @@ -3312,8 +3330,7 @@ next_overlay_change (pos) regions of text. */ static enum prop_handled -handle_fontified_prop (it) - struct it *it; +handle_fontified_prop (struct it *it) { Lisp_Object prop, pos; enum prop_handled handled = HANDLED_NORMALLY; @@ -3400,8 +3417,7 @@ handle_fontified_prop (it) Called from handle_stop. */ static enum prop_handled -handle_face_prop (it) - struct it *it; +handle_face_prop (struct it *it) { int new_face_id; EMACS_INT next_stop; @@ -3444,7 +3460,8 @@ handle_face_prop (it) } else { - int base_face_id, bufpos; + int base_face_id; + EMACS_INT bufpos; int i; Lisp_Object from_overlay = (it->current.overlay_string_index >= 0 @@ -3539,8 +3556,7 @@ handle_face_prop (it) Otherwise, use the iterator's base_face_id. */ static int -underlying_face_id (it) - struct it *it; +underlying_face_id (struct it *it) { int face_id = it->base_face_id, i; @@ -3559,9 +3575,7 @@ underlying_face_id (it) position. Value is the id of the face. */ static int -face_before_or_after_it_pos (it, before_p) - struct it *it; - int before_p; +face_before_or_after_it_pos (struct it *it, int before_p) { int face_id, limit; EMACS_INT next_check_charpos; @@ -3571,7 +3585,8 @@ face_before_or_after_it_pos (it, before_p) if (STRINGP (it->string)) { - int bufpos, base_face_id; + EMACS_INT bufpos; + int base_face_id; /* No face change past the end of the string (for the case we are padding with spaces). No face change before the @@ -3614,7 +3629,6 @@ face_before_or_after_it_pos (it, before_p) if (STRING_MULTIBYTE (it->string)) { const unsigned char *p = SDATA (it->string) + BYTEPOS (pos); - int rest = SBYTES (it->string) - BYTEPOS (pos); int c, len; struct face *face = FACE_FROM_ID (it->f, face_id); @@ -3675,14 +3689,12 @@ face_before_or_after_it_pos (it, before_p) position. Called from handle_stop. */ static enum prop_handled -handle_invisible_prop (it) - struct it *it; +handle_invisible_prop (struct it *it) { enum prop_handled handled = HANDLED_NORMALLY; if (STRINGP (it->string)) { - extern Lisp_Object Qinvisible; Lisp_Object prop, end_charpos, limit, charpos; /* Get the value of the invisible text property at the @@ -3738,18 +3750,18 @@ handle_invisible_prop (it) else { int invis_p; - EMACS_INT newpos, next_stop, start_charpos; + EMACS_INT newpos, next_stop, start_charpos, tem; Lisp_Object pos, prop, overlay; /* First of all, is there invisible text at this position? */ - start_charpos = IT_CHARPOS (*it); - pos = make_number (IT_CHARPOS (*it)); + tem = start_charpos = IT_CHARPOS (*it); + pos = make_number (tem); prop = get_char_property_and_overlay (pos, Qinvisible, it->window, &overlay); invis_p = TEXT_PROP_MEANS_INVISIBLE (prop); /* If we are on invisible text, skip over it. */ - if (invis_p && IT_CHARPOS (*it) < it->end_charpos) + if (invis_p && start_charpos < it->end_charpos) { /* Record whether we have to display an ellipsis for the invisible text. */ @@ -3762,17 +3774,16 @@ handle_invisible_prop (it) do { /* Try to skip some invisible text. Return value is the - position reached which can be equal to IT's position - if there is nothing invisible here. This skips both + position reached which can be equal to where we start + if there is nothing invisible there. This skips both over invisible text properties and overlays with invisible property. */ - newpos = skip_invisible (IT_CHARPOS (*it), - &next_stop, ZV, it->window); + newpos = skip_invisible (tem, &next_stop, ZV, it->window); /* If we skipped nothing at all we weren't at invisible text in the first place. If everything to the end of the buffer was skipped, end the loop. */ - if (newpos == IT_CHARPOS (*it) || newpos >= ZV) + if (newpos == tem || newpos >= ZV) invis_p = 0; else { @@ -3790,7 +3801,7 @@ handle_invisible_prop (it) /* If we ended up on invisible text, proceed to skip starting with next_stop. */ if (invis_p) - IT_CHARPOS (*it) = next_stop; + tem = next_stop; /* If there are adjacent invisible texts, don't lose the second one's ellipsis. */ @@ -3800,8 +3811,48 @@ handle_invisible_prop (it) while (invis_p); /* The position newpos is now either ZV or on visible text. */ - IT_CHARPOS (*it) = newpos; - IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); + if (it->bidi_p && newpos < ZV) + { + /* With bidi iteration, the region of invisible text + could start and/or end in the middle of a non-base + embedding level. Therefore, we need to skip + invisible text using the bidi iterator, starting at + IT's current position, until we find ourselves + outside the invisible text. Skipping invisible text + _after_ bidi iteration avoids affecting the visual + order of the displayed text when invisible properties + are added or removed. */ + if (it->bidi_it.first_elt) + { + /* If we were `reseat'ed to a new paragraph, + determine the paragraph base direction. We need + to do it now because next_element_from_buffer may + not have a chance to do it, if we are going to + skip any text at the beginning, which resets the + FIRST_ELT flag. */ + bidi_paragraph_init (it->paragraph_embedding, + &it->bidi_it, 1); + } + do + { + bidi_move_to_visually_next (&it->bidi_it); + } + while (it->stop_charpos <= it->bidi_it.charpos + && it->bidi_it.charpos < newpos); + IT_CHARPOS (*it) = it->bidi_it.charpos; + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + /* If we overstepped NEWPOS, record its position in the + iterator, so that we skip invisible text if later the + bidi iteration lands us in the invisible region + again. */ + if (IT_CHARPOS (*it) >= newpos) + it->prev_stop = newpos; + } + else + { + IT_CHARPOS (*it) = newpos; + IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); + } /* If there are before-strings at the start of invisible text, and the text is invisible because of a text @@ -3810,7 +3861,7 @@ handle_invisible_prop (it) overlay property instead of a text property, this is already handled in the overlay code.) */ if (NILP (overlay) - && get_overlay_strings (it, start_charpos)) + && get_overlay_strings (it, it->stop_charpos)) { handled = HANDLED_RECOMPUTE_PROPS; it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p; @@ -3831,7 +3882,7 @@ handle_invisible_prop (it) first invisible character. */ if (!STRINGP (it->object)) { - it->position.charpos = IT_CHARPOS (*it) - 1; + it->position.charpos = newpos - 1; it->position.bytepos = CHAR_TO_BYTE (it->position.charpos); } it->ellipsis_p = 1; @@ -3851,9 +3902,7 @@ handle_invisible_prop (it) Replaces LEN characters from buffer. */ static void -setup_for_ellipsis (it, len) - struct it *it; - int len; +setup_for_ellipsis (struct it *it, int len) { /* Use the display table definition for `...'. Invalid glyphs will be handled by the method returning elements from dpvec. */ @@ -3897,8 +3946,7 @@ setup_for_ellipsis (it, len) Otherwise we return HANDLED_NORMALLY. */ static enum prop_handled -handle_display_prop (it) - struct it *it; +handle_display_prop (struct it *it) { Lisp_Object prop, object, overlay; struct text_pos *position; @@ -3995,10 +4043,7 @@ handle_display_prop (it) at START_POS in OBJECT. */ static struct text_pos -display_prop_end (it, object, start_pos) - struct it *it; - Lisp_Object object; - struct text_pos start_pos; +display_prop_end (struct it *it, Lisp_Object object, struct text_pos start_pos) { Lisp_Object end; struct text_pos end_pos; @@ -4033,14 +4078,9 @@ display_prop_end (it, object, start_pos) of buffer or string text. */ static int -handle_single_display_spec (it, spec, object, overlay, position, - display_replaced_before_p) - struct it *it; - Lisp_Object spec; - Lisp_Object object; - Lisp_Object overlay; - struct text_pos *position; - int display_replaced_before_p; +handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, + Lisp_Object overlay, struct text_pos *position, + int display_replaced_before_p) { Lisp_Object form; Lisp_Object location, value; @@ -4405,8 +4445,7 @@ handle_single_display_spec (it, spec, object, overlay, position, treated as intangible. */ static int -single_display_spec_intangible_p (prop) - Lisp_Object prop; +single_display_spec_intangible_p (Lisp_Object prop) { /* Skip over `when FORM'. */ if (CONSP (prop) && EQ (XCAR (prop), Qwhen)) @@ -4448,8 +4487,7 @@ single_display_spec_intangible_p (prop) treated as intangible. */ int -display_prop_intangible_p (prop) - Lisp_Object prop; +display_prop_intangible_p (Lisp_Object prop) { if (CONSP (prop) && CONSP (XCAR (prop)) @@ -4481,8 +4519,7 @@ display_prop_intangible_p (prop) /* Return 1 if PROP is a display sub-property value containing STRING. */ static int -single_display_spec_string_p (prop, string) - Lisp_Object prop, string; +single_display_spec_string_p (Lisp_Object prop, Lisp_Object string) { if (EQ (string, prop)) return 1; @@ -4516,8 +4553,7 @@ single_display_spec_string_p (prop, string) /* Return 1 if STRING appears in the `display' property PROP. */ static int -display_prop_string_p (prop, string) - Lisp_Object prop, string; +display_prop_string_p (Lisp_Object prop, Lisp_Object string) { if (CONSP (prop) && CONSP (XCAR (prop)) @@ -4545,43 +4581,43 @@ display_prop_string_p (prop, string) return 0; } - -/* Determine which buffer position in W's buffer STRING comes from. - AROUND_CHARPOS is an approximate position where it could come from. - Value is the buffer position or 0 if it couldn't be determined. +/* Look for STRING in overlays and text properties in W's buffer, + between character positions FROM and TO (excluding TO). + BACK_P non-zero means look back (in this case, TO is supposed to be + less than FROM). + Value is the first character position where STRING was found, or + zero if it wasn't found before hitting TO. W's buffer must be current. - This function is necessary because we don't record buffer positions - in glyphs generated from strings (to keep struct glyph small). This function may only use code that doesn't eval because it is called asynchronously from note_mouse_highlight. */ -int -string_buffer_position (w, string, around_charpos) - struct window *w; - Lisp_Object string; - int around_charpos; +static EMACS_INT +string_buffer_position_lim (struct window *w, Lisp_Object string, + EMACS_INT from, EMACS_INT to, int back_p) { Lisp_Object limit, prop, pos; - const int MAX_DISTANCE = 1000; int found = 0; - pos = make_number (around_charpos); - limit = make_number (min (XINT (pos) + MAX_DISTANCE, ZV)); - while (!found && !EQ (pos, limit)) + pos = make_number (from); + + if (!back_p) /* looking forward */ { - prop = Fget_char_property (pos, Qdisplay, Qnil); - if (!NILP (prop) && display_prop_string_p (prop, string)) - found = 1; - else - pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, limit); + limit = make_number (min (to, ZV)); + while (!found && !EQ (pos, limit)) + { + prop = Fget_char_property (pos, Qdisplay, Qnil); + if (!NILP (prop) && display_prop_string_p (prop, string)) + found = 1; + else + pos = Fnext_single_char_property_change (pos, Qdisplay, Qnil, + limit); + } } - - if (!found) + else /* looking back */ { - pos = make_number (around_charpos); - limit = make_number (max (XINT (pos) - MAX_DISTANCE, BEGV)); + limit = make_number (max (to, BEGV)); while (!found && !EQ (pos, limit)) { prop = Fget_char_property (pos, Qdisplay, Qnil); @@ -4596,6 +4632,31 @@ string_buffer_position (w, string, around_charpos) return found ? XINT (pos) : 0; } +/* Determine which buffer position in W's buffer STRING comes from. + AROUND_CHARPOS is an approximate position where it could come from. + Value is the buffer position or 0 if it couldn't be determined. + + W's buffer must be current. + + This function is necessary because we don't record buffer positions + in glyphs generated from strings (to keep struct glyph small). + This function may only use code that doesn't eval because it is + called asynchronously from note_mouse_highlight. */ + +EMACS_INT +string_buffer_position (struct window *w, Lisp_Object string, EMACS_INT around_charpos) +{ + const int MAX_DISTANCE = 1000; + EMACS_INT found = string_buffer_position_lim (w, string, around_charpos, + around_charpos + MAX_DISTANCE, + 0); + + if (!found) + found = string_buffer_position_lim (w, string, around_charpos, + around_charpos - MAX_DISTANCE, 1); + return found; +} + /*********************************************************************** @@ -4606,8 +4667,7 @@ string_buffer_position (w, string, around_charpos) position. Called from handle_stop. */ static enum prop_handled -handle_composition_prop (it) - struct it *it; +handle_composition_prop (struct it *it) { Lisp_Object prop, string; EMACS_INT pos, pos_byte, start, end; @@ -4680,8 +4740,7 @@ struct overlay_entry Called from handle_stop. */ static enum prop_handled -handle_overlay_change (it) - struct it *it; +handle_overlay_change (struct it *it) { if (!STRINGP (it->string) && get_overlay_strings (it, 0)) return HANDLED_RECOMPUTE_PROPS; @@ -4698,8 +4757,7 @@ handle_overlay_change (it) Otherwise IT->string is set to nil. */ static void -next_overlay_string (it) - struct it *it; +next_overlay_string (struct it *it) { ++it->current.overlay_string_index; if (it->current.overlay_string_index == it->n_overlay_strings) @@ -4767,8 +4825,7 @@ next_overlay_string (it) static int -compare_overlay_entries (e1, e2) - void *e1, *e2; +compare_overlay_entries (const void *e1, const void *e2) { struct overlay_entry *entry1 = (struct overlay_entry *) e1; struct overlay_entry *entry2 = (struct overlay_entry *) e2; @@ -4819,14 +4876,11 @@ compare_overlay_entries (e1, e2) compare_overlay_entries. */ static void -load_overlay_strings (it, charpos) - struct it *it; - int charpos; +load_overlay_strings (struct it *it, EMACS_INT charpos) { - extern Lisp_Object Qwindow, Qpriority; Lisp_Object overlay, window, str, invisible; struct Lisp_Overlay *ov; - int start, end; + EMACS_INT start, end; int size = 20; int n = 0, i, j, invis_p; struct overlay_entry *entries @@ -4851,7 +4905,7 @@ load_overlay_strings (it, charpos) entries = \ (struct overlay_entry *) alloca (new_size \ * sizeof *entries); \ - bcopy (old, entries, size * sizeof *entries); \ + memcpy (entries, old, size * sizeof *entries); \ size = new_size; \ } \ \ @@ -4972,10 +5026,7 @@ load_overlay_strings (it, charpos) least one overlay string was found. */ static int -get_overlay_strings_1 (it, charpos, compute_stop_p) - struct it *it; - int charpos; - int compute_stop_p; +get_overlay_strings_1 (struct it *it, EMACS_INT charpos, int compute_stop_p) { /* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to process. This fills IT->overlay_strings with strings, and sets @@ -5026,9 +5077,7 @@ get_overlay_strings_1 (it, charpos, compute_stop_p) } static int -get_overlay_strings (it, charpos) - struct it *it; - int charpos; +get_overlay_strings (struct it *it, EMACS_INT charpos) { it->string = Qnil; it->method = GET_FROM_BUFFER; @@ -5053,8 +5102,7 @@ get_overlay_strings (it, charpos) processed. */ static void -push_it (it) - struct it *it; +push_it (struct it *it) { struct iterator_stack_entry *p; @@ -5062,6 +5110,8 @@ push_it (it) p = it->stack + it->sp; p->stop_charpos = it->stop_charpos; + p->prev_stop = it->prev_stop; + p->base_level_stop = it->base_level_stop; p->cmp_it = it->cmp_it; xassert (it->face_id >= 0); p->face_id = it->face_id; @@ -5095,6 +5145,32 @@ push_it (it) ++it->sp; } +static void +iterate_out_of_display_property (struct it *it) +{ + /* Maybe initialize paragraph direction. If we are at the beginning + of a new paragraph, next_element_from_buffer may not have a + chance to do that. */ + if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV) + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); + /* prev_stop can be zero, so check against BEGV as well. */ + while (it->bidi_it.charpos >= BEGV + && it->prev_stop <= it->bidi_it.charpos + && it->bidi_it.charpos < CHARPOS (it->position)) + bidi_move_to_visually_next (&it->bidi_it); + /* Record the stop_pos we just crossed, for when we cross it + back, maybe. */ + if (it->bidi_it.charpos > CHARPOS (it->position)) + it->prev_stop = CHARPOS (it->position); + /* If we ended up not where pop_it put us, resync IT's + positional members with the bidi iterator. */ + if (it->bidi_it.charpos != CHARPOS (it->position)) + { + SET_TEXT_POS (it->position, + it->bidi_it.charpos, it->bidi_it.bytepos); + it->current.pos = it->position; + } +} /* Restore IT's settings from IT->stack. Called, for example, when no more overlay strings must be processed, and we return to delivering @@ -5103,8 +5179,7 @@ push_it (it) elements from an overlay string, or from a buffer. */ static void -pop_it (it) - struct it *it; +pop_it (struct it *it) { struct iterator_stack_entry *p; @@ -5112,6 +5187,8 @@ pop_it (it) --it->sp; p = it->stack + it->sp; it->stop_charpos = p->stop_charpos; + it->prev_stop = p->prev_stop; + it->base_level_stop = p->base_level_stop; it->cmp_it = p->cmp_it; it->face_id = p->face_id; it->current = p->current; @@ -5133,6 +5210,18 @@ pop_it (it) break; case GET_FROM_BUFFER: it->object = it->w->buffer; + if (it->bidi_p) + { + /* Bidi-iterate until we get out of the portion of text, if + any, covered by a `display' text property or an overlay + with `display' property. (We cannot just jump there, + because the internal coherency of the bidi iterator state + can not be preserved across such jumps.) We also must + determine the paragraph base direction if the overlay we + just processed is at the beginning of a new + paragraph. */ + iterate_out_of_display_property (it); + } break; case GET_FROM_STRING: it->object = it->string; @@ -5169,8 +5258,7 @@ pop_it (it) /* Set IT's current position to the previous line start. */ static void -back_to_previous_line_start (it) - struct it *it; +back_to_previous_line_start (struct it *it) { IT_CHARPOS (*it) = find_next_newline_no_quit (IT_CHARPOS (*it) - 1, -1); IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); @@ -5196,9 +5284,7 @@ back_to_previous_line_start (it) leads to wrong cursor motion. */ static int -forward_to_next_line_start (it, skipped_p) - struct it *it; - int *skipped_p; +forward_to_next_line_start (struct it *it, int *skipped_p) { int old_selective, newline_found_p, n; const int MAX_NEWLINE_DISTANCE = 500; @@ -5237,8 +5323,8 @@ forward_to_next_line_start (it, skipped_p) short-cut. */ if (!newline_found_p) { - int start = IT_CHARPOS (*it); - int limit = find_next_newline_no_quit (start, 1); + EMACS_INT start = IT_CHARPOS (*it); + EMACS_INT limit = find_next_newline_no_quit (start, 1); Lisp_Object pos; xassert (!STRINGP (it->string)); @@ -5279,8 +5365,7 @@ forward_to_next_line_start (it, skipped_p) IT->hpos. */ static void -back_to_previous_visible_line_start (it) - struct it *it; +back_to_previous_visible_line_start (struct it *it) { while (IT_CHARPOS (*it) > BEGV) { @@ -5289,8 +5374,8 @@ back_to_previous_visible_line_start (it) if (IT_CHARPOS (*it) <= BEGV) break; - /* If selective > 0, then lines indented more than that values - are invisible. */ + /* If selective > 0, then lines indented more than its value are + invisible. */ if (it->selective > 0 && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it), (double) it->selective)) /* iftc */ @@ -5310,7 +5395,7 @@ back_to_previous_visible_line_start (it) { struct it it2; - int pos; + EMACS_INT pos; EMACS_INT beg, end; Lisp_Object val, overlay; @@ -5360,8 +5445,7 @@ back_to_previous_visible_line_start (it) face information etc. */ void -reseat_at_previous_visible_line_start (it) - struct it *it; +reseat_at_previous_visible_line_start (struct it *it) { back_to_previous_visible_line_start (it); reseat (it, it->current.pos, 1); @@ -5377,9 +5461,7 @@ reseat_at_previous_visible_line_start (it) is invisible because of text properties. */ static void -reseat_at_next_visible_line_start (it, on_newline_p) - struct it *it; - int on_newline_p; +reseat_at_next_visible_line_start (struct it *it, int on_newline_p) { int newline_found_p, skipped_p = 0; @@ -5433,12 +5515,9 @@ reseat_at_next_visible_line_start (it, on_newline_p) IT->check_charpos of a property. */ static void -reseat (it, pos, force_p) - struct it *it; - struct text_pos pos; - int force_p; +reseat (struct it *it, struct text_pos pos, int force_p) { - int original_pos = IT_CHARPOS (*it); + EMACS_INT original_pos = IT_CHARPOS (*it); reseat_1 (it, pos, 0); @@ -5447,7 +5526,30 @@ reseat (it, pos, force_p) if (force_p || CHARPOS (pos) > it->stop_charpos || CHARPOS (pos) < original_pos) - handle_stop (it); + { + if (it->bidi_p) + { + /* For bidi iteration, we need to prime prev_stop and + base_level_stop with our best estimations. */ + if (CHARPOS (pos) < it->prev_stop) + { + handle_stop_backwards (it, BEGV); + if (CHARPOS (pos) < it->base_level_stop) + it->base_level_stop = 0; + } + else if (CHARPOS (pos) > it->stop_charpos + && it->stop_charpos >= BEGV) + handle_stop_backwards (it, it->stop_charpos); + else /* force_p */ + handle_stop (it); + } + else + { + handle_stop (it); + it->prev_stop = it->base_level_stop = 0; + } + + } CHECK_IT (it); } @@ -5457,10 +5559,7 @@ reseat (it, pos, force_p) IT->stop_pos to POS, also. */ static void -reseat_1 (it, pos, set_stop_p) - struct it *it; - struct text_pos pos; - int set_stop_p; +reseat_1 (struct it *it, struct text_pos pos, int set_stop_p) { /* Don't call this function when scanning a C string. */ xassert (it->s == NULL); @@ -5484,9 +5583,17 @@ reseat_1 (it, pos, set_stop_p) it->sp = 0; it->string_from_display_prop_p = 0; it->face_before_selective_p = 0; + if (it->bidi_p) + { + it->bidi_it.first_elt = 1; + it->bidi_it.paragraph_dir = NEUTRAL_DIR; + } if (set_stop_p) - it->stop_charpos = CHARPOS (pos); + { + it->stop_charpos = CHARPOS (pos); + it->base_level_stop = CHARPOS (pos); + } } @@ -5509,12 +5616,9 @@ reseat_1 (it, pos, set_stop_p) calling this function. */ static void -reseat_to_string (it, s, string, charpos, precision, field_width, multibyte) - struct it *it; - unsigned char *s; - Lisp_Object string; - int charpos; - int precision, field_width, multibyte; +reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string, + EMACS_INT charpos, EMACS_INT precision, int field_width, + int multibyte) { /* No region in strings. */ it->region_beg_charpos = it->region_end_charpos = -1; @@ -5523,7 +5627,7 @@ reseat_to_string (it, s, string, charpos, precision, field_width, multibyte) it->stop_charpos = -1; /* Set iterator position and end position. */ - bzero (&it->current, sizeof it->current); + memset (&it->current, 0, sizeof it->current); it->current.overlay_string_index = -1; it->current.dpvec_index = -1; xassert (charpos >= 0); @@ -5598,11 +5702,11 @@ reseat_to_string (it, s, string, charpos, precision, field_width, multibyte) /*********************************************************************** Iteration - ***********************************************************************/ +***********************************************************************/ /* Map enum it_method value to corresponding next_element_from_* function. */ -static int (* get_next_element[NUM_IT_METHODS]) P_ ((struct it *it)) = +static int (* get_next_element[NUM_IT_METHODS]) (struct it *it) = { next_element_from_buffer, next_element_from_display_vector, @@ -5636,8 +5740,7 @@ static unsigned last_escape_glyph_face_id = (1 << FACE_ID_BITS); static int last_escape_glyph_merged_face_id = 0; int -get_next_display_element (it) - struct it *it; +get_next_display_element (struct it *it) { /* Non-zero means that we found a display element. Zero means that we hit the end of what we iterate over. Performance note: the @@ -5650,6 +5753,13 @@ get_next_display_element (it) if (it->what == IT_CHARACTER) { + /* UAX#9, L4: "A character is depicted by a mirrored glyph if + and only if (a) the resolved directionality of that character + is R..." */ + /* FIXME: Do we need an exception for characters from display + tables? */ + if (it->bidi_p && it->bidi_it.type == STRONG_R) + it->c = bidi_mirror_char (it->c); /* Map via display table or translate control characters. IT->c, IT->len etc. have been set to the next character by the function call above. If we have a display table, and it @@ -5911,9 +6021,9 @@ get_next_display_element (it) } else { - int pos = (it->s ? -1 - : STRINGP (it->string) ? IT_STRING_CHARPOS (*it) - : IT_CHARPOS (*it)); + EMACS_INT pos = (it->s ? -1 + : STRINGP (it->string) ? IT_STRING_CHARPOS (*it) + : IT_CHARPOS (*it)); it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display, pos, it->string); @@ -5995,9 +6105,7 @@ get_next_display_element (it) decrement position function which would not be easy to write. */ void -set_iterator_to_next (it, reseat_p) - struct it *it; - int reseat_p; +set_iterator_to_next (struct it *it, int reseat_p) { /* Reset flags indicating start and end of a sequence of characters with box. Reset them at the start of this function because @@ -6014,23 +6122,113 @@ set_iterator_to_next (it, reseat_p) reseat_at_next_visible_line_start (it, 0); else if (it->cmp_it.id >= 0) { - IT_CHARPOS (*it) += it->cmp_it.nchars; - IT_BYTEPOS (*it) += it->cmp_it.nbytes; - if (it->cmp_it.to < it->cmp_it.nglyphs) - it->cmp_it.from = it->cmp_it.to; + /* We are currently getting glyphs from a composition. */ + int i; + + if (! it->bidi_p) + { + IT_CHARPOS (*it) += it->cmp_it.nchars; + IT_BYTEPOS (*it) += it->cmp_it.nbytes; + if (it->cmp_it.to < it->cmp_it.nglyphs) + { + it->cmp_it.from = it->cmp_it.to; + } + else + { + it->cmp_it.id = -1; + composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), + IT_BYTEPOS (*it), + it->end_charpos, Qnil); + } + } + else if (! it->cmp_it.reversed_p) + { + /* Composition created while scanning forward. */ + /* Update IT's char/byte positions to point to the first + character of the next grapheme cluster, or to the + character visually after the current composition. */ + for (i = 0; i < it->cmp_it.nchars; i++) + bidi_move_to_visually_next (&it->bidi_it); + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + IT_CHARPOS (*it) = it->bidi_it.charpos; + + if (it->cmp_it.to < it->cmp_it.nglyphs) + { + /* Proceed to the next grapheme cluster. */ + it->cmp_it.from = it->cmp_it.to; + } + else + { + /* No more grapheme clusters in this composition. + Find the next stop position. */ + EMACS_INT stop = it->end_charpos; + if (it->bidi_it.scan_dir < 0) + /* Now we are scanning backward and don't know + where to stop. */ + stop = -1; + composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), + IT_BYTEPOS (*it), stop, Qnil); + } + } else { - it->cmp_it.id = -1; - composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), - IT_BYTEPOS (*it), it->stop_charpos, - Qnil); + /* Composition created while scanning backward. */ + /* Update IT's char/byte positions to point to the last + character of the previous grapheme cluster, or the + character visually after the current composition. */ + for (i = 0; i < it->cmp_it.nchars; i++) + bidi_move_to_visually_next (&it->bidi_it); + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + IT_CHARPOS (*it) = it->bidi_it.charpos; + if (it->cmp_it.from > 0) + { + /* Proceed to the previous grapheme cluster. */ + it->cmp_it.to = it->cmp_it.from; + } + else + { + /* No more grapheme clusters in this composition. + Find the next stop position. */ + EMACS_INT stop = it->end_charpos; + if (it->bidi_it.scan_dir < 0) + /* Now we are scanning backward and don't know + where to stop. */ + stop = -1; + composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), + IT_BYTEPOS (*it), stop, Qnil); + } } } else { xassert (it->len != 0); - IT_BYTEPOS (*it) += it->len; - IT_CHARPOS (*it) += 1; + + if (!it->bidi_p) + { + IT_BYTEPOS (*it) += it->len; + IT_CHARPOS (*it) += 1; + } + else + { + int prev_scan_dir = it->bidi_it.scan_dir; + /* If this is a new paragraph, determine its base + direction (a.k.a. its base embedding level). */ + if (it->bidi_it.new_paragraph) + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 0); + bidi_move_to_visually_next (&it->bidi_it); + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + IT_CHARPOS (*it) = it->bidi_it.charpos; + if (prev_scan_dir != it->bidi_it.scan_dir) + { + /* As the scan direction was changed, we must + re-compute the stop position for composition. */ + EMACS_INT stop = it->end_charpos; + if (it->bidi_it.scan_dir < 0) + stop = -1; + composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), + IT_BYTEPOS (*it), stop, Qnil); + } + } xassert (IT_BYTEPOS (*it) == CHAR_TO_BYTE (IT_CHARPOS (*it))); } break; @@ -6102,7 +6300,7 @@ set_iterator_to_next (it, reseat_p) composition_compute_stop_pos (&it->cmp_it, IT_STRING_CHARPOS (*it), IT_STRING_BYTEPOS (*it), - it->stop_charpos, it->string); + it->end_charpos, it->string); } } else @@ -6172,8 +6370,7 @@ set_iterator_to_next (it, reseat_p) is restored into IT->face_id in set_iterator_to_next. */ static int -next_element_from_display_vector (it) - struct it *it; +next_element_from_display_vector (struct it *it) { Lisp_Object gc; @@ -6183,7 +6380,7 @@ next_element_from_display_vector (it) it->face_id = it->saved_face_id; /* KFS: This code used to check ip->dpvec[0] instead of the current element. - That seemed totally bogus - so I changed it... */ + That seemed totally bogus - so I changed it... */ gc = it->dpvec[it->current.dpvec_index]; if (GLYPH_CODE_P (gc) && GLYPH_CODE_CHAR_VALID_P (gc)) @@ -6222,8 +6419,7 @@ next_element_from_display_vector (it) overlay string. */ static int -next_element_from_string (it) - struct it *it; +next_element_from_string (struct it *it) { struct text_pos position; @@ -6260,7 +6456,6 @@ next_element_from_string (it) } else if (STRING_MULTIBYTE (it->string)) { - int remaining = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); const unsigned char *s = (SDATA (it->string) + IT_STRING_BYTEPOS (*it)); it->c = string_char_and_length (s, &it->len); @@ -6296,7 +6491,6 @@ next_element_from_string (it) } else if (STRING_MULTIBYTE (it->string)) { - int maxlen = SBYTES (it->string) - IT_STRING_BYTEPOS (*it); const unsigned char *s = (SDATA (it->string) + IT_STRING_BYTEPOS (*it)); it->c = string_char_and_length (s, &it->len); @@ -6324,8 +6518,7 @@ next_element_from_string (it) reached, including padding spaces. */ static int -next_element_from_c_string (it) - struct it *it; +next_element_from_c_string (struct it *it) { int success_p = 1; @@ -6350,13 +6543,7 @@ next_element_from_c_string (it) BYTEPOS (it->position) = CHARPOS (it->position) = -1; } else if (it->multibyte_p) - { - /* Implementation note: The calls to strlen apparently aren't a - performance problem because there is no noticeable performance - difference between Emacs running in unibyte or multibyte mode. */ - int maxlen = strlen (it->s) - IT_BYTEPOS (*it); - it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len); - } + it->c = string_char_and_length (it->s + IT_BYTEPOS (*it), &it->len); else it->c = it->s[IT_BYTEPOS (*it)], it->len = 1; @@ -6370,8 +6557,7 @@ next_element_from_c_string (it) ellipsis if an ellipsis is to be displayed. */ static int -next_element_from_ellipsis (it) - struct it *it; +next_element_from_ellipsis (struct it *it) { if (it->selective_display_ellipsis_p) setup_for_ellipsis (it, it->len); @@ -6398,8 +6584,7 @@ next_element_from_ellipsis (it) static int -next_element_from_image (it) - struct it *it; +next_element_from_image (struct it *it) { it->what = IT_IMAGE; it->ignore_overlay_strings_at_pos_p = 0; @@ -6412,13 +6597,52 @@ next_element_from_image (it) always 1. */ static int -next_element_from_stretch (it) - struct it *it; +next_element_from_stretch (struct it *it) { it->what = IT_STRETCH; return 1; } +/* Scan forward from CHARPOS in the current buffer, until we find a + stop position > current IT's position. Then handle the stop + position before that. This is called when we bump into a stop + position while reordering bidirectional text. CHARPOS should be + the last previously processed stop_pos (or BEGV, if none were + processed yet) whose position is less that IT's current + position. */ + +static void +handle_stop_backwards (struct it *it, EMACS_INT charpos) +{ + EMACS_INT where_we_are = IT_CHARPOS (*it); + struct display_pos save_current = it->current; + struct text_pos save_position = it->position; + struct text_pos pos1; + EMACS_INT next_stop; + + /* Scan in strict logical order. */ + it->bidi_p = 0; + do + { + it->prev_stop = charpos; + SET_TEXT_POS (pos1, charpos, CHAR_TO_BYTE (charpos)); + reseat_1 (it, pos1, 0); + compute_stop_pos (it); + /* We must advance forward, right? */ + if (it->stop_charpos <= it->prev_stop) + abort (); + charpos = it->stop_charpos; + } + while (charpos <= where_we_are); + + next_stop = it->stop_charpos; + it->stop_charpos = it->prev_stop; + it->bidi_p = 1; + it->current = save_current; + it->position = save_position; + handle_stop (it); + it->stop_charpos = next_stop; +} /* Load IT with the next display element from current_buffer. Value is zero if end of buffer reached. IT->stop_charpos is the next @@ -6426,13 +6650,73 @@ next_element_from_stretch (it) end. */ static int -next_element_from_buffer (it) - struct it *it; +next_element_from_buffer (struct it *it) { int success_p = 1; xassert (IT_CHARPOS (*it) >= BEGV); + /* With bidi reordering, the character to display might not be the + character at IT_CHARPOS. BIDI_IT.FIRST_ELT non-zero means that + we were reseat()ed to a new buffer position, which is potentially + a different paragraph. */ + if (it->bidi_p && it->bidi_it.first_elt) + { + it->bidi_it.charpos = IT_CHARPOS (*it); + it->bidi_it.bytepos = IT_BYTEPOS (*it); + if (it->bidi_it.bytepos == ZV_BYTE) + { + /* Nothing to do, but reset the FIRST_ELT flag, like + bidi_paragraph_init does, because we are not going to + call it. */ + it->bidi_it.first_elt = 0; + } + else if (it->bidi_it.bytepos == BEGV_BYTE + /* FIXME: Should support all Unicode line separators. */ + || FETCH_CHAR (it->bidi_it.bytepos - 1) == '\n' + || FETCH_CHAR (it->bidi_it.bytepos) == '\n') + { + /* If we are at the beginning of a line, we can produce the + next element right away. */ + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); + bidi_move_to_visually_next (&it->bidi_it); + } + else + { + EMACS_INT orig_bytepos = IT_BYTEPOS (*it); + + /* We need to prime the bidi iterator starting at the line's + beginning, before we will be able to produce the next + element. */ + IT_CHARPOS (*it) = find_next_newline_no_quit (IT_CHARPOS (*it), -1); + IT_BYTEPOS (*it) = CHAR_TO_BYTE (IT_CHARPOS (*it)); + it->bidi_it.charpos = IT_CHARPOS (*it); + it->bidi_it.bytepos = IT_BYTEPOS (*it); + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1); + do + { + /* Now return to buffer position where we were asked to + get the next display element, and produce that. */ + bidi_move_to_visually_next (&it->bidi_it); + } + while (it->bidi_it.bytepos != orig_bytepos + && it->bidi_it.bytepos < ZV_BYTE); + } + + it->bidi_it.first_elt = 0; /* paranoia: bidi.c does this */ + /* Adjust IT's position information to where we ended up. */ + IT_CHARPOS (*it) = it->bidi_it.charpos; + IT_BYTEPOS (*it) = it->bidi_it.bytepos; + SET_TEXT_POS (it->position, IT_CHARPOS (*it), IT_BYTEPOS (*it)); + { + EMACS_INT stop = it->end_charpos; + if (it->bidi_it.scan_dir < 0) + stop = -1; + composition_compute_stop_pos (&it->cmp_it, IT_CHARPOS (*it), + IT_BYTEPOS (*it), stop, Qnil); + } + } + if (IT_CHARPOS (*it) >= it->stop_charpos) { if (IT_CHARPOS (*it) >= it->end_charpos) @@ -6458,17 +6742,57 @@ next_element_from_buffer (it) success_p = 0; } } + else if (!(!it->bidi_p + || BIDI_AT_BASE_LEVEL (it->bidi_it) + || IT_CHARPOS (*it) == it->stop_charpos)) + { + /* With bidi non-linear iteration, we could find ourselves + far beyond the last computed stop_charpos, with several + other stop positions in between that we missed. Scan + them all now, in buffer's logical order, until we find + and handle the last stop_charpos that precedes our + current position. */ + handle_stop_backwards (it, it->stop_charpos); + return GET_NEXT_DISPLAY_ELEMENT (it); + } else { + if (it->bidi_p) + { + /* Take note of the stop position we just moved across, + for when we will move back across it. */ + it->prev_stop = it->stop_charpos; + /* If we are at base paragraph embedding level, take + note of the last stop position seen at this + level. */ + if (BIDI_AT_BASE_LEVEL (it->bidi_it)) + it->base_level_stop = it->stop_charpos; + } handle_stop (it); return GET_NEXT_DISPLAY_ELEMENT (it); } } + else if (it->bidi_p + /* We can sometimes back up for reasons that have nothing + to do with bidi reordering. E.g., compositions. The + code below is only needed when we are above the base + embedding level, so test for that explicitly. */ + && !BIDI_AT_BASE_LEVEL (it->bidi_it) + && IT_CHARPOS (*it) < it->prev_stop) + { + if (it->base_level_stop <= 0) + it->base_level_stop = BEGV; + if (IT_CHARPOS (*it) < it->base_level_stop) + abort (); + handle_stop_backwards (it, it->base_level_stop); + return GET_NEXT_DISPLAY_ELEMENT (it); + } else { /* No face changes, overlays etc. in sight, so just return a character from current_buffer. */ unsigned char *p; + EMACS_INT stop; /* Maybe run the redisplay end trigger hook. Performance note: This doesn't seem to cost measurable time. */ @@ -6477,8 +6801,9 @@ next_element_from_buffer (it) && IT_CHARPOS (*it) >= it->redisplay_end_trigger_charpos) run_redisplay_end_trigger_hook (it); + stop = it->bidi_it.scan_dir < 0 ? -1 : it->end_charpos; if (CHAR_COMPOSED_P (it, IT_CHARPOS (*it), IT_BYTEPOS (*it), - it->end_charpos) + stop) && next_element_from_composition (it)) { return 1; @@ -6534,8 +6859,7 @@ next_element_from_buffer (it) /* Run the redisplay end trigger hook for IT. */ static void -run_redisplay_end_trigger_hook (it) - struct it *it; +run_redisplay_end_trigger_hook (struct it *it) { Lisp_Object args[3]; @@ -6565,8 +6889,7 @@ run_redisplay_end_trigger_hook (it) next_element_from_string when necessary. */ static int -next_element_from_composition (it) - struct it *it; +next_element_from_composition (struct it *it) { it->what = IT_COMPOSITION; it->len = it->cmp_it.nbytes; @@ -6589,6 +6912,15 @@ next_element_from_composition (it) { IT_CHARPOS (*it) += it->cmp_it.nchars; IT_BYTEPOS (*it) += it->cmp_it.nbytes; + if (it->bidi_p) + { + if (it->bidi_it.new_paragraph) + bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 0); + /* Resync the bidi iterator with IT's new position. + FIXME: this doesn't support bidirectional text. */ + while (it->bidi_it.charpos < IT_CHARPOS (*it)) + bidi_move_to_visually_next (&it->bidi_it); + } return 0; } it->position = it->current.pos; @@ -6618,9 +6950,9 @@ next_element_from_composition (it) line on the display without producing glyphs. OP should be a bit mask including some or all of these bits: - MOVE_TO_X: Stop on reaching x-position TO_X. - MOVE_TO_POS: Stop on reaching buffer or string position TO_CHARPOS. - Regardless of OP's value, stop in reaching the end of the display line. + MOVE_TO_X: Stop upon reaching x-position TO_X. + MOVE_TO_POS: Stop upon reaching buffer or string position TO_CHARPOS. + Regardless of OP's value, stop upon reaching the end of the display line. TO_X is normally a value 0 <= TO_X <= IT->last_visible_x. This means, in particular, that TO_X includes window's horizontal @@ -6656,6 +6988,8 @@ move_it_in_display_line_to (struct it *it, struct glyph_row *saved_glyph_row; struct it wrap_it, atpos_it, atx_it; int may_wrap = 0; + enum it_method prev_method = it->method; + EMACS_INT prev_pos = IT_CHARPOS (*it); /* Don't produce glyphs in produce_glyphs. */ saved_glyph_row = it->glyph_row; @@ -6673,7 +7007,8 @@ move_it_in_display_line_to (struct it *it, #define BUFFER_POS_REACHED_P() \ ((op & MOVE_TO_POS) != 0 \ && BUFFERP (it->object) \ - && IT_CHARPOS (*it) >= to_charpos \ + && (IT_CHARPOS (*it) == to_charpos \ + || (!it->bidi_p && IT_CHARPOS (*it) > to_charpos)) \ && (it->method == GET_FROM_BUFFER \ || (it->method == GET_FROM_DISPLAY_VECTOR \ && it->dpvec + it->current.dpvec_index + 1 >= it->dpend))) @@ -6697,7 +7032,16 @@ move_it_in_display_line_to (struct it *it, if ((op & MOVE_TO_POS) != 0 && BUFFERP (it->object) && it->method == GET_FROM_BUFFER - && IT_CHARPOS (*it) > to_charpos) + && ((!it->bidi_p && IT_CHARPOS (*it) > to_charpos) + || (it->bidi_p + && (prev_method == GET_FROM_IMAGE + || prev_method == GET_FROM_STRETCH) + /* Passed TO_CHARPOS from left to right. */ + && ((prev_pos < to_charpos + && IT_CHARPOS (*it) > to_charpos) + /* Passed TO_CHARPOS from right to left. */ + || (prev_pos > to_charpos + && IT_CHARPOS (*it) < to_charpos))))) { if (it->line_wrap != WORD_WRAP || wrap_it.sp < 0) { @@ -6711,6 +7055,9 @@ move_it_in_display_line_to (struct it *it, atpos_it = *it; } + prev_method = it->method; + if (it->method == GET_FROM_BUFFER) + prev_pos = IT_CHARPOS (*it); /* Stop when ZV reached. We used to stop here when TO_CHARPOS reached as well, but that is too soon if this glyph does not fit on this line. So we handle it @@ -6976,6 +7323,8 @@ move_it_in_display_line_to (struct it *it, break; } + if (it->method == GET_FROM_BUFFER) + prev_pos = IT_CHARPOS (*it); /* The current display element has been consumed. Advance to the next. */ set_iterator_to_next (it, 1); @@ -7063,10 +7412,7 @@ move_it_in_display_line (struct it *it, TO_CHARPOS. */ void -move_it_to (it, to_charpos, to_x, to_y, to_vpos, op) - struct it *it; - int to_charpos, to_x, to_y, to_vpos; - int op; +move_it_to (struct it *it, EMACS_INT to_charpos, int to_x, int to_y, int to_vpos, int op) { enum move_it_result skip, skip2 = MOVE_X_REACHED; int line_height, line_start_x = 0, reached = 0; @@ -7317,13 +7663,11 @@ move_it_to (it, to_charpos, to_x, to_y, to_vpos, op) set to the top of the line moved to. */ void -move_it_vertically_backward (it, dy) - struct it *it; - int dy; +move_it_vertically_backward (struct it *it, int dy) { int nlines, h; struct it it2, it3; - int start_pos; + EMACS_INT start_pos; move_further_back: xassert (dy >= 0); @@ -7438,9 +7782,7 @@ move_it_vertically_backward (it, dy) end, IT will be on the start of a screen line. */ void -move_it_vertically (it, dy) - struct it *it; - int dy; +move_it_vertically (struct it *it, int dy) { if (dy <= 0) move_it_vertically_backward (it, -dy); @@ -7464,8 +7806,7 @@ move_it_vertically (it, dy) /* Move iterator IT past the end of the text line it is in. */ void -move_it_past_eol (it) - struct it *it; +move_it_past_eol (struct it *it) { enum move_it_result rc; @@ -7485,16 +7826,14 @@ move_it_past_eol (it) truncate-lines nil. */ void -move_it_by_lines (it, dvpos, need_y_p) - struct it *it; - int dvpos, need_y_p; +move_it_by_lines (struct it *it, int dvpos, int need_y_p) { - struct position pos; /* The commented-out optimization uses vmotion on terminals. This gives bad results, because elements like it->what, on which callers such as pos_visible_p rely, aren't updated. */ - /* if (!FRAME_WINDOW_P (it->f)) + /* struct position pos; + if (!FRAME_WINDOW_P (it->f)) { struct text_pos textpos; @@ -7523,7 +7862,7 @@ move_it_by_lines (it, dvpos, need_y_p) else { struct it it2; - int start_charpos, i; + EMACS_INT start_charpos, i; /* Start at the beginning of the screen line containing IT's position. This may actually move vertically backwards, @@ -7581,8 +7920,7 @@ move_it_by_lines (it, dvpos, need_y_p) /* Return 1 if IT points into the middle of a display vector. */ int -in_display_vector_p (it) - struct it *it; +in_display_vector_p (struct it *it) { return (it->method == GET_FROM_DISPLAY_VECTOR && it->current.dpvec_index > 0 @@ -7599,14 +7937,12 @@ in_display_vector_p (it) to *Messages*. */ void -add_to_log (format, arg1, arg2) - char *format; - Lisp_Object arg1, arg2; +add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2) { Lisp_Object args[3]; Lisp_Object msg, fmt; char *buffer; - int len; + EMACS_INT len; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; USE_SAFE_ALLOCA; @@ -7626,7 +7962,7 @@ add_to_log (format, arg1, arg2) len = SBYTES (msg) + 1; SAFE_ALLOCA (buffer, char *, len); - bcopy (SDATA (msg), buffer, len); + memcpy (buffer, SDATA (msg), len); message_dolog (buffer, len - 1, 1, 0); SAFE_FREE (); @@ -7638,7 +7974,7 @@ add_to_log (format, arg1, arg2) /* Output a newline in the *Messages* buffer if "needs" one. */ void -message_log_maybe_newline () +message_log_maybe_newline (void) { if (message_log_need_newline) message_dolog ("", 0, 1, 0); @@ -7655,9 +7991,7 @@ message_log_maybe_newline () so the buffer M must NOT point to a Lisp string. */ void -message_dolog (m, nbytes, nlflag, multibyte) - const char *m; - int nbytes, nlflag, multibyte; +message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) { if (!NILP (Vmemory_full)) return; @@ -7667,8 +8001,8 @@ message_dolog (m, nbytes, nlflag, multibyte) struct buffer *oldbuf; Lisp_Object oldpoint, oldbegv, oldzv; int old_windows_or_buffers_changed = windows_or_buffers_changed; - int point_at_end = 0; - int zv_at_end = 0; + EMACS_INT point_at_end = 0; + EMACS_INT zv_at_end = 0; Lisp_Object old_deactivate_mark, tem; struct gcpro gcpro1; @@ -7701,7 +8035,8 @@ message_dolog (m, nbytes, nlflag, multibyte) if (multibyte && NILP (current_buffer->enable_multibyte_characters)) { - int i, c, char_bytes; + EMACS_INT i; + int c, char_bytes; unsigned char work[1]; /* Convert a multibyte string to single-byte @@ -7718,7 +8053,8 @@ message_dolog (m, nbytes, nlflag, multibyte) else if (! multibyte && ! NILP (current_buffer->enable_multibyte_characters)) { - int i, c, char_bytes; + EMACS_INT i; + int c, char_bytes; unsigned char *msg = (unsigned char *) m; unsigned char str[MAX_MULTIBYTE_LENGTH]; /* Convert a single-byte string to multibyte @@ -7736,7 +8072,8 @@ message_dolog (m, nbytes, nlflag, multibyte) if (nlflag) { - int this_bol, this_bol_byte, prev_bol, prev_bol_byte, dup; + EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte; + int dup; insert_1 ("\n", 1, 1, 0, 0); scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); @@ -7827,12 +8164,11 @@ message_dolog (m, nbytes, nlflag, multibyte) value N > 1 if we should also append " [N times]". */ static int -message_log_check_duplicate (prev_bol, prev_bol_byte, this_bol, this_bol_byte) - int prev_bol, this_bol; - int prev_bol_byte, this_bol_byte; +message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte, + EMACS_INT this_bol, EMACS_INT this_bol_byte) { - int i; - int len = Z_BYTE - 1 - this_bol_byte; + EMACS_INT i; + EMACS_INT len = Z_BYTE - 1 - this_bol_byte; int seen_dots = 0; unsigned char *p1 = BUF_BYTE_ADDRESS (current_buffer, prev_bol_byte); unsigned char *p2 = BUF_BYTE_ADDRESS (current_buffer, this_bol_byte); @@ -7867,10 +8203,7 @@ message_log_check_duplicate (prev_bol, prev_bol_byte, this_bol, this_bol_byte) This may GC, so the buffer M must NOT point to a Lisp string. */ void -message2 (m, nbytes, multibyte) - const char *m; - int nbytes; - int multibyte; +message2 (const char *m, EMACS_INT nbytes, int multibyte) { /* First flush out any partial line written with print. */ message_log_maybe_newline (); @@ -7883,9 +8216,7 @@ message2 (m, nbytes, multibyte) /* The non-logging counterpart of message2. */ void -message2_nolog (m, nbytes, multibyte) - const char *m; - int nbytes, multibyte; +message2_nolog (const char *m, EMACS_INT nbytes, int multibyte) { struct frame *sf = SELECTED_FRAME (); message_enable_multibyte = multibyte; @@ -7947,10 +8278,7 @@ message2_nolog (m, nbytes, multibyte) This function cancels echoing. */ void -message3 (m, nbytes, multibyte) - Lisp_Object m; - int nbytes; - int multibyte; +message3 (Lisp_Object m, EMACS_INT nbytes, int multibyte) { struct gcpro gcpro1; @@ -7966,7 +8294,7 @@ message3 (m, nbytes, multibyte) USE_SAFE_ALLOCA; SAFE_ALLOCA (buffer, char *, nbytes); - bcopy (SDATA (m), buffer, nbytes); + memcpy (buffer, SDATA (m), nbytes); message_dolog (buffer, nbytes, 1, multibyte); SAFE_FREE (); } @@ -7982,9 +8310,7 @@ message3 (m, nbytes, multibyte) and make this cancel echoing. */ void -message3_nolog (m, nbytes, multibyte) - Lisp_Object m; - int nbytes, multibyte; +message3_nolog (Lisp_Object m, EMACS_INT nbytes, int multibyte) { struct frame *sf = SELECTED_FRAME (); message_enable_multibyte = multibyte; @@ -8052,8 +8378,7 @@ message3_nolog (m, nbytes, multibyte) that was alloca'd. */ void -message1 (m) - char *m; +message1 (const char *m) { message2 (m, (m ? strlen (m) : 0), 0); } @@ -8062,8 +8387,7 @@ message1 (m) /* The non-logging counterpart of message1. */ void -message1_nolog (m) - char *m; +message1_nolog (const char *m) { message2_nolog (m, (m ? strlen (m) : 0), 0); } @@ -8072,10 +8396,7 @@ message1_nolog (m) which gets replaced with STRING. */ void -message_with_string (m, string, log) - char *m; - Lisp_Object string; - int log; +message_with_string (const char *m, Lisp_Object string, int log) { CHECK_STRING (string); @@ -8138,11 +8459,8 @@ message_with_string (m, string, log) /* Dump an informative message to the minibuf. If M is 0, clear out any existing message, and let the mini-buffer text show through. */ -/* VARARGS 1 */ -void -message (m, a1, a2, a3) - char *m; - EMACS_INT a1, a2, a3; +static void +vmessage (const char *m, va_list ap) { if (noninteractive) { @@ -8151,7 +8469,7 @@ message (m, a1, a2, a3) if (noninteractive_need_newline) putc ('\n', stderr); noninteractive_need_newline = 0; - fprintf (stderr, m, a1, a2, a3); + vfprintf (stderr, m, ap); if (cursor_in_echo_area == 0) fprintf (stderr, "\n"); fflush (stderr); @@ -8178,20 +8496,10 @@ message (m, a1, a2, a3) { if (m) { - int len; -#ifdef NO_ARG_ARRAY - char *a[3]; - a[0] = (char *) a1; - a[1] = (char *) a2; - a[2] = (char *) a3; + EMACS_INT len; len = doprnt (FRAME_MESSAGE_BUF (f), - FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, 3, a); -#else - len = doprnt (FRAME_MESSAGE_BUF (f), - FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, 3, - (char **) &a1); -#endif /* NO_ARG_ARRAY */ + FRAME_MESSAGE_BUF_SIZE (f), m, (char *)0, ap); message2 (FRAME_MESSAGE_BUF (f), len, 0); } @@ -8205,19 +8513,29 @@ message (m, a1, a2, a3) } } +void +message (const char *m, ...) +{ + va_list ap; + va_start (ap, m); + vmessage (m, ap); + va_end (ap); +} + /* The non-logging version of message. */ void -message_nolog (m, a1, a2, a3) - char *m; - EMACS_INT a1, a2, a3; +message_nolog (const char *m, ...) { Lisp_Object old_log_max; + va_list ap; + va_start (ap, m); old_log_max = Vmessage_log_max; Vmessage_log_max = Qnil; - message (m, a1, a2, a3); + vmessage (m, ap); Vmessage_log_max = old_log_max; + va_end (ap); } @@ -8226,7 +8544,7 @@ message_nolog (m, a1, a2, a3) critical. */ void -update_echo_area () +update_echo_area (void) { if (!NILP (echo_area_buffer[0])) { @@ -8242,7 +8560,7 @@ update_echo_area () If they aren't, make new ones. */ static void -ensure_echo_area_buffers () +ensure_echo_area_buffers (void) { int i; @@ -8286,13 +8604,9 @@ ensure_echo_area_buffers () Value is what FN returns. */ static int -with_echo_area_buffer (w, which, fn, a1, a2, a3, a4) - struct window *w; - int which; - int (*fn) P_ ((EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT)); - EMACS_INT a1; - Lisp_Object a2; - EMACS_INT a3, a4; +with_echo_area_buffer (struct window *w, int which, + int (*fn) (EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT), + EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) { Lisp_Object buffer; int this_one, the_other, clear_buffer_p, rc; @@ -8379,8 +8693,7 @@ with_echo_area_buffer (w, which, fn, a1, a2, a3, a4) FN called in with_echo_area_buffer. */ static Lisp_Object -with_echo_area_buffer_unwind_data (w) - struct window *w; +with_echo_area_buffer_unwind_data (struct window *w) { int i = 0; Lisp_Object vector, tmp; @@ -8420,8 +8733,7 @@ with_echo_area_buffer_unwind_data (w) with_echo_area_buffer_unwind_data. */ static Lisp_Object -unwind_with_echo_area_buffer (vector) - Lisp_Object vector; +unwind_with_echo_area_buffer (Lisp_Object vector) { set_buffer_internal_1 (XBUFFER (AREF (vector, 0))); Vdeactivate_mark = AREF (vector, 1); @@ -8451,8 +8763,7 @@ unwind_with_echo_area_buffer (vector) non-zero means we will print multibyte. */ void -setup_echo_area_for_printing (multibyte_p) - int multibyte_p; +setup_echo_area_for_printing (int multibyte_p) { /* If we can't find an echo area any more, exit. */ if (! FRAME_LIVE_P (XFRAME (selected_frame))) @@ -8526,8 +8837,7 @@ setup_echo_area_for_printing (multibyte_p) display the current message. */ static int -display_echo_area (w) - struct window *w; +display_echo_area (struct window *w) { int i, no_message_p, window_height_changed_p, count; @@ -8565,10 +8875,7 @@ display_echo_area (w) Value is non-zero if height of W was changed. */ static int -display_echo_area_1 (a1, a2, a3, a4) - EMACS_INT a1; - Lisp_Object a2; - EMACS_INT a3, a4; +display_echo_area_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) { struct window *w = (struct window *) a1; Lisp_Object window; @@ -8597,7 +8904,7 @@ display_echo_area_1 (a1, a2, a3, a4) is active, don't shrink it. */ void -resize_echo_area_exactly () +resize_echo_area_exactly (void) { if (BUFFERP (echo_area_buffer[0]) && WINDOWP (echo_area_window)) @@ -8630,10 +8937,7 @@ resize_echo_area_exactly () resize_mini_window returns. */ static int -resize_mini_window_1 (a1, exactly, a3, a4) - EMACS_INT a1; - Lisp_Object exactly; - EMACS_INT a3, a4; +resize_mini_window_1 (EMACS_INT a1, Lisp_Object exactly, EMACS_INT a3, EMACS_INT a4) { return resize_mini_window ((struct window *) a1, !NILP (exactly)); } @@ -8651,9 +8955,7 @@ resize_mini_window_1 (a1, exactly, a3, a4) Value is non-zero if the window height has been changed. */ int -resize_mini_window (w, exact_p) - struct window *w; - int exact_p; +resize_mini_window (struct window *w, int exact_p) { struct frame *f = XFRAME (w->frame); int window_height_changed_p = 0; @@ -8794,7 +9096,7 @@ resize_mini_window (w, exact_p) current message. */ Lisp_Object -current_message () +current_message (void) { Lisp_Object msg; @@ -8813,10 +9115,7 @@ current_message () static int -current_message_1 (a1, a2, a3, a4) - EMACS_INT a1; - Lisp_Object a2; - EMACS_INT a3, a4; +current_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) { Lisp_Object *msg = (Lisp_Object *) a1; @@ -8834,7 +9133,7 @@ current_message_1 (a1, a2, a3, a4) worth optimizing. */ int -push_message () +push_message (void) { Lisp_Object msg; msg = current_message (); @@ -8846,7 +9145,7 @@ push_message () /* Restore message display from the top of Vmessage_stack. */ void -restore_message () +restore_message (void) { Lisp_Object msg; @@ -8862,8 +9161,7 @@ restore_message () /* Handler for record_unwind_protect calling pop_message. */ Lisp_Object -pop_message_unwind (dummy) - Lisp_Object dummy; +pop_message_unwind (Lisp_Object dummy) { pop_message (); return Qnil; @@ -8872,7 +9170,7 @@ pop_message_unwind (dummy) /* Pop the top-most entry off Vmessage_stack. */ void -pop_message () +pop_message (void) { xassert (CONSP (Vmessage_stack)); Vmessage_stack = XCDR (Vmessage_stack); @@ -8884,7 +9182,7 @@ pop_message () somewhere. */ void -check_message_stack () +check_message_stack (void) { if (!NILP (Vmessage_stack)) abort (); @@ -8895,8 +9193,7 @@ check_message_stack () time we display it---but don't redisplay it now. */ void -truncate_echo_area (nchars) - int nchars; +truncate_echo_area (EMACS_INT nchars) { if (nchars == 0) echo_area_buffer[0] = Qnil; @@ -8918,10 +9215,7 @@ truncate_echo_area (nchars) message to at most NCHARS characters. */ static int -truncate_message_1 (nchars, a2, a3, a4) - EMACS_INT nchars; - Lisp_Object a2; - EMACS_INT a3, a4; +truncate_message_1 (EMACS_INT nchars, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) { if (BEG + nchars < Z) del_range (BEG + nchars, Z); @@ -8946,10 +9240,8 @@ truncate_message_1 (nchars, a2, a3, a4) */ void -set_message (s, string, nbytes, multibyte_p) - const char *s; - Lisp_Object string; - int nbytes, multibyte_p; +set_message (const char *s, Lisp_Object string, + EMACS_INT nbytes, int multibyte_p) { message_enable_multibyte = ((s && multibyte_p) @@ -8968,10 +9260,7 @@ set_message (s, string, nbytes, multibyte_p) current. */ static int -set_message_1 (a1, a2, nbytes, multibyte_p) - EMACS_INT a1; - Lisp_Object a2; - EMACS_INT nbytes, multibyte_p; +set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multibyte_p) { const char *s = (const char *) a1; Lisp_Object string = a2; @@ -8988,7 +9277,7 @@ set_message_1 (a1, a2, nbytes, multibyte_p) if (STRINGP (string)) { - int nchars; + EMACS_INT nchars; if (nbytes == 0) nbytes = SBYTES (string); @@ -9007,7 +9296,8 @@ set_message_1 (a1, a2, nbytes, multibyte_p) if (multibyte_p && NILP (current_buffer->enable_multibyte_characters)) { /* Convert from multi-byte to single-byte. */ - int i, c, n; + EMACS_INT i; + int c, n; unsigned char work[1]; /* Convert a multibyte string to single-byte. */ @@ -9024,7 +9314,8 @@ set_message_1 (a1, a2, nbytes, multibyte_p) && !NILP (current_buffer->enable_multibyte_characters)) { /* Convert from single-byte to multi-byte. */ - int i, c, n; + EMACS_INT i; + int c, n; const unsigned char *msg = (const unsigned char *) s; unsigned char str[MAX_MULTIBYTE_LENGTH]; @@ -9050,8 +9341,7 @@ set_message_1 (a1, a2, nbytes, multibyte_p) last displayed. */ void -clear_message (current_p, last_displayed_p) - int current_p, last_displayed_p; +clear_message (int current_p, int last_displayed_p) { if (current_p) { @@ -9075,7 +9365,7 @@ clear_message (current_p, last_displayed_p) and ensure a complete redisplay of all windows. */ static void -clear_garbaged_frames () +clear_garbaged_frames (void) { if (frame_garbaged) { @@ -9112,8 +9402,7 @@ clear_garbaged_frames () mini-windows height has been changed. */ static int -echo_area_display (update_frame_p) - int update_frame_p; +echo_area_display (int update_frame_p) { Lisp_Object mini_window; struct window *w; @@ -9288,8 +9577,7 @@ format_mode_line_unwind_data (struct buffer *obuf, } static Lisp_Object -unwind_format_mode_line (vector) - Lisp_Object vector; +unwind_format_mode_line (Lisp_Object vector) { mode_line_target = XINT (AREF (vector, 0)); mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); @@ -9318,12 +9606,7 @@ unwind_format_mode_line (vector) Re-allocate mode_line_noprop_buf if necessary. */ static void -#ifdef PROTOTYPES store_mode_line_noprop_char (char c) -#else -store_mode_line_noprop_char (c) - char c; -#endif { /* If output position has reached the end of the allocated buffer, double the buffer's size. */ @@ -9349,12 +9632,10 @@ store_mode_line_noprop_char (c) frame title. */ static int -store_mode_line_noprop (str, field_width, precision) - const unsigned char *str; - int field_width, precision; +store_mode_line_noprop (const unsigned char *str, int field_width, int precision) { int n = 0; - int dummy, nbytes; + EMACS_INT dummy, nbytes; /* Copy at most PRECISION chars from STR. */ nbytes = strlen (str); @@ -9384,8 +9665,7 @@ store_mode_line_noprop (str, field_width, precision) frame_title_format. */ static void -x_consider_frame_title (frame) - Lisp_Object frame; +x_consider_frame_title (Lisp_Object frame) { struct frame *f = XFRAME (frame); @@ -9445,7 +9725,7 @@ x_consider_frame_title (frame) higher level than this.) */ if (! STRINGP (f->name) || SBYTES (f->name) != len - || bcmp (title, SDATA (f->name), len) != 0) + || memcmp (title, SDATA (f->name), len) != 0) x_implicitly_set_name (f, make_string (title, len), Qnil); } } @@ -9464,7 +9744,7 @@ x_consider_frame_title (frame) appropriate. This can call eval. */ void -prepare_menu_bars () +prepare_menu_bars (void) { int all_windows; struct gcpro gcpro1, gcpro2; @@ -9562,12 +9842,6 @@ prepare_menu_bars () update_tool_bar (sf, 1); #endif } - - /* Motif needs this. See comment in xmenu.c. Turn it off when - pending_menu_activation is not defined. */ -#ifdef USE_X_TOOLKIT - pending_menu_activation = 0; -#endif } @@ -9583,10 +9857,7 @@ prepare_menu_bars () updated value of this flag, to pass to the next call. */ static int -update_menu_bar (f, save_match_data, hooks_run) - struct frame *f; - int save_match_data; - int hooks_run; +update_menu_bar (struct frame *f, int save_match_data, int hooks_run) { Lisp_Object window; register struct window *w; @@ -9711,8 +9982,7 @@ struct cursor_pos output_cursor; positions are relative to updated_window. */ void -set_output_cursor (cursor) - struct cursor_pos *cursor; +set_output_cursor (struct cursor_pos *cursor) { output_cursor.hpos = cursor->hpos; output_cursor.vpos = cursor->vpos; @@ -9733,8 +10003,7 @@ set_output_cursor (cursor) selected_window and display the cursor at the given position. */ void -x_cursor_to (vpos, hpos, y, x) - int vpos, hpos, y, x; +x_cursor_to (int vpos, int hpos, int y, int x) { struct window *w; @@ -9782,8 +10051,7 @@ int last_tool_bar_item; static Lisp_Object -update_tool_bar_unwind (frame) - Lisp_Object frame; +update_tool_bar_unwind (Lisp_Object frame) { selected_frame = frame; return Qnil; @@ -9795,9 +10063,7 @@ update_tool_bar_unwind (frame) and restore it here. */ static void -update_tool_bar (f, save_match_data) - struct frame *f; - int save_match_data; +update_tool_bar (struct frame *f, int save_match_data) { #if defined (USE_GTK) || defined (HAVE_NS) int do_update = FRAME_EXTERNAL_TOOL_BAR (f); @@ -9895,8 +10161,7 @@ update_tool_bar (f, save_match_data) been set up previously by calling prepare_menu_bars. */ static void -build_desired_tool_bar_string (f) - struct frame *f; +build_desired_tool_bar_string (struct frame *f) { int i, size, size_needed; struct gcpro gcpro1, gcpro2, gcpro3; @@ -9937,7 +10202,6 @@ build_desired_tool_bar_string (f) int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); int hmargin, vmargin, relief, idx, end; - extern Lisp_Object QCrelief, QCmargin, QCconversion; /* If image is a vector, choose the image according to the button state. */ @@ -10067,9 +10331,7 @@ build_desired_tool_bar_string (f) */ static void -display_tool_bar_line (it, height) - struct it *it; - int height; +display_tool_bar_line (struct it *it, int height) { struct glyph_row *row = it->glyph_row; int max_x = it->last_visible_x; @@ -10196,9 +10458,7 @@ display_tool_bar_line (it, height) returned in *N_ROWS if non-NULL. */ static int -tool_bar_lines_needed (f, n_rows) - struct frame *f; - int *n_rows; +tool_bar_lines_needed (struct frame *f, int *n_rows) { struct window *w = XWINDOW (f->tool_bar_window); struct it it; @@ -10233,8 +10493,7 @@ tool_bar_lines_needed (f, n_rows) DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed, 0, 1, 0, doc: /* Return the number of lines occupied by the tool bar of FRAME. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; struct window *w; @@ -10266,8 +10525,7 @@ DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed, height should be changed. */ static int -redisplay_tool_bar (f) - struct frame *f; +redisplay_tool_bar (struct frame *f) { struct window *w; struct it it; @@ -10305,7 +10563,6 @@ redisplay_tool_bar (f) if ((nlines = tool_bar_lines_needed (f, &f->n_tool_bar_rows), nlines != WINDOW_TOTAL_LINES (w))) { - extern Lisp_Object Qtool_bar_lines; Lisp_Object frame; int old_height = WINDOW_TOTAL_LINES (w); @@ -10397,7 +10654,6 @@ redisplay_tool_bar (f) frame parameter. */ if (change_height_p) { - extern Lisp_Object Qtool_bar_lines; Lisp_Object frame; int old_height = WINDOW_TOTAL_LINES (w); int nrows; @@ -10438,10 +10694,7 @@ redisplay_tool_bar (f) GLYPH doesn't display a tool-bar item. */ static int -tool_bar_item_info (f, glyph, prop_idx) - struct frame *f; - struct glyph *glyph; - int *prop_idx; +tool_bar_item_info (struct frame *f, struct glyph *glyph, int *prop_idx) { Lisp_Object prop; int success_p; @@ -10481,11 +10734,8 @@ tool_bar_item_info (f, glyph, prop_idx) 1 otherwise. */ static int -get_tool_bar_item (f, x, y, glyph, hpos, vpos, prop_idx) - struct frame *f; - int x, y; - struct glyph **glyph; - int *hpos, *vpos, *prop_idx; +get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph, + int *hpos, int *vpos, int *prop_idx) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); struct window *w = XWINDOW (f->tool_bar_window); @@ -10523,10 +10773,8 @@ get_tool_bar_item (f, x, y, glyph, hpos, vpos, prop_idx) release. */ void -handle_tool_bar_click (f, x, y, down_p, modifiers) - struct frame *f; - int x, y, down_p; - unsigned int modifiers; +handle_tool_bar_click (struct frame *f, int x, int y, int down_p, + unsigned int modifiers) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); struct window *w = XWINDOW (f->tool_bar_window); @@ -10584,9 +10832,7 @@ handle_tool_bar_click (f, x, y, down_p, modifiers) note_mouse_highlight. */ static void -note_tool_bar_highlight (f, x, y) - struct frame *f; - int x, y; +note_tool_bar_highlight (struct frame *f, int x, int y) { Lisp_Object window = f->tool_bar_window; struct window *w = XWINDOW (window); @@ -10600,7 +10846,7 @@ note_tool_bar_highlight (f, x, y) enum draw_glyphs_face draw = DRAW_IMAGE_RAISED; int mouse_down_p, rc; - /* Function note_mouse_highlight is called with negative x(y + /* Function note_mouse_highlight is called with negative X/Y values when mouse moves outside of the frame. */ if (x <= 0 || y <= 0) { @@ -10680,8 +10926,8 @@ note_tool_bar_highlight (f, x, y) Horizontal scrolling ************************************************************************/ -static int hscroll_window_tree P_ ((Lisp_Object)); -static int hscroll_windows P_ ((Lisp_Object)); +static int hscroll_window_tree (Lisp_Object); +static int hscroll_windows (Lisp_Object); /* For all leaf windows in the window tree rooted at WINDOW, set their hscroll value so that PT is (i) visible in the window, and (ii) so @@ -10690,8 +10936,7 @@ static int hscroll_windows P_ ((Lisp_Object)); changed. */ static int -hscroll_window_tree (window) - Lisp_Object window; +hscroll_window_tree (Lisp_Object window) { int hscrolled_p = 0; int hscroll_relative_p = FLOATP (Vhscroll_step); @@ -10752,7 +10997,7 @@ hscroll_window_tree (window) struct it it; int hscroll; struct buffer *saved_current_buffer; - int pt; + EMACS_INT pt; int wanted_x; /* Find point in a display of infinite width. */ @@ -10834,8 +11079,7 @@ hscroll_window_tree (window) of WINDOW are cleared. */ static int -hscroll_windows (window) - Lisp_Object window; +hscroll_windows (Lisp_Object window) { int hscrolled_p = hscroll_window_tree (window); if (hscrolled_p) @@ -10866,7 +11110,7 @@ int debug_dvpos, debug_dy; /* Delta in characters and bytes for try_window_id. */ -int debug_delta, debug_delta_bytes; +EMACS_INT debug_delta, debug_delta_bytes; /* Values of window_end_pos and window_end_vpos at the end of try_window_id. */ @@ -10918,9 +11162,8 @@ debug_method_add (w, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) redisplay_internal for display optimization. */ static INLINE int -text_outside_line_unchanged_p (w, start, end) - struct window *w; - int start, end; +text_outside_line_unchanged_p (struct window *w, + EMACS_INT start, EMACS_INT end) { int unchanged_p = 1; @@ -10962,6 +11205,17 @@ text_outside_line_unchanged_p (w, start, end) && overlay_touches_p (Z - end)) unchanged_p = 0; } + + /* Under bidi reordering, adding or deleting a character in the + beginning of a paragraph, before the first strong directional + character, can change the base direction of the paragraph (unless + the buffer specifies a fixed paragraph direction), which will + require to redisplay the whole paragraph. It might be worthwhile + to find the paragraph limits and widen the range of redisplayed + lines to that, but for now just give up this optimization. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) + unchanged_p = 0; } return unchanged_p; @@ -10976,15 +11230,14 @@ text_outside_line_unchanged_p (w, start, end) mini-buffer if that is in use. */ void -redisplay () +redisplay (void) { redisplay_internal (0); } static Lisp_Object -overlay_arrow_string_or_property (var) - Lisp_Object var; +overlay_arrow_string_or_property (Lisp_Object var) { Lisp_Object val; @@ -10996,7 +11249,7 @@ overlay_arrow_string_or_property (var) /* Return 1 if there are any overlay-arrows in current_buffer. */ static int -overlay_arrow_in_current_buffer_p () +overlay_arrow_in_current_buffer_p (void) { Lisp_Object vlist; @@ -11022,7 +11275,7 @@ overlay_arrow_in_current_buffer_p () has changed. */ static int -overlay_arrows_changed_p () +overlay_arrows_changed_p (void) { Lisp_Object vlist; @@ -11050,8 +11303,7 @@ overlay_arrows_changed_p () /* Mark overlay arrows to be updated on next redisplay. */ static void -update_overlay_arrows (up_to_date) - int up_to_date; +update_overlay_arrows (int up_to_date) { Lisp_Object vlist; @@ -11087,9 +11339,7 @@ update_overlay_arrows (up_to_date) Return nil if no overlay arrow. */ static Lisp_Object -overlay_arrow_at_row (it, row) - struct it *it; - struct glyph_row *row; +overlay_arrow_at_row (struct it *it, struct glyph_row *row) { Lisp_Object vlist; @@ -11110,6 +11360,8 @@ overlay_arrow_at_row (it, row) && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val))) { if (FRAME_WINDOW_P (it->f) + /* FIXME: if ROW->reversed_p is set, this should test + the right fringe, not the left one. */ && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0) { #ifdef HAVE_WINDOW_SYSTEM @@ -11134,9 +11386,8 @@ overlay_arrow_at_row (it, row) position. BUF and PT are the current point buffer and position. */ int -check_point_in_composition (prev_buf, prev_pt, buf, pt) - struct buffer *prev_buf, *buf; - int prev_pt, pt; +check_point_in_composition (struct buffer *prev_buf, EMACS_INT prev_pt, + struct buffer *buf, EMACS_INT pt) { EMACS_INT start, end; Lisp_Object prop; @@ -11172,9 +11423,7 @@ check_point_in_composition (prev_buf, prev_pt, buf, pt) in window W. */ static INLINE void -reconsider_clip_changes (w, b) - struct window *w; - struct buffer *b; +reconsider_clip_changes (struct window *w, struct buffer *b) { if (b->clip_changed && !NILP (w->window_end_valid) @@ -11191,7 +11440,7 @@ reconsider_clip_changes (w, b) if (!b->clip_changed && BUFFERP (w->buffer) && !NILP (w->window_end_valid)) { - int pt; + EMACS_INT pt; if (w == XWINDOW (selected_window)) pt = BUF_PT (current_buffer); @@ -11213,10 +11462,9 @@ reconsider_clip_changes (w, b) directly. */ static void -select_frame_for_redisplay (frame) - Lisp_Object frame; +select_frame_for_redisplay (Lisp_Object frame) { - Lisp_Object tail, symbol, val; + Lisp_Object tail, tem; Lisp_Object old = selected_frame; struct Lisp_Symbol *sym; @@ -11224,20 +11472,18 @@ select_frame_for_redisplay (frame) selected_frame = frame; - do - { - for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail)) - if (CONSP (XCAR (tail)) - && (symbol = XCAR (XCAR (tail)), - SYMBOLP (symbol)) - && (sym = indirect_variable (XSYMBOL (symbol)), - val = sym->value, - (BUFFER_LOCAL_VALUEP (val))) - && XBUFFER_LOCAL_VALUE (val)->check_frame) - /* Use find_symbol_value rather than Fsymbol_value - to avoid an error if it is void. */ - find_symbol_value (symbol); - } while (!EQ (frame, old) && (frame = old, 1)); + do { + for (tail = XFRAME (frame)->param_alist; CONSP (tail); tail = XCDR (tail)) + if (CONSP (XCAR (tail)) + && (tem = XCAR (XCAR (tail)), + SYMBOLP (tem)) + && (sym = indirect_variable (XSYMBOL (tem)), + sym->redirect == SYMBOL_LOCALIZED) + && sym->val.blv->frame_local) + /* Use find_symbol_value rather than Fsymbol_value + to avoid an error if it is void. */ + find_symbol_value (tem); + } while (!EQ (frame, old) && (frame = old, 1)); } @@ -11257,8 +11503,7 @@ do { if (polling_stopped_here) start_polling (); \ causes some problems. */ static void -redisplay_internal (preserve_echo_area) - int preserve_echo_area; +redisplay_internal (int preserve_echo_area) { struct window *w = XWINDOW (selected_window); struct frame *f; @@ -11293,16 +11538,6 @@ redisplay_internal (preserve_echo_area) if (!f->glyphs_initialized_p) return; - /* The flag redisplay_performed_directly_p is set by - direct_output_for_insert when it already did the whole screen - update necessary. */ - if (redisplay_performed_directly_p) - { - redisplay_performed_directly_p = 0; - if (!hscroll_windows (selected_window)) - return; - } - #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) if (popup_activated ()) return; @@ -11607,7 +11842,7 @@ redisplay_internal (preserve_echo_area) { struct glyph_row *row = MATRIX_ROW (w->current_matrix, this_line_vpos + 1); - int delta, delta_bytes; + EMACS_INT delta, delta_bytes; /* We used to distinguish between two cases here, conditioned by Z - CHARPOS (tlendpos) == ZV, for @@ -11963,22 +12198,25 @@ redisplay_internal (preserve_echo_area) if (windows_or_buffers_changed && !pause) goto retry; - /* Clear the face cache eventually. */ - if (consider_all_windows_p) + /* Clear the face and image caches. + + We used to do this only if consider_all_windows_p. But the cache + needs to be cleared if a timer creates images in the current + buffer (e.g. the test case in Bug#6230). */ + + if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT) { - if (clear_face_cache_count > CLEAR_FACE_CACHE_COUNT) - { - clear_face_cache (0); - clear_face_cache_count = 0; - } + clear_face_cache (0); + clear_face_cache_count = 0; + } + #ifdef HAVE_WINDOW_SYSTEM - if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT) - { - clear_image_caches (Qnil); - clear_image_cache_count = 0; - } -#endif /* HAVE_WINDOW_SYSTEM */ + if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT) + { + clear_image_caches (Qnil); + clear_image_cache_count = 0; } +#endif /* HAVE_WINDOW_SYSTEM */ end_of_redisplay: unbind_to (count, Qnil); @@ -11998,8 +12236,7 @@ redisplay_internal (preserve_echo_area) called. This is useful for debugging. */ void -redisplay_preserve_echo_area (from_where) - int from_where; +redisplay_preserve_echo_area (int from_where) { TRACE ((stderr, "redisplay_preserve_echo_area (%d)\n", from_where)); @@ -12028,8 +12265,7 @@ redisplay_preserve_echo_area (from_where) failure during redisplay, for example). */ static Lisp_Object -unwind_redisplay (val) - Lisp_Object val; +unwind_redisplay (Lisp_Object val) { Lisp_Object old_redisplaying_p, old_frame; @@ -12049,9 +12285,7 @@ unwind_redisplay (val) redisplay_internal is called. */ static void -mark_window_display_accurate_1 (w, accurate_p) - struct window *w; - int accurate_p; +mark_window_display_accurate_1 (struct window *w, int accurate_p) { if (BUFFERP (w->buffer)) { @@ -12102,9 +12336,7 @@ mark_window_display_accurate_1 (w, accurate_p) be redisplayed the next time redisplay_internal is called. */ void -mark_window_display_accurate (window, accurate_p) - Lisp_Object window; - int accurate_p; +mark_window_display_accurate (Lisp_Object window, int accurate_p) { struct window *w; @@ -12139,9 +12371,7 @@ mark_window_display_accurate (window, accurate_p) macro DISP_CHAR_VECTOR. */ Lisp_Object -disp_char_vector (dp, c) - struct Lisp_Char_Table *dp; - int c; +disp_char_vector (struct Lisp_Char_Table *dp, int c) { Lisp_Object val; @@ -12172,8 +12402,7 @@ disp_char_vector (dp, c) /* Redisplay all leaf windows in the window tree rooted at WINDOW. */ static void -redisplay_windows (window) - Lisp_Object window; +redisplay_windows (Lisp_Object window) { while (!NILP (window)) { @@ -12198,15 +12427,14 @@ redisplay_windows (window) } static Lisp_Object -redisplay_window_error () +redisplay_window_error (Lisp_Object ignore) { displayed_buffer->display_error_modiff = BUF_MODIFF (displayed_buffer); return Qnil; } static Lisp_Object -redisplay_window_0 (window) - Lisp_Object window; +redisplay_window_0 (Lisp_Object window) { if (displayed_buffer->display_error_modiff < BUF_MODIFF (displayed_buffer)) redisplay_window (window, 0); @@ -12214,8 +12442,7 @@ redisplay_window_0 (window) } static Lisp_Object -redisplay_window_1 (window) - Lisp_Object window; +redisplay_window_1 (Lisp_Object window) { if (displayed_buffer->display_error_modiff < BUF_MODIFF (displayed_buffer)) redisplay_window (window, 1); @@ -12243,171 +12470,465 @@ redisplay_window_1 (window) Return 0 if cursor is not on this row, 1 otherwise. */ int -set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) - struct window *w; - struct glyph_row *row; - struct glyph_matrix *matrix; - int delta, delta_bytes, dy, dvpos; +set_cursor_from_row (struct window *w, struct glyph_row *row, + struct glyph_matrix *matrix, + EMACS_INT delta, EMACS_INT delta_bytes, + int dy, int dvpos) { struct glyph *glyph = row->glyphs[TEXT_AREA]; struct glyph *end = glyph + row->used[TEXT_AREA]; struct glyph *cursor = NULL; - /* The first glyph that starts a sequence of glyphs from a string - that is a value of a display property. */ - struct glyph *string_start; - /* The X coordinate of string_start. */ - int string_start_x; /* The last known character position in row. */ - int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; - /* The last known character position before string_start. */ - int string_before_pos; + EMACS_INT last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; int x = row->x; - int cursor_x = x; - /* Last buffer position covered by an overlay. */ - int cursor_from_overlay_pos = 0; - int pt_old = PT - delta; - - /* Skip over glyphs not having an object at the start of the row. - These are special glyphs like truncation marks on terminal - frames. */ + EMACS_INT pt_old = PT - delta; + EMACS_INT pos_before = MATRIX_ROW_START_CHARPOS (row) + delta; + EMACS_INT pos_after = MATRIX_ROW_END_CHARPOS (row) + delta; + struct glyph *glyph_before = glyph - 1, *glyph_after = end; + /* A glyph beyond the edge of TEXT_AREA which we should never + touch. */ + struct glyph *glyphs_end = end; + /* Non-zero means we've found a match for cursor position, but that + glyph has the avoid_cursor_p flag set. */ + int match_with_avoid_cursor = 0; + /* Non-zero means we've seen at least one glyph that came from a + display string. */ + int string_seen = 0; + /* Largest and smalles buffer positions seen so far during scan of + glyph row. */ + EMACS_INT bpos_max = pos_before; + EMACS_INT bpos_min = pos_after; + /* Last buffer position covered by an overlay string with an integer + `cursor' property. */ + EMACS_INT bpos_covered = 0; + + /* Skip over glyphs not having an object at the start and the end of + the row. These are special glyphs like truncation marks on + terminal frames. */ if (row->displays_text_p) - while (glyph < end - && INTEGERP (glyph->object) - && glyph->charpos < 0) + { + if (!row->reversed_p) + { + while (glyph < end + && INTEGERP (glyph->object) + && glyph->charpos < 0) + { + x += glyph->pixel_width; + ++glyph; + } + while (end > glyph + && INTEGERP ((end - 1)->object) + /* CHARPOS is zero for blanks and stretch glyphs + inserted by extend_face_to_end_of_line. */ + && (end - 1)->charpos <= 0) + --end; + glyph_before = glyph - 1; + glyph_after = end; + } + else + { + struct glyph *g; + + /* If the glyph row is reversed, we need to process it from back + to front, so swap the edge pointers. */ + glyphs_end = end = glyph - 1; + glyph += row->used[TEXT_AREA] - 1; + + while (glyph > end + 1 + && INTEGERP (glyph->object) + && glyph->charpos < 0) + { + --glyph; + x -= glyph->pixel_width; + } + if (INTEGERP (glyph->object) && glyph->charpos < 0) + --glyph; + /* By default, in reversed rows we put the cursor on the + rightmost (first in the reading order) glyph. */ + for (g = end + 1; g < glyph; g++) + x += g->pixel_width; + while (end < glyph + && INTEGERP ((end + 1)->object) + && (end + 1)->charpos <= 0) + ++end; + glyph_before = glyph + 1; + glyph_after = end; + } + } + else if (row->reversed_p) + { + /* In R2L rows that don't display text, put the cursor on the + rightmost glyph. Case in point: an empty last line that is + part of an R2L paragraph. */ + cursor = end - 1; + /* Avoid placing the cursor on the last glyph of the row, where + on terminal frames we hold the vertical border between + adjacent windows. */ + if (!FRAME_WINDOW_P (WINDOW_XFRAME (w)) + && !WINDOW_RIGHTMOST_P (w) + && cursor == row->glyphs[LAST_AREA] - 1) + cursor--; + x = -1; /* will be computed below, at label compute_x */ + } + + /* Step 1: Try to find the glyph whose character position + corresponds to point. If that's not possible, find 2 glyphs + whose character positions are the closest to point, one before + point, the other after it. */ + if (!row->reversed_p) + while (/* not marched to end of glyph row */ + glyph < end + /* glyph was not inserted by redisplay for internal purposes */ + && !INTEGERP (glyph->object)) { + if (BUFFERP (glyph->object)) + { + EMACS_INT dpos = glyph->charpos - pt_old; + + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; + if (glyph->charpos < bpos_min) + bpos_min = glyph->charpos; + if (!glyph->avoid_cursor_p) + { + /* If we hit point, we've found the glyph on which to + display the cursor. */ + if (dpos == 0) + { + match_with_avoid_cursor = 0; + break; + } + /* See if we've found a better approximation to + POS_BEFORE or to POS_AFTER. Note that we want the + first (leftmost) glyph of all those that are the + closest from below, and the last (rightmost) of all + those from above. */ + if (0 > dpos && dpos > pos_before - pt_old) + { + pos_before = glyph->charpos; + glyph_before = glyph; + } + else if (0 < dpos && dpos <= pos_after - pt_old) + { + pos_after = glyph->charpos; + glyph_after = glyph; + } + } + else if (dpos == 0) + match_with_avoid_cursor = 1; + } + else if (STRINGP (glyph->object)) + { + Lisp_Object chprop; + EMACS_INT glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. Note that overlays and text properties + with string values stop bidi reordering, so every + buffer position to the left of the string is always + smaller than any position to the right of the + string. Therefore, if a `cursor' property on one + of the string's characters has an integer value, we + will break out of the loop below _before_ we get to + the position match above. IOW, integer values of + the `cursor' property override the "exact match for + point" strategy of positioning the cursor. */ + /* Implementation note: bpos_max == pt_old when, e.g., + we are in an empty line, where bpos_max is set to + MATRIX_ROW_START_CHARPOS, see above. */ + if (bpos_max <= pt_old && bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + + string_seen = 1; + } x += glyph->pixel_width; ++glyph; } + else if (glyph > end) /* row is reversed */ + while (!INTEGERP (glyph->object)) + { + if (BUFFERP (glyph->object)) + { + EMACS_INT dpos = glyph->charpos - pt_old; - string_start = NULL; - while (glyph < end - && !INTEGERP (glyph->object) - && (!BUFFERP (glyph->object) - || (last_pos = glyph->charpos) < pt_old - || glyph->avoid_cursor_p)) + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; + if (glyph->charpos < bpos_min) + bpos_min = glyph->charpos; + if (!glyph->avoid_cursor_p) + { + if (dpos == 0) + { + match_with_avoid_cursor = 0; + break; + } + if (0 > dpos && dpos > pos_before - pt_old) + { + pos_before = glyph->charpos; + glyph_before = glyph; + } + else if (0 < dpos && dpos <= pos_after - pt_old) + { + pos_after = glyph->charpos; + glyph_after = glyph; + } + } + else if (dpos == 0) + match_with_avoid_cursor = 1; + } + else if (STRINGP (glyph->object)) + { + Lisp_Object chprop; + EMACS_INT glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. */ + if (bpos_max <= pt_old && bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + string_seen = 1; + } + --glyph; + if (glyph == glyphs_end) /* don't dereference outside TEXT_AREA */ + { + x--; /* can't use any pixel_width */ + break; + } + x -= glyph->pixel_width; + } + + /* Step 2: If we didn't find an exact match for point, we need to + look for a proper place to put the cursor among glyphs between + GLYPH_BEFORE and GLYPH_AFTER. */ + if (!((row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end) + && BUFFERP (glyph->object) && glyph->charpos == pt_old) + && bpos_covered < pt_old) { - if (! STRINGP (glyph->object)) + if (row->ends_in_ellipsis_p && pos_after == last_pos) { - string_start = NULL; - x += glyph->pixel_width; - ++glyph; - /* If we are beyond the cursor position computed from the - last overlay seen, that overlay is not in effect for - current cursor position. Reset the cursor information - computed from that overlay. */ - if (cursor_from_overlay_pos - && last_pos >= cursor_from_overlay_pos) + EMACS_INT ellipsis_pos; + + /* Scan back over the ellipsis glyphs. */ + if (!row->reversed_p) { - cursor_from_overlay_pos = 0; - cursor = NULL; + ellipsis_pos = (glyph - 1)->charpos; + while (glyph > row->glyphs[TEXT_AREA] + && (glyph - 1)->charpos == ellipsis_pos) + glyph--, x -= glyph->pixel_width; + /* That loop always goes one position too far, including + the glyph before the ellipsis. So scan forward over + that one. */ + x += glyph->pixel_width; + glyph++; } - } - else - { - if (string_start == NULL) + else /* row is reversed */ { - string_before_pos = last_pos; - string_start = glyph; - string_start_x = x; + ellipsis_pos = (glyph + 1)->charpos; + while (glyph < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1 + && (glyph + 1)->charpos == ellipsis_pos) + glyph++, x += glyph->pixel_width; + x -= glyph->pixel_width; + glyph--; } - /* Skip all glyphs from a string. */ - do + } + else if (match_with_avoid_cursor + /* A truncated row may not include PT among its + character positions. Setting the cursor inside the + scroll margin will trigger recalculation of hscroll + in hscroll_window_tree. */ + || (row->truncated_on_left_p && pt_old < bpos_min) + || (row->truncated_on_right_p && pt_old > bpos_max) + /* Zero-width characters produce no glyphs. */ + || ((row->reversed_p + ? glyph_after > glyphs_end + : glyph_after < glyphs_end) + && eabs (glyph_after - glyph_before) == 1)) + { + cursor = glyph_after; + x = -1; + } + else if (string_seen) + { + int incr = row->reversed_p ? -1 : +1; + + /* Need to find the glyph that came out of a string which is + present at point. That glyph is somewhere between + GLYPH_BEFORE and GLYPH_AFTER, and it came from a string + positioned between POS_BEFORE and POS_AFTER in the + buffer. */ + struct glyph *stop = glyph_after; + EMACS_INT pos = pos_before; + + x = -1; + for (glyph = glyph_before + incr; + row->reversed_p ? glyph > stop : glyph < stop; ) { - Lisp_Object cprop; - int pos; - if ((cursor == NULL || glyph > cursor) - && (cprop = Fget_char_property (make_number ((glyph)->charpos), - Qcursor, (glyph)->object), - !NILP (cprop)) - && (pos = string_buffer_position (w, glyph->object, - string_before_pos), - (pos == 0 /* from overlay */ - || pos == pt_old))) + + /* Any glyphs that come from the buffer are here because + of bidi reordering. Skip them, and only pay + attention to glyphs that came from some string. */ + if (STRINGP (glyph->object)) { - /* Compute the first buffer position after the overlay. - If the `cursor' property tells us how many positions - are associated with the overlay, use that. Otherwise, - estimate from the buffer positions of the glyphs - before and after the overlay. */ - cursor_from_overlay_pos = (pos ? 0 : last_pos - + (INTEGERP (cprop) ? XINT (cprop) : 0)); - cursor = glyph; - cursor_x = x; + Lisp_Object str; + EMACS_INT tem; + + str = glyph->object; + tem = string_buffer_position_lim (w, str, pos, pos_after, 0); + if (tem == 0 /* from overlay */ + || pos <= tem) + { + /* If the string from which this glyph came is + found in the buffer at point, then we've + found the glyph we've been looking for. If + it comes from an overlay (tem == 0), and it + has the `cursor' property on one of its + glyphs, record that glyph as a candidate for + displaying the cursor. (As in the + unidirectional version, we will display the + cursor on the last candidate we find.) */ + if (tem == 0 || tem == pt_old) + { + /* The glyphs from this string could have + been reordered. Find the one with the + smallest string position. Or there could + be a character in the string with the + `cursor' property, which means display + cursor on that character's glyph. */ + EMACS_INT strpos = glyph->charpos; + + cursor = glyph; + for (glyph += incr; + (row->reversed_p ? glyph > stop : glyph < stop) + && EQ (glyph->object, str); + glyph += incr) + { + Lisp_Object cprop; + EMACS_INT gpos = glyph->charpos; + + cprop = Fget_char_property (make_number (gpos), + Qcursor, + glyph->object); + if (!NILP (cprop)) + { + cursor = glyph; + break; + } + if (glyph->charpos < strpos) + { + strpos = glyph->charpos; + cursor = glyph; + } + } + + if (tem == pt_old) + goto compute_x; + } + if (tem) + pos = tem + 1; /* don't find previous instances */ + } + /* This string is not what we want; skip all of the + glyphs that came from it. */ + do + glyph += incr; + while ((row->reversed_p ? glyph > stop : glyph < stop) + && EQ (glyph->object, str)); } - x += glyph->pixel_width; - ++glyph; + else + glyph += incr; } - while (glyph < end && EQ (glyph->object, string_start->object)); + + /* If we reached the end of the line, and END was from a string, + the cursor is not on this line. */ + if (cursor == NULL + && (row->reversed_p ? glyph <= end : glyph >= end) + && STRINGP (end->object) + && row->continued_p) + return 0; } } + compute_x: if (cursor != NULL) + glyph = cursor; + if (x < 0) { - glyph = cursor; - x = cursor_x; - } - else if (row->ends_in_ellipsis_p && glyph == end) - { - /* Scan back over the ellipsis glyphs, decrementing positions. */ - while (glyph > row->glyphs[TEXT_AREA] - && (glyph - 1)->charpos == last_pos) - glyph--, x -= glyph->pixel_width; - /* That loop always goes one position too far, including the - glyph before the ellipsis. So scan forward over that one. */ - x += glyph->pixel_width; - glyph++; - } - else if (string_start - && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old)) - { - /* We may have skipped over point because the previous glyphs - are from string. As there's no easy way to know the - character position of the current glyph, find the correct - glyph on point by scanning from string_start again. */ - Lisp_Object limit; - Lisp_Object string; - struct glyph *stop = glyph; - int pos; - - limit = make_number (pt_old + 1); - glyph = string_start; - x = string_start_x; - string = glyph->object; - pos = string_buffer_position (w, string, string_before_pos); - /* If POS == 0, STRING is from overlay. We skip such glyphs - because we always put the cursor after overlay strings. */ - while (pos == 0 && glyph < stop) - { - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - if (glyph < stop) - pos = string_buffer_position (w, glyph->object, string_before_pos); - } + struct glyph *g; - while (glyph < stop) + /* Need to compute x that corresponds to GLYPH. */ + for (g = row->glyphs[TEXT_AREA], x = row->x; g < glyph; g++) { - pos = XINT (Fnext_single_char_property_change - (make_number (pos), Qdisplay, Qnil, limit)); - if (pos > pt_old) - break; - /* Skip glyphs from the same string. */ - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - /* Skip glyphs from an overlay. */ - while (glyph < stop - && ! string_buffer_position (w, glyph->object, pos)) - { - string = glyph->object; - SKIP_GLYPHS (glyph, stop, x, EQ (glyph->object, string)); - } - } - - /* If we reached the end of the line, and END was from a string, - the cursor is not on this line. */ - if (glyph == end && row->continued_p) + if (g >= row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]) + abort (); + x += g->pixel_width; + } + } + + /* ROW could be part of a continued line, which, under bidi + reordering, might have other rows whose start and end charpos + occlude point. Only set w->cursor if we found a better + approximation to the cursor position than we have from previously + examined candidate rows belonging to the same continued line. */ + if (/* we already have a candidate row */ + w->cursor.vpos >= 0 + /* that candidate is not the row we are processing */ + && MATRIX_ROW (matrix, w->cursor.vpos) != row + /* the row we are processing is part of a continued line */ + && (row->continued_p || MATRIX_ROW_CONTINUATION_LINE_P (row)) + /* Make sure cursor.vpos specifies a row whose start and end + charpos occlude point. This is because some callers of this + function leave cursor.vpos at the row where the cursor was + displayed during the last redisplay cycle. */ + && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old + && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) + { + struct glyph *g1 = + MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; + + /* Don't consider glyphs that are outside TEXT_AREA. */ + if (!(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end)) + return 0; + /* Keep the candidate whose buffer position is the closest to + point. */ + if (/* previous candidate is a glyph in TEXT_AREA of that row */ + w->cursor.hpos >= 0 + && w->cursor.hpos < MATRIX_ROW_USED (matrix, w->cursor.vpos) + && BUFFERP (g1->object) + && (g1->charpos == pt_old /* an exact match always wins */ + || (BUFFERP (glyph->object) + && eabs (g1->charpos - pt_old) + < eabs (glyph->charpos - pt_old)))) + return 0; + /* If this candidate gives an exact match, use that. */ + if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) + /* Otherwise, keep the candidate that comes from a row + spanning less buffer positions. This may win when one or + both candidate positions are on glyphs that came from + display strings, for which we cannot compare buffer + positions. */ + && MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) + - MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) + < MATRIX_ROW_END_CHARPOS (row) - MATRIX_ROW_START_CHARPOS (row)) return 0; } - w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; w->cursor.x = x; w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; @@ -12450,9 +12971,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) We assume that the window's buffer is really current. */ static INLINE struct text_pos -run_window_scroll_functions (window, startp) - Lisp_Object window; - struct text_pos startp; +run_window_scroll_functions (Lisp_Object window, struct text_pos startp) { struct window *w = XWINDOW (window); SET_MARKER_FROM_TEXT_POS (w->start, startp); @@ -12486,10 +13005,7 @@ run_window_scroll_functions (window, startp) as if point had gone off the screen. */ static int -cursor_row_fully_visible_p (w, force_p, current_matrix_p) - struct window *w; - int force_p; - int current_matrix_p; +cursor_row_fully_visible_p (struct window *w, int force_p, int current_matrix_p) { struct glyph_matrix *matrix; struct glyph_row *row; @@ -12549,13 +13065,9 @@ enum }; static int -try_scrolling (window, just_this_one_p, scroll_conservatively, - scroll_step, temp_scroll_step, last_line_misfit) - Lisp_Object window; - int just_this_one_p; - EMACS_INT scroll_conservatively, scroll_step; - int temp_scroll_step; - int last_line_misfit; +try_scrolling (Lisp_Object window, int just_this_one_p, + EMACS_INT scroll_conservatively, EMACS_INT scroll_step, + int temp_scroll_step, int last_line_misfit) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); @@ -12622,14 +13134,22 @@ try_scrolling (window, just_this_one_p, scroll_conservatively, if (PT > CHARPOS (it.current.pos)) { int y0 = line_bottom_y (&it); - - /* Compute the distance from the scroll margin to PT - (including the height of the cursor line). Moving the - iterator unconditionally to PT can be slow if PT is far - away, so stop 10 lines past the window bottom (is there a - way to do the right thing quickly?). */ - move_it_to (&it, PT, -1, - it.last_visible_y + 10 * FRAME_LINE_HEIGHT (f), + /* Compute how many pixels below window bottom to stop searching + for PT. This avoids costly search for PT that is far away if + the user limited scrolling by a small number of lines, but + always finds PT if scroll_conservatively is set to a large + number, such as most-positive-fixnum. */ + int slack = max (scroll_max, 10 * FRAME_LINE_HEIGHT (f)); + int y_to_move = + slack >= INT_MAX - it.last_visible_y + ? INT_MAX + : it.last_visible_y + slack; + + /* Compute the distance from the scroll margin to PT or to + the scroll limit, whichever comes first. This should + include the height of the cursor line, to make that line + fully visible. */ + move_it_to (&it, PT, -1, y_to_move, -1, MOVE_TO_POS | MOVE_TO_Y); dy = line_bottom_y (&it) - y0; @@ -12669,7 +13189,26 @@ try_scrolling (window, just_this_one_p, scroll_conservatively, return SCROLLING_FAILED; start_display (&it, w, startp); - move_it_vertically (&it, amount_to_scroll); + if (scroll_max < INT_MAX) + move_it_vertically (&it, amount_to_scroll); + else + { + /* Extra precision for users who set scroll-conservatively + to most-positive-fixnum: make sure the amount we scroll + the window start is never less than amount_to_scroll, + which was computed as distance from window bottom to + point. This matters when lines at window top and lines + below window bottom have different height. */ + struct it it1 = it; + /* We use a temporary it1 because line_bottom_y can modify + its argument, if it moves one line down; see there. */ + int start_y = line_bottom_y (&it1); + + do { + move_it_by_lines (&it, 1, 1); + it1 = it; + } while (line_bottom_y (&it1) - start_y < amount_to_scroll); + } /* If STARTP is unchanged, move it down another screen line. */ if (CHARPOS (it.current.pos) == CHARPOS (startp)) @@ -12781,8 +13320,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively, screen line with the minimum distance from the old start W->start. */ static int -compute_window_start_on_continuation_line (w) - struct window *w; +compute_window_start_on_continuation_line (struct window *w) { struct text_pos pos, start_pos; int window_start_changed_p = 0; @@ -12868,10 +13406,7 @@ enum }; static int -try_cursor_movement (window, startp, scroll_step) - Lisp_Object window; - struct text_pos startp; - int *scroll_step; +try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_step) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); @@ -12958,7 +13493,7 @@ try_cursor_movement (window, startp, scroll_step) if (rc == CURSOR_MOVEMENT_CANNOT_BE_USED) { - int scroll_p = 0; + int scroll_p = 0, must_scroll = 0; int last_y = window_text_bottom_y (w) - this_scroll_margin; if (PT > XFASTINT (w->last_point)) @@ -12971,11 +13506,14 @@ try_cursor_movement (window, startp, scroll_step) ++row; } - /* The end position of a row equals the start position - of the next row. If PT is there, we would rather - display it in the next line. */ + /* If the end position of a row equals the start + position of the next row, and PT is at that position, + we would rather display cursor in the next line. */ while (MATRIX_ROW_BOTTOM_Y (row) < last_y && MATRIX_ROW_END_CHARPOS (row) == PT + && row < w->current_matrix->rows + + w->current_matrix->nrows - 1 + && MATRIX_ROW_START_CHARPOS (row+1) == PT && !cursor_row_p (w, row)) ++row; @@ -13048,10 +13586,41 @@ try_cursor_movement (window, startp, scroll_step) { /* if PT is not in the glyph row, give up. */ rc = CURSOR_MOVEMENT_MUST_SCROLL; + must_scroll = 1; + } + else if (rc != CURSOR_MOVEMENT_SUCCESS + && !NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + { + /* If rows are bidi-reordered and point moved, back up + until we find a row that does not belong to a + continuation line. This is because we must consider + all rows of a continued line as candidates for the + new cursor positioning, since row start and end + positions change non-linearly with vertical position + in such rows. */ + /* FIXME: Revisit this when glyph ``spilling'' in + continuation lines' rows is implemented for + bidi-reordered rows. */ + while (MATRIX_ROW_CONTINUATION_LINE_P (row)) + { + xassert (row->enabled_p); + --row; + /* If we hit the beginning of the displayed portion + without finding the first row of a continued + line, give up. */ + if (row <= w->current_matrix->rows) + { + rc = CURSOR_MOVEMENT_MUST_SCROLL; + break; + } + + } } + if (must_scroll) + ; else if (rc != CURSOR_MOVEMENT_SUCCESS - && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) - && make_cursor_line_fully_visible_p) + && MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) + && make_cursor_line_fully_visible_p) { if (PT == MATRIX_ROW_END_CHARPOS (row) && !row->ends_at_zv_p @@ -13077,6 +13646,48 @@ try_cursor_movement (window, startp, scroll_step) } else if (scroll_p) rc = CURSOR_MOVEMENT_MUST_SCROLL; + else if (rc != CURSOR_MOVEMENT_SUCCESS + && !NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + { + /* With bidi-reordered rows, there could be more than + one candidate row whose start and end positions + occlude point. We need to let set_cursor_from_row + find the best candidate. */ + /* FIXME: Revisit this when glyph ``spilling'' in + continuation lines' rows is implemented for + bidi-reordered rows. */ + int rv = 0; + + do + { + if (MATRIX_ROW_START_CHARPOS (row) <= PT + && PT <= MATRIX_ROW_END_CHARPOS (row) + && cursor_row_p (w, row)) + rv |= set_cursor_from_row (w, row, w->current_matrix, + 0, 0, 0, 0); + /* As soon as we've found the first suitable row + whose ends_at_zv_p flag is set, we are done. */ + if (rv + && MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p) + { + rc = CURSOR_MOVEMENT_SUCCESS; + break; + } + ++row; + } + while ((MATRIX_ROW_CONTINUATION_LINE_P (row) + && MATRIX_ROW_BOTTOM_Y (row) <= last_y) + || (MATRIX_ROW_START_CHARPOS (row) == PT + && MATRIX_ROW_BOTTOM_Y (row) < last_y)); + /* If we didn't find any candidate rows, or exited the + loop before all the candidates were examined, signal + to the caller that this method failed. */ + if (rc != CURSOR_MOVEMENT_SUCCESS + && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row))) + rc = CURSOR_MOVEMENT_MUST_SCROLL; + else if (rv) + rc = CURSOR_MOVEMENT_SUCCESS; + } else { do @@ -13099,10 +13710,9 @@ try_cursor_movement (window, startp, scroll_step) } void -set_vertical_scroll_bar (w) - struct window *w; +set_vertical_scroll_bar (struct window *w) { - int start, end, whole; + EMACS_INT start, end, whole; /* Calculate the start and end positions for the current window. At some point, it would be nice to choose between scrollbars @@ -13145,9 +13755,7 @@ set_vertical_scroll_bar (w) retry. */ static void -redisplay_window (window, just_this_one_p) - Lisp_Object window; - int just_this_one_p; +redisplay_window (Lisp_Object window, int just_this_one_p) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); @@ -13168,7 +13776,7 @@ redisplay_window (window, just_this_one_p) int rc; int centering_position = -1; int last_line_misfit = 0; - int beg_unchanged, end_unchanged; + EMACS_INT beg_unchanged, end_unchanged; SET_TEXT_POS (lpoint, PT, PT_BYTE); opoint = lpoint; @@ -13310,8 +13918,8 @@ redisplay_window (window, just_this_one_p) window, set up appropriate value. */ if (!EQ (window, selected_window)) { - int new_pt = XMARKER (w->pointm)->charpos; - int new_pt_byte = marker_byte_position (w->pointm); + EMACS_INT new_pt = XMARKER (w->pointm)->charpos; + EMACS_INT new_pt_byte = marker_byte_position (w->pointm); if (new_pt < BEGV) { new_pt = BEGV; @@ -13577,7 +14185,7 @@ redisplay_window (window, just_this_one_p) = try_window_reusing_current_matrix (w))) { IF_DEBUG (debug_method_add (w, "1")); - if (try_window (window, startp, 1) < 0) + if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0) /* -1 means we need to scroll. 0 means we need new matrices, but fonts_changed_p is set in that case, so we will detect it below. */ @@ -13869,7 +14477,6 @@ redisplay_window (window, just_this_one_p) if (redisplay_tool_bar_p && redisplay_tool_bar (f)) { - extern int ignore_mouse_drag_p; ignore_mouse_drag_p = 1; } } @@ -13936,13 +14543,12 @@ redisplay_window (window, just_this_one_p) Value is 1 if successful. It is zero if fonts were loaded during redisplay which makes re-adjusting glyph matrices necessary, and -1 if point would appear in the scroll margins. - (We check that only if CHECK_MARGINS is nonzero. */ + (We check the former only if TRY_WINDOW_IGNORE_FONTS_CHANGE is + unset in FLAGS, and the latter only if TRY_WINDOW_CHECK_MARGINS is + set in FLAGS.) */ int -try_window (window, pos, check_margins) - Lisp_Object window; - struct text_pos pos; - int check_margins; +try_window (Lisp_Object window, struct text_pos pos, int flags) { struct window *w = XWINDOW (window); struct it it; @@ -13964,12 +14570,12 @@ try_window (window, pos, check_margins) { if (display_line (&it)) last_text_row = it.glyph_row - 1; - if (fonts_changed_p) + if (fonts_changed_p && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE)) return 0; } /* Don't let the cursor end in the scroll margins. */ - if (check_margins + if ((flags & TRY_WINDOW_CHECK_MARGINS) && !MINI_WINDOW_P (w)) { int this_scroll_margin; @@ -14042,8 +14648,7 @@ try_window (window, pos, check_margins) W->start is the new window start. */ static int -try_window_reusing_current_matrix (w) - struct window *w; +try_window_reusing_current_matrix (struct window *w) { struct frame *f = XFRAME (w->frame); struct glyph_row *row, *bottom_row; @@ -14090,7 +14695,7 @@ try_window_reusing_current_matrix (w) /* The variable new_start now holds the new window start. The old start `start' can be determined from the current matrix. */ SET_TEXT_POS_FROM_MARKER (new_start, w->start); - start = start_row->start.pos; + start = start_row->minpos; start_vpos = MATRIX_ROW_VPOS (start_row, w->current_matrix); /* Clear the desired matrix for the display below. */ @@ -14129,7 +14734,7 @@ try_window_reusing_current_matrix (w) { /* Advance to the next row as the "start". */ start_row++; - start = start_row->start.pos; + start = start_row->minpos; /* If there are no more rows to try, or just one, give up. */ if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1 || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row) @@ -14412,14 +15017,25 @@ try_window_reusing_current_matrix (w) struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; struct glyph *end = glyph + row->used[TEXT_AREA]; - for (; glyph < end - && (!BUFFERP (glyph->object) - || glyph->charpos < PT); - glyph++) + /* Can't use this optimization with bidi-reordered glyph + rows, unless cursor is already at point. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering)) { - w->cursor.hpos++; - w->cursor.x += glyph->pixel_width; + if (!(w->cursor.hpos >= 0 + && w->cursor.hpos < row->used[TEXT_AREA] + && BUFFERP (glyph->object) + && glyph->charpos == PT)) + return 0; } + else + for (; glyph < end + && (!BUFFERP (glyph->object) + || glyph->charpos < PT); + glyph++) + { + w->cursor.hpos++; + w->cursor.x += glyph->pixel_width; + } } } @@ -14459,12 +15075,12 @@ try_window_reusing_current_matrix (w) Window redisplay reusing current matrix when buffer has changed ************************************************************************/ -static struct glyph_row *find_last_unchanged_at_beg_row P_ ((struct window *)); -static struct glyph_row *find_first_unchanged_at_end_row P_ ((struct window *, - int *, int *)); +static struct glyph_row *find_last_unchanged_at_beg_row (struct window *); +static struct glyph_row *find_first_unchanged_at_end_row (struct window *, + EMACS_INT *, EMACS_INT *); static struct glyph_row * -find_last_row_displaying_text P_ ((struct glyph_matrix *, struct it *, - struct glyph_row *)); +find_last_row_displaying_text (struct glyph_matrix *, struct it *, + struct glyph_row *); /* Return the last row in MATRIX displaying text. If row START is @@ -14473,10 +15089,8 @@ find_last_row_displaying_text P_ ((struct glyph_matrix *, struct it *, a pointer to the row found. */ static struct glyph_row * -find_last_row_displaying_text (matrix, it, start) - struct glyph_matrix *matrix; - struct it *it; - struct glyph_row *start; +find_last_row_displaying_text (struct glyph_matrix *matrix, struct it *it, + struct glyph_row *start) { struct glyph_row *row, *row_found; @@ -14509,10 +15123,9 @@ find_last_row_displaying_text (matrix, it, start) when the current matrix was built. */ static struct glyph_row * -find_last_unchanged_at_beg_row (w) - struct window *w; +find_last_unchanged_at_beg_row (struct window *w) { - int first_changed_pos = BEG + BEG_UNCHANGED; + EMACS_INT first_changed_pos = BEG + BEG_UNCHANGED; struct glyph_row *row; struct glyph_row *row_found = NULL; int yb = window_text_bottom_y (w); @@ -14559,9 +15172,8 @@ find_last_unchanged_at_beg_row (w) changes. */ static struct glyph_row * -find_first_unchanged_at_end_row (w, delta, delta_bytes) - struct window *w; - int *delta, *delta_bytes; +find_first_unchanged_at_end_row (struct window *w, + EMACS_INT *delta, EMACS_INT *delta_bytes) { struct glyph_row *row; struct glyph_row *row_found = NULL; @@ -14589,9 +15201,11 @@ find_first_unchanged_at_end_row (w, delta, delta_bytes) corresponds to window_end_pos. This allows us to translate buffer positions in the current matrix to current buffer positions for characters not in changed text. */ - int Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); - int Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; - int last_unchanged_pos, last_unchanged_pos_old; + EMACS_INT Z_old = + MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); + EMACS_INT Z_BYTE_old = + MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; + EMACS_INT last_unchanged_pos, last_unchanged_pos_old; struct glyph_row *first_text_row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); @@ -14634,8 +15248,7 @@ find_first_unchanged_at_end_row (w, delta, delta_bytes) try_window_reusing_current_matrix. */ static void -sync_frame_with_window_matrix_rows (w) - struct window *w; +sync_frame_with_window_matrix_rows (struct window *w) { struct frame *f = XFRAME (w->frame); struct glyph_row *window_row, *window_row_end, *frame_row; @@ -14679,13 +15292,12 @@ sync_frame_with_window_matrix_rows (w) containing CHARPOS or null. */ struct glyph_row * -row_containing_pos (w, charpos, start, end, dy) - struct window *w; - int charpos; - struct glyph_row *start, *end; - int dy; +row_containing_pos (struct window *w, EMACS_INT charpos, + struct glyph_row *start, struct glyph_row *end, int dy) { struct glyph_row *row = start; + struct glyph_row *best_row = NULL; + EMACS_INT mindif = BUF_ZV (XBUFFER (w->buffer)) + 1; int last_y; /* If we happen to start on a header-line, skip that. */ @@ -14718,7 +15330,30 @@ row_containing_pos (w, charpos, start, end, dy) && !row->ends_at_zv_p && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))) && charpos >= MATRIX_ROW_START_CHARPOS (row)) - return row; + { + struct glyph *g; + + if (NILP (XBUFFER (w->buffer)->bidi_display_reordering)) + return row; + /* In bidi-reordered rows, there could be several rows + occluding point. We need to find the one which fits + CHARPOS the best. */ + for (g = row->glyphs[TEXT_AREA]; + g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; + g++) + { + if (!STRINGP (g->object)) + { + if (g->charpos > 0 && eabs (g->charpos - charpos) < mindif) + { + mindif = eabs (g->charpos - charpos); + best_row = row; + } + } + } + } + else if (best_row) + return best_row; ++row; } } @@ -14760,8 +15395,7 @@ row_containing_pos (w, charpos, start, end, dy) 7. Update W's window end information. */ static int -try_window_id (w) - struct window *w; +try_window_id (struct window *w) { struct frame *f = XFRAME (w->frame); struct glyph_matrix *current_matrix = w->current_matrix; @@ -14772,13 +15406,14 @@ try_window_id (w) struct glyph_row *bottom_row; int bottom_vpos; struct it it; - int delta = 0, delta_bytes = 0, stop_pos, dvpos, dy; + EMACS_INT delta = 0, delta_bytes = 0, stop_pos; + int dvpos, dy; struct text_pos start_pos; struct run run; int first_unchanged_at_end_vpos = 0; struct glyph_row *last_text_row, *last_text_row_at_end; struct text_pos start; - int first_changed_charpos, last_changed_charpos; + EMACS_INT first_changed_charpos, last_changed_charpos; #if GLYPH_DEBUG if (inhibit_try_window_id) @@ -14863,6 +15498,18 @@ try_window_id (w) if (!NILP (XBUFFER (w->buffer)->word_wrap)) GIVE_UP (21); + /* Under bidi reordering, adding or deleting a character in the + beginning of a paragraph, before the first strong directional + character, can change the base direction of the paragraph (unless + the buffer specifies a fixed paragraph direction), which will + require to redisplay the whole paragraph. It might be worthwhile + to find the paragraph limits and widen the range of redisplayed + lines to that, but for now just give up this optimization and + redisplay from scratch. */ + if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) + GIVE_UP (22); + /* Make sure beg_unchanged and end_unchanged are up to date. Do it only if buffer has really changed. The reason is that the gap is initially at Z for freshly visited files. The code below would @@ -14893,7 +15540,7 @@ try_window_id (w) || (last_changed_charpos < CHARPOS (start) - 1 && FETCH_BYTE (BYTEPOS (start) - 1) == '\n'))) { - int Z_old, delta, Z_BYTE_old, delta_bytes; + EMACS_INT Z_old, delta, Z_BYTE_old, delta_bytes; struct glyph_row *r0; /* Compute how many chars/bytes have been added to or removed @@ -14962,13 +15609,13 @@ try_window_id (w) as is, without changing glyph positions since no text has been added/removed in front of the window end. */ r0 = MATRIX_FIRST_TEXT_ROW (current_matrix); - if (TEXT_POS_EQUAL_P (start, r0->start.pos) + if (TEXT_POS_EQUAL_P (start, r0->minpos) /* PT must not be in a partially visible line. */ && !(PT >= MATRIX_ROW_START_CHARPOS (row) && MATRIX_ROW_BOTTOM_Y (row) > window_text_bottom_y (w))) { /* We have to compute the window end anew since text - can have been added/removed after it. */ + could have been added/removed after it. */ w->window_end_pos = make_number (Z - MATRIX_ROW_END_CHARPOS (row)); w->window_end_bytepos @@ -15000,7 +15647,7 @@ try_window_id (w) start is not in changed text, otherwise positions would not be comparable. */ row = MATRIX_FIRST_TEXT_ROW (current_matrix); - if (!TEXT_POS_EQUAL_P (start, row->start.pos)) + if (!TEXT_POS_EQUAL_P (start, row->minpos)) GIVE_UP (16); /* Give up if the window ends in strings. Overlay strings @@ -15485,9 +16132,9 @@ try_window_id (w) #if GLYPH_DEBUG -void dump_glyph_row P_ ((struct glyph_row *, int, int)); -void dump_glyph_matrix P_ ((struct glyph_matrix *, int)); -void dump_glyph P_ ((struct glyph_row *, struct glyph *, int)); +void dump_glyph_row (struct glyph_row *, int, int); +void dump_glyph_matrix (struct glyph_matrix *, int); +void dump_glyph (struct glyph_row *, struct glyph *, int); /* Dump the contents of glyph matrix MATRIX on stderr. @@ -15592,7 +16239,7 @@ dump_glyph (row, glyph, area) if (glyph->u.cmp.automatic) fprintf (stderr, "[%d-%d]", - glyph->u.cmp.from, glyph->u.cmp.to); + glyph->slice.cmp.from, glyph->slice.cmp.to); fprintf (stderr, " . %4d %1.1d%1.1d\n", glyph->face_id, glyph->left_box_line_p, @@ -15704,8 +16351,7 @@ DEFUN ("dump-glyph-matrix", Fdump_glyph_matrix, Shows contents of glyph row structures. With non-nil parameter GLYPHS, dump glyphs as well. If GLYPHS is 1 show glyphs in short form, otherwise show glyphs in long form. */) - (glyphs) - Lisp_Object glyphs; + (Lisp_Object glyphs) { struct window *w = XWINDOW (selected_window); struct buffer *buffer = XBUFFER (w->buffer); @@ -15723,7 +16369,7 @@ glyphs in short form, otherwise show glyphs in long form. */) DEFUN ("dump-frame-glyph-matrix", Fdump_frame_glyph_matrix, Sdump_frame_glyph_matrix, 0, 0, "", doc: /* */) - () + (void) { struct frame *f = XFRAME (selected_frame); dump_glyph_matrix (f->current_matrix, 1); @@ -15736,8 +16382,7 @@ DEFUN ("dump-glyph-row", Fdump_glyph_row, Sdump_glyph_row, 1, 2, "", GLYPH 0 means don't dump glyphs. GLYPH 1 means dump glyphs in short form. GLYPH > 1 or omitted means dump glyphs in long form. */) - (row, glyphs) - Lisp_Object row, glyphs; + (Lisp_Object row, Lisp_Object glyphs) { struct glyph_matrix *matrix; int vpos; @@ -15758,8 +16403,7 @@ DEFUN ("dump-tool-bar-row", Fdump_tool_bar_row, Sdump_tool_bar_row, 1, 2, "", GLYPH 0 means don't dump glyphs. GLYPH 1 means dump glyphs in short form. GLYPH > 1 or omitted means dump glyphs in long form. */) - (row, glyphs) - Lisp_Object row, glyphs; + (Lisp_Object row, Lisp_Object glyphs) { struct frame *sf = SELECTED_FRAME (); struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix; @@ -15777,8 +16421,7 @@ GLYPH > 1 or omitted means dump glyphs in long form. */) DEFUN ("trace-redisplay", Ftrace_redisplay, Strace_redisplay, 0, 1, "P", doc: /* Toggle tracing of redisplay. With ARG, turn tracing on if and only if ARG is positive. */) - (arg) - Lisp_Object arg; + (Lisp_Object arg) { if (NILP (arg)) trace_redisplay_p = !trace_redisplay_p; @@ -15795,9 +16438,7 @@ With ARG, turn tracing on if and only if ARG is positive. */) DEFUN ("trace-to-stderr", Ftrace_to_stderr, Strace_to_stderr, 1, MANY, "", doc: /* Like `format', but print result to stderr. usage: (trace-to-stderr STRING &rest OBJECTS) */) - (nargs, args) - int nargs; - Lisp_Object *args; + (int nargs, Lisp_Object *args) { Lisp_Object s = Fformat (nargs, args); fprintf (stderr, "%s", SDATA (s)); @@ -15816,9 +16457,7 @@ usage: (trace-to-stderr STRING &rest OBJECTS) */) Used for non-window-redisplay windows, and for windows w/o left fringe. */ static struct glyph_row * -get_overlay_arrow_glyph_row (w, overlay_arrow_string) - struct window *w; - Lisp_Object overlay_arrow_string; +get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct buffer *buffer = XBUFFER (w->buffer); @@ -15884,8 +16523,7 @@ get_overlay_arrow_glyph_row (w, overlay_arrow_string) produce_special_glyphs. */ static void -insert_left_trunc_glyphs (it) - struct it *it; +insert_left_trunc_glyphs (struct it *it) { struct it truncate_it; struct glyph *from, *end, *to, *toend; @@ -15903,24 +16541,61 @@ insert_left_trunc_glyphs (it) produce_special_glyphs (&truncate_it, IT_TRUNCATION); /* Overwrite glyphs from IT with truncation glyphs. */ - from = truncate_it.glyph_row->glyphs[TEXT_AREA]; - end = from + truncate_it.glyph_row->used[TEXT_AREA]; - to = it->glyph_row->glyphs[TEXT_AREA]; - toend = to + it->glyph_row->used[TEXT_AREA]; - - while (from < end) - *to++ = *from++; - - /* There may be padding glyphs left over. Overwrite them too. */ - while (to < toend && CHAR_GLYPH_PADDING_P (*to)) + if (!it->glyph_row->reversed_p) { from = truncate_it.glyph_row->glyphs[TEXT_AREA]; + end = from + truncate_it.glyph_row->used[TEXT_AREA]; + to = it->glyph_row->glyphs[TEXT_AREA]; + toend = to + it->glyph_row->used[TEXT_AREA]; + while (from < end) *to++ = *from++; + + /* There may be padding glyphs left over. Overwrite them too. */ + while (to < toend && CHAR_GLYPH_PADDING_P (*to)) + { + from = truncate_it.glyph_row->glyphs[TEXT_AREA]; + while (from < end) + *to++ = *from++; + } + + if (to > toend) + it->glyph_row->used[TEXT_AREA] = to - it->glyph_row->glyphs[TEXT_AREA]; } + else + { + /* In R2L rows, overwrite the last (rightmost) glyphs, and do + that back to front. */ + end = truncate_it.glyph_row->glyphs[TEXT_AREA]; + from = end + truncate_it.glyph_row->used[TEXT_AREA] - 1; + toend = it->glyph_row->glyphs[TEXT_AREA]; + to = toend + it->glyph_row->used[TEXT_AREA] - 1; + + while (from >= end && to >= toend) + *to-- = *from--; + while (to >= toend && CHAR_GLYPH_PADDING_P (*to)) + { + from = + truncate_it.glyph_row->glyphs[TEXT_AREA] + + truncate_it.glyph_row->used[TEXT_AREA] - 1; + while (from >= end && to >= toend) + *to-- = *from--; + } + if (from >= end) + { + /* Need to free some room before prepending additional + glyphs. */ + int move_by = from - end + 1; + struct glyph *g0 = it->glyph_row->glyphs[TEXT_AREA]; + struct glyph *g = g0 + it->glyph_row->used[TEXT_AREA] - 1; - if (to > toend) - it->glyph_row->used[TEXT_AREA] = to - it->glyph_row->glyphs[TEXT_AREA]; + for ( ; g >= g0; g--) + g[move_by] = *g; + while (from >= end) + *to-- = *from--; + it->glyph_row->used[TEXT_AREA] += move_by; + } + } } @@ -15942,8 +16617,7 @@ insert_left_trunc_glyphs (it) must not be zero. */ static void -compute_line_metrics (it) - struct it *it; +compute_line_metrics (struct it *it) { struct glyph_row *row = it->glyph_row; int area, i; @@ -16038,9 +16712,7 @@ compute_line_metrics (it) end of the line if the row ends in italic text. */ static int -append_space_for_newline (it, default_face_p) - struct it *it; - int default_face_p; +append_space_for_newline (struct it *it, int default_face_p) { if (FRAME_WINDOW_P (it->f)) { @@ -16066,7 +16738,7 @@ append_space_for_newline (it, default_face_p) saved_pos = it->position; it->what = IT_CHARACTER; - bzero (&it->position, sizeof it->position); + memset (&it->position, 0, sizeof it->position); it->object = make_number (0); it->c = it->char_to_display = ' '; it->len = 1; @@ -16099,26 +16771,34 @@ append_space_for_newline (it, default_face_p) /* Extend the face of the last glyph in the text area of IT->glyph_row - to the end of the display line. Called from display_line. - If the glyph row is empty, add a space glyph to it so that we - know the face to draw. Set the glyph row flag fill_line_p. */ + to the end of the display line. Called from display_line. If the + glyph row is empty, add a space glyph to it so that we know the + face to draw. Set the glyph row flag fill_line_p. If the glyph + row is R2L, prepend a stretch glyph to cover the empty space to the + left of the leftmost glyph. */ static void -extend_face_to_end_of_line (it) - struct it *it; +extend_face_to_end_of_line (struct it *it) { struct face *face; struct frame *f = it->f; - /* If line is already filled, do nothing. */ - if (it->current_x >= it->last_visible_x) + /* If line is already filled, do nothing. Non window-system frames + get a grace of one more ``pixel'' because their characters are + 1-``pixel'' wide, so they hit the equality too early. This grace + is needed only for R2L rows that are not continued, to produce + one extra blank where we could display the cursor. */ + if (it->current_x >= it->last_visible_x + + (!FRAME_WINDOW_P (f) + && it->glyph_row->reversed_p + && !it->glyph_row->continued_p)) return; /* Face extension extends the background and box of IT->face_id to the end of the line. If the background equals the background of the frame, we don't have to do anything. */ if (it->face_before_selective_p) - face = FACE_FROM_ID (it->f, it->saved_face_id); + face = FACE_FROM_ID (f, it->saved_face_id); else face = FACE_FROM_ID (f, it->face_id); @@ -16126,7 +16806,8 @@ extend_face_to_end_of_line (it) && it->glyph_row->displays_text_p && face->box == FACE_NO_BOX && face->background == FRAME_BACKGROUND_PIXEL (f) - && !face->stipple) + && !face->stipple + && !it->glyph_row->reversed_p) return; /* Set the glyph row flag indicating that the face of the last glyph @@ -16153,6 +16834,50 @@ extend_face_to_end_of_line (it) it->glyph_row->glyphs[TEXT_AREA][0].face_id = it->face_id; it->glyph_row->used[TEXT_AREA] = 1; } +#ifdef HAVE_WINDOW_SYSTEM + if (it->glyph_row->reversed_p) + { + /* Prepend a stretch glyph to the row, such that the + rightmost glyph will be drawn flushed all the way to the + right margin of the window. The stretch glyph that will + occupy the empty space, if any, to the left of the + glyphs. */ + struct font *font = face->font ? face->font : FRAME_FONT (f); + struct glyph *row_start = it->glyph_row->glyphs[TEXT_AREA]; + struct glyph *row_end = row_start + it->glyph_row->used[TEXT_AREA]; + struct glyph *g; + int row_width, stretch_ascent, stretch_width; + struct text_pos saved_pos; + int saved_face_id, saved_avoid_cursor; + + for (row_width = 0, g = row_start; g < row_end; g++) + row_width += g->pixel_width; + stretch_width = window_box_width (it->w, TEXT_AREA) - row_width; + if (stretch_width > 0) + { + stretch_ascent = + (((it->ascent + it->descent) + * FONT_BASE (font)) / FONT_HEIGHT (font)); + saved_pos = it->position; + memset (&it->position, 0, sizeof it->position); + saved_avoid_cursor = it->avoid_cursor_p; + it->avoid_cursor_p = 1; + saved_face_id = it->face_id; + /* The last row's stretch glyph should get the default + face, to avoid painting the rest of the window with + the region face, if the region ends at ZV. */ + if (it->glyph_row->ends_at_zv_p) + it->face_id = DEFAULT_FACE_ID; + else + it->face_id = face->id; + append_stretch_glyph (it, make_number (0), stretch_width, + it->ascent + it->descent, stretch_ascent); + it->position = saved_pos; + it->avoid_cursor_p = saved_avoid_cursor; + it->face_id = saved_face_id; + } + } +#endif /* HAVE_WINDOW_SYSTEM */ } else { @@ -16167,11 +16892,17 @@ extend_face_to_end_of_line (it) saved_pos = it->position; it->what = IT_CHARACTER; - bzero (&it->position, sizeof it->position); + memset (&it->position, 0, sizeof it->position); it->object = make_number (0); it->c = it->char_to_display = ' '; it->len = 1; - it->face_id = face->id; + /* The last row's blank glyphs should get the default face, to + avoid painting the rest of the window with the region face, + if the region ends at ZV. */ + if (it->glyph_row->ends_at_zv_p) + it->face_id = DEFAULT_FACE_ID; + else + it->face_id = face->id; PRODUCE_GLYPHS (it); @@ -16193,10 +16924,9 @@ extend_face_to_end_of_line (it) trailing whitespace. */ static int -trailing_whitespace_p (charpos) - int charpos; +trailing_whitespace_p (EMACS_INT charpos) { - int bytepos = CHAR_TO_BYTE (charpos); + EMACS_INT bytepos = CHAR_TO_BYTE (charpos); int c = 0; while (bytepos < ZV_BYTE @@ -16216,9 +16946,7 @@ trailing_whitespace_p (charpos) /* Highlight trailing whitespace, if any, in ROW. */ void -highlight_trailing_whitespace (f, row) - struct frame *f; - struct glyph_row *row; +highlight_trailing_whitespace (struct frame *f, struct glyph_row *row) { int used = row->used[TEXT_AREA]; @@ -16227,19 +16955,37 @@ highlight_trailing_whitespace (f, row) struct glyph *start = row->glyphs[TEXT_AREA]; struct glyph *glyph = start + used - 1; + if (row->reversed_p) + { + /* Right-to-left rows need to be processed in the opposite + direction, so swap the edge pointers. */ + glyph = start; + start = row->glyphs[TEXT_AREA] + used - 1; + } + /* Skip over glyphs inserted to display the cursor at the end of a line, for extending the face of the last glyph to the end of the line on terminals, and for truncation and continuation glyphs. */ - while (glyph >= start - && glyph->type == CHAR_GLYPH - && INTEGERP (glyph->object)) - --glyph; + if (!row->reversed_p) + { + while (glyph >= start + && glyph->type == CHAR_GLYPH + && INTEGERP (glyph->object)) + --glyph; + } + else + { + while (glyph <= start + && glyph->type == CHAR_GLYPH + && INTEGERP (glyph->object)) + ++glyph; + } /* If last glyph is a space or stretch, and it's trailing whitespace, set the face of all trailing whitespace glyphs in IT->glyph_row to `trailing-whitespace'. */ - if (glyph >= start + if ((row->reversed_p ? glyph <= start : glyph >= start) && BUFFERP (glyph->object) && (glyph->type == STRETCH_GLYPH || (glyph->type == CHAR_GLYPH @@ -16250,12 +16996,24 @@ highlight_trailing_whitespace (f, row) if (face_id < 0) return; - while (glyph >= start - && BUFFERP (glyph->object) - && (glyph->type == STRETCH_GLYPH - || (glyph->type == CHAR_GLYPH - && glyph->u.ch == ' '))) - (glyph--)->face_id = face_id; + if (!row->reversed_p) + { + while (glyph >= start + && BUFFERP (glyph->object) + && (glyph->type == STRETCH_GLYPH + || (glyph->type == CHAR_GLYPH + && glyph->u.ch == ' '))) + (glyph--)->face_id = face_id; + } + else + { + while (glyph <= start + && BUFFERP (glyph->object) + && (glyph->type == STRETCH_GLYPH + || (glyph->type == CHAR_GLYPH + && glyph->u.ch == ' '))) + (glyph++)->face_id = face_id; + } } } } @@ -16265,13 +17023,11 @@ highlight_trailing_whitespace (f, row) used to hold the cursor. */ static int -cursor_row_p (w, row) - struct window *w; - struct glyph_row *row; +cursor_row_p (struct window *w, struct glyph_row *row) { int cursor_row_p = 1; - if (PT == MATRIX_ROW_END_CHARPOS (row)) + if (PT == CHARPOS (row->end.pos)) { /* Suppose the row ends on a string. Unless the row is continued, that means it ends on a newline @@ -16308,14 +17064,15 @@ cursor_row_p (w, row) { /* If the row ends in middle of a real character, and the line is continued, we want the cursor here. - That's because MATRIX_ROW_END_CHARPOS would equal + That's because CHARPOS (ROW->end.pos) would equal PT if PT is before the character. */ if (!row->ends_in_ellipsis_p) cursor_row_p = row->continued_p; else /* If the row ends in an ellipsis, then - MATRIX_ROW_END_CHARPOS will equal point after the invisible text. - We want that position to be displayed after the ellipsis. */ + CHARPOS (ROW->end.pos) will equal point after the + invisible text. We want that position to be displayed + after the ellipsis. */ cursor_row_p = 0; } /* If the row ends at ZV, display the cursor at the end of that @@ -16381,9 +17138,7 @@ push_display_prop (struct it *it, Lisp_Object prop) /* Return the character-property PROP at the current position in IT. */ static Lisp_Object -get_it_property (it, prop) - struct it *it; - Lisp_Object prop; +get_it_property (struct it *it, Lisp_Object prop) { Lisp_Object position; @@ -16427,6 +17182,110 @@ handle_line_prefix (struct it *it) +/* Remove N glyphs at the start of a reversed IT->glyph_row. Called + only for R2L lines from display_line, when it decides that too many + glyphs were produced by PRODUCE_GLYPHS, and the line needs to be + continued. */ +static void +unproduce_glyphs (struct it *it, int n) +{ + struct glyph *glyph, *end; + + xassert (it->glyph_row); + xassert (it->glyph_row->reversed_p); + xassert (it->area == TEXT_AREA); + xassert (n <= it->glyph_row->used[TEXT_AREA]); + + if (n > it->glyph_row->used[TEXT_AREA]) + n = it->glyph_row->used[TEXT_AREA]; + glyph = it->glyph_row->glyphs[TEXT_AREA] + n; + end = it->glyph_row->glyphs[TEXT_AREA] + it->glyph_row->used[TEXT_AREA]; + for ( ; glyph < end; glyph++) + glyph[-n] = *glyph; +} + +/* Find the positions in a bidi-reordered ROW to serve as ROW->minpos + and ROW->maxpos. */ +static void +find_row_edges (struct it *it, struct glyph_row *row, + EMACS_INT min_pos, EMACS_INT min_bpos, + EMACS_INT max_pos, EMACS_INT max_bpos) +{ + /* FIXME: Revisit this when glyph ``spilling'' in continuation + lines' rows is implemented for bidi-reordered rows. */ + + /* ROW->minpos is the value of min_pos, the minimal buffer position + we have in ROW. */ + if (min_pos <= ZV) + SET_TEXT_POS (row->minpos, min_pos, min_bpos); + else + { + /* We didn't find _any_ valid buffer positions in any of the + glyphs, so we must trust the iterator's computed + positions. */ + row->minpos = row->start.pos; + max_pos = CHARPOS (it->current.pos); + max_bpos = BYTEPOS (it->current.pos); + } + + if (!max_pos) + abort (); + + /* Here are the various use-cases for ending the row, and the + corresponding values for ROW->maxpos: + + Line ends in a newline from buffer eol_pos + 1 + Line is continued from buffer max_pos + 1 + Line is truncated on right it->current.pos + Line ends in a newline from string max_pos + Line is continued from string max_pos + Line is continued from display vector max_pos + Line is entirely from a string min_pos == max_pos + Line is entirely from a display vector min_pos == max_pos + Line that ends at ZV ZV + + If you discover other use-cases, please add them here as + appropriate. */ + if (row->ends_at_zv_p) + row->maxpos = it->current.pos; + else if (row->used[TEXT_AREA]) + { + if (row->ends_in_newline_from_string_p) + SET_TEXT_POS (row->maxpos, max_pos, max_bpos); + else if (CHARPOS (it->eol_pos) > 0) + SET_TEXT_POS (row->maxpos, + CHARPOS (it->eol_pos) + 1, BYTEPOS (it->eol_pos) + 1); + else if (row->continued_p) + { + /* If max_pos is different from IT's current position, it + means IT->method does not belong to the display element + at max_pos. However, it also means that the display + element at max_pos was displayed in its entirety on this + line, which is equivalent to saying that the next line + starts at the next buffer position. */ + if (IT_CHARPOS (*it) == max_pos && it->method != GET_FROM_BUFFER) + SET_TEXT_POS (row->maxpos, max_pos, max_bpos); + else + { + INC_BOTH (max_pos, max_bpos); + SET_TEXT_POS (row->maxpos, max_pos, max_bpos); + } + } + else if (row->truncated_on_right_p) + /* display_line already called reseat_at_next_visible_line_start, + which puts the iterator at the beginning of the next line, in + the logical order. */ + row->maxpos = it->current.pos; + else if (max_pos == min_pos && it->method != GET_FROM_BUFFER) + /* A line that is entirely from a string/image/stretch... */ + row->maxpos = row->minpos; + else + abort (); + } + else + row->maxpos = it->current.pos; +} + /* Construct the glyph row IT->glyph_row in the desired matrix of IT->w from text at the current position of IT. See dispextern.h for an overview of struct it. Value is non-zero if @@ -16434,8 +17293,7 @@ handle_line_prefix (struct it *it) only. */ static int -display_line (it) - struct it *it; +display_line (struct it *it) { struct glyph_row *row = it->glyph_row; Lisp_Object overlay_arrow_string; @@ -16444,6 +17302,10 @@ display_line (it) int wrap_row_used = -1, wrap_row_ascent, wrap_row_height; int wrap_row_phys_ascent, wrap_row_phys_height; int wrap_row_extra_line_spacing; + EMACS_INT wrap_row_min_pos, wrap_row_min_bpos; + EMACS_INT wrap_row_max_pos, wrap_row_max_bpos; + int cvpos; + EMACS_INT min_pos = ZV + 1, min_bpos, max_pos = 0, max_bpos; /* We always start displaying at hpos zero even if hscrolled. */ xassert (it->hpos == 0 && it->current_x == 0); @@ -16500,6 +17362,23 @@ display_line (it) row->phys_height = it->max_phys_ascent + it->max_phys_descent; row->extra_line_spacing = it->max_extra_line_spacing; +/* Utility macro to record max and min buffer positions seen until now. */ +#define RECORD_MAX_MIN_POS(IT) \ + do \ + { \ + if (IT_CHARPOS (*(IT)) < min_pos) \ + { \ + min_pos = IT_CHARPOS (*(IT)); \ + min_bpos = IT_BYTEPOS (*(IT)); \ + } \ + if (IT_CHARPOS (*(IT)) > max_pos) \ + { \ + max_pos = IT_CHARPOS (*(IT)); \ + max_bpos = IT_BYTEPOS (*(IT)); \ + } \ + } \ + while (0) + /* Loop generating characters. The loop is left with IT on the next character to display. */ while (1) @@ -16532,6 +17411,12 @@ display_line (it) it->continuation_lines_width = 0; row->ends_at_zv_p = 1; + /* A row that displays right-to-left text must always have + its last face extended all the way to the end of line, + even if this row ends in ZV, because we still write to + the screen left to right. */ + if (row->reversed_p) + extend_face_to_end_of_line (it); break; } @@ -16563,6 +17448,10 @@ display_line (it) wrap_row_phys_ascent = row->phys_ascent; wrap_row_phys_height = row->phys_height; wrap_row_extra_line_spacing = row->extra_line_spacing; + wrap_row_min_pos = min_pos; + wrap_row_min_bpos = min_bpos; + wrap_row_max_pos = max_pos; + wrap_row_max_bpos = max_bpos; may_wrap = 0; } } @@ -16613,6 +17502,10 @@ display_line (it) it->max_extra_line_spacing); if (it->current_x - it->pixel_width < it->first_visible_x) row->x = x - it->first_visible_x; + /* Record the maximum and minimum buffer positions seen so + far in glyphs that will be displayed by this row. */ + if (it->bidi_p) + RECORD_MAX_MIN_POS (it); } else { @@ -16646,6 +17539,11 @@ display_line (it) it->current_x = new_x; it->continuation_lines_width += new_x; ++it->hpos; + /* Record the maximum and minimum buffer + positions seen so far in glyphs that will be + displayed by this row. */ + if (it->bidi_p) + RECORD_MAX_MIN_POS (it); if (i == nglyphs - 1) { /* If line-wrap is on, check if a previous @@ -16684,6 +17582,9 @@ display_line (it) /* A padding glyph that doesn't fit on this line. This means the whole character doesn't fit on the line. */ + if (row->reversed_p) + unproduce_glyphs (it, row->used[TEXT_AREA] + - n_glyphs_before); row->used[TEXT_AREA] = n_glyphs_before; /* Fill the rest of the row with continuation @@ -16706,6 +17607,9 @@ display_line (it) else if (wrap_row_used > 0) { back_to_wrap: + if (row->reversed_p) + unproduce_glyphs (it, + row->used[TEXT_AREA] - wrap_row_used); *it = wrap_it; it->continuation_lines_width += wrap_x; row->used[TEXT_AREA] = wrap_row_used; @@ -16714,6 +17618,10 @@ display_line (it) row->phys_ascent = wrap_row_phys_ascent; row->phys_height = wrap_row_phys_height; row->extra_line_spacing = wrap_row_extra_line_spacing; + min_pos = wrap_row_min_pos; + min_bpos = wrap_row_min_bpos; + max_pos = wrap_row_max_pos; + max_bpos = wrap_row_max_bpos; row->continued_p = 1; row->ends_at_zv_p = 0; row->exact_window_width_line_p = 0; @@ -16741,6 +17649,9 @@ display_line (it) /* Something other than a TAB that draws past the right edge of the window. Restore positions to values before the element. */ + if (row->reversed_p) + unproduce_glyphs (it, row->used[TEXT_AREA] + - (n_glyphs_before + i)); row->used[TEXT_AREA] = n_glyphs_before + i; /* Display continuation glyphs. */ @@ -16773,6 +17684,12 @@ display_line (it) /* Increment number of glyphs actually displayed. */ ++it->hpos; + /* Record the maximum and minimum buffer positions + seen so far in glyphs that will be displayed by + this row. */ + if (it->bidi_p) + RECORD_MAX_MIN_POS (it); + if (x < it->first_visible_x) /* Glyph is partially visible, i.e. row starts at negative X position. */ @@ -16824,6 +17741,10 @@ display_line (it) if (used_before == 0) row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position); + /* Record the position of the newline, for use in + find_row_edges. */ + it->eol_pos = it->current.pos; + /* Consume the line end. This skips over invisible lines. */ set_iterator_to_next (it, 1); it->continuation_lines_width = 0; @@ -16846,9 +17767,26 @@ display_line (it) { int i, n; - for (i = row->used[TEXT_AREA] - 1; i > 0; --i) - if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i])) - break; + if (!row->reversed_p) + { + for (i = row->used[TEXT_AREA] - 1; i > 0; --i) + if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i])) + break; + } + else + { + for (i = 0; i < row->used[TEXT_AREA]; i++) + if (!CHAR_GLYPH_PADDING_P (row->glyphs[TEXT_AREA][i])) + break; + /* Remove any padding glyphs at the front of ROW, to + make room for the truncation glyphs we will be + adding below. The loop below always inserts at + least one truncation glyph, so also remove the + last glyph added to ROW. */ + unproduce_glyphs (it, i + 1); + /* Adjust i for the loop below. */ + i = row->used[TEXT_AREA] - (i + 1); + } for (n = row->used[TEXT_AREA]; i < n; ++i) { @@ -16886,13 +17824,33 @@ display_line (it) /* If line is not empty and hscrolled, maybe insert truncation glyphs at the left window margin. */ if (it->first_visible_x - && IT_CHARPOS (*it) != MATRIX_ROW_START_CHARPOS (row)) + && IT_CHARPOS (*it) != CHARPOS (row->start.pos)) { if (!FRAME_WINDOW_P (it->f)) insert_left_trunc_glyphs (it); row->truncated_on_left_p = 1; } + /* Remember the position at which this line ends. + + BIDI Note: any code that needs MATRIX_ROW_START/END_CHARPOS + cannot be before the call to find_row_edges below, since that is + where these positions are determined. */ + row->end = it->current; + if (!it->bidi_p) + { + row->minpos = row->start.pos; + row->maxpos = row->end.pos; + } + else + { + /* ROW->minpos and ROW->maxpos must be the smallest and + `1 + the largest' buffer positions in ROW. But if ROW was + bidi-reordered, these two positions can be anywhere in the + row, so we must determine them now. */ + find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos); + } + /* If the start of this line is the overlay arrow-position, then mark this glyph row as the one containing the overlay arrow. This is clearly a mess with variable size fonts. It would be @@ -16938,9 +17896,6 @@ display_line (it) /* Compute pixel dimensions of this line. */ compute_line_metrics (it); - /* Remember the position at which this line ends. */ - row->end = it->current; - /* Record whether this row ends inside an ellipsis. */ row->ends_in_ellipsis_p = (it->method == GET_FROM_DISPLAY_VECTOR @@ -16958,7 +17913,18 @@ display_line (it) it->right_user_fringe_face_id = 0; /* Maybe set the cursor. */ - if (it->w->cursor.vpos < 0 + cvpos = it->w->cursor.vpos; + if ((cvpos < 0 + /* In bidi-reordered rows, keep checking for proper cursor + position even if one has been found already, because buffer + positions in such rows change non-linearly with ROW->VPOS, + when a line is continued. One exception: when we are at ZV, + display cursor on the first suitable glyph row, since all + the empty rows after that also have their position set to ZV. */ + /* FIXME: Revisit this when glyph ``spilling'' in continuation + lines' rows is implemented for bidi-reordered rows. */ + || (it->bidi_p + && !MATRIX_ROW (it->w->desired_matrix, cvpos)->ends_at_zv_p)) && PT >= MATRIX_ROW_START_CHARPOS (row) && PT <= MATRIX_ROW_END_CHARPOS (row) && cursor_row_p (it->w, row)) @@ -16974,10 +17940,104 @@ display_line (it) row to be used. */ it->current_x = it->hpos = 0; it->current_y += row->height; + SET_TEXT_POS (it->eol_pos, 0, 0); ++it->vpos; ++it->glyph_row; - it->start = it->current; + /* The next row should by default use the same value of the + reversed_p flag as this one. set_iterator_to_next decides when + it's a new paragraph, and PRODUCE_GLYPHS recomputes the value of + the flag accordingly. */ + if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w)) + it->glyph_row->reversed_p = row->reversed_p; + it->start = row->end; return row->displays_text_p; + +#undef RECORD_MAX_MIN_POS +} + +DEFUN ("current-bidi-paragraph-direction", Fcurrent_bidi_paragraph_direction, + Scurrent_bidi_paragraph_direction, 0, 1, 0, + doc: /* Return paragraph direction at point in BUFFER. +Value is either `left-to-right' or `right-to-left'. +If BUFFER is omitted or nil, it defaults to the current buffer. + +Paragraph direction determines how the text in the paragraph is displayed. +In left-to-right paragraphs, text begins at the left margin of the window +and the reading direction is generally left to right. In right-to-left +paragraphs, text begins at the right margin and is read from right to left. + +See also `bidi-paragraph-direction'. */) + (Lisp_Object buffer) +{ + struct buffer *buf; + struct buffer *old; + + if (NILP (buffer)) + buf = current_buffer; + else + { + CHECK_BUFFER (buffer); + buf = XBUFFER (buffer); + old = current_buffer; + } + + if (NILP (buf->bidi_display_reordering)) + return Qleft_to_right; + else if (!NILP (buf->bidi_paragraph_direction)) + return buf->bidi_paragraph_direction; + else + { + /* Determine the direction from buffer text. We could try to + use current_matrix if it is up to date, but this seems fast + enough as it is. */ + struct bidi_it itb; + EMACS_INT pos = BUF_PT (buf); + EMACS_INT bytepos = BUF_PT_BYTE (buf); + int c; + + if (buf != current_buffer) + set_buffer_temp (buf); + /* bidi_paragraph_init finds the base direction of the paragraph + by searching forward from paragraph start. We need the base + direction of the current or _previous_ paragraph, so we need + to make sure we are within that paragraph. To that end, find + the previous non-empty line. */ + if (pos >= ZV && pos > BEGV) + { + pos--; + bytepos = CHAR_TO_BYTE (pos); + } + while ((c = FETCH_BYTE (bytepos)) == '\n' + || c == ' ' || c == '\t' || c == '\f') + { + if (bytepos <= BEGV_BYTE) + break; + bytepos--; + pos--; + } + while (!CHAR_HEAD_P (FETCH_BYTE (bytepos))) + bytepos--; + itb.charpos = pos; + itb.bytepos = bytepos; + itb.first_elt = 1; + itb.separator_limit = -1; + itb.paragraph_dir = NEUTRAL_DIR; + + bidi_paragraph_init (NEUTRAL_DIR, &itb, 1); + if (buf != current_buffer) + set_buffer_temp (old); + switch (itb.paragraph_dir) + { + case L2R: + return Qleft_to_right; + break; + case R2L: + return Qright_to_left; + break; + default: + abort (); + } + } } @@ -16997,8 +18057,7 @@ display_line (it) for the menu bar. */ static void -display_menu_bar (w) - struct window *w; +display_menu_bar (struct window *w) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct it it; @@ -17102,9 +18161,7 @@ display_menu_bar (w) the number of windows whose mode lines were redisplayed. */ static int -redisplay_mode_lines (window, force) - Lisp_Object window; - int force; +redisplay_mode_lines (Lisp_Object window, int force) { int nwindows = 0; @@ -17166,8 +18223,7 @@ redisplay_mode_lines (window, force) sum number of mode lines and header lines displayed. */ static int -display_mode_lines (w) - struct window *w; +display_mode_lines (struct window *w) { Lisp_Object old_selected_window, old_selected_frame; int n = 0; @@ -17211,10 +18267,7 @@ display_mode_lines (w) displayed. */ static int -display_mode_line (w, face_id, format) - struct window *w; - enum face_id face_id; - Lisp_Object format; +display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) { struct it it; struct face *face; @@ -17273,8 +18326,7 @@ display_mode_line (w, face_id, format) Return the updated list. */ static Lisp_Object -move_elt_to_front (elt, list) - Lisp_Object elt, list; +move_elt_to_front (Lisp_Object elt, Lisp_Object list) { register Lisp_Object tail, prev; register Lisp_Object tem; @@ -17332,12 +18384,8 @@ move_elt_to_front (elt, list) `store_mode_line_string', or `display_string'. */ static int -display_mode_element (it, depth, field_width, precision, elt, props, risky) - struct it *it; - int depth; - int field_width, precision; - Lisp_Object elt, props; - int risky; +display_mode_element (struct it *it, int depth, int field_width, int precision, + Lisp_Object elt, Lisp_Object props, int risky) { int n = 0, field, prec; int literal = 0; @@ -17354,7 +18402,7 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) { /* A string: output it and check for %-constructs within it. */ unsigned char c; - int offset = 0; + EMACS_INT offset = 0; if (SCHARS (elt) > 0 && (!NILP (props) || risky)) @@ -17451,7 +18499,7 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) && (mode_line_target != MODE_LINE_DISPLAY || it->current_x < it->last_visible_x)) { - int last_offset = offset; + EMACS_INT last_offset = offset; /* Advance to end of string or next format specifier. */ while ((c = SREF (elt, offset++)) != '\0' && c != '%') @@ -17459,7 +18507,7 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) if (offset - 1 != last_offset) { - int nchars, nbytes; + EMACS_INT nchars, nbytes; /* Output to end of string or up to '%'. Field width is length of string. Don't output more than @@ -17478,11 +18526,11 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) break; case MODE_LINE_STRING: { - int bytepos = last_offset; - int charpos = string_byte_to_char (elt, bytepos); - int endpos = (precision <= 0 - ? string_byte_to_char (elt, offset) - : charpos + nchars); + EMACS_INT bytepos = last_offset; + EMACS_INT charpos = string_byte_to_char (elt, bytepos); + EMACS_INT endpos = (precision <= 0 + ? string_byte_to_char (elt, offset) + : charpos + nchars); n += store_mode_line_string (NULL, Fsubstring (elt, make_number (charpos), @@ -17492,8 +18540,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) break; case MODE_LINE_DISPLAY: { - int bytepos = last_offset; - int charpos = string_byte_to_char (elt, bytepos); + EMACS_INT bytepos = last_offset; + EMACS_INT charpos = string_byte_to_char (elt, bytepos); if (precision <= 0) nchars = string_byte_to_char (elt, offset) - charpos; @@ -17506,7 +18554,7 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) } else /* c == '%' */ { - int percent_position = offset; + EMACS_INT percent_position = offset; /* Get the specified minimum width. Zero means don't pad. */ @@ -17528,8 +18576,8 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) else if (c != 0) { int multibyte; - int bytepos, charpos; - unsigned char *spec; + EMACS_INT bytepos, charpos; + const unsigned char *spec; Lisp_Object string; bytepos = percent_position; @@ -17799,15 +18847,10 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky) */ static int -store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props) - char *string; - Lisp_Object lisp_string; - int copy_string; - int field_width; - int precision; - Lisp_Object props; +store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string, + int field_width, int precision, Lisp_Object props) { - int len; + EMACS_INT len; int n = 0; if (string != NULL) @@ -17896,8 +18939,7 @@ If FACE is an integer, the value string has no text properties. Optional third and fourth args WINDOW and BUFFER specify the window and buffer to use as the context for the formatting (defaults are the selected window and the window's buffer). */) - (format, face, window, buffer) - Lisp_Object format, face, window, buffer; + (Lisp_Object format, Lisp_Object face, Lisp_Object window, Lisp_Object buffer) { struct it it; int len; @@ -17992,10 +19034,7 @@ are the selected window and the window's buffer). */) the positive integer D to BUF using a minimal field width WIDTH. */ static void -pint2str (buf, width, d) - register char *buf; - register int width; - register int d; +pint2str (register char *buf, register int width, register int d) { register char *p = buf; @@ -18039,10 +19078,7 @@ static const char power_letter[] = }; static void -pint2hrstr (buf, width, d) - char *buf; - int width; - int d; +pint2hrstr (char *buf, int width, int d) { /* We aim to represent the nonnegative integer D as QUOTIENT.TENTHS * 10 ^ (3 * EXPONENT). */ @@ -18143,10 +19179,7 @@ pint2hrstr (buf, width, d) static unsigned char invalid_eol_type[] = "(*invalid*)"; static char * -decode_mode_spec_coding (coding_system, buf, eol_flag) - Lisp_Object coding_system; - register char *buf; - int eol_flag; +decode_mode_spec_coding (Lisp_Object coding_system, register char *buf, int eol_flag) { Lisp_Object val; int multibyte = !NILP (current_buffer->enable_multibyte_characters); @@ -18212,7 +19245,7 @@ decode_mode_spec_coding (coding_system, buf, eol_flag) eol_str = invalid_eol_type; eol_str_len = sizeof (invalid_eol_type) - 1; } - bcopy (eol_str, buf, eol_str_len); + memcpy (buf, eol_str, eol_str_len); buf += eol_str_len; } @@ -18230,12 +19263,9 @@ decode_mode_spec_coding (coding_system, buf, eol_flag) static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------"; -static char * -decode_mode_spec (w, c, field_width, precision, string) - struct window *w; - register int c; - int field_width, precision; - Lisp_Object *string; +static const char * +decode_mode_spec (struct window *w, register int c, int field_width, + int precision, Lisp_Object *string) { Lisp_Object obj; struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -18365,22 +19395,23 @@ decode_mode_spec (w, c, field_width, precision, string) case 'i': { - int size = ZV - BEGV; + EMACS_INT size = ZV - BEGV; pint2str (decode_mode_spec_buf, field_width, size); return decode_mode_spec_buf; } case 'I': { - int size = ZV - BEGV; + EMACS_INT size = ZV - BEGV; pint2hrstr (decode_mode_spec_buf, field_width, size); return decode_mode_spec_buf; } case 'l': { - int startpos, startpos_byte, line, linepos, linepos_byte; - int topline, nlines, junk, height; + EMACS_INT startpos, startpos_byte, line, linepos, linepos_byte; + int topline, nlines, height; + EMACS_INT junk; /* %c and %l are ignored in `frame-title-format'. */ if (mode_line_target == MODE_LINE_TITLE) @@ -18441,9 +19472,9 @@ decode_mode_spec (w, c, field_width, precision, string) else if (nlines < height + 25 || nlines > height * 3 + 50 || linepos == BUF_BEGV (b)) { - int limit = BUF_BEGV (b); - int limit_byte = BUF_BEGV_BYTE (b); - int position; + EMACS_INT limit = BUF_BEGV (b); + EMACS_INT limit_byte = BUF_BEGV_BYTE (b); + EMACS_INT position; int distance = (height * 2 + 30) * line_number_display_limit_width; if (startpos - distance > limit) @@ -18505,8 +19536,8 @@ decode_mode_spec (w, c, field_width, precision, string) case 'p': { - int pos = marker_position (w->start); - int total = BUF_ZV (b) - BUF_BEGV (b); + EMACS_INT pos = marker_position (w->start); + EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b); if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b)) { @@ -18528,7 +19559,7 @@ decode_mode_spec (w, c, field_width, precision, string) so get us a 2-digit number that is close. */ if (total == 100) total = 99; - sprintf (decode_mode_spec_buf, "%2d%%", total); + sprintf (decode_mode_spec_buf, "%2ld%%", (long)total); return decode_mode_spec_buf; } } @@ -18536,9 +19567,9 @@ decode_mode_spec (w, c, field_width, precision, string) /* Display percentage of size above the bottom of the screen. */ case 'P': { - int toppos = marker_position (w->start); - int botpos = BUF_Z (b) - XFASTINT (w->window_end_pos); - int total = BUF_ZV (b) - BUF_BEGV (b); + EMACS_INT toppos = marker_position (w->start); + EMACS_INT botpos = BUF_Z (b) - XFASTINT (w->window_end_pos); + EMACS_INT total = BUF_ZV (b) - BUF_BEGV (b); if (botpos >= BUF_ZV (b)) { @@ -18559,9 +19590,9 @@ decode_mode_spec (w, c, field_width, precision, string) if (total == 100) total = 99; if (toppos <= BUF_BEGV (b)) - sprintf (decode_mode_spec_buf, "Top%2d%%", total); + sprintf (decode_mode_spec_buf, "Top%2ld%%", (long)total); else - sprintf (decode_mode_spec_buf, "%2d%%", total); + sprintf (decode_mode_spec_buf, "%2ld%%", (long)total); return decode_mode_spec_buf; } } @@ -18571,7 +19602,7 @@ decode_mode_spec (w, c, field_width, precision, string) obj = Fget_buffer_process (Fcurrent_buffer ()); if (NILP (obj)) return "no process"; -#ifdef subprocesses +#ifndef MSDOS obj = Fsymbol_name (Fprocess_status (obj)); #endif break; @@ -18652,9 +19683,9 @@ decode_mode_spec (w, c, field_width, precision, string) Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */ static int -display_count_lines (start, start_byte, limit_byte, count, byte_pos_ptr) - int start, start_byte, limit_byte, count; - int *byte_pos_ptr; +display_count_lines (EMACS_INT start, EMACS_INT start_byte, + EMACS_INT limit_byte, int count, + EMACS_INT *byte_pos_ptr) { register unsigned char *cursor; unsigned char *base; @@ -18794,16 +19825,9 @@ display_count_lines (start, start_byte, limit_byte, count, byte_pos_ptr) Value is the number of columns displayed. */ static int -display_string (string, lisp_string, face_string, face_string_pos, - start, it, field_width, precision, max_x, multibyte) - unsigned char *string; - Lisp_Object lisp_string; - Lisp_Object face_string; - EMACS_INT face_string_pos; - EMACS_INT start; - struct it *it; - int field_width, precision, max_x; - int multibyte; +display_string (const unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string, + EMACS_INT face_string_pos, EMACS_INT start, struct it *it, + int field_width, int precision, int max_x, int multibyte) { int hpos_at_start = it->hpos; int saved_face_id = it->face_id; @@ -18813,7 +19837,7 @@ display_string (string, lisp_string, face_string, face_string_pos, with index START. */ reseat_to_string (it, NILP (lisp_string) ? string : NULL, lisp_string, start, precision, field_width, multibyte); - if (string && STRINGP (lisp_string)) + if (string && STRINGP (lisp_string)) /* LISP_STRING is the one returned by decode_mode_spec. We should ignore its text properties. */ it->stop_charpos = -1; @@ -18987,9 +20011,7 @@ display_string (string, lisp_string, face_string, face_string_pos, and 1 if it's invisible and without an ellipsis. */ int -invisible_p (propval, list) - register Lisp_Object propval; - Lisp_Object list; +invisible_p (register Lisp_Object propval, Lisp_Object list) { register Lisp_Object tail, proptail; @@ -19032,8 +20054,7 @@ is checked; or it can be some other value, which is then presumed to be the value of the `invisible' property of the text of interest. The non-nil value returned can be t for truly invisible text or something else if the text is replaced by an ellipsis. */) - (pos_or_prop) - Lisp_Object pos_or_prop; + (Lisp_Object pos_or_prop) { Lisp_Object prop = (NATNUMP (pos_or_prop) || MARKERP (pos_or_prop) @@ -19118,12 +20139,8 @@ else if the text is replaced by an ellipsis. */) : - 1) int -calc_pixel_width_or_height (res, it, prop, font, width_p, align_to) - double *res; - struct it *it; - Lisp_Object prop; - struct font *font; - int width_p, *align_to; +calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, + struct font *font, int width_p, int *align_to) { double pixels; @@ -19341,7 +20358,7 @@ dump_glyph_string (s) face-override for drawing S. */ #ifdef HAVE_NTGUI -#define OPTIONAL_HDC(hdc) hdc, +#define OPTIONAL_HDC(hdc) HDC hdc, #define DECLARE_HDC(hdc) HDC hdc; #define ALLOCATE_HDC(hdc, f) hdc = get_frame_dc ((f)) #define RELEASE_HDC(hdc, f) release_frame_dc ((f), (hdc)) @@ -19355,17 +20372,12 @@ dump_glyph_string (s) #endif static void -init_glyph_string (s, OPTIONAL_HDC (hdc) char2b, w, row, area, start, hl) - struct glyph_string *s; - DECLARE_HDC (hdc) - XChar2b *char2b; - struct window *w; - struct glyph_row *row; - enum glyph_row_area area; - int start; - enum draw_glyphs_face hl; +init_glyph_string (struct glyph_string *s, + OPTIONAL_HDC (hdc) + XChar2b *char2b, struct window *w, struct glyph_row *row, + enum glyph_row_area area, int start, enum draw_glyphs_face hl) { - bzero (s, sizeof *s); + memset (s, 0, sizeof *s); s->w = w; s->f = XFRAME (w->frame); #ifdef HAVE_NTGUI @@ -19388,9 +20400,8 @@ init_glyph_string (s, OPTIONAL_HDC (hdc) char2b, w, row, area, start, hl) with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */ static INLINE void -append_glyph_string_lists (head, tail, h, t) - struct glyph_string **head, **tail; - struct glyph_string *h, *t; +append_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail, + struct glyph_string *h, struct glyph_string *t) { if (h) { @@ -19409,9 +20420,8 @@ append_glyph_string_lists (head, tail, h, t) result. */ static INLINE void -prepend_glyph_string_lists (head, tail, h, t) - struct glyph_string **head, **tail; - struct glyph_string *h, *t; +prepend_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail, + struct glyph_string *h, struct glyph_string *t) { if (h) { @@ -19429,9 +20439,8 @@ prepend_glyph_string_lists (head, tail, h, t) Set *HEAD and *TAIL to the resulting list. */ static INLINE void -append_glyph_string (head, tail, s) - struct glyph_string **head, **tail; - struct glyph_string *s; +append_glyph_string (struct glyph_string **head, struct glyph_string **tail, + struct glyph_string *s) { s->next = s->prev = NULL; append_glyph_string_lists (head, tail, s, s); @@ -19446,11 +20455,8 @@ append_glyph_string (head, tail, s) DISPLAY_P is non-zero. */ static INLINE struct face * -get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p, display_p) - struct frame *f; - int c, face_id; - XChar2b *char2b; - int multibyte_p, display_p; +get_char_face_and_encoding (struct frame *f, int c, int face_id, + XChar2b *char2b, int multibyte_p, int display_p) { struct face *face = FACE_FROM_ID (f, face_id); @@ -19482,11 +20488,8 @@ get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p, display_p) a pointer to a realized face that is ready for display. */ static INLINE struct face * -get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p) - struct frame *f; - struct glyph *glyph; - XChar2b *char2b; - int *two_byte_p; +get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, + XChar2b *char2b, int *two_byte_p) { struct face *face; @@ -19549,10 +20552,8 @@ get_char_glyph_code (int c, struct font *font, XChar2b *char2b) Value is the index of a component not in S. */ static int -fill_composite_glyph_string (s, base_face, overlaps) - struct glyph_string *s; - struct face *base_face; - int overlaps; +fill_composite_glyph_string (struct glyph_string *s, struct face *base_face, + int overlaps) { int i; /* For all glyphs of this composition, starting at the offset @@ -19615,10 +20616,8 @@ fill_composite_glyph_string (s, base_face, overlaps) } static int -fill_gstring_glyph_string (s, face_id, start, end, overlaps) - struct glyph_string *s; - int face_id; - int start, end, overlaps; +fill_gstring_glyph_string (struct glyph_string *s, int face_id, + int start, int end, int overlaps) { struct glyph *glyph, *last; Lisp_Object lgstring; @@ -19628,8 +20627,8 @@ fill_gstring_glyph_string (s, face_id, start, end, overlaps) glyph = s->row->glyphs[s->area] + start; last = s->row->glyphs[s->area] + end; s->cmp_id = glyph->u.cmp.id; - s->cmp_from = glyph->u.cmp.from; - s->cmp_to = glyph->u.cmp.to + 1; + s->cmp_from = glyph->slice.cmp.from; + s->cmp_to = glyph->slice.cmp.to + 1; s->face = FACE_FROM_ID (s->f, face_id); lgstring = composition_gstring_from_id (s->cmp_id); s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring)); @@ -19637,8 +20636,8 @@ fill_gstring_glyph_string (s, face_id, start, end, overlaps) while (glyph < last && glyph->u.cmp.automatic && glyph->u.cmp.id == s->cmp_id - && s->cmp_to == glyph->u.cmp.from) - s->cmp_to = (glyph++)->u.cmp.to + 1; + && s->cmp_to == glyph->slice.cmp.from) + s->cmp_to = (glyph++)->slice.cmp.to + 1; for (i = s->cmp_from; i < s->cmp_to; i++) { @@ -19662,10 +20661,8 @@ fill_gstring_glyph_string (s, face_id, start, end, overlaps) Value is the index of the first glyph not in S. */ static int -fill_glyph_string (s, face_id, start, end, overlaps) - struct glyph_string *s; - int face_id; - int start, end, overlaps; +fill_glyph_string (struct glyph_string *s, int face_id, + int start, int end, int overlaps) { struct glyph *glyph, *last; int voffset; @@ -19725,13 +20722,12 @@ fill_glyph_string (s, face_id, start, end, overlaps) /* Fill glyph string S from image glyph S->first_glyph. */ static void -fill_image_glyph_string (s) - struct glyph_string *s; +fill_image_glyph_string (struct glyph_string *s) { xassert (s->first_glyph->type == IMAGE_GLYPH); s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id); xassert (s->img); - s->slice = s->first_glyph->slice; + s->slice = s->first_glyph->slice.img; s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); s->font = s->face->font; s->width = s->first_glyph->pixel_width; @@ -19750,11 +20746,8 @@ fill_image_glyph_string (s) Value is the index of the first glyph not in S. */ static int -fill_stretch_glyph_string (s, row, area, start, end) - struct glyph_string *s; - struct glyph_row *row; - enum glyph_row_area area; - int start, end; +fill_stretch_glyph_string (struct glyph_string *s, struct glyph_row *row, + enum glyph_row_area area, int start, int end) { struct glyph *glyph, *last; int voffset, face_id; @@ -19788,10 +20781,7 @@ fill_stretch_glyph_string (s, row, area, start, end) } static struct font_metrics * -get_per_char_metric (f, font, char2b) - struct frame *f; - struct font *font; - XChar2b *char2b; +get_per_char_metric (struct frame *f, struct font *font, XChar2b *char2b) { static struct font_metrics metrics; unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b); @@ -19808,10 +20798,7 @@ get_per_char_metric (f, font, char2b) assumed to be zero. */ void -x_get_glyph_overhangs (glyph, f, left, right) - struct glyph *glyph; - struct frame *f; - int *left, *right; +x_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *right) { *left = *right = 0; @@ -19846,8 +20833,8 @@ x_get_glyph_overhangs (glyph, f, left, right) Lisp_Object gstring = composition_gstring_from_id (glyph->u.cmp.id); struct font_metrics metrics; - composition_gstring_width (gstring, glyph->u.cmp.from, - glyph->u.cmp.to + 1, &metrics); + composition_gstring_width (gstring, glyph->slice.cmp.from, + glyph->slice.cmp.to + 1, &metrics); if (metrics.rbearing > metrics.width) *right = metrics.rbearing - metrics.width; if (metrics.lbearing < 0) @@ -19862,8 +20849,7 @@ x_get_glyph_overhangs (glyph, f, left, right) if no glyphs are overwritten. */ static int -left_overwritten (s) - struct glyph_string *s; +left_overwritten (struct glyph_string *s) { int k; @@ -19890,8 +20876,7 @@ left_overwritten (s) glyph in front of S overwrites S. */ static int -left_overwriting (s) - struct glyph_string *s; +left_overwriting (struct glyph_string *s) { int i, k, x; struct glyph *glyphs = s->row->glyphs[s->area]; @@ -19917,8 +20902,7 @@ left_overwriting (s) no such glyph is found. */ static int -right_overwritten (s) - struct glyph_string *s; +right_overwritten (struct glyph_string *s) { int k = -1; @@ -19944,8 +20928,7 @@ right_overwritten (s) if no such glyph is found. */ static int -right_overwriting (s) - struct glyph_string *s; +right_overwriting (struct glyph_string *s) { int i, k, x; int end = s->row->used[s->area]; @@ -19972,10 +20955,7 @@ right_overwriting (s) in the drawing area. */ static INLINE void -set_glyph_string_background_width (s, start, last_x) - struct glyph_string *s; - int start; - int last_x; +set_glyph_string_background_width (struct glyph_string *s, int start, int last_x) { /* If the face of this glyph string has to be drawn to the end of the drawing area, set S->extends_to_end_of_line_p. */ @@ -20004,10 +20984,7 @@ set_glyph_string_background_width (s, start, last_x) BACKWARD_P non-zero means process predecessors. */ static void -compute_overhangs_and_x (s, x, backward_p) - struct glyph_string *s; - int x; - int backward_p; +compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p) { if (backward_p) { @@ -20263,14 +21240,9 @@ compute_overhangs_and_x (s, x, backward_p) Value is the x-position reached, relative to AREA of W. */ static int -draw_glyphs (w, x, row, area, start, end, hl, overlaps) - struct window *w; - int x; - struct glyph_row *row; - enum glyph_row_area area; - EMACS_INT start, end; - enum draw_glyphs_face hl; - int overlaps; +draw_glyphs (struct window *w, int x, struct glyph_row *row, + enum glyph_row_area area, EMACS_INT start, EMACS_INT end, + enum draw_glyphs_face hl, int overlaps) { struct glyph_string *head, *tail; struct glyph_string *s; @@ -20518,8 +21490,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps) Called from x_produce_glyphs when IT->glyph_row is non-null. */ static INLINE void -append_glyph (it) - struct it *it; +append_glyph (struct it *it) { struct glyph *glyph; enum glyph_row_area area = it->area; @@ -20530,6 +21501,17 @@ append_glyph (it) glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; if (glyph < it->glyph_row->glyphs[area + 1]) { + /* If the glyph row is reversed, we need to prepend the glyph + rather than append it. */ + if (it->glyph_row->reversed_p && area == TEXT_AREA) + { + struct glyph *g; + + /* Make room for the additional glyph. */ + for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--) + g[1] = *g; + glyph = it->glyph_row->glyphs[area]; + } glyph->charpos = CHARPOS (it->position); glyph->object = it->object; if (it->pixel_width > 0) @@ -20557,8 +21539,20 @@ append_glyph (it) glyph->glyph_not_available_p = it->glyph_not_available_p; glyph->face_id = it->face_id; glyph->u.ch = it->char_to_display; - glyph->slice = null_glyph_slice; + glyph->slice.img = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[area]; } else @@ -20570,8 +21564,7 @@ append_glyph (it) non-null. */ static INLINE void -append_composite_glyph (it) - struct it *it; +append_composite_glyph (struct it *it) { struct glyph *glyph; enum glyph_row_area area = it->area; @@ -20581,7 +21574,18 @@ append_composite_glyph (it) glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; if (glyph < it->glyph_row->glyphs[area + 1]) { - glyph->charpos = CHARPOS (it->position); + /* If the glyph row is reversed, we need to prepend the glyph + rather than append it. */ + if (it->glyph_row->reversed_p && it->area == TEXT_AREA) + { + struct glyph *g; + + /* Make room for the new glyph. */ + for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--) + g[1] = *g; + glyph = it->glyph_row->glyphs[it->area]; + } + glyph->charpos = it->cmp_it.charpos; glyph->object = it->object; glyph->pixel_width = it->pixel_width; glyph->ascent = it->ascent; @@ -20592,13 +21596,14 @@ append_composite_glyph (it) { glyph->u.cmp.automatic = 0; glyph->u.cmp.id = it->cmp_it.id; + glyph->slice.cmp.from = glyph->slice.cmp.to = 0; } else { glyph->u.cmp.automatic = 1; glyph->u.cmp.id = it->cmp_it.id; - glyph->u.cmp.from = it->cmp_it.from; - glyph->u.cmp.to = it->cmp_it.to - 1; + glyph->slice.cmp.from = it->cmp_it.from; + glyph->slice.cmp.to = it->cmp_it.to - 1; } glyph->avoid_cursor_p = it->avoid_cursor_p; glyph->multibyte_p = it->multibyte_p; @@ -20609,8 +21614,14 @@ append_composite_glyph (it) glyph->padding_p = 0; glyph->glyph_not_available_p = 0; glyph->face_id = it->face_id; - glyph->slice = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } ++it->glyph_row->used[area]; } else @@ -20622,8 +21633,7 @@ append_composite_glyph (it) IT->voffset. */ static INLINE void -take_vertical_position_into_account (it) - struct it *it; +take_vertical_position_into_account (struct it *it) { if (it->voffset) { @@ -20644,8 +21654,7 @@ take_vertical_position_into_account (it) an overview of struct display_iterator. */ static void -produce_image_glyph (it) - struct it *it; +produce_image_glyph (struct it *it) { struct image *img; struct face *face; @@ -20783,8 +21792,15 @@ produce_image_glyph (it) glyph->glyph_not_available_p = 0; glyph->face_id = it->face_id; glyph->u.img_id = img->id; - glyph->slice = slice; + glyph->slice.img = slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } ++it->glyph_row->used[area]; } else @@ -20798,11 +21814,8 @@ produce_image_glyph (it) stretch. ASCENT is the ascent of the glyph (0 <= ASCENT <= HEIGHT). */ static void -append_stretch_glyph (it, object, width, height, ascent) - struct it *it; - Lisp_Object object; - int width, height; - int ascent; +append_stretch_glyph (struct it *it, Lisp_Object object, + int width, int height, int ascent) { struct glyph *glyph; enum glyph_row_area area = it->area; @@ -20812,6 +21825,17 @@ append_stretch_glyph (it, object, width, height, ascent) glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area]; if (glyph < it->glyph_row->glyphs[area + 1]) { + /* If the glyph row is reversed, we need to prepend the glyph + rather than append it. */ + if (it->glyph_row->reversed_p && area == TEXT_AREA) + { + struct glyph *g; + + /* Make room for the additional glyph. */ + for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--) + g[1] = *g; + glyph = it->glyph_row->glyphs[area]; + } glyph->charpos = CHARPOS (it->position); glyph->object = object; glyph->pixel_width = width; @@ -20829,8 +21853,20 @@ append_stretch_glyph (it, object, width, height, ascent) glyph->face_id = it->face_id; glyph->u.stretch.ascent = ascent; glyph->u.stretch.height = height; - glyph->slice = null_glyph_slice; + glyph->slice.img = null_glyph_slice; glyph->font_type = FONT_TYPE_UNKNOWN; + if (it->bidi_p) + { + glyph->resolved_level = it->bidi_it.resolved_level; + if ((it->bidi_it.type & 7) != it->bidi_it.type) + abort (); + glyph->bidi_type = it->bidi_it.type; + } + else + { + glyph->resolved_level = 0; + glyph->bidi_type = UNKNOWN_BT; + } ++it->glyph_row->used[area]; } else @@ -20870,8 +21906,7 @@ append_stretch_glyph (it, object, width, height, ascent) ASCENT must be in the range 0 <= ASCENT <= 100. */ static void -produce_stretch_glyph (it) - struct it *it; +produce_stretch_glyph (struct it *it) { /* (space :width WIDTH :height HEIGHT ...) */ Lisp_Object prop, plist; @@ -20907,11 +21942,7 @@ produce_stretch_glyph (it) it2 = *it; if (it->multibyte_p) - { - int maxlen = ((IT_BYTEPOS (*it) >= GPT ? ZV : GPT) - - IT_BYTEPOS (*it)); - it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len); - } + it2.c = it2.char_to_display = STRING_CHAR_AND_LENGTH (p, it2.len); else { it2.c = it2.char_to_display = *p, it2.len = 1; @@ -21001,11 +22032,8 @@ produce_stretch_glyph (it) static Lisp_Object -calc_line_height_property (it, val, font, boff, override) - struct it *it; - Lisp_Object val; - struct font *font; - int boff, override; +calc_line_height_property (struct it *it, Lisp_Object val, struct font *font, + int boff, int override) { Lisp_Object face_name = Qnil; int ascent, descent, height; @@ -21081,8 +22109,7 @@ calc_line_height_property (it, val, font, boff, override) for an overview of struct it. */ void -x_produce_glyphs (it) - struct it *it; +x_produce_glyphs (struct it *it) { int extra_line_spacing = it->extra_line_spacing; @@ -21255,7 +22282,7 @@ x_produce_glyphs (it) it->pixel_width = 0; it->nglyphs = 0; - height = get_it_property(it, Qline_height); + height = get_it_property (it, Qline_height); /* Split (line-height total-height) list */ if (CONSP (height) && CONSP (XCDR (height)) @@ -21264,7 +22291,7 @@ x_produce_glyphs (it) total_height = XCAR (XCDR (height)); height = XCAR (height); } - height = calc_line_height_property(it, height, font, boff, 1); + height = calc_line_height_property (it, height, font, boff, 1); if (it->override_ascent >= 0) { @@ -21314,11 +22341,11 @@ x_produce_glyphs (it) it->ascent = XINT (height) - it->descent; if (!NILP (total_height)) - spacing = calc_line_height_property(it, total_height, font, boff, 0); + spacing = calc_line_height_property (it, total_height, font, boff, 0); else { - spacing = get_it_property(it, Qline_spacing); - spacing = calc_line_height_property(it, spacing, font, boff, 0); + spacing = get_it_property (it, Qline_spacing); + spacing = calc_line_height_property (it, spacing, font, boff, 0); } if (INTEGERP (spacing)) { @@ -21401,7 +22428,7 @@ x_produce_glyphs (it) XChar2b char2b; struct font_metrics *pcm; int font_not_found_p; - int pos; + EMACS_INT pos; for (glyph_len = cmp->glyph_len; glyph_len > 0; glyph_len--) if ((c = COMPOSITION_GLYPH (cmp, glyph_len - 1)) != '\t') @@ -21757,9 +22784,7 @@ x_produce_glyphs (it) row being updated. */ void -x_write_glyphs (start, len) - struct glyph *start; - int len; +x_write_glyphs (struct glyph *start, int len) { int x, hpos; @@ -21794,9 +22819,7 @@ x_write_glyphs (start, len) Insert LEN glyphs from START at the nominal cursor position. */ void -x_insert_glyphs (start, len) - struct glyph *start; - int len; +x_insert_glyphs (struct glyph *start, int len) { struct frame *f; struct window *w; @@ -21854,8 +22877,7 @@ x_insert_glyphs (start, len) updated_window. TO_X == -1 means clear to the end of this area. */ void -x_clear_end_of_line (to_x) - int to_x; +x_clear_end_of_line (int to_x) { struct frame *f; struct window *w = updated_window; @@ -21931,9 +22953,7 @@ x_clear_end_of_line (to_x) of the bar cursor. */ static enum text_cursor_kinds -get_specified_cursor_type (arg, width) - Lisp_Object arg; - int *width; +get_specified_cursor_type (Lisp_Object arg, int *width) { enum text_cursor_kinds type; @@ -21986,9 +23006,7 @@ get_specified_cursor_type (arg, width) /* Set the default cursor types for specified frame. */ void -set_frame_cursor_types (f, arg) - struct frame *f; - Lisp_Object arg; +set_frame_cursor_types (struct frame *f, Lisp_Object arg) { int width; Lisp_Object tem; @@ -22022,11 +23040,8 @@ set_frame_cursor_types (f, arg) In all other cases, we want a hollow box cursor. */ static enum text_cursor_kinds -get_window_cursor_type (w, glyph, width, active_cursor) - struct window *w; - struct glyph *glyph; - int *width; - int *active_cursor; +get_window_cursor_type (struct window *w, struct glyph *glyph, int *width, + int *active_cursor) { struct frame *f = XFRAME (w->frame); struct buffer *b = XBUFFER (w->buffer); @@ -22182,10 +23197,8 @@ get_window_cursor_type (w, glyph, width, active_cursor) are window-relative. */ static void -notice_overwritten_cursor (w, area, x0, x1, y0, y1) - struct window *w; - enum glyph_row_area area; - int x0, y0, x1, y1; +notice_overwritten_cursor (struct window *w, enum glyph_row_area area, + int x0, int x1, int y0, int y1) { int cx0, cx1, cy0, cy1; struct glyph_row *row; @@ -22204,7 +23217,7 @@ notice_overwritten_cursor (w, area, x0, x1, y0, y1) if (row->cursor_in_fringe_p) { row->cursor_in_fringe_p = 0; - draw_fringe_bitmap (w, row, 0); + draw_fringe_bitmap (w, row, row->reversed_p); w->phys_cursor_on_p = 0; return; } @@ -22252,11 +23265,8 @@ notice_overwritten_cursor (w, area, x0, x1, y0, y1) with respect to the overlapping part OVERLAPS. */ void -x_fix_overlapping_area (w, row, area, overlaps) - struct window *w; - struct glyph_row *row; - enum glyph_row_area area; - int overlaps; +x_fix_overlapping_area (struct window *w, struct glyph_row *row, + enum glyph_row_area area, int overlaps) { int i, x; @@ -22297,15 +23307,15 @@ x_fix_overlapping_area (w, row, area, overlaps) comment of draw_glyphs for the meaning of HL. */ void -draw_phys_cursor_glyph (w, row, hl) - struct window *w; - struct glyph_row *row; - enum draw_glyphs_face hl; +draw_phys_cursor_glyph (struct window *w, struct glyph_row *row, + enum draw_glyphs_face hl) { /* If cursor hpos is out of bounds, don't draw garbage. This can happen in mini-buffer windows when switching between echo area glyphs and mini-buffer. */ - if (w->phys_cursor.hpos < row->used[TEXT_AREA]) + if ((row->reversed_p + ? (w->phys_cursor.hpos >= 0) + : (w->phys_cursor.hpos < row->used[TEXT_AREA]))) { int on_p = w->phys_cursor_on_p; int x1; @@ -22341,8 +23351,7 @@ draw_phys_cursor_glyph (w, row, hl) Erase the image of a cursor of window W from the screen. */ void -erase_phys_cursor (w) - struct window *w; +erase_phys_cursor (struct window *w) { struct frame *f = XFRAME (w->frame); Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -22385,7 +23394,7 @@ erase_phys_cursor (w) if (cursor_row->cursor_in_fringe_p) { cursor_row->cursor_in_fringe_p = 0; - draw_fringe_bitmap (w, cursor_row, 0); + draw_fringe_bitmap (w, cursor_row, cursor_row->reversed_p); goto mark_cursor_off; } @@ -22394,7 +23403,9 @@ erase_phys_cursor (w) should have cleared the cursor. Note that we wouldn't be able to erase the cursor in this case because we don't have a cursor glyph at hand. */ - if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA]) + if ((cursor_row->reversed_p + ? (w->phys_cursor.hpos < 0) + : (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA]))) goto mark_cursor_off; /* If the cursor is in the mouse face area, redisplay that when @@ -22410,7 +23421,7 @@ erase_phys_cursor (w) /* Don't redraw the cursor's spot in mouse face if it is at the end of a line (on a newline). The cursor appears there, but mouse highlighting does not. */ - && cursor_row->used[TEXT_AREA] > hpos) + && cursor_row->used[TEXT_AREA] > hpos && hpos >= 0) mouse_face_here_p = 1; /* Maybe clear the display under the cursor. */ @@ -22456,9 +23467,8 @@ erase_phys_cursor (w) where to put the cursor is specified by HPOS, VPOS, X and Y. */ void -display_and_set_cursor (w, on, hpos, vpos, x, y) - struct window *w; - int on, hpos, vpos, x, y; +display_and_set_cursor (struct window *w, int on, + int hpos, int vpos, int x, int y) { struct frame *f = XFRAME (w->frame); int new_cursor_type; @@ -22492,7 +23502,7 @@ display_and_set_cursor (w, on, hpos, vpos, x, y) glyph = NULL; if (!glyph_row->exact_window_width_line_p - || hpos < glyph_row->used[TEXT_AREA]) + || (0 <= hpos && hpos < glyph_row->used[TEXT_AREA])) glyph = glyph_row->glyphs[TEXT_AREA] + hpos; xassert (interrupt_input_blocked); @@ -22541,9 +23551,7 @@ display_and_set_cursor (w, on, hpos, vpos, x, y) of ON. */ void -update_window_cursor (w, on) - struct window *w; - int on; +update_window_cursor (struct window *w, int on) { /* Don't update cursor in windows whose frame is in the process of being deleted. */ @@ -22561,9 +23569,7 @@ update_window_cursor (w, on) in the window tree rooted at W. */ static void -update_cursor_in_window_tree (w, on_p) - struct window *w; - int on_p; +update_cursor_in_window_tree (struct window *w, int on_p) { while (w) { @@ -22584,9 +23590,7 @@ update_cursor_in_window_tree (w, on_p) Don't change the cursor's position. */ void -x_update_cursor (f, on_p) - struct frame *f; - int on_p; +x_update_cursor (struct frame *f, int on_p) { update_cursor_in_window_tree (XWINDOW (f->root_window), on_p); } @@ -22598,8 +23602,7 @@ x_update_cursor (f, on_p) is about to be rewritten. */ void -x_clear_cursor (w) - struct window *w; +x_clear_cursor (struct window *w) { if (FRAME_VISIBLE_P (XFRAME (w->frame)) && w->phys_cursor_on_p) update_window_cursor (w, 0); @@ -22610,9 +23613,7 @@ x_clear_cursor (w) Display the active region described by mouse_face_* according to DRAW. */ void -show_mouse_face (dpyinfo, draw) - Display_Info *dpyinfo; - enum draw_glyphs_face draw; +show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw) { struct window *w = XWINDOW (dpyinfo->mouse_face_window); struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -22695,8 +23696,7 @@ show_mouse_face (dpyinfo, draw) face was actually drawn unhighlighted. */ int -clear_mouse_face (dpyinfo) - Display_Info *dpyinfo; +clear_mouse_face (Display_Info *dpyinfo) { int cleared = 0; @@ -22718,8 +23718,7 @@ clear_mouse_face (dpyinfo) Non-zero if physical cursor of window W is within mouse face. */ int -cursor_in_mouse_face_p (w) - struct window *w; +cursor_in_mouse_face_p (struct window *w) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); int in_mouse_face = 0; @@ -22898,7 +23897,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, associated with the end position, which must not be highlighted. */ Lisp_Object prev_object; - int pos; + EMACS_INT pos; while (glyph > row->glyphs[TEXT_AREA]) { @@ -22944,12 +23943,8 @@ mouse_face_from_buffer_pos (Lisp_Object window, Value is non-zero if a glyph was found. */ static int -fast_find_string_pos (w, pos, object, hpos, vpos, x, y, right_p) - struct window *w; - EMACS_INT pos; - Lisp_Object object; - int *hpos, *vpos, *x, *y; - int right_p; +fast_find_string_pos (struct window *w, EMACS_INT pos, Lisp_Object object, + int *hpos, int *vpos, int *x, int *y, int right_p) { int yb = window_text_bottom_y (w); struct glyph_row *r; @@ -23013,9 +24008,7 @@ fast_find_string_pos (w, pos, object, hpos, vpos, x, y, right_p) /* See if position X, Y is within a hot-spot of an image. */ static int -on_hot_spot_p (hot_spot, x, y) - Lisp_Object hot_spot; - int x, y; +on_hot_spot_p (Lisp_Object hot_spot, int x, int y) { if (!CONSP (hot_spot)) return 0; @@ -23111,9 +24104,7 @@ on_hot_spot_p (hot_spot, x, y) } Lisp_Object -find_hot_spot (map, x, y) - Lisp_Object map; - int x, y; +find_hot_spot (Lisp_Object map, int x, int y) { while (CONSP (map)) { @@ -23138,9 +24129,7 @@ and the radius of the circle; r may be a float or integer. A polygon is a cons (poly . [x0 y0 x1 y1 ...]) where each pair in the vector describes one corner in the polygon. Returns the alist element for the first matching AREA in MAP. */) - (map, x, y) - Lisp_Object map; - Lisp_Object x, y; + (Lisp_Object map, Lisp_Object x, Lisp_Object y) { if (NILP (map)) return Qnil; @@ -23154,10 +24143,7 @@ Returns the alist element for the first matching AREA in MAP. */) /* Display frame CURSOR, optionally using shape defined by POINTER. */ static void -define_frame_cursor1 (f, cursor, pointer) - struct frame *f; - Cursor cursor; - Lisp_Object pointer; +define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer) { /* Do not change cursor shape while dragging mouse. */ if (!NILP (do_mouse_tracking)) @@ -23196,17 +24182,16 @@ define_frame_cursor1 (f, cursor, pointer) position relative to the start of the mode line. */ static void -note_mode_line_or_margin_highlight (window, x, y, area) - Lisp_Object window; - int x, y; - enum window_part area; +note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, + enum window_part area) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; Lisp_Object pointer = Qnil; - int charpos, dx, dy, width, height; + int dx, dy, width, height; + EMACS_INT charpos; Lisp_Object string, object = Qnil; Lisp_Object pos, help; @@ -23439,9 +24424,7 @@ note_mode_line_or_margin_highlight (window, x, y, area) X and Y can be negative or out of range. */ void -note_mouse_highlight (f, x, y) - struct frame *f; - int x, y; +note_mouse_highlight (struct frame *f, int x, int y) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); enum window_part part; @@ -23531,14 +24514,16 @@ note_mouse_highlight (f, x, y) && XFASTINT (w->last_modified) == BUF_MODIFF (b) && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) { - int hpos, vpos, pos, i, dx, dy, area; + int hpos, vpos, i, dx, dy, area; + EMACS_INT pos; struct glyph *glyph; Lisp_Object object; Lisp_Object mouse_face = Qnil, overlay = Qnil, position; Lisp_Object *overlay_vec = NULL; int noverlays; struct buffer *obuf; - int obegv, ozv, same_region; + EMACS_INT obegv, ozv; + int same_region; /* Find the glyph under X/Y. */ glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area); @@ -23553,8 +24538,8 @@ note_mouse_highlight (f, x, y) if ((image_map = Fplist_get (XCDR (img->spec), QCmap), !NILP (image_map)) && (hotspot = find_hot_spot (image_map, - glyph->slice.x + dx, - glyph->slice.y + dy), + glyph->slice.img.x + dx, + glyph->slice.img.y + dy), CONSP (hotspot)) && (hotspot = XCDR (hotspot), CONSP (hotspot))) { @@ -23724,7 +24709,7 @@ note_mouse_highlight (f, x, y) /* If we are on a display string with no mouse-face, check if the text under it has one. */ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); - int start = MATRIX_ROW_START_CHARPOS (r); + EMACS_INT start = MATRIX_ROW_START_CHARPOS (r); pos = string_buffer_position (w, object, start); if (pos > 0) { @@ -23803,7 +24788,7 @@ note_mouse_highlight (f, x, y) else { Lisp_Object object = glyph->object; - int charpos = glyph->charpos; + EMACS_INT charpos = glyph->charpos; /* Try text properties. */ if (STRINGP (object) @@ -23818,8 +24803,8 @@ note_mouse_highlight (f, x, y) see if the buffer text ``under'' it does. */ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); - int start = MATRIX_ROW_START_CHARPOS (r); - int pos = string_buffer_position (w, object, start); + EMACS_INT start = MATRIX_ROW_START_CHARPOS (r); + EMACS_INT pos = string_buffer_position (w, object, start); if (pos > 0) { help = Fget_char_property (make_number (pos), @@ -23858,7 +24843,7 @@ note_mouse_highlight (f, x, y) if (NILP (pointer)) { Lisp_Object object = glyph->object; - int charpos = glyph->charpos; + EMACS_INT charpos = glyph->charpos; /* Try text properties. */ if (STRINGP (object) @@ -23873,8 +24858,9 @@ note_mouse_highlight (f, x, y) see if the buffer text ``under'' it does. */ struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos); - int start = MATRIX_ROW_START_CHARPOS (r); - int pos = string_buffer_position (w, object, start); + EMACS_INT start = MATRIX_ROW_START_CHARPOS (r); + EMACS_INT pos = string_buffer_position (w, object, + start); if (pos > 0) pointer = Fget_char_property (make_number (pos), Qpointer, w->buffer); @@ -23905,8 +24891,7 @@ note_mouse_highlight (f, x, y) functions to ensure the mouse-highlight is off. */ void -x_clear_window_mouse_face (w) - struct window *w; +x_clear_window_mouse_face (struct window *w) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); Lisp_Object window; @@ -23924,8 +24909,7 @@ x_clear_window_mouse_face (w) This is used when the size of F is changed. */ void -cancel_mouse_face (f) - struct frame *f; +cancel_mouse_face (struct frame *f) { Lisp_Object window; Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -23953,11 +24937,8 @@ cancel_mouse_face (f) which intersects rectangle R. R is in window-relative coordinates. */ static void -expose_area (w, row, r, area) - struct window *w; - struct glyph_row *row; - XRectangle *r; - enum glyph_row_area area; +expose_area (struct window *w, struct glyph_row *row, XRectangle *r, + enum glyph_row_area area) { struct glyph *first = row->glyphs[area]; struct glyph *end = row->glyphs[area] + row->used[area]; @@ -24011,10 +24992,7 @@ expose_area (w, row, r, area) non-zero if mouse-face was overwritten. */ static int -expose_line (w, row, r) - struct window *w; - struct glyph_row *row; - XRectangle *r; +expose_line (struct window *w, struct glyph_row *row, XRectangle *r) { xassert (row->enabled_p); @@ -24046,11 +25024,10 @@ expose_line (w, row, r) LAST_OVERLAPPING_ROW is the last such row. */ static void -expose_overlaps (w, first_overlapping_row, last_overlapping_row, r) - struct window *w; - struct glyph_row *first_overlapping_row; - struct glyph_row *last_overlapping_row; - XRectangle *r; +expose_overlaps (struct window *w, + struct glyph_row *first_overlapping_row, + struct glyph_row *last_overlapping_row, + XRectangle *r) { struct glyph_row *row; @@ -24076,9 +25053,7 @@ expose_overlaps (w, first_overlapping_row, last_overlapping_row, r) /* Return non-zero if W's cursor intersects rectangle R. */ static int -phys_cursor_in_rect_p (w, r) - struct window *w; - XRectangle *r; +phys_cursor_in_rect_p (struct window *w, XRectangle *r) { XRectangle cr, result; struct glyph *cursor_glyph; @@ -24124,8 +25099,7 @@ phys_cursor_in_rect_p (w, r) have vertical scroll bars. */ void -x_draw_vertical_border (w) - struct window *w; +x_draw_vertical_border (struct window *w) { struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -24175,9 +25149,7 @@ x_draw_vertical_border (w) mouse-face. */ static int -expose_window (w, fr) - struct window *w; - XRectangle *fr; +expose_window (struct window *w, XRectangle *fr) { struct frame *f = XFRAME (w->frame); XRectangle wr, r; @@ -24310,9 +25282,7 @@ expose_window (w, fr) non-zero if the exposure overwrites mouse-face. */ static int -expose_window_tree (w, r) - struct window *w; - XRectangle *r; +expose_window_tree (struct window *w, XRectangle *r) { struct frame *f = XFRAME (w->frame); int mouse_face_overwritten_p = 0; @@ -24342,9 +25312,7 @@ expose_window_tree (w, r) the entire frame. */ void -expose_frame (f, x, y, w, h) - struct frame *f; - int x, y, w, h; +expose_frame (struct frame *f, int x, int y, int w, int h) { XRectangle r; int mouse_face_overwritten_p = 0; @@ -24432,8 +25400,7 @@ expose_frame (f, x, y, w, h) empty. */ int -x_intersect_rectangles (r1, r2, result) - XRectangle *r1, *r2, *result; +x_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result) { XRectangle *left, *right; XRectangle *upper, *lower; @@ -24488,7 +25455,7 @@ x_intersect_rectangles (r1, r2, result) ***********************************************************************/ void -syms_of_xdisp () +syms_of_xdisp (void) { Vwith_echo_area_save_vector = Qnil; staticpro (&Vwith_echo_area_save_vector); @@ -24520,6 +25487,7 @@ syms_of_xdisp () #endif defsubr (&Sformat_mode_line); defsubr (&Sinvisible_p); + defsubr (&Scurrent_bidi_paragraph_direction); staticpro (&Qmenu_bar_update_hook); Qmenu_bar_update_hook = intern_c_string ("menu-bar-update-hook"); @@ -24593,6 +25561,14 @@ syms_of_xdisp () staticpro (&Qnobreak_space); Qimage = intern_c_string ("image"); staticpro (&Qimage); + Qtext = intern_c_string ("text"); + staticpro (&Qtext); + Qboth = intern_c_string ("both"); + staticpro (&Qboth); + Qboth_horiz = intern_c_string ("both-horiz"); + staticpro (&Qboth_horiz); + Qtext_image_horiz = intern_c_string ("text-image-horiz"); + staticpro (&Qtext_image_horiz); QCmap = intern_c_string (":map"); staticpro (&QCmap); QCpointer = intern_c_string (":pointer"); @@ -24683,6 +25659,11 @@ syms_of_xdisp () staticpro (&previous_help_echo_string); help_echo_pos = -1; + Qright_to_left = intern_c_string ("right-to-left"); + staticpro (&Qright_to_left); + Qleft_to_right = intern_c_string ("left-to-right"); + staticpro (&Qleft_to_right); + #ifdef HAVE_WINDOW_SYSTEM DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p, doc: /* *Non-nil means draw block cursor as wide as the glyph under it. @@ -24928,6 +25909,23 @@ vertical margin. */); doc: /* *Relief thickness of tool-bar buttons. */); tool_bar_button_relief = DEFAULT_TOOL_BAR_BUTTON_RELIEF; + DEFVAR_LISP ("tool-bar-style", &Vtool_bar_style, + doc: /* *Tool bar style to use. +It can be one of + image - show images only + text - show text only + both - show both, text below image + both-horiz - show text to the right of the image + text-image-horiz - show text to the left of the image + any other - use system default or image if no system default. */); + Vtool_bar_style = Qnil; + + DEFVAR_INT ("tool-bar-max-label-size", &tool_bar_max_label_size, + doc: /* *Maximum number of characters a label can have to be shown. +The tool bar style must also show labels for this to have any effect, see +`tool-bar-style'. */); + tool_bar_max_label_size = DEFAULT_TOOL_BAR_LABEL_SIZE; + DEFVAR_LISP ("fontification-functions", &Vfontification_functions, doc: /* List of functions to call to fontify regions of text. Each function is called with one argument POS. Functions must @@ -25107,7 +26105,7 @@ Value must be an integer or float. */); /* Initialize this module when Emacs starts. */ void -init_xdisp () +init_xdisp (void) { Lisp_Object root_window; struct window *mini_w; @@ -25164,14 +26162,14 @@ init_xdisp () /* Return non-zero if houglass timer has been started or hourglass is shown. */ int -hourglass_started () +hourglass_started (void) { return hourglass_shown_p || hourglass_atimer != NULL; } /* Cancel a currently active hourglass timer, and start a new one. */ void -start_hourglass () +start_hourglass (void) { #if defined (HAVE_WINDOW_SYSTEM) EMACS_TIME delay; @@ -25203,7 +26201,7 @@ start_hourglass () /* Cancel the hourglass cursor timer if active, hide a busy cursor if shown. */ void -cancel_hourglass () +cancel_hourglass (void) { #if defined (HAVE_WINDOW_SYSTEM) if (hourglass_atimer) diff --git a/src/xfaces.c b/src/xfaces.c index 7dab1a871d1..21adb948c91 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -321,11 +321,6 @@ Lisp_Object QCreverse_video; Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit; Lisp_Object QCfontset; -/* Keywords symbols used for font properties. */ -extern Lisp_Object QCfoundry, QCadstyle, QCregistry; -extern Lisp_Object QCspacing, QCsize, QCavgwidth; -extern Lisp_Object Qp; - /* Symbols used for attribute values. */ Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight; @@ -351,7 +346,6 @@ Lisp_Object Qframe_set_background_mode; Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe; Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse, Qmenu; Lisp_Object Qmode_line_inactive, Qvertical_border; -extern Lisp_Object Qmode_line; /* The symbol `face-alias'. A symbols having that property is an alias for another face. Value of the property is the name of @@ -359,8 +353,6 @@ extern Lisp_Object Qmode_line; Lisp_Object Qface_alias; -extern Lisp_Object Qcircular_list; - /* Default stipple pattern used on monochrome displays. This stipple pattern is used on monochrome displays instead of shades of gray for a face background color. See `set-face-stipple' for possible @@ -411,7 +403,6 @@ Lisp_Object Qforeground_color, Qbackground_color; /* The symbols `face' and `mouse-face' used as text properties. */ Lisp_Object Qface; -extern Lisp_Object Qmouse_face; /* Property for basic faces which other faces cannot inherit. */ @@ -510,56 +501,55 @@ int menu_face_changed_default; struct table_entry; struct named_merge_point; -static void map_tty_color P_ ((struct frame *, struct face *, - enum lface_attribute_index, int *)); -static Lisp_Object resolve_face_name P_ ((Lisp_Object, int)); -static int may_use_scalable_font_p P_ ((const char *)); -static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); -static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, - int, struct named_merge_point *)); -static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); -static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); -static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); -static void free_face_colors P_ ((struct frame *, struct face *)); -static int face_color_gray_p P_ ((struct frame *, char *)); -static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, - int)); -static struct face *realize_non_ascii_face P_ ((struct frame *, Lisp_Object, - struct face *)); -static struct face *realize_x_face P_ ((struct face_cache *, Lisp_Object *)); -static struct face *realize_tty_face P_ ((struct face_cache *, Lisp_Object *)); -static int realize_basic_faces P_ ((struct frame *)); -static int realize_default_face P_ ((struct frame *)); -static void realize_named_face P_ ((struct frame *, Lisp_Object, int)); -static int lface_fully_specified_p P_ ((Lisp_Object *)); -static int lface_equal_p P_ ((Lisp_Object *, Lisp_Object *)); -static unsigned hash_string_case_insensitive P_ ((Lisp_Object)); -static unsigned lface_hash P_ ((Lisp_Object *)); -static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *)); -static struct face_cache *make_face_cache P_ ((struct frame *)); -static void clear_face_gcs P_ ((struct face_cache *)); -static void free_face_cache P_ ((struct face_cache *)); -static int face_fontset P_ ((Lisp_Object *)); -static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, - struct named_merge_point *)); -static int merge_face_ref P_ ((struct frame *, Lisp_Object, Lisp_Object *, - int, struct named_merge_point *)); -static int set_lface_from_font P_ ((struct frame *, Lisp_Object, Lisp_Object, - int)); -static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); -static struct face *make_realized_face P_ ((Lisp_Object *)); -static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); -static void uncache_face P_ ((struct face_cache *, struct face *)); +static void map_tty_color (struct frame *, struct face *, + enum lface_attribute_index, int *); +static Lisp_Object resolve_face_name (Lisp_Object, int); +static void set_font_frame_param (Lisp_Object, Lisp_Object); +static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *, + int, struct named_merge_point *); +static int load_pixmap (struct frame *, Lisp_Object, unsigned *, unsigned *); +static struct frame *frame_or_selected_frame (Lisp_Object, int); +static void load_face_colors (struct frame *, struct face *, Lisp_Object *); +static void free_face_colors (struct frame *, struct face *); +static int face_color_gray_p (struct frame *, const char *); +static struct face *realize_face (struct face_cache *, Lisp_Object *, + int); +static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, + struct face *); +static struct face *realize_x_face (struct face_cache *, Lisp_Object *); +static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); +static int realize_basic_faces (struct frame *); +static int realize_default_face (struct frame *); +static void realize_named_face (struct frame *, Lisp_Object, int); +static int lface_fully_specified_p (Lisp_Object *); +static int lface_equal_p (Lisp_Object *, Lisp_Object *); +static unsigned hash_string_case_insensitive (Lisp_Object); +static unsigned lface_hash (Lisp_Object *); +static int lface_same_font_attributes_p (Lisp_Object *, Lisp_Object *); +static struct face_cache *make_face_cache (struct frame *); +static void clear_face_gcs (struct face_cache *); +static void free_face_cache (struct face_cache *); +static int face_fontset (Lisp_Object *); +static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*, + struct named_merge_point *); +static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, + int, struct named_merge_point *); +static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object, + int); +static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int); +static struct face *make_realized_face (Lisp_Object *); +static void cache_face (struct face_cache *, struct face *, unsigned); +static void uncache_face (struct face_cache *, struct face *); #ifdef HAVE_WINDOW_SYSTEM -static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); -static void x_free_gc P_ ((struct frame *, GC)); +static GC x_create_gc (struct frame *, unsigned long, XGCValues *); +static void x_free_gc (struct frame *, GC); #ifdef USE_X_TOOLKIT -static void x_update_menu_appearance P_ ((struct frame *)); +static void x_update_menu_appearance (struct frame *); -extern void free_frame_menubar P_ ((struct frame *)); +extern void free_frame_menubar (struct frame *); #endif /* USE_X_TOOLKIT */ #endif /* HAVE_WINDOW_SYSTEM */ @@ -626,7 +616,7 @@ unregister_colors (pixels, n) DEFUN ("dump-colors", Fdump_colors, Sdump_colors, 0, 0, 0, doc: /* Dump currently allocated colors to stderr. */) - () + (void) { int i, n; @@ -656,10 +646,7 @@ DEFUN ("dump-colors", Fdump_colors, Sdump_colors, 0, 0, 0, is called. */ void -x_free_colors (f, pixels, npixels) - struct frame *f; - unsigned long *pixels; - int npixels; +x_free_colors (struct frame *f, long unsigned int *pixels, int npixels) { int class = FRAME_X_DISPLAY_INFO (f)->visual->class; @@ -681,12 +668,7 @@ x_free_colors (f, pixels, npixels) is called. */ void -x_free_dpy_colors (dpy, screen, cmap, pixels, npixels) - Display *dpy; - Screen *screen; - Colormap cmap; - unsigned long *pixels; - int npixels; +x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap, long unsigned int *pixels, int npixels) { struct x_display_info *dpyinfo = x_display_info_for_display (dpy); int class = dpyinfo->visual->class; @@ -707,10 +689,7 @@ x_free_dpy_colors (dpy, screen, cmap, pixels, npixels) are given by XGCV and MASK. */ static INLINE GC -x_create_gc (f, mask, xgcv) - struct frame *f; - unsigned long mask; - XGCValues *xgcv; +x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv) { GC gc; BLOCK_INPUT; @@ -724,9 +703,7 @@ x_create_gc (f, mask, xgcv) /* Free GC which was used on frame F. */ static INLINE void -x_free_gc (f, gc) - struct frame *f; - GC gc; +x_free_gc (struct frame *f, GC gc) { eassert (interrupt_input_blocked); IF_DEBUG (xassert (--ngcs >= 0)); @@ -739,10 +716,7 @@ x_free_gc (f, gc) /* W32 emulation of GCs */ static INLINE GC -x_create_gc (f, mask, xgcv) - struct frame *f; - unsigned long mask; - XGCValues *xgcv; +x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv) { GC gc; BLOCK_INPUT; @@ -756,9 +730,7 @@ x_create_gc (f, mask, xgcv) /* Free GC which was used on frame F. */ static INLINE void -x_free_gc (f, gc) - struct frame *f; - GC gc; +x_free_gc (struct frame *f, GC gc) { IF_DEBUG (xassert (--ngcs >= 0)); xfree (gc); @@ -770,21 +742,18 @@ x_free_gc (f, gc) /* NS emulation of GCs */ static INLINE GC -x_create_gc (f, mask, xgcv) - struct frame *f; - unsigned long mask; - XGCValues *xgcv; +x_create_gc (struct frame *f, + unsigned long mask, + XGCValues *xgcv) { GC gc = xmalloc (sizeof (*gc)); if (gc) - bcopy(xgcv, gc, sizeof(XGCValues)); + memcpy (gc, xgcv, sizeof (XGCValues)); return gc; } static INLINE void -x_free_gc (f, gc) - struct frame *f; - GC gc; +x_free_gc (struct frame *f, GC gc) { xfree (gc); } @@ -794,8 +763,7 @@ x_free_gc (f, gc) are in ISO8859-1. */ int -xstrcasecmp (s1, s2) - const unsigned char *s1, *s2; +xstrcasecmp (const unsigned char *s1, const unsigned char *s2) { while (*s1 && *s2) { @@ -819,9 +787,7 @@ xstrcasecmp (s1, s2) Lisp function definitions. */ static INLINE struct frame * -frame_or_selected_frame (frame, nparam) - Lisp_Object frame; - int nparam; +frame_or_selected_frame (Lisp_Object frame, int nparam) { if (NILP (frame)) frame = selected_frame; @@ -838,8 +804,7 @@ frame_or_selected_frame (frame, nparam) /* Initialize face cache and basic faces for frame F. */ void -init_frame_faces (f) - struct frame *f; +init_frame_faces (struct frame *f) { /* Make a face cache, if F doesn't have one. */ if (FRAME_FACE_CACHE (f) == NULL) @@ -877,8 +842,7 @@ init_frame_faces (f) /* Free face cache of frame F. Called from delete_frame. */ void -free_frame_faces (f) - struct frame *f; +free_frame_faces (struct frame *f) { struct face_cache *face_cache = FRAME_FACE_CACHE (f); @@ -909,8 +873,7 @@ free_frame_faces (f) of named faces. */ void -recompute_basic_faces (f) - struct frame *f; +recompute_basic_faces (struct frame *f) { if (FRAME_FACE_CACHE (f)) { @@ -925,8 +888,7 @@ recompute_basic_faces (f) try to free unused fonts, too. */ void -clear_face_cache (clear_fonts_p) - int clear_fonts_p; +clear_face_cache (int clear_fonts_p) { #ifdef HAVE_WINDOW_SYSTEM Lisp_Object tail, frame; @@ -971,8 +933,7 @@ clear_face_cache (clear_fonts_p) DEFUN ("clear-face-cache", Fclear_face_cache, Sclear_face_cache, 0, 1, 0, doc: /* Clear face caches on all frames. Optional THOROUGHLY non-nil means try to free unused fonts, too. */) - (thoroughly) - Lisp_Object thoroughly; + (Lisp_Object thoroughly) { clear_face_cache (!NILP (thoroughly)); ++face_change_count; @@ -994,8 +955,7 @@ A bitmap specification is either a string, a file name, or a list HEIGHT is its height, and DATA is a string containing the bits of the pixmap. Bits are stored row by row, each row occupies \(WIDTH + 7)/8 bytes. */) - (object) - Lisp_Object object; + (Lisp_Object object) { int pixmap_p = 0; @@ -1045,10 +1005,7 @@ the pixmap. Bits are stored row by row, each row occupies if these pointers are not null. */ static int -load_pixmap (f, name, w_ptr, h_ptr) - FRAME_PTR f; - Lisp_Object name; - unsigned int *w_ptr, *h_ptr; +load_pixmap (FRAME_PTR f, Lisp_Object name, unsigned int *w_ptr, unsigned int *h_ptr) { int bitmap_id; @@ -1117,9 +1074,7 @@ load_pixmap (f, name, w_ptr, h_ptr) Return 0 if there's a problem with RGB_LIST, otherwise return 1. */ static int -parse_rgb_list (rgb_list, color) - Lisp_Object rgb_list; - XColor *color; +parse_rgb_list (Lisp_Object rgb_list, XColor *color) { #define PARSE_RGB_LIST_FIELD(field) \ if (CONSP (rgb_list) && INTEGERP (XCAR (rgb_list))) \ @@ -1144,10 +1099,7 @@ parse_rgb_list (rgb_list, color) returned in it. */ static int -tty_lookup_color (f, color, tty_color, std_color) - struct frame *f; - Lisp_Object color; - XColor *tty_color, *std_color; +tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, XColor *std_color) { Lisp_Object frame, color_desc; @@ -1207,11 +1159,8 @@ tty_lookup_color (f, color, tty_color, std_color) /* A version of defined_color for non-X frames. */ int -tty_defined_color (f, color_name, color_def, alloc) - struct frame *f; - char *color_name; - XColor *color_def; - int alloc; +tty_defined_color (struct frame *f, const char *color_name, + XColor *color_def, int alloc) { int status = 1; @@ -1246,11 +1195,7 @@ tty_defined_color (f, color_name, color_def, alloc) This does the right thing for any type of frame. */ int -defined_color (f, color_name, color_def, alloc) - struct frame *f; - char *color_name; - XColor *color_def; - int alloc; +defined_color (struct frame *f, const char *color_name, XColor *color_def, int alloc) { if (!FRAME_WINDOW_P (f)) return tty_defined_color (f, color_name, color_def, alloc); @@ -1275,9 +1220,7 @@ defined_color (f, color_name, color_def, alloc) Lisp string. */ Lisp_Object -tty_color_name (f, idx) - struct frame *f; - int idx; +tty_color_name (struct frame *f, int idx) { if (idx >= 0 && !NILP (Ffboundp (Qtty_color_by_index))) { @@ -1312,9 +1255,7 @@ tty_color_name (f, idx) The criterion implemented here is not a terribly sophisticated one. */ static int -face_color_gray_p (f, color_name) - struct frame *f; - char *color_name; +face_color_gray_p (struct frame *f, const char *color_name) { XColor color; int gray_p; @@ -1341,10 +1282,7 @@ face_color_gray_p (f, color_name) color. */ static int -face_color_supported_p (f, color_name, background_p) - struct frame *f; - char *color_name; - int background_p; +face_color_supported_p (struct frame *f, const char *color_name, int background_p) { Lisp_Object frame; XColor not_used; @@ -1370,8 +1308,7 @@ DEFUN ("color-gray-p", Fcolor_gray_p, Scolor_gray_p, 1, 2, 0, doc: /* Return non-nil if COLOR is a shade of gray (or white or black). FRAME specifies the frame and thus the display for interpreting COLOR. If FRAME is nil or omitted, use the selected frame. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { struct frame *f; @@ -1392,8 +1329,7 @@ BACKGROUND-P non-nil means COLOR is used as a background. Otherwise, this function tells whether it can be used as a foreground. If FRAME is nil or omitted, use the selected frame. COLOR must be a valid color name. */) - (color, frame, background_p) - Lisp_Object frame, color, background_p; + (Lisp_Object color, Lisp_Object frame, Lisp_Object background_p) { struct frame *f; @@ -1419,11 +1355,7 @@ COLOR must be a valid color name. */) these colors. */ unsigned long -load_color (f, face, name, target_index) - struct frame *f; - struct face *face; - Lisp_Object name; - enum lface_attribute_index target_index; +load_color (struct frame *f, struct face *face, Lisp_Object name, enum lface_attribute_index target_index) { XColor color; @@ -1494,10 +1426,7 @@ load_color (f, face, name, target_index) try to emulate gray colors with a stipple from Vface_default_stipple. */ static void -load_face_colors (f, face, attrs) - struct frame *f; - struct face *face; - Lisp_Object *attrs; +load_face_colors (struct frame *f, struct face *face, Lisp_Object *attrs) { Lisp_Object fg, bg; @@ -1533,9 +1462,7 @@ load_face_colors (f, face, attrs) /* Free color PIXEL on frame F. */ void -unload_color (f, pixel) - struct frame *f; - unsigned long pixel; +unload_color (struct frame *f, long unsigned int pixel) { #ifdef HAVE_X_WINDOWS if (pixel != -1) @@ -1551,9 +1478,7 @@ unload_color (f, pixel) /* Free colors allocated for FACE. */ static void -free_face_colors (f, face) - struct frame *f; - struct face *face; +free_face_colors (struct frame *f, struct face *face) { /* PENDING(NS): need to do something here? */ #ifdef HAVE_X_WINDOWS @@ -1693,8 +1618,7 @@ static int font_sort_order[4]; static enum font_property_index font_props_for_sorting[FONT_SIZE_INDEX]; static int -compare_fonts_by_sort_order (v1, v2) - const void *v1, *v2; +compare_fonts_by_sort_order (const void *v1, const void *v2) { Lisp_Object font1 = *(Lisp_Object *) v1; Lisp_Object font2 = *(Lisp_Object *) v2; @@ -1742,8 +1666,7 @@ FULL is the full name of the font, and REGISTRY-AND-ENCODING is a string giving the registry and encoding of the font. The result list is sorted according to the current setting of the face font sort order. */) - (family, frame) - Lisp_Object family, frame; + (Lisp_Object family, Lisp_Object frame) { Lisp_Object font_spec, list, *drivers, vec; int i, nfonts, ndrivers; @@ -1840,8 +1763,7 @@ fonts to match. The first MAXIMUM fonts are reported. The optional fifth argument WIDTH, if specified, is a number of columns occupied by a character of a font. In that case, return only fonts the WIDTH times as wide as FACE on FRAME. */) - (pattern, face, frame, maximum, width) - Lisp_Object pattern, face, frame, maximum, width; + (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width) { struct frame *f; int size, avgwidth; @@ -2150,9 +2072,7 @@ resolve_face_name_error (ignore) Return default face in case of errors. */ static Lisp_Object -resolve_face_name (face_name, signal_p) - Lisp_Object face_name; - int signal_p; +resolve_face_name (Lisp_Object face_name, int signal_p) { Lisp_Object orig_face; Lisp_Object tortoise, hare; @@ -2198,10 +2118,7 @@ resolve_face_name (face_name, signal_p) signal an error if FACE_NAME is not a valid face name. If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face name. */ static INLINE Lisp_Object -lface_from_face_name_no_resolve (f, face_name, signal_p) - struct frame *f; - Lisp_Object face_name; - int signal_p; +lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name, int signal_p) { Lisp_Object lface; @@ -2229,10 +2146,7 @@ lface_from_face_name_no_resolve (f, face_name, signal_p) If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face name. */ static INLINE Lisp_Object -lface_from_face_name (f, face_name, signal_p) - struct frame *f; - Lisp_Object face_name; - int signal_p; +lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p) { face_name = resolve_face_name (face_name, signal_p); return lface_from_face_name_no_resolve (f, face_name, signal_p); @@ -2246,19 +2160,15 @@ lface_from_face_name (f, face_name, signal_p) Otherwise, value is zero if FACE_NAME is not a face. */ static INLINE int -get_lface_attributes_no_remap (f, face_name, attrs, signal_p) - struct frame *f; - Lisp_Object face_name; - Lisp_Object *attrs; - int signal_p; +get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p) { Lisp_Object lface; lface = lface_from_face_name_no_resolve (f, face_name, signal_p); if (! NILP (lface)) - bcopy (XVECTOR (lface)->contents, attrs, - LFACE_VECTOR_SIZE * sizeof *attrs); + memcpy (attrs, XVECTOR (lface)->contents, + LFACE_VECTOR_SIZE * sizeof *attrs); return !NILP (lface); } @@ -2271,12 +2181,7 @@ get_lface_attributes_no_remap (f, face_name, attrs, signal_p) Otherwise, value is zero if FACE_NAME is not a face. */ static INLINE int -get_lface_attributes (f, face_name, attrs, signal_p, named_merge_points) - struct frame *f; - Lisp_Object face_name; - Lisp_Object *attrs; - int signal_p; - struct named_merge_point *named_merge_points; +get_lface_attributes (struct frame *f, Lisp_Object face_name, Lisp_Object *attrs, int signal_p, struct named_merge_point *named_merge_points) { Lisp_Object face_remapping; @@ -2312,8 +2217,7 @@ get_lface_attributes (f, face_name, attrs, signal_p, named_merge_points) specified, i.e. are non-nil. */ static int -lface_fully_specified_p (attrs) - Lisp_Object *attrs; +lface_fully_specified_p (Lisp_Object *attrs) { int i; @@ -2333,10 +2237,7 @@ lface_fully_specified_p (attrs) of FORCE_P. */ static int -set_lface_from_font (f, lface, font_object, force_p) - struct frame *f; - Lisp_Object lface, font_object; - int force_p; +set_lface_from_font (struct frame *f, Lisp_Object lface, Lisp_Object font_object, int force_p) { Lisp_Object val; struct font *font = XFONT_OBJECT (font_object); @@ -2397,8 +2298,7 @@ set_lface_from_font (f, lface, font_object, force_p) unless both FROM and TO are relative. */ Lisp_Object -merge_face_heights (from, to, invalid) - Lisp_Object from, to, invalid; +merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) { Lisp_Object result = invalid; @@ -2447,10 +2347,7 @@ merge_face_heights (from, to, invalid) other places. */ static INLINE void -merge_face_vectors (f, from, to, named_merge_points) - struct frame *f; - Lisp_Object *from, *to; - struct named_merge_point *named_merge_points; +merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, struct named_merge_point *named_merge_points) { int i; @@ -2517,11 +2414,7 @@ merge_face_vectors (f, from, to, named_merge_points) merging succeeded. */ static int -merge_named_face (f, face_name, to, named_merge_points) - struct frame *f; - Lisp_Object face_name; - Lisp_Object *to; - struct named_merge_point *named_merge_points; +merge_named_face (struct frame *f, Lisp_Object face_name, Lisp_Object *to, struct named_merge_point *named_merge_points) { struct named_merge_point named_merge_point; @@ -2571,12 +2464,7 @@ merge_named_face (f, face_name, to, named_merge_points) specifications. */ static int -merge_face_ref (f, face_ref, to, err_msgs, named_merge_points) - struct frame *f; - Lisp_Object face_ref; - Lisp_Object *to; - int err_msgs; - struct named_merge_point *named_merge_points; +merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to, int err_msgs, struct named_merge_point *named_merge_points) { int ok = 1; /* Succeed without an error? */ @@ -2806,8 +2694,7 @@ If FACE was not known as a face before, create a new one. If optional argument FRAME is specified, make a frame-local face for that frame. Otherwise operate on the global face definition. Value is a vector of face attributes. */) - (face, frame) - Lisp_Object face, frame; + (Lisp_Object face, Lisp_Object frame) { Lisp_Object global_lface, lface; struct frame *f; @@ -2895,8 +2782,7 @@ FACE should be a symbol or string. If optional second argument FRAME is non-nil, check for the existence of a frame-local face with name FACE on that frame. Otherwise check for the existence of a global face. */) - (face, frame) - Lisp_Object face, frame; + (Lisp_Object face, Lisp_Object frame) { Lisp_Object lface; @@ -2924,8 +2810,7 @@ definition of TO on NEW-FRAME. If NEW-FRAME is nil, FRAME controls where the data is copied to. The value is TO. */) - (from, to, frame, new_frame) - Lisp_Object from, to, frame, new_frame; + (Lisp_Object from, Lisp_Object to, Lisp_Object frame, Lisp_Object new_frame) { Lisp_Object lface, copy; @@ -2950,8 +2835,8 @@ The value is TO. */) copy = Finternal_make_lisp_face (to, new_frame); } - bcopy (XVECTOR (lface)->contents, XVECTOR (copy)->contents, - LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); + memcpy (XVECTOR (copy)->contents, XVECTOR (lface)->contents, + LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); /* Changing a named face means that all realized faces depending on that face are invalid. Since we cannot tell which realized faces @@ -2976,8 +2861,7 @@ FRAME nil means change the face of the selected frame. FRAME t means change the default for new frames. FRAME 0 means change the face on all frames, and change the default for new frames. */) - (face, attr, value, frame) - Lisp_Object face, attr, value, frame; + (Lisp_Object face, Lisp_Object attr, Lisp_Object value, Lisp_Object frame) { Lisp_Object lface; Lisp_Object old_value = Qnil; @@ -3490,44 +3374,11 @@ FRAME 0 means change the face on all frames, and change the default } -#ifdef HAVE_WINDOW_SYSTEM - -/* Set the `font' frame parameter of FRAME determined from the - font-object set in `default' face attributes LFACE. */ - -static void -set_font_frame_param (frame, lface) - Lisp_Object frame, lface; -{ - struct frame *f = XFRAME (frame); - Lisp_Object font; - - if (FRAME_WINDOW_P (f) - /* Don't do anything if the font is `unspecified'. This can - happen during frame creation. */ - && (font = LFACE_FONT (lface), - ! UNSPECIFIEDP (font))) - { - if (FONT_SPEC_P (font)) - { - font = font_load_for_lface (f, XVECTOR (lface)->contents, font); - if (NILP (font)) - return; - LFACE_FONT (lface) = font; - } - f->default_face_done_p = 0; - Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil)); - } -} - - /* Update the corresponding face when frame parameter PARAM on frame F has been assigned the value NEW_VALUE. */ void -update_face_from_frame_parameter (f, param, new_value) - struct frame *f; - Lisp_Object param, new_value; +update_face_from_frame_parameter (struct frame *f, Lisp_Object param, Lisp_Object new_value) { Lisp_Object face = Qnil; Lisp_Object lface; @@ -3562,6 +3413,7 @@ update_face_from_frame_parameter (f, param, new_value) ? new_value : Qunspecified); realize_basic_faces (f); } +#ifdef HAVE_WINDOW_SYSTEM else if (EQ (param, Qborder_color)) { face = Qborder; @@ -3583,6 +3435,7 @@ update_face_from_frame_parameter (f, param, new_value) LFACE_BACKGROUND (lface) = (STRINGP (new_value) ? new_value : Qunspecified); } +#endif /* Changing a named face means that all realized faces depending on that face are invalid. Since we cannot tell which realized faces @@ -3598,14 +3451,43 @@ update_face_from_frame_parameter (f, param, new_value) } +#ifdef HAVE_WINDOW_SYSTEM + +/* Set the `font' frame parameter of FRAME determined from the + font-object set in `default' face attributes LFACE. */ + +static void +set_font_frame_param (Lisp_Object frame, Lisp_Object lface) +{ + struct frame *f = XFRAME (frame); + Lisp_Object font; + + if (FRAME_WINDOW_P (f) + /* Don't do anything if the font is `unspecified'. This can + happen during frame creation. */ + && (font = LFACE_FONT (lface), + ! UNSPECIFIEDP (font))) + { + if (FONT_SPEC_P (font)) + { + font = font_load_for_lface (f, XVECTOR (lface)->contents, font); + if (NILP (font)) + return; + LFACE_FONT (lface) = font; + } + f->default_face_done_p = 0; + Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil)); + } +} + + /* Get the value of X resource RESOURCE, class CLASS for the display of frame FRAME. This is here because ordinary `x-get-resource' doesn't take a frame argument. */ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, Sinternal_face_x_get_resource, 3, 3, 0, doc: /* */) - (resource, class, frame) - Lisp_Object resource, class, frame; + (Lisp_Object resource, Lisp_Object class, Lisp_Object frame) { Lisp_Object value = Qnil; CHECK_STRING (resource); @@ -3625,9 +3507,7 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, error; if SIGNAL_P is zero, return 0. */ static Lisp_Object -face_boolean_x_resource_value (value, signal_p) - Lisp_Object value; - int signal_p; +face_boolean_x_resource_value (Lisp_Object value, int signal_p) { Lisp_Object result = make_number (0); @@ -3652,8 +3532,7 @@ DEFUN ("internal-set-lisp-face-attribute-from-resource", Finternal_set_lisp_face_attribute_from_resource, Sinternal_set_lisp_face_attribute_from_resource, 3, 4, 0, doc: /* */) - (face, attr, value, frame) - Lisp_Object face, attr, value, frame; + (Lisp_Object face, Lisp_Object attr, Lisp_Object value, Lisp_Object frame) { CHECK_SYMBOL (face); CHECK_SYMBOL (attr); @@ -3703,8 +3582,7 @@ DEFUN ("internal-set-lisp-face-attribute-from-resource", /* Make menus on frame F appear as specified by the `menu' face. */ static void -x_update_menu_appearance (f) - struct frame *f; +x_update_menu_appearance (struct frame *f) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); XrmDatabase rdb; @@ -3777,8 +3655,6 @@ x_update_menu_appearance (f) if (! NILP (xlfd)) { #if defined HAVE_X_I18N - extern char *xic_create_fontsetname - P_ ((char *base_fontname, Bool motif)); char *fontsetname = xic_create_fontsetname (SDATA (xlfd), motif); #else char *fontsetname = (char *) SDATA (xlfd); @@ -3814,8 +3690,7 @@ A relative value is one that doesn't entirely override whatever is inherited from another face. For most possible attributes, the only relative value that users see is `unspecified'. However, for :height, floating point values are also relative. */) - (attribute, value) - Lisp_Object attribute, value; + (Lisp_Object attribute, Lisp_Object value) { if (EQ (value, Qunspecified) || (EQ (value, Qignore_defface))) return Qt; @@ -3830,8 +3705,7 @@ DEFUN ("merge-face-attribute", Fmerge_face_attribute, Smerge_face_attribute, doc: /* Return face ATTRIBUTE VALUE1 merged with VALUE2. If VALUE1 or VALUE2 are absolute (see `face-attribute-relative-p'), then the result will be absolute, otherwise it will be relative. */) - (attribute, value1, value2) - Lisp_Object attribute, value1, value2; + (Lisp_Object attribute, Lisp_Object value1, Lisp_Object value2) { if (EQ (value1, Qunspecified) || EQ (value1, Qignore_defface)) return value2; @@ -3851,8 +3725,7 @@ face attribute name, signal an error. If the optional argument FRAME is given, report on face SYMBOL in that frame. If FRAME is t, report on the defaults for face SYMBOL (for new frames). If FRAME is omitted or nil, use the selected frame. */) - (symbol, keyword, frame) - Lisp_Object symbol, keyword, frame; + (Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame) { Lisp_Object lface, value = Qnil; @@ -3919,8 +3792,7 @@ DEFUN ("internal-lisp-face-attribute-values", Sinternal_lisp_face_attribute_values, 1, 1, 0, doc: /* Return a list of valid discrete values for face attribute ATTR. Value is nil if ATTR doesn't have a discrete set of valid values. */) - (attr) - Lisp_Object attr; + (Lisp_Object attr) { Lisp_Object result = Qnil; @@ -3943,8 +3815,7 @@ DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face, Sinternal_merge_in_global_face, 2, 2, 0, doc: /* Add attributes from frame-default definition of FACE to FACE on FRAME. Default face attributes override any local face attributes. */) - (face, frame) - Lisp_Object face, frame; + (Lisp_Object face, Lisp_Object frame) { int i; Lisp_Object global_lface, local_lface, *gvec, *lvec; @@ -3982,9 +3853,9 @@ Default face attributes override any local face attributes. */) { /* Ensure that the face vector is fully specified by merging the previously-cached vector. */ - bcopy (oldface->lface, attrs, sizeof attrs); + memcpy (attrs, oldface->lface, sizeof attrs); merge_face_vectors (f, lvec, attrs, 0); - bcopy (attrs, lvec, sizeof attrs); + memcpy (lvec, attrs, sizeof attrs); newface = realize_face (c, lvec, DEFAULT_FACE_ID); if ((! UNSPECIFIEDP (gvec[LFACE_FAMILY_INDEX]) @@ -4022,8 +3893,7 @@ If FRAME is t, report on the defaults for face FACE (for new frames). If FRAME is omitted or nil, use the selected frame. And, in this case, if the optional third argument CHARACTER is given, return the font name used for CHARACTER. */) - (face, frame, character) - Lisp_Object face, frame, character; + (Lisp_Object face, Lisp_Object frame, Lisp_Object character) { if (EQ (frame, Qt)) { @@ -4073,8 +3943,7 @@ return the font name used for CHARACTER. */) is called quite often. */ static INLINE int -face_attr_equal_p (v1, v2) - Lisp_Object v1, v2; +face_attr_equal_p (Lisp_Object v1, Lisp_Object v2) { /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, and the other is specified. */ @@ -4090,7 +3959,7 @@ face_attr_equal_p (v1, v2) if (SBYTES (v1) != SBYTES (v2)) return 0; - return bcmp (SDATA (v1), SDATA (v2), SBYTES (v1)) == 0; + return memcmp (SDATA (v1), SDATA (v2), SBYTES (v1)) == 0; case_Lisp_Int: case Lisp_Symbol: @@ -4107,8 +3976,7 @@ face_attr_equal_p (v1, v2) is called quite often. */ static INLINE int -lface_equal_p (v1, v2) - Lisp_Object *v1, *v2; +lface_equal_p (Lisp_Object *v1, Lisp_Object *v2) { int i, equal_p = 1; @@ -4125,8 +3993,7 @@ DEFUN ("internal-lisp-face-equal-p", Finternal_lisp_face_equal_p, If the optional argument FRAME is given, report on FACE1 and FACE2 in that frame. If FRAME is t, report on the defaults for FACE1 and FACE2 (for new frames). If FRAME is omitted or nil, use the selected frame. */) - (face1, face2, frame) - Lisp_Object face1, face2, frame; + (Lisp_Object face1, Lisp_Object face2, Lisp_Object frame) { int equal_p; struct frame *f; @@ -4155,8 +4022,7 @@ DEFUN ("internal-lisp-face-empty-p", Finternal_lisp_face_empty_p, If the optional argument FRAME is given, report on face FACE in that frame. If FRAME is t, report on the defaults for face FACE (for new frames). If FRAME is omitted or nil, use the selected frame. */) - (face, frame) - Lisp_Object face, frame; + (Lisp_Object face, Lisp_Object frame) { struct frame *f; Lisp_Object lface; @@ -4184,8 +4050,7 @@ DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, 0, 1, 0, doc: /* Return an alist of frame-local faces defined on FRAME. For internal use only. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f = frame_or_selected_frame (frame, 0); return f->face_alist; @@ -4196,8 +4061,7 @@ For internal use only. */) below in computing a hash value for a Lisp face. */ static INLINE unsigned -hash_string_case_insensitive (string) - Lisp_Object string; +hash_string_case_insensitive (Lisp_Object string) { const unsigned char *s; unsigned hash = 0; @@ -4211,8 +4075,7 @@ hash_string_case_insensitive (string) /* Return a hash code for face attribute vector V. */ static INLINE unsigned -lface_hash (v) - Lisp_Object *v; +lface_hash (Lisp_Object *v) { return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) ^ hash_string_case_insensitive (v[LFACE_FOUNDRY_INDEX]) @@ -4231,8 +4094,7 @@ lface_hash (v) LFACE1 and LFACE2 must be fully-specified. */ static INLINE int -lface_same_font_attributes_p (lface1, lface2) - Lisp_Object *lface1, *lface2; +lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2) { xassert (lface_fully_specified_p (lface1) && lface_fully_specified_p (lface2)); @@ -4263,13 +4125,12 @@ lface_same_font_attributes_p (lface1, lface2) vector ATTR. */ static struct face * -make_realized_face (attr) - Lisp_Object *attr; +make_realized_face (Lisp_Object *attr) { struct face *face = (struct face *) xmalloc (sizeof *face); - bzero (face, sizeof *face); + memset (face, 0, sizeof *face); face->ascii_face = face; - bcopy (attr, face->lface, sizeof face->lface); + memcpy (face->lface, attr, sizeof face->lface); return face; } @@ -4278,9 +4139,7 @@ make_realized_face (attr) be null. */ void -free_realized_face (f, face) - struct frame *f; - struct face *face; +free_realized_face (struct frame *f, struct face *face) { if (face) { @@ -4315,9 +4174,7 @@ free_realized_face (f, face) by clearing the face cache. */ void -prepare_face_for_display (f, face) - struct frame *f; - struct face *face; +prepare_face_for_display (struct frame *f, struct face *face) { #ifdef HAVE_WINDOW_SYSTEM xassert (FRAME_WINDOW_P (f)); @@ -4354,8 +4211,7 @@ prepare_face_for_display (f, face) /* Returns the `distance' between the colors X and Y. */ static int -color_distance (x, y) - XColor *x, *y; +color_distance (XColor *x, XColor *y) { /* This formula is from a paper title `Colour metric' by Thiadmer Riemersma. Quoting from that paper: @@ -4384,8 +4240,7 @@ DEFUN ("color-distance", Fcolor_distance, Scolor_distance, 2, 3, 0, COLOR1 and COLOR2 may be either strings containing the color name, or lists of the form (RED GREEN BLUE). If FRAME is unspecified or nil, the current frame is used. */) - (color1, color2, frame) - Lisp_Object color1, color2, frame; + (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame) { struct frame *f; XColor cdef1, cdef2; @@ -4413,17 +4268,16 @@ If FRAME is unspecified or nil, the current frame is used. */) /* Return a new face cache for frame F. */ static struct face_cache * -make_face_cache (f) - struct frame *f; +make_face_cache (struct frame *f) { struct face_cache *c; int size; c = (struct face_cache *) xmalloc (sizeof *c); - bzero (c, sizeof *c); + memset (c, 0, sizeof *c); size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; c->buckets = (struct face **) xmalloc (size); - bzero (c->buckets, size); + memset (c->buckets, 0, size); c->size = 50; c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id); c->f = f; @@ -4437,8 +4291,7 @@ make_face_cache (f) keeping too many graphics contexts that are no longer needed. */ static void -clear_face_gcs (c) - struct face_cache *c; +clear_face_gcs (struct face_cache *c) { if (c && FRAME_WINDOW_P (c->f)) { @@ -4468,8 +4321,7 @@ clear_face_gcs (c) event doesn't try to use faces we destroyed. */ static void -free_realized_faces (c) - struct face_cache *c; +free_realized_faces (struct face_cache *c) { if (c && c->used) { @@ -4489,7 +4341,7 @@ free_realized_faces (c) c->used = 0; size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; - bzero (c->buckets, size); + memset (c->buckets, 0, size); /* Must do a thorough redisplay the next time. Mark current matrices as invalid because they will reference faces freed @@ -4509,9 +4361,7 @@ free_realized_faces (c) /* Free all realized faces that are using FONTSET on frame F. */ void -free_realized_faces_for_fontset (f, fontset) - struct frame *f; - int fontset; +free_realized_faces_for_fontset (struct frame *f, int fontset) { struct face_cache *cache = FRAME_FACE_CACHE (f); struct face *face; @@ -4552,8 +4402,7 @@ free_realized_faces_for_fontset (f, fontset) because we can't tell which realized faces depend on that face. */ void -free_all_realized_faces (frame) - Lisp_Object frame; +free_all_realized_faces (Lisp_Object frame) { if (NILP (frame)) { @@ -4569,8 +4418,7 @@ free_all_realized_faces (frame) /* Free face cache C and faces in it, including their X resources. */ static void -free_face_cache (c) - struct face_cache *c; +free_face_cache (struct face_cache *c) { if (c) { @@ -4590,10 +4438,7 @@ free_face_cache (c) that a requested face is not cached. */ static void -cache_face (c, face, hash) - struct face_cache *c; - struct face *face; - unsigned hash; +cache_face (struct face_cache *c, struct face *face, unsigned int hash) { int i = hash % FACE_CACHE_BUCKETS_SIZE; @@ -4670,9 +4515,7 @@ cache_face (c, face, hash) /* Remove face FACE from cache C. */ static void -uncache_face (c, face) - struct face_cache *c; - struct face *face; +uncache_face (struct face_cache *c, struct face *face) { int i = face->hash % FACE_CACHE_BUCKETS_SIZE; @@ -4696,9 +4539,7 @@ uncache_face (c, face) realize a new one. */ INLINE int -lookup_face (f, attr) - struct frame *f; - Lisp_Object *attr; +lookup_face (struct frame *f, Lisp_Object *attr) { struct face_cache *cache = FRAME_FACE_CACHE (f); unsigned hash; @@ -4744,10 +4585,7 @@ lookup_face (f, attr) suitable face is found, realize a new one. */ int -face_for_font (f, font_object, base_face) - struct frame *f; - Lisp_Object font_object; - struct face *base_face; +face_for_font (struct frame *f, Lisp_Object font_object, struct face *base_face) { struct face_cache *cache = FRAME_FACE_CACHE (f); unsigned hash; @@ -4782,10 +4620,7 @@ face_for_font (f, font_object, base_face) face isn't realized and cannot be realized. */ int -lookup_named_face (f, symbol, signal_p) - struct frame *f; - Lisp_Object symbol; - int signal_p; +lookup_named_face (struct frame *f, Lisp_Object symbol, int signal_p) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; @@ -4803,7 +4638,7 @@ lookup_named_face (f, symbol, signal_p) if (! get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) return -1; - bcopy (default_face->lface, attrs, sizeof attrs); + memcpy (attrs, default_face->lface, sizeof attrs); merge_face_vectors (f, symbol_attrs, attrs, 0); return lookup_face (f, attrs); @@ -4817,9 +4652,7 @@ lookup_named_face (f, symbol, signal_p) rather than signal an error. */ int -lookup_basic_face (f, face_id) - struct frame *f; - int face_id; +lookup_basic_face (struct frame *f, int face_id) { Lisp_Object name, mapping; int remapped_face_id; @@ -4866,9 +4699,7 @@ lookup_basic_face (f, face_id) LFACE_ID on frame F. Value is -1 if LFACE_ID isn't valid. */ int -ascii_face_of_lisp_face (f, lface_id) - struct frame *f; - int lface_id; +ascii_face_of_lisp_face (struct frame *f, int lface_id) { int face_id; @@ -4889,9 +4720,7 @@ ascii_face_of_lisp_face (f, lface_id) STEPS < 0 means larger. Value is the id of the face. */ int -smaller_face (f, face_id, steps) - struct frame *f; - int face_id, steps; +smaller_face (struct frame *f, int face_id, int steps) { #ifdef HAVE_WINDOW_SYSTEM struct face *face; @@ -4910,7 +4739,7 @@ smaller_face (f, face_id, steps) steps = eabs (steps); face = FACE_FROM_ID (f, face_id); - bcopy (face->lface, attrs, sizeof attrs); + memcpy (attrs, face->lface, sizeof attrs); pt = last_pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); new_face_id = face_id; last_height = FONT_HEIGHT (face->font); @@ -4950,10 +4779,7 @@ smaller_face (f, face_id, steps) FACE_ID on frame F, but has height HEIGHT. */ int -face_with_height (f, face_id, height) - struct frame *f; - int face_id; - int height; +face_with_height (struct frame *f, int face_id, int height) { #ifdef HAVE_WINDOW_SYSTEM struct face *face; @@ -4964,7 +4790,7 @@ face_with_height (f, face_id, height) return face_id; face = FACE_FROM_ID (f, face_id); - bcopy (face->lface, attrs, sizeof attrs); + memcpy (attrs, face->lface, sizeof attrs); attrs[LFACE_HEIGHT_INDEX] = make_number (height); font_clear_prop (attrs, FONT_SIZE_INDEX); face_id = lookup_face (f, attrs); @@ -4982,11 +4808,7 @@ face_with_height (f, face_id, height) default face. FACE_ID is assumed to be already realized. */ int -lookup_derived_face (f, symbol, face_id, signal_p) - struct frame *f; - Lisp_Object symbol; - int face_id; - int signal_p; +lookup_derived_face (struct frame *f, Lisp_Object symbol, int face_id, int signal_p) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; @@ -4998,7 +4820,7 @@ lookup_derived_face (f, symbol, face_id, signal_p) if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p, 0)) return -1; - bcopy (default_face->lface, attrs, sizeof attrs); + memcpy (attrs, default_face->lface, sizeof attrs); merge_face_vectors (f, symbol_attrs, attrs, 0); return lookup_face (f, attrs); } @@ -5006,8 +4828,7 @@ lookup_derived_face (f, symbol, face_id, signal_p) DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector, Sface_attributes_as_vector, 1, 1, 0, doc: /* Return a vector of face attributes corresponding to PLIST. */) - (plist) - Lisp_Object plist; + (Lisp_Object plist) { Lisp_Object lface; lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), @@ -5043,10 +4864,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector, \(2) `close in spirit' to what the attributes specify, if not exact. */ static int -x_supports_face_attributes_p (f, attrs, def_face) - struct frame *f; - Lisp_Object *attrs; - struct face *def_face; +x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) { Lisp_Object *def_attrs = def_face->lface; @@ -5092,7 +4910,7 @@ x_supports_face_attributes_p (f, attrs, def_face) Lisp_Object merged_attrs[LFACE_VECTOR_SIZE]; int i; - bcopy (def_attrs, merged_attrs, sizeof merged_attrs); + memcpy (merged_attrs, def_attrs, sizeof merged_attrs); merge_face_vectors (f, attrs, merged_attrs, 0); @@ -5147,10 +4965,7 @@ x_supports_face_attributes_p (f, attrs, def_face) substitution of a `dim' face for italic. */ static int -tty_supports_face_attributes_p (f, attrs, def_face) - struct frame *f; - Lisp_Object *attrs; - struct face *def_face; +tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs, struct face *def_face) { int weight; Lisp_Object val, fg, bg; @@ -5330,8 +5145,7 @@ any display that can display bold, and a `:foreground \"yellow\"' as long as it can display a yellowish color, but `:slant italic' will _not_ be satisfied by the tty display code's automatic substitution of a `dim' face for italic. */) - (attributes, display) - Lisp_Object attributes, display; + (Lisp_Object attributes, Lisp_Object display) { int supports = 0, i; Lisp_Object frame; @@ -5408,15 +5222,14 @@ first in ORDER are matched first, e.g. if `:height' appears before `:weight' in ORDER, font selection first tries to find a font with a suitable height, and then tries to match the font weight. Value is ORDER. */) - (order) - Lisp_Object order; + (Lisp_Object order) { Lisp_Object list; int i; int indices[DIM (font_sort_order)]; CHECK_LIST (order); - bzero (indices, sizeof indices); + memset (indices, 0, sizeof indices); i = 0; for (list = order; @@ -5448,9 +5261,9 @@ Value is ORDER. */) if (indices[i] == 0) signal_error ("Invalid font sort order", order); - if (bcmp (indices, font_sort_order, sizeof indices) != 0) + if (memcmp (indices, font_sort_order, sizeof indices) != 0) { - bcopy (indices, font_sort_order, sizeof font_sort_order); + memcpy (font_sort_order, indices, sizeof font_sort_order); free_all_realized_faces (Qnil); } @@ -5467,8 +5280,7 @@ DEFUN ("internal-set-alternative-font-family-alist", ALIST is an alist of (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...) entries. Each ALTERNATIVE is tried in order if no fonts of font family FAMILY can be found. Value is ALIST. */) - (alist) - Lisp_Object alist; + (Lisp_Object alist) { Lisp_Object entry, tail, tail2; @@ -5497,8 +5309,7 @@ DEFUN ("internal-set-alternative-font-registry-alist", ALIST is an alist of (REGISTRY ALTERNATIVE1 ALTERNATIVE2 ...) entries. Each ALTERNATIVE is tried in order if no fonts of font registry REGISTRY can be found. Value is ALIST. */) - (alist) - Lisp_Object alist; + (Lisp_Object alist) { Lisp_Object entry, tail, tail2; @@ -5530,8 +5341,7 @@ be found. Value is ALIST. */) attribute of ATTRS doesn't name a fontset. */ static int -face_fontset (attrs) - Lisp_Object *attrs; +face_fontset (Lisp_Object *attrs) { Lisp_Object name; @@ -5554,8 +5364,7 @@ face_fontset (attrs) face. */ static int -realize_basic_faces (f) - struct frame *f; +realize_basic_faces (struct frame *f) { int success_p = 0; int count = SPECPDL_INDEX (); @@ -5603,8 +5412,7 @@ realize_basic_faces (f) that are not explicitly specified are taken from frame parameters. */ static int -realize_default_face (f) - struct frame *f; +realize_default_face (struct frame *f) { struct face_cache *c = FRAME_FACE_CACHE (f); Lisp_Object lface; @@ -5698,7 +5506,7 @@ realize_default_face (f) /* Realize the face; it must be fully-specified now. */ xassert (lface_fully_specified_p (XVECTOR (lface)->contents)); check_lface (lface); - bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); + memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs); face = realize_face (c, attrs, DEFAULT_FACE_ID); #ifdef HAVE_WINDOW_SYSTEM @@ -5727,10 +5535,7 @@ realize_default_face (f) have. The default face must have been realized already. */ static void -realize_named_face (f, symbol, id) - struct frame *f; - Lisp_Object symbol; - int id; +realize_named_face (struct frame *f, Lisp_Object symbol, int id) { struct face_cache *c = FRAME_FACE_CACHE (f); Lisp_Object lface = lface_from_face_name (f, symbol, 0); @@ -5766,10 +5571,7 @@ realize_named_face (f, symbol, id) face. Value is a pointer to the newly created realized face. */ static struct face * -realize_face (cache, attrs, former_face_id) - struct face_cache *cache; - Lisp_Object *attrs; - int former_face_id; +realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id) { struct face *face; @@ -5811,10 +5613,7 @@ realize_face (cache, attrs, former_face_id) no-font. */ static struct face * -realize_non_ascii_face (f, font_object, base_face) - struct frame *f; - Lisp_Object font_object; - struct face *base_face; +realize_non_ascii_face (struct frame *f, Lisp_Object font_object, struct face *base_face) { struct face_cache *cache = FRAME_FACE_CACHE (f); struct face *face; @@ -5848,9 +5647,7 @@ realize_non_ascii_face (f, font_object, base_face) created realized face. */ static struct face * -realize_x_face (cache, attrs) - struct face_cache *cache; - Lisp_Object *attrs; +realize_x_face (struct face_cache *cache, Lisp_Object *attrs) { struct face *face = NULL; #ifdef HAVE_WINDOW_SYSTEM @@ -6057,11 +5854,7 @@ realize_x_face (cache, attrs) default foreground/background colors. */ static void -map_tty_color (f, face, idx, defaulted) - struct frame *f; - struct face *face; - enum lface_attribute_index idx; - int *defaulted; +map_tty_color (struct frame *f, struct face *face, enum lface_attribute_index idx, int *defaulted) { Lisp_Object frame, color, def; int foreground_p = idx == LFACE_FOREGROUND_INDEX; @@ -6138,9 +5931,7 @@ map_tty_color (f, face, idx, defaulted) Value is a pointer to the newly created realized face. */ static struct face * -realize_tty_face (cache, attrs) - struct face_cache *cache; - Lisp_Object *attrs; +realize_tty_face (struct face_cache *cache, Lisp_Object *attrs) { struct face *face; int weight, slant; @@ -6203,8 +5994,7 @@ This affects bold faces on TTYs whose foreground is the default background color of the display and whose background is the default foreground color. For such faces, the bold face attribute is ignored if this variable is non-nil. */) - (suppress) - Lisp_Object suppress; + (Lisp_Object suppress) { tty_suppress_bold_inverse_default_colors_p = !NILP (suppress); ++face_change_count; @@ -6221,10 +6011,7 @@ is non-nil. */) property PROP on frame F in current_buffer. */ int -compute_char_face (f, ch, prop) - struct frame *f; - int ch; - Lisp_Object prop; +compute_char_face (struct frame *f, int ch, Lisp_Object prop) { int face_id; @@ -6240,7 +6027,7 @@ compute_char_face (f, ch, prop) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); - bcopy (default_face->lface, attrs, sizeof attrs); + memcpy (attrs, default_face->lface, sizeof attrs); merge_face_ref (f, prop, attrs, 1, 0); face_id = lookup_face (f, attrs); } @@ -6267,15 +6054,10 @@ compute_char_face (f, ch, prop) The face returned is suitable for displaying ASCII characters. */ int -face_at_buffer_position (w, pos, region_beg, region_end, - endptr, limit, mouse, base_face_id) - struct window *w; - EMACS_INT pos; - EMACS_INT region_beg, region_end; - EMACS_INT *endptr; - EMACS_INT limit; - int mouse; - int base_face_id; +face_at_buffer_position (struct window *w, EMACS_INT pos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, EMACS_INT limit, + int mouse, int base_face_id) { struct frame *f = XFRAME (w->frame); Lisp_Object attrs[LFACE_VECTOR_SIZE]; @@ -6329,7 +6111,7 @@ face_at_buffer_position (w, pos, region_beg, region_end, return default_face->id; /* Begin with attributes from the default face. */ - bcopy (default_face->lface, attrs, sizeof attrs); + memcpy (attrs, default_face->lface, sizeof attrs); /* Merge in attributes specified via text properties. */ if (!NILP (prop)) @@ -6375,15 +6157,10 @@ face_at_buffer_position (w, pos, region_beg, region_end, simply disregards the `face' properties of all overlays. */ int -face_for_overlay_string (w, pos, region_beg, region_end, - endptr, limit, mouse, overlay) - struct window *w; - EMACS_INT pos; - EMACS_INT region_beg, region_end; - EMACS_INT *endptr; - EMACS_INT limit; - int mouse; - Lisp_Object overlay; +face_for_overlay_string (struct window *w, EMACS_INT pos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, EMACS_INT limit, + int mouse, Lisp_Object overlay) { struct frame *f = XFRAME (w->frame); Lisp_Object attrs[LFACE_VECTOR_SIZE]; @@ -6423,7 +6200,7 @@ face_for_overlay_string (w, pos, region_beg, region_end, return DEFAULT_FACE_ID; /* Begin with attributes from the default face. */ - bcopy (default_face->lface, attrs, sizeof attrs); + memcpy (attrs, default_face->lface, sizeof attrs); /* Merge in attributes specified via text properties. */ if (!NILP (prop)) @@ -6468,15 +6245,11 @@ face_for_overlay_string (w, pos, region_beg, region_end, for displaying ASCII characters. */ int -face_at_string_position (w, string, pos, bufpos, region_beg, - region_end, endptr, base_face_id, mouse_p) - struct window *w; - Lisp_Object string; - EMACS_INT pos, bufpos; - EMACS_INT region_beg, region_end; - EMACS_INT *endptr; - enum face_id base_face_id; - int mouse_p; +face_at_string_position (struct window *w, Lisp_Object string, + EMACS_INT pos, EMACS_INT bufpos, + EMACS_INT region_beg, EMACS_INT region_end, + EMACS_INT *endptr, enum face_id base_face_id, + int mouse_p) { Lisp_Object prop, position, end, limit; struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -6524,7 +6297,7 @@ face_at_string_position (w, string, pos, bufpos, region_beg, return base_face->id; /* Begin with attributes from the base face. */ - bcopy (base_face->lface, attrs, sizeof attrs); + memcpy (attrs, base_face->lface, sizeof attrs); /* Merge in attributes specified via text properties. */ if (!NILP (prop)) @@ -6558,10 +6331,7 @@ face_at_string_position (w, string, pos, bufpos, region_beg, */ int -merge_faces (f, face_name, face_id, base_face_id) - struct frame *f; - Lisp_Object face_name; - int face_id, base_face_id; +merge_faces (struct frame *f, Lisp_Object face_name, int face_id, int base_face_id) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; struct face *base_face; @@ -6582,7 +6352,7 @@ merge_faces (f, face_name, face_id, base_face_id) } /* Begin with attributes from the base face. */ - bcopy (base_face->lface, attrs, sizeof attrs); + memcpy (attrs, base_face->lface, sizeof attrs); if (!NILP (face_name)) { @@ -6615,8 +6385,7 @@ DEFUN ("x-load-color-file", Fx_load_color_file, The file should define one named RGB color per line like so: R G B name where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */) - (filename) - Lisp_Object filename; + (Lisp_Object filename) { FILE *fp; Lisp_Object cmap = Qnil; @@ -6698,8 +6467,7 @@ dump_realized_face (face) DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */) - (n) - Lisp_Object n; + (Lisp_Object n) { if (NILP (n)) { @@ -6733,7 +6501,7 @@ DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, doc: /* */) DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, 0, 0, 0, doc: /* */) - () + (void) { fprintf (stderr, "number of colors = %d\n", ncolors_allocated); fprintf (stderr, "number of pixmaps = %d\n", npixmaps_allocated); @@ -6750,7 +6518,7 @@ DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, ***********************************************************************/ void -syms_of_xfaces () +syms_of_xfaces (void) { Qface = intern_c_string ("face"); staticpro (&Qface); @@ -6989,10 +6757,10 @@ Each element is of the form: (FACE REPLACEMENT...), which causes display of the face FACE to use REPLACEMENT... instead. -REPLACEMENT... is interpreted the same way the value of a `face' text -property is: it may be (1) A face name, (2) A list of face names, (3) A -property-list of face attribute/value pairs, or (4) A list of face names -intermixed with lists containing face attribute/value pairs. +REPLACEMENT... is interpreted the same way as the value of a `face' +text property: it may be (1) A face name, (2) A list of face names, +(3) A property-list of face attribute/value pairs, or (4) A list of +face names or lists containing face attribute/value pairs. Multiple entries in REPLACEMENT... are merged together to form the final result, with faces or attributes earlier in the list taking precedence @@ -7016,7 +6784,11 @@ face definitions. For instance, the mode my-mode could define a face `my-mode-default', and then in the mode setup function, do: (set (make-local-variable 'face-remapping-alist) - '((default my-mode-default)))). */); + '((default my-mode-default)))). + +Because Emacs normally only redraws screen areas when the underlying +buffer contents change, you may need to call `redraw-display' after +changing this variable for it to take effect. */); Vface_remapping_alist = Qnil; DEFVAR_LISP ("face-font-rescale-alist", &Vface_font_rescale_alist, diff --git a/src/xfns.c b/src/xfns.c index 1d7d3d03580..cb6733e8fa1 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -101,6 +101,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <Xm/FileSB.h> #endif +#ifdef USE_LUCID +#include "../lwlib/xlwmenu.h" +#endif + #if !defined(NO_EDITRES) #define HACK_EDITRES extern void _XEditResCheckMessages (); @@ -110,11 +114,6 @@ extern void _XEditResCheckMessages (); extern LWLIB_ID widget_id_tick; -#ifdef USE_LUCID -/* This is part of a kludge--see lwlib/xlwmenu.c. */ -extern XFontStruct *xlwmenu_default_font; -#endif - extern void free_frame_menubar (); extern double atof (); @@ -162,6 +161,10 @@ int x_gtk_file_dialog_help_text; int x_gtk_whole_detached_tool_bar; +/* If non-zero, use Gtk+ tooltips. */ + +static int x_gtk_use_system_tooltips; + /* The background and shape of the mouse pointer, and shape when not over text or in the modeline. */ @@ -199,14 +202,6 @@ Lisp_Object Qundefined_color; Lisp_Object Qcompound_text, Qcancel_timer; Lisp_Object Qfont_param; -/* In dispnew.c */ - -extern Lisp_Object Vwindow_system_version; - -/* The below are defined in frame.c. */ - -extern Lisp_Object Qtooltip; - #if GLYPH_DEBUG int image_cache_refcount, dpyinfo_refcount; #endif @@ -219,7 +214,7 @@ char *x_last_font_name; /* Error if we are not connected to X. */ void -check_x () +check_x (void) { if (! x_in_use) error ("X windows are not in use or not initialized"); @@ -229,7 +224,7 @@ check_x () You should not call this unless HAVE_MENUS is defined. */ int -have_menus_p () +have_menus_p (void) { return x_in_use; } @@ -238,8 +233,7 @@ have_menus_p () and checking validity for X. */ FRAME_PTR -check_x_frame (frame) - Lisp_Object frame; +check_x_frame (Lisp_Object frame) { FRAME_PTR f; @@ -258,8 +252,7 @@ check_x_frame (frame) the first X display on the list. */ struct x_display_info * -check_x_display_info (object) - Lisp_Object object; +check_x_display_info (Lisp_Object object) { struct x_display_info *dpyinfo = NULL; @@ -301,9 +294,7 @@ check_x_display_info (object) /* This function can be called during GC, so use GC_xxx type test macros. */ struct frame * -x_window_to_frame (dpyinfo, wdesc) - struct x_display_info *dpyinfo; - int wdesc; +x_window_to_frame (struct x_display_info *dpyinfo, int wdesc) { Lisp_Object tail, frame; struct frame *f; @@ -351,9 +342,7 @@ x_window_to_frame (dpyinfo, wdesc) windows. */ struct frame * -x_any_window_to_frame (dpyinfo, wdesc) - struct x_display_info *dpyinfo; - int wdesc; +x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) { Lisp_Object tail, frame; struct frame *f, *found; @@ -404,9 +393,7 @@ x_any_window_to_frame (dpyinfo, wdesc) /* Likewise, but consider only the menu bar widget. */ struct frame * -x_menubar_window_to_frame (dpyinfo, event) - struct x_display_info *dpyinfo; - XEvent *event; +x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event) { Window wdesc = event->xany.window; Lisp_Object tail, frame; @@ -441,9 +428,7 @@ x_menubar_window_to_frame (dpyinfo, event) If WDESC is some other (smaller) window, we return 0. */ struct frame * -x_top_window_to_frame (dpyinfo, wdesc) - struct x_display_info *dpyinfo; - int wdesc; +x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) { Lisp_Object tail, frame; struct frame *f; @@ -491,33 +476,33 @@ x_top_window_to_frame (dpyinfo, wdesc) -static void x_default_font_parameter P_ ((struct frame *, Lisp_Object)); - -static Lisp_Object unwind_create_frame P_ ((Lisp_Object)); -static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object)); - -void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object, - Lisp_Object)); -void x_set_scroll_bar_background P_ ((struct frame *, Lisp_Object, - Lisp_Object)); -static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *, - Lisp_Object, - Lisp_Object, - char *, char *, - int)); +static void x_default_font_parameter (struct frame *, Lisp_Object); + +static Lisp_Object unwind_create_frame (Lisp_Object); +static Lisp_Object unwind_create_tip_frame (Lisp_Object); + +void x_set_foreground_color (struct frame *, Lisp_Object, Lisp_Object); +static void x_set_wait_for_wm (struct frame *, Lisp_Object, Lisp_Object); +void x_set_background_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_mouse_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_cursor_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_border_color (struct frame *, Lisp_Object, Lisp_Object); +void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object); +void x_set_icon_type (struct frame *, Lisp_Object, Lisp_Object); +void x_set_icon_name (struct frame *, Lisp_Object, Lisp_Object); +void x_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); +void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +void x_set_title (struct frame *, Lisp_Object, Lisp_Object); +void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +void x_set_scroll_bar_foreground (struct frame *, Lisp_Object, + Lisp_Object); +void x_set_scroll_bar_background (struct frame *, Lisp_Object, + Lisp_Object); +static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *, + Lisp_Object, + Lisp_Object, + const char *, const char *, + int); /* Store the screen positions of frame F into XPTR and YPTR. @@ -525,9 +510,7 @@ static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *, not Emacs's own window. */ void -x_real_positions (f, xptr, yptr) - FRAME_PTR f; - int *xptr, *yptr; +x_real_positions (FRAME_PTR f, int *xptr, int *yptr) { int win_x, win_y, outer_x, outer_y; int real_x = 0, real_y = 0; @@ -645,9 +628,7 @@ x_real_positions (f, xptr, yptr) /* Gamma-correct COLOR on frame F. */ void -gamma_correct (f, color) - struct frame *f; - XColor *color; +gamma_correct (struct frame *f, XColor *color) { if (f->gamma) { @@ -664,18 +645,19 @@ gamma_correct (f, color) no color could be allocated. */ int -x_defined_color (f, color_name, color, alloc_p) - struct frame *f; - char *color_name; - XColor *color; - int alloc_p; +x_defined_color (struct frame *f, const char *color_name, + XColor *color, int alloc_p) { - int success_p; + int success_p = 0; Display *dpy = FRAME_X_DISPLAY (f); Colormap cmap = FRAME_X_COLORMAP (f); BLOCK_INPUT; - success_p = XParseColor (dpy, cmap, color_name, color); +#ifdef USE_GTK + success_p = xg_check_special_colors (f, color_name, color); +#endif + if (!success_p) + success_p = XParseColor (dpy, cmap, color_name, color); if (success_p && alloc_p) success_p = x_alloc_nearest_color (f, cmap, color); UNBLOCK_INPUT; @@ -689,10 +671,7 @@ x_defined_color (f, color_name, color, alloc_p) Signal an error if color can't be allocated. */ int -x_decode_color (f, color_name, mono_color) - FRAME_PTR f; - Lisp_Object color_name; - int mono_color; +x_decode_color (FRAME_PTR f, Lisp_Object color_name, int mono_color) { XColor cdef; @@ -726,22 +705,34 @@ x_decode_color (f, color_name, mono_color) See also the comment of wait_for_wm in struct x_output. */ static void -x_set_wait_for_wm (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_wait_for_wm (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { f->output_data.x->wait_for_wm = !NILP (new_value); } +static void +x_set_tool_bar_position (struct frame *f, + Lisp_Object new_value, + Lisp_Object old_value) +{ + if (! EQ (new_value, Qleft) && ! EQ (new_value, Qright) + && ! EQ (new_value, Qbottom) && ! EQ (new_value, Qtop)) + return; + if (EQ (new_value, old_value)) return; + +#ifdef USE_GTK + if (xg_change_toolbar_position (f, new_value)) + f->tool_bar_position = new_value; +#endif +} + #ifdef USE_GTK /* Set icon from FILE for frame F. By using GTK functions the icon may be any format that GdkPixbuf knows about, i.e. not just bitmaps. */ int -xg_set_icon (f, file) - FRAME_PTR f; - Lisp_Object file; +xg_set_icon (FRAME_PTR f, Lisp_Object file) { int result = 0; Lisp_Object found; @@ -775,12 +766,10 @@ xg_set_icon (f, file) } int -xg_set_icon_from_xpm_data (f, data) - FRAME_PTR f; - char **data; +xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data) { int result = 0; - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data); + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data); if (!pixbuf) return 0; @@ -801,9 +790,7 @@ xg_set_icon_from_xpm_data (f, data) in the standard place; do not attempt to change the window. */ void -x_set_foreground_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { struct x_output *x = f->output_data.x; unsigned long fg, old_fg; @@ -839,9 +826,7 @@ x_set_foreground_color (f, arg, oldval) } void -x_set_background_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { struct x_output *x = f->output_data.x; unsigned long bg; @@ -887,8 +872,7 @@ x_set_background_color (f, arg, oldval) } static Cursor -make_invisible_cursor (f) - struct frame *f; +make_invisible_cursor (struct frame *f) { Display *dpy = FRAME_X_DISPLAY (f); static char const no_data[] = { 0 }; @@ -916,9 +900,7 @@ make_invisible_cursor (f) } void -x_set_mouse_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { struct x_output *x = f->output_data.x; Display *dpy = FRAME_X_DISPLAY (f); @@ -1063,9 +1045,7 @@ x_set_mouse_color (f, arg, oldval) } void -x_set_cursor_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { unsigned long fore_pixel, pixel; int fore_pixel_allocated_p = 0, pixel_allocated_p = 0; @@ -1136,9 +1116,7 @@ x_set_cursor_color (f, arg, oldval) F has an x-window. */ void -x_set_border_pixel (f, pix) - struct frame *f; - int pix; +x_set_border_pixel (struct frame *f, int pix) { unload_color (f, f->output_data.x->border_pixel); f->output_data.x->border_pixel = pix; @@ -1167,9 +1145,7 @@ x_set_border_pixel (f, pix) and so emacs' border colors may be overridden. */ void -x_set_border_color (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int pix; @@ -1181,9 +1157,7 @@ x_set_border_color (f, arg, oldval) void -x_set_cursor_type (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { set_frame_cursor_types (f, arg); @@ -1192,9 +1166,7 @@ x_set_cursor_type (f, arg, oldval) } void -x_set_icon_type (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int result; @@ -1226,9 +1198,7 @@ x_set_icon_type (f, arg, oldval) } void -x_set_icon_name (f, arg, oldval) - struct frame *f; - Lisp_Object arg, oldval; +x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { int result; @@ -1266,9 +1236,7 @@ x_set_icon_name (f, arg, oldval) void -x_set_menu_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int nlines; #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) @@ -1358,9 +1326,7 @@ x_set_menu_bar_lines (f, value, oldval) The frame's height doesn't change. */ void -x_set_tool_bar_lines (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { int delta, nlines, root_height; Lisp_Object root_window; @@ -1455,9 +1421,7 @@ x_set_tool_bar_lines (f, value, oldval) the frame parameter. */ void -x_set_scroll_bar_foreground (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_scroll_bar_foreground (struct frame *f, Lisp_Object value, Lisp_Object oldval) { unsigned long pixel; @@ -1490,9 +1454,7 @@ x_set_scroll_bar_foreground (f, value, oldval) parameter. */ void -x_set_scroll_bar_background (f, value, oldval) - struct frame *f; - Lisp_Object value, oldval; +x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object oldval) { unsigned long pixel; @@ -1555,11 +1517,7 @@ x_set_scroll_bar_background (f, value, oldval) the result should be `COMPOUND_TEXT'. */ static unsigned char * -x_encode_text (string, coding_system, selectionp, text_bytes, stringp, freep) - Lisp_Object string, coding_system; - int *text_bytes, *stringp; - int selectionp; - int *freep; +x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, int *text_bytes, int *stringp, int *freep) { int result = string_xstring_p (string); struct coding_system coding; @@ -1593,9 +1551,7 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp, freep) icon name to NAME. */ static void -x_set_name_internal (f, name) - FRAME_PTR f; - Lisp_Object name; +x_set_name_internal (FRAME_PTR f, Lisp_Object name) { if (FRAME_X_WINDOW (f)) { @@ -1605,8 +1561,8 @@ x_set_name_internal (f, name) int bytes, stringp; int do_free_icon_value = 0, do_free_text_value = 0; Lisp_Object coding_system; -#ifdef USE_GTK Lisp_Object encoded_name; + Lisp_Object encoded_icon_name; struct gcpro gcpro1; /* As ENCODE_UTF_8 may cause GC and relocation of string data, @@ -1614,7 +1570,6 @@ x_set_name_internal (f, name) GCPRO1 (name); encoded_name = ENCODE_UTF_8 (name); UNGCPRO; -#endif coding_system = Qcompound_text; /* Note: Encoding strategy @@ -1630,7 +1585,12 @@ x_set_name_internal (f, name) We may also be able to use "UTF8_STRING" in text.encoding in the future which can encode all Unicode characters. But, for the moment, there's no way to know that the - current window manager supports it or not. */ + current window manager supports it or not. + + Either way, we also set the _NET_WM_NAME and _NET_WM_ICON_NAME + properties. Per the EWMH specification, those two properties + are always UTF8_STRING. This matches what gtk_window_set_title() + does in the USE_GTK case. */ text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp, &do_free_text_value); text.encoding = (stringp ? XA_STRING @@ -1641,6 +1601,7 @@ x_set_name_internal (f, name) if (!STRINGP (f->icon_name)) { icon = text; + encoded_icon_name = encoded_name; } else { @@ -1651,6 +1612,8 @@ x_set_name_internal (f, name) : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); icon.format = 8; icon.nitems = bytes; + + encoded_icon_name = ENCODE_UTF_8 (f->icon_name); } #ifdef USE_GTK @@ -1658,9 +1621,21 @@ x_set_name_internal (f, name) (char *) SDATA (encoded_name)); #else /* not USE_GTK */ XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text); + XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), + FRAME_X_DISPLAY_INFO (f)->Xatom_net_wm_name, + FRAME_X_DISPLAY_INFO (f)->Xatom_UTF8_STRING, + 8, PropModeReplace, + (char *) SDATA (encoded_name), + SBYTES (encoded_name)); #endif /* not USE_GTK */ XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon); + XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), + FRAME_X_DISPLAY_INFO (f)->Xatom_net_wm_icon_name, + FRAME_X_DISPLAY_INFO (f)->Xatom_UTF8_STRING, + 8, PropModeReplace, + (char *) SDATA (encoded_icon_name), + SBYTES (encoded_icon_name)); if (do_free_icon_value) xfree (icon.value); @@ -1683,10 +1658,7 @@ x_set_name_internal (f, name) F->explicit_name is set, ignore the new name; otherwise, set it. */ void -x_set_name (f, name, explicit) - struct frame *f; - Lisp_Object name; - int explicit; +x_set_name (struct frame *f, Lisp_Object name, int explicit) { /* Make sure that requests from lisp code override requests from Emacs redisplay code. */ @@ -1733,9 +1705,7 @@ x_set_name (f, name, explicit) specified a name for the frame; the name will override any set by the redisplay code. */ void -x_explicitly_set_name (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { x_set_name (f, arg, 1); } @@ -1744,9 +1714,7 @@ x_explicitly_set_name (f, arg, oldval) name; names set this way will never override names set by the user's lisp code. */ void -x_implicitly_set_name (f, arg, oldval) - FRAME_PTR f; - Lisp_Object arg, oldval; +x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) { x_set_name (f, arg, 0); } @@ -1755,9 +1723,7 @@ x_implicitly_set_name (f, arg, oldval) If NAME is nil, use the frame name as the title. */ void -x_set_title (f, name, old_name) - struct frame *f; - Lisp_Object name, old_name; +x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) { /* Don't change the title if it's already NAME. */ if (EQ (name, f->title)) @@ -1776,8 +1742,7 @@ x_set_title (f, name, old_name) } void -x_set_scroll_bar_default_width (f) - struct frame *f; +x_set_scroll_bar_default_width (struct frame *f) { int wid = FRAME_COLUMN_WIDTH (f); @@ -1804,14 +1769,10 @@ x_set_scroll_bar_default_width (f) named NAME. If that is not found either, use the value DEFLT. */ static Lisp_Object -x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass, - foreground_p) - struct frame *f; - Lisp_Object alist; - Lisp_Object prop; - char *xprop; - char *xclass; - int foreground_p; +x_default_scroll_bar_color_parameter (struct frame *f, + Lisp_Object alist, Lisp_Object prop, + const char *xprop, const char *xclass, + int foreground_p) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Lisp_Object tem; @@ -1862,9 +1823,7 @@ x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass, for example, but Xt doesn't). */ static void -hack_wm_protocols (f, widget) - FRAME_PTR f; - Widget widget; +hack_wm_protocols (FRAME_PTR f, Widget widget) { Display *dpy = XtDisplay (widget); Window w = XtWindow (widget); @@ -1930,8 +1889,8 @@ hack_wm_protocols (f, widget) #ifdef HAVE_X_I18N -static XFontSet xic_create_xfontset P_ ((struct frame *)); -static XIMStyle best_xim_style P_ ((XIMStyles *, XIMStyles *)); +static XFontSet xic_create_xfontset (struct frame *); +static XIMStyle best_xim_style (XIMStyles *, XIMStyles *); /* Supported XIM styles, ordered by preference. */ @@ -1953,14 +1912,12 @@ static XIMStyle supported_xim_styles[] = /* Create an X fontset on frame F with base font name BASE_FONTNAME. */ -char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; +const char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; /* Create an Xt fontset spec from the name of a base font. If `motif' is True use the Motif syntax. */ char * -xic_create_fontsetname (base_fontname, motif) - char *base_fontname; - Bool motif; +xic_create_fontsetname (const char *base_fontname, int motif) { const char *sep = motif ? ";" : ","; char *fontsetname; @@ -1970,7 +1927,7 @@ xic_create_fontsetname (base_fontname, motif) { /* There is no base font name, use the default. */ int len = strlen (base_fontname) + 2; fontsetname = xmalloc (len); - bzero (fontsetname, len); + memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); } else @@ -1980,7 +1937,7 @@ xic_create_fontsetname (base_fontname, motif) - the base font. - the base font where the charset spec is replaced by -*-*. - the same but with the family also replaced with -*-*-. */ - char *p = base_fontname; + const char *p = base_fontname; int i; for (i = 0; *p; p++) @@ -1991,7 +1948,7 @@ xic_create_fontsetname (base_fontname, motif) Use the specified font plus the default. */ int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 3; fontsetname = xmalloc (len); - bzero (fontsetname, len); + memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); strcat (fontsetname, sep); strcat (fontsetname, xic_defaut_fontset); @@ -1999,13 +1956,13 @@ xic_create_fontsetname (base_fontname, motif) else { int len; - char *p1 = NULL, *p2 = NULL, *p3 = NULL; + const char *p1 = NULL, *p2 = NULL, *p3 = NULL; char *font_allcs = NULL; char *font_allfamilies = NULL; char *font_all = NULL; - char *allcs = "*-*-*-*-*-*-*"; - char *allfamilies = "-*-*-"; - char *all = "*-*-*-*-"; + const char *allcs = "*-*-*-*-*-*-*"; + const char *allfamilies = "-*-*-"; + const char *all = "*-*-*-*-"; char *base; for (i = 0, p = base_fontname; i < 8; p++) @@ -2028,7 +1985,7 @@ xic_create_fontsetname (base_fontname, motif) int diff = (p2 - p3) - 2; base = alloca (strlen (base_fontname) + 1); - bcopy (base_fontname, base, p3 - base_fontname); + memcpy (base, base_fontname, p3 - base_fontname); base[p3 - base_fontname] = '*'; base[(p3 - base_fontname) + 1] = '-'; strcpy (base + (p3 - base_fontname) + 2, p2); @@ -2041,33 +1998,33 @@ xic_create_fontsetname (base_fontname, motif) /* Build the font spec that matches all charsets. */ len = p - base_fontname + strlen (allcs) + 1; font_allcs = (char *) alloca (len); - bzero (font_allcs, len); - bcopy (base_fontname, font_allcs, p - base_fontname); + memset (font_allcs, 0, len); + memcpy (font_allcs, base_fontname, p - base_fontname); strcat (font_allcs, allcs); /* Build the font spec that matches all families and add-styles. */ len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1; font_allfamilies = (char *) alloca (len); - bzero (font_allfamilies, len); + memset (font_allfamilies, 0, len); strcpy (font_allfamilies, allfamilies); - bcopy (p1, font_allfamilies + strlen (allfamilies), p - p1); + memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); strcat (font_allfamilies, allcs); /* Build the font spec that matches all. */ len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; font_all = (char *) alloca (len); - bzero (font_all, len); + memset (font_all, 0, len); strcpy (font_all, allfamilies); strcat (font_all, all); - bcopy (p2, font_all + strlen (all) + strlen (allfamilies), p - p2); + memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); strcat (font_all, allcs); /* Build the actual font set name. */ len = strlen (base_fontname) + strlen (font_allcs) + strlen (font_allfamilies) + strlen (font_all) + 5; fontsetname = xmalloc (len); - bzero (fontsetname, len); + memset (fontsetname, 0, len); strcpy (fontsetname, base_fontname); strcat (fontsetname, sep); strcat (fontsetname, font_allcs); @@ -2106,8 +2063,7 @@ print_fontset_result (xfs, name, missing_list, missing_count) #endif static XFontSet -xic_create_xfontset (f) - struct frame *f; +xic_create_xfontset (struct frame *f) { XFontSet xfs = NULL; struct font *font = FRAME_FONT (f); @@ -2135,7 +2091,7 @@ xic_create_xfontset (f) char **missing_list; int missing_count; char *def_string; - char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*"; + const char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*"; sprintf (buf, xlfd_format, pixel_size); missing_list = NULL; @@ -2186,7 +2142,7 @@ xic_create_xfontset (f) } if (! xfs) { - char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*"; + const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*"; missing_list = NULL; xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort, @@ -2206,8 +2162,7 @@ xic_create_xfontset (f) /* Free the X fontset of frame F if it is the last frame using it. */ void -xic_free_xfontset (f) - struct frame *f; +xic_free_xfontset (struct frame *f) { Lisp_Object rest, frame; int shared_p = 0; @@ -2244,9 +2199,7 @@ xic_free_xfontset (f) input method XIM. */ static XIMStyle -best_xim_style (user, xim) - XIMStyles *user; - XIMStyles *xim; +best_xim_style (XIMStyles *user, XIMStyles *xim) { int i, j; @@ -2264,8 +2217,7 @@ best_xim_style (user, xim) static XIMStyle xic_style; void -create_frame_xic (f) - struct frame *f; +create_frame_xic (struct frame *f) { XIM xim; XIC xic = NULL; @@ -2340,8 +2292,7 @@ create_frame_xic (f) /* Destroy XIC and free XIC fontset of frame F, if any. */ void -free_frame_xic (f) - struct frame *f; +free_frame_xic (struct frame *f) { if (FRAME_XIC (f) == NULL) return; @@ -2357,9 +2308,7 @@ free_frame_xic (f) pixel position X/Y. X and Y are relative to window W. */ void -xic_set_preeditarea (w, x, y) - struct window *w; - int x, y; +xic_set_preeditarea (struct window *w, int x, int y) { struct frame *f = XFRAME (w->frame); XVaNestedList attr; @@ -2376,8 +2325,7 @@ xic_set_preeditarea (w, x, y) /* Place status area for XIC in bottom right corner of frame F.. */ void -xic_set_statusarea (f) - struct frame *f; +xic_set_statusarea (struct frame *f) { XIC xic = FRAME_XIC (f); XVaNestedList attr; @@ -2407,7 +2355,7 @@ xic_set_statusarea (f) area.x = FRAME_PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f); area.y = (FRAME_PIXEL_HEIGHT (f) - area.height - FRAME_MENUBAR_HEIGHT (f) - - FRAME_TOOLBAR_HEIGHT (f) + - FRAME_TOOLBAR_TOP_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f)); XFree (needed); @@ -2421,9 +2369,7 @@ xic_set_statusarea (f) BASE_FONTNAME. Called when a new Emacs fontset is chosen. */ void -xic_set_xfontset (f, base_fontname) - struct frame *f; - char *base_fontname; +xic_set_xfontset (struct frame *f, const char *base_fontname) { XVaNestedList attr; XFontSet xfs; @@ -2451,10 +2397,7 @@ xic_set_xfontset (f, base_fontname) /* Create and set up the X widget for frame F. */ static void -x_window (f, window_prompting, minibuffer_only) - struct frame *f; - long window_prompting; - int minibuffer_only; +x_window (struct frame *f, long window_prompting, int minibuffer_only) { XClassHint class_hints; XSetWindowAttributes attributes; @@ -2506,6 +2449,7 @@ x_window (f, window_prompting, minibuffer_only) XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++; XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++; XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++; + XtSetArg (al[ac], XtNborderWidth, 0); ac++; XtSetValues (pane_widget, al, ac); f->output_data.x->column_widget = pane_widget; @@ -2521,6 +2465,7 @@ x_window (f, window_prompting, minibuffer_only) XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++; XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++; XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++; + XtSetArg (al[ac], XtNborderWidth, 0); ac++; frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget, al, ac); @@ -2698,8 +2643,7 @@ x_window (f, window_prompting, minibuffer_only) #else /* not USE_X_TOOLKIT */ #ifdef USE_GTK void -x_window (f) - FRAME_PTR f; +x_window (FRAME_PTR f) { if (! xg_create_frame_widgets (f)) error ("Unable to create window"); @@ -2739,9 +2683,7 @@ x_window (f) /* Create and set up the X window for frame F. */ void -x_window (f) - struct frame *f; - +x_window (struct frame *f) { XClassHint class_hints; XSetWindowAttributes attributes; @@ -2846,9 +2788,7 @@ x_window (f) /* Verify that the icon position args for this window are valid. */ static void -x_icon_verify (f, parms) - struct frame *f; - Lisp_Object parms; +x_icon_verify (struct frame *f, Lisp_Object parms) { Lisp_Object icon_x, icon_y; @@ -2870,9 +2810,7 @@ x_icon_verify (f, parms) well. */ static void -x_icon (f, parms) - struct frame *f; - Lisp_Object parms; +x_icon (struct frame *f, Lisp_Object parms) { Lisp_Object icon_x, icon_y; #if 0 @@ -2918,8 +2856,7 @@ x_icon (f, parms) mouse cursor and the gray border tile. */ static void -x_make_gc (f) - struct frame *f; +x_make_gc (struct frame *f) { XGCValues gc_values; @@ -2978,8 +2915,7 @@ x_make_gc (f) /* Free what was allocated in x_make_gc. */ void -x_free_gcs (f) - struct frame *f; +x_free_gcs (struct frame *f) { Display *dpy = FRAME_X_DISPLAY (f); @@ -3018,8 +2954,7 @@ x_free_gcs (f) constructed. */ static Lisp_Object -unwind_create_frame (frame) - Lisp_Object frame; +unwind_create_frame (Lisp_Object frame) { struct frame *f = XFRAME (frame); @@ -3051,34 +2986,36 @@ unwind_create_frame (frame) static void -x_default_font_parameter (f, parms) - struct frame *f; - Lisp_Object parms; +x_default_font_parameter (struct frame *f, Lisp_Object parms) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL, RES_TYPE_STRING); - Lisp_Object font; - int got_from_gconf = 0; + Lisp_Object font = Qnil; if (EQ (font_param, Qunbound)) font_param = Qnil; if (NILP (font_param)) { - /* System font takes precedendce over X resources. We must suggest this + /* System font should take precedendce over X resources. We suggest this regardless of font-use-system-font because .emacs may not have been read yet. */ const char *system_font = xsettings_get_system_font (); - if (system_font) font_param = make_string (system_font, - strlen (system_font)); + if (system_font) + { + char *name = xstrdup (system_font); + font = font_open_by_name (f, name); + free (name); + } } - font = !NILP (font_param) ? font_param - : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING); + if (NILP (font)) + font = !NILP (font_param) ? font_param + : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING); - if (! STRINGP (font)) + if (! FONTP (font) && ! STRINGP (font)) { - char *names[] + const char *names[] = { #ifdef HAVE_XFT /* This will find the normal Xft font. */ @@ -3113,10 +3050,8 @@ x_default_font_parameter (f, parms) x_set_frame_parameters (f, Fcons (Fcons (Qfont_param, font_param), Qnil)); } - x_default_parameter (f, parms, Qfont, font, - got_from_gconf ? NULL : "font", - got_from_gconf ? NULL : "Font", - RES_TYPE_STRING); + /* This call will make X resources override any system font setting. */ + x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING); } @@ -3124,8 +3059,7 @@ DEFUN ("x-wm-set-size-hint", Fx_wm_set_size_hint, Sx_wm_set_size_hint, 0, 1, 0, doc: /* Send the size hints for frame FRAME to the window manager. If FRAME is nil, use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f; if (NILP (frame)) @@ -3138,6 +3072,37 @@ If FRAME is nil, use the selected frame. */) return Qnil; } +static void +set_machine_and_pid_properties (struct frame *f) +{ + /* See the above comment "Note: Encoding strategy". */ + XTextProperty text; + int bytes, stringp; + int do_free_text_value = 0; + long pid = (long) getpid (); + + text.value = x_encode_text (Vsystem_name, + Qcompound_text, 0, &bytes, &stringp, + &do_free_text_value); + text.encoding = (stringp ? XA_STRING + : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); + text.format = 8; + text.nitems = bytes; + XSetWMClientMachine (FRAME_X_DISPLAY (f), + FRAME_OUTER_WINDOW (f), + &text); + if (do_free_text_value) + xfree (text.value); + + XChangeProperty (FRAME_X_DISPLAY (f), + FRAME_OUTER_WINDOW (f), + XInternAtom (FRAME_X_DISPLAY (f), + "_NET_WM_PID", + False), + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &pid, 1); +} + DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1, 1, 0, doc: /* Make a new X window, which is called a "frame" in Emacs terms. @@ -3149,8 +3114,7 @@ then `default-minibuffer-frame' must be a frame whose minibuffer can be shared by the new frame. This function is an internal primitive--use `make-frame' instead. */) - (parms) - Lisp_Object parms; + (Lisp_Object parms) { struct frame *f; Lisp_Object frame, tem; @@ -3227,7 +3191,7 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_method = output_x_window; f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); - bzero (f->output_data.x, sizeof (struct x_output)); + memset (f->output_data.x, 0, sizeof (struct x_output)); f->output_data.x->icon_bitmap = -1; FRAME_FONTSET (f) = -1; f->output_data.x->scroll_bar_foreground_pixel = -1; @@ -3337,17 +3301,9 @@ This function is an internal primitive--use `make-frame' instead. */) error ("Invalid frame font"); } -#ifdef USE_LUCID - /* Prevent lwlib/xlwmenu.c from crashing because of a bug - whereby it fails to get any font. */ - BLOCK_INPUT; - xlwmenu_default_font = XLoadQueryFont (FRAME_X_DISPLAY (f), "fixed"); - UNBLOCK_INPUT; -#endif - /* Frame contents get displaced if an embedded X window has a border. */ if (! FRAME_X_EMBEDDED_P (f)) - x_default_parameter (f, parms, Qborder_width, make_number (2), + x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER); /* This defaults to 1 in order to match xterm. We recognize either @@ -3371,7 +3327,12 @@ This function is an internal primitive--use `make-frame' instead. */) #endif "internalBorderWidth", "internalBorderWidth", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qvertical_scroll_bars, Qleft, + x_default_parameter (f, parms, Qvertical_scroll_bars, +#if defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS) + Qright, +#else + Qleft, +#endif "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL); @@ -3410,10 +3371,18 @@ This function is an internal primitive--use `make-frame' instead. */) happen. */ init_frame_faces (f); - x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), - "menuBar", "MenuBar", RES_TYPE_BOOLEAN_NUMBER); - x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), - "toolBar", "ToolBar", RES_TYPE_NUMBER); + /* The X resources controlling the menu-bar and tool-bar are + processed specially at startup, and reflected in the mode + variables; ignore them here. */ + x_default_parameter (f, parms, Qmenu_bar_lines, + NILP (Vmenu_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qtool_bar_lines, + NILP (Vtool_bar_mode) + ? make_number (0) : make_number (1), + NULL, NULL, RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); @@ -3423,6 +3392,8 @@ This function is an internal primitive--use `make-frame' instead. */) "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN); x_default_parameter (f, parms, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); + x_default_parameter (f, parms, Qtool_bar_position, + f->tool_bar_position, 0, 0, RES_TYPE_SYMBOL); /* Compute the size of the X window. */ window_prompting = x_figure_window_size (f, parms, 1); @@ -3519,19 +3490,24 @@ This function is an internal primitive--use `make-frame' instead. */) ; } + BLOCK_INPUT; + + /* Set machine name and pid for the purpose of window managers. */ + set_machine_and_pid_properties(f); + /* Set the WM leader property. GTK does this itself, so this is not needed when using GTK. */ if (dpyinfo->client_leader_window != 0) { - BLOCK_INPUT; XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), dpyinfo->Xatom_wm_client_leader, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &dpyinfo->client_leader_window, 1); - UNBLOCK_INPUT; } + UNBLOCK_INPUT; + /* Initialize `default-minibuffer-frame' in case this is the first frame on this terminal. */ if (FRAME_HAS_MINIBUF_P (f) @@ -3560,8 +3536,7 @@ This function is an internal primitive--use `make-frame' instead. */) know about that structure. */ Lisp_Object -x_get_focus_frame (frame) - struct frame *frame; +x_get_focus_frame (struct frame *frame) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (frame); Lisp_Object xfocus; @@ -3585,8 +3560,7 @@ x_get_focus_frame (frame) DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, doc: /* Set the input focus to FRAME. FRAME nil means use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { struct frame *f = check_x_frame (frame); Display *dpy = FRAME_X_DISPLAY (f); @@ -3605,8 +3579,7 @@ FRAME nil means use the selected frame. */) DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, doc: /* Internal function called by `color-defined-p', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { XColor foo; FRAME_PTR f = check_x_frame (frame); @@ -3621,8 +3594,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, doc: /* Internal function called by `color-values', which see. */) - (color, frame) - Lisp_Object color, frame; + (Lisp_Object color, Lisp_Object frame) { XColor foo; FRAME_PTR f = check_x_frame (frame); @@ -3639,8 +3611,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, doc: /* Internal function called by `display-color-p', which see. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3667,8 +3638,7 @@ Note that color displays do support shades of gray. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3696,8 +3666,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3710,8 +3679,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3724,8 +3692,7 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3738,8 +3705,7 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3763,8 +3729,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3778,11 +3743,10 @@ that operating systems cannot be developed and distributed noncommercially.) The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); - char *vendor = ServerVendor (dpyinfo->display); + const char *vendor = ServerVendor (dpyinfo->display); if (! vendor) vendor = ""; return build_string (vendor); @@ -3797,8 +3761,7 @@ number. See also the function `x-server-vendor'. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); Display *dpy = dpyinfo->display; @@ -3813,8 +3776,7 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3826,8 +3788,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3839,8 +3800,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3854,8 +3814,7 @@ The value may be `always', `when-mapped', or `not-useful'. The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); Lisp_Object result; @@ -3891,8 +3850,7 @@ The value is one of the symbols `static-gray', `gray-scale', The optional argument TERMINAL specifies which display to ask about. TERMINAL should a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); Lisp_Object result; @@ -3931,8 +3889,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under, The optional argument TERMINAL specifies which display to ask about. TERMINAL should be a terminal object, a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -3943,36 +3900,31 @@ If omitted or nil, that stands for the selected frame's display. */) } int -x_pixel_width (f) - register struct frame *f; +x_pixel_width (register struct frame *f) { return FRAME_PIXEL_WIDTH (f); } int -x_pixel_height (f) - register struct frame *f; +x_pixel_height (register struct frame *f) { return FRAME_PIXEL_HEIGHT (f); } int -x_char_width (f) - register struct frame *f; +x_char_width (register struct frame *f) { return FRAME_COLUMN_WIDTH (f); } int -x_char_height (f) - register struct frame *f; +x_char_height (register struct frame *f) { return FRAME_LINE_HEIGHT (f); } int -x_screen_planes (f) - register struct frame *f; +x_screen_planes (register struct frame *f) { return FRAME_X_DISPLAY_INFO (f)->n_planes; } @@ -3988,7 +3940,7 @@ x_screen_planes (f) static struct visual_class { - char *name; + const char *name; int class; } visual_classes[] = @@ -4029,8 +3981,7 @@ XScreenNumberOfScreen (scr) members of DPYINFO appropriately. Called from x_term_init. */ void -select_visual (dpyinfo) - struct x_display_info *dpyinfo; +select_visual (struct x_display_info *dpyinfo) { Display *dpy = dpyinfo->display; Screen *screen = dpyinfo->screen; @@ -4052,7 +4003,7 @@ select_visual (dpyinfo) XVisualInfo vinfo; strcpy (s, SDATA (value)); - dash = index (s, '-'); + dash = strchr (s, '-'); if (dash) { dpyinfo->n_planes = atoi (dash + 1); @@ -4090,7 +4041,7 @@ select_visual (dpyinfo) vinfo_template.screen = XScreenNumberOfScreen (screen); vinfo = XGetVisualInfo (dpy, VisualIDMask | VisualScreenMask, &vinfo_template, &n_visuals); - if (n_visuals != 1) + if (n_visuals <= 0) fatal ("Can't get proper X visual info"); dpyinfo->n_planes = vinfo->depth; @@ -4103,8 +4054,7 @@ select_visual (dpyinfo) Open a new connection if necessary. */ struct x_display_info * -x_display_info_for_name (name) - Lisp_Object name; +x_display_info_for_name (Lisp_Object name) { Lisp_Object names; struct x_display_info *dpyinfo; @@ -4151,8 +4101,7 @@ DISPLAY is the name of the display to connect to. Optional second arg XRM-STRING is a string of resources in xrdb format. If the optional third arg MUST-SUCCEED is non-nil, terminate Emacs if we can't open the connection. */) - (display, xrm_string, must_succeed) - Lisp_Object display, xrm_string, must_succeed; + (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed) { unsigned char *xrm_option; struct x_display_info *dpyinfo; @@ -4203,8 +4152,7 @@ DEFUN ("x-close-connection", Fx_close_connection, For TERMINAL, specify a terminal object, a frame or a display name (a string). If TERMINAL is nil, that stands for the selected frame's terminal. */) - (terminal) - Lisp_Object terminal; + (Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -4218,7 +4166,7 @@ terminal. */) DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, doc: /* Return the list of display names that Emacs has connections to. */) - () + (void) { Lisp_Object tail, result; @@ -4238,8 +4186,7 @@ easier. The optional second argument TERMINAL specifies which display to act on. TERMINAL should be a terminal object, a frame or a display name (a string). If TERMINAL is omitted or nil, that stands for the selected frame's display. */) - (on, terminal) - Lisp_Object terminal, on; + (Lisp_Object on, Lisp_Object terminal) { struct x_display_info *dpyinfo = check_x_display_info (terminal); @@ -4251,8 +4198,7 @@ If TERMINAL is omitted or nil, that stands for the selected frame's display. */ /* Wait for responses to all X commands issued so far for frame F. */ void -x_sync (f) - FRAME_PTR f; +x_sync (FRAME_PTR f) { BLOCK_INPUT; XSync (FRAME_X_DISPLAY (f), False); @@ -4283,8 +4229,7 @@ If OUTER_P is non-nil, the property is changed for the outer X window of FRAME. Default is to change on the edit X window. Value is VALUE. */) - (prop, value, frame, type, format, outer_p) - Lisp_Object prop, value, frame, type, format, outer_p; + (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) { struct frame *f = check_x_frame (frame); Atom prop_atom; @@ -4362,8 +4307,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property, Sx_delete_window_property, 1, 2, 0, doc: /* Remove window property PROP from X window of FRAME. FRAME nil or omitted means use the selected frame. Value is PROP. */) - (prop, frame) - Lisp_Object prop, frame; + (Lisp_Object prop, Lisp_Object frame) { struct frame *f = check_x_frame (frame); Atom prop_atom; @@ -4394,8 +4338,7 @@ If VECTOR_RET_P is non-nil, don't return a string but a vector of values. Value is nil if FRAME hasn't a property with name PROP or if PROP has no value of TYPE. */) - (prop, frame, type, source, delete_p, vector_ret_p) - Lisp_Object prop, frame, type, source, delete_p, vector_ret_p; + (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) { struct frame *f = check_x_frame (frame); Atom prop_atom; @@ -4463,7 +4406,7 @@ no value of TYPE. */) elements." This applies even if long is more than 32 bits, the X library converts from 32 bit elements received from the X server to long - and passes the long array to us. Thus, for that case bcopy can not + and passes the long array to us. Thus, for that case memcpy can not be used. We convert to a 32 bit type here, because so much code assume on that. @@ -4514,8 +4457,7 @@ no value of TYPE. */) shown on the frames. */ void -show_hourglass (timer) - struct atimer *timer; +show_hourglass (struct atimer *timer) { /* The timer implementation will cancel this timer automatically after this function has run. Set hourglass_atimer to null @@ -4579,7 +4521,7 @@ show_hourglass (timer) shown. */ void -hide_hourglass () +hide_hourglass (void) { if (hourglass_shown_p) { @@ -4614,10 +4556,10 @@ hide_hourglass () Tool tips ***********************************************************************/ -static Lisp_Object x_create_tip_frame P_ ((struct x_display_info *, - Lisp_Object, Lisp_Object)); -static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object, - Lisp_Object, int, int, int *, int *)); +static Lisp_Object x_create_tip_frame (struct x_display_info *, + Lisp_Object, Lisp_Object); +static void compute_tip_xy (struct frame *, Lisp_Object, Lisp_Object, + Lisp_Object, int, int, int *, int *); /* The frame of a currently visible tooltip. */ @@ -4640,8 +4582,7 @@ Lisp_Object Vx_max_tooltip_size; static Lisp_Object -unwind_create_tip_frame (frame) - Lisp_Object frame; +unwind_create_tip_frame (Lisp_Object frame) { Lisp_Object deleted; @@ -4666,9 +4607,9 @@ unwind_create_tip_frame (frame) when this happens. */ static Lisp_Object -x_create_tip_frame (dpyinfo, parms, text) - struct x_display_info *dpyinfo; - Lisp_Object parms, text; +x_create_tip_frame (struct x_display_info *dpyinfo, + Lisp_Object parms, + Lisp_Object text) { struct frame *f; Lisp_Object frame, tem; @@ -4723,7 +4664,7 @@ x_create_tip_frame (dpyinfo, parms, text) counts etc. */ f->output_method = output_x_window; f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); - bzero (f->output_data.x, sizeof (struct x_output)); + memset (f->output_data.x, 0, sizeof (struct x_output)); f->output_data.x->icon_bitmap = -1; FRAME_FONTSET (f) = -1; f->output_data.x->scroll_bar_foreground_pixel = -1; @@ -4808,7 +4749,7 @@ x_create_tip_frame (dpyinfo, parms, text) needed to determine window geometry. */ x_default_font_parameter (f, parms); - x_default_parameter (f, parms, Qborder_width, make_number (2), + x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER); /* This defaults to 2 in order to match xterm. We recognize either @@ -4982,11 +4923,7 @@ x_create_tip_frame (dpyinfo, parms, text) the display in *ROOT_X, and *ROOT_Y. */ static void -compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) - struct frame *f; - Lisp_Object parms, dx, dy; - int width, height; - int *root_x, *root_y; +compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, int width, int height, int *root_x, int *root_y) { Lisp_Object left, top; int win_x, win_y; @@ -5063,8 +5000,7 @@ DY added (default is -10). A tooltip's maximum size is specified by `x-max-tooltip-size'. Text larger than the specified size is clipped. */) - (string, frame, parms, timeout, dx, dy) - Lisp_Object string, frame, parms, timeout, dx, dy; + (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy) { struct frame *f; struct window *w; @@ -5100,6 +5036,27 @@ Text larger than the specified size is clipped. */) else CHECK_NUMBER (dy); +#ifdef USE_GTK + if (x_gtk_use_system_tooltips) + { + int ok; + + /* Hide a previous tip, if any. */ + Fx_hide_tip (); + + BLOCK_INPUT; + if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0) + { + compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); + xg_show_tooltip (f, root_x, root_y); + /* This is used in Fx_hide_tip. */ + XSETFRAME (tip_frame, f); + } + UNBLOCK_INPUT; + if (ok) goto start_timer; + } +#endif /* USE_GTK */ + if (NILP (last_show_tip_args)) last_show_tip_args = Fmake_vector (make_number (3), Qnil); @@ -5188,7 +5145,7 @@ Text larger than the specified size is clipped. */) clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos, 0); + try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); /* Compute width and height of the tooltip. */ width = height = 0; @@ -5205,15 +5162,15 @@ Text larger than the specified size is clipped. */) /* Let the row go over the full width of the frame. */ row->full_width_p = 1; + row_width = row->pixel_width; /* There's a glyph at the end of rows that is used to place the cursor there. Don't include the width of this glyph. */ if (row->used[TEXT_AREA]) { last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; - row_width = row->pixel_width - last->pixel_width; + if (INTEGERP (last->object)) + row_width -= last->pixel_width; } - else - row_width = row->pixel_width; height += row->height; width = max (width, row_width); @@ -5255,11 +5212,12 @@ Text larger than the specified size is clipped. */) DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, doc: /* Hide the current tooltip window, if there is any. Value is t if tooltip was open, nil otherwise. */) - () + (void) { int count; Lisp_Object deleted, frame, timer; struct gcpro gcpro1, gcpro2; + struct frame *f; /* Return quickly if nothing to do. */ if (NILP (tip_timer) && NILP (tip_frame)) @@ -5277,6 +5235,14 @@ Value is t if tooltip was open, nil otherwise. */) if (!NILP (timer)) call1 (Qcancel_timer, timer); +#ifdef USE_GTK + /* When using system tooltip, tip_frame is the Emacs frame on which + the tip is shown. */ + f = XFRAME (frame); + if (FRAME_LIVE_P (f) && xg_hide_tooltip (f)) + frame = Qnil; +#endif + if (FRAMEP (frame)) { delete_frame (frame, Qnil); @@ -5287,9 +5253,9 @@ Value is t if tooltip was open, nil otherwise. */) redisplay procedure is not called when a tip frame over menu items is unmapped. Redisplay the menu manually... */ { - struct frame *f = SELECTED_FRAME (); - Widget w = f->output_data.x->menubar_widget; - extern void xlwmenu_redisplay P_ ((Widget)); + Widget w; + f = SELECTED_FRAME (); + w = f->output_data.x->menubar_widget; if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) && w != NULL) @@ -5316,12 +5282,9 @@ DEFUN ("x-uses-old-gtk-dialog", Fx_uses_old_gtk_dialog, Sx_uses_old_gtk_dialog, 0, 0, 0, doc: /* Return t if the old Gtk+ file selection dialog is used. */) - () + (void) { #ifdef USE_GTK - extern int use_dialog_box; - extern int use_file_dialog; - if (use_dialog_box && use_file_dialog && have_menus_p () @@ -5383,8 +5346,7 @@ DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file selection box, if specified. If MUSTMATCH is non-nil, the returned file or directory must exist. ONLY-DIR-P is ignored." */) - (prompt, dir, default_filename, mustmatch, only_dir_p) - Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; + (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { int result; struct frame *f = SELECTED_FRAME (); @@ -5393,7 +5355,6 @@ or directory must exist. ONLY-DIR-P is ignored." */) Widget dialog, text, help; Arg al[10]; int ac = 0; - extern XtAppContext Xt_app_con; XmString dir_xmstring, pattern_xmstring; int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; @@ -5542,8 +5503,7 @@ or directory must exist. ONLY-DIR-P is ignored." */) #ifdef USE_GTK static Lisp_Object -clean_up_dialog (arg) - Lisp_Object arg; +clean_up_dialog (Lisp_Object arg) { x_menu_set_in_use (0); @@ -5556,8 +5516,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file selection box, if specified. If MUSTMATCH is non-nil, the returned file or directory must exist. If ONLY-DIR-P is non-nil, the user can only select directories. */) - (prompt, dir, default_filename, mustmatch, only_dir_p) - Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; + (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) { FRAME_PTR f = SELECTED_FRAME (); char *fn; @@ -5618,8 +5577,7 @@ DEFUN ("x-select-font", Fx_select_font, Sx_select_font, 0, 2, 0, Return a GTK-style font string corresponding to the selection. If FRAME is omitted or nil, it defaults to the selected frame. */) - (frame, ignored) - Lisp_Object frame, ignored; + (Lisp_Object frame, Lisp_Object ignored) { FRAME_PTR f = check_x_frame (frame); char *name; @@ -5707,8 +5665,7 @@ FRAME nil means use the selected frame. Value is t if we know that both keys are present, and are mapped to the usual X keysyms. Value is `lambda' if we cannot determine if both keys are present and mapped to the usual X keysyms. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { #ifdef HAVE_XKBGETKEYBOARD XkbDescPtr kb; @@ -5769,9 +5726,9 @@ present and mapped to the usual X keysyms. */) /* The XKB symbolic key names can be seen most easily in the PS file generated by `xkbprint -label name $DISPLAY'. */ - if (bcmp ("DELE", kb->names->keys[i].name, 4) == 0) + if (memcmp ("DELE", kb->names->keys[i].name, 4) == 0) delete_keycode = i; - else if (bcmp ("BKSP", kb->names->keys[i].name, 4) == 0) + else if (memcmp ("BKSP", kb->names->keys[i].name, 4) == 0) backspace_keycode = i; } @@ -5836,10 +5793,11 @@ frame_parm_handler x_frame_parm_handlers[] = x_set_font_backend, x_set_alpha, x_set_sticky, + x_set_tool_bar_position, }; void -syms_of_xfns () +syms_of_xfns (void) { /* This is zero if not using X windows. */ x_in_use = 0; @@ -5966,6 +5924,12 @@ The default is to just show an arrow and pressing on that arrow shows the tool bar buttons. */); x_gtk_whole_detached_tool_bar = 0; + DEFVAR_BOOL ("x-gtk-use-system-tooltips", &x_gtk_use_system_tooltips, + doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used. +Otherwise use Emacs own tooltip implementation. +When using Gtk+ tooltips, the tooltip face is not used. */); + x_gtk_use_system_tooltips = 1; + Fprovide (intern_c_string ("x"), Qnil); #ifdef USE_X_TOOLKIT @@ -5986,6 +5950,7 @@ the tool bar buttons. */); accepts --with-x-toolkit=gtk. */ Fprovide (intern_c_string ("x-toolkit"), Qnil); Fprovide (intern_c_string ("gtk"), Qnil); + Fprovide (intern_c_string ("move-toolbar"), Qnil); DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string, doc: /* Version info for GTK+. */); diff --git a/src/xfont.c b/src/xfont.c index a676cd29c82..d4c6af17c49 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdio.h> -#include <stdlib.h> #include <setjmp.h> #include <X11/Xlib.h> @@ -47,17 +46,15 @@ struct xfont_info }; /* Prototypes of support functions. */ -extern void x_clear_errors P_ ((Display *)); +extern void x_clear_errors (Display *); -static XCharStruct *xfont_get_pcm P_ ((XFontStruct *, XChar2b *)); +static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B is not contained in the font. */ static XCharStruct * -xfont_get_pcm (xfont, char2b) - XFontStruct *xfont; - XChar2b *char2b; +xfont_get_pcm (XFontStruct *xfont, XChar2b *char2b) { /* The result metric information. */ XCharStruct *pcm = NULL; @@ -119,19 +116,19 @@ xfont_get_pcm (xfont, char2b) ? NULL : pcm); } -static Lisp_Object xfont_get_cache P_ ((FRAME_PTR)); -static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object xfont_list_family P_ ((Lisp_Object)); -static Lisp_Object xfont_open P_ ((FRAME_PTR, Lisp_Object, int)); -static void xfont_close P_ ((FRAME_PTR, struct font *)); -static int xfont_prepare_face P_ ((FRAME_PTR, struct face *)); -static int xfont_has_char P_ ((Lisp_Object, int)); -static unsigned xfont_encode_char P_ ((struct font *, int)); -static int xfont_text_extents P_ ((struct font *, unsigned *, int, - struct font_metrics *)); -static int xfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); -static int xfont_check P_ ((FRAME_PTR, struct font *)); +static Lisp_Object xfont_get_cache (FRAME_PTR); +static Lisp_Object xfont_list (Lisp_Object, Lisp_Object); +static Lisp_Object xfont_match (Lisp_Object, Lisp_Object); +static Lisp_Object xfont_list_family (Lisp_Object); +static Lisp_Object xfont_open (FRAME_PTR, Lisp_Object, int); +static void xfont_close (FRAME_PTR, struct font *); +static int xfont_prepare_face (FRAME_PTR, struct face *); +static int xfont_has_char (Lisp_Object, int); +static unsigned xfont_encode_char (struct font *, int); +static int xfont_text_extents (struct font *, unsigned *, int, + struct font_metrics *); +static int xfont_draw (struct glyph_string *, int, int, int, int, int); +static int xfont_check (FRAME_PTR, struct font *); struct font_driver xfont_driver = { @@ -156,19 +153,14 @@ struct font_driver xfont_driver = NULL, /* filter_properties */ }; -extern Lisp_Object QCname; - static Lisp_Object -xfont_get_cache (f) - FRAME_PTR f; +xfont_get_cache (FRAME_PTR f) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); return (dpyinfo->name_list_element); } -extern Lisp_Object Vface_alternative_font_registry_alist; - static int compare_font_names (const void *name1, const void *name2) { @@ -292,8 +284,6 @@ static Lisp_Object xfont_scripts_cache; /* Re-usable vector to store characteristic font properites. */ static Lisp_Object xfont_scratch_props; -extern Lisp_Object Qlatin; - /* Return a list of scripts supported by the font of FONTNAME whose characteristic properties are in PROPS and whose encoding charset is ENCODING. A caller must call BLOCK_INPUT in advance. */ @@ -342,10 +332,8 @@ xfont_supported_scripts (Display *display, char *fontname, Lisp_Object props, return scripts; } -extern Lisp_Object Vscalable_fonts_allowed; - static Lisp_Object -xfont_list_pattern (Display *display, char *pattern, +xfont_list_pattern (Display *display, const char *pattern, Lisp_Object registry, Lisp_Object script) { Lisp_Object list = Qnil; @@ -497,8 +485,7 @@ xfont_list_pattern (Display *display, char *pattern, } static Lisp_Object -xfont_list (frame, spec) - Lisp_Object frame, spec; +xfont_list (Lisp_Object frame, Lisp_Object spec) { FRAME_PTR f = XFRAME (frame); Display *display = FRAME_X_DISPLAY_INFO (f)->display; @@ -566,7 +553,7 @@ xfont_list (frame, spec) val = assq_no_quit (QCname, AREF (spec, FONT_EXTRA_INDEX)); if (CONSP (val) && STRINGP (XCDR (val)) && SBYTES (XCDR (val)) < 512) { - bcopy (SDATA (XCDR (val)), name, SBYTES (XCDR (val)) + 1); + memcpy (name, SDATA (XCDR (val)), SBYTES (XCDR (val)) + 1); if (xfont_encode_coding_xlfd (name) < 0) return Qnil; list = xfont_list_pattern (display, name, registry, script); @@ -577,8 +564,7 @@ xfont_list (frame, spec) } static Lisp_Object -xfont_match (frame, spec) - Lisp_Object frame, spec; +xfont_match (Lisp_Object frame, Lisp_Object spec) { FRAME_PTR f = XFRAME (frame); Display *display = FRAME_X_DISPLAY_INFO (f)->display; @@ -595,7 +581,7 @@ xfont_match (frame, spec) return Qnil; } else if (SBYTES (XCDR (val)) < 512) - bcopy (SDATA (XCDR (val)), name, SBYTES (XCDR (val)) + 1); + memcpy (name, SDATA (XCDR (val)), SBYTES (XCDR (val)) + 1); else return Qnil; if (xfont_encode_coding_xlfd (name) < 0) @@ -636,8 +622,7 @@ xfont_match (frame, spec) } static Lisp_Object -xfont_list_family (frame) - Lisp_Object frame; +xfont_list_family (Lisp_Object frame) { FRAME_PTR f = XFRAME (frame); Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -675,7 +660,7 @@ xfont_list_family (frame) if (! *p1 || p1 == p0) continue; if (last_len == p1 - p0 - && bcmp (last_family, p0, last_len) == 0) + && memcmp (last_family, p0, last_len) == 0) continue; last_len = p1 - p0; last_family = p0; @@ -693,13 +678,8 @@ xfont_list_family (frame) return list; } -extern Lisp_Object QCavgwidth; - static Lisp_Object -xfont_open (f, entity, pixel_size) - FRAME_PTR f; - Lisp_Object entity; - int pixel_size; +xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) { Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Display *display = dpyinfo->display; @@ -911,9 +891,7 @@ xfont_open (f, entity, pixel_size) } static void -xfont_close (f, font) - FRAME_PTR f; - struct font *font; +xfont_close (FRAME_PTR f, struct font *font) { BLOCK_INPUT; XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont); @@ -921,9 +899,7 @@ xfont_close (f, font) } static int -xfont_prepare_face (f, face) - FRAME_PTR f; - struct face *face; +xfont_prepare_face (FRAME_PTR f, struct face *face) { BLOCK_INPUT; XSetFont (FRAME_X_DISPLAY (f), face->gc, @@ -934,9 +910,7 @@ xfont_prepare_face (f, face) } static int -xfont_has_char (font, c) - Lisp_Object font; - int c; +xfont_has_char (Lisp_Object font, int c) { Lisp_Object registry = AREF (font, FONT_REGISTRY_INDEX); struct charset *encoding; @@ -965,9 +939,7 @@ xfont_has_char (font, c) } static unsigned -xfont_encode_char (font, c) - struct font *font; - int c; +xfont_encode_char (struct font *font, int c) { XFontStruct *xfont = ((struct xfont_info *) font)->xfont; struct charset *charset; @@ -990,18 +962,14 @@ xfont_encode_char (font, c) } static int -xfont_text_extents (font, code, nglyphs, metrics) - struct font *font; - unsigned *code; - int nglyphs; - struct font_metrics *metrics; +xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) { XFontStruct *xfont = ((struct xfont_info *) font)->xfont; int width = 0; int i, first, x; if (metrics) - bzero (metrics, sizeof (struct font_metrics)); + memset (metrics, 0, sizeof (struct font_metrics)); for (i = 0, x = 0, first = 1; i < nglyphs; i++) { XChar2b char2b; @@ -1046,9 +1014,7 @@ xfont_text_extents (font, code, nglyphs, metrics) } static int -xfont_draw (s, from, to, x, y, with_background) - struct glyph_string *s; - int from, to, x, y, with_background; +xfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) { XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; int len = to - from; @@ -1123,9 +1089,7 @@ xfont_draw (s, from, to, x, y, with_background) } static int -xfont_check (f, font) - FRAME_PTR f; - struct font *font; +xfont_check (FRAME_PTR f, struct font *font) { struct xfont_info *xfont = (struct xfont_info *) font; @@ -1134,7 +1098,7 @@ xfont_check (f, font) void -syms_of_xfont () +syms_of_xfont (void) { staticpro (&xfont_scripts_cache); { /* Here we rely on the fact that syms_of_xfont (via syms_of_font) diff --git a/src/xftfont.c b/src/xftfont.c index 197cc9c1f5b..dc82c28b215 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -70,9 +70,9 @@ struct xftface_info XftColor xft_bg; /* color for face->background */ }; -static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc, - struct xftface_info *, - XftColor *fg, XftColor *bg)); +static void xftfont_get_colors (FRAME_PTR, struct face *, GC gc, + struct xftface_info *, + XftColor *fg, XftColor *bg); /* Setup foreground and background colors of GC into FG and BG. If @@ -80,12 +80,7 @@ static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc, may be NULL. */ static void -xftfont_get_colors (f, face, gc, xftface_info, fg, bg) - FRAME_PTR f; - struct face *face; - GC gc; - struct xftface_info *xftface_info; - XftColor *fg, *bg; +xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *xftface_info, XftColor *fg, XftColor *bg) { if (xftface_info && face->gc == gc) { @@ -141,25 +136,23 @@ xftfont_get_colors (f, face, gc, xftface_info, fg, bg) } -static Lisp_Object xftfont_list P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object xftfont_match P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object xftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); -static void xftfont_close P_ ((FRAME_PTR, struct font *)); -static int xftfont_prepare_face P_ ((FRAME_PTR, struct face *)); -static void xftfont_done_face P_ ((FRAME_PTR, struct face *)); -static int xftfont_has_char P_ ((Lisp_Object, int)); -static unsigned xftfont_encode_char P_ ((struct font *, int)); -static int xftfont_text_extents P_ ((struct font *, unsigned *, int, - struct font_metrics *)); -static int xftfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); -static int xftfont_end_for_frame P_ ((FRAME_PTR f)); +static Lisp_Object xftfont_list (Lisp_Object, Lisp_Object); +static Lisp_Object xftfont_match (Lisp_Object, Lisp_Object); +static Lisp_Object xftfont_open (FRAME_PTR, Lisp_Object, int); +static void xftfont_close (FRAME_PTR, struct font *); +static int xftfont_prepare_face (FRAME_PTR, struct face *); +static void xftfont_done_face (FRAME_PTR, struct face *); +static int xftfont_has_char (Lisp_Object, int); +static unsigned xftfont_encode_char (struct font *, int); +static int xftfont_text_extents (struct font *, unsigned *, int, + struct font_metrics *); +static int xftfont_draw (struct glyph_string *, int, int, int, int, int); +static int xftfont_end_for_frame (FRAME_PTR f); struct font_driver xftfont_driver; static Lisp_Object -xftfont_list (frame, spec) - Lisp_Object frame; - Lisp_Object spec; +xftfont_list (Lisp_Object frame, Lisp_Object spec) { Lisp_Object list = ftfont_driver.list (frame, spec), tail; @@ -169,9 +162,7 @@ xftfont_list (frame, spec) } static Lisp_Object -xftfont_match (frame, spec) - Lisp_Object frame; - Lisp_Object spec; +xftfont_match (Lisp_Object frame, Lisp_Object spec) { Lisp_Object entity = ftfont_driver.match (frame, spec); @@ -180,15 +171,10 @@ xftfont_match (frame, spec) return entity; } -extern Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object)); -extern FcCharSet *ftfont_get_fc_charset P_ ((Lisp_Object)); -extern Lisp_Object QCantialias; - static FcChar8 ascii_printable[95]; static void -xftfont_fix_match (pat, match) - FcPattern *pat, *match; +xftfont_fix_match (FcPattern *pat, FcPattern *match) { /* These values are not used for matching (except antialias), but for rendering, so make sure they are carried over to the match. @@ -238,9 +224,7 @@ xftfont_fix_match (pat, match) } static void -xftfont_add_rendering_parameters (pat, entity) - FcPattern *pat; - Lisp_Object entity; +xftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity) { Lisp_Object tail; int ival; @@ -288,10 +272,7 @@ xftfont_add_rendering_parameters (pat, entity) } static Lisp_Object -xftfont_open (f, entity, pixel_size) - FRAME_PTR f; - Lisp_Object entity; - int pixel_size; +xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) { FcResult result; Display *display = FRAME_X_DISPLAY (f); @@ -510,9 +491,7 @@ xftfont_open (f, entity, pixel_size) } static void -xftfont_close (f, font) - FRAME_PTR f; - struct font *font; +xftfont_close (FRAME_PTR f, struct font *font) { struct xftfont_info *xftfont_info = (struct xftfont_info *) font; @@ -527,9 +506,7 @@ xftfont_close (f, font) } static int -xftfont_prepare_face (f, face) - FRAME_PTR f; - struct face *face; +xftfont_prepare_face (FRAME_PTR f, struct face *face) { struct xftface_info *xftface_info; @@ -552,9 +529,7 @@ xftfont_prepare_face (f, face) } static void -xftfont_done_face (f, face) - FRAME_PTR f; - struct face *face; +xftfont_done_face (FRAME_PTR f, struct face *face) { struct xftface_info *xftface_info; @@ -573,12 +548,8 @@ xftfont_done_face (f, face) } } -extern Lisp_Object Qja, Qko; - static int -xftfont_has_char (font, c) - Lisp_Object font; - int c; +xftfont_has_char (Lisp_Object font, int c) { struct xftfont_info *xftfont_info; struct charset *cs = NULL; @@ -600,9 +571,7 @@ xftfont_has_char (font, c) } static unsigned -xftfont_encode_char (font, c) - struct font *font; - int c; +xftfont_encode_char (struct font *font, int c) { struct xftfont_info *xftfont_info = (struct xftfont_info *) font; unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont, @@ -612,11 +581,7 @@ xftfont_encode_char (font, c) } static int -xftfont_text_extents (font, code, nglyphs, metrics) - struct font *font; - unsigned *code; - int nglyphs; - struct font_metrics *metrics; +xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics) { struct xftfont_info *xftfont_info = (struct xftfont_info *) font; XGlyphInfo extents; @@ -637,8 +602,7 @@ xftfont_text_extents (font, code, nglyphs, metrics) } static XftDraw * -xftfont_get_xft_draw (f) - FRAME_PTR f; +xftfont_get_xft_draw (FRAME_PTR f) { XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver); @@ -658,9 +622,7 @@ xftfont_get_xft_draw (f) } static int -xftfont_draw (s, from, to, x, y, with_background) - struct glyph_string *s; - int from, to, x, y, with_background; +xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background) { FRAME_PTR f = s->f; struct face *face = s->face; @@ -703,8 +665,7 @@ xftfont_draw (s, from, to, x, y, with_background) } static int -xftfont_end_for_frame (f) - FRAME_PTR f; +xftfont_end_for_frame (FRAME_PTR f) { XftDraw *xft_draw; @@ -724,11 +685,7 @@ xftfont_end_for_frame (f) } static int -xftfont_cached_font_ok (f, font_object, entity) - struct frame *f; - Lisp_Object font_object; - Lisp_Object entity; - +xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity) { struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object); FcPattern *oldpat = info->xftfont->pattern; @@ -771,7 +728,7 @@ xftfont_cached_font_ok (f, font_object, entity) } void -syms_of_xftfont () +syms_of_xftfont (void) { DEFSYM (Qxft, "xft"); DEFSYM (QChinting, ":hinting"); diff --git a/src/xgselect.c b/src/xgselect.c index a06713458a0..487f9882b81 100644 --- a/src/xgselect.c +++ b/src/xgselect.c @@ -17,7 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" +#include <config.h> #if defined (USE_GTK) || defined (HAVE_GCONF) #include <glib.h> @@ -29,12 +29,8 @@ static GPollFD *gfds; static int gfds_size; int -xg_select (max_fds, rfds, wfds, efds, timeout) - int max_fds; - SELECT_TYPE *rfds; - SELECT_TYPE *wfds; - SELECT_TYPE *efds; - EMACS_TIME *timeout; +xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, + EMACS_TIME *timeout) { SELECT_TYPE all_rfds, all_wfds; EMACS_TIME tmo, *tmop = timeout; @@ -153,7 +149,7 @@ xg_select (max_fds, rfds, wfds, efds, timeout) #endif /* defined (USE_GTK) || defined (HAVE_GCONF) */ void -xgselect_initialize () +xgselect_initialize (void) { #if defined (USE_GTK) || defined (HAVE_GCONF) gfds_size = 128; diff --git a/src/xgselect.h b/src/xgselect.h index bae084f0d5c..f120d8866cf 100644 --- a/src/xgselect.h +++ b/src/xgselect.h @@ -24,13 +24,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "systime.h" #include "sysselect.h" -extern int xg_select P_ ((int max_fds, - SELECT_TYPE *rfds, - SELECT_TYPE *wfds, - SELECT_TYPE *efds, - EMACS_TIME *timeout)); +extern int xg_select (int max_fds, + SELECT_TYPE *rfds, + SELECT_TYPE *wfds, + SELECT_TYPE *efds, + EMACS_TIME *timeout); -extern void xgselect_initialize P_ ((void)); +extern void xgselect_initialize (void); #endif /* XGSELECT_H */ diff --git a/src/xmenu.c b/src/xmenu.c index 64e55b7413c..68b442388a5 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -81,13 +81,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <X11/StringDefs.h> #include <X11/Shell.h> #ifdef USE_LUCID +#include "xsettings.h" +#include "../lwlib/xlwmenu.h" #ifdef HAVE_XAW3D #include <X11/Xaw3d/Paned.h> #else /* !HAVE_XAW3D */ #include <X11/Xaw/Paned.h> #endif /* HAVE_XAW3D */ #endif /* USE_LUCID */ -#include "../lwlib/lwlib.h" #else /* not USE_X_TOOLKIT */ #ifndef USE_GTK #include "../oldXMenu/XMenu.h" @@ -108,34 +109,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ Lisp_Object Qdebug_on_next_call; -extern Lisp_Object Qmenu_bar; - -extern Lisp_Object QCtoggle, QCradio; - -extern Lisp_Object Voverriding_local_map; -extern Lisp_Object Voverriding_local_map_menu_flag; - -extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; - -extern Lisp_Object Qmenu_bar_update_hook; - -#ifdef USE_X_TOOLKIT -extern void set_frame_menubar P_ ((FRAME_PTR, int, int)); -extern XtAppContext Xt_app_con; - -static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object, - char **)); -static void popup_get_selection P_ ((XEvent *, struct x_display_info *, - LWLIB_ID, int)); -#endif /* USE_X_TOOLKIT */ - -#ifdef USE_GTK -extern void set_frame_menubar P_ ((FRAME_PTR, int, int)); -static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object, - char **)); +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) +static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object, + const char **); #endif -static int update_frame_menubar P_ ((struct frame *)); +static int update_frame_menubar (struct frame *); /* Flag which when set indicates a dialog or menu has been posted by Xt on behalf of one of the widget sets. */ @@ -143,28 +122,13 @@ static int popup_activated_flag; static int next_menubar_widget_id; -/* For NS and NTGUI, these prototypes are defined in keyboard.h. */ -#if defined (USE_X_TOOLKIT) || defined (USE_GTK) -extern widget_value *xmalloc_widget_value P_ ((void)); -extern widget_value *digest_single_submenu P_ ((int, int, int)); -#endif - -/* This is set nonzero after the user activates the menu bar, and set - to zero again after the menu bars are redisplayed by prepare_menu_bar. - While it is nonzero, all calls to set_frame_menubar go deep. - - I don't understand why this is needed, but it does seem to be - needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */ - -int pending_menu_activation; #ifdef USE_X_TOOLKIT /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ static struct frame * -menubar_id_to_frame (id) - LWLIB_ID id; +menubar_id_to_frame (LWLIB_ID id) { Lisp_Object tail, frame; FRAME_PTR f; @@ -194,10 +158,7 @@ menubar_id_to_frame (id) the scroll bar or the edit window. Fx_popup_menu needs to be sure it is the edit window. */ void -mouse_position_for_popup (f, x, y) - FRAME_PTR f; - int *x; - int *y; +mouse_position_for_popup (FRAME_PTR f, int *x, int *y) { Window root, dummy_window; int dummy; @@ -261,8 +222,7 @@ otherwise it is "Question". If the user gets rid of the dialog box without making a valid choice, for instance using the window manager, then this produces a quit and `x-popup-dialog' does not return. */) - (position, contents, header) - Lisp_Object position, contents, header; + (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { FRAME_PTR f = NULL; Lisp_Object window; @@ -352,7 +312,7 @@ for instance using the window manager, then this produces a quit and #else { Lisp_Object title; - char *error_name; + const char *error_name; Lisp_Object selection; int specpdl_count = SPECPDL_INDEX (); @@ -389,8 +349,7 @@ for instance using the window manager, then this produces a quit and /* Set menu_items_inuse so no other popup menu or dialog is created. */ void -x_menu_set_in_use (in_use) - int in_use; +x_menu_set_in_use (int in_use) { menu_items_inuse = in_use ? Qt : Qnil; popup_activated_flag = in_use; @@ -459,11 +418,7 @@ x_menu_wait_for_event (void *data) with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ static void -popup_get_selection (initial_event, dpyinfo, id, do_timers) - XEvent *initial_event; - struct x_display_info *dpyinfo; - LWLIB_ID id; - int do_timers; +popup_get_selection (XEvent *initial_event, struct x_display_info *dpyinfo, LWLIB_ID id, int do_timers) { XEvent event; @@ -520,8 +475,7 @@ arrow keys, select a menu entry with the return key or cancel with the escape key. If FRAME has no menu bar this function does nothing. If FRAME is nil or not given, use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { XEvent ev; FRAME_PTR f = check_x_frame (frame); @@ -599,8 +553,7 @@ arrow keys, select a menu entry with the return key or cancel with the escape key. If FRAME has no menu bar this function does nothing. If FRAME is nil or not given, use the selected frame. */) - (frame) - Lisp_Object frame; + (Lisp_Object frame) { GtkWidget *menubar; FRAME_PTR f; @@ -636,9 +589,7 @@ If FRAME is nil or not given, use the selected frame. */) Used for popup menus and dialogs. */ static void -popup_widget_loop (do_timers, widget) - int do_timers; - GtkWidget *widget; +popup_widget_loop (int do_timers, GtkWidget *widget) { ++popup_activated_flag; @@ -666,8 +617,7 @@ popup_widget_loop (do_timers, widget) execute Lisp code. */ void -x_activate_menubar (f) - FRAME_PTR f; +x_activate_menubar (FRAME_PTR f) { if (! FRAME_X_P (f)) abort (); @@ -683,18 +633,14 @@ x_activate_menubar (f) set_frame_menubar (f, 0, 1); BLOCK_INPUT; + popup_activated_flag = 1; #ifdef USE_GTK XPutBackEvent (f->output_data.x->display_info->display, f->output_data.x->saved_menu_event); - popup_activated_flag = 1; #else XtDispatchEvent (f->output_data.x->saved_menu_event); #endif UNBLOCK_INPUT; -#ifdef USE_MOTIF - if (f->output_data.x->saved_menu_event->type == ButtonRelease) - pending_menu_activation = 1; -#endif /* Ignore this if we get it a second time. */ f->output_data.x->saved_menu_event->type = 0; @@ -705,10 +651,7 @@ x_activate_menubar (f) #ifndef USE_GTK static void -popup_activate_callback (widget, id, client_data) - Widget widget; - LWLIB_ID id; - XtPointer client_data; +popup_activate_callback (Widget widget, LWLIB_ID id, XtPointer client_data) { popup_activated_flag = 1; #ifdef USE_X_TOOLKIT @@ -722,18 +665,13 @@ popup_activate_callback (widget, id, client_data) #ifdef USE_GTK static void -popup_deactivate_callback (widget, client_data) - GtkWidget *widget; - gpointer client_data; +popup_deactivate_callback (GtkWidget *widget, gpointer client_data) { popup_activated_flag = 0; } #else static void -popup_deactivate_callback (widget, id, client_data) - Widget widget; - LWLIB_ID id; - XtPointer client_data; +popup_deactivate_callback (Widget widget, LWLIB_ID id, XtPointer client_data) { popup_activated_flag = 0; } @@ -744,10 +682,7 @@ popup_deactivate_callback (widget, id, client_data) for that widget. F is the frame if known, or NULL if not known. */ static void -show_help_event (f, widget, help) - FRAME_PTR f; - xt_or_gtk_widget widget; - Lisp_Object help; +show_help_event (FRAME_PTR f, xt_or_gtk_widget widget, Lisp_Object help) { Lisp_Object frame; @@ -785,9 +720,7 @@ show_help_event (f, widget, help) #ifdef USE_GTK void -menu_highlight_callback (widget, call_data) - GtkWidget *widget; - gpointer call_data; +menu_highlight_callback (GtkWidget *widget, gpointer call_data) { xg_menu_item_cb_data *cb_data; Lisp_Object help; @@ -806,10 +739,7 @@ menu_highlight_callback (widget, call_data) } #else void -menu_highlight_callback (widget, id, call_data) - Widget widget; - LWLIB_ID id; - void *call_data; +menu_highlight_callback (Widget widget, LWLIB_ID id, void *call_data) { struct frame *f; Lisp_Object help; @@ -837,9 +767,7 @@ static int xg_crazy_callback_abort; Figure out what the user chose and put the appropriate events into the keyboard buffer. */ static void -menubar_selection_callback (widget, client_data) - GtkWidget *widget; - gpointer client_data; +menubar_selection_callback (GtkWidget *widget, gpointer client_data) { xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data; @@ -882,10 +810,7 @@ menubar_selection_callback (widget, client_data) Figure out what the user chose and put the appropriate events into the keyboard buffer. */ static void -menubar_selection_callback (widget, id, client_data) - Widget widget; - LWLIB_ID id; - XtPointer client_data; +menubar_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) { FRAME_PTR f; @@ -901,8 +826,7 @@ menubar_selection_callback (widget, id, client_data) changed. Value is non-zero if widgets were updated. */ static int -update_frame_menubar (f) - FRAME_PTR f; +update_frame_menubar (FRAME_PTR f) { #ifdef USE_GTK return xg_update_frame_menubar (f); @@ -950,15 +874,48 @@ update_frame_menubar (f) return 1; } +#ifdef USE_LUCID +static void +apply_systemfont_to_dialog (Widget w) +{ + const char *fn = xsettings_get_system_normal_font (); + if (fn) + { + XrmDatabase db = XtDatabase (XtDisplay (w)); + if (db) + XrmPutStringResource (&db, "*dialog.faceName", fn); + } +} + +static void +apply_systemfont_to_menu (Widget w) +{ + const char *fn = xsettings_get_system_normal_font (); + int defflt; + + if (!fn) return; + + if (XtIsShell (w)) /* popup menu */ + { + Widget *childs = NULL; + + XtVaGetValues (w, XtNchildren, &childs, NULL); + if (*childs) w = *childs; + } + + /* Only use system font if the default is used for the menu. */ + XtVaGetValues (w, XtNdefaultFace, &defflt, NULL); + if (defflt) + XtVaSetValues (w, XtNfaceName, fn, NULL); +} +#endif + /* Set the contents of the menubar widgets of frame F. The argument FIRST_TIME is currently ignored; it is set the first time this is called, from initialize_frame_menubar. */ void -set_frame_menubar (f, first_time, deep_p) - FRAME_PTR f; - int first_time; - int deep_p; +set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) { xt_or_gtk_widget menubar_widget; #ifdef USE_X_TOOLKIT @@ -985,8 +942,6 @@ set_frame_menubar (f, first_time, deep_p) if (! menubar_widget) deep_p = 1; - else if (pending_menu_activation && !deep_p) - deep_p = 1; /* Make the first call for any given frame always go deep. */ else if (!f->output_data.x->saved_menu_event && !deep_p) { @@ -1047,8 +1002,8 @@ set_frame_menubar (f, first_time, deep_p) /* Save the frame's previous menu bar contents data. */ if (previous_menu_items_used) - bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, - previous_menu_items_used * sizeof (Lisp_Object)); + memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, + previous_menu_items_used * sizeof (Lisp_Object)); /* Fill in menu_items with the current menu bar contents. This can evaluate Lisp code. */ @@ -1262,10 +1217,17 @@ set_frame_menubar (f, first_time, deep_p) /* Make menu pop down on C-g. */ XtOverrideTranslations (menubar_widget, override); +#ifdef USE_LUCID + apply_systemfont_to_menu (menubar_widget); +#endif } { - int menubar_size + int menubar_size; + if (f->output_data.x->menubar_widget) + XtRealizeWidget (f->output_data.x->menubar_widget); + + menubar_size = (f->output_data.x->menubar_widget ? (f->output_data.x->menubar_widget->core.height + f->output_data.x->menubar_widget->core.border_width) @@ -1274,7 +1236,7 @@ set_frame_menubar (f, first_time, deep_p) #if 1 /* Experimentally, we now get the right results for -geometry -0-0 without this. 24 Aug 96, rms. Maybe so, but the menu bar size is missing the pixels so the - WM size hints are off by theses pixel. Jan D, oct 2009. */ + WM size hints are off by these pixels. Jan D, oct 2009. */ #ifdef USE_LUCID if (FRAME_EXTERNAL_MENU_BAR (f)) { @@ -1306,8 +1268,7 @@ set_frame_menubar (f, first_time, deep_p) is visible. */ void -initialize_frame_menubar (f) - FRAME_PTR f; +initialize_frame_menubar (FRAME_PTR f) { /* This function is called before the first chance to redisplay the frame. It has to be, so the frame will have the right size. */ @@ -1322,8 +1283,7 @@ initialize_frame_menubar (f) #ifndef USE_GTK void -free_frame_menubar (f) - FRAME_PTR f; +free_frame_menubar (FRAME_PTR f) { Widget menubar_widget; @@ -1358,15 +1318,15 @@ free_frame_menubar (f) lw_destroy_all_widgets ((LWLIB_ID) f->output_data.x->id); f->output_data.x->menubar_widget = NULL; -#ifdef USE_MOTIF if (f->output_data.x->widget) { +#ifdef USE_MOTIF XtVaGetValues (f->output_data.x->widget, XtNx, &x1, XtNy, &y1, NULL); if (x1 == 0 && y1 == 0) XtVaSetValues (f->output_data.x->widget, XtNx, x0, XtNy, y0, NULL); - } #endif - + x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); + } UNBLOCK_INPUT; } } @@ -1417,12 +1377,7 @@ struct next_popup_x_y Here only X and Y are used. */ static void -menu_position_func (menu, x, y, push_in, user_data) - GtkMenu *menu; - gint *x; - gint *y; - gboolean *push_in; - gpointer user_data; +menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) { struct next_popup_x_y* data = (struct next_popup_x_y*)user_data; GtkRequisition req; @@ -1443,9 +1398,7 @@ menu_position_func (menu, x, y, push_in, user_data) } static void -popup_selection_callback (widget, client_data) - GtkWidget *widget; - gpointer client_data; +popup_selection_callback (GtkWidget *widget, gpointer client_data) { xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data; @@ -1454,8 +1407,7 @@ popup_selection_callback (widget, client_data) } static Lisp_Object -pop_down_menu (arg) - Lisp_Object arg; +pop_down_menu (Lisp_Object arg) { struct Lisp_Save_Value *p = XSAVE_VALUE (arg); @@ -1470,13 +1422,7 @@ pop_down_menu (arg) menu pops down. menu_item_selection will be set to the selection. */ static void -create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) - FRAME_PTR f; - widget_value *first_wv; - int x; - int y; - int for_click; - EMACS_UINT timestamp; +create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, int for_click, EMACS_UINT timestamp) { int i; GtkWidget *menu; @@ -1524,7 +1470,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) record_unwind_protect (pop_down_menu, make_save_value (menu, 0)); - if (GTK_WIDGET_MAPPED (menu)) + if (gtk_widget_get_mapped (menu)) { /* Set this to one. popup_widget_loop increases it by one, so it becomes two. show_help_echo uses this to detect popup menus. */ @@ -1553,10 +1499,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) LWLIB_ID widget_id_tick; static void -popup_selection_callback (widget, id, client_data) - Widget widget; - LWLIB_ID id; - XtPointer client_data; +popup_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) { menu_item_selection = (Lisp_Object *) client_data; } @@ -1565,8 +1508,7 @@ popup_selection_callback (widget, id, client_data) as a Lisp object as (HIGHPART . LOWPART). */ static Lisp_Object -pop_down_menu (arg) - Lisp_Object arg; +pop_down_menu (Lisp_Object arg) { LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) | XINT (XCDR (arg))); @@ -1583,13 +1525,8 @@ pop_down_menu (arg) menu pops down. menu_item_selection will be set to the selection. */ static void -create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) - FRAME_PTR f; - widget_value *first_wv; - int x; - int y; - int for_click; - EMACS_UINT timestamp; +create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, + int x, int y, int for_click, EMACS_UINT timestamp) { int i; Arg av[2]; @@ -1608,6 +1545,10 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) popup_deactivate_callback, menu_highlight_callback); +#ifdef USE_LUCID + apply_systemfont_to_menu (menu); +#endif + dummy.type = ButtonPress; dummy.serial = 0; dummy.send_event = 0; @@ -1659,7 +1600,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) Lisp_Object xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, char **error, EMACS_UINT timestamp) + Lisp_Object title, const char **error, EMACS_UINT timestamp) { int i; widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; @@ -1723,7 +1664,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); @@ -1934,9 +1875,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, #ifdef USE_GTK static void -dialog_selection_callback (widget, client_data) - GtkWidget *widget; - gpointer client_data; +dialog_selection_callback (GtkWidget *widget, gpointer client_data) { /* The EMACS_INT cast avoids a warning. There's no problem as long as pointers have enough bits to hold small integers. */ @@ -1950,9 +1889,7 @@ dialog_selection_callback (widget, client_data) dialog pops down. menu_item_selection will be set to the selection. */ static void -create_and_show_dialog (f, first_wv) - FRAME_PTR f; - widget_value *first_wv; +create_and_show_dialog (FRAME_PTR f, widget_value *first_wv) { GtkWidget *menu; @@ -1981,10 +1918,7 @@ create_and_show_dialog (f, first_wv) #else /* not USE_GTK */ static void -dialog_selection_callback (widget, id, client_data) - Widget widget; - LWLIB_ID id; - XtPointer client_data; +dialog_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) { /* The EMACS_INT cast avoids a warning. There's no problem as long as pointers have enough bits to hold small integers. */ @@ -2002,9 +1936,7 @@ dialog_selection_callback (widget, id, client_data) dialog pops down. menu_item_selection will be set to the selection. */ static void -create_and_show_dialog (f, first_wv) - FRAME_PTR f; - widget_value *first_wv; +create_and_show_dialog (FRAME_PTR f, widget_value *first_wv) { LWLIB_ID dialog_id; @@ -2012,11 +1944,13 @@ create_and_show_dialog (f, first_wv) abort(); dialog_id = widget_id_tick++; +#ifdef USE_LUCID + apply_systemfont_to_dialog (f->output_data.x->widget); +#endif lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, f->output_data.x->widget, 1, 0, dialog_selection_callback, 0, 0); lw_modify_all_widgets (dialog_id, first_wv->contents, True); - /* Display the dialog box. */ lw_pop_up_all_widgets (dialog_id); popup_activated_flag = 1; @@ -2042,16 +1976,16 @@ create_and_show_dialog (f, first_wv) #endif /* not USE_GTK */ -static char * button_names [] = { +static const char * button_names [] = { "button1", "button2", "button3", "button4", "button5", "button6", "button7", "button8", "button9", "button10" }; static Lisp_Object -xdialog_show (f, keymaps, title, header, error_name) - FRAME_PTR f; - int keymaps; - Lisp_Object title, header; - char **error_name; +xdialog_show (FRAME_PTR f, + int keymaps, + Lisp_Object title, + Lisp_Object header, + const char **error_name) { int i, nb_buttons=0; char dialog_name[6]; @@ -2078,7 +2012,7 @@ xdialog_show (f, keymaps, title, header, error_name) representing the text label and buttons. */ { Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; pane_string = (NILP (pane_name) @@ -2249,11 +2183,8 @@ static struct frame *menu_help_frame; keyboard events. */ static void -menu_help_callback (help_string, pane, item) - char *help_string; - int pane, item; +menu_help_callback (char *help_string, int pane, int item) { - extern Lisp_Object Qmenu_item; Lisp_Object *first_item; Lisp_Object pane_name; Lisp_Object menu_object; @@ -2276,8 +2207,7 @@ menu_help_callback (help_string, pane, item) } static Lisp_Object -pop_down_menu (arg) - Lisp_Object arg; +pop_down_menu (Lisp_Object arg) { struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg)); struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg)); @@ -2312,14 +2242,8 @@ pop_down_menu (arg) Lisp_Object -xmenu_show (f, x, y, for_click, keymaps, title, error, timestamp) - FRAME_PTR f; - int x, y; - int for_click; - int keymaps; - Lisp_Object title; - char **error; - EMACS_UINT timestamp; +xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, + Lisp_Object title, const char **error, EMACS_UINT timestamp) { Window root; XMenu *menu; @@ -2450,12 +2374,10 @@ xmenu_show (f, x, y, for_click, keymaps, title, error, timestamp) item_data = (unsigned char *) alloca (maxwidth + SBYTES (descrip) + 1); - bcopy (SDATA (item_name), item_data, - SBYTES (item_name)); + memcpy (item_data, SDATA (item_name), SBYTES (item_name)); for (j = SCHARS (item_name); j < maxwidth; j++) item_data[j] = ' '; - bcopy (SDATA (descrip), item_data + j, - SBYTES (descrip)); + memcpy (item_data + j, SDATA (descrip), SBYTES (descrip)); item_data[j + SBYTES (descrip)] = 0; } else @@ -2613,7 +2535,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error, timestamp) /* Detect if a dialog or menu has been posted. */ int -popup_activated () +popup_activated (void) { return popup_activated_flag; } @@ -2622,7 +2544,7 @@ popup_activated () DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0, doc: /* Return t if a menu or popup dialog is active. */) - () + (void) { #ifdef HAVE_MENUS return (popup_activated ()) ? Qt : Qnil; @@ -2632,7 +2554,7 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_ } void -syms_of_xmenu () +syms_of_xmenu (void) { Qdebug_on_next_call = intern_c_string ("debug-on-next-call"); staticpro (&Qdebug_on_next_call); diff --git a/src/xml.c b/src/xml.c new file mode 100644 index 00000000000..a686e55f0b0 --- /dev/null +++ b/src/xml.c @@ -0,0 +1,158 @@ +/* Interface to libxml2. + Copyright (C) 2010 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#ifdef HAVE_LIBXML2 + +#include <setjmp.h> +#include <libxml/tree.h> +#include <libxml/parser.h> +#include <libxml/HTMLparser.h> + +#include "lisp.h" +#include "buffer.h" + +Lisp_Object make_dom (xmlNode *node) +{ + if (node->type == XML_ELEMENT_NODE) + { + Lisp_Object result = Fcons (intern (node->name), Qnil); + xmlNode *child; + xmlAttr *property; + Lisp_Object plist = Qnil; + + /* First add the attributes. */ + property = node->properties; + while (property != NULL) + { + if (property->children && + property->children->content) + { + plist = Fcons (Fcons (intern (property->name), + build_string (property->children->content)), + plist); + } + property = property->next; + } + result = Fcons (Fnreverse (plist), result); + + /* Then add the children of the node. */ + child = node->children; + while (child != NULL) + { + result = Fcons (make_dom (child), result); + child = child->next; + } + + return Fnreverse (result); + } + else if (node->type == XML_TEXT_NODE) + { + if (node->content) + return build_string (node->content); + else + return Qnil; + } + else + return Qnil; +} + +static Lisp_Object +parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, int htmlp) +{ + xmlDoc *doc; + xmlNode *node; + Lisp_Object result = Qnil; + const char *burl = ""; + EMACS_INT bytes; + EMACS_INT istart, iend; + + LIBXML_TEST_VERSION; + + validate_region (&start, &end); + + istart = XINT (start); + iend = XINT (end); + + if (istart < GPT && GPT < iend) + move_gap (iend); + + if (! NILP (base_url)) + { + CHECK_STRING (base_url); + burl = SDATA (base_url); + } + + bytes = CHAR_TO_BYTE (iend) - CHAR_TO_BYTE (istart); + + if (htmlp) + doc = htmlReadMemory (BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), + bytes, burl, "utf-8", + HTML_PARSE_RECOVER|HTML_PARSE_NONET| + HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR); + else + doc = xmlReadMemory (BYTE_POS_ADDR (CHAR_TO_BYTE (istart)), + bytes, burl, "utf-8", + XML_PARSE_NONET|XML_PARSE_NOWARNING| + XML_PARSE_NOERROR); + + if (doc != NULL) + { + node = xmlDocGetRootElement (doc); + if (node != NULL) + result = make_dom (node); + xmlFreeDoc (doc); + xmlCleanupParser (); + } + + return result; +} + +DEFUN ("libxml-parse-html-region", Flibxml_parse_html_region, + Slibxml_parse_html_region, + 2, 3, 0, + doc: /* Parse the region as an HTML document and return the parse tree. +If BASE-URL is non-nil, it is used to expand relative URLs. */) + (Lisp_Object start, Lisp_Object end, Lisp_Object base_url) +{ + return parse_region (start, end, base_url, 1); +} + +DEFUN ("libxml-parse-xml-region", Flibxml_parse_xml_region, + Slibxml_parse_xml_region, + 2, 3, 0, + doc: /* Parse the region as an XML document and return the parse tree. +If BASE-URL is non-nil, it is used to expand relative URLs. */) + (Lisp_Object start, Lisp_Object end, Lisp_Object base_url) +{ + return parse_region (start, end, base_url, 0); +} + + +/*********************************************************************** + Initialization + ***********************************************************************/ +void +syms_of_xml (void) +{ + defsubr (&Slibxml_parse_html_region); + defsubr (&Slibxml_parse_xml_region); +} + +#endif /* HAVE_LIBXML2 */ diff --git a/src/xrdb.c b/src/xrdb.c index c8cb55cb7b8..d2898e1d8f8 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -20,37 +20,20 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#ifdef emacs #include <config.h> -#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include <errno.h> #include <epaths.h> #include <stdio.h> #include <setjmp.h> -#if 1 /* I'd really appreciate it if this code could go away... -JimB */ -/* This avoids lossage in the `dual-universe' headers on AT&T SysV - X11. Don't do it on Solaris, because it breaks compilation with - XFree86 4.0.3 (and probably many other X11R6 releases) on Solaris - 2 */ -#if defined(USG5) && !defined(SOLARIS2) -#ifndef SYSV -#define SYSV -#endif -#endif /* USG5 && !SOLARIS2 */ - -#endif /* 1 */ - #include <X11/Xlib.h> #include <X11/Xatom.h> -#if 0 -#include <X11/Xos.h> -#endif #include <X11/X.h> #include <X11/Xutil.h> #include <X11/Xresource.h> @@ -65,40 +48,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "lisp.h" -extern char *getenv (); - -/* This does cause trouble on AIX. I'm going to take the comment at - face value. */ -#if 0 -extern short getuid (); /* If this causes portability problems, - I think we should just delete it; it'll - default to `int' anyway. */ -#endif +extern char *getenv (const char *); -#ifdef DECLARE_GETPWUID_WITH_UID_T extern struct passwd *getpwuid (uid_t); extern struct passwd *getpwnam (const char *); -#else -extern struct passwd *getpwuid (); -extern struct passwd *getpwnam (); -#endif -extern char *get_system_name (); - -/* Make sure not to #include anything after these definitions. Let's - not step on anyone's prototypes. */ -#ifdef emacs -/* darwin.h may have already defined these. */ -#undef malloc -#undef realloc -#undef free -#define malloc xmalloc -#define realloc xrealloc -#define free xfree -#endif +extern const char *get_system_name (void); -char *x_get_string_resource (); -static int file_p (); +char *x_get_string_resource (XrmDatabase rdb, const char *name, + const char *class); +static int file_p (const char *filename); /* X file search path processing. */ @@ -113,9 +72,7 @@ char *x_customization_string; resource, for later use in search path decoding. If we find no such resource, return zero. */ char * -x_get_customization_string (db, name, class) - XrmDatabase db; - char *name, *class; +x_get_customization_string (XrmDatabase db, const char *name, const char *class) { char *full_name = (char *) alloca (strlen (name) + sizeof ("customization") + 3); @@ -130,7 +87,7 @@ x_get_customization_string (db, name, class) if (result) { - char *copy = (char *) malloc (strlen (result) + 1); + char *copy = (char *) xmalloc (strlen (result) + 1); strcpy (copy, result); return copy; } @@ -170,23 +127,20 @@ x_get_customization_string (db, name, class) Return NULL otherwise. */ static char * -magic_file_p (string, string_len, class, escaped_suffix, suffix) - char *string; - int string_len; - char *class, *escaped_suffix, *suffix; +magic_file_p (const char *string, EMACS_INT string_len, const char *class, const char *escaped_suffix, const char *suffix) { char *lang = getenv ("LANG"); int path_size = 100; - char *path = (char *) malloc (path_size); + char *path = (char *) xmalloc (path_size); int path_len = 0; - char *p = string; + const char *p = string; while (p < string + string_len) { /* The chunk we're about to stick on the end of result. */ - char *next = NULL; + const char *next = NULL; int next_len; if (*p == '%') @@ -229,7 +183,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) case 'l': if (! lang) { - free (path); + xfree (path); return NULL; } @@ -239,7 +193,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) case 't': case 'c': - free (path); + xfree (path); return NULL; } } @@ -250,10 +204,10 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) if (path_len + next_len + 1 > path_size) { path_size = (path_len + next_len + 1) * 2; - path = (char *) realloc (path, path_size); + path = (char *) xrealloc (path, path_size); } - bcopy (next, path + path_len, next_len); + memcpy (path + path_len, next, next_len); path_len += next_len; p++; @@ -276,10 +230,10 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) if (path_len + suffix_len + 1 > path_size) { path_size = (path_len + suffix_len + 1); - path = (char *) realloc (path, path_size); + path = (char *) xrealloc (path, path_size); } - bcopy (suffix, path + path_len, suffix_len); + memcpy (path + path_len, suffix, suffix_len); path_len += suffix_len; } @@ -287,7 +241,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) if (! file_p (path)) { - free (path); + xfree (path); return NULL; } @@ -296,7 +250,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix) static char * -gethomedir () +gethomedir (void) { struct passwd *pw; char *ptr; @@ -317,7 +271,7 @@ gethomedir () if (ptr == NULL) return xstrdup ("/"); - copy = (char *) malloc (strlen (ptr) + 2); + copy = (char *) xmalloc (strlen (ptr) + 2); strcpy (copy, ptr); strcat (copy, "/"); @@ -326,8 +280,7 @@ gethomedir () static int -file_p (filename) - char *filename; +file_p (const char *filename) { struct stat status; @@ -342,10 +295,9 @@ file_p (filename) the path name of the one we found otherwise. */ static char * -search_magic_path (search_path, class, escaped_suffix, suffix) - char *search_path, *class, *escaped_suffix, *suffix; +search_magic_path (const char *search_path, const char *class, const char *escaped_suffix, const char *suffix) { - register char *s, *p; + const char *s, *p; for (s = search_path; *s; s = p) { @@ -354,7 +306,8 @@ search_magic_path (search_path, class, escaped_suffix, suffix) if (p > s) { - char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix); + char *path = magic_file_p (s, p - s, class, escaped_suffix, + suffix); if (path) return path; } @@ -378,20 +331,20 @@ search_magic_path (search_path, class, escaped_suffix, suffix) /* Producing databases for individual sources. */ static XrmDatabase -get_system_app (class) - char *class; +get_system_app (const char *class) { XrmDatabase db = NULL; - char *path; + const char *path; + char *p; path = getenv ("XFILESEARCHPATH"); if (! path) path = PATH_X_DEFAULTS; - path = search_magic_path (path, class, 0, 0); - if (path) + p = search_magic_path (path, class, 0, 0); + if (p) { - db = XrmGetFileDatabase (path); - free (path); + db = XrmGetFileDatabase (p); + xfree (p); } return db; @@ -399,18 +352,16 @@ get_system_app (class) static XrmDatabase -get_fallback (display) - Display *display; +get_fallback (Display *display) { return NULL; } static XrmDatabase -get_user_app (class) - char *class; +get_user_app (const char *class) { - char *path; + const char *path; char *file = 0; char *free_it = 0; @@ -432,19 +383,18 @@ get_user_app (class) || (file = search_magic_path (free_it, class, "%N", 0))))) { XrmDatabase db = XrmGetFileDatabase (file); - free (file); - free (free_it); + xfree (file); + xfree (free_it); return db; } - free (free_it); + xfree (free_it); return NULL; } static XrmDatabase -get_user_db (display) - Display *display; +get_user_db (Display *display) { XrmDatabase db; char *xdefs; @@ -463,12 +413,12 @@ get_user_db (display) char *xdefault; home = gethomedir (); - xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults")); + xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults")); strcpy (xdefault, home); strcat (xdefault, ".Xdefaults"); db = XrmGetFileDatabase (xdefault); - free (home); - free (xdefault); + xfree (home); + xfree (xdefault); } #ifdef HAVE_XSCREENRESOURCESTRING @@ -485,17 +435,18 @@ get_user_db (display) } static XrmDatabase -get_environ_db () +get_environ_db (void) { XrmDatabase db; char *p; - char *path = 0, *home = 0, *host; + char *path = 0, *home = 0; + const char *host; if ((p = getenv ("XENVIRONMENT")) == NULL) { home = gethomedir (); host = get_system_name (); - path = (char *) malloc (strlen (home) + path = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults-") + strlen (host)); sprintf (path, "%s%s%s", home, ".Xdefaults-", host); @@ -504,8 +455,8 @@ get_environ_db () db = XrmGetFileDatabase (p); - free (path); - free (home); + xfree (path); + xfree (home); return db; } @@ -520,20 +471,18 @@ XrmRepresentation x_rm_string; /* Quark representation */ /* Load X resources based on the display and a possible -xrm option. */ XrmDatabase -x_load_resources (display, xrm_string, myname, myclass) - Display *display; - char *xrm_string, *myname, *myclass; +x_load_resources (Display *display, const char *xrm_string, + const char *myname, const char *myclass) { XrmDatabase user_database; XrmDatabase rdb; XrmDatabase db; char line[256]; - char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"; + const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"; #ifdef USE_MOTIF - char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"; - extern Lisp_Object Vdouble_click_time; + const char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"; #endif x_rm_string = XrmStringToQuark (XrmStringType); @@ -612,7 +561,7 @@ x_load_resources (display, xrm_string, myname, myclass) /* Figure out what the "customization string" is, so we can use it to decode paths. */ - free (x_customization_string); + xfree (x_customization_string); x_customization_string = x_get_customization_string (user_database, myname, myclass); @@ -656,11 +605,7 @@ x_load_resources (display, xrm_string, myname, myclass) and of type TYPE from database RDB. The value is returned in RET_VALUE. */ int -x_get_resource (rdb, name, class, expected_type, ret_value) - XrmDatabase rdb; - char *name, *class; - XrmRepresentation expected_type; - XrmValue *ret_value; +x_get_resource (XrmDatabase rdb, const char *name, const char *class, XrmRepresentation expected_type, XrmValue *ret_value) { XrmValue value; XrmName namelist[100]; @@ -676,7 +621,7 @@ x_get_resource (rdb, name, class, expected_type, ret_value) if (type == x_rm_string) ret_value->addr = (char *) value.addr; else - bcopy (value.addr, ret_value->addr, ret_value->size); + memcpy (ret_value->addr, value.addr, ret_value->size); return value.size; } @@ -688,9 +633,7 @@ x_get_resource (rdb, name, class, expected_type, ret_value) database RDB. */ char * -x_get_string_resource (rdb, name, class) - XrmDatabase rdb; - char *name, *class; +x_get_string_resource (XrmDatabase rdb, const char *name, const char *class) { XrmValue value; @@ -734,8 +677,6 @@ fatal (msg, prog, x1, x2, x3, x4, x5) char *msg, *prog; int x1, x2, x3, x4, x5; { - extern int errno; - if (errno) perror (prog); diff --git a/src/xselect.c b/src/xselect.c index e2027736855..7479f245a77 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -45,45 +45,44 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ struct prop_location; -static Lisp_Object x_atom_to_symbol P_ ((Display *dpy, Atom atom)); -static Atom symbol_to_x_atom P_ ((struct x_display_info *, Display *, - Lisp_Object)); -static void x_own_selection P_ ((Lisp_Object, Lisp_Object)); -static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int)); -static void x_decline_selection_request P_ ((struct input_event *)); -static Lisp_Object x_selection_request_lisp_error P_ ((Lisp_Object)); -static Lisp_Object queue_selection_requests_unwind P_ ((Lisp_Object)); -static Lisp_Object some_frame_on_display P_ ((struct x_display_info *)); -static Lisp_Object x_catch_errors_unwind P_ ((Lisp_Object)); -static void x_reply_selection_request P_ ((struct input_event *, int, - unsigned char *, int, Atom)); -static int waiting_for_other_props_on_window P_ ((Display *, Window)); -static struct prop_location *expect_property_change P_ ((Display *, Window, - Atom, int)); -static void unexpect_property_change P_ ((struct prop_location *)); -static Lisp_Object wait_for_property_change_unwind P_ ((Lisp_Object)); -static void wait_for_property_change P_ ((struct prop_location *)); -static Lisp_Object x_get_foreign_selection P_ ((Lisp_Object, - Lisp_Object, - Lisp_Object)); -static void x_get_window_property P_ ((Display *, Window, Atom, - unsigned char **, int *, - Atom *, int *, unsigned long *, int)); -static void receive_incremental_selection P_ ((Display *, Window, Atom, - Lisp_Object, unsigned, - unsigned char **, int *, - Atom *, int *, unsigned long *)); -static Lisp_Object x_get_window_property_as_lisp_data P_ ((Display *, - Window, Atom, - Lisp_Object, Atom)); -static Lisp_Object selection_data_to_lisp_data P_ ((Display *, unsigned char *, - int, Atom, int)); -static void lisp_data_to_selection_data P_ ((Display *, Lisp_Object, - unsigned char **, Atom *, - unsigned *, int *, int *)); -static Lisp_Object clean_local_selection_data P_ ((Lisp_Object)); -static void initialize_cut_buffers P_ ((Display *, Window)); - +static Lisp_Object x_atom_to_symbol (Display *dpy, Atom atom); +static Atom symbol_to_x_atom (struct x_display_info *, Display *, + Lisp_Object); +static void x_own_selection (Lisp_Object, Lisp_Object); +static Lisp_Object x_get_local_selection (Lisp_Object, Lisp_Object, int); +static void x_decline_selection_request (struct input_event *); +static Lisp_Object x_selection_request_lisp_error (Lisp_Object); +static Lisp_Object queue_selection_requests_unwind (Lisp_Object); +static Lisp_Object some_frame_on_display (struct x_display_info *); +static Lisp_Object x_catch_errors_unwind (Lisp_Object); +static void x_reply_selection_request (struct input_event *, int, + unsigned char *, int, Atom); +static int waiting_for_other_props_on_window (Display *, Window); +static struct prop_location *expect_property_change (Display *, Window, + Atom, int); +static void unexpect_property_change (struct prop_location *); +static Lisp_Object wait_for_property_change_unwind (Lisp_Object); +static void wait_for_property_change (struct prop_location *); +static Lisp_Object x_get_foreign_selection (Lisp_Object, + Lisp_Object, + Lisp_Object); +static void x_get_window_property (Display *, Window, Atom, + unsigned char **, int *, + Atom *, int *, unsigned long *, int); +static void receive_incremental_selection (Display *, Window, Atom, + Lisp_Object, unsigned, + unsigned char **, int *, + Atom *, int *, unsigned long *); +static Lisp_Object x_get_window_property_as_lisp_data (Display *, + Window, Atom, + Lisp_Object, Atom); +static Lisp_Object selection_data_to_lisp_data (Display *, + const unsigned char *, + int, Atom, int); +static void lisp_data_to_selection_data (Display *, Lisp_Object, + unsigned char **, Atom *, + unsigned *, int *, int *); +static Lisp_Object clean_local_selection_data (Lisp_Object); /* Printing traces to stderr. */ @@ -104,9 +103,7 @@ static void initialize_cut_buffers P_ ((Display *, Window)); #endif -#define CUT_BUFFER_SUPPORT - -Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, +Lisp_Object QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, QATOM_PAIR; @@ -115,11 +112,6 @@ Lisp_Object QUTF8_STRING; /* This is a type of selection. */ Lisp_Object Qcompound_text_with_extensions; -#ifdef CUT_BUFFER_SUPPORT -Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3, - QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7; -#endif - static Lisp_Object Vx_lost_selection_functions; static Lisp_Object Vx_sent_selection_functions; static Lisp_Object Qforeign_selection; @@ -183,8 +175,7 @@ static int x_queue_selection_requests; /* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */ static void -x_queue_event (event) - struct input_event *event; +x_queue_event (struct input_event *event) { struct selection_event_queue *queue_tmp; @@ -192,7 +183,7 @@ x_queue_event (event) This only happens for large requests which uses the incremental protocol. */ for (queue_tmp = selection_queue; queue_tmp; queue_tmp = queue_tmp->next) { - if (!bcmp (&queue_tmp->event, event, sizeof (*event))) + if (!memcmp (&queue_tmp->event, event, sizeof (*event))) { TRACE1 ("DECLINE DUP SELECTION EVENT %08lx", (unsigned long)queue_tmp); x_decline_selection_request (event); @@ -215,7 +206,7 @@ x_queue_event (event) /* Start queuing SELECTION_REQUEST_EVENT events. */ static void -x_start_queuing_selection_requests () +x_start_queuing_selection_requests (void) { if (x_queue_selection_requests) abort (); @@ -227,7 +218,7 @@ x_start_queuing_selection_requests () /* Stop queuing SELECTION_REQUEST_EVENT events. */ static void -x_stop_queuing_selection_requests () +x_stop_queuing_selection_requests (void) { TRACE1 ("x_stop_queuing_selection_requests %d", x_queue_selection_requests); --x_queue_selection_requests; @@ -250,10 +241,7 @@ x_stop_queuing_selection_requests () roundtrip whenever possible. */ static Atom -symbol_to_x_atom (dpyinfo, display, sym) - struct x_display_info *dpyinfo; - Display *display; - Lisp_Object sym; +symbol_to_x_atom (struct x_display_info *dpyinfo, Display *display, Lisp_Object sym) { Atom val; if (NILP (sym)) return 0; @@ -273,16 +261,6 @@ symbol_to_x_atom (dpyinfo, display, sym) if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; -#ifdef CUT_BUFFER_SUPPORT - if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0; - if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1; - if (EQ (sym, QCUT_BUFFER2)) return XA_CUT_BUFFER2; - if (EQ (sym, QCUT_BUFFER3)) return XA_CUT_BUFFER3; - if (EQ (sym, QCUT_BUFFER4)) return XA_CUT_BUFFER4; - if (EQ (sym, QCUT_BUFFER5)) return XA_CUT_BUFFER5; - if (EQ (sym, QCUT_BUFFER6)) return XA_CUT_BUFFER6; - if (EQ (sym, QCUT_BUFFER7)) return XA_CUT_BUFFER7; -#endif if (!SYMBOLP (sym)) abort (); TRACE1 (" XInternAtom %s", (char *) SDATA (SYMBOL_NAME (sym))); @@ -297,9 +275,7 @@ symbol_to_x_atom (dpyinfo, display, sym) and calls to intern whenever possible. */ static Lisp_Object -x_atom_to_symbol (dpy, atom) - Display *dpy; - Atom atom; +x_atom_to_symbol (Display *dpy, Atom atom) { struct x_display_info *dpyinfo; char *str; @@ -320,24 +296,6 @@ x_atom_to_symbol (dpy, atom) return QINTEGER; case XA_ATOM: return QATOM; -#ifdef CUT_BUFFER_SUPPORT - case XA_CUT_BUFFER0: - return QCUT_BUFFER0; - case XA_CUT_BUFFER1: - return QCUT_BUFFER1; - case XA_CUT_BUFFER2: - return QCUT_BUFFER2; - case XA_CUT_BUFFER3: - return QCUT_BUFFER3; - case XA_CUT_BUFFER4: - return QCUT_BUFFER4; - case XA_CUT_BUFFER5: - return QCUT_BUFFER5; - case XA_CUT_BUFFER6: - return QCUT_BUFFER6; - case XA_CUT_BUFFER7: - return QCUT_BUFFER7; -#endif } dpyinfo = x_display_info_for_display (dpy); @@ -382,8 +340,7 @@ x_atom_to_symbol (dpy, atom) our selection. */ static void -x_own_selection (selection_name, selection_value) - Lisp_Object selection_name, selection_value; +x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value) { struct frame *sf = SELECTED_FRAME (); Window selecting_window; @@ -398,7 +355,7 @@ x_own_selection (selection_name, selection_value) selecting_window = FRAME_X_WINDOW (sf); display = FRAME_X_DISPLAY (sf); dpyinfo = FRAME_X_DISPLAY_INFO (sf); - + CHECK_SYMBOL (selection_name); selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name); @@ -416,10 +373,8 @@ x_own_selection (selection_name, selection_value) Lisp_Object prev_value; selection_time = long_to_cons ((unsigned long) time); - selection_data = Fcons (selection_name, - Fcons (selection_value, - Fcons (selection_time, - Fcons (selected_frame, Qnil)))); + selection_data = list4 (selection_name, selection_value, + selection_time, selected_frame); prev_value = assq_no_quit (selection_name, Vselection_alist); Vselection_alist = Fcons (selection_data, Vselection_alist); @@ -449,9 +404,7 @@ x_own_selection (selection_name, selection_value) This calls random Lisp code, and may signal or gc. */ static Lisp_Object -x_get_local_selection (selection_symbol, target_type, local_request) - Lisp_Object selection_symbol, target_type; - int local_request; +x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, int local_request) { Lisp_Object local_value; Lisp_Object handler_fn, value, type, check; @@ -561,8 +514,7 @@ x_get_local_selection (selection_symbol, target_type, local_request) meaning we were unable to do what they wanted. */ static void -x_decline_selection_request (event) - struct input_event *event; +x_decline_selection_request (struct input_event *event) { XSelectionEvent reply; @@ -597,8 +549,7 @@ static struct x_display_info *selection_request_dpyinfo; before we throw to top-level or go into the debugger or whatever. */ static Lisp_Object -x_selection_request_lisp_error (ignore) - Lisp_Object ignore; +x_selection_request_lisp_error (Lisp_Object ignore) { if (x_selection_current_request != 0 && selection_request_dpyinfo->display) @@ -607,8 +558,7 @@ x_selection_request_lisp_error (ignore) } static Lisp_Object -x_catch_errors_unwind (dummy) - Lisp_Object dummy; +x_catch_errors_unwind (Lisp_Object dummy) { BLOCK_INPUT; x_uncatch_errors (); @@ -634,10 +584,10 @@ struct prop_location struct prop_location *next; }; -static struct prop_location *expect_property_change (); -static void wait_for_property_change (); -static void unexpect_property_change (); -static int waiting_for_other_props_on_window (); +static struct prop_location *expect_property_change (Display *display, Window window, Atom property, int state); +static void wait_for_property_change (struct prop_location *location); +static void unexpect_property_change (struct prop_location *location); +static int waiting_for_other_props_on_window (Display *display, Window window); static int prop_location_identifier; @@ -648,8 +598,7 @@ static struct prop_location *property_change_reply_object; static struct prop_location *property_change_wait_list; static Lisp_Object -queue_selection_requests_unwind (tem) - Lisp_Object tem; +queue_selection_requests_unwind (Lisp_Object tem) { x_stop_queuing_selection_requests (); return Qnil; @@ -659,8 +608,7 @@ queue_selection_requests_unwind (tem) Return nil if there is none. */ static Lisp_Object -some_frame_on_display (dpyinfo) - struct x_display_info *dpyinfo; +some_frame_on_display (struct x_display_info *dpyinfo) { Lisp_Object list, frame; @@ -684,11 +632,7 @@ static int x_reply_selection_request_cnt; #endif /* TRACE_SELECTION */ static void -x_reply_selection_request (event, format, data, size, type) - struct input_event *event; - int format, size; - unsigned char *data; - Atom type; +x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type) { XSelectionEvent reply; Display *display = SELECTION_EVENT_DISPLAY (event); @@ -881,8 +825,7 @@ x_reply_selection_request (event, format, data, size, type) This is called from keyboard.c when such an event is found in the queue. */ static void -x_handle_selection_request (event) - struct input_event *event; +x_handle_selection_request (struct input_event *event) { struct gcpro gcpro1, gcpro2, gcpro3; Lisp_Object local_selection_data; @@ -1002,8 +945,7 @@ x_handle_selection_request (event) This is called from keyboard.c when such an event is found in the queue. */ static void -x_handle_selection_clear (event) - struct input_event *event; +x_handle_selection_clear (struct input_event *event) { Display *display = SELECTION_EVENT_DISPLAY (event); Atom selection = SELECTION_EVENT_SELECTION (event); @@ -1034,7 +976,7 @@ x_handle_selection_clear (event) } } UNBLOCK_INPUT; - + selection_symbol = x_atom_to_symbol (display, selection); local_selection_data = assq_no_quit (selection_symbol, Vselection_alist); @@ -1085,8 +1027,7 @@ x_handle_selection_clear (event) } void -x_handle_selection_event (event) - struct input_event *event; +x_handle_selection_event (struct input_event *event) { TRACE0 ("x_handle_selection_event"); @@ -1106,8 +1047,7 @@ x_handle_selection_event (event) We do this when about to delete a frame. */ void -x_clear_frame_selections (f) - FRAME_PTR f; +x_clear_frame_selections (FRAME_PTR f) { Lisp_Object frame; Lisp_Object rest; @@ -1168,9 +1108,7 @@ x_clear_frame_selections (f) are on the list of what we are waiting for. */ static int -waiting_for_other_props_on_window (display, window) - Display *display; - Window window; +waiting_for_other_props_on_window (Display *display, Window window) { struct prop_location *rest = property_change_wait_list; while (rest) @@ -1187,11 +1125,7 @@ waiting_for_other_props_on_window (display, window) this awaited property change. */ static struct prop_location * -expect_property_change (display, window, property, state) - Display *display; - Window window; - Atom property; - int state; +expect_property_change (Display *display, Window window, Atom property, int state) { struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl); pl->identifier = ++prop_location_identifier; @@ -1209,8 +1143,7 @@ expect_property_change (display, window, property, state) IDENTIFIER is the number that uniquely identifies the entry. */ static void -unexpect_property_change (location) - struct prop_location *location; +unexpect_property_change (struct prop_location *location) { struct prop_location *prev = 0, *rest = property_change_wait_list; while (rest) @@ -1232,8 +1165,7 @@ unexpect_property_change (location) /* Remove the property change expectation element for IDENTIFIER. */ static Lisp_Object -wait_for_property_change_unwind (loc) - Lisp_Object loc; +wait_for_property_change_unwind (Lisp_Object loc) { struct prop_location *location = XSAVE_VALUE (loc)->pointer; @@ -1247,8 +1179,7 @@ wait_for_property_change_unwind (loc) IDENTIFIER should be the value that expect_property_change returned. */ static void -wait_for_property_change (location) - struct prop_location *location; +wait_for_property_change (struct prop_location *location) { int secs, usecs; int count = SPECPDL_INDEX (); @@ -1286,8 +1217,7 @@ wait_for_property_change (location) /* Called from XTread_socket in response to a PropertyNotify event. */ void -x_handle_property_notify (event) - XPropertyEvent *event; +x_handle_property_notify (XPropertyEvent *event) { struct prop_location *prev = 0, *rest = property_change_wait_list; @@ -1378,8 +1308,7 @@ static Window reading_selection_window; Converts this to Lisp data and returns it. */ static Lisp_Object -x_get_foreign_selection (selection_symbol, target_type, time_stamp) - Lisp_Object selection_symbol, target_type, time_stamp; +x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, Lisp_Object time_stamp) { struct frame *sf = SELECTED_FRAME (); Window requestor_window; @@ -1486,18 +1415,10 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp) /* Use xfree, not XFree, to free the data obtained with this function. */ static void -x_get_window_property (display, window, property, data_ret, bytes_ret, - actual_type_ret, actual_format_ret, actual_size_ret, - delete_p) - Display *display; - Window window; - Atom property; - unsigned char **data_ret; - int *bytes_ret; - Atom *actual_type_ret; - int *actual_format_ret; - unsigned long *actual_size_ret; - int delete_p; +x_get_window_property (Display *display, Window window, Atom property, + unsigned char **data_ret, int *bytes_ret, + Atom *actual_type_ret, int *actual_format_ret, + unsigned long *actual_size_ret, int delete_p) { int total_size; unsigned long bytes_remaining; @@ -1567,7 +1488,7 @@ x_get_window_property (display, window, property, data_ret, bytes_ret, elements." This applies even if long is more than 32 bits, the X library converts from 32 bit elements received from the X server to long - and passes the long array to us. Thus, for that case bcopy can not + and passes the long array to us. Thus, for that case memcpy can not be used. We convert to a 32 bit type here, because so much code assume on that. @@ -1589,7 +1510,7 @@ x_get_window_property (display, window, property, data_ret, bytes_ret, else { *actual_size_ret *= *actual_format_ret / 8; - bcopy (tmp_data, (*data_ret) + offset, *actual_size_ret); + memcpy ((*data_ret) + offset, tmp_data, *actual_size_ret); offset += *actual_size_ret; } @@ -1605,19 +1526,12 @@ x_get_window_property (display, window, property, data_ret, bytes_ret, /* Use xfree, not XFree, to free the data obtained with this function. */ static void -receive_incremental_selection (display, window, property, target_type, - min_size_bytes, data_ret, size_bytes_ret, - type_ret, format_ret, size_ret) - Display *display; - Window window; - Atom property; - Lisp_Object target_type; /* for error messages only */ - unsigned int min_size_bytes; - unsigned char **data_ret; - int *size_bytes_ret; - Atom *type_ret; - unsigned long *size_ret; - int *format_ret; +receive_incremental_selection (Display *display, Window window, Atom property, + Lisp_Object target_type, + unsigned int min_size_bytes, + unsigned char **data_ret, int *size_bytes_ret, + Atom *type_ret, int *format_ret, + unsigned long *size_ret) { int offset = 0; struct prop_location *wait_object; @@ -1691,7 +1605,7 @@ receive_incremental_selection (display, window, property, target_type, *data_ret = (unsigned char *) xrealloc (*data_ret, *size_bytes_ret); } - bcopy (tmp_data, (*data_ret) + offset, tmp_size_bytes); + memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes); offset += tmp_size_bytes; /* Use xfree, not XFree, because x_get_window_property @@ -1706,13 +1620,10 @@ receive_incremental_selection (display, window, property, target_type, TARGET_TYPE and SELECTION_ATOM are used in error message if this fails. */ static Lisp_Object -x_get_window_property_as_lisp_data (display, window, property, target_type, - selection_atom) - Display *display; - Window window; - Atom property; - Lisp_Object target_type; /* for error messages only */ - Atom selection_atom; /* for error messages only */ +x_get_window_property_as_lisp_data (Display *display, Window window, + Atom property, + Lisp_Object target_type, + Atom selection_atom) { Atom actual_type; int actual_format; @@ -1809,11 +1720,8 @@ x_get_window_property_as_lisp_data (display, window, property, target_type, static Lisp_Object -selection_data_to_lisp_data (display, data, size, type, format) - Display *display; - unsigned char *data; - Atom type; - int size, format; +selection_data_to_lisp_data (Display *display, const unsigned char *data, + int size, Atom type, int format) { struct x_display_info *dpyinfo = x_display_info_for_display (display); @@ -1906,16 +1814,10 @@ selection_data_to_lisp_data (display, data, size, type, format) /* Use xfree, not XFree, to free the data obtained with this function. */ static void -lisp_data_to_selection_data (display, obj, - data_ret, type_ret, size_ret, - format_ret, nofree_ret) - Display *display; - Lisp_Object obj; - unsigned char **data_ret; - Atom *type_ret; - unsigned int *size_ret; - int *format_ret; - int *nofree_ret; +lisp_data_to_selection_data (Display *display, Lisp_Object obj, + unsigned char **data_ret, Atom *type_ret, + unsigned int *size_ret, + int *format_ret, int *nofree_ret) { Lisp_Object type = Qnil; struct x_display_info *dpyinfo = x_display_info_for_display (display); @@ -2071,8 +1973,7 @@ lisp_data_to_selection_data (display, obj, } static Lisp_Object -clean_local_selection_data (obj) - Lisp_Object obj; +clean_local_selection_data (Lisp_Object obj) { if (CONSP (obj) && INTEGERP (XCAR (obj)) @@ -2112,8 +2013,7 @@ clean_local_selection_data (obj) We store t there if the reply is successful, lambda if not. */ void -x_handle_selection_notify (event) - XSelectionEvent *event; +x_handle_selection_notify (XSelectionEvent *event) { if (event->requestor != reading_selection_window) return; @@ -2133,8 +2033,7 @@ TYPE is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) VALUE is typically a string, or a cons of two markers, but may be anything that the functions on `selection-converter-alist' know about. */) - (selection_name, selection_value) - Lisp_Object selection_name, selection_value; + (Lisp_Object selection_name, Lisp_Object selection_value) { check_x (); CHECK_SYMBOL (selection_name); @@ -2156,8 +2055,7 @@ SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'. TYPE is the type of data desired, typically `STRING'. TIME_STAMP is the time to use in the XConvertSelection call for foreign selections. If omitted, defaults to the time for the last event. */) - (selection_symbol, target_type, time_stamp) - Lisp_Object selection_symbol, target_type, time_stamp; + (Lisp_Object selection_symbol, Lisp_Object target_type, Lisp_Object time_stamp) { Lisp_Object val = Qnil; struct gcpro gcpro1, gcpro2; @@ -2202,9 +2100,7 @@ DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal, Sx_disown_selection_internal, 1, 2, 0, doc: /* If we own the selection SELECTION, disown it. Disowning it means there is no such selection. */) - (selection, time) - Lisp_Object selection; - Lisp_Object time; + (Lisp_Object selection, Lisp_Object time) { Time timestamp; Atom selection_atom; @@ -2254,8 +2150,7 @@ Disowning it means there is no such selection. */) This is used when we kill a buffer. */ void -x_disown_buffer_selections (buffer) - Lisp_Object buffer; +x_disown_buffer_selections (Lisp_Object buffer) { Lisp_Object tail; struct buffer *buf = XBUFFER (buffer); @@ -2279,8 +2174,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'. */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { check_x (); CHECK_SYMBOL (selection); @@ -2300,8 +2194,7 @@ the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. \(Those are literal upper-case symbol names, since that's what X expects.) For convenience, the symbol nil is the same as `PRIMARY', and t is the same as `SECONDARY'. */) - (selection) - Lisp_Object selection; + (Lisp_Object selection) { Window owner; Atom atom; @@ -2328,200 +2221,6 @@ and t is the same as `SECONDARY'. */) } -#ifdef CUT_BUFFER_SUPPORT - -/* Ensure that all 8 cut buffers exist. ICCCM says we gotta... */ -static void -initialize_cut_buffers (display, window) - Display *display; - Window window; -{ - unsigned char *data = (unsigned char *) ""; - BLOCK_INPUT; -#define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \ - PropModeAppend, data, 0) - FROB (XA_CUT_BUFFER0); - FROB (XA_CUT_BUFFER1); - FROB (XA_CUT_BUFFER2); - FROB (XA_CUT_BUFFER3); - FROB (XA_CUT_BUFFER4); - FROB (XA_CUT_BUFFER5); - FROB (XA_CUT_BUFFER6); - FROB (XA_CUT_BUFFER7); -#undef FROB - UNBLOCK_INPUT; -} - - -#define CHECK_CUT_BUFFER(symbol) \ - do { CHECK_SYMBOL ((symbol)); \ - if (!EQ((symbol), QCUT_BUFFER0) && !EQ((symbol), QCUT_BUFFER1) \ - && !EQ((symbol), QCUT_BUFFER2) && !EQ((symbol), QCUT_BUFFER3) \ - && !EQ((symbol), QCUT_BUFFER4) && !EQ((symbol), QCUT_BUFFER5) \ - && !EQ((symbol), QCUT_BUFFER6) && !EQ((symbol), QCUT_BUFFER7)) \ - signal_error ("Doesn't name a cut buffer", (symbol)); \ - } while (0) - -DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal, - Sx_get_cut_buffer_internal, 1, 1, 0, - doc: /* Returns the value of the named cut buffer (typically CUT_BUFFER0). */) - (buffer) - Lisp_Object buffer; -{ - Window window; - Atom buffer_atom; - unsigned char *data = NULL; - int bytes; - Atom type; - int format; - unsigned long size; - Lisp_Object ret; - Display *display; - struct x_display_info *dpyinfo; - struct frame *sf = SELECTED_FRAME (); - - check_x (); - - if (! FRAME_X_P (sf)) - return Qnil; - - display = FRAME_X_DISPLAY (sf); - dpyinfo = FRAME_X_DISPLAY_INFO (sf); - window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ - CHECK_CUT_BUFFER (buffer); - buffer_atom = symbol_to_x_atom (dpyinfo, display, buffer); - - x_get_window_property (display, window, buffer_atom, &data, &bytes, - &type, &format, &size, 0); - - if (!data || !format) - { - xfree (data); - return Qnil; - } - - if (format != 8 || type != XA_STRING) - signal_error ("Cut buffer doesn't contain 8-bit data", - list2 (x_atom_to_symbol (display, type), - make_number (format))); - - ret = (bytes ? make_unibyte_string ((char *) data, bytes) : Qnil); - /* Use xfree, not XFree, because x_get_window_property - calls xmalloc itself. */ - xfree (data); - return ret; -} - - -DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal, - Sx_store_cut_buffer_internal, 2, 2, 0, - doc: /* Sets the value of the named cut buffer (typically CUT_BUFFER0). */) - (buffer, string) - Lisp_Object buffer, string; -{ - Window window; - Atom buffer_atom; - unsigned char *data; - int bytes; - int bytes_remaining; - int max_bytes; - Display *display; - struct frame *sf = SELECTED_FRAME (); - - check_x (); - - if (! FRAME_X_P (sf)) - return Qnil; - - display = FRAME_X_DISPLAY (sf); - window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ - - max_bytes = SELECTION_QUANTUM (display); - if (max_bytes > MAX_SELECTION_QUANTUM) - max_bytes = MAX_SELECTION_QUANTUM; - - CHECK_CUT_BUFFER (buffer); - CHECK_STRING (string); - buffer_atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (sf), - display, buffer); - data = (unsigned char *) SDATA (string); - bytes = SBYTES (string); - bytes_remaining = bytes; - - if (! FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized) - { - initialize_cut_buffers (display, window); - FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized = 1; - } - - BLOCK_INPUT; - - /* Don't mess up with an empty value. */ - if (!bytes_remaining) - XChangeProperty (display, window, buffer_atom, XA_STRING, 8, - PropModeReplace, data, 0); - - while (bytes_remaining) - { - int chunk = (bytes_remaining < max_bytes - ? bytes_remaining : max_bytes); - XChangeProperty (display, window, buffer_atom, XA_STRING, 8, - (bytes_remaining == bytes - ? PropModeReplace - : PropModeAppend), - data, chunk); - data += chunk; - bytes_remaining -= chunk; - } - UNBLOCK_INPUT; - return string; -} - - -DEFUN ("x-rotate-cut-buffers-internal", Fx_rotate_cut_buffers_internal, - Sx_rotate_cut_buffers_internal, 1, 1, 0, - doc: /* Rotate the values of the cut buffers by N steps. -Positive N means shift the values forward, negative means backward. */) - (n) - Lisp_Object n; -{ - Window window; - Atom props[8]; - Display *display; - struct frame *sf = SELECTED_FRAME (); - - check_x (); - - if (! FRAME_X_P (sf)) - return Qnil; - - display = FRAME_X_DISPLAY (sf); - window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ - CHECK_NUMBER (n); - if (XINT (n) == 0) - return n; - if (! FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized) - { - initialize_cut_buffers (display, window); - FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized = 1; - } - - props[0] = XA_CUT_BUFFER0; - props[1] = XA_CUT_BUFFER1; - props[2] = XA_CUT_BUFFER2; - props[3] = XA_CUT_BUFFER3; - props[4] = XA_CUT_BUFFER4; - props[5] = XA_CUT_BUFFER5; - props[6] = XA_CUT_BUFFER6; - props[7] = XA_CUT_BUFFER7; - BLOCK_INPUT; - XRotateWindowProperties (display, window, props, 8, XINT (n)); - UNBLOCK_INPUT; - return n; -} - -#endif - /*********************************************************************** Drag and drop support ***********************************************************************/ @@ -2530,8 +2229,7 @@ Positive N means shift the values forward, negative means backward. */) bit parts of a 32 bit number). */ int -x_check_property_data (data) - Lisp_Object data; +x_check_property_data (Lisp_Object data) { Lisp_Object iter; int size = 0; @@ -2564,11 +2262,7 @@ x_check_property_data (data) XClientMessageEvent). */ void -x_fill_property_data (dpy, data, ret, format) - Display *dpy; - Lisp_Object data; - void *ret; - int format; +x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) { long val; long *d32 = (long *) ret; @@ -2620,12 +2314,8 @@ x_fill_property_data (dpy, data, ret, format) Also see comment for selection_data_to_lisp_data above. */ Lisp_Object -x_property_data_to_lisp (f, data, type, format, size) - struct frame *f; - unsigned char *data; - Atom type; - int format; - unsigned long size; +x_property_data_to_lisp (struct frame *f, const unsigned char *data, + Atom type, int format, long unsigned int size) { return selection_data_to_lisp_data (FRAME_X_DISPLAY (f), data, size*format/8, type, format); @@ -2634,10 +2324,7 @@ x_property_data_to_lisp (f, data, type, format, size) /* Get the mouse position in frame relative coordinates. */ static void -mouse_position_for_drop (f, x, y) - FRAME_PTR f; - int *x; - int *y; +mouse_position_for_drop (FRAME_PTR f, int *x, int *y) { Window root, dummy_window; int dummy; @@ -2679,11 +2366,11 @@ the cdr is the lower 16 bits of a 32 bit value. Use the display for FRAME or the current frame if FRAME is not given or nil. If the value is 0 or the atom is not known, return the empty string. */) - (value, frame) - Lisp_Object value, frame; + (Lisp_Object value, Lisp_Object frame) { struct frame *f = check_x_frame (frame); char *name = 0; + char empty[] = ""; Lisp_Object ret = Qnil; Display *dpy = FRAME_X_DISPLAY (f); Atom atom; @@ -2700,7 +2387,7 @@ If the value is 0 or the atom is not known, return the empty string. */) BLOCK_INPUT; x_catch_errors (dpy); - name = atom ? XGetAtomName (dpy, atom) : ""; + name = atom ? XGetAtomName (dpy, atom) : empty; had_errors = x_had_errors_p (dpy); x_uncatch_errors (); @@ -2720,8 +2407,7 @@ DEFUN ("x-register-dnd-atom", Fx_register_dnd_atom, doc: /* Request that dnd events are made for ClientMessages with ATOM. ATOM can be a symbol or a string. The ATOM is interned on the display that FRAME is on. If FRAME is nil, the selected frame is used. */) - (atom, frame) - Lisp_Object atom, frame; + (Lisp_Object atom, Lisp_Object frame) { Atom x_atom; struct frame *f = check_x_frame (frame); @@ -2759,11 +2445,7 @@ FRAME is on. If FRAME is nil, the selected frame is used. */) /* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ int -x_handle_dnd_message (f, event, dpyinfo, bufp) - struct frame *f; - XClientMessageEvent *event; - struct x_display_info *dpyinfo; - struct input_event *bufp; +x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_display_info *dpyinfo, struct input_event *bufp) { Lisp_Object vec; Lisp_Object frame; @@ -2842,8 +2524,7 @@ the Atom is sent. If a value is a cons, it is converted to a 32 bit number with the high 16 bits from the car and the lower 16 bit from the cdr. If more values than fits into the event is given, the excessive values are ignored. */) - (display, dest, from, message_type, format, values) - Lisp_Object display, dest, from, message_type, format, values; + (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Lisp_Object message_type, Lisp_Object format, Lisp_Object values) { struct x_display_info *dpyinfo = check_x_display_info (display); Window wdest; @@ -2935,7 +2616,7 @@ are ignored. */) void -syms_of_xselect () +syms_of_xselect (void) { defsubr (&Sx_get_selection_internal); defsubr (&Sx_own_selection_internal); @@ -2943,12 +2624,6 @@ syms_of_xselect () defsubr (&Sx_selection_owner_p); defsubr (&Sx_selection_exists_p); -#ifdef CUT_BUFFER_SUPPORT - defsubr (&Sx_get_cut_buffer_internal); - defsubr (&Sx_store_cut_buffer_internal); - defsubr (&Sx_rotate_cut_buffers_internal); -#endif - defsubr (&Sx_get_atom_name); defsubr (&Sx_send_client_message); defsubr (&Sx_register_dnd_atom); @@ -3010,7 +2685,7 @@ A value of 0 means wait as long as necessary. This is initialized from the \"*selectionTimeout\" resource. */); x_selection_timeout = 0; - QPRIMARY = intern_c_string ("PRIMARY"); staticpro (&QPRIMARY); + /* QPRIMARY is defined in keyboard.c. */ QSECONDARY = intern_c_string ("SECONDARY"); staticpro (&QSECONDARY); QSTRING = intern_c_string ("STRING"); staticpro (&QSTRING); QINTEGER = intern_c_string ("INTEGER"); staticpro (&QINTEGER); @@ -3030,17 +2705,6 @@ A value of 0 means wait as long as necessary. This is initialized from the Qcompound_text_with_extensions = intern_c_string ("compound-text-with-extensions"); staticpro (&Qcompound_text_with_extensions); -#ifdef CUT_BUFFER_SUPPORT - QCUT_BUFFER0 = intern_c_string ("CUT_BUFFER0"); staticpro (&QCUT_BUFFER0); - QCUT_BUFFER1 = intern_c_string ("CUT_BUFFER1"); staticpro (&QCUT_BUFFER1); - QCUT_BUFFER2 = intern_c_string ("CUT_BUFFER2"); staticpro (&QCUT_BUFFER2); - QCUT_BUFFER3 = intern_c_string ("CUT_BUFFER3"); staticpro (&QCUT_BUFFER3); - QCUT_BUFFER4 = intern_c_string ("CUT_BUFFER4"); staticpro (&QCUT_BUFFER4); - QCUT_BUFFER5 = intern_c_string ("CUT_BUFFER5"); staticpro (&QCUT_BUFFER5); - QCUT_BUFFER6 = intern_c_string ("CUT_BUFFER6"); staticpro (&QCUT_BUFFER6); - QCUT_BUFFER7 = intern_c_string ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7); -#endif - Qforeign_selection = intern_c_string ("foreign-selection"); staticpro (&Qforeign_selection); } diff --git a/src/xsettings.c b/src/xsettings.c index 945007db2f0..0d9c9cadb27 100644 --- a/src/xsettings.c +++ b/src/xsettings.c @@ -1,4 +1,4 @@ -/* Functions for handle font changes dynamically. +/* Functions for handle font and other changes dynamically. Copyright (C) 2009, 2010 Free Software Foundation, Inc. @@ -17,7 +17,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" +#include <config.h> +#include <limits.h> #include <setjmp.h> #include <fcntl.h> #include "lisp.h" @@ -39,11 +40,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif static char *current_mono_font; +static char *current_font; static struct x_display_info *first_dpyinfo; -static Lisp_Object Qfont_name, Qfont_render; +static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render, + Qtool_bar_style; static int use_system_font; static Lisp_Object Vxft_settings; - +static Lisp_Object current_tool_bar_style; #ifdef HAVE_GCONF static GConfClient *gconf_client; @@ -51,9 +54,7 @@ static GConfClient *gconf_client; static void -store_font_changed_event (arg, display_name) - Lisp_Object arg; - Lisp_Object display_name; +store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) { struct input_event event; EVENT_INIT (event); @@ -63,19 +64,46 @@ store_font_changed_event (arg, display_name) kbd_buffer_store_event (&event); } +#define XSETTINGS_FONT_NAME "Gtk/FontName" +#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" + +enum { + SEEN_AA = 0x01, + SEEN_HINTING = 0x02, + SEEN_RGBA = 0x04, + SEEN_LCDFILTER = 0x08, + SEEN_HINTSTYLE = 0x10, + SEEN_DPI = 0x20, + SEEN_FONT = 0x40, + SEEN_TB_STYLE = 0x80, +}; +struct xsettings +{ +#ifdef HAVE_XFT + FcBool aa, hinting; + int rgba, lcdfilter, hintstyle; + double dpi; +#endif + + char *font; + char *tb_style; + + unsigned seen; +}; + #ifdef HAVE_GCONF -#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name" +#define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name" +#define SYSTEM_FONT "/desktop/gnome/interface/font_name" /* Callback called when something changed in GConf that we care about, that is SYSTEM_MONO_FONT. */ static void -something_changedCB (client, cnxn_id, entry, user_data) - GConfClient *client; - guint cnxn_id; - GConfEntry *entry; - gpointer user_data; +something_changedCB (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data) { GConfValue *v = gconf_entry_get_value (entry); @@ -83,7 +111,6 @@ something_changedCB (client, cnxn_id, entry, user_data) if (v->type == GCONF_VALUE_STRING) { const char *value = gconf_value_get_string (v); - int i; if (current_mono_font != NULL && strcmp (value, current_mono_font) == 0) return; /* No change. */ @@ -101,8 +128,8 @@ something_changedCB (client, cnxn_id, entry, user_data) found = dpyinfo == first_dpyinfo; if (found && use_system_font) - store_font_changed_event (Qfont_name, - XCAR (first_dpyinfo->name_list_element)); + store_config_changed_event (Qmonospace_font_name, + XCAR (first_dpyinfo->name_list_element)); } } #endif /* HAVE_GCONF */ @@ -120,11 +147,12 @@ something_changedCB (client, cnxn_id, entry, user_data) #define FC_LCD_FILTER "lcdfilter" #endif +#endif /* HAVE_XFT */ + /* Find the window that contains the XSETTINGS property values. */ static void -get_prop_window (dpyinfo) - struct x_display_info *dpyinfo; +get_prop_window (struct x_display_info *dpyinfo) { Display *dpy = dpyinfo->display; @@ -140,23 +168,6 @@ get_prop_window (dpyinfo) XUngrabServer (dpy); } -enum { - SEEN_AA = 0x01, - SEEN_HINTING = 0x02, - SEEN_RGBA = 0x04, - SEEN_LCDFILTER = 0x08, - SEEN_HINTSTYLE = 0x10, - SEEN_DPI = 0x20, -}; -struct xsettings -{ - FcBool aa, hinting; - int rgba, lcdfilter, hintstyle; - double dpi; - - unsigned seen; -}; - #define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000) \ | (((nr) >> 8) & 0xff00) | ((nr) >> 24)) #define SWAP16(nr) (((nr) << 8) | ((nr) >> 8)) @@ -213,10 +224,9 @@ struct xsettings */ static int -parse_xft_settings (prop, bytes, settings) - unsigned char *prop; - unsigned long bytes; - struct xsettings *settings; +parse_settings (unsigned char *prop, + long unsigned int bytes, + struct xsettings *settings) { Lisp_Object byteorder = Fbyteorder (); int my_bo = XFASTINT (byteorder) == 'B' ? MSBFirst : LSBFirst; @@ -235,7 +245,7 @@ parse_xft_settings (prop, bytes, settings) memset (settings, 0, sizeof (*settings)); - while (bytes_parsed+4 < bytes && settings_seen < 6 + while (bytes_parsed+4 < bytes && settings_seen < 7 && i < n_settings) { int type = prop[bytes_parsed++]; @@ -243,7 +253,7 @@ parse_xft_settings (prop, bytes, settings) CARD32 vlen, ival = 0; char name[128]; /* The names we are looking for are not this long. */ char sval[128]; /* The values we are looking for are not this long. */ - int is_xft; + int want_this; int to_cpy; sval[0] = '\0'; @@ -264,13 +274,19 @@ parse_xft_settings (prop, bytes, settings) bytes_parsed += 4; /* Skip serial for this value */ if (bytes_parsed > bytes) return BadLength; - is_xft = nlen > 6 && strncmp (name, "Xft/", 4) == 0; + want_this = +#ifdef HAVE_XFT + (nlen > 6 && strncmp (name, "Xft/", 4) == 0) + || +#endif + (strcmp (XSETTINGS_FONT_NAME, name) == 0) + || (strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0); switch (type) { case 0: /* Integer */ if (bytes_parsed+4 > bytes) return BadLength; - if (is_xft) + if (want_this) { memcpy (&ival, prop+bytes_parsed, 4); if (my_bo != that_bo) ival = SWAP32 (ival); @@ -283,7 +299,7 @@ parse_xft_settings (prop, bytes, settings) memcpy (&vlen, prop+bytes_parsed, 4); bytes_parsed += 4; if (my_bo != that_bo) vlen = SWAP32 (vlen); - if (is_xft) + if (want_this) { to_cpy = vlen > 127 ? 127 : vlen; memcpy (sval, prop+bytes_parsed, to_cpy); @@ -303,10 +319,21 @@ parse_xft_settings (prop, bytes, settings) return BadValue; } - if (is_xft) + if (want_this) { ++settings_seen; - if (strcmp (name, "Xft/Antialias") == 0) + if (strcmp (name, XSETTINGS_FONT_NAME) == 0) + { + settings->font = xstrdup (sval); + settings->seen |= SEEN_FONT; + } + else if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0) + { + settings->tb_style = xstrdup (sval); + settings->seen |= SEEN_TB_STYLE; + } +#ifdef HAVE_XFT + else if (strcmp (name, "Xft/Antialias") == 0) { settings->seen |= SEEN_AA; settings->aa = ival != 0; @@ -361,6 +388,7 @@ parse_xft_settings (prop, bytes, settings) else settings->seen &= ~SEEN_LCDFILTER; } +#endif /* HAVE_XFT */ } } @@ -368,11 +396,8 @@ parse_xft_settings (prop, bytes, settings) } static int -read_xft_settings (dpyinfo, settings) - struct x_display_info *dpyinfo; - struct xsettings *settings; +read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) { - long long_len; Atom act_type; int act_form; unsigned long nitems, bytes_after; @@ -390,7 +415,7 @@ read_xft_settings (dpyinfo, settings) if (rc == Success && prop != NULL && act_form == 8 && nitems > 0 && act_type == dpyinfo->Xatom_xsettings_prop) - rc = parse_xft_settings (prop, nitems, settings); + rc = parse_settings (prop, nitems, settings); XFree (prop); @@ -401,18 +426,16 @@ read_xft_settings (dpyinfo, settings) static void -apply_xft_settings (dpyinfo, send_event_p) - struct x_display_info *dpyinfo; - int send_event_p; +apply_xft_settings (struct x_display_info *dpyinfo, + int send_event_p, + struct xsettings *settings) { +#ifdef HAVE_XFT FcPattern *pat; - struct xsettings settings, oldsettings; + struct xsettings oldsettings; int changed = 0; char buf[256]; - if (!read_xft_settings (dpyinfo, &settings)) - return; - memset (&oldsettings, 0, sizeof (oldsettings)); buf[0] = '\0'; pat = FcPatternCreate (); @@ -426,74 +449,74 @@ apply_xft_settings (dpyinfo, send_event_p) FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba); FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi); - if ((settings.seen & SEEN_AA) != 0 && oldsettings.aa != settings.aa) + if ((settings->seen & SEEN_AA) != 0 && oldsettings.aa != settings->aa) { FcPatternDel (pat, FC_ANTIALIAS); - FcPatternAddBool (pat, FC_ANTIALIAS, settings.aa); + FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa); ++changed; - oldsettings.aa = settings.aa; + oldsettings.aa = settings->aa; } sprintf (buf, "Antialias: %d", oldsettings.aa); - if ((settings.seen & SEEN_HINTING) != 0 - && oldsettings.hinting != settings.hinting) + if ((settings->seen & SEEN_HINTING) != 0 + && oldsettings.hinting != settings->hinting) { FcPatternDel (pat, FC_HINTING); - FcPatternAddBool (pat, FC_HINTING, settings.hinting); + FcPatternAddBool (pat, FC_HINTING, settings->hinting); ++changed; - oldsettings.hinting = settings.hinting; + oldsettings.hinting = settings->hinting; } if (strlen (buf) > 0) strcat (buf, ", "); sprintf (buf+strlen (buf), "Hinting: %d", oldsettings.hinting); - if ((settings.seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings.rgba) + if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba) { FcPatternDel (pat, FC_RGBA); - FcPatternAddInteger (pat, FC_RGBA, settings.rgba); - oldsettings.rgba = settings.rgba; + FcPatternAddInteger (pat, FC_RGBA, settings->rgba); + oldsettings.rgba = settings->rgba; ++changed; } if (strlen (buf) > 0) strcat (buf, ", "); sprintf (buf+strlen (buf), "RGBA: %d", oldsettings.rgba); /* Older fontconfig versions don't have FC_LCD_FILTER. */ - if ((settings.seen & SEEN_LCDFILTER) != 0 - && oldsettings.lcdfilter != settings.lcdfilter) + if ((settings->seen & SEEN_LCDFILTER) != 0 + && oldsettings.lcdfilter != settings->lcdfilter) { FcPatternDel (pat, FC_LCD_FILTER); - FcPatternAddInteger (pat, FC_LCD_FILTER, settings.lcdfilter); + FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter); ++changed; - oldsettings.lcdfilter = settings.lcdfilter; + oldsettings.lcdfilter = settings->lcdfilter; } if (strlen (buf) > 0) strcat (buf, ", "); sprintf (buf+strlen (buf), "LCDFilter: %d", oldsettings.lcdfilter); - if ((settings.seen & SEEN_HINTSTYLE) != 0 - && oldsettings.hintstyle != settings.hintstyle) + if ((settings->seen & SEEN_HINTSTYLE) != 0 + && oldsettings.hintstyle != settings->hintstyle) { FcPatternDel (pat, FC_HINT_STYLE); - FcPatternAddInteger (pat, FC_HINT_STYLE, settings.hintstyle); + FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle); ++changed; - oldsettings.hintstyle = settings.hintstyle; + oldsettings.hintstyle = settings->hintstyle; } if (strlen (buf) > 0) strcat (buf, ", "); sprintf (buf+strlen (buf), "Hintstyle: %d", oldsettings.hintstyle); - if ((settings.seen & SEEN_DPI) != 0 && oldsettings.dpi != settings.dpi - && settings.dpi > 0) + if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi + && settings->dpi > 0) { Lisp_Object frame, tail; FcPatternDel (pat, FC_DPI); - FcPatternAddDouble (pat, FC_DPI, settings.dpi); + FcPatternAddDouble (pat, FC_DPI, settings->dpi); ++changed; - oldsettings.dpi = settings.dpi; + oldsettings.dpi = settings->dpi; /* Change the DPI on this display and all frames on the display. */ - dpyinfo->resy = dpyinfo->resx = settings.dpi; + dpyinfo->resy = dpyinfo->resx = settings->dpi; FOR_EACH_FRAME (tail, frame) if (FRAME_X_P (XFRAME (frame)) && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) - XFRAME (frame)->resy = XFRAME (frame)->resx = settings.dpi; + XFRAME (frame)->resy = XFRAME (frame)->resx = settings->dpi; } if (strlen (buf) > 0) strcat (buf, ", "); @@ -503,23 +526,64 @@ apply_xft_settings (dpyinfo, send_event_p) { XftDefaultSet (dpyinfo->display, pat); if (send_event_p) - store_font_changed_event (Qfont_render, - XCAR (dpyinfo->name_list_element)); + store_config_changed_event (Qfont_render, + XCAR (dpyinfo->name_list_element)); Vxft_settings = make_string (buf, strlen (buf)); } else FcPatternDestroy (pat); +#endif /* HAVE_XFT */ } -#endif /* HAVE_XFT */ +static void +read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p) +{ + struct xsettings settings; + Lisp_Object dpyname = XCAR (dpyinfo->name_list_element); + + if (!read_settings (dpyinfo, &settings)) + return; + + apply_xft_settings (dpyinfo, True, &settings); + if (settings.seen & SEEN_TB_STYLE) + { + Lisp_Object style = Qnil; + if (strcmp (settings.tb_style, "both") == 0) + style = Qboth; + else if (strcmp (settings.tb_style, "both-horiz") == 0) + style = Qboth_horiz; + else if (strcmp (settings.tb_style, "icons") == 0) + style = Qimage; + else if (strcmp (settings.tb_style, "text") == 0) + style = Qtext; + if (!NILP (style) && !EQ (style, current_tool_bar_style)) + { + current_tool_bar_style = style; + if (send_event_p) + store_config_changed_event (Qtool_bar_style, dpyname); + } + free (settings.tb_style); + } + + if (settings.seen & SEEN_FONT) + { + if (!current_font || strcmp (current_font, settings.font) != 0) + { + free (current_font); + current_font = settings.font; + if (send_event_p) + store_config_changed_event (Qfont_name, dpyname); + } + else + free (settings.font); + } +} void -xft_settings_event (dpyinfo, event) - struct x_display_info *dpyinfo; - XEvent *event; +xft_settings_event (struct x_display_info *dpyinfo, XEvent *event) { -#ifdef HAVE_XFT int check_window_p = 0; + int apply_settings = 0; switch (event->type) { @@ -539,28 +603,28 @@ xft_settings_event (dpyinfo, event) if (event->xproperty.window == dpyinfo->xsettings_window && event->xproperty.state == PropertyNewValue && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop) - { - apply_xft_settings (dpyinfo, True); - } + apply_settings = 1; break; } + if (check_window_p) { dpyinfo->xsettings_window = None; get_prop_window (dpyinfo); if (dpyinfo->xsettings_window != None) - apply_xft_settings (dpyinfo, True); + apply_settings = 1; } -#endif /* HAVE_XFT */ + + if (apply_settings) + read_and_apply_settings (dpyinfo, True); } static void -init_gconf () +init_gconf (void) { #if defined (HAVE_GCONF) && defined (HAVE_XFT) - int i; char *s; g_type_init (); @@ -571,6 +635,12 @@ init_gconf () current_mono_font = xstrdup (s); g_free (s); } + s = gconf_client_get_string (gconf_client, SYSTEM_FONT, NULL); + if (s) + { + current_font = xstrdup (s); + g_free (s); + } gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE); gconf_client_add_dir (gconf_client, SYSTEM_MONO_FONT, @@ -584,10 +654,8 @@ init_gconf () } static void -init_xfd_settings (dpyinfo) - struct x_display_info *dpyinfo; +init_xsettings (struct x_display_info *dpyinfo) { -#ifdef HAVE_XFT char sel[64]; Display *dpy = dpyinfo->display; @@ -606,62 +674,94 @@ init_xfd_settings (dpyinfo) get_prop_window (dpyinfo); if (dpyinfo->xsettings_window != None) - apply_xft_settings (dpyinfo, False); + read_and_apply_settings (dpyinfo, False); UNBLOCK_INPUT; - -#else /* ! HAVE_XFT */ - - dpyinfo->Xatom_xsettings_sel = None; - dpyinfo->Xatom_xsettings_prop = None; - dpyinfo->Xatom_xsettings_mgr = None; - dpyinfo->xsettings_window = None; - -#endif /* ! HAVE_XFT */ } void -xsettings_initialize (dpyinfo) - struct x_display_info *dpyinfo; +xsettings_initialize (struct x_display_info *dpyinfo) { if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo; init_gconf (); - init_xfd_settings (dpyinfo); + init_xsettings (dpyinfo); } const char * -xsettings_get_system_font () +xsettings_get_system_font (void) { return current_mono_font; } +const char * +xsettings_get_system_normal_font (void) +{ + return current_font; +} + +DEFUN ("font-get-system-normal-font", Ffont_get_system_normal_font, + Sfont_get_system_normal_font, + 0, 0, 0, + doc: /* Get the system default application font. */) + (void) +{ + return current_font + ? make_string (current_font, strlen (current_font)) + : Qnil; +} + DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font, 0, 0, 0, - doc: /* Get the system default monospaced font. */) - () + doc: /* Get the system default fixed width font. */) + (void) { - return current_mono_font && use_system_font + return current_mono_font ? make_string (current_mono_font, strlen (current_mono_font)) : Qnil; } +DEFUN ("tool-bar-get-system-style", Ftool_bar_get_system_style, Stool_bar_get_system_style, + 0, 0, 0, + doc: /* Get the system tool bar style. +If no system tool bar style is known, return `tool-bar-style' if set to a +known style. Otherwise return image. */) + (void) +{ + if (EQ (Vtool_bar_style, Qimage) + || EQ (Vtool_bar_style, Qtext) + || EQ (Vtool_bar_style, Qboth) + || EQ (Vtool_bar_style, Qboth_horiz) + || EQ (Vtool_bar_style, Qtext_image_horiz)) + return Vtool_bar_style; + if (!NILP (current_tool_bar_style)) + return current_tool_bar_style; + return Qimage; +} + void -syms_of_xsettings () +syms_of_xsettings (void) { current_mono_font = NULL; + current_font = NULL; first_dpyinfo = NULL; #ifdef HAVE_GCONF gconf_client = NULL; #endif + Qmonospace_font_name = intern_c_string ("monospace-font-name"); + staticpro (&Qmonospace_font_name); Qfont_name = intern_c_string ("font-name"); staticpro (&Qfont_name); Qfont_render = intern_c_string ("font-render"); staticpro (&Qfont_render); defsubr (&Sfont_get_system_font); + defsubr (&Sfont_get_system_normal_font); DEFVAR_BOOL ("font-use-system-font", &use_system_font, - doc: /* *Non-nil means to use the system defined font. */); + doc: /* *Non-nil means to apply the system defined font dynamically. +When this is non-nil and the system defined fixed width font changes, we +update frames dynamically. +If this variable is nil, Emacs ignores system font changes. */); use_system_font = 0; DEFVAR_LISP ("xft-settings", &Vxft_settings, @@ -674,6 +774,13 @@ syms_of_xsettings () Fprovide (intern_c_string ("system-font-setting"), Qnil); #endif #endif + + current_tool_bar_style = Qnil; + Qtool_bar_style = intern_c_string ("tool-bar-style"); + staticpro (&Qtool_bar_style); + defsubr (&Stool_bar_get_system_style); + + Fprovide (intern_c_string ("dynamic-setting"), Qnil); } /* arch-tag: 541716ed-2e6b-42e1-8212-3197e01ea61d diff --git a/src/xsettings.h b/src/xsettings.h index 6c603e5bbd9..50819d456c8 100644 --- a/src/xsettings.h +++ b/src/xsettings.h @@ -21,10 +21,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define XSETTINGS_H EXFUN (Ffont_get_system_font, 0); -extern void xsettings_initialize P_ ((struct x_display_info *dpyinfo)); -extern void xft_settings_event P_ ((struct x_display_info *dpyinfo, - XEvent *)); -extern const char *xsettings_get_system_font P_ ((void)); +EXFUN (Ffont_get_system_normal_font, 0); +EXFUN (Ftool_bar_get_system_style, 0); + +extern void xsettings_initialize (struct x_display_info *dpyinfo); +extern void xft_settings_event (struct x_display_info *dpyinfo, + XEvent *); +extern const char *xsettings_get_system_font (void); +extern const char *xsettings_get_system_normal_font (void); #endif /* XSETTINGS_H */ diff --git a/src/xsmfns.c b/src/xsmfns.c index ec5ca3b1a9f..79dccfa55e1 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -42,9 +42,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "termopts.h" #include "xterm.h" -/* The user login name. */ - -extern Lisp_Object Vuser_login_name; +/* Avoid "differ in sign" warnings */ +#define SSDATA(x) ((char *) SDATA (x)) /* This is the event used when SAVE_SESSION_EVENT occurs. */ @@ -88,10 +87,14 @@ Lisp_Object Vx_session_previous_id; /* The option to start Emacs without the splash screen when restarting Emacs. */ -#define NOSPLASH_OPT "--no-splash" +static char NOSPLASH_OPT[] = "--no-splash"; + +/* The option to make Emacs start in the given directory. */ + +#define CHDIR_OPT "--chdir=" static void -ice_connection_closed () +ice_connection_closed (void) { if (ice_fd >= 0) delete_keyboard_wait_descriptor (ice_fd); @@ -104,8 +107,7 @@ ice_connection_closed () Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ int -x_session_check_input (bufp) - struct input_event *bufp; +x_session_check_input (struct input_event *bufp) { SELECT_TYPE read_fds; EMACS_TIME tmout; @@ -148,7 +150,7 @@ x_session_check_input (bufp) /* Check if smc_interact_CB was called and we shall generate a SAVE_SESSION_EVENT. */ if (emacs_event.kind != NO_EVENT) - bcopy (&emacs_event, bufp, sizeof (struct input_event)); + memcpy (bufp, &emacs_event, sizeof (struct input_event)); return emacs_event.kind != NO_EVENT ? 1 : 0; } @@ -156,7 +158,7 @@ x_session_check_input (bufp) /* Return non-zero if we have a connection to a session manager. */ int -x_session_have_connection () +x_session_have_connection (void) { return ice_fd != -1; } @@ -166,9 +168,7 @@ x_session_have_connection () Then lisp code can interact with the user. */ static void -smc_interact_CB (smcConn, clientData) - SmcConn smcConn; - SmPointer clientData; +smc_interact_CB (SmcConn smcConn, SmPointer clientData) { doing_interact = True; emacs_event.kind = SAVE_SESSION_EVENT; @@ -183,18 +183,12 @@ smc_interact_CB (smcConn, clientData) we do so, because we don't know what the lisp code might do. */ static void -smc_save_yourself_CB (smcConn, - clientData, - saveType, - shutdown, - interactStyle, - fast) - SmcConn smcConn; - SmPointer clientData; - int saveType; - Bool shutdown; - int interactStyle; - Bool fast; +smc_save_yourself_CB (SmcConn smcConn, + SmPointer clientData, + int saveType, + Bool shutdown, + int interactStyle, + Bool fast) { #define NR_PROPS 5 @@ -204,14 +198,14 @@ smc_save_yourself_CB (smcConn, SmPropValue values[20]; int val_idx = 0; int props_idx = 0; - + int i; char *cwd = NULL; - char *smid_opt; + char *smid_opt, *chdir_opt = NULL; /* How to start a new instance of Emacs. */ props[props_idx] = &prop_ptr[props_idx]; - props[props_idx]->name = SmCloneCommand; - props[props_idx]->type = SmLISTofARRAY8; + props[props_idx]->name = xstrdup (SmCloneCommand); + props[props_idx]->type = xstrdup (SmLISTofARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; props[props_idx]->vals[0].length = strlen (emacs_program); @@ -220,19 +214,20 @@ smc_save_yourself_CB (smcConn, /* The name of the program. */ props[props_idx] = &prop_ptr[props_idx]; - props[props_idx]->name = SmProgram; - props[props_idx]->type = SmARRAY8; + props[props_idx]->name = xstrdup (SmProgram); + props[props_idx]->type = xstrdup (SmARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; - props[props_idx]->vals[0].length = strlen (SDATA (Vinvocation_name)); + props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name)); props[props_idx]->vals[0].value = SDATA (Vinvocation_name); ++props_idx; - /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ + /* How to restart Emacs. */ props[props_idx] = &prop_ptr[props_idx]; - props[props_idx]->name = SmRestartCommand; - props[props_idx]->type = SmLISTofARRAY8; - props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ + props[props_idx]->name = xstrdup (SmRestartCommand); + props[props_idx]->type = xstrdup (SmLISTofARRAY8); + /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */ + props[props_idx]->num_vals = 4; props[props_idx]->vals = &values[val_idx]; props[props_idx]->vals[0].length = strlen (emacs_program); props[props_idx]->vals[0].value = emacs_program; @@ -246,26 +241,37 @@ smc_save_yourself_CB (smcConn, props[props_idx]->vals[2].length = strlen (NOSPLASH_OPT); props[props_idx]->vals[2].value = NOSPLASH_OPT; - val_idx += 3; + + cwd = get_current_dir_name (); + if (cwd) + { + chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1); + strcpy (chdir_opt, CHDIR_OPT); + strcat (chdir_opt, cwd); + + props[props_idx]->vals[3].length = strlen (chdir_opt); + props[props_idx]->vals[3].value = chdir_opt; + } + + val_idx += cwd ? 4 : 3; ++props_idx; /* User id. */ props[props_idx] = &prop_ptr[props_idx]; - props[props_idx]->name = SmUserID; - props[props_idx]->type = SmARRAY8; + props[props_idx]->name = xstrdup (SmUserID); + props[props_idx]->type = xstrdup (SmARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; - props[props_idx]->vals[0].length = strlen (SDATA (Vuser_login_name)); + props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name)); props[props_idx]->vals[0].value = SDATA (Vuser_login_name); ++props_idx; - cwd = get_current_dir_name (); if (cwd) { props[props_idx] = &prop_ptr[props_idx]; - props[props_idx]->name = SmCurrentDirectory; - props[props_idx]->type = SmARRAY8; + props[props_idx]->name = xstrdup (SmCurrentDirectory); + props[props_idx]->type = xstrdup (SmARRAY8); props[props_idx]->num_vals = 1; props[props_idx]->vals = &values[val_idx++]; props[props_idx]->vals[0].length = strlen (cwd); @@ -277,8 +283,14 @@ smc_save_yourself_CB (smcConn, SmcSetProperties (smcConn, props_idx, props); xfree (smid_opt); + xfree (chdir_opt); free (cwd); + for (i = 0; i < props_idx; ++i) + { + xfree (props[i]->type); + xfree (props[i]->name); + } /* See if we maybe shall interact with the user. */ if (interactStyle != SmInteractStyleAny @@ -294,9 +306,7 @@ smc_save_yourself_CB (smcConn, /* According to the SM specification, this shall close the connection. */ static void -smc_die_CB (smcConn, clientData) - SmcConn smcConn; - SmPointer clientData; +smc_die_CB (SmcConn smcConn, SmPointer clientData) { SmcCloseConnection (smcConn, 0, 0); ice_connection_closed (); @@ -309,17 +319,13 @@ smc_die_CB (smcConn, clientData) even seem necessary. */ static void -smc_save_complete_CB (smcConn, clientData) - SmcConn smcConn; - SmPointer clientData; +smc_save_complete_CB (SmcConn smcConn, SmPointer clientData) { /* Empty */ } static void -smc_shutdown_cancelled_CB (smcConn, clientData) - SmcConn smcConn; - SmPointer clientData; +smc_shutdown_cancelled_CB (SmcConn smcConn, SmPointer clientData) { /* Empty */ } @@ -328,47 +334,32 @@ smc_shutdown_cancelled_CB (smcConn, clientData) because there is some error in the session management. */ static void -smc_error_handler (smcConn, - swap, - offendingMinorOpcode, - offendingSequence, - errorClass, - severity, - values) - SmcConn smcConn; - Bool swap; - int offendingMinorOpcode; - unsigned long offendingSequence; - int errorClass; - int severity; - SmPointer values; +smc_error_handler (SmcConn smcConn, + Bool swap, + int offendingMinorOpcode, + unsigned long offendingSequence, + int errorClass, + int severity, + SmPointer values) { /* Empty */ } static void -ice_error_handler (iceConn, - swap, - offendingMinorOpcode, - offendingSequence, - errorClass, - severity, - values) - IceConn iceConn; - Bool swap; - int offendingMinorOpcode; - unsigned long offendingSequence; - int errorClass; - int severity; - IcePointer values; +ice_error_handler (IceConn iceConn, + Bool swap, + int offendingMinorOpcode, + unsigned long offendingSequence, + int errorClass, + int severity, + IcePointer values) { /* Empty */ } static void -ice_io_error_handler (iceConn) - IceConn iceConn; +ice_io_error_handler (IceConn iceConn) { /* Connection probably gone. */ ice_connection_closed (); @@ -378,11 +369,7 @@ ice_io_error_handler (iceConn) uses ICE as it transport protocol. */ static void -ice_conn_watch_CB (iceConn, clientData, opening, watchData) - IceConn iceConn; - IcePointer clientData; - Bool opening; - IcePointer *watchData; +ice_conn_watch_CB (IceConn iceConn, IcePointer clientData, int opening, IcePointer *watchData) { if (! opening) { @@ -405,10 +392,9 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData) /* Create the client leader window. */ +#ifndef USE_GTK static void -create_client_leader_window (dpyinfo, client_id) - struct x_display_info *dpyinfo; - char *client_id; +create_client_leader_window (struct x_display_info *dpyinfo, char *client_id) { Window w; XClassHint class_hints; @@ -426,16 +412,17 @@ create_client_leader_window (dpyinfo, client_id) sm_id = XInternAtom (dpyinfo->display, "SM_CLIENT_ID", False); XChangeProperty (dpyinfo->display, w, sm_id, XA_STRING, 8, PropModeReplace, - client_id, strlen (client_id)); + (unsigned char *)client_id, strlen (client_id)); dpyinfo->client_leader_window = w; } +#endif /* ! USE_GTK */ + /* Try to open a connection to the session manager. */ void -x_session_initialize (dpyinfo) - struct x_display_info *dpyinfo; +x_session_initialize (struct x_display_info *dpyinfo) { #define SM_ERRORSTRING_LEN 512 char errorstring[SM_ERRORSTRING_LEN]; @@ -449,12 +436,12 @@ x_session_initialize (dpyinfo) /* Check if we where started by the session manager. If so, we will have a previous id. */ if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) - previous_id = SDATA (Vx_session_previous_id); + previous_id = SSDATA (Vx_session_previous_id); /* Construct the path to the Emacs program. */ if (! EQ (Vinvocation_directory, Qnil)) - name_len += strlen (SDATA (Vinvocation_directory)); - name_len += strlen (SDATA (Vinvocation_name)); + name_len += strlen (SSDATA (Vinvocation_directory)); + name_len += strlen (SSDATA (Vinvocation_name)); /* This malloc will not be freed, but it is only done once, and hopefully not very large */ @@ -462,8 +449,8 @@ x_session_initialize (dpyinfo) emacs_program[0] = '\0'; if (! EQ (Vinvocation_directory, Qnil)) - strcpy (emacs_program, SDATA (Vinvocation_directory)); - strcat (emacs_program, SDATA (Vinvocation_name)); + strcpy (emacs_program, SSDATA (Vinvocation_directory)); + strcat (emacs_program, SSDATA (Vinvocation_name)); /* The SM protocol says all callbacks are mandatory, so set up all here and in the mask passed to SmcOpenConnection. */ @@ -515,7 +502,7 @@ x_session_initialize (dpyinfo) /* Ensure that the session manager is not contacted again. */ void -x_session_close () +x_session_close (void) { ice_connection_closed (); } @@ -533,8 +520,7 @@ from `emacs-session-save' If the return value is non-nil the session manager is told to abort the window system shutdown. Do not call this function yourself. */) - (event) - Lisp_Object event; + (Lisp_Object event) { /* Check doing_interact so that we don't do anything if someone called this at the wrong time. */ @@ -558,7 +544,7 @@ Do not call this function yourself. */) Initialization ***********************************************************************/ void -syms_of_xsmfns () +syms_of_xsmfns (void) { DEFVAR_LISP ("x-session-id", &Vx_session_id, doc: /* The session id Emacs got from the session manager for this session. diff --git a/src/xterm.c b/src/xterm.c index 1fee90754fc..d9d908d4396 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -22,11 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* Xt features made by Fred Pierresteguy. */ #include <config.h> - -/* On 4.3 these lose if they come after xterm.h. */ -/* Putting these at the beginning seems to be standard for other .c files. */ #include <signal.h> - #include <stdio.h> #include <setjmp.h> @@ -50,15 +46,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <sys/types.h> #endif /* makedev */ -#ifdef BSD_SYSTEM +#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> -#endif /* ! defined (BSD_SYSTEM) */ +#endif /* ! defined (HAVE_SYS_IOCTL_H) */ #include "systime.h" -#ifndef INCLUDED_FCNTL #include <fcntl.h> -#endif #include <ctype.h> #include <errno.h> #include <setjmp.h> @@ -106,13 +100,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif #ifdef USE_LUCID -extern int xlwmenu_window_p P_ ((Widget w, Window window)); -extern void xlwmenu_redisplay P_ ((Widget)); -#endif - -#if defined (USE_X_TOOLKIT) || defined (USE_GTK) - -extern void free_frame_menubar P_ ((struct frame *)); +#include "../lwlib/xlwmenu.h" #endif #ifdef USE_X_TOOLKIT @@ -296,25 +284,6 @@ static int input_signal_count; static int x_noop_count; -/* Initial values of argv and argc. */ - -extern char **initial_argv; -extern int initial_argc; - -extern Lisp_Object Vcommand_line_args, Vsystem_name; - -/* Tells if a window manager is present or not. */ - -extern Lisp_Object Vx_no_window_manager; - -extern Lisp_Object Qeql; - -extern int errno; - -/* A mask of extra modifier bits to put into every keyboard char. */ - -extern EMACS_INT extra_keyboard_modifiers; - /* The keysyms to use for the various modifiers. */ Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym; @@ -332,65 +301,66 @@ static Lisp_Object xg_default_icon_file; Lisp_Object Qx_gtk_map_stock; #endif +/* Some functions take this as char *, not const char *. */ +static char emacs_class[] = EMACS_CLASS; + /* Used in x_flush. */ -extern Lisp_Object Vinhibit_redisplay; - -extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); -extern int x_bitmap_mask P_ ((FRAME_PTR, int)); - -static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *)); -static void x_set_window_size_1 P_ ((struct frame *, int, int, int)); -static const XColor *x_color_cells P_ ((Display *, int *)); -static void x_update_window_end P_ ((struct window *, int, int)); - -static int x_io_error_quitter P_ ((Display *)); -static struct terminal *x_create_terminal P_ ((struct x_display_info *)); -void x_delete_terminal P_ ((struct terminal *)); -static void x_update_end P_ ((struct frame *)); -static void XTframe_up_to_date P_ ((struct frame *)); -static void XTset_terminal_modes P_ ((struct terminal *)); -static void XTreset_terminal_modes P_ ((struct terminal *)); -static void x_clear_frame P_ ((struct frame *)); -static void frame_highlight P_ ((struct frame *)); -static void frame_unhighlight P_ ((struct frame *)); -static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); -static void x_focus_changed P_ ((int, int, struct x_display_info *, - struct frame *, struct input_event *)); -static void x_detect_focus_change P_ ((struct x_display_info *, - XEvent *, struct input_event *)); -static void XTframe_rehighlight P_ ((struct frame *)); -static void x_frame_rehighlight P_ ((struct x_display_info *)); -static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); -static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, - enum text_cursor_kinds)); - -static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC)); -static void x_flush P_ ((struct frame *f)); -static void x_update_begin P_ ((struct frame *)); -static void x_update_window_begin P_ ((struct window *)); -static void x_after_update_window_line P_ ((struct glyph_row *)); -static struct scroll_bar *x_window_to_scroll_bar P_ ((Display *, Window)); -static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *, - enum scroll_bar_part *, - Lisp_Object *, Lisp_Object *, - unsigned long *)); -static void x_handle_net_wm_state P_ ((struct frame *, XPropertyEvent *)); -static void x_check_fullscreen P_ ((struct frame *)); -static void x_check_expected_move P_ ((struct frame *, int, int)); -static void x_sync_with_move P_ ((struct frame *, int, int, int)); -static int handle_one_xevent P_ ((struct x_display_info *, XEvent *, - int *, struct input_event *)); +extern XrmDatabase x_load_resources (Display *, const char *, const char *, + const char *); +extern int x_bitmap_mask (FRAME_PTR, int); + +static int x_alloc_nearest_color_1 (Display *, Colormap, XColor *); +static void x_set_window_size_1 (struct frame *, int, int, int); +static const XColor *x_color_cells (Display *, int *); +static void x_update_window_end (struct window *, int, int); + +static int x_io_error_quitter (Display *); +static struct terminal *x_create_terminal (struct x_display_info *); +void x_delete_terminal (struct terminal *); +static void x_update_end (struct frame *); +static void XTframe_up_to_date (struct frame *); +static void XTset_terminal_modes (struct terminal *); +static void XTreset_terminal_modes (struct terminal *); +static void x_clear_frame (struct frame *); +static void frame_highlight (struct frame *); +static void frame_unhighlight (struct frame *); +static void x_new_focus_frame (struct x_display_info *, struct frame *); +static void x_focus_changed (int, int, struct x_display_info *, + struct frame *, struct input_event *); +static void x_detect_focus_change (struct x_display_info *, + XEvent *, struct input_event *); +static void XTframe_rehighlight (struct frame *); +static void x_frame_rehighlight (struct x_display_info *); +static void x_draw_hollow_cursor (struct window *, struct glyph_row *); +static void x_draw_bar_cursor (struct window *, struct glyph_row *, int, + enum text_cursor_kinds); + +static void x_clip_to_row (struct window *, struct glyph_row *, int, GC); +static void x_flush (struct frame *f); +static void x_update_begin (struct frame *); +static void x_update_window_begin (struct window *); +static void x_after_update_window_line (struct glyph_row *); +static struct scroll_bar *x_window_to_scroll_bar (Display *, Window); +static void x_scroll_bar_report_motion (struct frame **, Lisp_Object *, + enum scroll_bar_part *, + Lisp_Object *, Lisp_Object *, + unsigned long *); +static void x_handle_net_wm_state (struct frame *, XPropertyEvent *); +static void x_check_fullscreen (struct frame *); +static void x_check_expected_move (struct frame *, int, int); +static void x_sync_with_move (struct frame *, int, int, int); +static int handle_one_xevent (struct x_display_info *, XEvent *, + int *, struct input_event *); /* Don't declare this NO_RETURN because we want no interference with debugging failing X calls. */ -static SIGTYPE x_connection_closed P_ ((Display *, char *)); +static SIGTYPE x_connection_closed (Display *, const char *); /* Flush display of frame F, or of all frames if F is null. */ static void -x_flush (f) - struct frame *f; +x_flush (struct frame *f) { /* Don't call XFlush when it is not safe to redisplay; the X connection may be broken. */ @@ -459,8 +429,7 @@ record_event (locus, type) /* Return the struct x_display_info corresponding to DPY. */ struct x_display_info * -x_display_info_for_display (dpy) - Display *dpy; +x_display_info_for_display (Display *dpy) { struct x_display_info *dpyinfo; @@ -475,8 +444,7 @@ x_display_info_for_display (dpy) #define OPACITY "_NET_WM_WINDOW_OPACITY" void -x_set_frame_alpha (f) - struct frame *f; +x_set_frame_alpha (struct frame *f) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Display *dpy = FRAME_X_DISPLAY (f); @@ -488,7 +456,7 @@ x_set_frame_alpha (f) if (FRAME_X_DISPLAY_INFO (f)->root_window != FRAME_X_OUTPUT (f)->parent_desc) /* Since the WM decoration lies under the FRAME_OUTER_WINDOW, we must treat the former instead of the latter. */ - win = FRAME_X_OUTPUT(f)->parent_desc; + win = FRAME_X_OUTPUT (f)->parent_desc; if (dpyinfo->x_highlight_frame == f) alpha = f->alpha[0]; @@ -517,10 +485,10 @@ x_set_frame_alpha (f) unsigned long n, left; x_catch_errors (dpy); - rc = XGetWindowProperty(dpy, win, XInternAtom(dpy, OPACITY, False), - 0L, 1L, False, XA_CARDINAL, - &actual, &format, &n, &left, - &data); + rc = XGetWindowProperty (dpy, win, XInternAtom(dpy, OPACITY, False), + 0L, 1L, False, XA_CARDINAL, + &actual, &format, &n, &left, + &data); if (rc == Success && actual != None) if (*(unsigned long *)data == opac) @@ -542,15 +510,13 @@ x_set_frame_alpha (f) } int -x_display_pixel_height (dpyinfo) - struct x_display_info *dpyinfo; +x_display_pixel_height (struct x_display_info *dpyinfo) { return HeightOfScreen (dpyinfo->screen); } int -x_display_pixel_width (dpyinfo) - struct x_display_info *dpyinfo; +x_display_pixel_width (struct x_display_info *dpyinfo) { return WidthOfScreen (dpyinfo->screen); } @@ -567,8 +533,7 @@ x_display_pixel_width (dpyinfo) because all interesting stuff is done on a window basis. */ static void -x_update_begin (f) - struct frame *f; +x_update_begin (struct frame *f) { /* Nothing to do. */ } @@ -579,8 +544,7 @@ x_update_begin (f) position of W. */ static void -x_update_window_begin (w) - struct window *w; +x_update_window_begin (struct window *w) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f); @@ -608,9 +572,7 @@ x_update_window_begin (w) /* Draw a vertical window border from (x,y0) to (x,y1) */ static void -x_draw_vertical_window_border (w, x, y0, y1) - struct window *w; - int x, y0, y1; +x_draw_vertical_window_border (struct window *w, int x, int y0, int y1) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct face *face; @@ -638,9 +600,7 @@ x_draw_vertical_window_border (w, x, y0, y1) here. */ static void -x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) - struct window *w; - int cursor_on_p, mouse_face_overwritten_p; +x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); @@ -676,8 +636,7 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) update_end. */ static void -x_update_end (f) - struct frame *f; +x_update_end (struct frame *f) { /* Mouse highlight may be displayed again. */ FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0; @@ -695,8 +654,7 @@ x_update_end (f) updated_window is not available here. */ static void -XTframe_up_to_date (f) - struct frame *f; +XTframe_up_to_date (struct frame *f) { if (FRAME_X_P (f)) { @@ -725,8 +683,7 @@ XTframe_up_to_date (f) between bitmaps to be drawn between current row and DESIRED_ROW. */ static void -x_after_update_window_line (desired_row) - struct glyph_row *desired_row; +x_after_update_window_line (struct glyph_row *desired_row) { struct window *w = updated_window; struct frame *f; @@ -764,10 +721,7 @@ x_after_update_window_line (desired_row) } static void -x_draw_fringe_bitmap (w, row, p) - struct window *w; - struct glyph_row *row; - struct draw_fringe_bitmap_params *p; +x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fringe_bitmap_params *p) { struct frame *f = XFRAME (WINDOW_FRAME (w)); Display *display = FRAME_X_DISPLAY (f); @@ -920,37 +874,37 @@ XTreset_terminal_modes (struct terminal *terminal) -static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); -static void x_set_glyph_string_gc P_ ((struct glyph_string *)); -static void x_draw_glyph_string_background P_ ((struct glyph_string *, - int)); -static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); -static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); -static void x_draw_glyph_string_box P_ ((struct glyph_string *)); -static void x_draw_glyph_string P_ ((struct glyph_string *)); -static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *)); -static void x_set_cursor_gc P_ ((struct glyph_string *)); -static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); -static void x_set_mouse_face_gc P_ ((struct glyph_string *)); -static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap, - unsigned long *, double, int)); -static void x_setup_relief_color P_ ((struct frame *, struct relief *, - double, int, unsigned long)); -static void x_setup_relief_colors P_ ((struct glyph_string *)); -static void x_draw_image_glyph_string P_ ((struct glyph_string *)); -static void x_draw_image_relief P_ ((struct glyph_string *)); -static void x_draw_image_foreground P_ ((struct glyph_string *)); -static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap)); -static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, - int, int, int)); -static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, - int, int, int, int, int, int, - XRectangle *)); -static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, - int, int, int, XRectangle *)); +static void x_set_glyph_string_clipping (struct glyph_string *); +static void x_set_glyph_string_gc (struct glyph_string *); +static void x_draw_glyph_string_background (struct glyph_string *, + int); +static void x_draw_glyph_string_foreground (struct glyph_string *); +static void x_draw_composite_glyph_string_foreground (struct glyph_string *); +static void x_draw_glyph_string_box (struct glyph_string *); +static void x_draw_glyph_string (struct glyph_string *); +static void x_compute_glyph_string_overhangs (struct glyph_string *); +static void x_set_cursor_gc (struct glyph_string *); +static void x_set_mode_line_face_gc (struct glyph_string *); +static void x_set_mouse_face_gc (struct glyph_string *); +static int x_alloc_lighter_color (struct frame *, Display *, Colormap, + unsigned long *, double, int); +static void x_setup_relief_color (struct frame *, struct relief *, + double, int, unsigned long); +static void x_setup_relief_colors (struct glyph_string *); +static void x_draw_image_glyph_string (struct glyph_string *); +static void x_draw_image_relief (struct glyph_string *); +static void x_draw_image_foreground (struct glyph_string *); +static void x_draw_image_foreground_1 (struct glyph_string *, Pixmap); +static void x_clear_glyph_string_rect (struct glyph_string *, int, + int, int, int); +static void x_draw_relief_rect (struct frame *, int, int, int, int, + int, int, int, int, int, int, + XRectangle *); +static void x_draw_box_rect (struct glyph_string *, int, int, int, int, + int, int, int, XRectangle *); #if GLYPH_DEBUG -static void x_check_font P_ ((struct frame *, struct font *)); +static void x_check_font (struct frame *, struct font *); #endif @@ -958,8 +912,7 @@ static void x_check_font P_ ((struct frame *, struct font *)); face. */ static void -x_set_cursor_gc (s) - struct glyph_string *s; +x_set_cursor_gc (struct glyph_string *s) { if (s->font == FRAME_FONT (s->f) && s->face->background == FRAME_BACKGROUND_PIXEL (s->f) @@ -1010,8 +963,7 @@ x_set_cursor_gc (s) /* Set up S->gc of glyph string S for drawing text in mouse face. */ static void -x_set_mouse_face_gc (s) - struct glyph_string *s; +x_set_mouse_face_gc (struct glyph_string *s) { int face_id; struct face *face; @@ -1062,8 +1014,7 @@ x_set_mouse_face_gc (s) matrix was built, so there isn't much to do, here. */ static INLINE void -x_set_mode_line_face_gc (s) - struct glyph_string *s; +x_set_mode_line_face_gc (struct glyph_string *s) { s->gc = s->face->gc; } @@ -1074,8 +1025,7 @@ x_set_mode_line_face_gc (s) pattern. */ static INLINE void -x_set_glyph_string_gc (s) - struct glyph_string *s; +x_set_glyph_string_gc (struct glyph_string *s) { PREPARE_FACE_FOR_DISPLAY (s->f, s->face); @@ -1120,8 +1070,7 @@ x_set_glyph_string_gc (s) line or menu if we don't have X toolkit support. */ static INLINE void -x_set_glyph_string_clipping (s) - struct glyph_string *s; +x_set_glyph_string_clipping (struct glyph_string *s) { XRectangle *r = s->clip; int n = get_glyph_string_clip_rects (s, r, 2); @@ -1137,8 +1086,7 @@ x_set_glyph_string_clipping (s) the area of SRC. */ static void -x_set_glyph_string_clipping_exactly (src, dst) - struct glyph_string *src, *dst; +x_set_glyph_string_clipping_exactly (struct glyph_string *src, struct glyph_string *dst) { XRectangle r; @@ -1156,8 +1104,7 @@ x_set_glyph_string_clipping_exactly (src, dst) Compute left and right overhang of glyph string S. */ static void -x_compute_glyph_string_overhangs (s) - struct glyph_string *s; +x_compute_glyph_string_overhangs (struct glyph_string *s) { if (s->cmp == NULL && (s->first_glyph->type == CHAR_GLYPH @@ -1196,9 +1143,7 @@ x_compute_glyph_string_overhangs (s) /* Fill rectangle X, Y, W, H with background color of glyph string S. */ static INLINE void -x_clear_glyph_string_rect (s, x, y, w, h) - struct glyph_string *s; - int x, y, w, h; +x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) { XGCValues xgcv; XGetGCValues (s->display, s->gc, GCForeground | GCBackground, &xgcv); @@ -1215,9 +1160,7 @@ x_clear_glyph_string_rect (s, x, y, w, h) contains the first component of a composition. */ static void -x_draw_glyph_string_background (s, force_p) - struct glyph_string *s; - int force_p; +x_draw_glyph_string_background (struct glyph_string *s, int force_p) { /* Nothing to do if background has already been drawn or if it shouldn't be drawn in the first place. */ @@ -1253,8 +1196,7 @@ x_draw_glyph_string_background (s, force_p) /* Draw the foreground of glyph string S. */ static void -x_draw_glyph_string_foreground (s) - struct glyph_string *s; +x_draw_glyph_string_foreground (struct glyph_string *s) { int i, x; @@ -1302,8 +1244,7 @@ x_draw_glyph_string_foreground (s) /* Draw the foreground of composite glyph string S. */ static void -x_draw_composite_glyph_string_foreground (s) - struct glyph_string *s; +x_draw_composite_glyph_string_foreground (struct glyph_string *s) { int i, j, x; struct font *font = s->font; @@ -1390,19 +1331,18 @@ x_draw_composite_glyph_string_foreground (s) #ifdef USE_X_TOOLKIT -static struct frame *x_frame_of_widget P_ ((Widget)); -static Boolean cvt_string_to_pixel P_ ((Display *, XrmValue *, Cardinal *, - XrmValue *, XrmValue *, XtPointer *)); -static void cvt_pixel_dtor P_ ((XtAppContext, XrmValue *, XtPointer, - XrmValue *, Cardinal *)); +static struct frame *x_frame_of_widget (Widget); +static Boolean cvt_string_to_pixel (Display *, XrmValue *, Cardinal *, + XrmValue *, XrmValue *, XtPointer *); +static void cvt_pixel_dtor (XtAppContext, XrmValue *, XtPointer, + XrmValue *, Cardinal *); /* Return the frame on which widget WIDGET is used.. Abort if frame cannot be determined. */ static struct frame * -x_frame_of_widget (widget) - Widget widget; +x_frame_of_widget (Widget widget) { struct x_display_info *dpyinfo; Lisp_Object tail; @@ -1438,10 +1378,7 @@ x_frame_of_widget (widget) if successful. This is called from lwlib. */ int -x_alloc_nearest_color_for_widget (widget, cmap, color) - Widget widget; - Colormap cmap; - XColor *color; +x_alloc_nearest_color_for_widget (Widget widget, Colormap cmap, XColor *color) { struct frame *f = x_frame_of_widget (widget); return x_alloc_nearest_color (f, cmap, color); @@ -1456,13 +1393,8 @@ x_alloc_nearest_color_for_widget (widget, cmap, color) Value is non-zero if successful. */ int -x_alloc_lighter_color_for_widget (widget, display, cmap, pixel, factor, delta) - Widget widget; - Display *display; - Colormap cmap; - unsigned long *pixel; - double factor; - int delta; +x_alloc_lighter_color_for_widget (Widget widget, Display *display, Colormap cmap, + unsigned long *pixel, double factor, int delta) { struct frame *f = x_frame_of_widget (widget); return x_alloc_lighter_color (f, display, cmap, pixel, factor, delta); @@ -1505,12 +1437,9 @@ static Pixel cvt_string_to_pixel_value; Value is True if successful, False otherwise. */ static Boolean -cvt_string_to_pixel (dpy, args, nargs, from, to, closure_ret) - Display *dpy; - XrmValue *args; - Cardinal *nargs; - XrmValue *from, *to; - XtPointer *closure_ret; +cvt_string_to_pixel (Display *dpy, XrmValue *args, Cardinal *nargs, + XrmValue *from, XrmValue *to, + XtPointer *closure_ret) { Screen *screen; Colormap cmap; @@ -1594,12 +1523,8 @@ cvt_string_to_pixel (dpy, args, nargs, from, to, closure_ret) ARGS and NARGS are like for cvt_string_to_pixel. */ static void -cvt_pixel_dtor (app, to, closure, args, nargs) - XtAppContext app; - XrmValuePtr to; - XtPointer closure; - XrmValuePtr args; - Cardinal *nargs; +cvt_pixel_dtor (XtAppContext app, XrmValuePtr to, XtPointer closure, XrmValuePtr args, + Cardinal *nargs) { if (*nargs != 2) { @@ -1628,9 +1553,7 @@ cvt_pixel_dtor (app, to, closure, args, nargs) say a 24-bit TrueColor map. */ static const XColor * -x_color_cells (dpy, ncells) - Display *dpy; - int *ncells; +x_color_cells (Display *dpy, int *ncells) { struct x_display_info *dpyinfo = x_display_info_for_display (dpy); @@ -1661,10 +1584,7 @@ x_color_cells (dpy, ncells) colors in COLORS. Use cached information, if available. */ void -x_query_colors (f, colors, ncolors) - struct frame *f; - XColor *colors; - int ncolors; +x_query_colors (struct frame *f, XColor *colors, int ncolors) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -1688,9 +1608,7 @@ x_query_colors (f, colors, ncolors) COLOR. Use cached information, if available. */ void -x_query_color (f, color) - struct frame *f; - XColor *color; +x_query_color (struct frame *f, XColor *color) { x_query_colors (f, color, 1); } @@ -1702,10 +1620,7 @@ x_query_color (f, color) allocated. */ static int -x_alloc_nearest_color_1 (dpy, cmap, color) - Display *dpy; - Colormap cmap; - XColor *color; +x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color) { int rc; @@ -1775,10 +1690,7 @@ x_alloc_nearest_color_1 (dpy, cmap, color) allocated. */ int -x_alloc_nearest_color (f, cmap, color) - struct frame *f; - Colormap cmap; - XColor *color; +x_alloc_nearest_color (struct frame *f, Colormap cmap, XColor *color) { gamma_correct (f, color); return x_alloc_nearest_color_1 (FRAME_X_DISPLAY (f), cmap, color); @@ -1790,9 +1702,7 @@ x_alloc_nearest_color (f, cmap, color) get color reference counts right. */ unsigned long -x_copy_color (f, pixel) - struct frame *f; - unsigned long pixel; +x_copy_color (struct frame *f, long unsigned int pixel) { XColor color; @@ -1813,10 +1723,7 @@ x_copy_color (f, pixel) get color reference counts right. */ unsigned long -x_copy_dpy_color (dpy, cmap, pixel) - Display *dpy; - Colormap cmap; - unsigned long pixel; +x_copy_dpy_color (Display *dpy, Colormap cmap, long unsigned int pixel) { XColor color; @@ -1854,13 +1761,7 @@ x_copy_dpy_color (dpy, cmap, pixel) Value is non-zero if successful. */ static int -x_alloc_lighter_color (f, display, cmap, pixel, factor, delta) - struct frame *f; - Display *display; - Colormap cmap; - unsigned long *pixel; - double factor; - int delta; +x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long unsigned int *pixel, double factor, int delta) { XColor color, new; long bright; @@ -1936,12 +1837,7 @@ x_alloc_lighter_color (f, display, cmap, pixel, factor, delta) be allocated, use DEFAULT_PIXEL, instead. */ static void -x_setup_relief_color (f, relief, factor, delta, default_pixel) - struct frame *f; - struct relief *relief; - double factor; - int delta; - unsigned long default_pixel; +x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int delta, long unsigned int default_pixel) { XGCValues xgcv; struct x_output *di = f->output_data.x; @@ -1989,8 +1885,7 @@ x_setup_relief_color (f, relief, factor, delta, default_pixel) /* Set up colors for the relief lines around glyph string S. */ static void -x_setup_relief_colors (s) - struct glyph_string *s; +x_setup_relief_colors (struct glyph_string *s) { struct x_output *di = s->f->output_data.x; unsigned long color; @@ -2031,12 +1926,10 @@ x_setup_relief_colors (s) when drawing. */ static void -x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, - raised_p, top_p, bot_p, left_p, right_p, clip_rect) - struct frame *f; - int left_x, top_y, right_x, bottom_y, width; - int top_p, bot_p, left_p, right_p, raised_p; - XRectangle *clip_rect; +x_draw_relief_rect (struct frame *f, + int left_x, int top_y, int right_x, int bottom_y, int width, + int raised_p, int top_p, int bot_p, int left_p, int right_p, + XRectangle *clip_rect) { Display *dpy = FRAME_X_DISPLAY (f); Window window = FRAME_X_WINDOW (f); @@ -2049,18 +1942,38 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, gc = f->output_data.x->black_relief.gc; XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); + /* This code is more complicated than it has to be, because of two + minor hacks to make the boxes look nicer: (i) if width > 1, draw + the outermost line using the black relief. (ii) Omit the four + corner pixels. */ + /* Top. */ if (top_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - left_x + i * left_p, top_y + i, - right_x + 1 - i * right_p, top_y + i); + { + if (width == 1) + XDrawLine (dpy, window, gc, + left_x + (left_p ? 1 : 0), top_y, + right_x + (right_p ? 0 : 1), top_y); + + for (i = 1; i < width; ++i) + XDrawLine (dpy, window, gc, + left_x + i * left_p, top_y + i, + right_x + 1 - i * right_p, top_y + i); + } /* Left. */ if (left_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - left_x + i, top_y + i, left_x + i, bottom_y - i + 1); + { + if (width == 1) + XDrawLine (dpy, window, gc, left_x, top_y + 1, left_x, bottom_y); + + XClearArea (dpy, window, left_x, top_y, 1, 1, False); + XClearArea (dpy, window, left_x, bottom_y, 1, 1, False); + + for (i = (width > 1 ? 1 : 0); i < width; ++i) + XDrawLine (dpy, window, gc, + left_x + i, top_y + i, left_x + i, bottom_y - i + 1); + } XSetClipMask (dpy, gc, None); if (raised_p) @@ -2069,18 +1982,40 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, gc = f->output_data.x->white_relief.gc; XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); + if (width > 1) + { + /* Outermost top line. */ + if (top_p) + XDrawLine (dpy, window, gc, + left_x + (left_p ? 1 : 0), top_y, + right_x + (right_p ? 0 : 1), top_y); + + /* Outermost left line. */ + if (left_p) + XDrawLine (dpy, window, gc, left_x, top_y + 1, left_x, bottom_y); + } + /* Bottom. */ if (bot_p) - for (i = 0; i < width; ++i) + { XDrawLine (dpy, window, gc, - left_x + i * left_p, bottom_y - i, - right_x + 1 - i * right_p, bottom_y - i); + left_x + (left_p ? 1 : 0), bottom_y, + right_x + (right_p ? 0 : 1), bottom_y); + for (i = 1; i < width; ++i) + XDrawLine (dpy, window, gc, + left_x + i * left_p, bottom_y - i, + right_x + 1 - i * right_p, bottom_y - i); + } /* Right. */ if (right_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - right_x - i, top_y + i + 1, right_x - i, bottom_y - i); + { + XClearArea (dpy, window, right_x, top_y, 1, 1, False); + XClearArea (dpy, window, right_x, bottom_y, 1, 1, False); + for (i = 0; i < width; ++i) + XDrawLine (dpy, window, gc, + right_x - i, top_y + i + 1, right_x - i, bottom_y - i); + } XSetClipMask (dpy, gc, None); } @@ -2094,11 +2029,9 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, rectangle to use when drawing. */ static void -x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, - left_p, right_p, clip_rect) - struct glyph_string *s; - int left_x, top_y, right_x, bottom_y, width, left_p, right_p; - XRectangle *clip_rect; +x_draw_box_rect (struct glyph_string *s, + int left_x, int top_y, int right_x, int bottom_y, int width, + int left_p, int right_p, XRectangle *clip_rect) { XGCValues xgcv; @@ -2132,8 +2065,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, /* Draw a box around glyph string S. */ static void -x_draw_glyph_string_box (s) - struct glyph_string *s; +x_draw_glyph_string_box (struct glyph_string *s) { int width, left_x, right_x, top_y, bottom_y, last_x, raised_p; int left_p, right_p; @@ -2184,8 +2116,7 @@ x_draw_glyph_string_box (s) /* Draw foreground of image glyph string S. */ static void -x_draw_image_foreground (s) - struct glyph_string *s; +x_draw_image_foreground (struct glyph_string *s) { int x = s->x; int y = s->ybase - image_ascent (s->img, s->face, &s->slice); @@ -2275,10 +2206,9 @@ x_draw_image_foreground (s) /* Draw a relief around the image glyph string S. */ static void -x_draw_image_relief (s) - struct glyph_string *s; +x_draw_image_relief (struct glyph_string *s) { - int x0, y0, x1, y1, thick, raised_p; + int x0, y0, x1, y1, thick, raised_p, extra; XRectangle r; int x = s->x; int y = s->ybase - image_ascent (s->img, s->face, &s->slice); @@ -2309,10 +2239,13 @@ x_draw_image_relief (s) raised_p = s->img->relief > 0; } - x0 = x - thick; - y0 = y - thick; - x1 = x + s->slice.width + thick - 1; - y1 = y + s->slice.height + thick - 1; + extra = s->face->id == TOOL_BAR_FACE_ID + ? XINT (Vtool_bar_button_margin) : 0; + + x0 = x - thick - extra; + y0 = y - thick - extra; + x1 = x + s->slice.width + thick - 1 + extra; + y1 = y + s->slice.height + thick - 1 + extra; x_setup_relief_colors (s); get_glyph_string_clip_rect (s, &r); @@ -2328,9 +2261,7 @@ x_draw_image_relief (s) /* Draw the foreground of image glyph string S to PIXMAP. */ static void -x_draw_image_foreground_1 (s, pixmap) - struct glyph_string *s; - Pixmap pixmap; +x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) { int x = 0; int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice); @@ -2406,9 +2337,7 @@ x_draw_image_foreground_1 (s, pixmap) give the rectangle to draw. */ static void -x_draw_glyph_string_bg_rect (s, x, y, w, h) - struct glyph_string *s; - int x, y, w, h; +x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int h) { if (s->stippled_p) { @@ -2437,8 +2366,7 @@ x_draw_glyph_string_bg_rect (s, x, y, w, h) */ static void -x_draw_image_glyph_string (s) - struct glyph_string *s; +x_draw_image_glyph_string (struct glyph_string *s) { int box_line_hwidth = eabs (s->face->box_line_width); int box_line_vwidth = max (s->face->box_line_width, 0); @@ -2542,25 +2470,41 @@ x_draw_image_glyph_string (s) /* Draw stretch glyph string S. */ static void -x_draw_stretch_glyph_string (s) - struct glyph_string *s; +x_draw_stretch_glyph_string (struct glyph_string *s) { xassert (s->first_glyph->type == STRETCH_GLYPH); if (s->hl == DRAW_CURSOR && !x_stretch_cursor_p) { - /* If `x-stretch-block-cursor' is nil, don't draw a block cursor - as wide as the stretch glyph. */ + /* If `x-stretch-cursor' is nil, don't draw a block cursor as + wide as the stretch glyph. */ int width, background_width = s->background_width; - int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA); + int x = s->x; - if (x < left_x) + if (!s->row->reversed_p) { - background_width -= left_x - x; - x = left_x; + int left_x = window_box_left_offset (s->w, TEXT_AREA); + + if (x < left_x) + { + background_width -= left_x - x; + x = left_x; + } + } + else + { + /* In R2L rows, draw the cursor on the right edge of the + stretch glyph. */ + int right_x = window_box_right_offset (s->w, TEXT_AREA); + + if (x + background_width > right_x) + background_width -= x - right_x; + x += background_width; } width = min (FRAME_COLUMN_WIDTH (s->f), background_width); + if (s->row->reversed_p) + x -= width; /* Draw cursor. */ x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height); @@ -2573,7 +2517,10 @@ x_draw_stretch_glyph_string (s) XRectangle r; GC gc; - x += width; + if (!s->row->reversed_p) + x += width; + else + x = s->x; if (s->row->mouse_face_p && cursor_in_mouse_face_p (s->w)) { @@ -2626,8 +2573,7 @@ x_draw_stretch_glyph_string (s) /* Draw glyph string S. */ static void -x_draw_glyph_string (s) - struct glyph_string *s; +x_draw_glyph_string (struct glyph_string *s) { int relief_drawn_p = 0; @@ -2881,9 +2827,7 @@ x_draw_glyph_string (s) /* Shift display to make room for inserted glyphs. */ void -x_shift_glyphs_for_insert (f, x, y, width, height, shift_by) - struct frame *f; - int x, y, width, height, shift_by; +x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height, int shift_by) { XCopyArea (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), FRAME_X_WINDOW (f), f->output_data.x->normal_gc, @@ -2895,9 +2839,7 @@ x_shift_glyphs_for_insert (f, x, y, width, height, shift_by) for X frames. */ static void -x_delete_glyphs (f, n) - struct frame *f; - register int n; +x_delete_glyphs (struct frame *f, register int n) { abort (); } @@ -2907,12 +2849,7 @@ x_delete_glyphs (f, n) If they are <= 0, this is probably an error. */ void -x_clear_area (dpy, window, x, y, width, height, exposures) - Display *dpy; - Window window; - int x, y; - int width, height; - int exposures; +x_clear_area (Display *dpy, Window window, int x, int y, int width, int height, int exposures) { xassert (width > 0 && height > 0); XClearArea (dpy, window, x, y, width, height, exposures); @@ -2942,9 +2879,10 @@ x_clear_frame (struct frame *f) #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) /* Make sure scroll bars are redrawn. As they aren't redrawn by redisplay, do it here. */ - gtk_widget_queue_draw (FRAME_GTK_WIDGET (f)); + if (FRAME_GTK_WIDGET (f)) + gtk_widget_queue_draw (FRAME_GTK_WIDGET (f)); #endif - + XFlush (FRAME_X_DISPLAY (f)); UNBLOCK_INPUT; @@ -2964,8 +2902,7 @@ x_clear_frame (struct frame *f) *RESULT. Return 1 if the difference is negative, otherwise 0. */ static int -timeval_subtract (result, x, y) - struct timeval *result, x, y; +timeval_subtract (struct timeval *result, struct timeval x, struct timeval y) { /* Perform the carry for the later subtraction by updating y. This is safer because on some systems the tv_sec member is unsigned. */ @@ -2994,8 +2931,7 @@ timeval_subtract (result, x, y) } void -XTflash (f) - struct frame *f; +XTflash (struct frame *f) { BLOCK_INPUT; @@ -3003,18 +2939,16 @@ XTflash (f) #ifdef USE_GTK /* Use Gdk routines to draw. This way, we won't draw over scroll bars when the scroll bars and the edit widget share the same X window. */ + GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); GdkGCValues vals; GdkGC *gc; vals.foreground.pixel = (FRAME_FOREGROUND_PIXEL (f) ^ FRAME_BACKGROUND_PIXEL (f)); vals.function = GDK_XOR; - gc = gdk_gc_new_with_values (FRAME_GTK_WIDGET (f)->window, - &vals, - GDK_GC_FUNCTION - | GDK_GC_FOREGROUND); + gc = gdk_gc_new_with_values (window, + &vals, GDK_GC_FUNCTION | GDK_GC_FOREGROUND); #define XFillRectangle(d, win, gc, x, y, w, h) \ - gdk_draw_rectangle (FRAME_GTK_WIDGET (f)->window, \ - gc, TRUE, x, y, w, h) + gdk_draw_rectangle (window, gc, TRUE, x, y, w, h) #else GC gc; @@ -3152,12 +3086,10 @@ XTflash (f) static void -XTtoggle_invisible_pointer (f, invisible) - FRAME_PTR f; - int invisible; +XTtoggle_invisible_pointer (FRAME_PTR f, int invisible) { BLOCK_INPUT; - if (invisible) + if (invisible) { if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0) XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), @@ -3174,10 +3106,8 @@ XTtoggle_invisible_pointer (f, invisible) /* Make audible bell. */ void -XTring_bell () +XTring_bell (struct frame *f) { - struct frame *f = SELECTED_FRAME (); - if (FRAME_X_DISPLAY (f)) { #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) @@ -3201,8 +3131,7 @@ XTring_bell () that is bounded by calls to x_update_begin and x_update_end. */ static void -XTset_terminal_window (n) - register int n; +XTset_terminal_window (struct frame *f, int n) { /* This function intentionally left blank. */ } @@ -3217,9 +3146,7 @@ XTset_terminal_window (n) lines or deleting -N lines at vertical position VPOS. */ static void -x_ins_del_lines (f, vpos, n) - struct frame *f; - int vpos, n; +x_ins_del_lines (struct frame *f, int vpos, int n) { abort (); } @@ -3228,9 +3155,7 @@ x_ins_del_lines (f, vpos, n) /* Scroll part of the display as described by RUN. */ static void -x_scroll_run (w, run) - struct window *w; - struct run *run; +x_scroll_run (struct window *w, struct run *run) { struct frame *f = XFRAME (w->frame); int x, y, width, height, from_y, to_y, bottom_y; @@ -3287,8 +3212,7 @@ x_scroll_run (w, run) static void -frame_highlight (f) - struct frame *f; +frame_highlight (struct frame *f) { /* We used to only do this if Vx_no_window_manager was non-nil, but the ICCCM (section 4.1.6) says that the window's border pixmap @@ -3303,8 +3227,7 @@ frame_highlight (f) } static void -frame_unhighlight (f) - struct frame *f; +frame_unhighlight (struct frame *f) { /* We used to only do this if Vx_no_window_manager was non-nil, but the ICCCM (section 4.1.6) says that the window's border pixmap @@ -3325,9 +3248,7 @@ frame_unhighlight (f) Lisp code can tell when the switch took place by examining the events. */ static void -x_new_focus_frame (dpyinfo, frame) - struct x_display_info *dpyinfo; - struct frame *frame; +x_new_focus_frame (struct x_display_info *dpyinfo, struct frame *frame) { struct frame *old_focus = dpyinfo->x_focus_frame; @@ -3354,12 +3275,7 @@ x_new_focus_frame (dpyinfo, frame) a FOCUS_IN_EVENT into *BUFP. */ static void -x_focus_changed (type, state, dpyinfo, frame, bufp) - int type; - int state; - struct x_display_info *dpyinfo; - struct frame *frame; - struct input_event *bufp; +x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct frame *frame, struct input_event *bufp) { if (type == FocusIn) { @@ -3411,10 +3327,7 @@ x_focus_changed (type, state, dpyinfo, frame, bufp) Returns FOCUS_IN_EVENT event in *BUFP. */ static void -x_detect_focus_change (dpyinfo, event, bufp) - struct x_display_info *dpyinfo; - XEvent *event; - struct input_event *bufp; +x_detect_focus_change (struct x_display_info *dpyinfo, XEvent *event, struct input_event *bufp) { struct frame *frame; @@ -3463,8 +3376,7 @@ x_detect_focus_change (dpyinfo, event, bufp) /* Handle an event saying the mouse has moved out of an Emacs frame. */ void -x_mouse_leave (dpyinfo) - struct x_display_info *dpyinfo; +x_mouse_leave (struct x_display_info *dpyinfo) { x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame); } @@ -3478,15 +3390,13 @@ x_mouse_leave (dpyinfo) the appropriate X display info. */ static void -XTframe_rehighlight (frame) - struct frame *frame; +XTframe_rehighlight (struct frame *frame) { x_frame_rehighlight (FRAME_X_DISPLAY_INFO (frame)); } static void -x_frame_rehighlight (dpyinfo) - struct x_display_info *dpyinfo; +x_frame_rehighlight (struct x_display_info *dpyinfo) { struct frame *old_highlight = dpyinfo->x_highlight_frame; @@ -3520,8 +3430,7 @@ x_frame_rehighlight (dpyinfo) /* Initialize mode_switch_bit and modifier_meaning. */ static void -x_find_modifier_meanings (dpyinfo) - struct x_display_info *dpyinfo; +x_find_modifier_meanings (struct x_display_info *dpyinfo) { int min_code, max_code; KeySym *syms; @@ -3632,9 +3541,7 @@ x_find_modifier_meanings (dpyinfo) Emacs uses. */ unsigned int -x_x_to_emacs_modifiers (dpyinfo, state) - struct x_display_info *dpyinfo; - unsigned int state; +x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state) { EMACS_UINT mod_meta = meta_modifier; EMACS_UINT mod_alt = alt_modifier; @@ -3661,9 +3568,7 @@ x_x_to_emacs_modifiers (dpyinfo, state) } static unsigned int -x_emacs_to_x_modifiers (dpyinfo, state) - struct x_display_info *dpyinfo; - unsigned int state; +x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, unsigned int state) { EMACS_UINT mod_meta = meta_modifier; EMACS_UINT mod_alt = alt_modifier; @@ -3693,8 +3598,7 @@ x_emacs_to_x_modifiers (dpyinfo, state) /* Convert a keysym to its name. */ char * -x_get_keysym_name (keysym) - KeySym keysym; +x_get_keysym_name (int keysym) { char *value; @@ -3715,10 +3619,7 @@ x_get_keysym_name (keysym) the mouse. */ static Lisp_Object -construct_mouse_click (result, event, f) - struct input_event *result; - XButtonEvent *event; - struct frame *f; +construct_mouse_click (struct input_event *result, XButtonEvent *event, struct frame *f) { /* Make the event type NO_EVENT; we'll change that when we decide otherwise. */ @@ -3751,9 +3652,7 @@ static XMotionEvent last_mouse_motion_event; static Lisp_Object last_mouse_motion_frame; static int -note_mouse_movement (frame, event) - FRAME_PTR frame; - XMotionEvent *event; +note_mouse_movement (FRAME_PTR frame, XMotionEvent *event) { last_mouse_movement_time = event->time; last_mouse_motion_event = *event; @@ -3797,7 +3696,7 @@ note_mouse_movement (frame, event) ************************************************************************/ static void -redo_mouse_highlight () +redo_mouse_highlight (void) { if (!NILP (last_mouse_motion_frame) && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame))) @@ -3829,13 +3728,7 @@ redo_mouse_highlight () movement. */ static void -XTmouse_position (fp, insist, bar_window, part, x, y, time) - FRAME_PTR *fp; - int insist; - Lisp_Object *bar_window; - enum scroll_bar_part *part; - Lisp_Object *x, *y; - unsigned long *time; +XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) { FRAME_PTR f1; @@ -4037,9 +3930,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) bits. */ static struct scroll_bar * -x_window_to_scroll_bar (display, window_id) - Display *display; - Window window_id; +x_window_to_scroll_bar (Display *display, Window window_id) { Lisp_Object tail; @@ -4084,8 +3975,7 @@ x_window_to_scroll_bar (display, window_id) if WINDOW is not part of a menu bar. */ static Widget -x_window_to_menu_bar (window) - Window window; +x_window_to_menu_bar (Window window) { Lisp_Object tail; @@ -4113,12 +4003,12 @@ x_window_to_menu_bar (window) #ifdef USE_TOOLKIT_SCROLL_BARS -static void x_scroll_bar_to_input_event P_ ((XEvent *, struct input_event *)); -static void x_send_scroll_bar_event P_ ((Lisp_Object, int, int, int)); -static void x_create_toolkit_scroll_bar P_ ((struct frame *, - struct scroll_bar *)); -static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, - int, int, int)); +static void x_scroll_bar_to_input_event (XEvent *, struct input_event *); +static void x_send_scroll_bar_event (Lisp_Object, int, int, int); +static void x_create_toolkit_scroll_bar (struct frame *, + struct scroll_bar *); +static void x_set_toolkit_scroll_bar_thumb (struct scroll_bar *, + int, int, int); /* Lisp window being scrolled. Set when starting to interact with @@ -4152,17 +4042,11 @@ static Boolean xaw3d_pick_top; a `end-scroll' SCROLL_BAR_CLICK_EVENT' event if so. */ static void -xt_action_hook (widget, client_data, action_name, event, params, - num_params) - Widget widget; - XtPointer client_data; - String action_name; - XEvent *event; - String *params; - Cardinal *num_params; +xt_action_hook (Widget widget, XtPointer client_data, String action_name, + XEvent *event, String *params, Cardinal *num_params) { int scroll_bar_p; - char *end_action; + const char *end_action; #ifdef USE_MOTIF scroll_bar_p = XmIsScrollBar (widget); @@ -4210,9 +4094,7 @@ static int scroll_bar_windows_size; amount to scroll of a whole of WHOLE. */ static void -x_send_scroll_bar_event (window, part, portion, whole) - Lisp_Object window; - int part, portion, whole; +x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) { XEvent event; XClientMessageEvent *ev = (XClientMessageEvent *) &event; @@ -4245,7 +4127,7 @@ x_send_scroll_bar_event (window, part, portion, whole) scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, nbytes); - bzero (&scroll_bar_windows[i], nbytes - old_nbytes); + memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); scroll_bar_windows_size = new_size; } @@ -4274,9 +4156,7 @@ x_send_scroll_bar_event (window, part, portion, whole) in *IEVENT. */ static void -x_scroll_bar_to_input_event (event, ievent) - XEvent *event; - struct input_event *ievent; +x_scroll_bar_to_input_event (XEvent *event, struct input_event *ievent) { XClientMessageEvent *ev = (XClientMessageEvent *) event; Lisp_Object window; @@ -4317,9 +4197,7 @@ x_scroll_bar_to_input_event (event, ievent) CALL_DATA is a pointer to a XmScrollBarCallbackStruct. */ static void -xm_scroll_callback (widget, client_data, call_data) - Widget widget; - XtPointer client_data, call_data; +xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data) { struct scroll_bar *bar = (struct scroll_bar *) client_data; XmScrollBarCallbackStruct *cs = (XmScrollBarCallbackStruct *) call_data; @@ -4414,7 +4292,8 @@ xg_scroll_callback (GtkRange *range, && FRAME_X_DISPLAY_INFO (f)->grabbed < (1 << 4)) { part = scroll_bar_handle; - whole = adj->upper - adj->page_size; + whole = gtk_adjustment_get_upper (adj) - + gtk_adjustment_get_page_size (adj); portion = min ((int)position, whole); bar->dragging = make_number ((int)portion); } @@ -4475,9 +4354,7 @@ xg_end_scroll_callback (GtkWidget *widget, the thumb is. */ static void -xaw_jump_callback (widget, client_data, call_data) - Widget widget; - XtPointer client_data, call_data; +xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data) { struct scroll_bar *bar = (struct scroll_bar *) client_data; float top = *(float *) call_data; @@ -4519,9 +4396,7 @@ xaw_jump_callback (widget, client_data, call_data) Values < height of scroll bar mean line-wise movement. */ static void -xaw_scroll_callback (widget, client_data, call_data) - Widget widget; - XtPointer client_data, call_data; +xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data) { struct scroll_bar *bar = (struct scroll_bar *) client_data; /* The position really is stored cast to a pointer. */ @@ -4559,11 +4434,9 @@ xaw_scroll_callback (widget, client_data, call_data) #ifdef USE_GTK static void -x_create_toolkit_scroll_bar (f, bar) - struct frame *f; - struct scroll_bar *bar; +x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) { - char *scroll_bar_name = SCROLL_BAR_NAME; + const char *scroll_bar_name = SCROLL_BAR_NAME; BLOCK_INPUT; xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), @@ -4575,9 +4448,7 @@ x_create_toolkit_scroll_bar (f, bar) #else /* not USE_GTK */ static void -x_create_toolkit_scroll_bar (f, bar) - struct frame *f; - struct scroll_bar *bar; +x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar) { Window xwindow; Widget widget; @@ -4670,7 +4541,7 @@ x_create_toolkit_scroll_bar (f, bar) if (f->output_data.x->scroll_bar_top_shadow_pixel == -1) { pixel = f->output_data.x->scroll_bar_background_pixel; - if (pixel != -1) + if (pixel != -1) { if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), @@ -4682,7 +4553,7 @@ x_create_toolkit_scroll_bar (f, bar) if (f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) { pixel = f->output_data.x->scroll_bar_background_pixel; - if (pixel != -1) + if (pixel != -1) { if (!x_alloc_lighter_color (f, FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), @@ -4698,8 +4569,11 @@ x_create_toolkit_scroll_bar (f, bar) || f->output_data.x->scroll_bar_bottom_shadow_pixel == -1) /* We tried to allocate a color for the top/bottom shadow, and failed, so tell Xaw3d to use dithering instead. */ + /* But only if we have a small colormap. Xaw3d can allocate nice + colors itself. */ { - XtSetArg (av[ac], XtNbeNiceToColormap, True); + XtSetArg (av[ac], XtNbeNiceToColormap, + DefaultDepthOfScreen (FRAME_X_SCREEN (f)) < 16); ++ac; } else @@ -4777,18 +4651,15 @@ x_create_toolkit_scroll_bar (f, bar) #ifdef USE_GTK static void -x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) - struct scroll_bar *bar; - int portion, position, whole; +x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, int whole) { xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); } #else /* not USE_GTK */ static void -x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) - struct scroll_bar *bar; - int portion, position, whole; +x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int position, + int whole) { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); @@ -4903,9 +4774,7 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) scroll bar. */ static struct scroll_bar * -x_scroll_bar_create (w, top, left, width, height) - struct window *w; - int top, left, width, height; +x_scroll_bar_create (struct window *w, int top, int left, int width, int height) { struct frame *f = XFRAME (w->frame); struct scroll_bar *bar @@ -4984,7 +4853,6 @@ x_scroll_bar_create (w, top, left, width, height) left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, max (height, 1)); - xg_show_scroll_bar (bar->x_window); #else /* not USE_GTK */ Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); XtConfigureWidget (scroll_bar, @@ -5020,10 +4888,7 @@ x_scroll_bar_create (w, top, left, width, height) to move to the very end of the buffer. */ static void -x_scroll_bar_set_handle (bar, start, end, rebuild) - struct scroll_bar *bar; - int start, end; - int rebuild; +x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild) { int dragging = ! NILP (bar->dragging); Window w = bar->x_window; @@ -5121,8 +4986,7 @@ x_scroll_bar_set_handle (bar, start, end, rebuild) nil. */ static void -x_scroll_bar_remove (bar) - struct scroll_bar *bar; +x_scroll_bar_remove (struct scroll_bar *bar) { struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); BLOCK_INPUT; @@ -5150,9 +5014,7 @@ x_scroll_bar_remove (bar) create one. */ static void -XTset_vertical_scroll_bar (w, portion, whole, position) - struct window *w; - int portion, whole, position; +XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int position) { struct frame *f = XFRAME (w->frame); struct scroll_bar *bar; @@ -5369,8 +5231,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) `*redeem_scroll_bar_hook' is applied to its window before the judgment. */ static void -XTcondemn_scroll_bars (frame) - FRAME_PTR frame; +XTcondemn_scroll_bars (FRAME_PTR frame) { /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */ while (! NILP (FRAME_SCROLL_BARS (frame))) @@ -5391,8 +5252,7 @@ XTcondemn_scroll_bars (frame) Note that WINDOW isn't necessarily condemned at all. */ static void -XTredeem_scroll_bar (window) - struct window *window; +XTredeem_scroll_bar (struct window *window) { struct scroll_bar *bar; struct frame *f; @@ -5437,8 +5297,7 @@ XTredeem_scroll_bar (window) last call to `*condemn_scroll_bars_hook'. */ static void -XTjudge_scroll_bars (f) - FRAME_PTR f; +XTjudge_scroll_bars (FRAME_PTR f) { Lisp_Object bar, next; @@ -5471,9 +5330,7 @@ XTjudge_scroll_bars (f) mark bits. */ static void -x_scroll_bar_expose (bar, event) - struct scroll_bar *bar; - XEvent *event; +x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event) { Window w = bar->x_window; FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); @@ -5515,10 +5372,7 @@ x_scroll_bar_expose (bar, event) static void -x_scroll_bar_handle_click (bar, event, emacs_event) - struct scroll_bar *bar; - XEvent *event; - struct input_event *emacs_event; +x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) { if (! WINDOWP (bar->window)) abort (); @@ -5576,9 +5430,7 @@ x_scroll_bar_handle_click (bar, event, emacs_event) mark bits. */ static void -x_scroll_bar_note_movement (bar, event) - struct scroll_bar *bar; - XEvent *event; +x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) { FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame); @@ -5608,12 +5460,7 @@ x_scroll_bar_note_movement (bar, event) on the scroll bar. */ static void -x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) - FRAME_PTR *fp; - Lisp_Object *bar_window; - enum scroll_bar_part *part; - Lisp_Object *x, *y; - unsigned long *time; +x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, long unsigned int *time) { struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); Window w = bar->x_window; @@ -5685,8 +5532,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) redraw them. */ void -x_scroll_bar_clear (f) - FRAME_PTR f; +x_scroll_bar_clear (FRAME_PTR f) { #ifndef USE_TOOLKIT_SCROLL_BARS Lisp_Object bar; @@ -5739,22 +5585,18 @@ struct x_display_info *XTread_socket_fake_io_error; static struct x_display_info *next_noop_dpyinfo; -#define SET_SAVED_MENU_EVENT(size) \ +#define SET_SAVED_BUTTON_EVENT \ do \ { \ if (f->output_data.x->saved_menu_event == 0) \ f->output_data.x->saved_menu_event \ = (XEvent *) xmalloc (sizeof (XEvent)); \ - bcopy (&event, f->output_data.x->saved_menu_event, size); \ + *f->output_data.x->saved_menu_event = event; \ inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \ XSETFRAME (inev.ie.frame_or_window, f); \ } \ while (0) -#define SET_SAVED_BUTTON_EVENT SET_SAVED_MENU_EVENT (sizeof (XButtonEvent)) -#define SET_SAVED_KEY_EVENT SET_SAVED_MENU_EVENT (sizeof (XKeyEvent)) - - enum { X_EVENT_NORMAL, @@ -5772,9 +5614,7 @@ enum #ifdef HAVE_X_I18N static int -x_filter_event (dpyinfo, event) - struct x_display_info *dpyinfo; - XEvent *event; +x_filter_event (struct x_display_info *dpyinfo, XEvent *event) { /* XFilterEvent returns non-zero if the input method has consumed the event. We pass the frame's X window to @@ -5797,10 +5637,7 @@ static struct input_event *current_hold_quit; It is invoked before the XEvent is translated to a GdkEvent, so we have a chance to act on the event before GTK. */ static GdkFilterReturn -event_handler_gdk (gxev, ev, data) - GdkXEvent *gxev; - GdkEvent *ev; - gpointer data; +event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data) { XEvent *xev = (XEvent *) gxev; @@ -5853,11 +5690,7 @@ event_handler_gdk (gxev, ev, data) We return the number of characters stored into the buffer. */ static int -handle_one_xevent (dpyinfo, eventp, finish, hold_quit) - struct x_display_info *dpyinfo; - XEvent *eventp; - int *finish; - struct input_event *hold_quit; +handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish, struct input_event *hold_quit) { union { struct input_event ie; @@ -5875,10 +5708,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) EVENT_INIT (inev.ie); inev.ie.kind = NO_EVENT; inev.ie.arg = Qnil; - + if (pending_event_wait.eventtype == event.type) pending_event_wait.eventtype = 0; /* Indicates we got it. */ - + switch (event.type) { case ClientMessage: @@ -6391,7 +6224,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) this enables ComposeCharacter to work whether or not it is combined with Meta. */ if (modifiers & dpyinfo->meta_mod_mask) - bzero (&compose_status, sizeof (compose_status)); + memset (&compose_status, 0, sizeof (compose_status)); #ifdef HAVE_X_I18N if (FRAME_XIC (f)) @@ -6439,7 +6272,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) if (compose_status.chars_matched > 0 && nbytes == 0) break; - bzero (&compose_status, sizeof (compose_status)); + memset (&compose_status, 0, sizeof (compose_status)); orig_keysym = keysym; /* Common for all keysym input events. */ @@ -6798,7 +6631,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) event.xconfigure.height); f = 0; } -#endif +#endif if (f) { #ifndef USE_X_TOOLKIT @@ -6832,7 +6665,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) /* GTK creates windows but doesn't map them. Only get real positions when mapped. */ if (FRAME_GTK_OUTER_WIDGET (f) - && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) + && gtk_widget_get_mapped (FRAME_GTK_OUTER_WIDGET (f))) #endif { x_real_positions (f, &f->left_pos, &f->top_pos); @@ -6853,7 +6686,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) by the rest of Emacs, we put it here. */ int tool_bar_p = 0; - bzero (&compose_status, sizeof (compose_status)); + memset (&compose_status, 0, sizeof (compose_status)); last_mouse_glyph_frame = 0; last_user_time = event.xbutton.time; @@ -6957,14 +6790,12 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) Instead, save it away and we will pass it to Xt from kbd_buffer_get_event. That way, we can run some Lisp code first. */ - if ( + if (! popup_activated () #ifdef USE_GTK - ! popup_activated () /* Gtk+ menus only react to the first three buttons. */ && event.xbutton.button < 3 - && #endif - f && event.type == ButtonPress + && f && event.type == ButtonPress /* Verify the event is really within the menu bar and not just sent to it due to grabbing. */ && event.xbutton.x >= 0 @@ -6975,30 +6806,13 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) { SET_SAVED_BUTTON_EVENT; XSETFRAME (last_mouse_press_frame, f); -#ifdef USE_GTK *finish = X_EVENT_DROP; -#endif } else if (event.type == ButtonPress) { last_mouse_press_frame = Qnil; goto OTHER; } - -#ifdef USE_MOTIF /* This should do not harm for Lucid, - but I am trying to be cautious. */ - else if (event.type == ButtonRelease) - { - if (!NILP (last_mouse_press_frame)) - { - f = XFRAME (last_mouse_press_frame); - if (f->output_data.x) - SET_SAVED_BUTTON_EVENT; - } - else - goto OTHER; - } -#endif /* USE_MOTIF */ else goto OTHER; #endif /* USE_X_TOOLKIT || USE_GTK */ @@ -7084,9 +6898,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) Returns the value handle_one_xevent sets in the finish argument. */ int -x_dispatch_event (event, display) - XEvent *event; - Display *display; +x_dispatch_event (XEvent *event, Display *display) { struct x_display_info *dpyinfo; int finish = X_EVENT_NORMAL; @@ -7112,10 +6924,7 @@ x_dispatch_event (event, display) EXPECTED is nonzero if the caller knows input is available. */ static int -XTread_socket (terminal, expected, hold_quit) - struct terminal *terminal; - int expected; - struct input_event *hold_quit; +XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) { int count = 0; XEvent event; @@ -7266,11 +7075,7 @@ XTread_socket (terminal, expected, hold_quit) mode lines must be clipped to the whole window. */ static void -x_clip_to_row (w, row, area, gc) - struct window *w; - struct glyph_row *row; - int area; - GC gc; +x_clip_to_row (struct window *w, struct glyph_row *row, int area, GC gc) { struct frame *f = XFRAME (WINDOW_FRAME (w)); XRectangle clip_rect; @@ -7291,9 +7096,7 @@ x_clip_to_row (w, row, area, gc) /* Draw a hollow box cursor on window W in glyph row ROW. */ static void -x_draw_hollow_cursor (w, row) - struct window *w; - struct glyph_row *row; +x_draw_hollow_cursor (struct window *w, struct glyph_row *row) { struct frame *f = XFRAME (WINDOW_FRAME (w)); struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -7338,11 +7141,7 @@ x_draw_hollow_cursor (w, row) --gerd. */ static void -x_draw_bar_cursor (w, row, width, kind) - struct window *w; - struct glyph_row *row; - int width; - enum text_cursor_kinds kind; +x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text_cursor_kinds kind) { struct frame *f = XFRAME (w->frame); struct glyph *cursor_glyph; @@ -7395,14 +7194,20 @@ x_draw_bar_cursor (w, row, width, kind) if (kind == BAR_CURSOR) { + int x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); + if (width < 0) width = FRAME_CURSOR_WIDTH (f); width = min (cursor_glyph->pixel_width, width); w->phys_cursor_width = width; - XFillRectangle (dpy, window, gc, - WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), + /* If the character under cursor is R2L, draw the bar cursor + on the right of its glyph, rather than on the left. */ + if ((cursor_glyph->resolved_level & 1) != 0) + x += cursor_glyph->pixel_width - width; + + XFillRectangle (dpy, window, gc, x, WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), width, row->height); } @@ -7433,9 +7238,7 @@ x_draw_bar_cursor (w, row, width, kind) /* RIF: Define cursor CURSOR on frame F. */ static void -x_define_frame_cursor (f, cursor) - struct frame *f; - Cursor cursor; +x_define_frame_cursor (struct frame *f, Cursor cursor) { if (!f->pointer_invisible && f->output_data.x->current_cursor != cursor) @@ -7447,9 +7250,7 @@ x_define_frame_cursor (f, cursor) /* RIF: Clear area on frame F. */ static void -x_clear_frame_area (f, x, y, width, height) - struct frame *f; - int x, y, width, height; +x_clear_frame_area (struct frame *f, int x, int y, int width, int height) { x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), x, y, width, height, False); @@ -7464,12 +7265,7 @@ x_clear_frame_area (f, x, y, width, height) /* RIF: Draw cursor on window W. */ static void -x_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, active_p) - struct window *w; - struct glyph_row *glyph_row; - int x, y; - int cursor_type, cursor_width; - int on_p, active_p; +x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int y, int cursor_type, int cursor_width, int on_p, int active_p) { struct frame *f = XFRAME (WINDOW_FRAME (w)); @@ -7479,36 +7275,40 @@ x_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, activ w->phys_cursor_on_p = 1; if (glyph_row->exact_window_width_line_p - && w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA]) + && (glyph_row->reversed_p + ? (w->phys_cursor.hpos < 0) + : (w->phys_cursor.hpos >= glyph_row->used[TEXT_AREA]))) { glyph_row->cursor_in_fringe_p = 1; - draw_fringe_bitmap (w, glyph_row, 0); + draw_fringe_bitmap (w, glyph_row, glyph_row->reversed_p); } else - switch (cursor_type) { - case HOLLOW_BOX_CURSOR: - x_draw_hollow_cursor (w, glyph_row); - break; + switch (cursor_type) + { + case HOLLOW_BOX_CURSOR: + x_draw_hollow_cursor (w, glyph_row); + break; - case FILLED_BOX_CURSOR: - draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR); - break; + case FILLED_BOX_CURSOR: + draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR); + break; - case BAR_CURSOR: - x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR); - break; + case BAR_CURSOR: + x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR); + break; - case HBAR_CURSOR: - x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR); - break; + case HBAR_CURSOR: + x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR); + break; - case NO_CURSOR: - w->phys_cursor_width = 0; - break; + case NO_CURSOR: + w->phys_cursor_width = 0; + break; - default: - abort (); + default: + abort (); + } } #ifdef HAVE_X_I18N @@ -7529,9 +7329,7 @@ x_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, activ /* Make the x-window of frame F use the gnu icon bitmap. */ int -x_bitmap_icon (f, file) - struct frame *f; - Lisp_Object file; +x_bitmap_icon (struct frame *f, Lisp_Object file) { int bitmap_id; @@ -7608,9 +7406,7 @@ x_bitmap_icon (f, file) Use ICON_NAME as the text. */ int -x_text_icon (f, icon_name) - struct frame *f; - char *icon_name; +x_text_icon (struct frame *f, const char *icon_name) { if (FRAME_X_WINDOW (f) == 0) return 1; @@ -7653,9 +7449,7 @@ static struct x_error_message_stack *x_error_message; x_catch_errors is in effect. */ static void -x_error_catcher (display, error) - Display *display; - XErrorEvent *error; +x_error_catcher (Display *display, XErrorEvent *error) { XGetErrorText (display, error->error_code, x_error_message->string, @@ -7675,11 +7469,10 @@ x_error_catcher (display, error) Calling x_uncatch_errors resumes the normal error handling. */ -void x_check_errors (); +void x_check_errors (Display *dpy, const char *format); void -x_catch_errors (dpy) - Display *dpy; +x_catch_errors (Display *dpy) { struct x_error_message_stack *data = xmalloc (sizeof (*data)); @@ -7696,7 +7489,7 @@ x_catch_errors (dpy) DPY should be the display that was passed to x_catch_errors. */ void -x_uncatch_errors () +x_uncatch_errors (void) { struct x_error_message_stack *tmp; @@ -7718,9 +7511,7 @@ x_uncatch_errors () sprintf (a buffer, FORMAT, the x error message text) as the text. */ void -x_check_errors (dpy, format) - Display *dpy; - char *format; +x_check_errors (Display *dpy, const char *format) { /* Make sure to catch any errors incurred so far. */ XSync (dpy, False); @@ -7728,7 +7519,7 @@ x_check_errors (dpy, format) if (x_error_message->string[0]) { char string[X_ERROR_MESSAGE_SIZE]; - bcopy (x_error_message->string, string, X_ERROR_MESSAGE_SIZE); + memcpy (string, x_error_message->string, X_ERROR_MESSAGE_SIZE); x_uncatch_errors (); error (format, string); } @@ -7738,8 +7529,7 @@ x_check_errors (dpy, format) since we did x_catch_errors on DPY. */ int -x_had_errors_p (dpy) - Display *dpy; +x_had_errors_p (Display *dpy) { /* Make sure to catch any errors incurred so far. */ XSync (dpy, False); @@ -7750,8 +7540,7 @@ x_had_errors_p (dpy) /* Forget about any errors we have had, since we did x_catch_errors on DPY. */ void -x_clear_errors (dpy) - Display *dpy; +x_clear_errors (Display *dpy) { x_error_message->string[0] = 0; } @@ -7761,7 +7550,7 @@ x_clear_errors (dpy) /* Close off all unclosed x_catch_errors calls. */ void -x_fully_uncatch_errors () +x_fully_uncatch_errors (void) { while (x_error_message) x_uncatch_errors (); @@ -7771,14 +7560,14 @@ x_fully_uncatch_errors () /* Nonzero if x_catch_errors has been done and not yet canceled. */ int -x_catching_errors () +x_catching_errors (void) { return x_error_message != 0; } #if 0 static unsigned int x_wire_count; -x_trace_wire () +x_trace_wire (void) { fprintf (stderr, "Lib call: %d\n", ++x_wire_count); } @@ -7792,8 +7581,8 @@ x_trace_wire () which will do the appropriate cleanup for us. */ static SIGTYPE -x_connection_signal (signalnum) /* If we don't have an argument, */ - int signalnum; /* some compilers complain in signal calls. */ +x_connection_signal (int signalnum) /* If we don't have an argument, */ + /* some compilers complain in signal calls. */ { #ifdef USG /* USG systems forget handlers when they are used; @@ -7816,7 +7605,7 @@ static char *error_msg; instead of dumping core when XtCloseDisplay fails. */ static void -x_fatal_error_signal () +x_fatal_error_signal (void) { fprintf (stderr, "%s\n", error_msg); exit (70); @@ -7826,9 +7615,7 @@ x_fatal_error_signal () the text of an error message that lead to the connection loss. */ static SIGTYPE -x_connection_closed (dpy, error_message) - Display *dpy; - char *error_message; +x_connection_closed (Display *dpy, const char *error_message) { struct x_display_info *dpyinfo = x_display_info_for_display (dpy); Lisp_Object frame, tail; @@ -7903,7 +7690,6 @@ x_connection_closed (dpy, error_message) /* If DPYINFO is null, this means we didn't open the display in the first place, so don't try to close it. */ { - extern void (*fatal_error_signal_hook) P_ ((void)); fatal_error_signal_hook = x_fatal_error_signal; XtCloseDisplay (dpy); fatal_error_signal_hook = NULL; @@ -7916,8 +7702,8 @@ x_connection_closed (dpy, error_message) if (terminal_list->next_terminal == NULL) { fprintf (stderr, "%s\n", error_msg); - shut_down_emacs (0, 0, Qnil); - exit (70); + Fkill_emacs (make_number (70)); + /* NOTREACHED */ } xg_display_close (dpyinfo->display); #endif @@ -7943,8 +7729,8 @@ x_connection_closed (dpy, error_message) if (terminal_list == 0) { fprintf (stderr, "%s\n", error_msg); - shut_down_emacs (0, 0, Qnil); - exit (70); + Fkill_emacs (make_number (70)); + /* NOTREACHED */ } /* Ordinary stack unwind doesn't deal with these. */ @@ -7964,15 +7750,13 @@ x_connection_closed (dpy, error_message) /* We specifically use it before defining it, so that gcc doesn't inline it, otherwise gdb doesn't know how to properly put a breakpoint on it. */ -static void x_error_quitter P_ ((Display *, XErrorEvent *)); +static void x_error_quitter (Display *, XErrorEvent *); /* This is the first-level handler for X protocol errors. It calls x_error_quitter or x_error_catcher. */ static int -x_error_handler (display, error) - Display *display; - XErrorEvent *error; +x_error_handler (Display *display, XErrorEvent *error) { if (x_error_message) x_error_catcher (display, error); @@ -7987,25 +7771,11 @@ x_error_handler (display, error) /* .gdbinit puts a breakpoint here, so make sure it is not inlined. */ -#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ -#define NO_INLINE __attribute__((noinline)) -#else -#define NO_INLINE -#endif - -/* Some versions of GNU/Linux define noinline in their headers. */ - -#ifdef noinline -#undef noinline -#endif - /* On older GCC versions, just putting x_error_quitter after x_error_handler prevents inlining into the former. */ static void NO_INLINE -x_error_quitter (display, error) - Display *display; - XErrorEvent *error; +x_error_quitter (Display *display, XErrorEvent *error) { char buf[256], buf1[356]; @@ -8030,8 +7800,7 @@ x_error_quitter (display, error) If that was the only one, it prints an error message and kills Emacs. */ static int -x_io_error_quitter (display) - Display *display; +x_io_error_quitter (Display *display) { char buf[256]; @@ -8048,10 +7817,7 @@ x_io_error_quitter (display) FONT-OBJECT. */ Lisp_Object -x_new_font (f, font_object, fontset) - struct frame *f; - Lisp_Object font_object; - int fontset; +x_new_font (struct frame *f, Lisp_Object font_object, int fontset) { struct font *font = XFONT_OBJECT (font_object); @@ -8120,10 +7886,7 @@ x_new_font (f, font_object, fontset) pointer to the x_display_info structure corresponding to XIM. */ static void -xim_destroy_callback (xim, client_data, call_data) - XIM xim; - XPointer client_data; - XPointer call_data; +xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data) { struct x_display_info *dpyinfo = (struct x_display_info *) client_data; Lisp_Object frame, tail; @@ -8151,16 +7914,14 @@ xim_destroy_callback (xim, client_data, call_data) #ifdef HAVE_X11R6 /* This isn't prototyped in OSF 5.0 or 5.1a. */ -extern char *XSetIMValues P_ ((XIM, ...)); +extern char *XSetIMValues (XIM, ...); #endif /* Open the connection to the XIM server on display DPYINFO. RESOURCE_NAME is the resource name Emacs uses. */ static void -xim_open_dpy (dpyinfo, resource_name) - struct x_display_info *dpyinfo; - char *resource_name; +xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name) { XIM xim; @@ -8170,7 +7931,7 @@ xim_open_dpy (dpyinfo, resource_name) if (dpyinfo->xim) XCloseIM (dpyinfo->xim); xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, - EMACS_CLASS); + emacs_class); dpyinfo->xim = xim; if (xim) @@ -8204,10 +7965,7 @@ xim_open_dpy (dpyinfo, resource_name) when the callback was registered. */ static void -xim_instantiate_callback (display, client_data, call_data) - Display *display; - XPointer client_data; - XPointer call_data; +xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_data) { struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data; struct x_display_info *dpyinfo = xim_inst->dpyinfo; @@ -8257,9 +8015,7 @@ xim_instantiate_callback (display, client_data, call_data) in the XIM instantiate callback function. */ static void -xim_initialize (dpyinfo, resource_name) - struct x_display_info *dpyinfo; - char *resource_name; +xim_initialize (struct x_display_info *dpyinfo, char *resource_name) { dpyinfo->xim = NULL; #ifdef HAVE_XIM @@ -8274,9 +8030,9 @@ xim_initialize (dpyinfo, resource_name) xim_inst->dpyinfo = dpyinfo; len = strlen (resource_name); xim_inst->resource_name = (char *) xmalloc (len + 1); - bcopy (resource_name, xim_inst->resource_name, len + 1); + memcpy (xim_inst->resource_name, resource_name, len + 1); XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, - resource_name, EMACS_CLASS, + resource_name, emacs_class, xim_instantiate_callback, /* This is XPointer in XFree86 but (XPointer *) on Tru64, at @@ -8293,8 +8049,7 @@ xim_initialize (dpyinfo, resource_name) /* Close the connection to the XIM server on display DPYINFO. */ static void -xim_close_dpy (dpyinfo) - struct x_display_info *dpyinfo; +xim_close_dpy (struct x_display_info *dpyinfo) { #ifdef HAVE_XIM if (use_xim) @@ -8302,7 +8057,7 @@ xim_close_dpy (dpyinfo) #ifdef HAVE_X11R6_XIM if (dpyinfo->display) XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, - NULL, EMACS_CLASS, + NULL, emacs_class, xim_instantiate_callback, NULL); xfree (dpyinfo->xim_callback_data->resource_name); xfree (dpyinfo->xim_callback_data); @@ -8323,8 +8078,7 @@ xim_close_dpy (dpyinfo) from its current recorded position values and gravity. */ void -x_calc_absolute_position (f) - struct frame *f; +x_calc_absolute_position (struct frame *f) { int flags = f->size_hint_flags; @@ -8376,10 +8130,7 @@ x_calc_absolute_position (f) which means, do adjust for borders but don't change the gravity. */ void -x_set_offset (f, xoff, yoff, change_gravity) - struct frame *f; - register int xoff, yoff; - int change_gravity; +x_set_offset (struct frame *f, register int xoff, register int yoff, int change_gravity) { int modified_top, modified_left; @@ -8448,9 +8199,7 @@ x_set_offset (f, xoff, yoff, change_gravity) http://freedesktop.org/wiki/Specifications/wm-spec. */ static int -wm_supports (f, atomname) - struct frame *f; - const char *atomname; +wm_supports (struct frame *f, const char *atomname) { Atom actual_type; unsigned long actual_size, bytes_remaining; @@ -8539,11 +8288,7 @@ wm_supports (f, atomname) } static void -set_wm_state (frame, add, what, what2) - Lisp_Object frame; - int add; - const char *what; - const char *what2; +set_wm_state (Lisp_Object frame, int add, const char *what, const char *what2) { const char *atom = "_NET_WM_STATE"; Fx_send_client_event (frame, make_number (0), frame, @@ -8561,9 +8306,7 @@ set_wm_state (frame, add, what, what2) } void -x_set_sticky (f, new_value, old_value) - struct frame *f; - Lisp_Object new_value, old_value; +x_set_sticky (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) { Lisp_Object frame; @@ -8641,8 +8384,7 @@ get_current_vm_state (struct frame *f, /* Do fullscreen as specified in extended window manager hints */ static int -do_ewmh_fullscreen (f) - struct frame *f; +do_ewmh_fullscreen (struct frame *f) { int have_net_atom = wm_supports (f, "_NET_WM_STATE"); Lisp_Object lval = get_frame_param (f, Qfullscreen); @@ -8709,8 +8451,7 @@ do_ewmh_fullscreen (f) } static void -XTfullscreen_hook (f) - FRAME_PTR f; +XTfullscreen_hook (FRAME_PTR f) { if (f->async_visible) { @@ -8723,9 +8464,7 @@ XTfullscreen_hook (f) static void -x_handle_net_wm_state (f, event) - struct frame *f; - XPropertyEvent *event; +x_handle_net_wm_state (struct frame *f, XPropertyEvent *event) { int value = FULLSCREEN_NONE; Lisp_Object lval; @@ -8733,7 +8472,7 @@ x_handle_net_wm_state (f, event) get_current_vm_state (f, event->window, &value, &sticky); lval = Qnil; - switch (value) + switch (value) { case FULLSCREEN_WIDTH: lval = Qfullwidth; @@ -8748,7 +8487,7 @@ x_handle_net_wm_state (f, event) lval = Qmaximized; break; } - + store_frame_param (f, Qfullscreen, lval); store_frame_param (f, Qsticky, sticky ? Qt : Qnil); } @@ -8756,8 +8495,7 @@ x_handle_net_wm_state (f, event) /* Check if we need to resize the frame due to a fullscreen request. If so needed, resize the frame. */ static void -x_check_fullscreen (f) - struct frame *f; +x_check_fullscreen (struct frame *f) { if (do_ewmh_fullscreen (f)) return; @@ -8784,7 +8522,7 @@ x_check_fullscreen (f) case FULLSCREEN_HEIGHT: height = x_display_pixel_height (dpyinfo); } - + if (FRAME_COLS (f) != width || FRAME_LINES (f) != height) { change_frame_size (f, height, width, 0, 1, 0); @@ -8803,10 +8541,7 @@ x_check_fullscreen (f) compensate by moving the window right and down by the proper amount. */ static void -x_check_expected_move (f, expected_left, expected_top) - struct frame *f; - int expected_left; - int expected_top; +x_check_expected_move (struct frame *f, int expected_left, int expected_top) { int current_left = 0, current_top = 0; @@ -8851,9 +8586,7 @@ x_check_expected_move (f, expected_left, expected_top) of an exact comparison. */ static void -x_sync_with_move (f, left, top, fuzzy) - struct frame *f; - int left, top, fuzzy; +x_sync_with_move (struct frame *f, int left, int top, int fuzzy) { int count = 0; @@ -8890,9 +8623,7 @@ x_sync_with_move (f, left, top, fuzzy) /* Wait for an event on frame F matching EVENTTYPE. */ void -x_wait_for_event (f, eventtype) - struct frame *f; - int eventtype; +x_wait_for_event (struct frame *f, int eventtype) { int level = interrupt_input_blocked; @@ -8919,7 +8650,7 @@ x_wait_for_event (f, eventtype) FD_ZERO (&fds); FD_SET (fd, &fds); - + EMACS_GET_TIME (time_now); EMACS_SUB_TIME (tmo, tmo_at, time_now); @@ -8937,10 +8668,7 @@ x_wait_for_event (f, eventtype) size changes. Otherwise we leave the window gravity unchanged. */ static void -x_set_window_size_1 (f, change_gravity, cols, rows) - struct frame *f; - int change_gravity; - int cols, rows; +x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows) { int pixelwidth, pixelheight; @@ -8948,13 +8676,12 @@ x_set_window_size_1 (f, change_gravity, cols, rows) f->scroll_bar_actual_width = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) ? 0 - : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 - ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) - : (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))); + : FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)); compute_fringe_widths (f, 0); - pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); + pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols) + + FRAME_TOOLBAR_WIDTH (f); pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); @@ -9005,17 +8732,14 @@ x_set_window_size_1 (f, change_gravity, cols, rows) Otherwise we leave the window gravity unchanged. */ void -x_set_window_size (f, change_gravity, cols, rows) - struct frame *f; - int change_gravity; - int cols, rows; +x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) { BLOCK_INPUT; if (NILP (tip_frame) || XFRAME (tip_frame) != f) { int r, c; - + /* When the frame is maximized/fullscreen or running under for example Xmonad, x_set_window_size_1 will be a no-op. In that case, the right thing to do is extend rows/cols to @@ -9064,9 +8788,7 @@ x_set_window_size (f, change_gravity, cols, rows) /* Mouse warping. */ void -x_set_mouse_position (f, x, y) - struct frame *f; - int x, y; +x_set_mouse_position (struct frame *f, int x, int y) { int pix_x, pix_y; @@ -9089,9 +8811,7 @@ x_set_mouse_position (f, x, y) /* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ void -x_set_mouse_pixel_position (f, pix_x, pix_y) - struct frame *f; - int pix_x, pix_y; +x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) { BLOCK_INPUT; @@ -9103,8 +8823,7 @@ x_set_mouse_pixel_position (f, pix_x, pix_y) /* focus shifting, raising and lowering. */ void -x_focus_on_frame (f) - struct frame *f; +x_focus_on_frame (struct frame *f) { #if 0 /* I don't think that the ICCCM allows programs to do things like this @@ -9116,8 +8835,7 @@ x_focus_on_frame (f) } void -x_unfocus_frame (f) - struct frame *f; +x_unfocus_frame (struct frame *f) { #if 0 /* Look at the remarks in x_focus_on_frame. */ @@ -9130,8 +8848,7 @@ x_unfocus_frame (f) /* Raise frame F. */ void -x_raise_frame (f) - struct frame *f; +x_raise_frame (struct frame *f) { BLOCK_INPUT; if (f->async_visible) @@ -9144,8 +8861,7 @@ x_raise_frame (f) /* Lower frame F. */ void -x_lower_frame (f) - struct frame *f; +x_lower_frame (struct frame *f) { if (f->async_visible) { @@ -9159,8 +8875,7 @@ x_lower_frame (f) /* Activate frame with Extended Window Manager Hints */ void -x_ewmh_activate_frame (f) - FRAME_PTR f; +x_ewmh_activate_frame (FRAME_PTR f) { /* See Window Manager Specification/Extended Window Manager Hints at http://freedesktop.org/wiki/Specifications/wm-spec */ @@ -9180,9 +8895,7 @@ x_ewmh_activate_frame (f) } static void -XTframe_raise_lower (f, raise_flag) - FRAME_PTR f; - int raise_flag; +XTframe_raise_lower (FRAME_PTR f, int raise_flag) { if (raise_flag) x_raise_frame (f); @@ -9193,9 +8906,7 @@ XTframe_raise_lower (f, raise_flag) /* XEmbed implementation. */ void -xembed_set_info (f, flags) - struct frame *f; - enum xembed_info flags; +xembed_set_info (struct frame *f, enum xembed_info flags) { Atom atom; unsigned long data[2]; @@ -9210,13 +8921,7 @@ xembed_set_info (f, flags) } void -xembed_send_message (f, time, message, detail, data1, data2) - struct frame *f; - Time time; - enum xembed_message message; - long detail; - long data1; - long data2; +xembed_send_message (struct frame *f, Time time, enum xembed_message message, long int detail, long int data1, long int data2) { XEvent event; @@ -9245,8 +8950,7 @@ xembed_send_message (f, time, message, detail, data1, data2) finishes with it. */ void -x_make_frame_visible (f) - struct frame *f; +x_make_frame_visible (struct frame *f) { Lisp_Object type; int original_top, original_left; @@ -9377,7 +9081,6 @@ x_make_frame_visible (f) /* It could be confusing if a real alarm arrives while processing the fake one. Turn it off and let the handler reset it. */ - extern void poll_for_input_1 P_ ((void)); int old_poll_suppress_count = poll_suppress_count; poll_suppress_count = 1; poll_for_input_1 (); @@ -9409,8 +9112,7 @@ x_make_frame_visible (f) /* Make the frame visible (mapped and not iconified). */ void -x_make_frame_invisible (f) - struct frame *f; +x_make_frame_invisible (struct frame *f) { Window window; @@ -9467,8 +9169,7 @@ x_make_frame_invisible (f) /* Change window state from mapped to iconified. */ void -x_iconify_frame (f) - struct frame *f; +x_iconify_frame (struct frame *f) { int result; Lisp_Object type; @@ -9594,8 +9295,7 @@ x_iconify_frame (f) /* Free X resources of frame F. */ void -x_free_frame_resources (f) - struct frame *f; +x_free_frame_resources (struct frame *f) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); Lisp_Object bar; @@ -9648,14 +9348,7 @@ x_free_frame_resources (f) #else /* !USE_X_TOOLKIT */ #ifdef USE_GTK - /* In the GTK version, tooltips are normal X - frames. We must check and free both types. */ - if (FRAME_GTK_OUTER_WIDGET (f)) - { - gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); - FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow below */ - FRAME_GTK_OUTER_WIDGET (f) = 0; - } + xg_free_frame_widgets (f); #endif /* USE_GTK */ if (FRAME_X_WINDOW (f)) @@ -9718,8 +9411,7 @@ x_free_frame_resources (f) /* Destroy the X window of frame F. */ void -x_destroy_window (f) - struct frame *f; +x_destroy_window (struct frame *f) { struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); @@ -9743,10 +9435,7 @@ x_destroy_window (f) #ifndef USE_GTK void -x_wm_set_size_hint (f, flags, user_position) - struct frame *f; - long flags; - int user_position; +x_wm_set_size_hint (struct frame *f, long flags, int user_position) { XSizeHints size_hints; Window window = FRAME_OUTER_WINDOW (f); @@ -9846,9 +9535,7 @@ x_wm_set_size_hint (f, flags, user_position) /* Used for IconicState or NormalState */ void -x_wm_set_window_state (f, state) - struct frame *f; - int state; +x_wm_set_window_state (struct frame *f, int state) { #ifdef USE_X_TOOLKIT Arg al[1]; @@ -9866,9 +9553,7 @@ x_wm_set_window_state (f, state) } void -x_wm_set_icon_pixmap (f, pixmap_id) - struct frame *f; - int pixmap_id; +x_wm_set_icon_pixmap (struct frame *f, int pixmap_id) { Pixmap icon_pixmap, icon_mask; @@ -9916,9 +9601,7 @@ x_wm_set_icon_pixmap (f, pixmap_id) } void -x_wm_set_icon_position (f, icon_x, icon_y) - struct frame *f; - int icon_x, icon_y; +x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) { Window window = FRAME_OUTER_WINDOW (f); @@ -9940,9 +9623,7 @@ x_wm_set_icon_position (f, icon_x, icon_y) font table. */ static void -x_check_font (f, font) - struct frame *f; - struct font *font; +x_check_font (struct frame *f, struct font *font) { Lisp_Object frame; @@ -9991,8 +9672,7 @@ static int x_session_initialized; /* Test whether two display-name strings agree up to the dot that separates the screen number from the server number. */ static int -same_x_server (name1, name2) - const char *name1, *name2; +same_x_server (const char *name1, const char *name2) { int seen_colon = 0; const unsigned char *system_name = SDATA (Vsystem_name); @@ -10039,10 +9719,7 @@ same_x_server (name1, name2) get to the first bit. With MASK 0x7e0, *BITS is set to 6, and *OFFSET to 5. */ static void -get_bits_and_offset (mask, bits, offset) - unsigned long mask; - int *bits; - int *offset; +get_bits_and_offset (long unsigned int mask, int *bits, int *offset) { int nr = 0; int off = 0; @@ -10067,8 +9744,7 @@ get_bits_and_offset (mask, bits, offset) But don't permanently open it, just test its availability. */ int -x_display_ok (display) - const char *display; +x_display_ok (const char *display) { int dpy_ok = 1; Display *dpy; @@ -10083,26 +9759,19 @@ x_display_ok (display) #ifdef USE_GTK static void -my_log_handler (log_domain, log_level, message, user_data) - const gchar *log_domain; - GLogLevelFlags log_level; - const gchar *message; - gpointer user_data; +my_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { if (!strstr (message, "g_set_prgname")) fprintf (stderr, "%s-WARNING **: %s\n", log_domain, message); } #endif - + /* Open a connection to X display DISPLAY_NAME, and return the structure that describes the open display. If we cannot contact the display, return null. */ struct x_display_info * -x_term_init (display_name, xrm_option, resource_name) - Lisp_Object display_name; - char *xrm_option; - char *resource_name; +x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) { int connection; Display *dpy; @@ -10128,23 +9797,16 @@ x_term_init (display_name, xrm_option, resource_name) char *argv[NUM_ARGV]; char **argv2 = argv; guint id; -#ifndef HAVE_GTK_MULTIDISPLAY - if (!EQ (Vinitial_window_system, Qx)) - error ("Sorry, you cannot connect to X servers with the GTK toolkit"); -#endif if (x_initialized++ > 1) { -#ifdef HAVE_GTK_MULTIDISPLAY - /* Opening another display. If xg_display_open returns less - than zero, we are probably on GTK 2.0, which can only handle - one display. GTK 2.2 or later can handle more than one. */ - if (xg_display_open (SDATA (display_name), &dpy) < 0) -#endif - error ("Sorry, this version of GTK can only handle one display"); + xg_display_open (SDATA (display_name), &dpy); } else { + static char display_opt[] = "--display"; + static char name_opt[] = "--name"; + for (argc = 0; argc < NUM_ARGV; ++argc) argv[argc] = 0; @@ -10153,11 +9815,11 @@ x_term_init (display_name, xrm_option, resource_name) if (! NILP (display_name)) { - argv[argc++] = "--display"; + argv[argc++] = display_opt; argv[argc++] = SDATA (display_name); } - argv[argc++] = "--name"; + argv[argc++] = name_opt; argv[argc++] = resource_name; XSetLocaleModifiers (""); @@ -10180,7 +9842,7 @@ x_term_init (display_name, xrm_option, resource_name) /* Load our own gtkrc if it exists. */ { - char *file = "~/.emacs.d/gtkrc"; + const char *file = "~/.emacs.d/gtkrc"; Lisp_Object s, abs_file; s = make_string (file, strlen (file)); @@ -10245,7 +9907,7 @@ x_term_init (display_name, xrm_option, resource_name) /* We have definitely succeeded. Record the new connection. */ dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); - bzero (dpyinfo, sizeof *dpyinfo); + memset (dpyinfo, 0, sizeof *dpyinfo); terminal = x_create_terminal (dpyinfo); @@ -10523,8 +10185,10 @@ x_term_init (display_name, xrm_option, resource_name) = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False); dpyinfo->Xatom_net_window_type_tooltip = XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE_TOOLTIP", False); - - dpyinfo->cut_buffers_initialized = 0; + dpyinfo->Xatom_net_wm_icon_name + = XInternAtom (dpyinfo->display, "_NET_WM_ICON_NAME", False); + dpyinfo->Xatom_net_wm_name + = XInternAtom (dpyinfo->display, "_NET_WM_NAME", False); dpyinfo->x_dnd_atoms_size = 8; dpyinfo->x_dnd_atoms_length = 0; @@ -10539,8 +10203,6 @@ x_term_init (display_name, xrm_option, resource_name) dpyinfo->connection = connection; { - extern int gray_bitmap_width, gray_bitmap_height; - extern char *gray_bitmap_bits; dpyinfo->gray = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, gray_bitmap_bits, @@ -10554,11 +10216,9 @@ x_term_init (display_name, xrm_option, resource_name) xsettings_initialize (dpyinfo); -#ifdef subprocesses /* This is only needed for distinguishing keyboard and process input. */ if (connection != 0) add_keyboard_wait_descriptor (connection); -#endif #ifdef F_SETOWN fcntl (connection, F_SETOWN, getpid ()); @@ -10640,8 +10300,7 @@ x_term_init (display_name, xrm_option, resource_name) and without sending any more commands to the X server. */ void -x_delete_display (dpyinfo) - struct x_display_info *dpyinfo; +x_delete_display (struct x_display_info *dpyinfo) { struct terminal *t; @@ -10653,7 +10312,7 @@ x_delete_display (dpyinfo) #ifdef HAVE_X_SM /* Close X session management when we close its display. */ if (t->id == 1 && x_session_have_connection ()) - x_session_close(); + x_session_close (); #endif delete_terminal (t); break; @@ -10710,8 +10369,7 @@ x_delete_display (dpyinfo) that slows us down. */ static void -x_process_timeouts (timer) - struct atimer *timer; +x_process_timeouts (struct atimer *timer) { BLOCK_INPUT; x_timeout_atimer_activated_flag = 0; @@ -10734,7 +10392,7 @@ x_process_timeouts (timer) processed, these widgets don't behave normally. */ void -x_activate_timeout_atimer () +x_activate_timeout_atimer (void) { BLOCK_INPUT; if (!x_timeout_atimer_activated_flag) @@ -10910,7 +10568,7 @@ x_create_terminal (struct x_display_info *dpyinfo) } void -x_initialize () +x_initialize (void) { baud_rate = 19200; @@ -10968,7 +10626,7 @@ x_initialize () void -syms_of_xterm () +syms_of_xterm (void) { x_error_message = NULL; diff --git a/src/xterm.h b/src/xterm.h index c8601b8c43d..d884945f985 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -51,6 +51,10 @@ typedef GtkWidget *xt_or_gtk_widget; #define XSync(d, b) do { gdk_window_process_all_updates (); \ XSync (d, b); } while (0) +/* The GtkTooltip API came in 2.12, but gtk-enable-tooltips in 2.14. */ +#if GTK_MAJOR_VERSION > 2 || GTK_MINOR_VERSION > 13 +#define USE_GTK_TOOLTIP +#endif #endif /* USE_GTK */ @@ -295,8 +299,6 @@ struct x_display_info /* Atom used in XEmbed client messages. */ Atom Xatom_XEMBED; - int cut_buffers_initialized; /* Whether we're sure they all exist */ - /* The frame (if any) which has the X window that has keyboard focus. Zero if none. This is examined by Ffocus_frame in xfns.c. Note that a mere EnterNotify event can set this; if you need to know the @@ -370,6 +372,9 @@ struct x_display_info /* XSettings atoms and windows. */ Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr; Window xsettings_window; + + /* Frame name and icon name */ + Atom Xatom_net_wm_name, Xatom_net_wm_icon_name; }; #ifdef HAVE_X_I18N @@ -378,14 +383,16 @@ extern int use_xim; #endif /* This checks to make sure we have a display. */ -extern void check_x P_ ((void)); -extern struct frame *x_window_to_frame P_ ((struct x_display_info *, int)); +extern void check_x (void); + +extern struct frame *x_window_to_frame (struct x_display_info *, int); -extern struct frame *x_any_window_to_frame P_ ((struct x_display_info *, int)); -extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, - XEvent *)); -extern struct frame *x_top_window_to_frame P_ ((struct x_display_info *, int)); +extern struct frame *x_any_window_to_frame (struct x_display_info *, int); +extern struct frame *x_menubar_window_to_frame (struct x_display_info *, + XEvent *); + +extern struct frame *x_top_window_to_frame (struct x_display_info *, int); #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) #define x_any_window_to_frame x_window_to_frame @@ -404,14 +411,14 @@ extern Lisp_Object x_display_name_list; /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */ extern Lisp_Object Vx_pixel_size_width_font_regexp; -extern struct x_display_info *x_display_info_for_display P_ ((Display *)); -extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object)); -extern void x_set_frame_alpha P_ ((struct frame *)); +extern struct x_display_info *x_display_info_for_display (Display *); +extern struct x_display_info *x_display_info_for_name (Lisp_Object); +extern void x_set_frame_alpha (struct frame *); -extern struct x_display_info *x_term_init P_ ((Lisp_Object, char *, char *)); -extern int x_display_ok P_ ((const char *)); +extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); +extern int x_display_ok (const char *); -extern void select_visual P_ ((struct x_display_info *)); +extern void select_visual (struct x_display_info *); struct font; @@ -428,9 +435,15 @@ struct x_output if the menubar is turned off. */ int menubar_height; - /* Height of tool bar widget, in pixels. - Zero if not using an external tool bar. */ - int toolbar_height; + /* Height of tool bar widget, in pixels. top_height is used if tool bar + at top, bottom_height if tool bar is at the bottom. + Zero if not using an external tool bar or if tool bar is vertical. */ + int toolbar_top_height, toolbar_bottom_height; + + /* Width of tool bar widget, in pixels. left_width is used if tool bar + at left, right_width if tool bar is at the right. + Zero if not using an external tool bar or if tool bar is horizontal. */ + int toolbar_left_width, toolbar_right_width; /* The tiled border used when the mouse is out of the frame. */ Pixmap border_tile; @@ -475,6 +488,8 @@ struct x_output GtkWidget *edit_widget; /* The widget used for laying out widgets vertically. */ GtkWidget *vbox_widget; + /* The widget used for laying out widgets horizontally. */ + GtkWidget *hbox_widget; /* The menubar in this frame. */ GtkWidget *menubar_widget; /* The tool bar in this frame */ @@ -483,11 +498,20 @@ struct x_output GtkWidget *handlebox_widget; /* Non-zero if the tool bar is detached. */ int toolbar_detached; + /* Non-zero if tool bar is packed into the hbox widget (i.e. vertical). */ + int toolbar_in_hbox; /* The last size hints set. */ GdkGeometry size_hints; long hint_flags; -#endif + +#ifdef USE_GTK_TOOLTIP + GtkTooltip *ttip_widget; + GtkWidget *ttip_lbl; + GtkWindow *ttip_window; +#endif /* USE_GTK_TOOLTIP */ + +#endif /* USE_GTK */ /* If >=0, a bitmap index. The indicated bitmap is used for the icon. */ @@ -662,8 +686,22 @@ enum FRAME_X_WINDOW (f)) #else #ifdef USE_GTK +/* Functions not present in older Gtk+ */ + +#ifndef HAVE_GTK_WIDGET_GET_WINDOW +#define gtk_widget_get_window(w) ((w)->window) +#endif +#ifndef HAVE_GTK_WIDGET_GET_MAPPED +#define gtk_widget_get_mapped(w) (GTK_WIDGET_MAPPED (w)) +#endif +#ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE +#define gtk_adjustment_get_page_size(w) ((w)->page_size) +#define gtk_adjustment_get_upper(w) ((w)->upper) +#endif + #define GTK_WIDGET_TO_X_WIN(w) \ - ((w) && (w)->window ? GDK_WINDOW_XWINDOW ((w)->window) : 0) + ((w) && gtk_widget_get_window (w) \ + ? GDK_WINDOW_XWINDOW (gtk_widget_get_window (w)) : 0) #define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget) #define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget) @@ -681,7 +719,15 @@ enum #define FRAME_FONT(f) ((f)->output_data.x->font) #define FRAME_FONTSET(f) ((f)->output_data.x->fontset) #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height) -#define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.x->toolbar_height) +#define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height) +#define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \ + ((f)->output_data.x->toolbar_bottom_height) +#define FRAME_TOOLBAR_HEIGHT(f) \ + (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f)) +#define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width) +#define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width) +#define FRAME_TOOLBAR_WIDTH(f) \ + (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f)) #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset) /* This gives the x_display_info structure for the display F is on. */ @@ -902,168 +948,173 @@ struct image; /* From xselect.c. */ -void x_handle_selection_notify P_ ((XSelectionEvent *)); -void x_handle_property_notify P_ ((XPropertyEvent *)); +void x_handle_selection_notify (XSelectionEvent *); +void x_handle_property_notify (XPropertyEvent *); /* From xfns.c. */ -Lisp_Object display_x_get_resource P_ ((struct x_display_info *, - Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object)); -struct frame *check_x_frame P_ ((Lisp_Object)); +Lisp_Object display_x_get_resource (struct x_display_info *, + Lisp_Object, Lisp_Object, + Lisp_Object, Lisp_Object); +struct frame *check_x_frame (Lisp_Object); EXFUN (Fx_display_color_p, 1); EXFUN (Fx_display_grayscale_p, 1); -extern void x_free_gcs P_ ((struct frame *)); +extern void x_free_gcs (struct frame *); +extern int gray_bitmap_width, gray_bitmap_height; +extern char *gray_bitmap_bits; /* From xrdb.c. */ -char *x_get_customization_string P_ ((XrmDatabase, char *, char *)); -XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); -int x_get_resource P_ ((XrmDatabase, char *, char *, - XrmRepresentation, XrmValue *)); -void x_delete_display P_ ((struct x_display_info *)); -void x_make_frame_visible P_ ((struct frame *)); -void x_iconify_frame P_ ((struct frame *)); -void x_wm_set_size_hint P_ ((struct frame *, long, int)); -int x_text_icon P_ ((struct frame *, char *)); -int x_bitmap_icon P_ ((struct frame *, Lisp_Object)); -void x_set_window_size P_ ((struct frame *, int, int, int)); -void x_wm_set_window_state P_ ((struct frame *, int)); -int x_alloc_nearest_color P_ ((struct frame *, Colormap, XColor *)); +char *x_get_customization_string (XrmDatabase, const char *, const char *); +XrmDatabase x_load_resources (Display *, const char *, const char *, + const char *); +int x_get_resource (XrmDatabase, const char *, const char *, + XrmRepresentation, XrmValue *); +void x_delete_display (struct x_display_info *); +void x_make_frame_visible (struct frame *); +void x_iconify_frame (struct frame *); +void x_wm_set_size_hint (struct frame *, long, int); +int x_text_icon (struct frame *, const char *); +int x_bitmap_icon (struct frame *, Lisp_Object); +void x_set_window_size (struct frame *, int, int, int); +void x_wm_set_window_state (struct frame *, int); +int x_alloc_nearest_color (struct frame *, Colormap, XColor *); /* Defined in xterm.c */ -extern void cancel_mouse_face P_ ((struct frame *)); -extern void x_scroll_bar_clear P_ ((struct frame *)); -extern int x_text_icon P_ ((struct frame *, char *)); -extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object)); -extern void x_catch_errors P_ ((Display *)); -extern void x_check_errors P_ ((Display *, char *)); -extern int x_had_errors_p P_ ((Display *)); -extern int x_catching_errors P_ ((void)); -extern void x_uncatch_errors P_ ((void)); -extern void x_clear_errors P_ ((Display *)); -extern void x_set_window_size P_ ((struct frame *, int, int, int)); -extern void x_set_mouse_position P_ ((struct frame *, int, int)); -extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int)); -extern void x_ewmh_activate_frame P_ ((struct frame *)); -extern void x_raise_frame P_ ((struct frame *)); -extern void x_lower_frame P_ ((struct frame *)); -extern void x_make_frame_visible P_ ((struct frame *)); -extern void x_make_frame_invisible P_ ((struct frame *)); -extern void x_iconify_frame P_ ((struct frame *)); -extern void x_free_frame_resources P_ ((struct frame *)); -extern void x_destroy_window P_ ((struct frame *)); -extern void x_wm_set_size_hint P_ ((struct frame *, long, int)); -extern void x_wm_set_window_state P_ ((struct frame *, int)); -extern void x_wm_set_icon_pixmap P_ ((struct frame *, int)); -extern void x_delete_display P_ ((struct x_display_info *)); -extern void x_delete_terminal P_ ((struct terminal *terminal)); -extern void x_initialize P_ ((void)); -extern unsigned long x_copy_color P_ ((struct frame *, unsigned long)); +extern void cancel_mouse_face (struct frame *); +extern void x_scroll_bar_clear (struct frame *); +extern int x_text_icon (struct frame *, const char *); +extern int x_bitmap_icon (struct frame *, Lisp_Object); +extern void x_catch_errors (Display *); +extern void x_check_errors (Display *, const char *); +extern int x_had_errors_p (Display *); +extern int x_catching_errors (void); +extern void x_uncatch_errors (void); +extern void x_clear_errors (Display *); +extern void x_set_window_size (struct frame *, int, int, int); +extern void x_set_mouse_position (struct frame *, int, int); +extern void x_set_mouse_pixel_position (struct frame *, int, int); +extern void x_ewmh_activate_frame (struct frame *); +extern void x_raise_frame (struct frame *); +extern void x_lower_frame (struct frame *); +extern void x_make_frame_visible (struct frame *); +extern void x_make_frame_invisible (struct frame *); +extern void x_iconify_frame (struct frame *); +extern void x_free_frame_resources (struct frame *); +extern void x_destroy_window (struct frame *); +extern void x_wm_set_size_hint (struct frame *, long, int); +extern void x_wm_set_window_state (struct frame *, int); +extern void x_wm_set_icon_pixmap (struct frame *, int); +extern void x_delete_display (struct x_display_info *); +extern void x_delete_terminal (struct terminal *terminal); +extern void x_initialize (void); +extern unsigned long x_copy_color (struct frame *, unsigned long); #ifdef USE_X_TOOLKIT extern XtAppContext Xt_app_con; -extern int x_alloc_lighter_color_for_widget __P ((Widget, Display*, Colormap, - unsigned long *, - double, int)); -extern void x_activate_timeout_atimer P_ ((void)); +extern int x_alloc_lighter_color_for_widget (Widget, Display*, Colormap, + unsigned long *, + double, int); +extern void x_activate_timeout_atimer (void); #endif -extern void x_query_colors P_ ((struct frame *f, XColor *, int)); -extern void x_query_color P_ ((struct frame *f, XColor *)); -extern void x_clear_area P_ ((Display *, Window, int, int, int, int, int)); -extern void set_vertical_scroll_bar P_ ((struct window *)); +extern void x_query_colors (struct frame *f, XColor *, int); +extern void x_query_color (struct frame *f, XColor *); +extern void x_clear_area (Display *, Window, int, int, int, int, int); +extern void set_vertical_scroll_bar (struct window *); -extern int x_dispatch_event P_ ((XEvent *, Display *)); -extern unsigned int x_x_to_emacs_modifiers P_ ((struct x_display_info *, - unsigned)); -extern int x_display_pixel_height P_ ((struct x_display_info *)); -extern int x_display_pixel_width P_ ((struct x_display_info *)); +extern int x_dispatch_event (XEvent *, Display *); +extern unsigned int x_x_to_emacs_modifiers (struct x_display_info *, + unsigned); +extern int x_display_pixel_height (struct x_display_info *); +extern int x_display_pixel_width (struct x_display_info *); -extern void x_set_sticky P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_wait_for_event P_ ((struct frame *, int)); +extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object); +extern void x_wait_for_event (struct frame *, int); /* Defined in xselect.c */ -extern void x_handle_property_notify P_ ((XPropertyEvent *)); -extern void x_handle_selection_notify P_ ((XSelectionEvent *)); -extern void x_handle_selection_event P_ ((struct input_event *)); -extern void x_clear_frame_selections P_ ((struct frame *)); - -extern int x_handle_dnd_message P_ ((struct frame *, - XClientMessageEvent *, - struct x_display_info *, - struct input_event *bufp)); -extern int x_check_property_data P_ ((Lisp_Object)); -extern void x_fill_property_data P_ ((Display *, - Lisp_Object, - void *, - int)); -extern Lisp_Object x_property_data_to_lisp P_ ((struct frame *, - unsigned char *, - Atom, - int, - unsigned long)); +extern void x_handle_property_notify (XPropertyEvent *); +extern void x_handle_selection_notify (XSelectionEvent *); +extern void x_handle_selection_event (struct input_event *); +extern void x_clear_frame_selections (struct frame *); + +extern int x_handle_dnd_message (struct frame *, + XClientMessageEvent *, + struct x_display_info *, + struct input_event *bufp); +extern int x_check_property_data (Lisp_Object); +extern void x_fill_property_data (Display *, + Lisp_Object, + void *, + int); +extern Lisp_Object x_property_data_to_lisp (struct frame *, + const unsigned char *, + Atom, + int, + unsigned long); /* Defined in xfns.c */ -extern struct x_display_info * check_x_display_info P_ ((Lisp_Object frame)); +extern struct x_display_info * check_x_display_info (Lisp_Object frame); +extern Lisp_Object x_get_focus_frame (struct frame *); #ifdef USE_GTK -extern int xg_set_icon P_ ((struct frame *, Lisp_Object)); -extern int xg_set_icon_from_xpm_data P_ ((struct frame *, char**)); +extern int xg_set_icon (struct frame *, Lisp_Object); +extern int xg_set_icon_from_xpm_data (struct frame *, const char**); #endif /* USE_GTK */ -extern void x_real_positions P_ ((struct frame *, int *, int *)); -extern int defined_color P_ ((struct frame *, char *, XColor *, int)); -extern void x_set_border_pixel P_ ((struct frame *, int)); -extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); -extern void xic_free_xfontset P_ ((struct frame *)); -extern void create_frame_xic P_ ((struct frame *)); -extern void destroy_frame_xic P_ ((struct frame *)); -extern void xic_set_preeditarea P_ ((struct window *, int, int)); -extern void xic_set_statusarea P_ ((struct frame *)); -extern void xic_set_xfontset P_ ((struct frame *, char *)); -extern int x_pixel_width P_ ((struct frame *)); -extern int x_pixel_height P_ ((struct frame *)); -extern int x_char_width P_ ((struct frame *)); -extern int x_char_height P_ ((struct frame *)); -extern int x_screen_planes P_ ((struct frame *)); -extern void x_sync P_ ((struct frame *)); -extern int x_defined_color P_ ((struct frame *, char *, XColor *, int)); +extern void x_real_positions (struct frame *, int *, int *); +extern int defined_color (struct frame *, const char *, XColor *, int); +extern void x_set_border_pixel (struct frame *, int); +extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); +extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); +extern void xic_free_xfontset (struct frame *); +extern void create_frame_xic (struct frame *); +extern void destroy_frame_xic (struct frame *); +extern void xic_set_preeditarea (struct window *, int, int); +extern void xic_set_statusarea (struct frame *); +extern void xic_set_xfontset (struct frame *, const char *); +extern int x_pixel_width (struct frame *); +extern int x_pixel_height (struct frame *); +extern int x_char_width (struct frame *); +extern int x_char_height (struct frame *); +extern int x_screen_planes (struct frame *); +extern void x_sync (struct frame *); +extern int x_defined_color (struct frame *, const char *, XColor *, int); #ifdef HAVE_X_I18N -extern void free_frame_xic P_ ((struct frame *)); +extern void free_frame_xic (struct frame *); +extern char * xic_create_fontsetname (const char *base_fontname, int motif); #endif -extern void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object)); +extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object); /* Defined in xfaces.c */ -extern int compute_glyph_face P_ ((struct frame *, int, int)); -extern int compute_glyph_face_1 P_ ((struct frame *, Lisp_Object, int)); -extern void x_free_dpy_colors P_ ((Display *, Screen *, Colormap, - unsigned long *, int)); +extern int compute_glyph_face (struct frame *, int, int); +extern int compute_glyph_face_1 (struct frame *, Lisp_Object, int); +extern void x_free_dpy_colors (Display *, Screen *, Colormap, + unsigned long *, int); /* Defined in xmenu.c */ -extern void x_menu_set_in_use P_ ((int)); -extern void x_menu_wait_for_event P_ ((void *data)); -extern void x_activate_menubar P_ ((struct frame *)); -extern int popup_activated P_ ((void)); -extern void initialize_frame_menubar P_ ((struct frame *)); -extern void free_frame_menubar P_ ((struct frame *)); +extern void x_menu_set_in_use (int); +extern void x_menu_wait_for_event (void *data); +extern void x_activate_menubar (struct frame *); +extern int popup_activated (void); +extern void initialize_frame_menubar (struct frame *); +extern void free_frame_menubar (struct frame *); /* Defined in widget.c */ #ifdef USE_X_TOOLKIT -extern void widget_store_internal_border P_ ((Widget)); +extern void widget_store_internal_border (Widget); #endif /* Defined in xsmfns.c */ #ifdef HAVE_X_SM -extern void x_session_initialize P_ ((struct x_display_info *dpyinfo)); -extern int x_session_check_input P_ ((struct input_event *bufp)); -extern int x_session_have_connection P_ ((void)); -extern void x_session_close P_ ((void)); +extern void x_session_initialize (struct x_display_info *dpyinfo); +extern int x_session_check_input (struct input_event *bufp); +extern int x_session_have_connection (void); +extern void x_session_close (void); #endif /* XEmbed implementation. */ @@ -1116,10 +1167,11 @@ enum xembed_accelerator /* Defined in xterm.c */ -extern void xembed_set_info P_ ((struct frame *f, enum xembed_info flags)); -extern void xembed_send_message P_ ((struct frame *f, Time time, - enum xembed_message message, - long detail, long data1, long data2)); +extern Lisp_Object Qx_gtk_map_stock; +extern void xembed_set_info (struct frame *f, enum xembed_info flags); +extern void xembed_send_message (struct frame *f, Time time, + enum xembed_message message, + long detail, long data1, long data2); /* Is the frame embedded into another application? */ |