On Fri, 19 Nov 2004, Andy Dougherty wrote:

> On Fri, 19 Nov 2004, Dan Sugalski wrote:
>
> > So, if someone'd like to take a shot at thumping the template
> > makefile bits to add in compilers/p6ge to the basic build, that'd be
> > great. Grovelling over the code in there to scrub out portability
> > issues would also be good.
>
> I'll take a look at this.

Ok, here's a first pass.  Most of it is pretty straightforward, but one
thing is worth noting:

The code uses both signed and unsigned chars, with and without the 'const'
qualifier.  I gather this is a deliberate part of a carefully considered
overall design.  Unfortunately, it's hard to get it to interact smoothly
with system headers and functions.  I put in various casts to pacify Sun's
cc compiler.  I fully expect that Linux/gcc folks might notice even more
squawking after applying my patch than before because that compiler will
complain about a completely different set of conversions.

Without understanding the underlying design, I don't know offhand what to
recommend, but this patch works for me and highlights spots where some
further thought might be needed.

diff -r -u -H -P parrot-orig/MANIFEST parrot-andy/MANIFEST
--- parrot-orig/MANIFEST        Fri Nov 19 10:58:42 2004
+++ parrot-andy/MANIFEST        Fri Nov 19 13:04:40 2004
@@ -123,7 +123,6 @@
 classes/unmanagedstruct.pmc                       []
 classes/version.pmc                               []
 classes/vtablecache.pmc                                  []
-compilers/p6ge/Makefile                           []
 compilers/p6ge/README                             []
 compilers/p6ge/demo.pir                           []
 compilers/p6ge/p6ge.h                             []
@@ -211,6 +210,7 @@
 config/gen/makefiles/miniperl.in                  []
 config/gen/makefiles/ook.in                       []
 config/gen/makefiles/perl6.in                     []
+config/gen/makefiles/p6ge.in                      []
 config/gen/makefiles/root.in                      []
 config/gen/makefiles/scheme.in                    []
 config/gen/makefiles/tcl.in                       []
diff -r -u -H -P parrot-orig/compilers/p6ge/p6ge_gen.c 
parrot-andy/compilers/p6ge/p6ge_gen.c
--- parrot-orig/compilers/p6ge/p6ge_gen.c       Fri Nov 19 08:53:40 2004
+++ parrot-andy/compilers/p6ge/p6ge_gen.c       Fri Nov 19 14:43:43 2004
@@ -81,7 +81,7 @@

 /* strcon(...) converts string values into PIR string constants */
 static char*
-strcon(const char* s, int len)
+strcon(const unsigned char* s, int len)
 {
     static char esc[P6GE_MAX_LITERAL_LEN * 2 + 3];
     char* t = esc;
diff -r -u -H -P parrot-orig/compilers/p6ge/p6ge_parse.c 
parrot-andy/compilers/p6ge/p6ge_parse.c
--- parrot-orig/compilers/p6ge/p6ge_parse.c     Fri Nov 19 08:53:40 2004
+++ parrot-andy/compilers/p6ge/p6ge_parse.c     Fri Nov 19 14:41:41 2004
@@ -22,6 +22,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>

 int p6ge_ctype[256];
 int p6ge_cmeta[256];
@@ -62,7 +63,7 @@
 p6ge_parse_error(P6GE_Text* t, const char* msg)
 {
    printf("%s at offset %d (found '%c')\n", msg, t->pos - t->text, *(t->pos));
-   t->pos = "";
+   t->pos = NULL;
 }


@@ -231,7 +232,7 @@
             p6ge_parse_error(t, "Missing { after ** quantifier");
         p6ge_skip(t, 1);
         if (isdigit(*(t->pos))) {
-            q->min = q->max = atoi(t->pos);
+            q->min = q->max = atoi((char *) t->pos);
             while (isdigit(*(t->pos))) t->pos++;
             p6ge_skip(t, 0);
         } else p6ge_parse_error(t, "Missing min value in **{} quantifier");
@@ -239,7 +240,7 @@
             p6ge_skip(t, 2);
             if (t->pos[0] == '.') { q->max = P6GE_INF; p6ge_skip(t, 1); }
             else if (isdigit(*(t->pos))) {
-                q->max = atoi(t->pos);
+                q->max = atoi((char *) t->pos);
                 while (isdigit(*(t->pos))) t->pos++;
                 p6ge_skip(t, 0);
             }
@@ -296,8 +297,8 @@
 {
     P6GE_Text t;
     P6GE_Exp* e = 0;
-    t.text = s;
-    t.pos = s;
+    t.text = (unsigned const char *) s;
+    t.pos = (unsigned const char *) s;
     t.capture = 0;
     t.ncapture = 0;
     return p6ge_parse_expr(&t);
@@ -361,6 +362,8 @@
 Initial version by Patrick R. Michaud, 2004.11.16

 =cut
+
+*/

 /*
  * Local variables:
diff -r -u -H -P parrot-orig/compilers/p6ge/p6ge_parsep5.c 
parrot-andy/compilers/p6ge/p6ge_parsep5.c
--- parrot-orig/compilers/p6ge/p6ge_parsep5.c   Fri Nov 19 08:53:40 2004
+++ parrot-andy/compilers/p6ge/p6ge_parsep5.c   Fri Nov 19 14:47:37 2004
@@ -22,6 +22,7 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>

 static P6GE_Exp* p5re_parse_expr(P6GE_Text* t);

@@ -29,7 +30,7 @@
 p5re_parse_error(P6GE_Text* t, const char* msg)
 {
    printf("%s at offset %d (found '%c')\n", msg, t->pos - t->text, *(t->pos));
-   t->pos = "";
+   t->pos = NULL;
 }


@@ -143,14 +144,14 @@
     else if (c == '*') { q->min = 0; q->max = P6GE_INF; }
     else if (c == '{') {
         if (isdigit(*(t->pos))) {
-            q->min = q->max = atoi(t->pos);
+            q->min = q->max = atoi((char *) t->pos);
             while (isdigit(*(t->pos))) t->pos++;
             p5re_skip(t, 0);
         } else p5re_parse_error(t, "Missing min value in {} quantifier");
         if (t->pos[0] == ',') {
             p5re_skip(t, 1);
             if (isdigit(*(t->pos))) {
-                q->max = atoi(t->pos);
+                q->max = atoi((char *) t->pos);
                 while (isdigit(*(t->pos))) t->pos++;
                 p5re_skip(t, 0);
             }
@@ -207,8 +208,8 @@
 {
     P6GE_Text t;
     P6GE_Exp* e = 0;
-    t.text = s;
-    t.pos = s;
+    t.text = (unsigned char *) s;
+    t.pos = (unsigned char *) s;
     t.capture = 0;
     t.ncapture = 0;
     return p5re_parse_expr(&t);
@@ -226,6 +227,8 @@
 Initial version by Patrick R. Michaud, 2004.11.16

 =cut
+
+*/

 /*
  * Local variables:
diff -r -u -H -P parrot-orig/config/gen/makefiles/p6ge.in 
parrot-andy/config/gen/makefiles/p6ge.in
--- parrot-orig/config/gen/makefiles/p6ge.in    Wed Dec 31 19:00:00 1969
+++ parrot-andy/config/gen/makefiles/p6ge.in    Fri Nov 19 14:34:06 2004
@@ -0,0 +1,75 @@
+# $Id: p6ge.in,v $
+
+# Setup some commands
+LN_S     = ${lns}
+PERL     = ${perl}
+RM_RF    = ${rm_rf}
+PARROT   = ..${slash}..${slash}parrot${exe}
+CP       = ${cp}
+
+# Where to put things
+PARROT_RUNTIME    = ..${slash}..${slash}runtime${slash}parrot${slash}dynext
+
+# Compile commands and flags
+CC        = ${cc}
+CC_SHARED = ${cc_shared} # e.g. -fpic
+DEBUG     = ${cc_debug}
+WARN      = ${ccwarn}
+CFLAGS    = ${ccflags} $(CC_SHARED) -I..${slash}..${slash}include $(DEBUG) 
$(WARN)
+O        = ${o}
+
+# Linker command and flags
+LINK      = ${link}
+LINKFLAGS = ${linkflags}
+
+# Shared-library and dynamically-loadable module building
+# XXX Which one is this?
+LD        = ${ld}
+LDFLAGS   = ${ldflags}
+LD_SHARE_FLAGS = ${ld_share_flags} # e.g. -shared
+SO        = ${share_ext}
+LD_LOAD_FLAGS = ${ld_load_flags}
+
+# the default target
+all: $(PARROT_RUNTIME)${slash}p6ge$(SO)
+
+$(PARROT_RUNTIME)${slash}p6ge$(SO): p6ge$(SO)
+       $(CP) p6ge$(SO) $(PARROT_RUNTIME)
+
+p6ge$(SO): p6ge_parse$(O) p6ge_gen$(O) p6ge_parsep5$(O)
+       $(LD) $(LD_SHARE_FLAGS) $(LDFLAGS) -o p6ge$(SO) p6ge_parse$(O) 
p6ge_gen$(O) p6ge_parsep5$(O)
+
+p6ge_gen$(O): p6ge_gen.c p6ge.h
+p6ge_parse$(O): p6ge_parse.c p6ge.h
+p6ge_parsep5$(O): p6ge_parsep5.c p6ge.h
+
+# This is a listing of all targets, that are meant to be called by users
+help:
+       @echo ""
+       @echo "Following targets are available for the user:"
+       @echo ""
+       @echo "  all:               p6ge.so"
+       @echo "                     This is the default."
+       @echo "Testing:"
+       @echo "  test:              Run the test suite."
+       @echo "                     (Doesn't work yet.)"
+       @echo ""
+       @echo "Cleaning:"
+       @echo "  clean:             Basic cleaning up."
+       @echo "  realclean:         Removes also files generated by 
'Configure.pl'"
+       @echo "  distclean:         Remove everything not in MANIFEST."
+       @echo ""
+       @echo "Misc:"
+       @echo "  help:              Print this help message."
+       @echo ""
+
+test: all
+       @echo "make test not supported yet."
+
+clean:
+       $(RM_RF) *$(O) p6ge$(SO)
+
+realclean: clean
+       $(RM_RF) Makefile
+
+distclean: realclean
diff -r -u -H -P parrot-orig/config/gen/makefiles.pl 
parrot-andy/config/gen/makefiles.pl
--- parrot-orig/config/gen/makefiles.pl Mon Sep 13 03:00:07 2004
+++ parrot-andy/config/gen/makefiles.pl Fri Nov 19 13:07:15 2004
@@ -53,6 +53,8 @@
           commentType => '#', replace_slashes => 1, conditioned_lines => 1);
   genfile('config/gen/makefiles/imcc.in',      'imcc/Makefile',
           commentType => '#', replace_slashes => 1);
+  genfile('config/gen/makefiles/p6ge.in',      'compilers/p6ge/Makefile',
+          commentType => '#', replace_slashes => 1);
   genfile('config/gen/makefiles/languages.in', 'languages/Makefile',
           commentType => '#', replace_slashes => 1);
   genfile('config/gen/makefiles/jako.in',      'languages/jako/Makefile',
diff -r -u -H -P parrot-orig/config/init/data.pl parrot-andy/config/init/data.pl
--- parrot-orig/config/init/data.pl     Fri Oct  8 13:40:37 2004
+++ parrot-andy/config/init/data.pl     Fri Nov 19 13:22:46 2004
@@ -75,9 +75,12 @@
     ld            => $Config{ld},
     ldflags       => $Config{ldflags},

-    # Shared libraries
+    # Some operating systems (e.g. Darwin) distinguish between shared 
libraries and
+    # modules that can be dynamically loaded.
+    # Flags to tell ld to build a shared library, e.g.  -shared for GNU ld.
     ld_share_flags => $Config{lddlflags},

+    # Flags to tell ld to build a dynamically loadable module, e.g.  -shared 
for GNU ld.
     # Dynamically loadable modules
     ld_load_flags => $Config{lddlflags},

@@ -87,10 +90,10 @@
     cc_debug      => '-g',
     link_debug    => '',

-    o             => '.o',                # object files extension
-    share_ext     => '.so',               # shared library extension
-    load_ext      => '.so',               # dynamically loadable module 
extension
-    a             => '.a',                # library or archive extension
+    o             => $Config{_o},         # object files extension
+    share_ext     => ".$Config{so}",      # shared library extension
+    load_ext      => ".$Config{so}",      # dynamically loadable module 
extension
+    a             => $Config{_a},         # library or archive extension
     exe           => $Config{_exe},       # executable files extension
     cc_o_out      => '-o ',               # cc object output file
     cc_exe_out    => '-o ',               # cc executable output file 
(different on Win32)
@@ -124,6 +127,7 @@
     as            => 'as',                # assembler

     cp            => 'cp',
+    lns           => $Config{lns},        # soft link
     slash         => '/',

     VERSION       => $main::parrot_version,


-- 
    Andy Dougherty              [EMAIL PROTECTED]

Reply via email to