1--- src/search.c	2007-01-13 19:24:37.000000000 -0800
2+++ src/search.c	2012-05-23 11:24:57.000000000 -0700
3@@ -939,8 +939,8 @@ search_command (string, bound, noerror, 
4      int posix;
5 {
6   register int np;
7-  int lim, lim_byte;
8-  int n = direction;
9+  EMACS_INT lim, lim_byte;
10+  EMACS_INT n = direction;
11 
12   if (!NILP (count))
13     {
14@@ -1078,18 +1078,18 @@ static int
15 search_buffer (string, pos, pos_byte, lim, lim_byte, n,
16 	       RE, trt, inverse_trt, posix)
17      Lisp_Object string;
18-     int pos;
19-     int pos_byte;
20-     int lim;
21-     int lim_byte;
22-     int n;
23+     EMACS_INT pos;
24+     EMACS_INT pos_byte;
25+     EMACS_INT lim;
26+     EMACS_INT lim_byte;
27+     EMACS_INT n;
28      int RE;
29      Lisp_Object trt;
30      Lisp_Object inverse_trt;
31      int posix;
32 {
33-  int len = SCHARS (string);
34-  int len_byte = SBYTES (string);
35+  EMACS_INT len = SCHARS (string);
36+  EMACS_INT len_byte = SBYTES (string);
37   register int i;
38 
39   if (running_asynch_code)
40@@ -1406,12 +1406,12 @@ search_buffer (string, pos, pos_byte, li
41 
42 static int
43 simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte)
44-     int n;
45+     EMACS_INT n;
46      unsigned char *pat;
47-     int len, len_byte;
48+     EMACS_INT len, len_byte;
49      Lisp_Object trt;
50-     int pos, pos_byte;
51-     int lim, lim_byte;
52+     EMACS_INT pos, pos_byte;
53+     EMACS_INT lim, lim_byte;
54 {
55   int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
56   int forward = n > 0;
57@@ -1422,10 +1422,10 @@ simple_search (n, pat, len, len_byte, tr
58 	while (1)
59 	  {
60 	    /* Try matching at position POS.  */
61-	    int this_pos = pos;
62-	    int this_pos_byte = pos_byte;
63-	    int this_len = len;
64-	    int this_len_byte = len_byte;
65+	    EMACS_INT this_pos = pos;
66+	    EMACS_INT this_pos_byte = pos_byte;
67+	    EMACS_INT this_len = len;
68+	    EMACS_INT this_len_byte = len_byte;
69 	    unsigned char *p = pat;
70 	    if (pos + len > lim)
71 	      goto stop;
72@@ -1470,8 +1470,8 @@ simple_search (n, pat, len, len_byte, tr
73 	while (1)
74 	  {
75 	    /* Try matching at position POS.  */
76-	    int this_pos = pos;
77-	    int this_len = len;
78+	    EMACS_INT this_pos = pos;
79+	    EMACS_INT this_len = len;
80 	    unsigned char *p = pat;
81 
82 	    if (pos + len > lim)
83@@ -1508,10 +1508,10 @@ simple_search (n, pat, len, len_byte, tr
84 	while (1)
85 	  {
86 	    /* Try matching at position POS.  */
87-	    int this_pos = pos - len;
88-	    int this_pos_byte = pos_byte - len_byte;
89-	    int this_len = len;
90-	    int this_len_byte = len_byte;
91+	    EMACS_INT this_pos = pos - len;
92+	    EMACS_INT this_pos_byte = pos_byte - len_byte;
93+	    EMACS_INT this_len = len;
94+	    EMACS_INT this_len_byte = len_byte;
95 	    unsigned char *p = pat;
96 
97 	    if (this_pos < lim || this_pos_byte < lim_byte)
98@@ -1556,8 +1556,8 @@ simple_search (n, pat, len, len_byte, tr
99 	while (1)
100 	  {
101 	    /* Try matching at position POS.  */
102-	    int this_pos = pos - len;
103-	    int this_len = len;
104+	    EMACS_INT this_pos = pos - len;
105+	    EMACS_INT this_len = len;
106 	    unsigned char *p = pat;
107 
108 	    if (pos - len < lim)
109@@ -1621,22 +1621,20 @@ simple_search (n, pat, len, len_byte, tr
110 static int
111 boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
112 	     pos, pos_byte, lim, lim_byte, charset_base)
113-     int n;
114+     EMACS_INT n;
115      unsigned char *base_pat;
116-     int len, len_byte;
117+     EMACS_INT len, len_byte;
118      Lisp_Object trt;
119      Lisp_Object inverse_trt;
120-     int pos, pos_byte;
121-     int lim, lim_byte;
122+     EMACS_INT pos, pos_byte;
123+     EMACS_INT lim, lim_byte;
124      int charset_base;
125 {
126-  int direction = ((n > 0) ? 1 : -1);
127-  register int dirlen;
128-  int infinity, limit, stride_for_teases = 0;
129-  register int *BM_tab;
130-  int *BM_tab_base;
131+  EMACS_INT direction = ((n > 0) ? 1 : -1);
132+  EMACS_INT dirlen;
133+  EMACS_INT infinity, limit, stride_for_teases = 0;
134   register unsigned char *cursor, *p_limit;
135-  register int i, j;
136+  EMACS_INT i, j;
137   unsigned char *pat, *pat_end;
138   int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
139 
140@@ -1649,12 +1647,8 @@ boyer_moore (n, base_pat, len, len_byte,
141   int translate_prev_byte2 = 0;
142   int translate_prev_byte3 = 0;
143 
144-#ifdef C_ALLOCA
145-  int BM_tab_space[0400];
146-  BM_tab = &BM_tab_space[0];
147-#else
148-  BM_tab = (int *) alloca (0400 * sizeof (int));
149-#endif
150+  EMACS_INT BM_tab[0400];
151+
152   /* The general approach is that we are going to maintain that we know */
153   /* the first (closest to the present position, in whatever direction */
154   /* we're searching) character that could possibly be the last */
155@@ -1693,23 +1687,13 @@ boyer_moore (n, base_pat, len, len_byte,
156   if (direction < 0)
157     base_pat = pat_end - 1;
158 
159-  BM_tab_base = BM_tab;
160-  BM_tab += 0400;
161-  j = dirlen;		/* to get it in a register */
162-  /* A character that does not appear in the pattern induces a */
163-  /* stride equal to the pattern length. */
164-  while (BM_tab_base != BM_tab)
165-    {
166-      *--BM_tab = j;
167-      *--BM_tab = j;
168-      *--BM_tab = j;
169-      *--BM_tab = j;
170-    }
171+  for (i = 0; i < 0400; i++) {
172+    BM_tab[i] = dirlen;
173+  }
174 
175   /* We use this for translation, instead of TRT itself.
176      We fill this in to handle the characters that actually
177      occur in the pattern.  Others don't matter anyway!  */
178-  bzero (simple_translate, sizeof simple_translate);
179   for (i = 0; i < 0400; i++)
180     simple_translate[i] = i;
181 
182@@ -1813,7 +1797,7 @@ boyer_moore (n, base_pat, len, len_byte,
183      char if reverse) of pattern would align in a possible match.  */
184   while (n != 0)
185     {
186-      int tail_end;
187+      EMACS_INT tail_end;
188       unsigned char *tail_end_ptr;
189 
190       /* It's been reported that some (broken) compiler thinks that
191@@ -1926,7 +1910,7 @@ boyer_moore (n, base_pat, len, len_byte,
192 	      cursor += dirlen - i - direction;	/* fix cursor */
193 	      if (i + direction == 0)
194 		{
195-		  int position;
196+		  EMACS_INT position;
197 
198 		  cursor -= direction;
199 
200@@ -2003,7 +1987,7 @@ boyer_moore (n, base_pat, len, len_byte,
201 	      pos_byte += dirlen - i- direction;
202 	      if (i + direction == 0)
203 		{
204-		  int position;
205+		  EMACS_INT position;
206 		  pos_byte -= direction;
207 
208 		  position = pos_byte + ((direction > 0) ? 1 - len_byte : 0);
209