Resolve many build warnings

This patch fixes many warnings from the beginning of the build up to
and including the depend stage. Nearly all warnings should be gone
even with -Wall.
This commit is contained in:
Ulrich Wilkens
2014-09-23 23:16:35 +02:00
committed by Jon Trulson
parent 2bf29e5d63
commit 42e891d9e7
125 changed files with 1926 additions and 1440 deletions

View File

@@ -154,6 +154,7 @@ XCOMM rules: $TOG: Imake.rules /main/227 1998/02/02 12:07:57 kaleb $
* MakeLintSubdirs (dirs,target,subtarget)
* LintSubdirs (dirs)
* MakeLintLibSubdirs (dirs)
* MakeMakeOneSubdirs ()
* MakeMakeSubdirs (dirs,target)
* MakefileSubdirs (dirs)
* CppScriptTarget (dst,src,defs,deplist)
@@ -2298,22 +2299,29 @@ MakeLintSubdirs(dirs,lintlib,lintlib)
/*
* MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
* of the specified step in the build. If $(TOP) is set to an absolute path,
* do not prepend the ../ prefix. This makes running things outside of the
* source tree much easier.
* $(ONESUBDIR)/Makefile exists as a separate, explicit target so that
* clearmake will know what its goal is and do wink-in.
* MakeMakeOneSubdirs - generate rules to recreate $(ONESUBDIR)/Makefile
* as part of the specified step in the build. This separate, explicit target
* exists so that clearmake will know what its goal is and do wink-in.
*/
#ifndef MakeMakeSubdirs
#define MakeMakeSubdirs(dirs,target) @@\
#ifndef MakeMakeOneSubdirs
#define MakeMakeOneSubdirs() @@\
$(ONESUBDIR)/Makefile: @@\
@MakeFlagsToShellFlags(n,executeit="no"); \ @@\
cd $(ONESUBDIR); \ @@\
if [ "$$executeit" != "no" ]; then \ @@\
ImakeSubCmdHelper -DTOPDIR=$(IMAKETOP) -DCURDIR=$(ONECURDIR)$(ONESUBDIR); \ @@\
fi; @@\
@@\
fi;
#endif /* MakeMakeOneSubdirs */
/*
* MakeMakeSubdirs - generate rules to recursively recreate Makefiles as part
* of the specified step in the build. If $(TOP) is set to an absolute path,
* do not prepend the ../ prefix. This makes running things outside of the
* source tree much easier.
*/
#ifndef MakeMakeSubdirs
#define MakeMakeSubdirs(dirs,target) @@\
target:: @@\
-@MakeFlagsToShellFlags(ik,set +e); \ @@\
MakeFlagsToShellFlags(n,executeit="no"); \ @@\
@@ -2380,6 +2388,7 @@ target:: @@\
*/
#ifndef MakefileSubdirs
#define MakefileSubdirs(dirs) @@\
MakeMakeOneSubdirs() @@\
MakeMakeSubdirs(dirs,Makefiles)
#endif /* MakefileSubdirs */

View File

@@ -1048,6 +1048,8 @@ CXXDEPENDINCLUDE != echo | `CcCmd -print-prog-name=cc1plus` -v 2>&1 | \
#define LibraryCplusplusOptions -Wall -Wpointer-arith -Wno-unused -Wno-write-strings -Wno-switch
#endif
#define DependFileName .depend
#define ArchitectureDefines -DOPENBSD_ARCHITECTURE
#define BuildLibPathVar LD_LIBRARY_PATH

View File

@@ -223,7 +223,7 @@ XCOMM $XConsortium: cde.tmpl /main/2 1996/12/04 10:13:09 swick $
# if UseInstalledCDE
# define DtCodeGen dtcodegen
# else
# define DtCodeGen $(CLIENTENVSETUP) $(CDESRC)/dtappbuilder/src/abmf/dtcodegen
# define DtCodeGen $(CLIENTENVSETUP) $(DTCODEGENCAT) $(CDESRC)/dtappbuilder/src/abmf/dtcodegen
# endif
#endif

View File

@@ -61,7 +61,7 @@ in this Software without prior written authorization from The Open Group .
int main(void)
{
write(1, imake_ccflags, sizeof(imake_ccflags) - 1);
ssize_t ret = write(1, imake_ccflags, sizeof(imake_ccflags) - 1);
return EXIT_SUCCESS;
}

View File

@@ -405,13 +405,14 @@ main(int argc, char *argv[])
tmpMakefile = Makefile;
else {
tmpMakefile = Strdup(tmpMakefile);
mkstemp(tmpMakefile);
int ret = mkstemp(tmpMakefile);
(void) ret;
}
AddMakeArg("-f");
AddMakeArg( tmpMakefile );
sprintf(makeMacro, "MAKE=%s", program);
snprintf(makeMacro, BUFSIZ, "MAKE=%s", program);
AddMakeArg( makeMacro );
sprintf(makefileMacro, "MAKEFILE=%s", Imakefile);
snprintf(makefileMacro, BUFSIZ, "MAKEFILE=%s", Imakefile);
AddMakeArg( makefileMacro );
if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL)
@@ -709,7 +710,8 @@ optional_include(FILE *inFile, const char *defsym, const char *fname)
{
errno = 0;
if (access(fname, R_OK) == 0) {
LogMsg(OverrideWarning, fname);
if(errno)
LogMsg(OverrideWarning, fname);
return (fprintf(inFile, LocalDefineFmt, defsym, fname) < 0 ||
fprintf(inFile, IncludeFmt, defsym) < 0);
}
@@ -780,35 +782,35 @@ parse_utsname(struct utsname *name, const char *fmt, char *result, const char *m
case 's':
if (arg > 0)
*ptr++ = ' ';
strcpy(ptr, name->sysname);
strncpy(ptr, name->sysname, SYS_NMLN);
ptr += strlen(ptr);
break;
case 'n':
if (arg > 0)
*ptr++ = ' ';
strcpy(ptr, name->nodename);
strncpy(ptr, name->nodename, SYS_NMLN);
ptr += strlen(ptr);
break;
case 'r':
if (arg > 0)
*ptr++ = ' ';
strcpy(ptr, name->release);
strncpy(ptr, name->release, SYS_NMLN);
ptr += strlen(ptr);
break;
case 'v':
if (arg > 0)
*ptr++ = ' ';
strcpy(ptr, name->version);
strncpy(ptr, name->version, SYS_NMLN);
ptr += strlen(ptr);
break;
case 'm':
if (arg > 0)
*ptr++ = ' ';
strcpy(ptr, name->machine);
strncpy(ptr, name->machine, SYS_NMLN);
ptr += strlen(ptr);
break;
@@ -823,7 +825,8 @@ parse_utsname(struct utsname *name, const char *fmt, char *result, const char *m
/* Parse the buffer. The sscanf() return value is rarely correct. */
*result = '\0';
(void) sscanf(buf, fmt + arg + 1, result);
int ret = sscanf(buf, fmt + arg + 1, result);
(void) ret;
}
#endif
@@ -993,7 +996,8 @@ get_libc_version(FILE *inFile)
*/
if (readlink (libcso, buf, PATH_MAX) >= 0) {
for (ptr = buf; *ptr && !isdigit (*ptr); ptr++);
(void) sscanf (ptr, "%d.%d.%d", &libcmajor, &libcminor, &libcteeny);
int ret = sscanf (ptr, "%d.%d.%d", &libcmajor, &libcminor, &libcteeny);
(void) ret;
fprintf(inFile, "#define DefaultLinuxCLibMajorVersion %d\n", libcmajor);
fprintf(inFile, "#define DefaultLinuxCLibMinorVersion %d\n", libcminor);
fprintf(inFile, "#define DefaultLinuxCLibTeenyVersion %d\n", libcteeny);
@@ -1014,17 +1018,17 @@ get_libc_version(FILE *inFile)
memset(&aout, '\0', PATH_MAX);
if (!lstat(getenv("TMPDIR"), &sb) && S_ISDIR(sb.st_mode))
strcpy(aout, getenv("TMPDIR"));
strncpy(aout, getenv("TMPDIR"), PATH_MAX);
#ifdef P_tmpdir /* defined by XPG and XOPEN, but don't assume we have it */
else if (!lstat(P_tmpdir, &sb) && S_ISDIR(sb.st_mode))
strcpy(aout, P_tmpdir);
strncpy(aout, P_tmpdir, PATH_MAX);
#endif
else if (!lstat("/tmp", &sb) && S_ISDIR(sb.st_mode))
strcpy(aout, "/tmp");
strncpy(aout, "/tmp", PATH_MAX);
else
abort();
strcpy(aout+strlen(aout), "/imaketmp.XXXXXX");
strncpy(aout+strlen(aout), "/imaketmp.XXXXXX", 16);
if ((fd = mkstemp(aout)) == -1)
abort ();
@@ -1051,7 +1055,7 @@ get_libc_version(FILE *inFile)
abort ();
while (fgets (command, len, fp))
fprintf (inFile, command);
fprintf (inFile, "%s", command);
len = pclose (fp);
remove (aout);
@@ -1073,7 +1077,8 @@ get_ld_version(FILE *inFile)
c = fgetc (ldprog);
} while (c != EOF && !isdigit (c));
ungetc (c, ldprog);
(void) fscanf (ldprog, "%d.%d", &ldmajor, &ldminor);
int ret = fscanf (ldprog, "%d.%d", &ldmajor, &ldminor);
(void) ret;
fprintf(inFile, "#define DefaultLinuxBinUtilsMajorVersion %d\n",
ldmajor * 10 + ldminor);
pclose (ldprog);
@@ -1097,15 +1102,16 @@ get_sun_compiler_versions(FILE *inFile)
char* vptr;
struct stat sb;
FILE* ccproc;
int ret;
if (lstat (sunpro_cc, &sb) == 0) {
strcpy (cmd, sunpro_cc);
strcat (cmd, " -V 2>&1");
strncpy (cmd, sunpro_cc, PATH_MAX);
strncat (cmd, " -V 2>&1", 8);
if ((ccproc = popen (cmd, "r")) != NULL) {
if (fgets (buf, PATH_MAX, ccproc) != NULL) {
vptr = strrchr (buf, 'C');
for (; !isdigit(*vptr); vptr++);
(void) sscanf (vptr, "%d.%d", &cmajor, &cminor);
ret = sscanf (vptr, "%d.%d", &cmajor, &cminor);
fprintf (inFile,
"#define DefaultSunProCCompilerMajorVersion %d\n",
cmajor);
@@ -1118,13 +1124,13 @@ get_sun_compiler_versions(FILE *inFile)
}
}
if (lstat (sunpro_CC, &sb) == 0) {
strcpy (cmd, sunpro_CC);
strcat (cmd, " -V 2>&1");
strncpy (cmd, sunpro_CC, PATH_MAX);
strncat (cmd, " -V 2>&1", 8);
if ((ccproc = popen (cmd, "r")) != NULL) {
if (fgets (buf, PATH_MAX, ccproc) != NULL) {
vptr = strrchr (buf, 'C');
for (; !isdigit(*vptr); vptr++);
(void) sscanf (vptr, "%d.%d", &cmajor, &cminor);
ret = sscanf (vptr, "%d.%d", &cmajor, &cminor);
fprintf (inFile,
"#define DefaultSunProCplusplusCompilerMajorVersion %d\n",
cmajor);
@@ -1136,6 +1142,7 @@ get_sun_compiler_versions(FILE *inFile)
pclose (ccproc);
}
}
(void) ret;
}
#endif
@@ -1159,12 +1166,12 @@ get_gcc_incdir(FILE *inFile)
buf[0] = '\0';
for (i = 0; i < sizeof gcc_path / sizeof gcc_path[0]; i++) {
if (lstat (gcc_path[i], &sb) == 0) {
strcpy (cmd, gcc_path[i]);
strcat (cmd, " --print-libgcc-file-name");
strncpy (cmd, gcc_path[i], PATH_MAX - 25);
strncpy (cmd + strlen(cmd), " --print-libgcc-file-name", 25);
if ((gccproc = popen (cmd, "r")) != NULL) {
if (fgets (buf, PATH_MAX, gccproc) != NULL) {
ptr = strstr (buf, "libgcc.a");
if (ptr) strcpy (ptr, "include");
if (ptr) strncpy (ptr, "include", 7);
}
(void) pclose (gccproc);
break;
@@ -1262,7 +1269,7 @@ cppit(const char *imakefile, const char *template, const char *masterc, FILE *ou
fprintf(inFile, IncludeFmt, ImakeTmplSym) < 0 ||
optional_include(inFile, "IMAKE_ADMIN_MACROS", "adminmacros") ||
optional_include(inFile, "IMAKE_LOCAL_MACROS", "localmacros") ||
fflush(inFile) ||
fflush(inFile) ||
fclose(inFile))
LogFatal("Cannot write to %s.", masterc);
/*
@@ -1334,7 +1341,8 @@ CleanCppInput(char *imakefile)
strcmp(ptoken, "undef")) {
if (outFile == NULL) {
tmpImakefile = Strdup(tmpImakefile);
mkstemp(tmpImakefile);
int ret = mkstemp(tmpImakefile);
(void) ret;
outFile = fopen(tmpImakefile, "w");
if (outFile == NULL)
LogFatal("Cannot open %s for write.",
@@ -1413,10 +1421,10 @@ isempty(char *line)
if (*pend == 'l' && pend[1] == 'i' && pend[2] == 'n' &&
pend[3] == 'e' && pend[4] == ' ')
pend += 5;
if (isdigit(*pend)) {
if (isdigit((int)*pend)) {
do {
pend++;
} while (isdigit(*pend));
} while (isdigit((int)*pend));
if (*pend == '\n' || *pend == '\0')
return(TRUE);
if (*pend++ == ' ' && *pend == '"')
@@ -1432,7 +1440,7 @@ isempty(char *line)
(pend[5] == ' ' || pend[5] == '\t' || pend[5] == '\0'))
{
*pend = '#';
strcpy(pend+1, pend+5);
strncpy(pend+1, pend+5, 1);
}
#ifdef MAGIC_MAKE_VARS
if (*pend == 'X' && pend[1] == 'V' && pend[2] == 'A' &&
@@ -1445,7 +1453,7 @@ isempty(char *line)
pend[7] >= '0' && pend[7] <= '9')
{
i = pend[7] - '0';
sprintf(varbuf, "%0.4d", xvariable);
snprintf(varbuf, 5, "%0.4d", xvariable);
strncpy(pend+4, varbuf, 4);
xvariables[i] = xvariable;
xvariable = (xvariable + 1) % 10000;
@@ -1455,7 +1463,7 @@ isempty(char *line)
pend[7] <= '9')
{
i = pend[7] - '0';
sprintf(varbuf, "%0.4d", xvariables[i]);
snprintf(varbuf, 5, "%0.4d", xvariables[i]);
strncpy(pend+4, varbuf, 4);
}
}
@@ -1504,7 +1512,8 @@ ReadLine(FILE *tmpfd, const char *tmpfname)
if (! tmpfd)
LogFatal("cannot reopen %s.", tmpfname);
#else /* !SYSV */
ftruncate(fileno(tmpfd), (off_t) 0);
int ret = ftruncate(fileno(tmpfd), (off_t) 0);
(void) ret;
#endif /* !SYSV */
initialized = TRUE;
fprintf (tmpfd, "# Makefile generated by imake - do not edit!\n");
@@ -1515,7 +1524,8 @@ ReadLine(FILE *tmpfd, const char *tmpfname)
for (p1 = pline; p1 < end; p1++) {
if (*p1 == '@' && *(p1+1) == '@'
/* ignore ClearCase version-extended pathnames */
&& !(p1 != pline && !isspace(*(p1-1)) && *(p1+2) == '/'))
&& !(p1 != pline && !isspace((int)*(p1-1))
&& *(p1+2) == '/'))
{ /* soft EOL */
*p1++ = '\0';
p1++; /* skip over second @ */
@@ -1652,6 +1662,6 @@ Strdup(const char *cp)
{
char *new = Emalloc(strlen(cp) + 1);
strcpy(new, cp);
strncpy(new, cp, strlen(cp) + 1);
return new;
}

View File

@@ -161,7 +161,7 @@ my_if_errors (ip, cp, expecting)
int prefixlen;
int i;
sprintf (prefix, "\"%s\":%d", filename, lineno);
snprintf (prefix, 300, "\"%s\":%d", filename, lineno);
prefixlen = strlen(prefix);
fprintf (stderr, "%s: %s", prefix, pd->line);
i = cp - pd->line;
@@ -224,7 +224,7 @@ my_eval_variable (ip, var, len)
return 0;
do {
var = (*s)->s_value;
if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
if (!isvarfirstletter((int)*var) || !strcmp((*s)->s_name, var))
break;
s = lookup_variable (ip, var, strlen(var));
} while (s);
@@ -235,7 +235,7 @@ my_eval_variable (ip, var, len)
}
cppsetup(line, filep, inc)
int cppsetup(line, filep, inc)
register char *line;
register struct filepointer *filep;
register struct inclist *inc;

View File

@@ -148,6 +148,7 @@ char *malloc();
char *realloc();
#endif
int match();
char *copy();
char *base_name();
char *our_getline();
@@ -155,8 +156,17 @@ struct symtab **slookup();
struct symtab **isdefined();
struct symtab **fdefined();
struct filepointer *getfile();
void included_by();
struct inclist *newinclude();
void inc_clean();
struct inclist *inc_path();
void freefile();
void define2();
void define();
int find_includes();
void recursive_pr_include();
void add_include();
int cppsetup();
#if NeedVarargsPrototypes
extern void fatalerr(char *, ...);

View File

@@ -81,6 +81,8 @@
#include "ifparser.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
/****************************************************************************
@@ -89,8 +91,8 @@
#define DO(val) if (!(val)) return NULL
#define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))
#define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
#define SKIPSPACE(ccc) while (isspace((int)*ccc)) ccc++
#define isvarfirstletter(ccc) (isalpha((int)ccc) || (ccc) == '_')
static const char *
@@ -106,7 +108,7 @@ parse_variable (g, cp, varp)
*varp = cp;
/* EMPTY */
for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
for (cp++; isalnum((int)*cp) || *cp == '_'; cp++) ;
return cp;
}
@@ -120,7 +122,7 @@ parse_number (g, cp, valp)
long base = 10;
SKIPSPACE (cp);
if (!isdigit(*cp))
if (!isdigit((int)*cp))
return CALLFUNC(g, handle_error) (g, cp, "number");
*valp = 0;
@@ -248,7 +250,7 @@ parse_value (g, cp, valp)
return cp + 1;
case 'd':
if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
if (strncmp (cp, "defined", 7) == 0 && !isalnum((int)cp[7])) {
int paren = 0;
int len;
@@ -269,7 +271,7 @@ parse_value (g, cp, valp)
/* fall out */
}
if (isdigit(*cp)) {
if (isdigit((int)*cp)) {
DO (cp = parse_number (g, cp, valp));
} else if (!isvarfirstletter(*cp))
return CALLFUNC(g, handle_error) (g, cp, "variable or number");

View File

@@ -79,7 +79,7 @@ issymbolic(dir, component)
struct stat st;
char buf[ BUFSIZ ], **pp;
sprintf(buf, "%s%s%s", dir, *dir ? "/" : "", component);
snprintf(buf, BUFSIZ, "%s%s%s", dir, *dir ? "/" : "", component);
for (pp=notdotdot; *pp; pp++)
if (strcmp(*pp, buf) == 0)
return (TRUE);
@@ -166,7 +166,7 @@ remove_dotdot(path)
/*
* copy the reconstituted path back to our pointer.
*/
strcpy(path, newpath);
strncpy(path, newpath, BUFSIZ);
}
/*
@@ -299,11 +299,12 @@ struct inclist *inc_path(file, include, dot)
if (*p == '/')
break;
if (p == file)
strcpy(path, include);
strncpy(path, include, BUFSIZ);
else {
strncpy(path, file, (p-file) + 1);
path[ (p-file) + 1 ] = '\0';
strcpy(path + (p-file) + 1, include);
strncpy(path + (p-file) + 1, include,
BUFSIZ - (p-file) - 1);
}
remove_dotdot(path);
if (stat(path, &st) == 0) {
@@ -320,7 +321,7 @@ struct inclist *inc_path(file, include, dot)
*/
if (!found)
for (pp = includedirs; *pp; pp++) {
sprintf(path, "%s/%s", *pp, include);
snprintf(path, BUFSIZ, "%s/%s", *pp, include);
remove_dotdot(path);
if (stat(path, &st) == 0) {
ip = newinclude(path, include);

View File

@@ -148,7 +148,7 @@ catch (sig)
struct sigaction sig_act;
#endif /* USGISH */
main(argc, argv)
int main(argc, argv)
int argc;
char **argv;
{
@@ -491,11 +491,11 @@ char *copy(str)
{
register char *p = (char *)malloc(strlen(str) + 1);
strcpy(p, str);
strncpy(p, str, strlen(str) + 1);
return(p);
}
match(str, list)
int match(str, list)
register char *str, **list;
{
register int i;
@@ -642,7 +642,7 @@ redirect(line, makefile)
stat(makefile, &st);
if ((fdin = fopen(makefile, "r")) == NULL)
fatalerr("cannot open \"%s\"\n", makefile);
sprintf(backup, "%s.bak", makefile);
snprintf(backup, BUFSIZ, "%s.bak", makefile);
unlink(backup);
#ifdef WIN32
fclose(fdin);

View File

@@ -45,6 +45,10 @@ in this Software without prior written authorization from The Open Group.
#include "def.h"
static int deftype();
static int zero_value();
static int merge2defines();
extern char *directives[];
extern struct inclist maininclist;
@@ -56,7 +60,7 @@ gobble(filep, file, file_red)
register char *line;
register int type;
while (line = our_getline(filep)) {
while ((line = our_getline(filep))) {
switch(type = deftype(line, filep, file_red, file, FALSE)) {
case IF:
case IFFALSE:
@@ -189,7 +193,7 @@ int deftype (line, filep, file_red, file, parse_it)
/*
* separate the name of a single symbol.
*/
while (isalnum(*p) || *p == '_')
while (isalnum((int)*p) || *p == '_')
*line++ = *p++;
*line = '\0';
break;
@@ -265,7 +269,7 @@ struct symtab **fdefined(symbol, file, srcfile)
if (file->i_flags & DEFCHECKED)
return(NULL);
file->i_flags |= DEFCHECKED;
if (val = slookup(symbol, file))
if ((val = slookup(symbol, file)))
debug(1,("%s defined in %s as %s\n",
symbol, file->i_file, (*val)->s_value));
if (val == NULL && file->i_list)
@@ -294,12 +298,12 @@ struct symtab **isdefined(symbol, file, srcfile)
{
register struct symtab **val;
if (val = slookup(symbol, &maininclist)) {
if ((val = slookup(symbol, &maininclist))) {
debug(1,("%s defined on command line\n", symbol));
if (srcfile != NULL) *srcfile = &maininclist;
return(val);
}
if (val = fdefined(symbol, file, srcfile))
if ((val = fdefined(symbol, file, srcfile)))
return(val);
debug(1,("%s not defined in %s\n", symbol, file->i_file));
return(NULL);
@@ -314,7 +318,7 @@ zero_value(exp, filep, file_red)
register struct filepointer *filep;
register struct inclist *file_red;
{
if (cppsetup(exp, filep, file_red))
if ((cppsetup(exp, filep, file_red)))
return(IFFALSE);
else
return(IF);
@@ -413,7 +417,7 @@ define(def, file)
/* Separate symbol name and its value */
val = def;
while (isalnum(*val) || *val == '_')
while (isalnum((int)*val) || *val == '_')
val++;
if (*val)
*val++ = '\0';
@@ -549,7 +553,7 @@ find_includes(filep, file, file_red, recursion, failOK)
register int type;
boolean recfailOK;
while (line = our_getline(filep)) {
while ((line = our_getline(filep))) {
switch(type = deftype(line, filep, file_red, file, TRUE)) {
case IF:
doif:

View File

@@ -107,13 +107,13 @@ pr(ip, file, base)
len = strlen(ip->i_file)+1;
if (current_len + len > width || file != lastfile) {
lastfile = file;
sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
ip->i_file);
snprintf(buf, BUFSIZ, "\n%s%s%s: %s", objprefix, base,
objsuffix, ip->i_file);
len = current_len = strlen(buf);
}
else {
buf[0] = ' ';
strcpy(buf+1, ip->i_file);
strncpy(buf+1, ip->i_file, BUFSIZ - 1);
current_len += len;
}
fwrite(buf, len, 1, stdout);

View File

@@ -261,8 +261,8 @@ static void WriteHeader (tagline, phile, abi)
{
FILE* f;
char* tmp;
Table* t;
TableEnt* te;
static void (*headerproc[])() = {
DefaultWriteHeader, ArrayperWriteHeader,
IntelABIWriteHeader, IntelABIWriteHeader,
@@ -284,11 +284,14 @@ static void WriteHeader (tagline, phile, abi)
if (strcmp (prefixstr, "Xm") == 0) {
if ((fileprotstr = malloc (strlen (phile->name) + 3)) == NULL)
exit (1);
(void) sprintf (fileprotstr, "_%s_", phile->name);
(void) snprintf (fileprotstr, strlen (phile->name) + 3,
"_%s_", phile->name);
} else {
if ((fileprotstr = malloc (strlen (phile->name) + strlen (prefixstr) + 3)) == NULL)
exit (1);
(void) sprintf (fileprotstr, "_%s%s_", prefixstr, phile->name);
(void) snprintf (fileprotstr,
strlen (phile->name) + strlen (prefixstr) + 3,
"_%s%s_", prefixstr, phile->name);
}
for (tmp = fileprotstr; *tmp; tmp++) if (*tmp == '.') *tmp = '_';
@@ -404,7 +407,7 @@ static void ArrayperWriteSource (abi)
}
(void) printf ("%s %sConst char %s%s[] = \"%s\";\n",
externdefstr, conststr ? conststr : prefixstr,
te->left, te->right);
prefixstr, te->left, te->right);
}
}
}
@@ -520,7 +523,8 @@ static void DoLine(buf)
exit(1);
if ((phile->name = malloc (strlen (buf + strlen (file_str)) + 1)) == NULL)
exit(1);
(void) strcpy (phile->name, buf + strlen (file_str) + 1);
(void) strncpy (phile->name, buf + strlen (file_str) + 1,
strlen (buf + strlen (file_str)) + 1);
phile->table = NULL;
phile->tablecurrent = NULL;
phile->tabletail = &phile->table;
@@ -539,7 +543,8 @@ static void DoLine(buf)
exit(1);
if ((table->name = malloc (strlen (buf + strlen (table_str)) + 1)) == NULL)
exit(1);
(void) strcpy (table->name, buf + strlen (table_str) + 1);
(void) strncpy (table->name, buf + strlen (table_str) + 1,
strlen (buf + strlen (table_str)) + 1);
table->tableent = NULL;
table->tableentcurrent = NULL;
table->tableenttail = &table->tableent;
@@ -554,27 +559,32 @@ static void DoLine(buf)
case X_PREFIX_TOKEN:
if ((prefixstr = malloc (strlen (buf + strlen (prefix_str)) + 1)) == NULL)
exit(1);
(void) strcpy (prefixstr, buf + strlen (prefix_str) + 1);
(void) strncpy (prefixstr, buf + strlen (prefix_str) + 1,
strlen (buf + strlen (prefix_str)) + 1);
break;
case X_FEATURE_TOKEN:
if ((featurestr = malloc (strlen (buf + strlen (feature_str)) + 1)) == NULL)
exit(1);
(void) strcpy (featurestr, buf + strlen (feature_str) + 1);
(void) strncpy (featurestr, buf + strlen (feature_str) + 1,
strlen (buf + strlen (feature_str)) + 1);
break;
case X_EXTERNREF_TOKEN:
if ((externrefstr = malloc (strlen (buf + strlen (externref_str)) + 1)) == NULL)
exit(1);
(void) strcpy (externrefstr, buf + strlen (externref_str) + 1);
(void) strncpy (externrefstr, buf + strlen (externref_str) + 1,
strlen (buf + strlen (externref_str)) + 1);
break;
case X_EXTERNDEF_TOKEN:
if ((externdefstr = malloc (strlen (buf + strlen (externdef_str)) + 1)) == NULL)
exit(1);
(void) strcpy (externdefstr, buf + strlen (externdef_str) + 1);
(void) strncpy (externdefstr, buf + strlen (externdef_str) + 1,
strlen (buf + strlen (externdef_str)) + 1);
break;
case X_CTMPL_TOKEN:
if ((ctmplstr = malloc (strlen (buf + strlen (ctmpl_str)) + 1)) == NULL)
exit(1);
(void) strcpy (ctmplstr, buf + strlen (ctmpl_str) + 1);
(void) strncpy (ctmplstr, buf + strlen (ctmpl_str) + 1,
strlen (buf + strlen (ctmpl_str)) + 1);
break;
case X_HTMPL_TOKEN:
if ((filecurrent->tmpl = fopen (buf + strlen (htmpl_str) + 1, "r")) == NULL) {
@@ -586,7 +596,8 @@ static void DoLine(buf)
case X_CONST_TOKEN:
if ((conststr = malloc (strlen (buf + strlen (const_str)) + 1)) == NULL)
exit(1);
(void) strcpy (conststr, buf + strlen (const_str) + 1);
(void) strncpy (conststr, buf + strlen (const_str) + 1,
strlen (buf + strlen (const_str)) + 1);
break;
default:
{
@@ -596,13 +607,13 @@ static void DoLine(buf)
int rlen;
int len;
if (right = index(buf, ' '))
if ((right = index(buf, ' ')))
*right++ = 0;
else
right = buf + 1;
if (buf[0] == 'H') {
strcpy (lbuf, prefixstr);
strcat (lbuf, right);
strncpy (lbuf, prefixstr, 1024);
strncat (lbuf, right, strlen(right));
right = lbuf;
}
@@ -612,10 +623,10 @@ static void DoLine(buf)
if ((tableent = (TableEnt*)malloc(sizeof(TableEnt) + len)) == NULL)
exit(1);
tableent->left = (char *)(tableent + 1);
strcpy(tableent->left, buf);
strncpy(tableent->left, buf, llen);
if (llen != len) {
tableent->right = tableent->left + llen;
strcpy(tableent->right, right);
strncpy(tableent->right, right, rlen);
} else {
tableent->right = tableent->left + 1;
}