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