use the mkdepend from the normal mozilla tree. it's got more portability foo in it.

git-svn-id: svn://10.0.0.236/trunk@16123 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
toshok%hungry.com
1998-12-10 08:02:59 +00:00
parent ceeb2e1e6d
commit a35c8545a2
9 changed files with 71 additions and 83 deletions

View File

@@ -30,7 +30,7 @@ CSRCS = \
pr.c \
$(NULL)
CFLAGS += -DINCLUDEDIR=\"/usr/include\" -DOBJSUFFIX=\".$(OBJ_SUFFIX)\" -DNeedVarargsPrototypes
CFLAGS += -DINCLUDEDIR=\"/usr/include\" -DOBJSUFFIX=\".$(OBJ_SUFFIX)\" -DNeedVarargsPrototypes $(X11INCLUDES)
MKDEPENDENCIES =
include $(DEPTH)/config/rules.mk

View File

@@ -59,7 +59,7 @@ extern char slotab[];
struct filepointer *currentfile;
struct inclist *currentinc;
int cppsetup(line, filep, inc)
cppsetup(line, filep, inc)
register char *line;
register struct filepointer *filep;
register struct inclist *inc;
@@ -137,6 +137,7 @@ _my_if_errors (ip, cp, expecting)
const char *cp;
const char *expecting;
{
#ifdef DEBUG_MKDEPEND
struct _parse_data *pd = (struct _parse_data *) ip->data;
int lineno = pd->filep->f_line;
char *filename = pd->inc->i_file;
@@ -155,6 +156,7 @@ _my_if_errors (ip, cp, expecting)
putc (' ', stderr);
}
fprintf (stderr, "^--- expecting %s\n", expecting);
#endif /* DEBUG_MKDEPEND */
return NULL;
}
@@ -215,7 +217,6 @@ _my_eval_variable (ip, var, len)
}
int
cppsetup(line, filep, inc)
register char *line;
register struct filepointer *filep;

View File

@@ -26,10 +26,23 @@ in this Software without prior written authorization from the X Consortium.
*/
#include <stdlib.h>
#include <string.h>
#ifndef NO_X11
#include <X11/Xosdefs.h>
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
#ifndef SUNOS4
#include <X11/Xfuncproto.h>
#endif /* SUNOS4 */
#endif /* NO_X11 */
#include <stdio.h>
#include <ctype.h>
#ifndef X_NOT_POSIX
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#endif
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -129,29 +142,9 @@ struct symtab *fdefined();
struct filepointer *getfile();
struct inclist *newinclude();
struct inclist *inc_path();
void remove_dotdot(char *path);
int isdot(char *p);
int isdotdot(char *p);
int issymbolic(char *dir, char *component);
void define2(char *name, char *val, struct inclist *file);
void pr(struct inclist *ip, char *file, char *base);
void included_by(struct inclist *ip, struct inclist *newfile);
int find_includes(struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, boolean failOK);
void freefile(struct filepointer *fp);
int deftype (char *line, struct filepointer *filep, struct inclist *file_red, struct inclist *file, int parse_it);
void recursive_pr_include(struct inclist *head, char *file, char *base);
void inc_clean ();
void define(char *def, struct inclist *file);
void redirect(char *line, char *makefile);
int gobble(struct filepointer *filep, struct inclist *file, struct inclist *file_red);
void undefine(char *symbol, struct inclist *file);
void add_include(struct filepointer *filep, struct inclist *file, struct inclist *file_red, char *include, boolean dot, int failOK);
int match(char *str, char **list);
int zero_value(char *exp, struct filepointer *filep, struct inclist *file_red);
int cppsetup(char *line, struct filepointer *filep, struct inclist *inc);
#if NeedVarargsPrototypes
extern void fatalerr(char *, ...);
extern void warning(char *, ...);
extern void warning1(char *, ...);
extern fatalerr(char *, ...);
extern warning(char *, ...);
extern warning1(char *, ...);
#endif

View File

@@ -57,13 +57,9 @@
* ParseIfExpression parse a string for #if
*/
#include <stdlib.h>
#include <string.h>
#include "ifparser.h"
#include <ctype.h>
extern int remove_dotdot(char *path);
/****************************************************************************
Internal Macros and Utilities for Parser
****************************************************************************/
@@ -132,10 +128,6 @@ parse_value (g, cp, valp)
case '(':
DO (cp = ParseIfExpression (g, cp + 1, valp));
SKIPSPACE (cp);
if (*cp == '?')
while (*cp != ')')
cp++;
if (*cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
@@ -220,7 +212,11 @@ parse_product (g, cp, valp)
case '/':
DO (cp = parse_product (g, cp + 1, &rightval));
*valp = (*valp / rightval);
/* Do nothing in the divide-by-zero case. */
if (rightval) {
*valp = (*valp / rightval);
}
break;
case '%':

View File

@@ -235,7 +235,7 @@ in this Software without prior written authorization from the X Consortium.
#ifdef _CRAY
#define DEFAULT_CPP "/lib/pcpp"
#endif
#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#define DEFAULT_CPP "/usr/libexec/cpp"
#endif
#ifdef MACH
@@ -273,7 +273,7 @@ char *cpp_argv[ARGUMENTS] = {
#ifdef unix
"-Uunix", /* remove unix symbol so that filename unix.c okay */
#endif
#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(MACH)
#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(MACH)
# ifdef __i386__
"-D__i386__",
# endif
@@ -716,6 +716,9 @@ struct symtab predefs[] = {
#ifdef __NetBSD__
{"__NetBSD__", "1"},
#endif
#ifdef __OpenBSD__
{"__OpenBSD__", "1"},
#endif
#ifdef __EMX__
{"__EMX__", "1"},
#endif

View File

@@ -122,7 +122,7 @@ struct inclist *inc_path(file, include, dot)
* Any of the 'x/..' sequences within the name can be eliminated.
* (but only if 'x' is not a symbolic link!!)
*/
void remove_dotdot(path)
remove_dotdot(path)
char *path;
{
register char *end, *from, *to, **cp;
@@ -191,7 +191,7 @@ void remove_dotdot(path)
strcpy(path, newpath);
}
int isdot(p)
isdot(p)
register char *p;
{
if(p && *p++ == '.' && *p++ == '\0')
@@ -199,7 +199,7 @@ int isdot(p)
return(FALSE);
}
int isdotdot(p)
isdotdot(p)
register char *p;
{
if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
@@ -207,7 +207,7 @@ int isdotdot(p)
return(FALSE);
}
int issymbolic(dir, component)
issymbolic(dir, component)
register char *dir, *component;
{
#ifdef S_IFLNK
@@ -253,7 +253,7 @@ struct inclist *newinclude(newfile, incstring)
return(ip);
}
void included_by(ip, newfile)
included_by(ip, newfile)
register struct inclist *ip, *newfile;
{
register i;
@@ -278,7 +278,7 @@ void included_by(ip, newfile)
newfile->i_file[i-1] == 'c' &&
newfile->i_file[i-2] == '.'))
{
/* only bitch if ip has */
/* only complain if ip has */
/* no #include SYMBOL lines */
/* and is not a .c file */
if (warn_multiple)
@@ -298,7 +298,7 @@ void included_by(ip, newfile)
ip->i_list[ ip->i_listlen-1 ] = newfile;
}
void inc_clean ()
inc_clean ()
{
register struct inclist *ip;

View File

@@ -50,10 +50,6 @@ in this Software without prior written authorization from the X Consortium.
#include <stdarg.h>
#endif
#ifndef _WIN32
#include <unistd.h>
#endif
#ifdef MINIX
#define USE_CHMOD 1
#endif
@@ -117,7 +113,7 @@ catch (sig)
fatalerr ("got signal %d\n", sig);
}
#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__EMX__) || defined(Lynx_22) || defined(FREEBSD)
#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__EMX__) || defined(Lynx_22)
#define USGISH
#endif
@@ -131,7 +127,6 @@ catch (sig)
struct sigaction sig_act;
#endif /* USGISH */
int
main(argc, argv)
int argc;
char **argv;
@@ -360,6 +355,7 @@ main(argc, argv)
#ifdef SIGSYS
signal (SIGSYS, catch);
#endif
signal (SIGFPE, catch);
#else
sig_act.sa_handler = catch;
#ifdef _POSIX_SOURCE
@@ -451,7 +447,7 @@ struct filepointer *getfile(file)
return(content);
}
void freefile(fp)
freefile(fp)
struct filepointer *fp;
{
free(fp->f_base);
@@ -467,7 +463,7 @@ char *copy(str)
return(p);
}
int match(str, list)
match(str, list)
register char *str, **list;
{
register int i;
@@ -579,7 +575,7 @@ int rename (from, to)
}
#endif /* USGISH */
void redirect(line, makefile)
redirect(line, makefile)
char *line,
*makefile;
{
@@ -615,20 +611,15 @@ void redirect(line, makefile)
unlink(backup);
#if defined(WIN32) || defined(__EMX__)
fclose(fdin);
/* Remove backup file if it already exists */
_unlink(backup);
#endif
if (rename(makefile, backup) < 0)
fatalerr("cannot rename %s to %s\n", makefile, backup);
#if defined(WIN32) || defined(__EMX__)
if ((fdin = fopen(backup, "r")) == NULL)
fatalerr("cannot open \"%s\"\n", backup);
#endif
if ((fdout = freopen(makefile, "w", stdout)) == NULL)
fatalerr("cannot open \"%s\"\n", makefile);
fatalerr("cannot open \"%s\"\n", backup);
len = strlen(line);
while (!found && fgets(buf, BUFSIZ, fdin)) {
if (*buf == '#' && strncmp(line, buf, len) == 0)
@@ -654,10 +645,10 @@ void redirect(line, makefile)
}
#if NeedVarargsPrototypes
void fatalerr(char *msg, ...)
fatalerr(char *msg, ...)
#else
/*VARARGS*/
void fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
char *msg;
#endif
{
@@ -676,13 +667,14 @@ void fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
}
#if NeedVarargsPrototypes
void warning(char *msg, ...)
warning(char *msg, ...)
#else
/*VARARGS0*/
void warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
char *msg;
#endif
{
#ifdef DEBUG_MKDEPEND
#if NeedVarargsPrototypes
va_list args;
#endif
@@ -694,16 +686,18 @@ void warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
#else
fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
#endif
#endif /* DEBUG_MKDEPEND */
}
#if NeedVarargsPrototypes
void warning1(char *msg, ...)
warning1(char *msg, ...)
#else
/*VARARGS0*/
void warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
char *msg;
#endif
{
#ifdef DEBUG_MKDEPEND
#if NeedVarargsPrototypes
va_list args;
va_start(args, msg);
@@ -712,4 +706,5 @@ void warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
#else
fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
#endif
#endif /* DEBUG_MKDEPEND */
}

View File

@@ -31,7 +31,7 @@ in this Software without prior written authorization from the X Consortium.
extern char *directives[];
extern struct inclist maininclist;
int find_includes(filep, file, file_red, recursion, failOK)
find_includes(filep, file, file_red, recursion, failOK)
struct filepointer *filep;
struct inclist *file, *file_red;
int recursion;
@@ -41,7 +41,7 @@ int find_includes(filep, file, file_red, recursion, failOK)
register int type;
boolean recfailOK;
while ((line = getline(filep))) {
while (line = getline(filep)) {
switch(type = deftype(line, filep, file_red, file, TRUE)) {
case IF:
doif:
@@ -156,14 +156,14 @@ int find_includes(filep, file, file_red, recursion, failOK)
return(-1);
}
int gobble(filep, file, file_red)
gobble(filep, file, file_red)
register struct filepointer *filep;
struct inclist *file, *file_red;
{
register char *line;
register int type;
while ((line = getline(filep))) {
while (line = getline(filep)) {
switch(type = deftype(line, filep, file_red, file, FALSE)) {
case IF:
case IFFALSE:
@@ -360,12 +360,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);
@@ -384,12 +384,12 @@ struct symtab *fdefined(symbol, file, srcfile)
if (file->i_defchecked)
return(NULL);
file->i_defchecked = TRUE;
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))
if (val == NULL && file->i_list)
{
for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
if ((val = fdefined(symbol, *ip, srcfile))) {
if (val = fdefined(symbol, *ip, srcfile)) {
break;
}
}
@@ -403,7 +403,7 @@ struct symtab *fdefined(symbol, file, srcfile)
/*
* Return type based on if the #if expression evaluates to 0
*/
int zero_value(exp, filep, file_red)
zero_value(exp, filep, file_red)
register char *exp;
register struct filepointer *filep;
register struct inclist *file_red;
@@ -414,7 +414,7 @@ int zero_value(exp, filep, file_red)
return(IF);
}
void define(def, file)
define(def, file)
char *def;
struct inclist *file;
{
@@ -434,7 +434,7 @@ void define(def, file)
define2(def, val, file);
}
void define2(name, val, file)
define2(name, val, file)
char *name, *val;
struct inclist *file;
{
@@ -552,7 +552,7 @@ struct symtab *slookup(symbol, file)
return(NULL);
}
void undefine(symbol, file)
undefine(symbol, file)
char *symbol;
register struct inclist *file;
{

View File

@@ -37,7 +37,7 @@ extern boolean printed;
extern boolean verbose;
extern boolean show_where_not;
void add_include(filep, file, file_red, include, dot, failOK)
add_include(filep, file, file_red, include, dot, failOK)
struct filepointer *filep;
struct inclist *file, *file_red;
char *include;
@@ -80,7 +80,7 @@ void add_include(filep, file, file_red, include, dot, failOK)
}
}
void recursive_pr_include(head, file, base)
recursive_pr_include(head, file, base)
register struct inclist *head;
register char *file, *base;
{
@@ -95,7 +95,7 @@ void recursive_pr_include(head, file, base)
recursive_pr_include(head->i_list[ i ], file, base);
}
void pr(ip, file, base)
pr(ip, file, base)
register struct inclist *ip;
char *file, *base;
{