aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-04-15 00:26:32 -0700
committerPaul Eggert2015-04-15 00:27:18 -0700
commita122a0276bddbda8ca84f9b94250a5a5f4e0582a (patch)
tree4d0368943f2d0c53504e1e5e4727adaafd602d7e /src
parent45d75c0b758cf152698e83e180dfc8eed5d355ba (diff)
downloademacs-a122a0276bddbda8ca84f9b94250a5a5f4e0582a.tar.gz
emacs-a122a0276bddbda8ca84f9b94250a5a5f4e0582a.zip
Make [:graph:] act like [:print:] sans space
In POSIX [[:print:]] is equivalent to [ [:graph:]], so change [:graph:] so that it matches everything that [:print:] does, except for space. * doc/lispref/searching.texi (Char Classes): * etc/NEWS: * lisp/emacs-lisp/rx.el (rx): Document [:graph:] to be [:print:] sans ' '. * src/character.c, src/character.h (graphicp): New function. * src/regex.c (ISGRAPH) [emacs]: Use it. (BIT_GRAPH): New macro. (BIT_PRINT): Increase to 0x200, to make room for BIT_GRAPH. (re_wctype_to_bit) [! WIDE_CHAR_SUPPORT]: Return BIT_GRAPH for RECC_GRAPH. (re_match_2_internal) [emacs]: Use ISGRAPH if BIT_GRAPH, and ISPRINT if BIT_PRINT.
Diffstat (limited to 'src')
-rw-r--r--src/character.c8
-rw-r--r--src/character.h1
-rw-r--r--src/regex.c12
3 files changed, 17 insertions, 4 deletions
diff --git a/src/character.c b/src/character.c
index b357dd5a334..ea98cf68e6c 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1022,6 +1022,14 @@ decimalnump (int c)
1022 return gen_cat == UNICODE_CATEGORY_Nd; 1022 return gen_cat == UNICODE_CATEGORY_Nd;
1023} 1023}
1024 1024
1025/* Return 'true' if C is a graphic character as defined by its
1026 Unicode properties. */
1027bool
1028graphicp (int c)
1029{
1030 return c == ' ' || printablep (c);
1031}
1032
1025/* Return 'true' if C is a printable character as defined by its 1033/* Return 'true' if C is a printable character as defined by its
1026 Unicode properties. */ 1034 Unicode properties. */
1027bool 1035bool
diff --git a/src/character.h b/src/character.h
index 1a5d2c8a670..859d717a0ba 100644
--- a/src/character.h
+++ b/src/character.h
@@ -662,6 +662,7 @@ extern Lisp_Object string_escape_byte8 (Lisp_Object);
662 662
663extern bool alphabeticp (int); 663extern bool alphabeticp (int);
664extern bool decimalnump (int); 664extern bool decimalnump (int);
665extern bool graphicp (int);
665extern bool printablep (int); 666extern bool printablep (int);
666 667
667/* Return a translation table of id number ID. */ 668/* Return a translation table of id number ID. */
diff --git a/src/regex.c b/src/regex.c
index b9d09d02c22..4af70c62cf5 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -314,7 +314,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
314 314
315# define ISGRAPH(c) (SINGLE_BYTE_CHAR_P (c) \ 315# define ISGRAPH(c) (SINGLE_BYTE_CHAR_P (c) \
316 ? (c) > ' ' && !((c) >= 0177 && (c) <= 0237) \ 316 ? (c) > ' ' && !((c) >= 0177 && (c) <= 0237) \
317 : 1) 317 : graphicp (c))
318 318
319# define ISPRINT(c) (SINGLE_BYTE_CHAR_P (c) \ 319# define ISPRINT(c) (SINGLE_BYTE_CHAR_P (c) \
320 ? (c) >= ' ' && !((c) >= 0177 && (c) <= 0237) \ 320 ? (c) >= ' ' && !((c) >= 0177 && (c) <= 0237) \
@@ -1875,7 +1875,8 @@ struct range_table_work_area
1875#define BIT_MULTIBYTE 0x20 1875#define BIT_MULTIBYTE 0x20
1876#define BIT_ALPHA 0x40 1876#define BIT_ALPHA 0x40
1877#define BIT_ALNUM 0x80 1877#define BIT_ALNUM 0x80
1878#define BIT_PRINT 0x100 1878#define BIT_GRAPH 0x100
1879#define BIT_PRINT 0x200
1879 1880
1880 1881
1881/* Set the bit for character C in a list. */ 1882/* Set the bit for character C in a list. */
@@ -2074,7 +2075,7 @@ re_wctype_to_bit (re_wctype_t cc)
2074{ 2075{
2075 switch (cc) 2076 switch (cc)
2076 { 2077 {
2077 case RECC_NONASCII: case RECC_GRAPH: 2078 case RECC_NONASCII:
2078 case RECC_MULTIBYTE: return BIT_MULTIBYTE; 2079 case RECC_MULTIBYTE: return BIT_MULTIBYTE;
2079 case RECC_ALPHA: return BIT_ALPHA; 2080 case RECC_ALPHA: return BIT_ALPHA;
2080 case RECC_ALNUM: return BIT_ALNUM; 2081 case RECC_ALNUM: return BIT_ALNUM;
@@ -2083,6 +2084,7 @@ re_wctype_to_bit (re_wctype_t cc)
2083 case RECC_UPPER: return BIT_UPPER; 2084 case RECC_UPPER: return BIT_UPPER;
2084 case RECC_PUNCT: return BIT_PUNCT; 2085 case RECC_PUNCT: return BIT_PUNCT;
2085 case RECC_SPACE: return BIT_SPACE; 2086 case RECC_SPACE: return BIT_SPACE;
2087 case RECC_GRAPH: return BIT_GRAPH;
2086 case RECC_PRINT: return BIT_PRINT; 2088 case RECC_PRINT: return BIT_PRINT;
2087 case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: 2089 case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL:
2088 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; 2090 case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0;
@@ -5522,7 +5524,9 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
5522 | (class_bits & BIT_UPPER && ISUPPER (c)) 5524 | (class_bits & BIT_UPPER && ISUPPER (c))
5523 | (class_bits & BIT_WORD && ISWORD (c)) 5525 | (class_bits & BIT_WORD && ISWORD (c))
5524 | (class_bits & BIT_ALPHA && ISALPHA (c)) 5526 | (class_bits & BIT_ALPHA && ISALPHA (c))
5525 | (class_bits & BIT_ALNUM && ISALNUM (c))) 5527 | (class_bits & BIT_ALNUM && ISALNUM (c))
5528 | (class_bits & BIT_GRAPH && ISGRAPH (c))
5529 | (class_bits & BIT_PRINT && ISPRINT (c)))
5526 not = !not; 5530 not = !not;
5527 else 5531 else
5528 CHARSET_LOOKUP_RANGE_TABLE_RAW (not, c, range_table, count); 5532 CHARSET_LOOKUP_RANGE_TABLE_RAW (not, c, range_table, count);