annotate src/mule.c @ 112:48d667d6f17f r20-1b8

Import from CVS: tag r20-1b8
author cvs
date Mon, 13 Aug 2007 09:20:48 +0200
parents 131b0175ea99
children 538048ae2ab8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* Copyright (C) 1995 Free Software Foundation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 /* Synched up with: Mule 2.3. Not in FSF. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
22 #include <config.h>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23 #include "lisp.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
24
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25 #include "regex.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #ifdef MULE_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29 Lisp_Object Vre_word;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 int re_short_flag;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 DEFUN ("define-word-pattern", Fdefine_word_pattern, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35 Don't call this function directly, instead use 'define-word' which
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 accept a pattern compiled by 'regexp-compile' with word-option t.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 (pattern))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
40 int i, len;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
41 char *p;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
42 Lisp_Object temp;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
43 struct Lisp_String *s;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
44
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
45 CHECK_CONS (pattern);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
46 len = XINT (Flength (pattern));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
47 if (len > MAXWORDBUF)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
48 error ("Too complicated regular expression for word!");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
49 for (i = 0; i < len; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
50 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
51 temp =XCONS (pattern)->car;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 CHECK_VECTOR (temp);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
53 CHECK_STRING (XVECTOR (temp)->contents[0]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 s = XSTRING (XVECTOR (temp)->contents[0]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 if (!wordbuf[i])
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 wordbuf[i] = (struct re_pattern_buffer *)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 xmalloc (sizeof (struct re_pattern_buffer));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 wordbuf[i]->buffer = (char *) xmalloc (s->size + 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 wordbuf[i]->used = s->size;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 memcpy (wordbuf[i]->buffer, s->data, s->size + 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 #ifdef EMACS19_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 wordbuf[i]->translate = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 wordbuf[i]->fastmap_accurate = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 wordbuf[i]->fastmap = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 wordbuf[i]->can_be_null = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 wordbuf[i]->mc_flag = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 wordbuf[i]->short_flag = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71 wordbuf[i]->no_empty = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 wordbuf[i]->syntax_version = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74 wordbuf[i]->category_version = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
76 wordbuf[i]->regs_allocated = REGS_UNALLOCATED;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 wordbuf[i]->re_nsub = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 wordbuf[i]->no_sub = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79 wordbuf[i]->newline_anchor = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 wordbuf[i]->syntax = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 wordbuf[i]->not_bol = wordbuf[i]->not_eol = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 #endif /* EMACS19_REGEXP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 pattern = XCONS (pattern)->cdr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 for (; i < MAXWORDBUF && wordbuf[i]; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 xfree (wordbuf[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
90 wordbuf[i] = (struct re_pattern_buffer *) 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 #endif /* MULE_REGEXP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 syms_of_mule (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 #ifdef MULE_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 DEFSUBR (Fdefine_word_pattern);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 vars_of_mule (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 #ifdef MULE_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 DEFVAR_BOOL ("re-short-flag", &re_short_flag /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 *T means regexp search success when the shortest match is found.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 */ );
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 re_short_flag = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114 #endif /* MULE_REGEXP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
115
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116 Vfeatures = Fcons (intern ("mule"), Vfeatures);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
118 #ifdef HAVE_EGG
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 Vfeatures = Fcons (intern ("egg"), Vfeatures);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
121 #ifdef HAVE_WNN
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 Vfeatures = Fcons (intern ("wnn"), Vfeatures);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
124 #ifdef HAVE_SJ3
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
125 Vfeatures = Fcons (intern "sj3"), Vfeatures);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
126 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
127 }