Subject: [clisp-list] now you can use the regexp module on MS-Windows

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Wed Mar 27 06:26:07 2002

Hi,

here's a tiny patch to make the regexp module usable with the MS-VC6 compiler.

I believe some users of the win32 binary distribution would very much appreciate for this module to be included in the binary.

For several years now, the FFI has been part of the binary distribution on MS-Windows. This was of no use at all except to know that it compiles(!), since without modules, it cannot do/call/access anything.

I'd be thankful to the autoconf & Makefile experts could come up with a scheme to automate generating and including the module. It's trivial to do by hand, but possibly hard to fully automate. I appended the makefile parts that I used.

The current src/Makefile does:
o using empty modules.h, create lisp.exe
o compile all .lisp files and create lispinit.mem

It needs to additionaly do:
o compile regexp.lisp (creates regexp.fas and regexp.c) with old(/any) lisp.exe
o compile modules/regexp.c, regexi., regex.c (delegate to modules/regexp/Makefile)
o put a line containing "MODULE(regexp)" into modules.h
o recompile modules.c as consequence of dependance
o recreate lisp.exe including regex objects
Note there's a dependency cycle.

A new .mem need not be created. Yet it may be convenient for users to have regexp.fas included and ready for use. The regexp.fas can only be loaded by the new lisp.exe.

ChangeLog	compiles with MS-VC6

Since one of the patches is to regex.c, I don't know whether the original GNU maintainers would be interested by portability, or if some boycott applies.

I can provide a Win.Zip containing an augmented lisp.exe, regexp.fas (+lisp) and the below diffs for CLISP-2.28 using MS-VC6 if somebody tells me where to put that. Though I don't know if that would be a violation of COPYRIGHT. Or the current CLISP-2.28 binaries were updated.

Regards,
	Jörg Höhle.
++++++++++++++ diff modules/regexp/
gdiff -c3 ../../orig/ regex.c
*** ../../orig/regex.c	Wed Jul 22 22:22:47 1998
--- regex.c	Fri Mar 22 15:58:38 2002
***************
*** 211,218 ****
--- 211,223 ----
  #if HAVE_ALLOCA_H
  #include <alloca.h>
  #else /* not __GNUC__ or HAVE_ALLOCA_H */
+ #ifdef _MSC_VER /* Microsoft VC */
+ #include <malloc.h>
+ #define alloca _alloca
+ #else
  #ifndef _AIX /* Already did AIX, up at the top.  */
  char *alloca ();
+ #endif /* not MS-VC */
  #endif /* not _AIX */
  #endif /* not HAVE_ALLOCA_H */ 
  #endif /* not __GNUC__ */
gdiff -c3 ../../orig/ regexi.c
*** ../../orig/regexi.c	Wed Jul 22 22:22:50 1998
--- regexi.c	Fri Mar 22 15:28:22 2002
***************
*** 2,10 ****
  /* Bruno Haible 14.4.1995 */
  
  #include <sys/types.h> /* regex.h needs this */
  #include "regex.h"
  
- #include <stdlib.h> /* declare malloc(), free() */
  
  int mregcomp (ppreg,pattern,cflags)
    regex_t* * ppreg;
--- 2,10 ----
  /* Bruno Haible 14.4.1995 */
  
  #include <sys/types.h> /* regex.h needs this */
+ #include <stdlib.h> /* declare malloc(), free() */
  #include "regex.h"

  int mregcomp (ppreg,pattern,cflags)
    regex_t* * ppreg;

++++++++++++++ hand-written modules/regexp/makefile for MSVC6
# I believe it should be a generated file
# Adapted from win32msvc/makefile.msvc6 and modules/regexp/Makefile.in

LISPSRCDIR = ..\..\src
INCLUDES=$(LISPSRCDIR)
CC = cl $(MFLAGS) -G5 -Os -Oy -Ob1 -Gs -Gf -Gy
CFLAGS = -DHAVE_STRING_H -DSTDC_HEADERS

!if !defined(MFLAGS)
MFLAGS=
!endif

MSVCDIR = "C:/Programme/Microsoft Visual Studio/VC98"
MAKE = nmake

CLISP = $(LISPSRCDIR)\lisp0.exe -M $(LISPSRCDIR)\lispinit.mem -B $(LISPSRCDIR) -Efile UTF-8 -norc -q

all : regexp.obj regexi.obj regex.obj

regexp.c : regexp.lisp
	$(CLISP) -c regexp.lisp

regexp.obj : regexp.c
	$(CC) $(CFLAGS) -I$(INCLUDES) -c regexp.c

regexi.obj : regexi.c regex.h
	$(CC) $(CFLAGS) -c regexi.c

regex.obj : regex.c regex.h
	$(CC) $(CFLAGS) -I. -c regex.c

# Make a module
clisp-module : all

---

From: Sam Steingold <[email-masked]>
Date: Sat Mar 30 18:28:05 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] now you can use the regexp module on MS-Windows"
> * Sent on Wed, 27 Mar 2002 15:24:45 +0100
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>

thanks!  this is really great news, worthy of a release!

> I believe some users of the win32 binary distribution would very much
> appreciate for this module to be included in the binary.

yes - I want to make the win32 binary distribution look just like a
UNIX binary distribution: with "base" and "full" dirs &c.

> I'd be thankful to the autoconf & Makefile experts could come up with
> a scheme to automate generating and including the module. It's trivial
> to do by hand, but possibly hard to fully automate. I appended the
> makefile parts that I used.

I think it is okay to have a separate hand-made win32 makefile, just
like with FFCALL.

> Since one of the patches is to regex.c, I don't know whether the
> original GNU maintainers would be interested by portability, or if
> some boycott applies.

are you sure this is necessary?  GNU Emacs does not have this special
casing and it does work on win32.
It might be an efficiency issue though.

> --- regex.c	Fri Mar 22 15:58:38 2002

do I understand correctly that without this the MS regexp would use
malloc/free instead of alloca?
I would rather not fork a separate CLISP version of this file.
Emacs & glibc's versions of regex.c have diverged over the years and
RMS recently declared that he wants them to merge (volunteers?)
neither version has your MS code - so I will have to get it into the
Emacs CVS tree ASAP, thus I need a justification for the change.

> --- regexi.c	Fri Mar 22 15:28:22 2002

is this necessary?
weird - it works on other platforms this way...

> ++++++++++++++ hand-written modules/regexp/makefile for MSVC6

thanks.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Diplomacy is the art of saying "nice doggy" until you can find a rock.

---

From: Sam Steingold <[email-masked]>
Date: Fri Apr 5 13:04:18 2002

> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:

could you please try the current Emacs regex.c instead?
<http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/emacs/emacs/src/regex.c?rev=HEAD&content-type=text/x-csrc>
thanks.

> --- regexi.c	Fri Mar 22 15:28:22 2002
installed - thanks!

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
Those who don't know lisp are destined to reinvent it, poorly.