From: Nicholas Clark Date: Tue, 19 May 2009 11:49:07 +0000 (+0200) Subject: Pass the output file name to generate_uudmap, and open it within the code, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b1d1392b607905ceba6df972064ea1ea6777ba8;p=p5sagit%2Fp5-mst-13.2.git Pass the output file name to generate_uudmap, and open it within the code, instead of having the calling Makefile redirect stdout. --- diff --git a/Makefile.SH b/Makefile.SH index f8a115f..94c1238 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -575,7 +575,7 @@ perlmini\$(OBJ_EXT): perlmini.c globals\$(OBJ_EXT): uudmap.h uudmap.h: generate_uudmap\$(HOST_EXE_EXT) - \$(RUN) ./generate_uudmap\$(HOST_EXE_EXT) >uudmap.h + \$(RUN) ./generate_uudmap\$(HOST_EXE_EXT) uudmap.h generate_uudmap\$(HOST_EXE_EXT): generate_uudmap\$(OBJ_EXT) \$(CC) -o generate_uudmap\$(EXE_EXT) \$(LDFLAGS) generate_uudmap\$(OBJ_EXT) \$(libs) diff --git a/generate_uudmap.c b/generate_uudmap.c index 28cfd27..31aba75 100644 --- a/generate_uudmap.c +++ b/generate_uudmap.c @@ -1,5 +1,11 @@ #include #include +/* If it turns out that we need to make this conditional on config.sh derived + values, it might be easier just to rip out the use of strerrer(). */ +#include +/* If a platform doesn't support errno.h, it's probably so strange that + "hello world" won't port easily to it. */ +#include static const char PL_uuemap[] = "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"; @@ -9,9 +15,21 @@ typedef unsigned char U8; /* This will ensure it is all zeros. */ static char PL_uudmap[256]; -int main() { +int main(int argc, char **argv) { size_t i; char *p; + FILE *uudmap_out; + + if (argc < 2 || argv[1][0] == '\0') { + fprintf(stderr, "Usage: %s uudemap.h\n", argv[0]); + return 1; + } + + if (!(uudmap_out = fopen(argv[1], "w"))) { + fprintf(stderr, "%s: Could not open '%s': %s\n", argv[0], argv[1], + strerror(errno)); + return 1; + } for (i = 0; i < sizeof(PL_uuemap) - 1; ++i) PL_uudmap[(U8)PL_uuemap[i]] = (char)i; @@ -24,18 +42,24 @@ int main() { i = sizeof(PL_uudmap); p = PL_uudmap; - fputs("{\n ", stdout); + fputs("{\n ", uudmap_out); while (i--) { - printf("%d", *p); + fprintf(uudmap_out, "%d", *p); p++; if (i) { - fputs(", ", stdout); + fputs(", ", uudmap_out); if (!(i & 15)) { - fputs("\n ", stdout); + fputs("\n ", uudmap_out); } } } - puts("\n}"); + fputs("\n}\n", uudmap_out); + + if (fclose(uudmap_out)) { + fprintf(stderr, "%s: Could not close '%s': %s\n", argv[0], argv[1], + strerror(errno)); + return 1; + } return 0; } diff --git a/vms/descrip_mms.template b/vms/descrip_mms.template index 232c563..6a0668a 100644 --- a/vms/descrip_mms.template +++ b/vms/descrip_mms.template @@ -503,8 +503,7 @@ perlmini$(O) : perlmini.c $(CC) $(CORECFLAGS) $(MMS$SOURCE) uudmap.h : generate_uudmap$(E) - DEFINE/USER_MODE SYS$OUTPUT uudmap.h - MCR SYS$DISK:[]generate_uudmap$(E) + MCR SYS$DISK:[]generate_uudmap$(E) uudmap.h generate_uudmap$(E) : generate_uudmap$(O) $(CRTL) Link $(LINKFLAGS)/NoDebug/Trace/NoMap/NoFull/NoCross/Exe=$(MMS$TARGET) generate_uudmap$(O) $(CRTLOPTS) diff --git a/win32/Makefile b/win32/Makefile index 4ba35b7..9eed883 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -1000,7 +1000,7 @@ $(X2P) : $(MINIPERL) $(X2P_OBJ) $(MINIDIR)\globals$(o) : $(UUDMAP_H) $(UUDMAP_H) : $(GENUUDMAP) - $(GENUUDMAP) >$(UUDMAP_H) + $(GENUUDMAP) $(UUDMAP_H) $(GENUUDMAP) : $(GENUUDMAP_OBJ) $(LINK32) -subsystem:console -out:$@ @<< diff --git a/win32/makefile.mk b/win32/makefile.mk index a6ab156..c5abb46 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -1301,7 +1301,7 @@ $(X2P) : $(MINIPERL) $(X2P_OBJ) $(MINIDIR)\globals$(o) : $(UUDMAP_H) $(UUDMAP_H) : $(GENUUDMAP) - $(GENUUDMAP) >$(UUDMAP_H) + $(GENUUDMAP) $(UUDMAP_H) $(GENUUDMAP) : $(GENUUDMAP_OBJ) .IF "$(CCTYPE)" == "BORLAND"