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