annotate src/mule.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents c5d627a313b1
children 697ef44129c6
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;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 272
diff changeset
43 Lisp_String *s;
70
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 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
51 temp = XCAR (pattern);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 CHECK_VECTOR (temp);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
53 CHECK_STRING (XVECTOR_DATA (temp)[0]);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 149
diff changeset
54 s = XSTRING (XVECTOR_DATA (temp)[0]);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
55 if (!wordbuf[i])
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
56 wordbuf[i] = xnew (struct re_pattern_buffer);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
57 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
58 if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 wordbuf[i]->buffer = (char *) xmalloc (s->size + 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 wordbuf[i]->used = s->size;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
61 memcpy (wordbuf[i]->buffer, s->data, s->size + 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
62 #ifdef EMACS19_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 wordbuf[i]->translate = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64 wordbuf[i]->fastmap_accurate = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
65 wordbuf[i]->fastmap = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 wordbuf[i]->can_be_null = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
68 wordbuf[i]->mc_flag = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
69 wordbuf[i]->short_flag = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70 wordbuf[i]->no_empty = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
71
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
72 wordbuf[i]->syntax_version = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
73 wordbuf[i]->category_version = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
74
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
75 wordbuf[i]->regs_allocated = REGS_UNALLOCATED;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
76 wordbuf[i]->re_nsub = 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
77 wordbuf[i]->no_sub = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78 wordbuf[i]->newline_anchor = 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
79
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
80 wordbuf[i]->syntax = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81 wordbuf[i]->not_bol = wordbuf[i]->not_eol = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 #endif /* EMACS19_REGEXP */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 185
diff changeset
83 pattern = XCDR (pattern);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
85 for (; i < MAXWORDBUF && wordbuf[i]; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
86 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87 if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
88 xfree (wordbuf[i]);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89 wordbuf[i] = (struct re_pattern_buffer *) 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
90 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
91 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 #endif /* MULE_REGEXP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 syms_of_mule (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
100 #ifdef MULE_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 DEFSUBR (Fdefine_word_pattern);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
102 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
103 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
104
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 vars_of_mule (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 #ifdef MULE_REGEXP
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109 DEFVAR_BOOL ("re-short-flag", &re_short_flag /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 *T means regexp search success when the shortest match is found.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 */ );
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 re_short_flag = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 #endif /* MULE_REGEXP */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
114
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
115 Fprovide (intern ("mule"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
116
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117 #ifdef HAVE_EGG
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
118 Fprovide (intern ("egg"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
119 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
120 #ifdef HAVE_WNN
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 70
diff changeset
121 Fprovide (intern ("wnn"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
122 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
123 }