mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
imake: Convert function prototypes and signatures to ANSI format.
This commit is contained in:
parent
eaec696ad6
commit
045c80dd78
1 changed files with 202 additions and 199 deletions
|
@ -256,6 +256,7 @@ extern int errno;
|
||||||
* are there any X_NOT_STDC_ENV machines left in the world?
|
* are there any X_NOT_STDC_ENV machines left in the world?
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include "imakemdep.h"
|
#include "imakemdep.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -275,14 +276,14 @@ extern int sys_nerr;
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
#ifdef FIXUP_CPP_WHITESPACE
|
#ifdef FIXUP_CPP_WHITESPACE
|
||||||
int InRule = FALSE;
|
static int InRule = FALSE;
|
||||||
# ifdef INLINE_SYNTAX
|
# ifdef INLINE_SYNTAX
|
||||||
int InInline = 0;
|
static int InInline = 0;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef MAGIC_MAKE_VARS
|
#ifdef MAGIC_MAKE_VARS
|
||||||
int xvariable = 0;
|
static int xvariable = 0;
|
||||||
int xvariables[10];
|
static int xvariables[10];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -291,7 +292,8 @@ int xvariables[10];
|
||||||
* space instead of being deleted. Blech.
|
* space instead of being deleted. Blech.
|
||||||
*/
|
*/
|
||||||
#ifdef FIXUP_CPP_WHITESPACE
|
#ifdef FIXUP_CPP_WHITESPACE
|
||||||
void KludgeOutputLine(), KludgeResetRule();
|
static void KludgeOutputLine(char **pline);
|
||||||
|
static void KludgeResetRule(void);
|
||||||
#else
|
#else
|
||||||
# define KludgeOutputLine(arg)
|
# define KludgeOutputLine(arg)
|
||||||
# define KludgeResetRule()
|
# define KludgeResetRule()
|
||||||
|
@ -313,11 +315,11 @@ typedef unsigned char boolean;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *cpp = NULL;
|
static char *cpp = NULL;
|
||||||
|
|
||||||
char *tmpMakefile = "/tmp/Imf.XXXXXX";
|
static char *tmpMakefile = "/tmp/Imf.XXXXXX";
|
||||||
char *tmpImakefile = "/tmp/IIf.XXXXXX";
|
static char *tmpImakefile = "/tmp/IIf.XXXXXX";
|
||||||
char *make_argv[ ARGUMENTS ] = {
|
static char *make_argv[ ARGUMENTS ] = {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
"nmake"
|
"nmake"
|
||||||
#else
|
#else
|
||||||
|
@ -325,42 +327,69 @@ char *make_argv[ ARGUMENTS ] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int make_argindex;
|
static int make_argindex;
|
||||||
int cpp_argindex;
|
static int cpp_argindex;
|
||||||
char *Imakefile = NULL;
|
static char *Imakefile = NULL;
|
||||||
char *Makefile = "Makefile";
|
static char *Makefile = "Makefile";
|
||||||
char *Template = "Imake.tmpl";
|
static char *Template = "Imake.tmpl";
|
||||||
char *ImakefileC = "Imakefile.c";
|
static char *ImakefileC = "Imakefile.c";
|
||||||
boolean haveImakefileC = FALSE;
|
static boolean haveImakefileC = FALSE;
|
||||||
char *cleanedImakefile = NULL;
|
static char *cleanedImakefile = NULL;
|
||||||
char *program;
|
static char *program;
|
||||||
char *FindImakefile();
|
static boolean verbose = FALSE;
|
||||||
char *ReadLine();
|
static boolean show = TRUE;
|
||||||
char *CleanCppInput();
|
|
||||||
char *Strdup();
|
|
||||||
char *Emalloc();
|
|
||||||
void LogFatalI(), LogFatal(), LogMsg();
|
|
||||||
|
|
||||||
void showit();
|
static char *FindImakefile(char *);
|
||||||
void wrapup();
|
static char *ReadLine(FILE *, const char *);
|
||||||
void init();
|
static char *CleanCppInput(char *);
|
||||||
void AddMakeArg();
|
static char *Strdup(const char *);
|
||||||
void AddCppArg();
|
static char *Emalloc(int);
|
||||||
void SetOpts();
|
static void LogFatal(const char *, ...);
|
||||||
void CheckImakefileC();
|
static void LogMsg(const char *, ...);
|
||||||
void cppit();
|
static void Log(const char *, va_list);
|
||||||
void makeit();
|
|
||||||
void CleanCppOutput();
|
|
||||||
boolean isempty();
|
|
||||||
void writetmpfile();
|
|
||||||
|
|
||||||
boolean verbose = FALSE;
|
static void showit(FILE *);
|
||||||
boolean show = TRUE;
|
static void wrapup(void);
|
||||||
|
static
|
||||||
|
#ifdef SIGNALRETURNSINT
|
||||||
|
int
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
#endif
|
||||||
|
catch(int);
|
||||||
|
static void init(void);
|
||||||
|
static void AddMakeArg(char *);
|
||||||
|
static void AddCppArg(char *);
|
||||||
|
static void SetOpts(int, char **);
|
||||||
|
static void showargs(char **);
|
||||||
|
static void CheckImakefileC(const char *);
|
||||||
|
static boolean optional_include(FILE *, const char *, const char *);
|
||||||
|
static void doit(FILE *, const char *, char **);
|
||||||
|
#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
|
||||||
|
defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
|
||||||
|
static void parse_utsname(struct utsname *, const char *, char *, const char *);
|
||||||
|
#endif
|
||||||
|
#if (defined(DEFAULT_OS_MAJOR_REV) || defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
|
||||||
|
static const char *trim_version(const char *);
|
||||||
|
#endif
|
||||||
|
#ifdef linux
|
||||||
|
static void get_distrib(FILE *);
|
||||||
|
static void get_libc_version(FILE *);
|
||||||
|
static void get_ld_version(FILE *);
|
||||||
|
#endif
|
||||||
|
#if defined(sun) && defined(__SVR4)
|
||||||
|
static void get_sun_compiler_versions(FILE *);
|
||||||
|
#endif
|
||||||
|
static void get_gcc_incdir(FILE *);
|
||||||
|
static boolean define_os_defaults(FILE *);
|
||||||
|
static void cppit(const char *i, const char *, const char *, FILE *, const char *);
|
||||||
|
static void makeit(void);
|
||||||
|
static void CleanCppOutput(FILE *, const char *);
|
||||||
|
static boolean isempty(char *);
|
||||||
|
static void writetmpfile(FILE *, const char *, int, const char *);
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(int argc, char *argv[])
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
FILE *tmpfd;
|
FILE *tmpfd;
|
||||||
char makeMacro[ BUFSIZ ];
|
char makeMacro[ BUFSIZ ];
|
||||||
|
@ -376,7 +405,7 @@ main(argc, argv)
|
||||||
tmpMakefile = Makefile;
|
tmpMakefile = Makefile;
|
||||||
else {
|
else {
|
||||||
tmpMakefile = Strdup(tmpMakefile);
|
tmpMakefile = Strdup(tmpMakefile);
|
||||||
(void) mktemp(tmpMakefile);
|
mkstemp(tmpMakefile);
|
||||||
}
|
}
|
||||||
AddMakeArg("-f");
|
AddMakeArg("-f");
|
||||||
AddMakeArg( tmpMakefile );
|
AddMakeArg( tmpMakefile );
|
||||||
|
@ -397,12 +426,11 @@ main(argc, argv)
|
||||||
} else
|
} else
|
||||||
makeit();
|
makeit();
|
||||||
wrapup();
|
wrapup();
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
showit(fd)
|
showit(FILE *fd)
|
||||||
FILE *fd;
|
|
||||||
{
|
{
|
||||||
char buf[ BUFSIZ ];
|
char buf[ BUFSIZ ];
|
||||||
int red;
|
int red;
|
||||||
|
@ -414,8 +442,8 @@ showit(fd)
|
||||||
LogFatal("Cannot read %s.", tmpMakefile);
|
LogFatal("Cannot read %s.", tmpMakefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
wrapup()
|
wrapup(void)
|
||||||
{
|
{
|
||||||
if (tmpMakefile != Makefile)
|
if (tmpMakefile != Makefile)
|
||||||
unlink(tmpMakefile);
|
unlink(tmpMakefile);
|
||||||
|
@ -425,25 +453,25 @@ wrapup()
|
||||||
unlink(ImakefileC);
|
unlink(ImakefileC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
#ifdef SIGNALRETURNSINT
|
#ifdef SIGNALRETURNSINT
|
||||||
int
|
int
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
#endif
|
#endif
|
||||||
catch(sig)
|
catch(int sig)
|
||||||
int sig;
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
LogFatalI("Signal %d.", sig);
|
LogFatal("Signal %d.", sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize some variables.
|
* Initialize some variables.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
init()
|
init(void)
|
||||||
{
|
{
|
||||||
register char *p;
|
char *p;
|
||||||
|
|
||||||
make_argindex=0;
|
make_argindex=0;
|
||||||
while (make_argv[ make_argindex ] != NULL)
|
while (make_argv[ make_argindex ] != NULL)
|
||||||
|
@ -457,10 +485,9 @@ init()
|
||||||
* the default. Or if cpp is not the default. Or if the make
|
* the default. Or if cpp is not the default. Or if the make
|
||||||
* found by the PATH variable is not the default.
|
* found by the PATH variable is not the default.
|
||||||
*/
|
*/
|
||||||
if (p = getenv("IMAKEINCLUDE")) {
|
if ((p = getenv("IMAKEINCLUDE"))) {
|
||||||
if (*p != '-' || *(p+1) != 'I')
|
if (*p != '-' || *(p+1) != 'I')
|
||||||
LogFatal("Environment var IMAKEINCLUDE %s",
|
LogFatal("Environment var IMAKEINCLUDE %s must begin with -I");
|
||||||
"must begin with -I");
|
|
||||||
AddCppArg(p);
|
AddCppArg(p);
|
||||||
for (; *p; p++)
|
for (; *p; p++)
|
||||||
if (*p == ' ') {
|
if (*p == ' ') {
|
||||||
|
@ -468,41 +495,37 @@ init()
|
||||||
AddCppArg(p);
|
AddCppArg(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p = getenv("IMAKECPP"))
|
if ((p = getenv("IMAKECPP")))
|
||||||
cpp = p;
|
cpp = p;
|
||||||
if (p = getenv("IMAKEMAKE"))
|
if ((p = getenv("IMAKEMAKE")))
|
||||||
make_argv[0] = p;
|
make_argv[0] = p;
|
||||||
|
|
||||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||||
signal(SIGINT, catch);
|
signal(SIGINT, catch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
AddMakeArg(arg)
|
AddMakeArg(char *arg)
|
||||||
char *arg;
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (make_argindex >= ARGUMENTS-1)
|
if (make_argindex >= ARGUMENTS-1)
|
||||||
LogFatal("Out of internal storage.", "");
|
LogFatal("Out of internal storage.");
|
||||||
make_argv[ make_argindex++ ] = arg;
|
make_argv[ make_argindex++ ] = arg;
|
||||||
make_argv[ make_argindex ] = NULL;
|
make_argv[ make_argindex ] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
AddCppArg(arg)
|
AddCppArg(char *arg)
|
||||||
char *arg;
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (cpp_argindex >= ARGUMENTS-1)
|
if (cpp_argindex >= ARGUMENTS-1)
|
||||||
LogFatal("Out of internal storage.", "");
|
LogFatal("Out of internal storage.");
|
||||||
cpp_argv[ cpp_argindex++ ] = arg;
|
cpp_argv[ cpp_argindex++ ] = arg;
|
||||||
cpp_argv[ cpp_argindex ] = NULL;
|
cpp_argv[ cpp_argindex ] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
SetOpts(argc, argv)
|
SetOpts(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
/*
|
/*
|
||||||
|
@ -523,7 +546,7 @@ SetOpts(argc, argv)
|
||||||
else {
|
else {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
if (! argc)
|
if (! argc)
|
||||||
LogFatal("No description arg after -f flag", "");
|
LogFatal("No description arg after -f flag");
|
||||||
Imakefile = argv[0];
|
Imakefile = argv[0];
|
||||||
}
|
}
|
||||||
} else if (argv[0][1] == 's') {
|
} else if (argv[0][1] == 's') {
|
||||||
|
@ -533,7 +556,7 @@ SetOpts(argc, argv)
|
||||||
else {
|
else {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
if (!argc)
|
if (!argc)
|
||||||
LogFatal("No description arg after -s flag", "");
|
LogFatal("No description arg after -s flag");
|
||||||
Makefile = ((argv[0][0] == '-') && !argv[0][1]) ?
|
Makefile = ((argv[0][0] == '-') && !argv[0][1]) ?
|
||||||
NULL : argv[0];
|
NULL : argv[0];
|
||||||
}
|
}
|
||||||
|
@ -547,7 +570,7 @@ SetOpts(argc, argv)
|
||||||
else {
|
else {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
if (! argc)
|
if (! argc)
|
||||||
LogFatal("No description arg after -T flag", "");
|
LogFatal("No description arg after -T flag");
|
||||||
Template = argv[0];
|
Template = argv[0];
|
||||||
}
|
}
|
||||||
} else if (argv[0][1] == 'C') {
|
} else if (argv[0][1] == 'C') {
|
||||||
|
@ -556,7 +579,7 @@ SetOpts(argc, argv)
|
||||||
else {
|
else {
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
if (! argc)
|
if (! argc)
|
||||||
LogFatal("No imakeCfile arg after -C flag", "");
|
LogFatal("No imakeCfile arg after -C flag");
|
||||||
ImakefileC = argv[0];
|
ImakefileC = argv[0];
|
||||||
}
|
}
|
||||||
} else if (argv[0][1] == 'v') {
|
} else if (argv[0][1] == 'v') {
|
||||||
|
@ -580,9 +603,8 @@ SetOpts(argc, argv)
|
||||||
AddCppArg(ImakefileC);
|
AddCppArg(ImakefileC);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
FindImakefile(Imakefile)
|
FindImakefile(char *Imakefile)
|
||||||
char *Imakefile;
|
|
||||||
{
|
{
|
||||||
if (Imakefile) {
|
if (Imakefile) {
|
||||||
if (access(Imakefile, R_OK) < 0)
|
if (access(Imakefile, R_OK) < 0)
|
||||||
|
@ -590,7 +612,7 @@ FindImakefile(Imakefile)
|
||||||
} else {
|
} else {
|
||||||
if (access("Imakefile", R_OK) < 0)
|
if (access("Imakefile", R_OK) < 0)
|
||||||
if (access("imakefile", R_OK) < 0)
|
if (access("imakefile", R_OK) < 0)
|
||||||
LogFatal("No description file.", "");
|
LogFatal("No description file.");
|
||||||
else
|
else
|
||||||
Imakefile = "imakefile";
|
Imakefile = "imakefile";
|
||||||
else
|
else
|
||||||
|
@ -599,49 +621,54 @@ FindImakefile(Imakefile)
|
||||||
return(Imakefile);
|
return(Imakefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
LogFatalI(s, i)
|
LogFatal(const char *s, ...)
|
||||||
char *s;
|
|
||||||
int i;
|
|
||||||
{
|
{
|
||||||
/*NOSTRICT*/
|
static boolean entered = FALSE;
|
||||||
LogFatal(s, (char *)i);
|
va_list args;
|
||||||
|
|
||||||
|
if (entered)
|
||||||
|
return;
|
||||||
|
|
||||||
|
entered = TRUE;
|
||||||
|
|
||||||
|
va_start(args, s);
|
||||||
|
Log(s, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
fprintf(stderr, "Stop.\n");
|
||||||
|
|
||||||
|
wrapup();
|
||||||
|
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
LogFatal(x0,x1)
|
LogMsg(const char *s, ...)
|
||||||
char *x0, *x1;
|
|
||||||
{
|
{
|
||||||
static boolean entered = FALSE;
|
va_list args;
|
||||||
|
|
||||||
if (entered)
|
va_start(args, s);
|
||||||
return;
|
Log(s, args);
|
||||||
entered = TRUE;
|
va_end(args);
|
||||||
|
|
||||||
LogMsg(x0, x1);
|
|
||||||
fprintf(stderr, " Stop.\n");
|
|
||||||
wrapup();
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
LogMsg(x0,x1)
|
Log(const char *s, va_list args)
|
||||||
char *x0, *x1;
|
|
||||||
{
|
{
|
||||||
int error_number = errno;
|
int error_number = errno;
|
||||||
|
|
||||||
if (error_number) {
|
if (error_number) {
|
||||||
fprintf(stderr, "%s: ", program);
|
fprintf(stderr, "%s: ", program);
|
||||||
fprintf(stderr, "%s\n", strerror(error_number));
|
fprintf(stderr, "%s\n", strerror(error_number));
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%s: ", program);
|
fprintf(stderr, "%s: ", program);
|
||||||
fprintf(stderr, x0, x1);
|
vfprintf(stderr, s, args);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
showargs(argv)
|
showargs(char **argv)
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
for (; *argv; argv++)
|
for (; *argv; argv++)
|
||||||
fprintf(stderr, "%s ", *argv);
|
fprintf(stderr, "%s ", *argv);
|
||||||
|
@ -650,9 +677,8 @@ showargs(argv)
|
||||||
|
|
||||||
#define ImakefileCHeader "/* imake - temporary file */"
|
#define ImakefileCHeader "/* imake - temporary file */"
|
||||||
|
|
||||||
void
|
static void
|
||||||
CheckImakefileC(masterc)
|
CheckImakefileC(const char *masterc)
|
||||||
char *masterc;
|
|
||||||
{
|
{
|
||||||
char mkcbuf[1024];
|
char mkcbuf[1024];
|
||||||
FILE *inFile;
|
FILE *inFile;
|
||||||
|
@ -678,11 +704,8 @@ CheckImakefileC(masterc)
|
||||||
#define ImakeTmplSym "IMAKE_TEMPLATE"
|
#define ImakeTmplSym "IMAKE_TEMPLATE"
|
||||||
#define OverrideWarning "Warning: local file \"%s\" overrides global macros."
|
#define OverrideWarning "Warning: local file \"%s\" overrides global macros."
|
||||||
|
|
||||||
boolean
|
static boolean
|
||||||
optional_include(inFile, defsym, fname)
|
optional_include(FILE *inFile, const char *defsym, const char *fname)
|
||||||
FILE *inFile;
|
|
||||||
char *defsym;
|
|
||||||
char *fname;
|
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (access(fname, R_OK) == 0) {
|
if (access(fname, R_OK) == 0) {
|
||||||
|
@ -693,11 +716,8 @@ optional_include(inFile, defsym, fname)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
doit(outfd, cmd, argv)
|
doit(FILE *outfd, const char *cmd, char **argv)
|
||||||
FILE *outfd;
|
|
||||||
char *cmd;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
waitType status;
|
waitType status;
|
||||||
|
@ -712,18 +732,18 @@ doit(outfd, cmd, argv)
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
LogFatal("Cannot spawn %s.", cmd);
|
LogFatal("Cannot spawn %s.", cmd);
|
||||||
if (status > 0)
|
if (status > 0)
|
||||||
LogFatalI("Exit code %d.", status);
|
LogFatal("Exit code %d.", status);
|
||||||
#else
|
#else
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
LogFatal("Cannot fork.", "");
|
LogFatal("Cannot fork.");
|
||||||
if (pid) { /* parent... simply wait */
|
if (pid) { /* parent... simply wait */
|
||||||
while (wait(&status) > 0) {
|
while (wait(&status) > 0) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (WIFSIGNALED(status))
|
if (WIFSIGNALED(status))
|
||||||
LogFatalI("Signal %d.", waitSig(status));
|
LogFatal("Signal %d.", waitSig(status));
|
||||||
if (WIFEXITED(status) && waitCode(status))
|
if (WIFEXITED(status) && waitCode(status))
|
||||||
LogFatalI("Exit code %d.", waitCode(status));
|
LogFatal("Exit code %d.", waitCode(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* child... dup and exec cmd */
|
else { /* child... dup and exec cmd */
|
||||||
|
@ -738,12 +758,11 @@ doit(outfd, cmd, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
||||||
|
#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
|
||||||
|
defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
|
||||||
static void
|
static void
|
||||||
parse_utsname(name, fmt, result, msg)
|
parse_utsname(struct utsname *name, const char *fmt, char *result, const char *msg)
|
||||||
struct utsname *name;
|
|
||||||
char *fmt;
|
|
||||||
char *result;
|
|
||||||
char *msg;
|
|
||||||
{
|
{
|
||||||
char buf[SYS_NMLN * 5 + 1];
|
char buf[SYS_NMLN * 5 + 1];
|
||||||
char *ptr = buf;
|
char *ptr = buf;
|
||||||
|
@ -800,21 +819,22 @@ parse_utsname(name, fmt, result, msg)
|
||||||
|
|
||||||
/* Just in case... */
|
/* Just in case... */
|
||||||
if (strlen(buf) >= sizeof(buf))
|
if (strlen(buf) >= sizeof(buf))
|
||||||
LogFatal("Buffer overflow parsing uname.", "");
|
LogFatal("Buffer overflow parsing uname.");
|
||||||
|
|
||||||
/* Parse the buffer. The sscanf() return value is rarely correct. */
|
/* Parse the buffer. The sscanf() return value is rarely correct. */
|
||||||
*result = '\0';
|
*result = '\0';
|
||||||
(void) sscanf(buf, fmt + arg + 1, result);
|
(void) sscanf(buf, fmt + arg + 1, result);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Trim leading 0's and periods from version names. The 0's cause
|
/* Trim leading 0's and periods from version names. The 0's cause
|
||||||
the number to be interpreted as octal numbers. Some version strings
|
the number to be interpreted as octal numbers. Some version strings
|
||||||
have the potential for different numbers of .'s in them.
|
have the potential for different numbers of .'s in them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *
|
#if (defined(DEFAULT_OS_MAJOR_REV) || defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
|
||||||
trim_version(p)
|
static const char *
|
||||||
char *p;
|
trim_version(const char *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (p != 0 && *p != '\0')
|
if (p != 0 && *p != '\0')
|
||||||
|
@ -826,9 +846,11 @@ trim_version(p)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
static void get_distrib(inFile)
|
static void
|
||||||
FILE* inFile;
|
get_distrib(FILE *inFile)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
|
@ -928,8 +950,8 @@ static const char *libc_c=
|
||||||
"}\n"
|
"}\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static void get_libc_version(inFile)
|
static void
|
||||||
FILE* inFile;
|
get_libc_version(FILE *inFile)
|
||||||
{
|
{
|
||||||
static char* libcso = "/usr/lib/libc.so";
|
static char* libcso = "/usr/lib/libc.so";
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
@ -991,8 +1013,8 @@ static void get_libc_version(inFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_ld_version(inFile)
|
static void
|
||||||
FILE* inFile;
|
get_ld_version(FILE *inFile)
|
||||||
{
|
{
|
||||||
FILE* ldprog = popen ("ld -v", "r");
|
FILE* ldprog = popen ("ld -v", "r");
|
||||||
char c;
|
char c;
|
||||||
|
@ -1016,8 +1038,8 @@ static void get_ld_version(inFile)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(sun) && defined(__SVR4)
|
#if defined(sun) && defined(__SVR4)
|
||||||
static void get_sun_compiler_versions (inFile)
|
static void
|
||||||
FILE* inFile;
|
get_sun_compiler_versions(FILE *inFile)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
char cmd[PATH_MAX];
|
char cmd[PATH_MAX];
|
||||||
|
@ -1069,8 +1091,8 @@ static void get_sun_compiler_versions (inFile)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void get_gcc_incdir(inFile)
|
static void
|
||||||
FILE* inFile;
|
get_gcc_incdir(FILE *inFile)
|
||||||
{
|
{
|
||||||
static char* gcc_path[] = {
|
static char* gcc_path[] = {
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
|
@ -1105,19 +1127,18 @@ static void get_gcc_incdir(inFile)
|
||||||
fprintf (inFile, "#define DefaultGccIncludeDir %s\n", buf);
|
fprintf (inFile, "#define DefaultGccIncludeDir %s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
static boolean
|
||||||
define_os_defaults(inFile)
|
define_os_defaults(FILE *inFile)
|
||||||
FILE *inFile;
|
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
|
#if (defined(DEFAULT_OS_NAME) || defined(DEFAULT_OS_MAJOR_REV) || \
|
||||||
defined(DEFAULT_OS_MINOR_REV) || defined(DEFAUL_OS_TEENY_REV))
|
defined(DEFAULT_OS_MINOR_REV) || defined(DEFAULT_OS_TEENY_REV))
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
char buf[SYS_NMLN * 5 + 1];
|
char buf[SYS_NMLN * 5 + 1];
|
||||||
|
|
||||||
/* Obtain the system information. */
|
/* Obtain the system information. */
|
||||||
if (uname(&name) < 0)
|
if (uname(&name) < 0)
|
||||||
LogFatal("Cannot invoke uname", "");
|
LogFatal("Cannot invoke uname");
|
||||||
|
|
||||||
# ifdef DEFAULT_OS_NAME
|
# ifdef DEFAULT_OS_NAME
|
||||||
parse_utsname(&name, DEFAULT_OS_NAME, buf,
|
parse_utsname(&name, DEFAULT_OS_NAME, buf,
|
||||||
|
@ -1175,13 +1196,8 @@ define_os_defaults(inFile)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cppit(imakefile, template, masterc, outfd, outfname)
|
cppit(const char *imakefile, const char *template, const char *masterc, FILE *outfd, const char *outfname)
|
||||||
char *imakefile;
|
|
||||||
char *template;
|
|
||||||
char *masterc;
|
|
||||||
FILE *outfd;
|
|
||||||
char *outfname;
|
|
||||||
{
|
{
|
||||||
FILE *inFile;
|
FILE *inFile;
|
||||||
|
|
||||||
|
@ -1208,15 +1224,14 @@ cppit(imakefile, template, masterc, outfd, outfname)
|
||||||
CleanCppOutput(outfd, outfname);
|
CleanCppOutput(outfd, outfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
makeit()
|
makeit(void)
|
||||||
{
|
{
|
||||||
doit(NULL, make_argv[0], make_argv);
|
doit(NULL, make_argv[0], make_argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
CleanCppInput(imakefile)
|
CleanCppInput(char *imakefile)
|
||||||
char *imakefile;
|
|
||||||
{
|
{
|
||||||
FILE *outFile = NULL;
|
FILE *outFile = NULL;
|
||||||
FILE *inFile;
|
FILE *inFile;
|
||||||
|
@ -1271,7 +1286,7 @@ CleanCppInput(imakefile)
|
||||||
strcmp(ptoken, "undef")) {
|
strcmp(ptoken, "undef")) {
|
||||||
if (outFile == NULL) {
|
if (outFile == NULL) {
|
||||||
tmpImakefile = Strdup(tmpImakefile);
|
tmpImakefile = Strdup(tmpImakefile);
|
||||||
(void) mktemp(tmpImakefile);
|
mkstemp(tmpImakefile);
|
||||||
outFile = fopen(tmpImakefile, "w");
|
outFile = fopen(tmpImakefile, "w");
|
||||||
if (outFile == NULL)
|
if (outFile == NULL)
|
||||||
LogFatal("Cannot open %s for write.",
|
LogFatal("Cannot open %s for write.",
|
||||||
|
@ -1298,15 +1313,13 @@ CleanCppInput(imakefile)
|
||||||
return(imakefile);
|
return(imakefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
CleanCppOutput(tmpfd, tmpfname)
|
CleanCppOutput(FILE *tmpfd, const char *tmpfname)
|
||||||
FILE *tmpfd;
|
|
||||||
char *tmpfname;
|
|
||||||
{
|
{
|
||||||
char *input;
|
char *input;
|
||||||
int blankline = 0;
|
int blankline = 0;
|
||||||
|
|
||||||
while(input = ReadLine(tmpfd, tmpfname)) {
|
while ((input = ReadLine(tmpfd, tmpfname))) {
|
||||||
if (isempty(input)) {
|
if (isempty(input)) {
|
||||||
if (blankline++)
|
if (blankline++)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1334,11 +1347,10 @@ CleanCppOutput(tmpfd, tmpfname)
|
||||||
* space from the end of the line. Cpp magic cookies are also thrown away.
|
* space from the end of the line. Cpp magic cookies are also thrown away.
|
||||||
* "XCOMM" token is transformed to "#".
|
* "XCOMM" token is transformed to "#".
|
||||||
*/
|
*/
|
||||||
boolean
|
static boolean
|
||||||
isempty(line)
|
isempty(char *line)
|
||||||
register char *line;
|
|
||||||
{
|
{
|
||||||
register char *pend;
|
char *pend;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for lines of the form
|
* Check for lines of the form
|
||||||
|
@ -1408,14 +1420,12 @@ isempty(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
char *
|
static char *
|
||||||
ReadLine(tmpfd, tmpfname)
|
ReadLine(FILE *tmpfd, const char *tmpfname)
|
||||||
FILE *tmpfd;
|
|
||||||
char *tmpfname;
|
|
||||||
{
|
{
|
||||||
static boolean initialized = FALSE;
|
static boolean initialized = FALSE;
|
||||||
static char *buf, *pline, *end;
|
static char *buf, *pline, *end;
|
||||||
register char *p1, *p2;
|
char *p1, *p2;
|
||||||
|
|
||||||
if (! initialized) {
|
if (! initialized) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -1444,7 +1454,7 @@ ReadLine(tmpfd, tmpfname)
|
||||||
tmpfd = freopen(tmpfname, "w+", fp);
|
tmpfd = freopen(tmpfname, "w+", fp);
|
||||||
#endif
|
#endif
|
||||||
if (! tmpfd)
|
if (! tmpfd)
|
||||||
LogFatal("cannot reopen %s\n", tmpfname);
|
LogFatal("cannot reopen %s.", tmpfname);
|
||||||
#else /* !SYSV */
|
#else /* !SYSV */
|
||||||
ftruncate(fileno(tmpfd), (off_t) 0);
|
ftruncate(fileno(tmpfd), (off_t) 0);
|
||||||
#endif /* !SYSV */
|
#endif /* !SYSV */
|
||||||
|
@ -1481,32 +1491,26 @@ ReadLine(tmpfd, tmpfname)
|
||||||
return(p2);
|
return(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
writetmpfile(fd, buf, cnt, fname)
|
writetmpfile(FILE *fd, const char *buf, int cnt, const char *fname)
|
||||||
FILE *fd;
|
|
||||||
int cnt;
|
|
||||||
char *buf;
|
|
||||||
char *fname;
|
|
||||||
{
|
{
|
||||||
if (fwrite(buf, sizeof(char), cnt, fd) == -1)
|
if (fwrite(buf, sizeof(char), cnt, fd) == -1)
|
||||||
LogFatal("Cannot write to %s.", fname);
|
LogFatal("Cannot write to %s.", fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
Emalloc(size)
|
Emalloc(int size)
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if ((p = malloc(size)) == NULL)
|
if ((p = malloc(size)) == NULL)
|
||||||
LogFatalI("Cannot allocate %d bytes", size);
|
LogFatal("Cannot allocate %d bytes.", size);
|
||||||
return(p);
|
return(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FIXUP_CPP_WHITESPACE
|
#ifdef FIXUP_CPP_WHITESPACE
|
||||||
void
|
static void
|
||||||
KludgeOutputLine(pline)
|
KludgeOutputLine(char **pline)
|
||||||
char **pline;
|
|
||||||
{
|
{
|
||||||
char *p = *pline;
|
char *p = *pline;
|
||||||
char quotechar = '\0';
|
char quotechar = '\0';
|
||||||
|
@ -1588,18 +1592,17 @@ breakfor:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
KludgeResetRule()
|
KludgeResetRule(void)
|
||||||
{
|
{
|
||||||
InRule = FALSE;
|
InRule = FALSE;
|
||||||
}
|
}
|
||||||
#endif /* FIXUP_CPP_WHITESPACE */
|
#endif /* FIXUP_CPP_WHITESPACE */
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
Strdup(cp)
|
Strdup(const char *cp)
|
||||||
register char *cp;
|
|
||||||
{
|
{
|
||||||
register char *new = Emalloc(strlen(cp) + 1);
|
char *new = Emalloc(strlen(cp) + 1);
|
||||||
|
|
||||||
strcpy(new, cp);
|
strcpy(new, cp);
|
||||||
return new;
|
return new;
|
||||||
|
|
Loading…
Reference in a new issue