[sword-devel] Mingw and SWORD's internal regex (was: Re: 1.6.1 outstanding items?

Matthew Talbert ransom1982 at gmail.com
Mon Dec 7 23:33:01 MST 2009

> I updated GNU's regex code because it was quite old, as you pointed out.

Maybe I did at one time, but I haven't really cared lately as I've
been using another regex library. Others have mentioned it recently.

> The additional files do not need to be added to any makefiles or project
> files. I suppose you could, but it would be counter-productive given their
> use. (Read regex.c if you don't understand this.)

OK, I see this now. I was having lots of compile errors which I
thought were due to the extra files not being included, but it turns
out that defining __USE_GNU took care of those problems.

There are still a couple of things that need changed for this to
compile. The header alloca.h is not available with Mingw, so it needs
to be skipped. A function from malloc.h was used without including the
header file. And bool, and true/false were used, all of which are C++,
rather than C. Anyway, here's a patch that will need to be applied for
this to compile. It should be safe for Visual Studio as well. It still
needs __USE_GNU defined, but I'll take care of that with my patch for
configure.ac that I'm working on.


Index: regex_internal.h
--- regex_internal.h	(revision 2486)
+++ regex_internal.h	(working copy)
@@ -418,7 +418,9 @@
 #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
 #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))

+#ifndef __MINGW32__
 #include <alloca.h>

 #ifndef _LIBC
Index: regexec.c
--- regexec.c	(revision 2486)
+++ regexec.c	(working copy)
@@ -18,6 +18,11 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */

+#include <malloc.h>
+typedef enum {FALSE, TRUE} bool;
+#define false FALSE;
+#define true TRUE;
 static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
 				     int n) internal_function;
 static void match_ctx_clean (re_match_context_t *mctx) internal_function;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: regex.patch
Type: text/x-diff
Size: 959 bytes
Desc: not available
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20091208/f25df4b6/attachment.bin>

More information about the sword-devel mailing list