summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-15 05:43:28 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-05-15 05:43:28 +0000
commit2631e080db1e1dde9603d6bfa6f2f6f21fd7c628 (patch)
tree4c4e8c773950d0e980c260123753b0a24d9cfc62 /regex.c
parentc25084921670dfe33a0871ee7b94c102fea0ea3a (diff)
ruby 1.1b9_20
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/regex.c b/regex.c
index b6fabb5..9a28afa 100644
--- a/regex.c
+++ b/regex.c
@@ -32,13 +32,6 @@
#include <ctype.h>
#include <sys/types.h>
-#ifdef __MWERKS__
-#include "ruby.h"
-#endif
-
-#include "config.h"
-#include "defines.h"
-
#ifdef __STDC__
#define P(s) s
#define MALLOC_ARG_T size_t
@@ -49,6 +42,20 @@
#define const
#endif
+#ifdef __MWERKS__
+#include "ruby.h"
+#else
+
+#include "config.h"
+#include "defines.h"
+
+void *xmalloc P((unsigned long));
+void *xcalloc P((unsigned long,unsigned long));
+void *xrealloc P((void*,unsigned long));
+void free P((void*));
+
+#endif
+
/* #define NO_ALLOCA /* try it out for now */
#ifndef NO_ALLOCA
/* Make alloca work the best possible way. */
@@ -80,7 +87,7 @@ char *alloca();
#ifdef C_ALLOCA
#define FREE_VARIABLES() alloca(0)
#else
-#define FREE_VARIABLES() 0
+#define FREE_VARIABLES()
#endif
#define FREE_AND_RETURN_VOID(stackb) return
@@ -91,7 +98,7 @@ char *alloca();
(type*) memcpy(stackx, stackb, len * sizeof (type)))
#else /* NO_ALLOCA defined */
-#define RE_ALLOCATE malloc
+#define RE_ALLOCATE xmalloc
#define FREE_VAR(var) if (var) free(var); var = NULL
#define FREE_VARIABLES() \
@@ -824,14 +831,14 @@ print_compiled_pattern(bufp)
static char*
calculate_must_string(start, end)
- unsigned char *start;
- unsigned char *end;
+ char *start;
+ char *end;
{
int mcnt, mcnt2;
int max = 0;
- unsigned char *p = start;
- unsigned char *pend = end;
- unsigned char *must = 0;
+ char *p = start;
+ char *pend = end;
+ char *must = 0;
if (start == NULL) return 0;
@@ -1020,21 +1027,19 @@ re_compile_pattern(pattern, size, bufp)
/* Initialize the syntax table. */
init_syntax_once();
- if (bufp->allocated == 0)
- {
- bufp->allocated = INIT_BUF_SIZE;
- if (bufp->buffer)
- /* EXTEND_BUFFER loses when bufp->allocated is 0. */
- bufp->buffer = (char *) xrealloc (bufp->buffer, INIT_BUF_SIZE);
- else
- /* Caller did not allocate a buffer. Do it for them. */
+ if (bufp->allocated == 0) {
+ bufp->allocated = INIT_BUF_SIZE;
+ if (bufp->buffer)
+ /* EXTEND_BUFFER loses when bufp->allocated is 0. */
+ bufp->buffer = (char *) xrealloc (bufp->buffer, INIT_BUF_SIZE);
+ else
+ /* Caller did not allocate a buffer. Do it for them. */
bufp->buffer = (char *) xmalloc(INIT_BUF_SIZE);
if (!bufp->buffer) goto memory_exhausted;
begalt = b = bufp->buffer;
}
- while (p != pend)
- {
+ while (p != pend) {
PATFETCH(c);
switch (c)