Karsten Hopp 645e3c
To: vim_dev@googlegroups.com
Karsten Hopp 645e3c
Subject: Patch 7.3.1175
Karsten Hopp 645e3c
Fcc: outbox
Karsten Hopp 645e3c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 645e3c
Mime-Version: 1.0
Karsten Hopp 645e3c
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 645e3c
Content-Transfer-Encoding: 8bit
Karsten Hopp 645e3c
------------
Karsten Hopp 645e3c
Karsten Hopp 645e3c
Patch 7.3.1175
Karsten Hopp 645e3c
Problem:    Using isalpha() and isalnum() can be slow.
Karsten Hopp 645e3c
Solution:   Use range checks. (Mike Williams)
Karsten Hopp 645e3c
Files:	    src/ex_docmd.c, src/macros.h
Karsten Hopp 645e3c
Karsten Hopp 645e3c
Karsten Hopp 645e3c
*** ../vim-7.3.1174/src/ex_docmd.c	2013-06-08 18:19:39.000000000 +0200
Karsten Hopp 645e3c
--- src/ex_docmd.c	2013-06-12 16:50:50.000000000 +0200
Karsten Hopp 645e3c
***************
Karsten Hopp 645e3c
*** 3120,3126 ****
Karsten Hopp 645e3c
  	for (j = 0; p[j] != NUL; ++j)
Karsten Hopp 645e3c
  	    if (p[j] != cmdmods[i].name[j])
Karsten Hopp 645e3c
  		break;
Karsten Hopp 645e3c
! 	if (!isalpha(p[j]) && j >= cmdmods[i].minlen
Karsten Hopp 645e3c
  					&& (p == cmd || cmdmods[i].has_count))
Karsten Hopp 645e3c
  	    return j + (int)(p - cmd);
Karsten Hopp 645e3c
      }
Karsten Hopp 645e3c
--- 3120,3126 ----
Karsten Hopp 645e3c
  	for (j = 0; p[j] != NUL; ++j)
Karsten Hopp 645e3c
  	    if (p[j] != cmdmods[i].name[j])
Karsten Hopp 645e3c
  		break;
Karsten Hopp 645e3c
! 	if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen
Karsten Hopp 645e3c
  					&& (p == cmd || cmdmods[i].has_count))
Karsten Hopp 645e3c
  	    return j + (int)(p - cmd);
Karsten Hopp 645e3c
      }
Karsten Hopp 645e3c
*** ../vim-7.3.1174/src/macros.h	2013-06-12 14:10:23.000000000 +0200
Karsten Hopp 645e3c
--- src/macros.h	2013-06-12 17:07:32.000000000 +0200
Karsten Hopp 645e3c
***************
Karsten Hopp 645e3c
*** 99,104 ****
Karsten Hopp 645e3c
--- 99,109 ----
Karsten Hopp 645e3c
  # define MB_TOUPPER(c)	TOUPPER_LOC(c)
Karsten Hopp 645e3c
  #endif
Karsten Hopp 645e3c
  
Karsten Hopp 645e3c
+ /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
Karsten Hopp 645e3c
+  * non-zero for superscript 1.  Also avoids that isdigit() crashes for numbers
Karsten Hopp 645e3c
+  * below 0 and above 255.  */
Karsten Hopp 645e3c
+ #define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
Karsten Hopp 645e3c
+ 
Karsten Hopp 645e3c
  /* Like isalpha() but reject non-ASCII characters.  Can't be used with a
Karsten Hopp 645e3c
   * special key (negative value). */
Karsten Hopp 645e3c
  #ifdef EBCDIC
Karsten Hopp 645e3c
***************
Karsten Hopp 645e3c
*** 107,123 ****
Karsten Hopp 645e3c
  # define ASCII_ISLOWER(c) islower(c)
Karsten Hopp 645e3c
  # define ASCII_ISUPPER(c) isupper(c)
Karsten Hopp 645e3c
  #else
Karsten Hopp 645e3c
- # define ASCII_ISALPHA(c) ((c) < 0x7f && isalpha(c))
Karsten Hopp 645e3c
- # define ASCII_ISALNUM(c) ((c) < 0x7f && isalnum(c))
Karsten Hopp 645e3c
  # define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
Karsten Hopp 645e3c
  # define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
Karsten Hopp 645e3c
  #endif
Karsten Hopp 645e3c
  
Karsten Hopp 645e3c
- /* Use our own isdigit() replacement, because on MS-Windows isdigit() returns
Karsten Hopp 645e3c
-  * non-zero for superscript 1.  Also avoids that isdigit() crashes for numbers
Karsten Hopp 645e3c
-  * below 0 and above 255.  */
Karsten Hopp 645e3c
- #define VIM_ISDIGIT(c) ((unsigned)(c) - '0' < 10)
Karsten Hopp 645e3c
- 
Karsten Hopp 645e3c
  /* macro version of chartab().
Karsten Hopp 645e3c
   * Only works with values 0-255!
Karsten Hopp 645e3c
   * Doesn't work for UTF-8 mode with chars >= 0x80. */
Karsten Hopp 645e3c
--- 112,123 ----
Karsten Hopp 645e3c
  # define ASCII_ISLOWER(c) islower(c)
Karsten Hopp 645e3c
  # define ASCII_ISUPPER(c) isupper(c)
Karsten Hopp 645e3c
  #else
Karsten Hopp 645e3c
  # define ASCII_ISLOWER(c) ((unsigned)(c) - 'a' < 26)
Karsten Hopp 645e3c
  # define ASCII_ISUPPER(c) ((unsigned)(c) - 'A' < 26)
Karsten Hopp 645e3c
+ # define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
Karsten Hopp 645e3c
+ # define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || VIM_ISDIGIT(c))
Karsten Hopp 645e3c
  #endif
Karsten Hopp 645e3c
  
Karsten Hopp 645e3c
  /* macro version of chartab().
Karsten Hopp 645e3c
   * Only works with values 0-255!
Karsten Hopp 645e3c
   * Doesn't work for UTF-8 mode with chars >= 0x80. */
Karsten Hopp 645e3c
*** ../vim-7.3.1174/src/version.c	2013-06-12 14:40:58.000000000 +0200
Karsten Hopp 645e3c
--- src/version.c	2013-06-12 17:05:51.000000000 +0200
Karsten Hopp 645e3c
***************
Karsten Hopp 645e3c
*** 730,731 ****
Karsten Hopp 645e3c
--- 730,733 ----
Karsten Hopp 645e3c
  {   /* Add new patch number below this line */
Karsten Hopp 645e3c
+ /**/
Karsten Hopp 645e3c
+     1175,
Karsten Hopp 645e3c
  /**/
Karsten Hopp 645e3c
Karsten Hopp 645e3c
-- 
Karsten Hopp 645e3c
"Hit any key to continue" is a lie.
Karsten Hopp 645e3c
Karsten Hopp 645e3c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 645e3c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 645e3c
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 645e3c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///