annotate src/terminfo.c @ 5648:3f4a234f4672

Support non-ASCII correctly in character classes, test this. src/ChangeLog addition: 2012-04-21 Aidan Kehoe <kehoea@parhasard.net> Support non-ASCII correctly in character classes ([:alnum:] and friends). * regex.c: * regex.c (ISBLANK, ISUNIBYTE): New. Make these and friends independent of the locale, since we want them to be consistent in XEmacs. * regex.c (print_partial_compiled_pattern): Print the flags for charset_mule; don't print non-ASCII as the character values in ranges, this breaks with locales. * regex.c (enum): Define various flags the charset_mule and charset_mule_not opcodes can now take. * regex.c (CHAR_CLASS_MAX_LENGTH): Update this. * regex.c (re_iswctype, re_wctype): New, from GNU. * regex.c (re_wctype_can_match_non_ascii): New; used when deciding on whether to use charset_mule or the ASCII-only regex character set opcode. * regex.c (regex_compile): Error correctly on long, non-existent character class names. Break out the handling of charsets that can match non-ASCII into a separate clause. Use compile_char_class when compiling character classes. * regex.c (compile_char_class): New. Used in regex_compile when compiling character sets that may match non-ASCII. * regex.c (re_compile_fastmap): If there are flags set for charset_mule or charset_mule_not, we can't use the fastmap (since we need to check syntax table values that aren't available there). * regex.c (re_match_2_internal): Check the new flags passed to the charset_mule{,_not} opcode, observe them if appropriate. * regex.h: * regex.h (enum): Expose re_wctype_t here, imported from GNU. tests/ChangeLog addition: 2012-04-21 Aidan Kehoe <kehoea@parhasard.net> * automated/regexp-tests.el: * automated/regexp-tests.el (Assert-char-class): Check that #'string-match errors correctly with an over-long character class name. Add tests for character class functionality that supports non-ASCII characters. These tests expose bugs in GNU Emacs 24.0.94.2, but pass under current XEmacs.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 21 Apr 2012 18:58:28 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Interface from Emacs to terminfo.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2286
diff changeset
6 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2286
diff changeset
8 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2286
diff changeset
9 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2286
diff changeset
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Every little bit of this God-damned file has caused all manner
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 of headaches due to inconsistent and incorrect header files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 on one system or other, and we don't currently need anything here,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 so just comment the whole damn lot out!!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #ifndef HAVE_TERMIOS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #ifdef AIX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include <termio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #endif /* AIX */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 /* Interface to curses/terminfo library.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 Turns out that all of the terminfo-level routines look
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 like their termcap counterparts except for tparm, which replaces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 tgoto. Not only is the calling sequence different, but the string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 format is different too.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
43 #include CURSES_H_FILE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 /* Sun, in their infinite lameness, supplies (possibly) broken headers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 even under Solaris. GCC feels it necessary to correct things by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 supplying its own headers. Unfortunately, if you build GCC under
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 one version of Solaris and then upgrade your Solaris, you may get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 screwed because Sun in their continuing lameness changes curses.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 in such a way that the "fixed" GCC headers are now broken. (GCC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 is equally lame in that it supplies "fixed" headers for curses.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 but not term.h.) However, it seems to work to just not include
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 term.h under Solaris, so we try that. KLUDGE! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #if !(defined (__GNUC__) && defined (SOLARIS2))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
54 #include TERM_H_FILE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 extern void *xmalloc (int size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #if 0 /* If this isn't declared somewhere, too bad */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
60 extern char * tparm (const char *string, int arg1, int arg2, int arg3,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 int arg4, int arg5, int arg6, int arg7, int arg8,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 int arg9);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 /* XEmacs: renamed this function because just tparam() conflicts with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ncurses (We don't use this function anyway!) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 char *
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 493
diff changeset
67 emacs_tparam (const char *string, char *outstring, int UNUSED (len), int arg1,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 int arg2, int arg3, int arg4, int arg5, int arg6, int arg7,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 int arg8, int arg9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 char *temp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 temp = (char *) tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 arg8, arg9);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 if (outstring == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 outstring = (char *) xmalloc (strlen (temp) + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 strcpy (outstring, temp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 return outstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #endif /* not HAVE_TERMIOS */