mirror of
https://github.com/golang/go
synced 2024-11-25 05:47:57 -07:00
gc: fix mkbuiltin for Plan 9 build
. Replaced Posix #includes with u.h and libc.h. . Replaced fprintf(stderr,...); exit(1); with sysfatal() calls. R=golang-dev CC=golang-dev, rsc https://golang.org/cl/4823047
This commit is contained in:
parent
ee14fbdf34
commit
12995e2d35
@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
// Compile .go file, import data from .6 file, and generate C string version.
|
// Compile .go file, import data from .6 file, and generate C string version.
|
||||||
|
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
void esc(char*);
|
void esc(char*);
|
||||||
|
|
||||||
@ -21,8 +19,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if(argc != 2) {
|
if(argc != 2) {
|
||||||
fprintf(stderr, "usage: mkbuiltin1 sys\n");
|
fprintf(stderr, "usage: mkbuiltin1 sys\n");
|
||||||
fprintf(stderr, "in file $1.6 s/PACKAGE/$1/\n");
|
sysfatal("in file $1.6 s/PACKAGE/$1/\n");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
@ -30,16 +27,14 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s.%s", name, getenv("O"));
|
snprintf(buf, sizeof(buf), "%s.%s", name, getenv("O"));
|
||||||
if((fin = fopen(buf, "r")) == NULL) {
|
if((fin = fopen(buf, "r")) == NULL) {
|
||||||
fprintf(stderr, "open %s: %s\n", buf, strerror(errno));
|
sysfatal("open %s: %r\n", buf);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for $$ that introduces imports
|
// look for $$ that introduces imports
|
||||||
while(fgets(buf, sizeof buf, fin) != NULL)
|
while(fgets(buf, sizeof buf, fin) != NULL)
|
||||||
if(strstr(buf, "$$"))
|
if(strstr(buf, "$$"))
|
||||||
goto begin;
|
goto begin;
|
||||||
fprintf(stderr, "did not find beginning of imports\n");
|
sysfatal("did not find beginning of imports\n");
|
||||||
exit(1);
|
|
||||||
|
|
||||||
begin:
|
begin:
|
||||||
printf("char *%simport =\n", name);
|
printf("char *%simport =\n", name);
|
||||||
@ -71,8 +66,7 @@ begin:
|
|||||||
esc(p);
|
esc(p);
|
||||||
printf("\\n\"\n", p);
|
printf("\\n\"\n", p);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "did not find end of imports\n");
|
sysfatal("did not find end of imports\n");
|
||||||
exit(1);
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
printf("\t\"$$\\n\";\n");
|
printf("\t\"$$\\n\";\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user