513 |
FILE *in; |
FILE *in; |
514 |
FILE *out; |
FILE *out; |
515 |
int filter_fd[2]; |
int filter_fd[2]; |
516 |
char const *argv[7]; |
char const *argv[6]; |
517 |
pid_t pid; |
pid_t pid; |
518 |
|
|
519 |
/* Compute the names of the package data dir and skeleton file. |
/* Compute the names of the package data dir and skeleton file. |
521 |
installation. A faulty installation can cause deadlock, so a |
installation. A faulty installation can cause deadlock, so a |
522 |
cheap sanity check is worthwhile. */ |
cheap sanity check is worthwhile. */ |
523 |
char const m4sugar[] = "m4sugar/m4sugar.m4"; |
char const m4sugar[] = "m4sugar/m4sugar.m4"; |
524 |
|
char *full_m4sugar; |
525 |
|
char *full_cm4; |
526 |
char *full_path; |
char *full_path; |
527 |
char const *p; |
char const *p; |
528 |
char const *m4 = (p = getenv ("M4")) ? p : M4; |
char const *m4 = (p = getenv ("M4")) ? p : M4; |
537 |
strcpy (full_path, pkgdatadir); |
strcpy (full_path, pkgdatadir); |
538 |
full_path[pkgdatadirlen] = '/'; |
full_path[pkgdatadirlen] = '/'; |
539 |
strcpy (full_path + pkgdatadirlen + 1, m4sugar); |
strcpy (full_path + pkgdatadirlen + 1, m4sugar); |
540 |
xfclose (xfopen (full_path, "r")); |
full_m4sugar = xstrdup (full_path); |
541 |
|
strcpy (full_path + pkgdatadirlen + 1, "c.m4"); |
542 |
|
full_cm4 = xstrdup (full_path); |
543 |
strcpy (full_path + pkgdatadirlen + 1, skeleton); |
strcpy (full_path + pkgdatadirlen + 1, skeleton); |
544 |
|
xfclose (xfopen (full_m4sugar, "r")); |
545 |
|
|
546 |
/* Create an m4 subprocess connected to us via two pipes. */ |
/* Create an m4 subprocess connected to us via two pipes. */ |
547 |
|
|
548 |
if (trace_flag & trace_tools) |
if (trace_flag & trace_tools) |
549 |
fprintf (stderr, "running: %s -I %s %s - %s\n", |
fprintf (stderr, "running: %s %s - %s %s\n", |
550 |
m4, pkgdatadir, m4sugar, full_path); |
m4, full_m4sugar, full_cm4, full_path); |
551 |
|
|
552 |
argv[0] = m4; |
argv[0] = m4; |
553 |
argv[1] = "-I"; |
argv[1] = full_m4sugar; |
554 |
argv[2] = pkgdatadir; |
argv[2] = "-"; |
555 |
argv[3] = m4sugar; |
argv[3] = full_cm4; |
556 |
argv[4] = "-"; |
argv[4] = full_path; |
557 |
argv[5] = full_path; |
argv[5] = NULL; |
|
argv[6] = NULL; |
|
558 |
|
|
559 |
init_subpipe (); |
init_subpipe (); |
560 |
pid = create_subpipe (argv, filter_fd); |
pid = create_subpipe (argv, filter_fd); |
561 |
|
free (full_m4sugar); |
562 |
|
free (full_cm4); |
563 |
free (full_path); |
free (full_path); |
564 |
|
|
565 |
out = fdopen (filter_fd[0], "w"); |
out = fdopen (filter_fd[0], "w"); |