9front and more

A minimal patch to compile and run minipeg on 9front (using pcc)

Published by be0ba on

minipeg on 9front

be0ba

Apply the patch, and on a *nix box, make minipeg-new.c && mv minipeg-new.c minipeg.c. After that, create version.h either using make version.h on *nix, or by w/e means you like on 9front, and then pcc -D_POSIX_SOURCE -D_BSD_EXTENSION -c minipeg.c and link the resulting object file.

diff --git a/compile.c b/compile.c
index 4e7977d..3abe12e 100644
--- a/compile.c
+++ b/compile.c
@@ -389,7 +389,7 @@ static char *header=
 
 static char *preamble= "\
 #ifndef YY_MAYBE_UNUSED\n\
-#define YY_MAYBE_UNUSED __attribute__((unused))\n\
+#define YY_MAYBE_UNUSED\n\
 #endif\n\
 #ifndef YY_MALLOC\n\
 #define YY_MALLOC(C, N)        malloc(N)\n\
diff --git a/peg.peg b/peg.peg
index 686106a..2b39d7c 100644
--- a/peg.peg
+++ b/peg.peg
@@ -2,13 +2,16 @@
 #include "tree.h"
 #include "version.h"
 
+#include <bsd.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <libgen.h>
 #include <assert.h>
 
+int yyparse(void);
+
   typedef struct Header Header;
 
   struct Header {
@@ -215,11 +218,11 @@ int main(int argc, char **argv)
       switch (c)
    {
    case 'V':
-     version(basename(argv[0]));
+     version(argv[0]);
      exit(0);
 
    case 'h':
-     usage(basename(argv[0]));
+     usage(argv[0]);
      break;
 
    case 'o':

Tags: minipeg9front.