1. 25 Apr, 2020 1 commit
    • Paul Eggert's avatar
      Inline a couple of functions that were macros · 24849c1b
      Paul Eggert authored
      This reclaims a bit of performance when compiling with gcc -Og.
      These functions were macros until I changed them in
      2020-04-17T14:57:25Z!eggert@cs.ucla.edu.
      * src/casefiddle.c (make_char_unibyte):
      * src/ccl.c (GET_TRANSLATION_TABLE): Now inline.
      24849c1b
  2. 17 Apr, 2020 1 commit
    • Paul Eggert's avatar
      Prefer more inline functions in character.h · 27d10183
      Paul Eggert authored
      * src/buffer.h (fetch_char_advance, fetch_char_advance_no_check)
      (buf_next_char_len, next_char_len, buf_prev_char_len)
      (prev_char_len, inc_both, dec_both): New inline functions,
      replacing the old character.h macros FETCH_CHAR_ADVANCE,
      FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS,
      DEC_POS, INC_BOTH, DEC_BOTH respectively.  All callers changed.
      These new functions all assume buffer primitives and so need
      to be here rather than in character.h.
      * src/casefiddle.c (make_char_unibyte): New static function,
      replacing the old MAKE_CHAR_UNIBYTE macro.  All callers changed.
      (do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead
      of open-coding it.
      * src/ccl.c (GET_TRANSLATION_TABLE): New static function,
      replacing the old macro of the same name.
      * src/character.c (string_char): Omit 2nd arg.  3rd arg can no
      longer be NULL.  All callers changed.
      * src/character.h (SINGLE_BYTE_CHAR_P): Move up.
      (MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY)
      (STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE)
      (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH)
      (DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove.
      (make_char_multibyte): New static function, replacing
      the old macro MAKE_CHAR_MULTIBYTE.  All callers changed.
      (CHAR_STRING_ADVANCE): Remove; all callers changed to use
      CHAR_STRING.
      (NEXT_CHAR_BOUNDARY): Remove; it was unused.
      (raw_prev_char_len): New inline function, replacing the
      old PREV_CHAR_BOUNDARY macro.  All callers changed.
      (string_char_and_length): New inline function, replacing the
      old STRING_CHAR_AND_LENGTH macro.  All callers changed.
      (STRING_CHAR): Rewrite in terms of string_char_and_length.
      (string_char_advance): New inline function, replacing the old
      STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_advance): New inline function, replacing the
      old FETCH_STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_as_multibyte_advance): New inline function,
      replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro.
      All callers changed.
      (fetch_string_char_advance_no_check): New inline function,
      replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro.  All
      callers changed.
      * src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used.
      * src/syntax.c (scan_lists): Use dec_bytepos instead of
      open-coding it.
      * src/xdisp.c (string_char_and_length): Rename from
      string_char_and_length to avoid name conflict with new function in
      character.h.  All callers changed.
      27d10183
  3. 12 Apr, 2020 1 commit
    • Paul Eggert's avatar
      Remove UNSIGNED_CMP · 43282a67
      Paul Eggert authored
      I added this macro in 2011 to fix some signedness comparison bugs.
      However, it’s a weird macro and the bugs can be fixed in a
      more-straightforward way.  This helps performance slightly (0.5%) on my
      platform (Fedora 31 x86-64, GCC 9.3.1 with -O2).
      * src/casefiddle.c (do_casify_natnum): Use simple comparison
      instead of UNSIGNED_CMP.
      * src/character.h (CHAR_VALID_P, SINGLE_BYTE_CHAR_P, CHAR_STRING):
      * src/composite.h (COMPOSITION_ENCODE_RULE_VALID):
      * src/lisp.h (ASCII_CHAR_P):
      Now an inline function, and uses simple comparison instead of
      UNSIGNED_CMP.
      * src/dispextern.h (FACE_FROM_ID, FACE_FROM_ID_OR_NULL)
      (IMAGE_FROM_ID, IMAGE_OPT_FROM_ID): Move these to ...
      * src/frame.h (FACE_FROM_ID, FACE_FROM_ID_OR_NULL)
      (IMAGE_FROM_ID, IMAGE_OPT_FROM_ID): ... here, and make them
      inline functions that no longer use UNSIGNED_CMP.
      * src/keyboard.c (read_char): UNSIGNED_CMP is not needed here
      since XFIXNAT always returns a nonnegative value.
      * src/lisp.h (UNSIGNED_CMP): Remove; no longer used.
      43282a67
  4. 01 Jan, 2020 1 commit
  5. 22 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Avoid crashes when casifying noncontiguous regions · 2f600e97
      Paul Eggert authored
      This is a followon fix for Bug#37477.
      * lisp/simple.el (region-extract-function):
      Use setq here, since the var is now defined in C code.
      * src/casefiddle.c (casify_pnc_region): New function.
      (Fupcase_region, Fdowncase_region, Fcapitalize_region)
      (Fupcase_initials_region): Use it.
      (Fupcase_initials_region): Add region-noncontiguous-p flag
      for consistency with the others.  All uses changed.
      (syms_of_casefiddle): Define Qbounds, Vregion_extract_function.
      * src/insdel.c (prepare_to_modify_buffer_1):
      * src/keyboard.c (command_loop_1):
      Use Vregion_extraction_function.
      * src/insdel.c (syms_of_insdel): No need to define
      Qregion_extract_function.
      * test/src/casefiddle-tests.el (casefiddle-oldfunc): New var.
      (casefiddle-loopfunc, casefiddle-badfunc): New functions.
      (casefiddle-invalid-region-extract-function): New test.
      2f600e97
  6. 21 Sep, 2019 1 commit
    • Juri Linkov's avatar
      Support rectangular regions in capitalize-region and capitalize-dwim. · 2879c3ec
      Juri Linkov authored
      * lisp/simple.el (capitalize-dwim): Add arg region-noncontiguous-p
      in capitalize-region call.
      
      * src/casefiddle.c (Fcapitalize_region): Add arg region-noncontiguous-p.
      If non-nil, operate on multiple chunks.  (Bug#37477)
      (Fdowncase_region): Use builtin symbol Qregion_extract_function
      rather than calling intern.
      2879c3ec
  7. 15 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Remove INT_ADD_WRAPV bug workarounds · 2098e8af
      Paul Eggert authored
      * src/alloc.c (free_cons):
      * src/casefiddle.c (do_casify_multibyte_string):
      * src/editfns.c (styled_format):
      * src/image.c (png_load_body):
      Remove recent workarounds for INT_ADD_WRAPV bugs since
      the bugs have been fixed (Bug#37006).
      2098e8af
  8. 12 Aug, 2019 2 commits
    • Eli Zaretskii's avatar
      ; Add commentary to recent changes · 2b329ed4
      Eli Zaretskii authored
      * src/image.c (png_load_body):
      * src/editfns.c (styled_format):
      * src/casefiddle.c (do_casify_multibyte_string):
      * src/alloc.c (free_cons): Comment why we use a signed
      temporary integer variable.  (Bug#37006)
      2b329ed4
    • Paul Eggert's avatar
      Prefer signed when testing for signed overflow · 57fc1a5f
      Paul Eggert authored
      * src/alloc.c (free_cons):
      * src/casefiddle.c (do_casify_multibyte_string):
      * src/editfns.c (styled_format):
      * src/image.c (png_load_body):
      Use signed arguments to INT_MULTIPLY_WRAPV etc.  This doesn’t fix
      any bugs, but GCC emits better code when all args are signed.
      Also, this removes the need for an if in free_cons (Bug#37006).
      57fc1a5f
  9. 31 Jul, 2019 1 commit
  10. 01 Jan, 2019 1 commit
  11. 08 Aug, 2018 1 commit
    • Tom Tromey's avatar
      More macro renamings for bignum · d1ec3a0a
      Tom Tromey authored
      * src/alloc.c, src/bidi.c, src/buffer.c, src/buffer.h, src/bytecode.c,
      src/callint.c, src/callproc.c, src/casefiddle.c, src/casetab.c,
      src/category.c, src/ccl.c, src/character.c, src/character.h,
      src/charset.c, src/charset.h, src/chartab.c, src/cmds.c, src/coding.c,
      src/composite.c, src/composite.h, src/data.c, src/dbusbind.c,
      src/decompress.c, src/dired.c, src/dispextern.h, src/dispnew.c,
      src/disptab.h, src/doc.c, src/dosfns.c, src/editfns.c,
      src/emacs-module.c, src/emacs.c, src/eval.c, src/fileio.c,
      src/floatfns.c, src/fns.c, src/font.c, src/font.h, src/fontset.c,
      src/frame.c, src/frame.h, src/fringe.c, src/ftcrfont.c, src/ftfont.c,
      src/gfilenotify.c, src/gnutls.c, src/gtkutil.c, src/image.c,
      src/indent.c, src/insdel.c, src/intervals.c, src/json.c,
      src/keyboard.c, src/keymap.c, src/kqueue.c, src/lcms.c, src/lisp.h,
      src/lread.c, src/macros.c, src/marker.c, src/menu.c, src/minibuf.c,
      src/msdos.c, src/print.c, src/process.c, src/profiler.c, src/search.c,
      src/sound.c, src/syntax.c, src/syntax.h, src/sysdep.c, src/term.c,
      src/termhooks.h, src/textprop.c, src/undo.c, src/w32.c,
      src/w32console.c, src/w32fns.c, src/w32font.c, src/w32inevt.c,
      src/w32proc.c, src/w32select.c, src/w32term.c, src/w32term.h,
      src/w32uniscribe.c, src/window.c, src/xdisp.c, src/xfaces.c,
      src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c, src/xml.c,
      src/xrdb.c, src/xselect.c, src/xsettings.c, src/xterm.c, src/xwidget.c
      Rename XINT->XFIXNUM, XFASTINT->XFIXNAT, XUINT->XUFIXNUM.
      d1ec3a0a
  12. 13 Jul, 2018 1 commit
    • Tom Tromey's avatar
      Rename integerp->fixnum, etc, in preparation for bignums · 42fe787b
      Tom Tromey authored
      * src/json.c, src/keyboard.c, src/keyboard.h, src/keymap.c,
      src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c,
      src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c,
      src/process.c, src/profiler.c, src/search.c, src/sound.c,
      src/syntax.c, src/sysdep.c, src/term.c, src/terminal.c,
      src/textprop.c, src/undo.c, src/w16select.c, src/w32.c,
      src/w32console.c, src/w32cygwinx.c, src/w32fns.c, src/w32font.c,
      src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c,
      src/w32uniscribe.c, src/widget.c, src/window.c, src/xdisp.c,
      src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c,
      src/xrdb.c, src/xselect.c, src/xterm.c, src/xwidget.c: Rename
      INTEGERP->FIXNUM, make_number->make_fixnum, CHECK_NUMBER->CHECK_FIXNUM,
      make_natnum->make_fixed_natum, NUMBERP->FIXED_OR_FLOATP,
      NATNUMP->FIXNATP, CHECK_NATNUM->CHECK_FIXNAT.
      42fe787b
  13. 01 Jan, 2018 1 commit
  14. 13 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Use alignas to fix GCALIGN-related bugs · b1573a97
      Paul Eggert authored
      Use alignas and unions to specify alignments of objects needing
      addresses that are at least a multiple of GCALIGNMENT.  Using
      these standard C facilities should be safer than relying on ad hoc
      and poorly-understood features like GCC’s __attribute__
      ((aligned (N))), the root cause for recent porting bugs like
      Bug#29040.  The alignas macro was standardized by C11 and Gnulib
      supports alignas for pre-C11 platforms.  I have tested this on Sun
      Studio 12 sparc (2007) and GCC 4.4.7 x86-64 (2012) as well as on
      more recent platforms like GCC 7.2.1 (2017) on Fedora 26 (both
      x86-64 and x86).
      * lib-src/make-docfile.c (close_emacs_globals): lispsym is now
      just an array of struct Lisp_Symbol, since struct Lisp_Symbol is
      now properly aligned.  All uses changed.
      * src/alloc.c (NEXT_FREE_LISP_STRING): Just use the new u.next
      member; this is simpler and safer than casting a pointer that
      might not be aligned properly.
      (aligned_Lisp_Symbol): Remove.  No longer needed, now that struct
      Lisp_Symbol is aligned properly.  All uses replaced with struct
      Lisp_Symbol.
      * src/lisp.h (GCALIGNED): Remove, as it does not work as expected:
      it can cause the natural alignment to be ignored.  All uses
      replaced by unions with a ‘char alignas (GCALIGNMENT)’ member as
      described below.
      (struct Lisp_Symbol, struct Lisp_Cons, struct Lisp_String):
      Change definition from ‘struct TAG { MEMBERS };’ to
      ‘struct TAG { union { struct { MEMBERS } s; char alignas
      (GCALIGNMENT) gcaligned; } u; };’.  This guarantees ‘struct TAG’
      to have an alignment that at least max (GCALIGNMENT, N) where N is
      its old alignment.  All uses like ‘PTR->MEMBER’ changed to
      ‘PTR->u.s.MEMBER’; these uses were supposed to be mostly private
      anyway.  Verify that the resulting ‘struct TAG’ is properly
      aligned for Emacs.
      (union vectorlike_header): New member ‘gcaligned’ to guarantee
      that this type, and its containing types like ‘struct Lisp_Subr’,
      ‘struct buffer’ and ‘struct thread_state’, are all properly
      aligned for Emacs.
      (struct Lisp_String): New union member ‘next’, for the benefit
      of NEXT_FREE_LISP_STRING.
      (union Aligned_Cons, union Aligned_String): Remove.  All uses
      replaced by struct Lisp_Cons and struct Lisp_String, since they
      are now properly aligned.
      (USE_STACK_CONS, USE_STACK_STRING): Simplify now that we can
      assume struct Lisp_Cons and struct Lisp_String are properly
      aligned.
      b1573a97
  15. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
      bc511a64
  16. 07 Apr, 2017 2 commits
    • Paul Eggert's avatar
      More casefiddle minor fixes · 2012839a
      Paul Eggert authored
      * src/casefiddle.c (case_character_impl): Omit unnecessary casts.
      (case_character_impl): Avoid reevaluation of CHAR_TABLE_REF.
      (GREEK_CAPITAL_LETTER_SIGMA): Fix typo in my previous change.
      2012839a
    • Noam Postavsky's avatar
      Fix ‘!NILP (Vpurify_flag)’ assertion failure during temacs bootstrap · 4b3db0da
      Noam Postavsky authored
      The recent changes to src/casefiddle.c cause build failure as seen
      below:
      
          Starting program: /home/npostavs/src/emacs/emacs-bootstrapping/src/temacs
      	--batch --load loadup bootstrap
          [Thread debugging using libthread_db enabled]
          Using host libthread_db library "/usr/lib/libthread_db.so.1".
          Loading loadup.el (source)...
          Using load-path (/home/npostavs/src/emacs/emacs-bootstrapping/lisp
      	/home/npostavs/src/emacs/emacs-bootstrapping/lisp/emacs-lisp
      	/home/npostavs/src/emacs/emacs-bootstrapping/lisp/language
      	/home/npostavs/src/emacs/emacs-bootstrapping/lisp/international
      	/home/npostavs/src/emacs/emacs-bootstrapping/lisp/textmodes
      	/home/npostavs/src/emacs/emacs-bootstrapping/lisp/vc)
          Loading emacs-lisp/byte-run (source)...
          Loading emacs-lisp/backquote (source)...
          Loading subr (source)...
          Loading version (source)...
          Loading widget (source)...
          Loading custom (source)...
          Loading emacs-lisp/map-ynp (source)...
          Loading international/mule (source)...
          Loading international/mule-conf (source)...
      
          lread.c:3914: Emacs fatal error: assertion failed: !NILP (Vpurify_flag)
      
          Breakpoint 1, terminate_due_to_signal at emacs.c:363
          363	  signal (sig, SIG_DFL);
          (gdb) bt
          #0  0x0000000000579826 in terminate_due_to_signal at emacs.c:363
          #1  0x000000000060ec33 in die at alloc.c:7352
          #2  0x000000000066db40 in intern_c_string_1 at lread.c:3914
          #3  0x0000000000576884 in intern_c_string at lisp.h:3790
          #4  0x00000000005dc84f in prepare_casing_context at casefiddle.c:69
          #5  0x00000000005dd37f in casify_object at casefiddle.c:311
          #6  0x00000000005dd47f in Fcapitalize at casefiddle.c:356
          #7  0x00000000006325ac in eval_sub at eval.c:2219
          #8  0x0000000000632368 in eval_sub at eval.c:2184
          #9  0x000000000063446c in apply_lambda at eval.c:2875
          #10 0x00000000006329af in eval_sub at eval.c:2294
          #11 0x000000000062d462 in Fprogn at eval.c:449
          #12 0x000000000062d4cf in prog_ignore at eval.c:461
          #13 0x000000000062f19c in Fwhile at eval.c:982
          #14 0x00000000006321f4 in eval_sub at eval.c:2172
          #15 0x000000000062d462 in Fprogn at eval.c:449
          #16 0x000000000062f0c4 in Flet at eval.c:963
          #17 0x00000000006321f4 in eval_sub at eval.c:2172
          #18 0x0000000000632963 in eval_sub at eval.c:2290
          #19 0x000000000062d462 in Fprogn at eval.c:449
          #20 0x000000000062f0c4 in Flet at eval.c:963
          #21 0x00000000006321f4 in eval_sub at eval.c:2172
          #22 0x0000000000668caa in readevalloop at lread.c:1927
          #23 0x0000000000667253 in Fload at lread.c:1332
          #24 0x0000000000632683 in eval_sub at eval.c:2233
          #25 0x0000000000668caa in readevalloop at lread.c:1927
          #26 0x0000000000667253 in Fload at lread.c:1332
          #27 0x0000000000632683 in eval_sub at eval.c:2233
          #28 0x0000000000631be5 in Feval at eval.c:2041
          #29 0x000000000057e1af in top_level_2 at keyboard.c:1121
          #30 0x000000000062ffc7 in internal_condition_case at eval.c:1324
          #31 0x000000000057e1f0 in top_level_1 at keyboard.c:1129
          #32 0x000000000062f51e in internal_catch at eval.c:1091
          #33 0x000000000057e0ea in command_loop at keyboard.c:1090
          #34 0x000000000057d6d5 in recursive_edit_1 at keyboard.c:697
          #35 0x000000000057d8b4 in Frecursive_edit at keyboard.c:768
          #36 0x000000000057b55b in main at emacs.c:1687
      
          Lisp Backtrace:
          "capitalize" (0xffffcf70)
          "format" (0xffffd130)
          "define-charset" (0xffffd370)
          "while" (0xffffd560)
          "let" (0xffffd7c0)
          "dolist" (0xffffd910)
          "let" (0xffffdb70)
          "load" (0xffffdfe0)
          "load" (0xffffe4a0)
      
      * src/casefiddle.c (syms_of_casefiddle): Declare four new symbols:
      Qtitlecase, Qspecial_uppercase, Qspecial_lowercase and
      Qspecial_titlecase.
      (prepare_casing_context): Use aforementioned symbols.
      4b3db0da
  17. 06 Apr, 2017 7 commits
    • Paul Eggert's avatar
      Minor casefiddle.c cleanups · 451a0c8b
      Paul Eggert authored
      * src/casefiddle.c: Redo recent changes to match GNU style,
      and prefer C99-style decls within blocks.
      (GREEK_CAPITAL_LETTER_SIGMA): Rename from CAPITAL_SIGMA, so that
      we are merely using the Unicode name, and make it a constant
      rather than a macro.  All uses changed.
      (SMALL_SIGMA): Remove; unused.
      (GREEK_SMALL_LETTER_FINAL_SIGMA): Rename from SMALL_FINAL_SIGMA,
      and make it a constant rather than a macro.  All uses changed.
      (do_casify_multibyte_string): Use ‘verify’ rather than an
      unportable static_assertion local.
      451a0c8b
    • Michal Nazarewicz's avatar
      Implement special sigma casing rule (bug#24603) · c1fa0722
      Michal Nazarewicz authored
      In Greek, a sigma character has two lower case forms which depend on
      their position in the word.  Implement logic determining it.
      
      * src/casefiddle.c (struct casing_context, case_character_impl): Don’t
      assume inword is true when flag is CASE_UP and false when flag is
      CASE_DOWN.  For final sigma detection we need this information tracked
      reliably;.
      (CAPITAL_SIGMA, SMALL_SIGMA, SMALL_FINAL_SIGMA): New macros defining
      Unicode code point of different forms of sigma letter.
      (case_character): Implement support for final sigma casing.
      (do_casify_multibyte_string, do_casify_multibyte_region): Update after
      changes to case_character.
      
      * test/src/casefiddle-tests.el (casefiddle-tests-casing): Add test
      cases for final sigma.
      c1fa0722
    • Michal Nazarewicz's avatar
      Support casing characters which map into multiple code points (bug#24603) · b3b9b258
      Michal Nazarewicz authored
      Implement unconditional special casing rules defined in Unicode standard.
      
      Among other things, they deal with cases when a single code point is
      replaced by multiple ones because single character does not exist (e.g.
      ‘fi’ ligature turning into ‘FL’) or is not commonly used (e.g. ß turning
      into SS).
      
      * admin/unidata/SpecialCasing.txt: New data file pulled from Unicode
      standard distribution.
      * admin/unidata/README: Mention SpecialCasing.txt.
      
      * admin/unidata/unidata-get.el (unidata-gen-table-special-casing,
      unidata-gen-table-special-casing--do-load): New functions generating
      ‘special-uppercase’, ‘special-lowercase’ and ‘special-titlecase’
      character Unicode properties built from the SpecialCasing.txt Unicode
      data file.
      
      * src/casefiddle.c (struct casing_str_buf): New structure for
      representing short strings used to handle one-to-many character
      mappings.
      
      (case_character_imlp): New function which can handle one-to-many
      character mappings.
      (case_character, case_single_character): Wrappers for the above
      functions.  The former may map one character to multiple (or no)
      code points while the latter does what the former used to do (i.e.
      handles one-to-one mappings only).
      
      (do_casify_natnum, do_casify_unibyte_string,
      do_casify_unibyte_region): Use case_single_character.
      (do_casify_multibyte_string, do_casify_multibyte_region): Support new
      features of case_character.
      * (do_casify_region): Updated to reflact do_casify_multibyte_string
      changes.
      
      (casify_word): Handle situation when one character-length of a word
      can change affecting where end of the word is.
      
      (upcase, capitalize, upcase-initials): Update documentation to mention
      limitations when working on characters.
      
      * test/src/casefiddle-tests.el (casefiddle-tests-char-properties):
      Add test cases for the newly introduced character properties.
      (casefiddle-tests-casing): Update test cases which are now passing.
      
      * test/lisp/char-fold-tests.el (char-fold--ascii-upcase,
      char-fold--ascii-downcase): New functions which behave like old ‘upcase’
      and ‘downcase’.
      (char-fold--test-match-exactly): Use the new functions.  This is needed
      because otherwise fi and similar characters are turned into their multi-
      -character representation.
      
      * doc/lispref/strings.texi: Describe issue with casing characters versus
      strings.
      * doc/lispref/nonascii.texi: Describe the new character properties.
      b3b9b258
    • Michal Nazarewicz's avatar
      Split up casify_region function (bug#24603) · 2c87dabd
      Michal Nazarewicz authored
      No functional changes at this time but splitting casify_region into
      a function dealing with multibyte and another dealing with unibyte
      buffers will make future code changes slightly easier.
      
      * src/casefiddle.c (casify_region): Move most of the code into two
      new functions:
      (do_casify_multibyte_region, do_casify_unibyte_region): new functions.
      2c87dabd
    • Michal Nazarewicz's avatar
      Add support for title-casing letters (bug#24603) · 13d813b1
      Michal Nazarewicz authored
      * src/casefiddle.c (struct casing_context, prepare_casing_context): Add
      titlecase_char_table member.  It’s set to the ‘titlecase’ Unicode
      property table if capitalisation has been requested.
      (case_character): Make use of the titlecase_char_table to title-case
      initial characters when capitalising.
      
      * test/src/casefiddle-tests.el (casefiddle-tests--characters,
      casefiddle-tests-casing): Update test cases which are now passing.
      13d813b1
    • Michal Nazarewicz's avatar
      Introduce case_character function · 8e5b909f
      Michal Nazarewicz authored
      Move single-character casing logic into a separate function so that
      it is collected in a single place.  This will make future changes to
      the logic easier.  This commit introduces no functionality changes.
      
      * src/casefiddle.c (struct casing_context, prepare_casing_context): New
      sturcture for saving casing context and function to initialise it.
      (case_character): New function which cases character base on provided
      context.
      (do_casify_integer, do_casify_multibyte_string,
      do_casify_unibyte_string, casify_object, casify_region): Convert to
      use casing_context and case_character.
      8e5b909f
    • Michal Nazarewicz's avatar
      Split casify_object into multiple functions · ec2d002f
      Michal Nazarewicz authored
      casify_object had three major cases to cover and those were mostly
      independent of each other.  Move those branches to separate function
      so it’s easier to comprehend each individual case.
      
      While at it, use somewhat more descriptive ch and cased variable names
      rather than c and c1.
      
      This commit introduces no functional changes.
      
      * src/casefiddle.c (casify_object): Split into…
      (do_casify_integer, do_casify_multibyte_string,
      do_casify_unibyte_string): …new functions.
      ec2d002f
  18. 17 Feb, 2017 1 commit
  19. 15 Feb, 2017 1 commit
    • Michal Nazarewicz's avatar
      casing: don’t assume letters are *either* upper- or lower-case (bug#24603) · 6220faeb
      Michal Nazarewicz authored
      A compatibility digraph characters, such as Dž, are neither upper- nor
      lower-case.  At the moment however, those are reported as upper-case¹
      despite the fact that they change when upper-cased.
      
      Stop checking if a character is upper-case before trying to up-case it
      so that title-case characters are handled correctly.  This fixes one of
      the issues mentioned in bug#24603.
      
      ¹ Because they change when converted to lower-case.  Notice an asymmetry
        in that for a character to be considered lower-case it must not be
        upper-case (plus the usual condition of changing when upper-cased).
      
      * src/buffer.h (upcase1): Delete.
      (upcase): Change to upcase character unconditionally just like downcase
      does it.  This is what upcase1 was.
      
      * src/casefiddle.c (casify_object, casify_region): Use upcase instead
      of upcase1 and don’t check !uppercasep(x) before calling upcase.
      
      * src/keyboard.c (read_key_sequence): Don’t check if uppercase(x), just
      downcase(x) and see if it changed.
      
      * test/src/casefiddle-tests.el (casefiddle-tests--characters,
      casefiddle-tests-casing): Update test cases which are now passing.
      6220faeb
  20. 01 Jan, 2017 1 commit
  21. 12 Sep, 2016 3 commits
  22. 05 Jun, 2016 1 commit
  23. 30 May, 2016 1 commit
    • Paul Eggert's avatar
      Omit IF_LINT code that no longer seems needed · 237244bb
      Paul Eggert authored
      Nowadays GCC is smarter, or the Emacs code has mutated, or both,
      and now is as good a time as any to remove uses of IF_LINT that
      now seem to be unnecessary.
      * lib-src/emacsclient.c (set_local_socket):
      * lib-src/movemail.c (main) [MAIL_USE_MAILLOCK && HAVE_TOUCHLOCK]:
      * src/buffer.c (fix_start_end_in_overlays, fix_overlays_before):
      * src/casefiddle.c (casify_region):
      * src/charset.c (load_charset_map):
      * src/coding.c (decode_coding_object, encode_coding_object):
      * src/data.c (Fmake_variable_buffer_local, Fmake_local_variable)
      (cons_to_unsigned, cons_to_signed):
      * src/frame.c (make_frame, x_set_frame_parameters):
      * src/keyboard.c (read_event_from_main_queue):
      * src/regex.c (regex_compile):
      * src/syntax.c (back_comment):
      * src/window.c (Frecenter):
      * src/xfaces.c (Fx_list_fonts):
      Remove IF_LINT that no longer seems necessary.
      * src/image.c (png_load_body, jpeg_load_body): Simplify use of IF_LINT.
      * src/keyboard.c (read_char): Use IF_LINT (volatile) rather than
      a pragma dance to pacify GCC -Wclobbered.
      * src/xdisp.c (x_produce_glyphs): Rewrite to avoid need for IF_LINT.
      
      * src/xterm.c (x_connection_closed): Now _Noreturn, which should
      mean we do not need IF_LINT any more.
      (x_io_error_quitter): Now _Noreturn.  Put an 'assume (false)’
      at the end, to forestall warnings from older compilers.
      237244bb
  24. 10 Mar, 2016 1 commit
    • Paul Eggert's avatar
      Rework C source files to avoid ^( · 7352c6c6
      Paul Eggert authored
      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.
      7352c6c6
  25. 01 Jan, 2016 1 commit
  26. 13 Nov, 2015 1 commit
    • Juri Linkov's avatar
      Support rectangular regions for more commands · 31f6e939
      Juri Linkov authored
      * lisp/simple.el (region-extract-function): Handle the arg value ‘bounds’.
      (region-insert-function): New function.
      (shell-command-on-region): Add arg ‘region-noncontiguous-p’.
      If non-nil, operate on multiple chunks.
      (region-noncontiguous-p): New function.
      
      * lisp/rect.el: Add function rectangle--insert-region
      around region-insert-function.
      (extract-rectangle-bounds): New function.
      (rectangle--extract-region): Handle the arg value ‘bounds’.
      (rectangle--insert-region): New function.
      
      * lisp/emulation/cua-rect.el: Add function cua--insert-rectangle
      around region-insert-function.
      (cua--extract-rectangle-bounds): New function.
      (cua--rectangle-region-extract): Handle the arg value ‘bounds’.
      
      * lisp/replace.el (query-replace, query-replace-regexp): Add arg
      ‘region-noncontiguous-p’.  Use ‘use-region-p’.
      (query-replace-regexp-eval, map-query-replace-regexp)
      (replace-string, replace-regexp): Use ‘use-region-p’.
      (keep-lines, flush-lines, how-many): Use ‘use-region-p’.
      (perform-replace): Add arg ‘region-noncontiguous-p’.
      If non-nil, operate on multiple chunks.
      
      * src/casefiddle.c (Fdowncase_region): Add arg ‘region-noncontiguous-p’.
      If non-nil, operate on multiple chunks. (Bug#19829)
      31f6e939
  27. 09 Nov, 2015 1 commit
    • Paul Eggert's avatar
      Use INT_ADD_WRAPV etc. to check integer overflow · 10873055
      Paul Eggert authored
      * 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.
      10873055
  28. 05 Jan, 2015 1 commit
    • Paul Eggert's avatar
      Compute C decls for DEFSYMs automatically · 58f2d6ef
      Paul Eggert authored
      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.
      58f2d6ef
  29. 01 Jan, 2015 2 commits