89d92318ee5c2aad9493f53ad770477b4b103aac
[chise/xemacs-chise.git.1] / src / mule.c
1 /* Copyright (C) 1995 Free Software Foundation.
2    Copyright (C) 1999,2000,2001,2002,2003 MORIOKA Tomohiko
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Synched up with: Mule 2.3.  Not in FSF. */
22
23 #include <config.h>
24 #include "lisp.h"
25
26 #include "regex.h"
27
28 #ifdef MULE_REGEXP
29
30 Lisp_Object Vre_word;
31
32 int re_short_flag;
33
34 \f
35 DEFUN ("define-word-pattern", Fdefine_word_pattern, 1, 1, 0, /*
36 Don't call this function directly, instead use 'define-word' which
37 accept a pattern compiled by 'regexp-compile' with word-option t.
38 */
39        (pattern))
40 {
41   int i, len;
42   char *p;
43   Lisp_Object temp;
44   Lisp_String *s;
45
46   CHECK_CONS (pattern);
47   len = XINT (Flength (pattern));
48   if (len > MAXWORDBUF)
49     error ("Too complicated regular expression for word!");
50   for (i = 0; i < len; i++)
51     {
52       temp = XCAR (pattern);
53       CHECK_VECTOR (temp);
54       CHECK_STRING (XVECTOR_DATA (temp)[0]);
55       s = XSTRING (XVECTOR_DATA (temp)[0]);
56       if (!wordbuf[i])
57         wordbuf[i] = xnew (struct re_pattern_buffer);
58       else
59         if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
60       wordbuf[i]->buffer = (char *) xmalloc (s->size + 1);
61       wordbuf[i]->used = s->size;
62       memcpy (wordbuf[i]->buffer, s->data, s->size + 1);
63 #ifdef EMACS19_REGEXP
64       wordbuf[i]->translate = 0;
65       wordbuf[i]->fastmap_accurate = 0;
66       wordbuf[i]->fastmap = 0;
67       wordbuf[i]->can_be_null = 1;
68
69       wordbuf[i]->mc_flag = 1;
70       wordbuf[i]->short_flag = 0;
71       wordbuf[i]->no_empty = 0;
72
73       wordbuf[i]->syntax_version = 0;
74       wordbuf[i]->category_version = 0;
75
76       wordbuf[i]->regs_allocated = REGS_UNALLOCATED;
77       wordbuf[i]->re_nsub = 0;
78       wordbuf[i]->no_sub = 0;
79       wordbuf[i]->newline_anchor = 1;
80
81       wordbuf[i]->syntax = 0;
82       wordbuf[i]->not_bol = wordbuf[i]->not_eol = 0;
83 #endif /* EMACS19_REGEXP */
84       pattern = XCDR (pattern);
85     }
86   for (; i < MAXWORDBUF && wordbuf[i]; i++)
87     {
88       if (wordbuf[i]->buffer) xfree (wordbuf[i]->buffer);
89       xfree (wordbuf[i]);
90       wordbuf[i] = (struct re_pattern_buffer *) 0;
91     }
92   return Qnil;
93 }
94
95 #endif /* MULE_REGEXP */
96
97 #ifdef UTF2000
98 Lisp_Object Vxemacs_chise_version;
99 #endif
100
101 \f
102 void
103 syms_of_mule (void)
104 {
105 #ifdef MULE_REGEXP
106   DEFSUBR (Fdefine_word_pattern);
107 #endif
108 }
109
110 void
111 vars_of_mule (void)
112 {
113 #ifdef MULE_REGEXP
114   DEFVAR_BOOL ("re-short-flag", &re_short_flag /*
115 *T means regexp search success when the shortest match is found.
116 */ );
117   re_short_flag = 0;
118 #endif /* MULE_REGEXP */
119
120   Fprovide (intern ("mule"));
121
122 #ifdef UTF2000
123   Fprovide (intern ("utf-2000"));
124
125   Vxemacs_chise_version = build_string("0.21 (Narayama)");
126   DEFVAR_LISP ("xemacs-chise-version", &Vxemacs_chise_version /*
127 Version number of XEmacs CHISE.
128 */ );
129   DEFVAR_LISP ("utf-2000-version", &Vxemacs_chise_version /*
130 Version number of XEmacs CHISE.
131 */ );
132 #endif
133
134 #if defined(CHISE)||defined(HAVE_CHISE_CLIENT)
135   Fprovide (intern ("chise"));
136 #endif
137
138 #ifdef HAVE_EGG
139   Fprovide (intern ("egg"));
140 #endif
141 #ifdef HAVE_WNN
142   Fprovide (intern ("wnn"));
143 #endif
144 }