summaryrefslogtreecommitdiff
path: root/src/coding.c
Commit message (Collapse)AuthorAgeFilesLines
* Rework C source files to avoid ^(Paul Eggert2016-03-101-4/+4
| | | | | | | | Work around Bug#22884 by rewording comments and strings to avoid ‘(’ at the start of a line unless it starts a function. This change is a short-term hack; in the longer run we plan to fix cc-mode’s performance for C files that have ‘(’ at the start of a line in a comment or string.
* Fix decoding DOS EOL in a unibyte bufferEli Zaretskii2016-02-171-3/+3
| | | | | * src/coding.c (decode_eol): Loop over bytes, not characters. (Bug#5251)
* Update copyright year to 2016Paul Eggert2016-01-011-1/+1
| | | | Run admin/update-copyright.
* Use INT_ADD_WRAPV etc. to check integer overflowPaul Eggert2015-11-081-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string): * src/buffer.c (record_overlay_string, overlay_strings): * src/casefiddle.c (casify_object): * src/ccl.c (Fccl_execute_on_string): * src/character.c (char_width, c_string_width, lisp_string_width) (count_size_as_multibyte, string_escape_byte8): * src/coding.c (coding_alloc_by_realloc, produce_chars): * src/data.c (arith_driver): * src/dispnew.c (realloc_glyph_pool, init_display): * src/editfns.c (styled_format): * src/fns.c (Ffillarray): * src/ftfont.c (ftfont_shape_by_flt): * src/gnutls.c (gnutls_hex_string): * src/gtkutil.c (get_utf8_string): * src/image.c (x_to_xcolors, x_detect_edges, png_load_body): * src/keymap.c (Fkey_description): * src/lisp.h (SAFE_ALLOCA_LISP): * src/term.c (encode_terminal_code): * src/tparam.c (tparam1): * src/xselect.c (x_property_data_to_lisp): * src/xsmfns.c (smc_save_yourself_CB): * src/xterm.c (x_term_init): When checking for integer overflow, prefer INT_MULTIPLY_WRAPV to more-complicated code involving division and/or INT_MULTIPLY_OVERFLOW, and similarly for INT_ADD_WRAPV and subtraction and/or INT_ADD_OVERFLOW. * src/casefiddle.c (casify_object): Simplify multibyte size check. * src/character.c: Remove some obsolete ‘#ifdef emacs’s. * src/data.c (arith_driver): Also check for division overflow, as that’s now possible given that the accumulator can now contain any Emacs integer. * src/lisp.h (lisp_word_count): Remove; no longer used.
* Include-file cleanup for src directoryPaul Eggert2015-10-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Omit ‘#include "foo.h"’ unless the file needs foo.h (Bug#21707). In a few cases, add ‘#include "foo.h"’ if the file needs foo.h but does not include it directly. As a general rule, a source file should include foo.h if it needs the interfaces that foo.h defines. * src/alloc.c: Don’t include process.h. Include dispextern.h, systime.h. * src/atimer.c: Don’t include blockinput.h. * src/buffer.c: Include coding.h, systime.h. Don’t include keyboard.h, coding.h. * src/callint.c: Don’t include commands.h, keymap.h. * src/callproc.c: Don’t include character.h, ccl.h, composite.h, systty.h, termhooks.h. * src/casetab.c: Don’t include character.h. * src/category.c: Don’t include charset.h, keymap.h. * src/ccl.h: Don’t include character.h. * src/character.c: Don’t include charset.h. * src/charset.c: Don’t include disptab.h. * src/chartab.c: Don’t include ccl.h. * src/cm.c: Don’t include frame.h, termhooks.h. * src/cmds.c: Don’t include window.h, dispextern.h. * src/coding.c: Don’t include window.h, frame.h. * src/composite.c: Include composite.h. Don’t include window.h, font.h. * src/data.c: Don’t include syssignal.h, termhooks.h, font.h. * src/dbusbind.c: Don’t include frame.h. * src/decompress.c: Don’t include character.h. * src/dired.c: Don’t include character.h, commands.h, charset.h. * src/dispnew.c: Don’t include character.h, indent.h, intervals.h, process.h, timespec.h. Include systime.h. * src/doc.c: Include coding.h. Don’t include keyboard.h. * src/editfns.c: Include composite.h. Don’t include frame.h. * src/emacs.c: Include fcntl.h, coding.h. Don’t include commands.h, systty.h.. * src/fileio.c: Don’t include intervals.h, dispextern.h. Include composite.h. * src/filelock.c: Don’t include character.h, systime.h. * src/fns.c: Don’t include time.h, commands.h, keyboard.h, keymap.h, frame.h, blockinput.h, xterm.h. Include composite.h. * src/font.c: Include termhooks.h. * src/font.h: Don’t include ccl.h, frame.h. Add forward decls of struct composition_it, struct face, struct glyph_string. * src/fontset.c: Don’t include buffer.h, ccl.h, keyboard.h, intervals.h, window.h, termhooks.h. * src/frame.c: Don’t include character.h, commands.h, font.h. * src/frame.h: Don’t include dispextern.h. * src/fringe.c: Don’t include character.h. * src/ftcrfont.c: Don’t include dispextern.h, frame.h, character.h, charset.h, fontset.h. * src/ftfont.c: Don’t include frame.h, blockinput.h, coding.h, fontset.h. * src/ftxfont.c: Don’t include dispextern.h, character.h, charset.h, fontset.h. * src/gfilenotify.c: Don’t include frame.h, process.h. * src/gtkutil.c: Include dispextern.h, frame.h, systime.h. Don’t include syssignal.h, buffer.h, charset.h, font.h. * src/gtkutil.h: Don’t include frame.h. * src/image.c: Include fcntl.h and stdio.h instead of sysstdio.h. Don’t include character.h. * src/indent.c: Don’t include keyboard.h, termchar.h. * src/inotify.c: Don’t include character.h, frame.h. * src/insdel.c: Include composite.h. Don’t include blockinput.h. * src/intervals.c: Don’t include character.h, keyboard.h. * src/intervals.h: Don’t include dispextern.h, composite.h. * src/keyboard.c: Don’t include sysstdio.h, disptab.h, puresize.h. Include coding.h. * src/keyboard.h: Don’t incldue systime.h. * src/keymap.c: Don’t include charset.h, frame.h. * src/lread.c: Include dispextern.h and systime.h. Don’t include frame.h. Include systime.h. * src/macros.c: Don’t include commands.h, character.h, buffer.h. * src/menu.c: Include character.h, coding.h. Don’t include dispextern.h. * src/menu.h: Don’t include systime.h. * src/minibuf.c: Don’t include commands.h, dispextern.h, syntax.h, intervals.h, termhooks.h. * src/print.c: Include coding.h. Don’t include keyboard.h, window.h, dispextern.h, termchar.h, termhooks.h, font.h. Add forward decl of struct terminal. * src/process.c: Don’t include termhooks.h, commands.h, dispextern.h, composite.h. * src/region-cache.c: Don’t include character.h. * src/scroll.c: Don’t include keyboard.h, window.h. * src/search.c: Don’t include category.h, commands.h. * src/sound.c: Don’t include dispextern.h. * src/syntax.c: Don’t include command.h, keymap.h. * src/sysdep.c: Don’t include window.h, dispextern.h. * src/systime.h: Use ‘#ifdef emacs’, not ‘#ifdef EMACS_LISP_H’, * src/term.c: Don’t include systty.h, intervals.h, xterm.h. * src/terminal.c: Include character.h. Don’t include charset.h, coding.h. * src/textprop.c: Don’t include character.h. * src/undo.c: Don’t include character.h, commands.h, window.h. * src/unexsol.c: Don’t include character.h, charset.h. * src/widget.c: Include widget.h. Don’t include keyboard.h, window.h, dispextern.h, blockinput.h, character.h, font.h. * src/widgetprv.h: Don’t include widget.h. * src/window.c: Don’t include character.h, menu.h, intervals.h. * src/xdisp.c: Include composite.h, systime.h. Don’t include macros.h, process.h. * src/xfaces.c: Don’t include charset.h, keyboard.h, termhooks.h, intervals.h. * src/xfns.c: Don’t include menu.h, character.h, intervals.h, epaths.h, fontset.h, systime.h, atimer.h, termchar.h. * src/xfont.c: Don’t include dispextern.h, fontset.h, ccl.h. * src/xftfont.c: Don’t include dispextern.h, character.h, fontset.h. * src/xgselect.c: Don’t include timespec.h, frame.h. Include systime.h. * src/xgselect.h: Don’t include time.h. Use a forward decl to struct timespec instead. * src/xmenu.c: Don’t include keymap.h, character.h, charset.h, dispextern.h. Include systime.h. * src/xml.c: Don’t include character.h. * src/xrdb.c [USE_MOTIF]: Don’t include keyboard.h. * src/xselect.c: Don’t include dispextern.h, character.h, buffer.h, process.h. * src/xsmfns.c: Don’t include systime.h, sysselect.h. * src/xterm.c: Don’t include syssignal.h, charset.h, disptab.h, intervals.h process.h, keymap.h, xgselect.h. Include composite.h.
* * src/coding.c (complement_process_encoding_system): Revert lastAndreas Schwab2015-10-031-1/+0
| | | | change.
* More validatation of coding systemsAndreas Schwab2015-10-031-1/+3
| | | | | | | | * src/fileio.c (Finsert_file_contents): Remove redundant coding-system check. (choose_write_coding_system): Likewise. * src/coding.c (complement_process_encoding_system): Check argument for valid coding system.
* Avoid crashes in coding_inherit_eol_typeEli Zaretskii2015-10-031-0/+2
| | | | | | * src/coding.c (coding_inherit_eol_type): Check the validity of the arguments. Suggested by Andreas Schwab <schwab@linux-m68k.org>. (Bug#21602)
* Omit unnecessary \ before paren in C docstringsPaul Eggert2015-09-161-2/+2
| | | | | | | | | Although \( is needed in docstrings in Elisp code, it is not needed in docstrings in C code, since C function definitiions do not start with a parenthesis. The backslashes made the docstrings a bit harder to read and to format in columns. Also, some C docstrings had ( in column 1 and this did not appear to be causing any problems. So, simplify C docstrings by replacing \( with ( and \) with ).
* Add -Wswitch to --enable-gcc-warningsPaul Eggert2015-09-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | Make --enable-gcc-warnings a bit pickier, by also using -Wswitch. * configure.ac (WERROR_CFLAGS): Don’t add -Wno-switch. * lib-src/etags.c (main, consider_token, C_entries): * src/coding.c (encode_invocation_designation): * src/data.c (Ftype_of): * src/eval.c (Fdefvaralias, default_toplevel_binding) (Fbacktrace__locals, mark_specpdl): * src/lisp.h (record_xmalloc): * src/syntax.c (scan_lists, scan_sexps_forward): * src/window.c (window_relative_x_coord): * src/xdisp.c (push_it, pop_it): * src/xterm.c (xg_scroll_callback, x_check_fullscreen): Error out or do nothing (as appropriate) if a switch statement with an enum value does not cover all of the enum. * src/dispextern.h (struct iterator_stack_entry.u.comp): Remove unused member discovered by using -Wswitch. * src/lisp.h (record_xmalloc): Add a ‘+ 0’ to pacify -Wswitch. * src/vm-limit.c (check_memory_limits): Simplify warning-diagnostic computation by using a table.
* Assume GC_MARK_STACK == GC_MAKE_GCPROS_NOOPSPaul Eggert2015-08-261-16/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the need for GCPRO1 etc. Suggested by Stefan Monnier in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00918.html * doc/lispref/internals.texi (Writing Emacs Primitives): * etc/NEWS: Document the change. * src/alloc.c (gcprolist, dump_zombies, MAX_ZOMBIES, zombies) (nzombies, ngcs, avg_zombies, max_live, max_zombies, avg_live) (Fgc_status, check_gcpros, relocatable_string_data_p, gc-precise): * src/bytecode.c (mark_byte_stack) [BYTE_MARK_STACK]: * src/eval.c (gcpro_level) [DEBUG_GCPRO]: * src/lisp.h (struct handler.gcpro, struct gcpro, GC_MARK_STACK) (GC_USE_GCPROS_AS_BEFORE, GC_MAKE_GCPROS_NOOPS) (GC_MARK_STACK_CHECK_GCPROS, GC_USE_GCPROS_CHECK_ZOMBIES) (BYTE_MARK_STACK, GCPRO1, GCPRO2, GCPRO3, GCPRO4, GCPRO5, GCPRO6) (GCPRO7, UNGCPRO, RETURN_UNGCPRO): Remove. All uses removed. The code now assumes GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS. * src/bytecode.c (relocate_byte_stack): Rename from unmark_byte_stack, since it now only relocates. All callers changed. * src/frame.c (make_frame): Add an IF_LINT to pacify GCC 5.2 with GCPROs removed. * src/systime.h: Use EMACS_LISP_H as the canary instead of GCPRO1. * test/automated/finalizer-tests.el (finalizer-basic) (finalizer-circular-reference, finalizer-cross-reference) (finalizer-error): * test/automated/generator-tests.el (cps-test-iter-close-finalizer): Remove tests, as they depend on gc-precise.
* Fix uninitalized value in encode_coding_objectPaul Eggert2015-07-271-1/+5
| | | | | | * src/coding.c (encode_coding_object): Also initialize coding->src_pos and coding->src_pos_byte when NILP (src_object). This avoids later use of uninitialized storage.
* Remove the obsolete leading "*" from some C doc strings.Glenn Morris2015-06-071-6/+6
| | | | | | | * src/coding.c (syms_of_coding): * src/font.c (syms_of_font): Remove leading "*" from docs. * lisp/cus-start.el (enable-character-translation): Add it.
* Treat batch stdout/stderr like standard displayPaul Eggert2015-05-311-1/+2
| | | | | | | | | | | | | | | | | | | | Calls like (print FOO) could generate improperly encoded or hard-to-read output if FOO contains characters outside the system locale. Fix this by treating batch stdout and stderr like interactive standard display, when it comes to transliterating and encoding characters (Bug#20545). * doc/emacs/mule.texi (Communication Coding): * doc/lispref/display.texi (Active Display Table): * doc/lispref/nonascii.texi (Locales): * etc/NEWS: * src/coding.c (syms_of_coding): * src/dispnew.c (syms_of_display): Document this. * src/print.c: Include disptab.h. (printchar_to_stream): New function, with much of the guts of the old Fexternal_debugging_output, except this one also uses the standard display table. (printchar, strout, Fexternal_debugging_output): Use it.
* Remove unused DEFSYMsPaul Eggert2015-05-311-11/+0
| | | | | | | | | | | | | Remove DEFSYMs that aren't used at the C level. Also: * src/decompress.c (Qzlib_dll): * src/font.c (Qunicode_sip): * src/frame.c (Qtip_frame): * src/ftfont.c (Qserif): * src/gnutls.c (Qgnutls_dll): * src/xml.c (Qlibxml2_dll): Move from here ... * src/w32fns.c (syms_of_w32fns): ... to here, as these are used only on MS-Windows.
* Prefer 'Qfoo' to 'intern ("foo")'Paul Eggert2015-02-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * buffer.c (syms_of_buffer): * bytecode.c (exec_byte_code): * callint.c (Fcall_interactively): * callproc.c (create_temp_file): * charset.c (define_charset_internal): * coding.c (syms_of_coding): * editfns.c (syms_of_editfns): * emacs.c (main): * fns.c (syms_of_fns): * frame.c (delete_frame, Fframe_parameters): * keyboard.c (syms_of_keyboard): * keymap.c (syms_of_keymap): * minibuf.c (read_minibuf, syms_of_minibuf): * nsfns.m (ns_cursor_type_to_lisp): * textprop.c (syms_of_textprop): * xdisp.c (Fformat_mode_line, syms_of_xdisp): * xfns.c (x_create_tip_frame, Fx_select_font): * xml.c (parse_region): Prefer constants like 'Qfoo' to calls like 'intern ("foo")'. * buffer.c (syms_of_buffer): OK to do (put 'erase-buffer 'disabled t) here now ... (keys_of_buffer): ... instead of here. * ftfont.c (syms_of_ftfont): Move DEFSYM of Qmono from here ... * xfns.c (syms_of_xfns): ... to here, since ftfont.c is more optional than xfns.c.
* Avoid aborts when keyboard-coding-system is raw-text (Bug#19532)Eli Zaretskii2015-01-311-0/+9
| | | | | | | src/coding.c (raw_text_coding_system_p): New function. src/keyboard.c (read_decoded_event_from_main_queue): Use it when the keyboard coding-system is 'raw-text'. src/coding.h (raw_text_coding_system_p): Add prototype.
* Merge from origin/emacs-24Fabián Ezequiel Gallina2015-01-281-1/+2
|\ | | | | | | | | | | 8ee825c doc/emacs/programs.texi (Custom C Indent): Fix a typo. (Bug#19647) 88ba49f Fix coding.c subscript error 3ea1b31 Prevent artist-mode from creating runaway timers (Bug#6130).
| * Fix coding.c subscript errorPaul Eggert2015-01-211-1/+2
| | | | | | | | | | * coding.c (CODING_ISO_INVOKED_CHARSET): Avoid undefined behavior if CODING_ISO_INVOCATION returns negative.
| * Update copyright year to 2015Paul Eggert2015-01-011-1/+1
| | | | | | | | Run admin/update-copyright.
| * Fix bug #18610 with crashes when visiting files with ESC and 8-bit bytes.Kenichi Handa2014-10-081-8/+26
| | | | | | | | | | | | | | src/coding.c (detect_coding_iso_2022): Set coding->rejected correctly when an invalid escape sequence is found. Backported from trunk.
* | Count MANY function args more reliablyPaul Eggert2015-01-251-56/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (Fgc_status, purecopy, unbind_to, garbage_collect_1): * buffer.c (Fbuffer_list, Fkill_buffer): * callint.c (read_file_name, Fcall_interactively): * charset.c (Fset_charset_priority, syms_of_charset): * chartab.c (uniprop_encode_value_numeric): * coding.c (syms_of_coding): * composite.c (syms_of_composite): * data.c (wrong_range): * dbusbind.c (syms_of_dbusbind): * dired.c (file_attributes): * editfns.c (Fdecode_time, update_buffer_properties, format2): * eval.c (run_hook_with_args_2, apply1, call1, call2, call3) (call4, call5, call6, call7): * fileio.c (Finsert_file_contents, choose_write_coding_system) (Fcar_less_than_car, build_annotations, auto_save_error): * filelock.c (get_boot_time): * fns.c (internal_equal, nconc2, Fyes_or_no_p, Fwidget_apply): (maybe_resize_hash_table, secure_hash): * font.c (font_style_to_value, font_open_by_name, Flist_fonts): * fontset.c (fontset_add, Fset_fontset_font): * ftfont.c (ftfont_lookup_cache): * gtkutil.c (xg_get_font): * insdel.c (signal_before_change, signal_after_change): * keymap.c (append_key): * lread.c (load_warn_old_style_backquotes, Fload, init_lread): * minibuf.c (Fread_buffer): * print.c (print_preprocess): * process.c (Fformat_network_address, Fmake_network_process) (server_accept_connection): * sound.c (Fplay_sound_internal): * term.c (Fsuspend_tty, Fresume_tty): * window.c (window_list): * xdisp.c (run_redisplay_end_trigger_hook, add_to_log) (message_with_string): * xfaces.c (Fx_list_fonts): * xfont.c (syms_of_xfont): * xselect.c (x_handle_selection_request) (x_handle_selection_clear, x_clear_frame_selections) (x_clipboard_manager_error_1): Prefer CALLMANY and CALLN to counting args by hand. * doc.c (reread_doc_file): Remove unused code. * fns.c (concat2, concat3): Redo to avoid need for local-var vector. (cmpfn_user_defined, hashfn_user_defined, Fmaphash): Prefer call1 and call2 to Ffuncall. * keyboard.c (safe_run_hook_funcall, safe_run_hooks): Use struct literal rather than a local var, for simplicity. * keymap.c (where_is_internal): Use NULL rather than a pointer to unused args. * lisp.h (CALLMANY, CALLN): New macros. * sound.c (Fplay_sound_internal): Coalesce duplicate code. Fixes: bug#19634
* | Better isolate code that assumes NIL_IS_ZEROPaul Eggert2015-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Stefan Monnier in: http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00588.html * alloc.c (allocate_pseudovector): Use memclear, not memsetnil, to remove a 'verify'. * callint.c (Fcall_interactively): * dispnew.c (realloc_glyph_pool): * xdisp.c (init_iterator): Use memclear, not memset, to remove a 'verify'. * lisp.h (memclear): Rename from memsetnil, and take a byte count rather than a word count. All callers changed.
* | Port to hypothetical case where Qnil is nonzeroPaul Eggert2015-01-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (allocate_pseudovector): * callint.c (Fcall_interactively): * coding.c (syms_of_coding): * dispnew.c (realloc_glyph_pool): * fringe.c (init_fringe): * lisp.h (memsetnil): * xdisp.c (init_iterator): Port to the currently-hypothetical case where Qnil is nonzero. * dispnew.c (adjust_glyph_matrix): Remove unnecessary verification, as there are no Lisp_Object values in the data here. * lisp.h (NIL_IS_NONZERO): New symbol, replacing NIL_IS_ZERO. All uses changed. Define only if not already defined, so that one can debug with -DNIL_IS_NONZERO. * xdisp.c (init_iterator): Remove unnecessary initializations to 0.
* | Prefer memset to repeatedly assigning QnilPaul Eggert2015-01-191-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (allocate_pseudovector): Catch more bogus values. * alloc.c (allocate_pseudovector): * callint.c (Fcall_interactively): * coding.c (syms_of_coding): * fringe.c (init_fringe): Verify that Qnil == 0. * callint.c (Fcall_interactively): * eval.c (Fapply, Ffuncall): * fns.c (mapcar1, larger_vector): * font.c (font_expand_wildcards): * fringe.c (init_fringe): Prefer memset to assigning zeros by hand. * callint.c (Fcall_interactively): Remove duplicate assignment of Qnil to args[i]. * coding.c (syms_of_coding): Prefer LISP_INITIALLY_ZERO to assigning zeros by hand. * fileio.c (Ffile_selinux_context): Rewrite to avoid need for Lisp_Object array. * lisp.h (XLI_BUILTIN_LISPSYM): New macro. (DEFINE_LISP_SYMBOL_END): Use it. (NIL_IS_ZERO): New constant. (memsetnil): New function.
* | * coding.c (Fcoding_system_plist): Use common style for docstring.Dmitry Antipov2015-01-111-1/+1
| |
* | Compute C decls for DEFSYMs automaticallyPaul Eggert2015-01-051-45/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes Bug#15880. This patch also makes Q constants (e.g., Qnil) constant addresses from the C point of view. * make-docfile.c: Revamp to generate table of symbols, too. Include <stdbool.h>. (xstrdup): New function. (main): Don't process the same file twice. (SYMBOL): New constant in enum global_type. (struct symbol): Turn 'value' member into a union, either v.value for int or v.svalue for string. All uses changed. (add_global): New arg svalue, which overrides value, so that globals can have a string value. (close_emacs_global): New arg num_symbols; all uses changed. Output lispsym decl. (write_globals): Output symbol globals too. Output more ATTRIBUTE_CONST, now that Qnil etc. are C constants. Output defsym_name table. (scan_c_file): Move most of guts into ... (scan_c_stream): ... new function. Scan for DEFSYMs and record symbols found. Don't read past EOF if file doesn't end in newline. * alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle: * casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c: * composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c: * frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c: * image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c: * macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m: * nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c: * search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c: * window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c: * xselect.c, xsettings.c, xterm.c: Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs). These names are now defined automatically by make-docfile. * alloc.c (init_symbol): New function. (Fmake_symbol): Use it. (c_symbol_p): New function. (valid_lisp_object_p, purecopy): Use it. * alloc.c (marked_pinned_symbols): Use make_lisp_symbol instead of make_lisp_ptr. (garbage_collect_1): Mark lispsym symbols. (CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro. (mark_object): Use it. (sweep_symbols): Sweep lispsym symbols. (symbol_uses_obj): New function. (which_symbols): Use it. Work for lispsym symbols, too. (init_alloc_once): Initialize Vpurify_flag here; no need to wait, since Qt's address is already known now. (syms_of_alloc): Add lispsym count to symbols_consed. * buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0), when testing whether storage is all bits zero. * dispextern (struct image_type): * font.c (font_property_table): * frame.c (struct frame_parm_table, frame_parms): * keyboard.c (scroll_bar_parts, struct event_head): * xdisp.c (struct props): Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and Lisp_Object *, since Qfoo is no longer an object whose address can be taken. All uses changed. * eval.c (run_hook): New function. Most uses of Frun_hooks changed to use it, so that they no longer need to take the address of a Lisp sym. (syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable. * frame.c (syms_of_frame): Add defsyms for the frame_parms table. * keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here. DEFSYM Qdeactivate_mark before the corresponding var. * keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line instead of interning their symbols; this avoids duplicates. (LISP_INITIALLY, TAG_PTR) (DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT): New macros. (LISP_INITIALLY_ZERO): Use it. (enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol) (EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*): Move decls up, to avoid forward uses. Include globals.h earlier, too. (make_lisp_symbol): New function. (XSETSYMBOL): Use it. (DEFSYM): Now just a placeholder for make-docfile. * lread.c (DEFINE_SYMBOLS): Define, for globals.h. (intern_sym): New function, with body taken from old intern_driver. (intern_driver): Use it. Last arg is now Lisp integer, not ptrdiff_t. All uses changed. (define_symbol): New function. (init_obarray): Define the C symbols taken from lispsym. Use plain DEFSYM for Qt and Qnil. * syntax.c (init_syntax_once): No need to worry about Qchar_table_extra_slots.
* | Update copyright year to 2015Paul Eggert2015-01-011-1/+1
| | | | | | | | Run admin/update-copyright.
* | Cleanup terminal handling code.Dmitry Antipov2014-10-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dispextern.h (get_named_tty): Remove prototype but... * termhooks.h (get_named_terminal): ...resurrect it under more meaningful name. (get_terminal): Likewise, but with... (decode_live_terminal): ...this name. (decode_tty_terminal): Add prototype. * term.c (get_tty_terminal): Remove. (get_named_tty): Remove. (Ftty_display_color_p, Ftty_display_color_cells, Ftty_type) (Fcontrolling_tty_p, Fsuspend_tty, Fresume_tty): Use decode_tty_terminal. (Ftty_no_underline, Ftty_top_frame): Use decode_live_terminal. * terminal.c (get_terminal): Refactor to... (decode_terminal, decode_live_terminal): ...new functions. (decode_tty_terminal): Replacement for get_tty_terminal. (get_named_terminal): Likewise for get_named_tty. * coding.c (Fset_terminal_coding_system_internal) (Fterminal_coding_system, Fset_keyboard_coding_system_internal): (Fkeyboard_coding_system): * composite.c (Fcomposition_get_gstring): * dispnew.c (Fsend_string_to_terminal): * frame.c (Fmake_terminal_frame): * nsfns.m (check_ns_display_info): * w32fns.c, xfns.c (check_x_display_info): * xselect.c (frame_for_x_selection): Use decode_live_terminal. * keyboard.c (handle_interrupt_signal, handle_interrupt) (Fset_quit_char): Use get_named_terminal. (Fset_output_flow_control, Fset_input_meta_mode): Use decode_tty_terminal.
* | coding.c (detect_coding_iso_2022): Fix previous change.Kenichi Handa2014-10-051-2/+2
| |
* | coding.c (detect_coding_iso_2022): Set coding->rejected correctly when an ↵Kenichi Handa2014-10-051-6/+24
| | | | | | | | invalid escape sequence is found (Bug#18610).
* | Consistently use min and max macros from lisp.h.Dmitry Antipov2014-10-031-9/+0
| | | | | | | | | | | | | | | | | | | | * coding.c (min, max): * font.c (MAX): * unexhp9k800.c (min): * unexw32.c (min, max): Use definitions from lisp.h. * regex.c (MAX, MIN) [!emacs]: Define own max and min as such. Adjust users. * gmalloc.c (min): Tiny style change.
* | Fix bug uncovered by changing alloca to auto buffer.Paul Eggert2014-09-071-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * coding.c (growable_destination): New function. (produce_chars): Use it for sanity checks. Do not fiddle with dst_end if the source and destination are both nil, as it's the caller's responsibility to avoid overlap. * keyboard.c (read_decoded_event_from_main_queue): The destination must be MAX_MULTIBYTE_LENGTH times the max source length, not 4 times, to prevent decode_coding_c_string from trying to reallocate a destination. This removes the need for the FIXME. Fixes: debbugs:18410
* | Use SAFE_ALLOCA etc. to avoid unbounded stack allocation.Paul Eggert2014-09-071-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows up on the recent thread in emacs-devel on alloca; see: http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00042.html This patch also cleans up alloca-related glitches noted while examining the code looking for unbounded alloca. * alloc.c (listn): * callproc.c (init_callproc): Rewrite to avoid need for alloca. * buffer.c (mouse_face_overlay_overlaps) (report_overlay_modification): * buffer.h (GET_OVERLAYS_AT): * coding.c (make_subsidiaries): * doc.c (Fsnarf_documentation): * editfns.c (Fuser_full_name): * fileio.c (Ffile_name_directory, Fexpand_file_name) (search_embedded_absfilename, Fsubstitute_in_file_name): * fns.c (Fmake_hash_table): * font.c (font_vconcat_entity_vectors, font_update_drivers): * fontset.c (fontset_pattern_regexp, Ffontset_info): * frame.c (Fmake_terminal_frame, x_set_frame_parameters) (xrdb_get_resource, x_get_resource_string): * ftfont.c (ftfont_get_charset, ftfont_check_otf, ftfont_drive_otf): * ftxfont.c (ftxfont_draw): * image.c (xbm_load, xpm_load, jpeg_load_body): * keyboard.c (echo_add_key, menu_bar_items, tool_bar_items): * keymap.c (Fdescribe_buffer_bindings, describe_map): * lread.c (openp): * menu.c (digest_single_submenu, find_and_call_menu_selection) (find_and_return_menu_selection): * print.c (PRINTFINISH): * process.c (Fformat_network_address): * scroll.c (do_scrolling, do_direct_scrolling, scrolling_1): * search.c (search_buffer, Fmatch_data, Fregexp_quote): * sound.c (wav_play, au_play): * syntax.c (skip_chars): * term.c (tty_menu_activate, tty_menu_show): * textprop.c (get_char_property_and_overlay): * window.c (Fset_window_configuration): * xdisp.c (safe__call, next_overlay_change, vmessage) (compute_overhangs_and_x, draw_glyphs, note_mouse_highlight): * xfaces.c (face_at_buffer_position): * xmenu.c (x_menu_show): Use SAFE_ALLOCA etc. instead of plain alloca, since the allocation size isn't bounded. * callint.c (Fcall_interactively): Redo memory_full check so that it can be done at compile-time on some platforms. * coding.c (MAX_LOOKUP_MAX): New constant. (get_translation_table): Use it. * callproc.c (call_process): Use SAFE_NALLOCA instead of SAFE_ALLOCA, to catch integer overflows on size calculation. (exec_failed) [!DOS_NT]: New function. (child_setup) [!DOS_NT]: Use it. * editfns.c (Ftranspose_regions): Hoist USE_SAFE_ALLOC + SAFE_FREE out of 'if'. * editfns.c (check_translation): Allocate larger buffers on the heap. * eval.c (internal_lisp_condition_case): Check for MAX_ALLOCA overflow. * fns.c (sort_vector): Use SAFE_ALLOCA_LISP rather than Fmake_vector. (Fbase64_encode_region, Fbase64_decode_region): Avoid unnecessary calls to SAFE_FREE before 'error'. * buffer.c (mouse_face_overlay_overlaps): * editfns.c (Fget_pos_property, check_translation): * eval.c (Ffuncall): * font.c (font_unparse_xlfd, font_find_for_lface): * ftfont.c (ftfont_drive_otf): * keyboard.c (echo_add_key, read_decoded_event_from_main_queue) (menu_bar_items, tool_bar_items): * sound.c (Fplay_sound_internal): * xdisp.c (load_overlay_strings, dump_glyph_row): Use an ordinary auto buffer rather than alloca, since the allocation size is fixed and small. * ftfont.c: Include <c-strcase.h>. (matching_prefix): New function. (get_adstyle_property): Use it, to avoid need for alloca. * keyboard.c (echo_add_key): * keymap.c (describe_map): Use ptrdiff_t, not int. * keyboard.c (echo_add_key): Prefer sizeof to strlen. * keymap.c (Fdescribe_buffer_bindings): Use SBYTES, not SCHARS, when counting bytes. * lisp.h (xlispstrdupa): Remove, replacing with ... (SAFE_ALLOCA_STRING): ... new macro with different API. This fixes a portability problem, namely, alloca result passed to another function. All uses changed. (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Check for MAX_ALLOCA, not MAX_ALLOCA - 1. * regex.c (REGEX_USE_SAFE_ALLOCA, REGEX_SAFE_FREE) (REGEX_ALLOCATE): New macros. (REGEX_REALLOCATE, REGEX_ALLOCATE_STACK, REGEX_REALLOCATE_STACK) (REGEX_FREE_STACK, FREE_VARIABLES, re_match_2_internal): Use them. * xdisp.c (message3): Use SAFE_ALLOCA_STRING rather than doing it by hand. (decode_mode_spec_coding): Store directly into buf rather than into an alloca temporary and copying the temporary to the buf. Fixes: debbugs:18410
* | Merge from emacs-24; up to 2014-06-28T23:35:17Z!rgm@gnu.orgGlenn Morris2014-08-101-3/+3
|\ \ | |/
| * src/coding.c: Fix typos in comments and doc strings.Eli Zaretskii2014-08-061-3/+3
| |
* | * coding.h (struct coding_system): Remove 'error_positions' (unused)Dmitry Antipov2014-07-101-10/+0
| | | | | | | | | | | | | | | | | | | | and 'errors' (set but unused) fields. Use bitfields for 'eol_seen', 'mode', 'common_flags' and 'result' fields, adjust layout to avoid extra padding and shrink struct coding_system by 56 bytes (x86_64). * coding.c (decode_coding_utf_8, decode_coding_utf_16) (decode_coding_emacs_mule, decode_coding_iso_2022, decode_coding_sjis) (decode_coding_big5, decode_coding_charset, decode_coding) (encode_coding): Adjust users.
* | * coding.c (ALLOC_CONVERSION_WORK_AREA): Prefer ptrdiff_t to int andDmitry Antipov2014-07-091-7/+4
| | | | | | | | so avoid integer overflow if decoded gap size exceeds INT_MAX bytes.
* | merge trunkKenichi Handa2014-07-021-1/+1
|\ \
| * | Fix bug #17881 with infloop in decoding emacs-mule encoded text.Eli Zaretskii2014-06-301-1/+2
| | | | | | | | | | | | src/coding.c (MIN_CHARBUF_SIZE): Enlarge to 32.
| * | Merge from emacs-24; up to 2014-06-12T14:55:48Z!monnier@iro.umontreal.caGlenn Morris2014-06-281-1/+1
| |\ \ | | |/
| | * Fixes: debbugs:17865Andreas Schwab2014-06-281-1/+1
| | | | | | | | | | | | | | | * coding.c (encode_coding_utf_8): Correctly count produced_chars also in unibyte case.
* | | * coding.c (MIN_CHARBUF_SIZE): Delete it.Kenichi Handa2014-07-021-4/+8
|/ / | | | | | | | | (MAX_CHARBUF_EXTRA_SIZE): New macro. (ALLOC_CONVERSION_WORK_AREA): Use MAX_CHARBUF_EXTRA_SIZE.
* | * coding.c (MAX_CHARBUF_SIZE): Renamed from CHARBUF_SIZE.Kenichi Handa2014-06-281-8/+11
| | | | | | | | | | (MIN_CHARBUF_SIZE): New macro. (ALLOC_CONVERSION_WORK_AREA): New arg SIZE. Callers changed.
* | Consistently use validate_subarray to verify substring.Dmitry Antipov2014-06-251-10/+5
| | | | | | | | | | | | | | | | | | | | * fns.c (validate_substring): Not static any more. Adjust to use ptrdiff_t, not EMACS_INT, becase string and vector limits can't exceed ptrdiff_t even if EMACS_INT is wider. * lisp.h (validate_subarray): Add prototype. * coding.c (Fundecodable_char_position): * composite.c (Fcomposition_get_gstring, Fcompose_string_internal): Use validate_subarray. Adjust comment to mention substring.
* | Simplify and cleanup character conversion stuff.Dmitry Antipov2014-06-231-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp.h (multibyte_char_to_unibyte, multibyte_char_to_unibyte_safe): Remove prototypes. * character.c (multibyte_char_to_unibyte) (multibyte_char_to_unibyte_safe): Remove; no longer used. * character.h (make_char): Remove; unused. (CHAR_TO_BYTE8, CHAR_TO_BYTE_SAFE): Simplify. (ASCII_BYTE_P): Remove; ASCII_CHAR_P does the same thing. * buffer.c, charset.c, charset.h, cmds.c, coding.c, editfns.c: * fileio.c, indent.c, insdel.c, keyboard.c, lread.c, print.c: * search.c, term.c, xdisp.c, xterm.c: Related users changed.
* | Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.Paul Eggert2014-04-051-2/+2
|/ | | | | | | | | | | | | | | | * alloc.c (memory_full): * charset.c (syms_of_charset): * doc.c (Fsnarf_documentation): * emacs.c (main): * font.c (BUILD_STYLE_TABLE): * keyboard.c (make_lispy_event): * profiler.c (setup_cpu_timer): * xgselect.c (xg_select): * xterm.c (record_event, STORE_KEYSYM_FOR_DEBUG): Use ARRAYELTS. * font.c (FONT_PROPERTY_TABLE_SIZE): Remove. Replace the only use with ARRAYELTS (font_property_table). * xfaces.c (DIM): Remove. All uses replaced by ARRAYELTS.
* Fix bug#16286 by the different way than ↵Kenichi Handa2014-01-291-2/+4
| | | | 2014-01-26T00:32:30Z!eggert@cs.ucla.edu to preserve the code detection behavior of 24.3.
* When decoding, prefer ptrdiff_t to int for buffer positions etc.Paul Eggert2014-01-251-8/+8
| | | | | | | | | * coding.c (detect_coding_utf_8, emacs_mule_char) (detect_coding_iso_2022, encode_coding_iso_2022, check_ascii) (check_utf_8, decode_coding): * coding.h (struct coding_system.errors): Use ptrdiff_t, not int, for integer values derived from buffer and string positions.
* Update copyright year to 2014 by running admin/update-copyright.Paul Eggert2014-01-011-1/+1
|